From 2ce5b23ec55d7069fdc7311f2289f2dff2d1c75f Mon Sep 17 00:00:00 2001 From: Saba Fazlali Date: Thu, 8 Feb 2024 19:55:26 +0100 Subject: [PATCH] fix running bug --- CMakeLists.txt | 33 +++++++++++++++++++++++++++++++++ src/main/c/Pong/pong.c | 12 ++++++------ 2 files changed, 39 insertions(+), 6 deletions(-) create mode 100644 CMakeLists.txt diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..62043bc --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,33 @@ +cmake_minimum_required(VERSION 3.26) +project(arcade C) + +set(CMAKE_C_STANDARD 11) + +include_directories(src/main/c) +include_directories(src/main/c/GameTic_Tac_Toe) +include_directories(src/main/c/Hangman) +include_directories(src/main/c/Minesweeper) +include_directories(src/main/c/Pong) +include_directories(src/main/c/Snake) + +add_executable(arcade + src/main/c/GameTic_Tac_Toe/tictactoe.c + src/main/c/GameTic_Tac_Toe/tictactoe.h + src/main/c/Hangman/drawHangman.c + src/main/c/Hangman/drawHangman.h + src/main/c/Hangman/initializeHangman.c + src/main/c/Hangman/initializeHangman.h + src/main/c/Hangman/playHangman.c + src/main/c/Hangman/playHangman.h + src/main/c/Hangman/word_selector.c + src/main/c/Hangman/word_selector.h + src/main/c/Minesweeper/minesweeper_start.c + src/main/c/Minesweeper/minesweeper_start.h + src/main/c/Pong/pong.c + src/main/c/Pong/pong.h + src/main/c/Snake/get_character.c + src/main/c/Snake/get_character.h + src/main/c/Snake/snake_start.c + src/main/c/Snake/snake_start.h + src/main/c/main.c + src/main/c/main.h) diff --git a/src/main/c/Pong/pong.c b/src/main/c/Pong/pong.c index 190f4c8..66476ad 100644 --- a/src/main/c/Pong/pong.c +++ b/src/main/c/Pong/pong.c @@ -55,7 +55,7 @@ void drawField(int paddle1PositionY, int paddle2PositionY, Ball ball, int score1 printf("Drücken Sie 'q', um das Spiel zu beenden.\n"); } -int kbhit(void){ +int kb_hit(void){ struct termios oldt, newt; int ch, oldf; @@ -78,7 +78,7 @@ int kbhit(void){ return 0; } -int getch(void) { +int get_ch(void) { int ch; while ((ch = getchar()) == '\n'); @@ -157,8 +157,8 @@ int pong(){ while (score1 < maxScore && score2 < maxScore) { //Steuerung für Schläger 1 - if (!isPaused && kbhit()){ - char input = getch(); + if (!isPaused && kb_hit()){ + char input = get_ch(); if (input == 'w' && paddle1PositionY > 1) { paddle1PositionY--; @@ -174,8 +174,8 @@ int pong(){ } //Steuerung für Schläger 2 - if (!isPaused && kbhit()){ - char input = getch(); + if (!isPaused && kb_hit()){ + char input = get_ch(); if (input == 'i' && paddle2PositionY > 1){ paddle2PositionY--; } else if (input == 'k' && paddle2PositionY < HEIGHT - PADDLE_LENGTH - 1){