diff --git a/cmake-build-debug/CMakeFiles/nhf.dir/C.includecache b/cmake-build-debug/CMakeFiles/nhf.dir/C.includecache index 0ccae6845f993171ad772b4966ab6cb1fb754395..dcdaee3423c06bb9c42dddcda4a6605700125963 100644 --- a/cmake-build-debug/CMakeFiles/nhf.dir/C.includecache +++ b/cmake-build-debug/CMakeFiles/nhf.dir/C.includecache @@ -18,17 +18,5 @@ move.h /home/blint/projects/nhf/move.h -/home/blint/projects/nhf/view.c -SDL2/SDL.h -- -SDL2/SDL_image.h -- -stdlib.h -- -stdio.h -- -view.h -/home/blint/projects/nhf/view.h - /home/blint/projects/nhf/view.h diff --git a/cmake-build-debug/CMakeFiles/nhf.dir/depend.internal b/cmake-build-debug/CMakeFiles/nhf.dir/depend.internal index 91f3310eca6256a75ebf666af4573e9de4c208b6..5e11d6dc69086a5b030b6d81ee9eb2f9d17fbe00 100644 --- a/cmake-build-debug/CMakeFiles/nhf.dir/depend.internal +++ b/cmake-build-debug/CMakeFiles/nhf.dir/depend.internal @@ -8,6 +8,7 @@ CMakeFiles/nhf.dir/main.c.o CMakeFiles/nhf.dir/move.c.o /home/blint/projects/nhf/move.c /home/blint/projects/nhf/move.h + /home/blint/projects/nhf/view.h /usr/include/SDL2/SDL.h /usr/include/SDL2/SDL_assert.h /usr/include/SDL2/SDL_atomic.h diff --git a/cmake-build-debug/CMakeFiles/nhf.dir/depend.make b/cmake-build-debug/CMakeFiles/nhf.dir/depend.make index 95bd43aa89b220c10b2911e1f1204345dd7120f7..df77db378cf70ee786e961a9e25bed7cb9ad4806 100644 --- a/cmake-build-debug/CMakeFiles/nhf.dir/depend.make +++ b/cmake-build-debug/CMakeFiles/nhf.dir/depend.make @@ -7,6 +7,7 @@ CMakeFiles/nhf.dir/main.c.o: ../view.h CMakeFiles/nhf.dir/move.c.o: ../move.c CMakeFiles/nhf.dir/move.c.o: ../move.h +CMakeFiles/nhf.dir/move.c.o: ../view.h CMakeFiles/nhf.dir/move.c.o: /usr/include/SDL2/SDL.h CMakeFiles/nhf.dir/move.c.o: /usr/include/SDL2/SDL_assert.h CMakeFiles/nhf.dir/move.c.o: /usr/include/SDL2/SDL_atomic.h diff --git a/cmake-build-debug/CMakeFiles/nhf.dir/main.c.o b/cmake-build-debug/CMakeFiles/nhf.dir/main.c.o index 2a535b4d4b49bf2475723f19b9d17583340e6b91..13a6367067881762e7f2025f33481bc7bd676970 100644 Binary files a/cmake-build-debug/CMakeFiles/nhf.dir/main.c.o and b/cmake-build-debug/CMakeFiles/nhf.dir/main.c.o differ diff --git a/cmake-build-debug/CMakeFiles/nhf.dir/move.c.o b/cmake-build-debug/CMakeFiles/nhf.dir/move.c.o index 07212cca7f4775e6ccd8b08ea81181635cc5d449..c05ab026372582ed1adbfec5d256a062e7beaa64 100644 Binary files a/cmake-build-debug/CMakeFiles/nhf.dir/move.c.o and b/cmake-build-debug/CMakeFiles/nhf.dir/move.c.o differ diff --git a/cmake-build-debug/nhf b/cmake-build-debug/nhf index c70970a9a49548b4c25bb561a20dbaac434a5362..6b79060fe457889f28eccf6acab0f517183a8fc2 100755 Binary files a/cmake-build-debug/nhf and b/cmake-build-debug/nhf differ diff --git a/main.c b/main.c index 9e0a4f8657c77b5d567bac2c5ce86555dbfdadf0..9745db57be6b50cb0ad2624f8cde645d73c76165 100644 --- a/main.c +++ b/main.c @@ -32,22 +32,7 @@ int main(int argc, char *argv[]) { SDL_WaitEvent(&ev); SDL_RenderClear(renderer); - switch (ev.type) { - case SDL_KEYUP: - switch (ev.key.keysym.sym) { - case SDLK_i: - kirajzol(renderer, kep, elozo_x, elozo_y); - moving = true; - break; - case SDLK_ESCAPE: quit = true; - break; - } - break; - - case SDL_QUIT: - quit = true; - break; - } + keywatcher(ev, kep, elozo_x, elozo_y, &quit, &moving, renderer); if (moving){ move(ev); diff --git a/move.c b/move.c index 4a6c2ff5bea0e954fd1b3ba4f4e702d8e1e08acf..ec116391300073e4d78e59168e01de6314542482 100644 --- a/move.c +++ b/move.c @@ -3,7 +3,9 @@ // #include <SDL.h> +#include <stdbool.h> #include "move.h" +#include "view.h" int v = 5; int vx = 0; @@ -65,4 +67,25 @@ void move(SDL_Event ev) } break; } -} \ No newline at end of file +} + +void keywatcher(SDL_Event ev, SDL_Texture *kep, int x, int y, bool *quit, bool *moving, SDL_Renderer *renderer) +{ + switch (ev.type) { + case SDL_KEYUP: + switch (ev.key.keysym.sym) { + case SDLK_i: + kirajzol(renderer, kep, x, y); + *moving = true; + break; + case SDLK_ESCAPE: + *quit = true; + break; + } + break; + + case SDL_QUIT: + *quit = true; + break; + } +} diff --git a/move.h b/move.h index bc02e45a699c58cada00ed414a576040f830f1dc..097aa3c8e7ac8da62f1b79e190f5331ac50f3f8f 100644 --- a/move.h +++ b/move.h @@ -5,10 +5,12 @@ #ifndef NHF_MOVE_H #define NHF_MOVE_H -#endif //NHF_MOVE_H - extern int v; extern int vx; extern int vy; -void move(SDL_Event ev); \ No newline at end of file +void move(SDL_Event ev); + +void keywatcher(SDL_Event ev, SDL_Texture *kep, int x, int y, bool *quit, bool *moving, SDL_Renderer *renderer); + +#endif //NHF_MOVE_H \ No newline at end of file diff --git a/view.h b/view.h index f8f37356afe54862d3f6cb634de7aa3158682185..e0f35926a8dccd573d1d04b1b1528c6f491ad2a5 100644 --- a/view.h +++ b/view.h @@ -5,12 +5,12 @@ #ifndef NHF_VIEW_H #define NHF_VIEW_H -#endif //NHF_VIEW_H - extern int owl; void sdl_init(int szeles, int magas, SDL_Window **pwindow, SDL_Renderer **prenderer); SDL_Texture *kep_betolt(SDL_Renderer *renderer, char *filename); -void kirajzol(SDL_Renderer *renderer, SDL_Texture *kep, int x, int y); \ No newline at end of file +void kirajzol(SDL_Renderer *renderer, SDL_Texture *kep, int x, int y); + +#endif //NHF_VIEW_H \ No newline at end of file