From 3fe1df697c9376e1dae7ca6cf658a4bac19b6c94 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Th=C3=A9ophyl=20Hoguet?= Date: Fri, 18 Mar 2022 16:07:00 +0100 Subject: [PATCH 1/2] SDL2 on model.h --- model.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/model.h b/model.h index 056c8ce..ccebb8c 100644 --- a/model.h +++ b/model.h @@ -3,7 +3,7 @@ #ifndef MODEL_H #define MODEL_H -#include +#include #include #include From 6db4e00068a0d19a750e2bcc3fe9ab99999f4563 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Th=C3=A9ophyl=20Hoguet?= Date: Fri, 18 Mar 2022 16:24:26 +0100 Subject: [PATCH 2/2] window functionnal --- .vscode/launch.json | 25 +++++++++++++++++++++++++ CMakeLists.txt | 20 +++++++++++++++++--- model.c | 27 ++++++++++++++------------- 3 files changed, 56 insertions(+), 16 deletions(-) diff --git a/.vscode/launch.json b/.vscode/launch.json index 9318f8b..adf3b44 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -57,6 +57,31 @@ ], "preLaunchTask": "make_build" }, + { + "name": "(gdb) game_sdl", + "type": "cppdbg", + "request": "launch", + "program": "${workspaceFolder}/build/game_sdl", + "args": [], + "stopAtEntry": false, + "cwd": "${fileDirname}", + "environment": [], + "externalConsole": false, + "MIMode": "gdb", + "setupCommands": [ + { + "description": "Enable pretty-printing for gdb", + "text": "-enable-pretty-printing", + "ignoreFailures": true + }, + { + "description": "Set Disassembly Flavor to Intel", + "text": "-gdb-set disassembly-flavor intel", + "ignoreFailures": true + } + ], + "preLaunchTask": "make_build" + }, { "name": "(gdb) debug tests", "type": "cppdbg", diff --git a/CMakeLists.txt b/CMakeLists.txt index 709d96f..3f5f802 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -31,6 +31,20 @@ set(CMAKE_C_FLAGS "-std=c99 -Wall") set(CMAKE_C_FLAGS_DEBUG "-g --coverage -pthread -Wextra -Wunused-parameter -Wpedantic -Werror") # use CMake option: -DCMAKE_BUILD_TYPE=DEBUG set(CMAKE_C_FLAGS_RELEASE "-O3 -DNDEBUG") # use CMake option: -DCMAKE_BUILD_TYPE=RELEASE +######################### COPY IMGAES ######################### + +file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/img/lightbulb_red.png DESTINATION ${CMAKE_CURRENT_BINARY_DIR}) +file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/img/lightbulb_white.png DESTINATION ${CMAKE_CURRENT_BINARY_DIR}) +file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/img/redo_down.png DESTINATION ${CMAKE_CURRENT_BINARY_DIR}) +file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/img/redo_up.png DESTINATION ${CMAKE_CURRENT_BINARY_DIR}) +file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/img/restart_up.png DESTINATION ${CMAKE_CURRENT_BINARY_DIR}) +file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/img/restart_down.png DESTINATION ${CMAKE_CURRENT_BINARY_DIR}) +file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/img/undo_down.png DESTINATION ${CMAKE_CURRENT_BINARY_DIR}) +file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/img/undo_up.png DESTINATION ${CMAKE_CURRENT_BINARY_DIR}) +file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/img/solve_up.png DESTINATION ${CMAKE_CURRENT_BINARY_DIR}) +file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/img/solve_down.png DESTINATION ${CMAKE_CURRENT_BINARY_DIR}) +file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/arial.ttf DESTINATION ${CMAKE_CURRENT_BINARY_DIR}) + ############################# SRC ############################# # game_text @@ -46,9 +60,9 @@ add_executable(game_solve game_solve.c) target_link_libraries(game_solve game) # game_sdl - include_directories(${SDL2_ALL_INC}) - add_executable(game_sdl main.c model.c) - target_link_libraries(game_sdl game ${SDL2_ALL_LIBS} m) +include_directories(${SDL2_ALL_INC}) +add_executable(game_sdl main.c model.c) +target_link_libraries(game_sdl game ${SDL2_ALL_LIBS} m) # libgame add_library (game game.c game_aux.c game_ext.c game_private.c history.c game_tools.c game_examples.c) diff --git a/model.c b/model.c index 65f3217..42d2f1c 100644 --- a/model.c +++ b/model.c @@ -15,17 +15,17 @@ /* **************************************************************** */ -#define RESTART_UP "../img/restart_up.png" -#define RESTART_DOWN "../img/restart_down.png" -#define UNDO_UP "../img/undo_up.png" -#define UNDO_DOWN "../img/undo_down.png" -#define REDO_UP "../img/redo_up.png" -#define REDO_DOWN "../img/redo_down.png" -#define SOLVE_UP "../img/solve_up.png" -#define SOLVE_DOWN "../img/solve_down.png" -#define LIGHTBULB_WHITE "../img/lightbulb_white.png" -#define LIGHTBULB_BLACK "../img/lightbulb_black.png" -#define FONT "../arial.ttf" +#define RESTART_UP "./img/restart_up.png" +#define RESTART_DOWN "./img/restart_down.png" +#define UNDO_UP "./img/undo_up.png" +#define UNDO_DOWN "./img/undo_down.png" +#define REDO_UP "./img/redo_up.png" +#define REDO_DOWN "./img/redo_down.png" +#define SOLVE_UP "./img/solve_up.png" +#define SOLVE_DOWN "./img/solve_down.png" +#define LIGHTBULB_WHITE "./img/lightbulb_white.png" +#define LIGHTBULB_BLACK "./img/lightbulb_black.png" +#define FONT "./arial.ttf" #define FONTSIZE 36 /* **************************************************************** */ @@ -323,10 +323,11 @@ void render(SDL_Window* win, SDL_Renderer* ren, Env* env) { render_blank(ren, &rec, game_is_lighted(env->g, i, j)); else if (game_is_marked(env->g, i, j)) render_mark(ren, &rec, game_is_lighted(env->g, i, j)); + rec.x += size_rec; } + rec.x = rec_x; + rec.y += size_rec; } - rec.x = rec_x; - rec.y += size_rec; } /* **************************************************************** */