Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
guzel.khuziakhmetova committed Aug 21, 2024
2 parents d463b79 + d7241d3 commit e74c92a
Show file tree
Hide file tree
Showing 8 changed files with 9 additions and 298 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
*.user
*.userosscache
*.sln.docstates
*.db

# User-specific files (MonoDevelop/Xamarin Studio)
*.userprefs
Expand Down
2 changes: 0 additions & 2 deletions client/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import ShowScores from './views/ShowScores';
import Settings from './views/Settings';
import CreateGame from './views/CreateGame';
import JoinGame from './views/JoinGame';
import EnterSessionId from './views/EnterSessionId';

const App = () => {
const [settings, setSettings] = useState({
Expand All @@ -30,7 +29,6 @@ const App = () => {
<Route path="/settings" element={<Settings />} />
<Route path="/create-game" element={<CreateGame onSubmit={handleCreateGameSubmit} />} /> {/* Stelle sicher, dass onSubmit übergeben wird */}
<Route path="/join/:sessionId" element={<JoinGame />} />
<Route path="/enter-session" element={<EnterSessionId />} />
</Routes>
</Router>
);
Expand Down
27 changes: 1 addition & 26 deletions client/src/components/QuestionDialog.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,5 @@
import React, { useEffect, useState, useCallback, useRef } from "react";
import { Question, QuestionDialogProps, gamepad } from "../utils/types";
import {
addGamePadListener,
isDownPressed,
isUpPressed,
removeGamePadListener,
} from "../utils/gamepad";
import { gameDefaults } from "../views/Game";
import correctSound from "../assets/correct.mp3";
import wrongSound from "../assets/wrong.mp3";
Expand Down Expand Up @@ -82,33 +76,14 @@ const QuestionDialogCmp: React.FC<QuestionDialogProps> = ({
[handleSpace]
);

const gamePadhandler = useCallback(
(input: gamepad) => {
if (input.type === "button" && input.pressed) {
handleSpace();
return;
}

if (isDownPressed(input)) {
setActiveIndex((prevIndex) => (prevIndex > 0 ? prevIndex - 1 : 0));
}

if (isUpPressed(input)) {
setActiveIndex((prevIndex) => (prevIndex < 3 ? prevIndex + 1 : 3));
}
},
[handleSpace]
);

useEffect(() => {
window.addEventListener("keydown", handleKeyPress);
const padIndex = addGamePadListener(gamePadhandler);

return () => {
window.removeEventListener("keydown", handleKeyPress);
removeGamePadListener(gamePadhandler, padIndex);
};
}, [handleKeyPress, gamePadhandler]);
}, [handleKeyPress]);

return (
<div className="hero min-h-screen bg-base-300 fixed z-20 top-0 opacity-95 backdrop-blur-md">
Expand Down
125 changes: 0 additions & 125 deletions client/src/utils/gamepad.ts

This file was deleted.

109 changes: 0 additions & 109 deletions client/src/views/EnterSessionId.tsx

This file was deleted.

36 changes: 0 additions & 36 deletions client/src/views/Home.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,6 @@ import backgroundMusic from "../assets/game.mp3";
import valuehero from "../assets/valuehero.png";
import valuehero2 from "../assets/valuehero2.png";
import AudioComponent from "../components/Audio";
import {
addGamePadListener,
isDownPressed,
isLeftPressed,
isRightPressed,
isUpPressed,
removeGamePadListener,
} from "../utils/gamepad";
import { playSound } from "../utils/board";

const state: any = {
Expand Down Expand Up @@ -82,37 +74,9 @@ const Home: React.FC<HomeProps> = ({ }) => {

window.addEventListener("keydown", handleKeyPress);

const handleGamepad = (input: gamepad) => {
if (input.type === "button" && input.pressed) {
handlePress();
return;
}

if (isDownPressed(input)) {
const newIndex = state.activeIndex > 0 ? state.activeIndex - 1 : 0;
setActiveIndex(newIndex);
}

if (isUpPressed(input)) {
const newIndexD = state.activeIndex < 1 ? state.activeIndex + 1 : 1;
setActiveIndex(newIndexD);
}

if (isRightPressed(input)) {
const newIndexR = state.gameMode == 0 ? state.gameMode + 1 : 0;
setGameMode(newIndexR);
}

if (isLeftPressed(input)) {
const newIndexR = state.gameMode == 1 ? state.gameMode - 1 : 0;
setGameMode(newIndexR);
}
};

const padIndex = addGamePadListener(handleGamepad);
return () => {
window.removeEventListener("keydown", handleKeyPress);
removeGamePadListener(handleGamepad, padIndex);
};
}, []);

Expand Down
Binary file removed service/src/PingPong/PingPong.db
Binary file not shown.
7 changes: 7 additions & 0 deletions service/src/PingPong/appsettings.Development.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,12 @@
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
},
"AllowedHosts": "*",
"SQLiteConfiguration": {
"ConnectionString": "Data Source=PingPong.db; Version=3;"
},
"AppInformation":{
"Version": "0.0.1"
}
}

0 comments on commit e74c92a

Please sign in to comment.