diff --git a/.gitignore b/.gitignore index 485dee64bcfb48793379b200a1afd14e85a8aaf4..8a7ea40c432d03a46457fc8514218573825b7fca 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ .idea +cmake-build-debug/CMakeFiles diff --git a/CMakeLists.txt b/CMakeLists.txt index 54c060cd334a5b4efbc3f83ce790a2cee645a1b9..10c93e981363a76b01d2ff65b45decc93174c3e3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -13,6 +13,8 @@ INCLUDE(FindPkgConfig) PKG_SEARCH_MODULE(SDL2 REQUIRED sdl2) PKG_SEARCH_MODULE(SDL2GFX REQUIRED SDL2_gfx) +PKG_SEARCH_MODULE(SDL2TTF REQUIRED SDL2_ttf) +PKG_SEARCH_MODULE(SDL2IMAGE REQUIRED SDL2_image) -INCLUDE_DIRECTORIES(${SDL2_INCLUDE_DIRS} ${SDL2GFX_INCLUDE_DIRS}) -TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${SDL2_LIBRARIES} ${SDL2GFX_LIBRARIES} SDL2_image) +INCLUDE_DIRECTORIES(${SDL2_INCLUDE_DIRS} ${SDL2GFX_INCLUDE_DIRS} ${SDL2TTF_INCLUDE_DIRS} ${SDL2IMAGE_INCLUDE_DIRS}) +TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${SDL2_LIBRARIES} ${SDL2GFX_LIBRARIES} ${SDL2TTF_LIBRARIES} ${SDL2IMAGE_LIBRARIES}) \ No newline at end of file diff --git a/cmake-build-debug/CMakeCache.txt b/cmake-build-debug/CMakeCache.txt index 8e544ade533d9df68d26d531d5cd12d7aae98201..af09f63e0f85d61e00ca1913585be5edc583b804 100644 --- a/cmake-build-debug/CMakeCache.txt +++ b/cmake-build-debug/CMakeCache.txt @@ -206,6 +206,18 @@ pkgcfg_lib_SDL2GFX_SDL2:FILEPATH=/usr/lib/x86_64-linux-gnu/libSDL2.so //Path to a library. pkgcfg_lib_SDL2GFX_SDL2_gfx:FILEPATH=/usr/lib/x86_64-linux-gnu/libSDL2_gfx.so +//Path to a library. +pkgcfg_lib_SDL2IMAGE_SDL2:FILEPATH=/usr/lib/x86_64-linux-gnu/libSDL2.so + +//Path to a library. +pkgcfg_lib_SDL2IMAGE_SDL2_image:FILEPATH=/usr/lib/x86_64-linux-gnu/libSDL2_image.so + +//Path to a library. +pkgcfg_lib_SDL2TTF_SDL2:FILEPATH=/usr/lib/x86_64-linux-gnu/libSDL2.so + +//Path to a library. +pkgcfg_lib_SDL2TTF_SDL2_ttf:FILEPATH=/usr/lib/x86_64-linux-gnu/libSDL2_ttf.so + //Path to a library. pkgcfg_lib_SDL2_SDL2:FILEPATH=/usr/lib/x86_64-linux-gnu/libSDL2.so @@ -381,6 +393,74 @@ SDL2GFX_STATIC_LIBS_L:INTERNAL= SDL2GFX_STATIC_LIBS_OTHER:INTERNAL= SDL2GFX_STATIC_LIBS_PATHS:INTERNAL= SDL2GFX_VERSION:INTERNAL=1.0.2 +SDL2IMAGE_CFLAGS:INTERNAL=-D_REENTRANT;-I/usr/include/SDL2 +SDL2IMAGE_CFLAGS_I:INTERNAL= +SDL2IMAGE_CFLAGS_OTHER:INTERNAL=-D_REENTRANT +SDL2IMAGE_FOUND:INTERNAL=1 +SDL2IMAGE_INCLUDEDIR:INTERNAL=/usr/include +SDL2IMAGE_INCLUDE_DIRS:INTERNAL=/usr/include/SDL2 +SDL2IMAGE_LDFLAGS:INTERNAL=-lSDL2_image;-lSDL2 +SDL2IMAGE_LDFLAGS_OTHER:INTERNAL= +SDL2IMAGE_LIBDIR:INTERNAL=/usr/lib/x86_64-linux-gnu +SDL2IMAGE_LIBRARIES:INTERNAL=SDL2_image;SDL2 +SDL2IMAGE_LIBRARY_DIRS:INTERNAL= +SDL2IMAGE_LIBS:INTERNAL= +SDL2IMAGE_LIBS_L:INTERNAL= +SDL2IMAGE_LIBS_OTHER:INTERNAL= +SDL2IMAGE_LIBS_PATHS:INTERNAL= +SDL2IMAGE_PREFIX:INTERNAL=/usr +SDL2IMAGE_SDL2_image_INCLUDEDIR:INTERNAL= +SDL2IMAGE_SDL2_image_LIBDIR:INTERNAL= +SDL2IMAGE_SDL2_image_PREFIX:INTERNAL= +SDL2IMAGE_SDL2_image_VERSION:INTERNAL= +SDL2IMAGE_STATIC_CFLAGS:INTERNAL=-D_REENTRANT;-I/usr/include/SDL2 +SDL2IMAGE_STATIC_CFLAGS_I:INTERNAL= +SDL2IMAGE_STATIC_CFLAGS_OTHER:INTERNAL=-D_REENTRANT +SDL2IMAGE_STATIC_INCLUDE_DIRS:INTERNAL=/usr/include/SDL2 +SDL2IMAGE_STATIC_LDFLAGS:INTERNAL=-lSDL2_image;-lSDL2;-Wl,--no-undefined;-lm;-ldl;-lasound;-lm;-ldl;-lpthread;-lpulse-simple;-lpulse;-lX11;-lXext;-lXcursor;-lXinerama;-lXi;-lXrandr;-lXss;-lXxf86vm;-lwayland-egl;-lwayland-client;-lwayland-cursor;-lxkbcommon;-lpthread;-lrt +SDL2IMAGE_STATIC_LDFLAGS_OTHER:INTERNAL=-Wl,--no-undefined +SDL2IMAGE_STATIC_LIBDIR:INTERNAL= +SDL2IMAGE_STATIC_LIBRARIES:INTERNAL=SDL2_image;SDL2;m;dl;asound;m;dl;pthread;pulse-simple;pulse;X11;Xext;Xcursor;Xinerama;Xi;Xrandr;Xss;Xxf86vm;wayland-egl;wayland-client;wayland-cursor;xkbcommon;pthread;rt +SDL2IMAGE_STATIC_LIBRARY_DIRS:INTERNAL= +SDL2IMAGE_STATIC_LIBS:INTERNAL= +SDL2IMAGE_STATIC_LIBS_L:INTERNAL= +SDL2IMAGE_STATIC_LIBS_OTHER:INTERNAL= +SDL2IMAGE_STATIC_LIBS_PATHS:INTERNAL= +SDL2IMAGE_VERSION:INTERNAL=2.0.5 +SDL2TTF_CFLAGS:INTERNAL=-D_REENTRANT;-I/usr/include/SDL2 +SDL2TTF_CFLAGS_I:INTERNAL= +SDL2TTF_CFLAGS_OTHER:INTERNAL=-D_REENTRANT +SDL2TTF_FOUND:INTERNAL=1 +SDL2TTF_INCLUDEDIR:INTERNAL=/usr/include +SDL2TTF_INCLUDE_DIRS:INTERNAL=/usr/include/SDL2 +SDL2TTF_LDFLAGS:INTERNAL=-lSDL2_ttf;-lSDL2 +SDL2TTF_LDFLAGS_OTHER:INTERNAL= +SDL2TTF_LIBDIR:INTERNAL=/usr/lib/x86_64-linux-gnu +SDL2TTF_LIBRARIES:INTERNAL=SDL2_ttf;SDL2 +SDL2TTF_LIBRARY_DIRS:INTERNAL= +SDL2TTF_LIBS:INTERNAL= +SDL2TTF_LIBS_L:INTERNAL= +SDL2TTF_LIBS_OTHER:INTERNAL= +SDL2TTF_LIBS_PATHS:INTERNAL= +SDL2TTF_PREFIX:INTERNAL=/usr +SDL2TTF_SDL2_ttf_INCLUDEDIR:INTERNAL= +SDL2TTF_SDL2_ttf_LIBDIR:INTERNAL= +SDL2TTF_SDL2_ttf_PREFIX:INTERNAL= +SDL2TTF_SDL2_ttf_VERSION:INTERNAL= +SDL2TTF_STATIC_CFLAGS:INTERNAL=-D_REENTRANT;-I/usr/include/SDL2 +SDL2TTF_STATIC_CFLAGS_I:INTERNAL= +SDL2TTF_STATIC_CFLAGS_OTHER:INTERNAL=-D_REENTRANT +SDL2TTF_STATIC_INCLUDE_DIRS:INTERNAL=/usr/include/SDL2 +SDL2TTF_STATIC_LDFLAGS:INTERNAL=-lSDL2_ttf;-lSDL2;-Wl,--no-undefined;-lm;-ldl;-lasound;-lm;-ldl;-lpthread;-lpulse-simple;-lpulse;-lX11;-lXext;-lXcursor;-lXinerama;-lXi;-lXrandr;-lXss;-lXxf86vm;-lwayland-egl;-lwayland-client;-lwayland-cursor;-lxkbcommon;-lpthread;-lrt +SDL2TTF_STATIC_LDFLAGS_OTHER:INTERNAL=-Wl,--no-undefined +SDL2TTF_STATIC_LIBDIR:INTERNAL= +SDL2TTF_STATIC_LIBRARIES:INTERNAL=SDL2_ttf;SDL2;m;dl;asound;m;dl;pthread;pulse-simple;pulse;X11;Xext;Xcursor;Xinerama;Xi;Xrandr;Xss;Xxf86vm;wayland-egl;wayland-client;wayland-cursor;xkbcommon;pthread;rt +SDL2TTF_STATIC_LIBRARY_DIRS:INTERNAL= +SDL2TTF_STATIC_LIBS:INTERNAL= +SDL2TTF_STATIC_LIBS_L:INTERNAL= +SDL2TTF_STATIC_LIBS_OTHER:INTERNAL= +SDL2TTF_STATIC_LIBS_PATHS:INTERNAL= +SDL2TTF_VERSION:INTERNAL=2.0.15 SDL2_CFLAGS:INTERNAL=-D_REENTRANT;-I/usr/include/SDL2 SDL2_CFLAGS_I:INTERNAL= SDL2_CFLAGS_OTHER:INTERNAL=-D_REENTRANT @@ -417,10 +497,20 @@ SDL2_sdl2_PREFIX:INTERNAL= SDL2_sdl2_VERSION:INTERNAL= __pkg_config_checked_SDL2:INTERNAL=1 __pkg_config_checked_SDL2GFX:INTERNAL=1 +__pkg_config_checked_SDL2IMAGE:INTERNAL=1 +__pkg_config_checked_SDL2TTF:INTERNAL=1 //ADVANCED property for variable: pkgcfg_lib_SDL2GFX_SDL2 pkgcfg_lib_SDL2GFX_SDL2-ADVANCED:INTERNAL=1 //ADVANCED property for variable: pkgcfg_lib_SDL2GFX_SDL2_gfx pkgcfg_lib_SDL2GFX_SDL2_gfx-ADVANCED:INTERNAL=1 +//ADVANCED property for variable: pkgcfg_lib_SDL2IMAGE_SDL2 +pkgcfg_lib_SDL2IMAGE_SDL2-ADVANCED:INTERNAL=1 +//ADVANCED property for variable: pkgcfg_lib_SDL2IMAGE_SDL2_image +pkgcfg_lib_SDL2IMAGE_SDL2_image-ADVANCED:INTERNAL=1 +//ADVANCED property for variable: pkgcfg_lib_SDL2TTF_SDL2 +pkgcfg_lib_SDL2TTF_SDL2-ADVANCED:INTERNAL=1 +//ADVANCED property for variable: pkgcfg_lib_SDL2TTF_SDL2_ttf +pkgcfg_lib_SDL2TTF_SDL2_ttf-ADVANCED:INTERNAL=1 //ADVANCED property for variable: pkgcfg_lib_SDL2_SDL2 pkgcfg_lib_SDL2_SDL2-ADVANCED:INTERNAL=1 prefix_result:INTERNAL=/usr/lib/x86_64-linux-gnu diff --git a/cmake-build-debug/CMakeFiles/clion-log.txt b/cmake-build-debug/CMakeFiles/clion-log.txt index ace78dfd02b6b7d027c5457bc2b4cc9cd8cae3af..5cded16b71b2fb0433632652439f0138c9553832 100644 --- a/cmake-build-debug/CMakeFiles/clion-log.txt +++ b/cmake-build-debug/CMakeFiles/clion-log.txt @@ -1,4 +1,6 @@ /snap/clion/92/bin/cmake/linux/bin/cmake -DCMAKE_BUILD_TYPE=Debug -G "CodeBlocks - Unix Makefiles" /home/blint/projects/nhf +-- Checking for one of the modules 'SDL2_ttf' +-- Checking for one of the modules 'SDL2_image' -- Configuring done -- Generating done -- Build files have been written to: /home/blint/projects/nhf/cmake-build-debug diff --git a/cmake-build-debug/CMakeFiles/nhf.dir/C.includecache b/cmake-build-debug/CMakeFiles/nhf.dir/C.includecache index dcdaee3423c06bb9c42dddcda4a6605700125963..1d7686855e712075dae64f9a64526ab1340e54b5 100644 --- a/cmake-build-debug/CMakeFiles/nhf.dir/C.includecache +++ b/cmake-build-debug/CMakeFiles/nhf.dir/C.includecache @@ -6,17 +6,639 @@ #IncludeRegexTransform: -/home/blint/projects/nhf/main.c -SDL2/SDL_image.h +/home/blint/projects/nhf/move.c +move.h +/home/blint/projects/nhf/move.h +view.h +/home/blint/projects/nhf/view.h +SDL.h - stdbool.h - -view.h -/home/blint/projects/nhf/view.h -move.h -/home/blint/projects/nhf/move.h +math.h +- /home/blint/projects/nhf/move.h +view.h +/home/blint/projects/nhf/view.h +SDL.h +- +stdbool.h +- +math.h +- /home/blint/projects/nhf/view.h +SDL2/SDL.h +- +SDL2/SDL_image.h +- +stdlib.h +- +stdio.h +- + +/usr/include/SDL2/SDL.h +SDL_main.h +/usr/include/SDL2/SDL_main.h +SDL_stdinc.h +/usr/include/SDL2/SDL_stdinc.h +SDL_assert.h +/usr/include/SDL2/SDL_assert.h +SDL_atomic.h +/usr/include/SDL2/SDL_atomic.h +SDL_audio.h +/usr/include/SDL2/SDL_audio.h +SDL_clipboard.h +/usr/include/SDL2/SDL_clipboard.h +SDL_cpuinfo.h +/usr/include/SDL2/SDL_cpuinfo.h +SDL_endian.h +/usr/include/SDL2/SDL_endian.h +SDL_error.h +/usr/include/SDL2/SDL_error.h +SDL_events.h +/usr/include/SDL2/SDL_events.h +SDL_filesystem.h +/usr/include/SDL2/SDL_filesystem.h +SDL_gamecontroller.h +/usr/include/SDL2/SDL_gamecontroller.h +SDL_haptic.h +/usr/include/SDL2/SDL_haptic.h +SDL_hints.h +/usr/include/SDL2/SDL_hints.h +SDL_joystick.h +/usr/include/SDL2/SDL_joystick.h +SDL_loadso.h +/usr/include/SDL2/SDL_loadso.h +SDL_log.h +/usr/include/SDL2/SDL_log.h +SDL_messagebox.h +/usr/include/SDL2/SDL_messagebox.h +SDL_mutex.h +/usr/include/SDL2/SDL_mutex.h +SDL_power.h +/usr/include/SDL2/SDL_power.h +SDL_render.h +/usr/include/SDL2/SDL_render.h +SDL_rwops.h +/usr/include/SDL2/SDL_rwops.h +SDL_sensor.h +/usr/include/SDL2/SDL_sensor.h +SDL_shape.h +/usr/include/SDL2/SDL_shape.h +SDL_system.h +/usr/include/SDL2/SDL_system.h +SDL_thread.h +/usr/include/SDL2/SDL_thread.h +SDL_timer.h +/usr/include/SDL2/SDL_timer.h +SDL_version.h +/usr/include/SDL2/SDL_version.h +SDL_video.h +/usr/include/SDL2/SDL_video.h +begin_code.h +/usr/include/SDL2/begin_code.h +close_code.h +/usr/include/SDL2/close_code.h + +/usr/include/SDL2/SDL_assert.h +SDL_config.h +/usr/include/SDL2/SDL_config.h +begin_code.h +/usr/include/SDL2/begin_code.h +signal.h +- +close_code.h +/usr/include/SDL2/close_code.h + +/usr/include/SDL2/SDL_atomic.h +SDL_stdinc.h +/usr/include/SDL2/SDL_stdinc.h +SDL_platform.h +/usr/include/SDL2/SDL_platform.h +begin_code.h +/usr/include/SDL2/begin_code.h +sys/cpuinline.h +- +mbarrier.h +- +close_code.h +/usr/include/SDL2/close_code.h + +/usr/include/SDL2/SDL_audio.h +SDL_stdinc.h +/usr/include/SDL2/SDL_stdinc.h +SDL_error.h +/usr/include/SDL2/SDL_error.h +SDL_endian.h +/usr/include/SDL2/SDL_endian.h +SDL_mutex.h +/usr/include/SDL2/SDL_mutex.h +SDL_thread.h +/usr/include/SDL2/SDL_thread.h +SDL_rwops.h +/usr/include/SDL2/SDL_rwops.h +begin_code.h +/usr/include/SDL2/begin_code.h +close_code.h +/usr/include/SDL2/close_code.h + +/usr/include/SDL2/SDL_blendmode.h +begin_code.h +/usr/include/SDL2/begin_code.h +close_code.h +/usr/include/SDL2/close_code.h + +/usr/include/SDL2/SDL_clipboard.h +SDL_stdinc.h +/usr/include/SDL2/SDL_stdinc.h +begin_code.h +/usr/include/SDL2/begin_code.h +close_code.h +/usr/include/SDL2/close_code.h + +/usr/include/SDL2/SDL_config.h +SDL_platform.h +/usr/include/SDL2/SDL_platform.h + +/usr/include/SDL2/SDL_cpuinfo.h +SDL_stdinc.h +/usr/include/SDL2/SDL_stdinc.h +intrin.h +- +intrin.h +- +altivec.h +- +arm_neon.h +- +armintr.h +- +arm_neon.h +- +armintr.h +- +arm_neon.h +- +mm3dnow.h +- +immintrin.h +- +mmintrin.h +- +xmmintrin.h +- +emmintrin.h +- +pmmintrin.h +- +begin_code.h +/usr/include/SDL2/begin_code.h +close_code.h +/usr/include/SDL2/close_code.h + +/usr/include/SDL2/SDL_endian.h +SDL_stdinc.h +/usr/include/SDL2/SDL_stdinc.h +endian.h +- +begin_code.h +/usr/include/SDL2/begin_code.h +close_code.h +/usr/include/SDL2/close_code.h + +/usr/include/SDL2/SDL_error.h +SDL_stdinc.h +/usr/include/SDL2/SDL_stdinc.h +begin_code.h +/usr/include/SDL2/begin_code.h +close_code.h +/usr/include/SDL2/close_code.h + +/usr/include/SDL2/SDL_events.h +SDL_stdinc.h +/usr/include/SDL2/SDL_stdinc.h +SDL_error.h +/usr/include/SDL2/SDL_error.h +SDL_video.h +/usr/include/SDL2/SDL_video.h +SDL_keyboard.h +/usr/include/SDL2/SDL_keyboard.h +SDL_mouse.h +/usr/include/SDL2/SDL_mouse.h +SDL_joystick.h +/usr/include/SDL2/SDL_joystick.h +SDL_gamecontroller.h +/usr/include/SDL2/SDL_gamecontroller.h +SDL_quit.h +/usr/include/SDL2/SDL_quit.h +SDL_gesture.h +/usr/include/SDL2/SDL_gesture.h +SDL_touch.h +/usr/include/SDL2/SDL_touch.h +begin_code.h +/usr/include/SDL2/begin_code.h +close_code.h +/usr/include/SDL2/close_code.h + +/usr/include/SDL2/SDL_filesystem.h +SDL_stdinc.h +/usr/include/SDL2/SDL_stdinc.h +begin_code.h +/usr/include/SDL2/begin_code.h +close_code.h +/usr/include/SDL2/close_code.h + +/usr/include/SDL2/SDL_gamecontroller.h +SDL_stdinc.h +/usr/include/SDL2/SDL_stdinc.h +SDL_error.h +/usr/include/SDL2/SDL_error.h +SDL_rwops.h +/usr/include/SDL2/SDL_rwops.h +SDL_joystick.h +/usr/include/SDL2/SDL_joystick.h +begin_code.h +/usr/include/SDL2/begin_code.h +close_code.h +/usr/include/SDL2/close_code.h + +/usr/include/SDL2/SDL_gesture.h +SDL_stdinc.h +/usr/include/SDL2/SDL_stdinc.h +SDL_error.h +/usr/include/SDL2/SDL_error.h +SDL_video.h +/usr/include/SDL2/SDL_video.h +SDL_touch.h +/usr/include/SDL2/SDL_touch.h +begin_code.h +/usr/include/SDL2/begin_code.h +close_code.h +/usr/include/SDL2/close_code.h + +/usr/include/SDL2/SDL_haptic.h +SDL_stdinc.h +/usr/include/SDL2/SDL_stdinc.h +SDL_error.h +/usr/include/SDL2/SDL_error.h +SDL_joystick.h +/usr/include/SDL2/SDL_joystick.h +begin_code.h +/usr/include/SDL2/begin_code.h +close_code.h +/usr/include/SDL2/close_code.h + +/usr/include/SDL2/SDL_hints.h +SDL_stdinc.h +/usr/include/SDL2/SDL_stdinc.h +begin_code.h +/usr/include/SDL2/begin_code.h +close_code.h +/usr/include/SDL2/close_code.h + +/usr/include/SDL2/SDL_joystick.h +SDL_stdinc.h +/usr/include/SDL2/SDL_stdinc.h +SDL_error.h +/usr/include/SDL2/SDL_error.h +begin_code.h +/usr/include/SDL2/begin_code.h +close_code.h +/usr/include/SDL2/close_code.h + +/usr/include/SDL2/SDL_keyboard.h +SDL_stdinc.h +/usr/include/SDL2/SDL_stdinc.h +SDL_error.h +/usr/include/SDL2/SDL_error.h +SDL_keycode.h +/usr/include/SDL2/SDL_keycode.h +SDL_video.h +/usr/include/SDL2/SDL_video.h +begin_code.h +/usr/include/SDL2/begin_code.h +close_code.h +/usr/include/SDL2/close_code.h + +/usr/include/SDL2/SDL_keycode.h +SDL_stdinc.h +/usr/include/SDL2/SDL_stdinc.h +SDL_scancode.h +/usr/include/SDL2/SDL_scancode.h + +/usr/include/SDL2/SDL_loadso.h +SDL_stdinc.h +/usr/include/SDL2/SDL_stdinc.h +SDL_error.h +/usr/include/SDL2/SDL_error.h +begin_code.h +/usr/include/SDL2/begin_code.h +close_code.h +/usr/include/SDL2/close_code.h + +/usr/include/SDL2/SDL_log.h +SDL_stdinc.h +/usr/include/SDL2/SDL_stdinc.h +begin_code.h +/usr/include/SDL2/begin_code.h +close_code.h +/usr/include/SDL2/close_code.h + +/usr/include/SDL2/SDL_main.h +SDL_stdinc.h +/usr/include/SDL2/SDL_stdinc.h +begin_code.h +/usr/include/SDL2/begin_code.h +close_code.h +/usr/include/SDL2/close_code.h + +/usr/include/SDL2/SDL_messagebox.h +SDL_stdinc.h +/usr/include/SDL2/SDL_stdinc.h +SDL_video.h +/usr/include/SDL2/SDL_video.h +begin_code.h +/usr/include/SDL2/begin_code.h +close_code.h +/usr/include/SDL2/close_code.h + +/usr/include/SDL2/SDL_mouse.h +SDL_stdinc.h +/usr/include/SDL2/SDL_stdinc.h +SDL_error.h +/usr/include/SDL2/SDL_error.h +SDL_video.h +/usr/include/SDL2/SDL_video.h +begin_code.h +/usr/include/SDL2/begin_code.h +close_code.h +/usr/include/SDL2/close_code.h + +/usr/include/SDL2/SDL_mutex.h +SDL_stdinc.h +/usr/include/SDL2/SDL_stdinc.h +SDL_error.h +/usr/include/SDL2/SDL_error.h +begin_code.h +/usr/include/SDL2/begin_code.h +close_code.h +/usr/include/SDL2/close_code.h + +/usr/include/SDL2/SDL_pixels.h +SDL_stdinc.h +/usr/include/SDL2/SDL_stdinc.h +SDL_endian.h +/usr/include/SDL2/SDL_endian.h +begin_code.h +/usr/include/SDL2/begin_code.h +close_code.h +/usr/include/SDL2/close_code.h + +/usr/include/SDL2/SDL_platform.h +AvailabilityMacros.h +/usr/include/SDL2/AvailabilityMacros.h +TargetConditionals.h +/usr/include/SDL2/TargetConditionals.h +winapifamily.h +- +begin_code.h +/usr/include/SDL2/begin_code.h +close_code.h +/usr/include/SDL2/close_code.h + +/usr/include/SDL2/SDL_power.h +SDL_stdinc.h +/usr/include/SDL2/SDL_stdinc.h +begin_code.h +/usr/include/SDL2/begin_code.h +close_code.h +/usr/include/SDL2/close_code.h + +/usr/include/SDL2/SDL_quit.h +SDL_stdinc.h +/usr/include/SDL2/SDL_stdinc.h +SDL_error.h +/usr/include/SDL2/SDL_error.h + +/usr/include/SDL2/SDL_rect.h +SDL_stdinc.h +/usr/include/SDL2/SDL_stdinc.h +SDL_error.h +/usr/include/SDL2/SDL_error.h +SDL_pixels.h +/usr/include/SDL2/SDL_pixels.h +SDL_rwops.h +/usr/include/SDL2/SDL_rwops.h +begin_code.h +/usr/include/SDL2/begin_code.h +close_code.h +/usr/include/SDL2/close_code.h + +/usr/include/SDL2/SDL_render.h +SDL_stdinc.h +/usr/include/SDL2/SDL_stdinc.h +SDL_rect.h +/usr/include/SDL2/SDL_rect.h +SDL_video.h +/usr/include/SDL2/SDL_video.h +begin_code.h +/usr/include/SDL2/begin_code.h +close_code.h +/usr/include/SDL2/close_code.h + +/usr/include/SDL2/SDL_rwops.h +SDL_stdinc.h +/usr/include/SDL2/SDL_stdinc.h +SDL_error.h +/usr/include/SDL2/SDL_error.h +begin_code.h +/usr/include/SDL2/begin_code.h +close_code.h +/usr/include/SDL2/close_code.h + +/usr/include/SDL2/SDL_scancode.h +SDL_stdinc.h +/usr/include/SDL2/SDL_stdinc.h + +/usr/include/SDL2/SDL_sensor.h +SDL_stdinc.h +/usr/include/SDL2/SDL_stdinc.h +SDL_error.h +/usr/include/SDL2/SDL_error.h +begin_code.h +/usr/include/SDL2/begin_code.h +close_code.h +/usr/include/SDL2/close_code.h + +/usr/include/SDL2/SDL_shape.h +SDL_stdinc.h +/usr/include/SDL2/SDL_stdinc.h +SDL_pixels.h +/usr/include/SDL2/SDL_pixels.h +SDL_rect.h +/usr/include/SDL2/SDL_rect.h +SDL_surface.h +/usr/include/SDL2/SDL_surface.h +SDL_video.h +/usr/include/SDL2/SDL_video.h +begin_code.h +/usr/include/SDL2/begin_code.h +close_code.h +/usr/include/SDL2/close_code.h + +/usr/include/SDL2/SDL_stdinc.h +SDL_config.h +/usr/include/SDL2/SDL_config.h +sys/types.h +- +stdio.h +- +stdlib.h +- +stddef.h +- +stdarg.h +- +stdlib.h +- +malloc.h +- +stddef.h +- +stdarg.h +- +memory.h +- +string.h +- +strings.h +- +wchar.h +- +inttypes.h +- +stdint.h +- +ctype.h +- +math.h +- +float.h +- +alloca.h +- +malloc.h +- +malloc.h +- +malloc.h +- +stdlib.h +- +sal.h +- +begin_code.h +/usr/include/SDL2/begin_code.h +close_code.h +/usr/include/SDL2/close_code.h + +/usr/include/SDL2/SDL_surface.h +SDL_stdinc.h +/usr/include/SDL2/SDL_stdinc.h +SDL_pixels.h +/usr/include/SDL2/SDL_pixels.h +SDL_rect.h +/usr/include/SDL2/SDL_rect.h +SDL_blendmode.h +/usr/include/SDL2/SDL_blendmode.h +SDL_rwops.h +/usr/include/SDL2/SDL_rwops.h +begin_code.h +/usr/include/SDL2/begin_code.h +close_code.h +/usr/include/SDL2/close_code.h + +/usr/include/SDL2/SDL_system.h +SDL_stdinc.h +/usr/include/SDL2/SDL_stdinc.h +SDL_keyboard.h +/usr/include/SDL2/SDL_keyboard.h +SDL_render.h +/usr/include/SDL2/SDL_render.h +SDL_video.h +/usr/include/SDL2/SDL_video.h +begin_code.h +/usr/include/SDL2/begin_code.h +close_code.h +/usr/include/SDL2/close_code.h + +/usr/include/SDL2/SDL_thread.h +SDL_stdinc.h +/usr/include/SDL2/SDL_stdinc.h +SDL_error.h +/usr/include/SDL2/SDL_error.h +SDL_atomic.h +/usr/include/SDL2/SDL_atomic.h +SDL_mutex.h +/usr/include/SDL2/SDL_mutex.h +begin_code.h +/usr/include/SDL2/begin_code.h +process.h +- +process.h +- +stdlib.h +- +close_code.h +/usr/include/SDL2/close_code.h + +/usr/include/SDL2/SDL_timer.h +SDL_stdinc.h +/usr/include/SDL2/SDL_stdinc.h +SDL_error.h +/usr/include/SDL2/SDL_error.h +begin_code.h +/usr/include/SDL2/begin_code.h +close_code.h +/usr/include/SDL2/close_code.h + +/usr/include/SDL2/SDL_touch.h +SDL_stdinc.h +/usr/include/SDL2/SDL_stdinc.h +SDL_error.h +/usr/include/SDL2/SDL_error.h +SDL_video.h +/usr/include/SDL2/SDL_video.h +begin_code.h +/usr/include/SDL2/begin_code.h +close_code.h +/usr/include/SDL2/close_code.h + +/usr/include/SDL2/SDL_version.h +SDL_stdinc.h +/usr/include/SDL2/SDL_stdinc.h +begin_code.h +/usr/include/SDL2/begin_code.h +close_code.h +/usr/include/SDL2/close_code.h + +/usr/include/SDL2/SDL_video.h +SDL_stdinc.h +/usr/include/SDL2/SDL_stdinc.h +SDL_pixels.h +/usr/include/SDL2/SDL_pixels.h +SDL_rect.h +/usr/include/SDL2/SDL_rect.h +SDL_surface.h +/usr/include/SDL2/SDL_surface.h +begin_code.h +/usr/include/SDL2/begin_code.h +close_code.h +/usr/include/SDL2/close_code.h + +/usr/include/SDL2/begin_code.h + +/usr/include/SDL2/close_code.h diff --git a/cmake-build-debug/CMakeFiles/nhf.dir/depend.internal b/cmake-build-debug/CMakeFiles/nhf.dir/depend.internal index 5e11d6dc69086a5b030b6d81ee9eb2f9d17fbe00..ec51b8604162440a429faeba44c8680560c6a71f 100644 --- a/cmake-build-debug/CMakeFiles/nhf.dir/depend.internal +++ b/cmake-build-debug/CMakeFiles/nhf.dir/depend.internal @@ -5,6 +5,51 @@ CMakeFiles/nhf.dir/main.c.o /home/blint/projects/nhf/main.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 + /usr/include/SDL2/SDL_audio.h + /usr/include/SDL2/SDL_blendmode.h + /usr/include/SDL2/SDL_clipboard.h + /usr/include/SDL2/SDL_config.h + /usr/include/SDL2/SDL_cpuinfo.h + /usr/include/SDL2/SDL_endian.h + /usr/include/SDL2/SDL_error.h + /usr/include/SDL2/SDL_events.h + /usr/include/SDL2/SDL_filesystem.h + /usr/include/SDL2/SDL_gamecontroller.h + /usr/include/SDL2/SDL_gesture.h + /usr/include/SDL2/SDL_haptic.h + /usr/include/SDL2/SDL_hints.h + /usr/include/SDL2/SDL_joystick.h + /usr/include/SDL2/SDL_keyboard.h + /usr/include/SDL2/SDL_keycode.h + /usr/include/SDL2/SDL_loadso.h + /usr/include/SDL2/SDL_log.h + /usr/include/SDL2/SDL_main.h + /usr/include/SDL2/SDL_messagebox.h + /usr/include/SDL2/SDL_mouse.h + /usr/include/SDL2/SDL_mutex.h + /usr/include/SDL2/SDL_pixels.h + /usr/include/SDL2/SDL_platform.h + /usr/include/SDL2/SDL_power.h + /usr/include/SDL2/SDL_quit.h + /usr/include/SDL2/SDL_rect.h + /usr/include/SDL2/SDL_render.h + /usr/include/SDL2/SDL_rwops.h + /usr/include/SDL2/SDL_scancode.h + /usr/include/SDL2/SDL_sensor.h + /usr/include/SDL2/SDL_shape.h + /usr/include/SDL2/SDL_stdinc.h + /usr/include/SDL2/SDL_surface.h + /usr/include/SDL2/SDL_system.h + /usr/include/SDL2/SDL_thread.h + /usr/include/SDL2/SDL_timer.h + /usr/include/SDL2/SDL_touch.h + /usr/include/SDL2/SDL_version.h + /usr/include/SDL2/SDL_video.h + /usr/include/SDL2/begin_code.h + /usr/include/SDL2/close_code.h CMakeFiles/nhf.dir/move.c.o /home/blint/projects/nhf/move.c /home/blint/projects/nhf/move.h diff --git a/cmake-build-debug/CMakeFiles/nhf.dir/depend.make b/cmake-build-debug/CMakeFiles/nhf.dir/depend.make index df77db378cf70ee786e961a9e25bed7cb9ad4806..4abfb174b1712f5741c304bf9c35df45127a1130 100644 --- a/cmake-build-debug/CMakeFiles/nhf.dir/depend.make +++ b/cmake-build-debug/CMakeFiles/nhf.dir/depend.make @@ -4,6 +4,51 @@ CMakeFiles/nhf.dir/main.c.o: ../main.c CMakeFiles/nhf.dir/main.c.o: ../move.h CMakeFiles/nhf.dir/main.c.o: ../view.h +CMakeFiles/nhf.dir/main.c.o: /usr/include/SDL2/SDL.h +CMakeFiles/nhf.dir/main.c.o: /usr/include/SDL2/SDL_assert.h +CMakeFiles/nhf.dir/main.c.o: /usr/include/SDL2/SDL_atomic.h +CMakeFiles/nhf.dir/main.c.o: /usr/include/SDL2/SDL_audio.h +CMakeFiles/nhf.dir/main.c.o: /usr/include/SDL2/SDL_blendmode.h +CMakeFiles/nhf.dir/main.c.o: /usr/include/SDL2/SDL_clipboard.h +CMakeFiles/nhf.dir/main.c.o: /usr/include/SDL2/SDL_config.h +CMakeFiles/nhf.dir/main.c.o: /usr/include/SDL2/SDL_cpuinfo.h +CMakeFiles/nhf.dir/main.c.o: /usr/include/SDL2/SDL_endian.h +CMakeFiles/nhf.dir/main.c.o: /usr/include/SDL2/SDL_error.h +CMakeFiles/nhf.dir/main.c.o: /usr/include/SDL2/SDL_events.h +CMakeFiles/nhf.dir/main.c.o: /usr/include/SDL2/SDL_filesystem.h +CMakeFiles/nhf.dir/main.c.o: /usr/include/SDL2/SDL_gamecontroller.h +CMakeFiles/nhf.dir/main.c.o: /usr/include/SDL2/SDL_gesture.h +CMakeFiles/nhf.dir/main.c.o: /usr/include/SDL2/SDL_haptic.h +CMakeFiles/nhf.dir/main.c.o: /usr/include/SDL2/SDL_hints.h +CMakeFiles/nhf.dir/main.c.o: /usr/include/SDL2/SDL_joystick.h +CMakeFiles/nhf.dir/main.c.o: /usr/include/SDL2/SDL_keyboard.h +CMakeFiles/nhf.dir/main.c.o: /usr/include/SDL2/SDL_keycode.h +CMakeFiles/nhf.dir/main.c.o: /usr/include/SDL2/SDL_loadso.h +CMakeFiles/nhf.dir/main.c.o: /usr/include/SDL2/SDL_log.h +CMakeFiles/nhf.dir/main.c.o: /usr/include/SDL2/SDL_main.h +CMakeFiles/nhf.dir/main.c.o: /usr/include/SDL2/SDL_messagebox.h +CMakeFiles/nhf.dir/main.c.o: /usr/include/SDL2/SDL_mouse.h +CMakeFiles/nhf.dir/main.c.o: /usr/include/SDL2/SDL_mutex.h +CMakeFiles/nhf.dir/main.c.o: /usr/include/SDL2/SDL_pixels.h +CMakeFiles/nhf.dir/main.c.o: /usr/include/SDL2/SDL_platform.h +CMakeFiles/nhf.dir/main.c.o: /usr/include/SDL2/SDL_power.h +CMakeFiles/nhf.dir/main.c.o: /usr/include/SDL2/SDL_quit.h +CMakeFiles/nhf.dir/main.c.o: /usr/include/SDL2/SDL_rect.h +CMakeFiles/nhf.dir/main.c.o: /usr/include/SDL2/SDL_render.h +CMakeFiles/nhf.dir/main.c.o: /usr/include/SDL2/SDL_rwops.h +CMakeFiles/nhf.dir/main.c.o: /usr/include/SDL2/SDL_scancode.h +CMakeFiles/nhf.dir/main.c.o: /usr/include/SDL2/SDL_sensor.h +CMakeFiles/nhf.dir/main.c.o: /usr/include/SDL2/SDL_shape.h +CMakeFiles/nhf.dir/main.c.o: /usr/include/SDL2/SDL_stdinc.h +CMakeFiles/nhf.dir/main.c.o: /usr/include/SDL2/SDL_surface.h +CMakeFiles/nhf.dir/main.c.o: /usr/include/SDL2/SDL_system.h +CMakeFiles/nhf.dir/main.c.o: /usr/include/SDL2/SDL_thread.h +CMakeFiles/nhf.dir/main.c.o: /usr/include/SDL2/SDL_timer.h +CMakeFiles/nhf.dir/main.c.o: /usr/include/SDL2/SDL_touch.h +CMakeFiles/nhf.dir/main.c.o: /usr/include/SDL2/SDL_version.h +CMakeFiles/nhf.dir/main.c.o: /usr/include/SDL2/SDL_video.h +CMakeFiles/nhf.dir/main.c.o: /usr/include/SDL2/begin_code.h +CMakeFiles/nhf.dir/main.c.o: /usr/include/SDL2/close_code.h CMakeFiles/nhf.dir/move.c.o: ../move.c CMakeFiles/nhf.dir/move.c.o: ../move.h diff --git a/cmake-build-debug/CMakeFiles/nhf.dir/link.txt b/cmake-build-debug/CMakeFiles/nhf.dir/link.txt index 5f41754272d0072b599c2df2c1b0d51e700ee00d..e737b810a5b92c753162bd9b8124eee4fe90278b 100644 --- a/cmake-build-debug/CMakeFiles/nhf.dir/link.txt +++ b/cmake-build-debug/CMakeFiles/nhf.dir/link.txt @@ -1 +1 @@ -/usr/bin/cc -I/usr/include/SDL2 -D_REENTRANT -g CMakeFiles/nhf.dir/main.c.o CMakeFiles/nhf.dir/view.c.o CMakeFiles/nhf.dir/move.c.o -o nhf -lm -lSDL2 -lSDL2_gfx -lSDL2 -lSDL2_image -lSDL2_gfx -lSDL2_image +/usr/bin/cc -I/usr/include/SDL2 -D_REENTRANT -g CMakeFiles/nhf.dir/main.c.o CMakeFiles/nhf.dir/view.c.o CMakeFiles/nhf.dir/move.c.o -o nhf -lm -lSDL2 -lSDL2_gfx -lSDL2 -lSDL2_ttf -lSDL2 -lSDL2_image -lSDL2 -lSDL2_gfx -lSDL2_ttf -lSDL2_image diff --git a/cmake-build-debug/CMakeFiles/nhf.dir/main.c.o b/cmake-build-debug/CMakeFiles/nhf.dir/main.c.o index d3333df879a65d76feadf0a11b9272e97940304f..1badde9d94d4da39773c09a263fc5ca93f833b78 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 ee2cd6e54e1cf53d1510a704cfb4b77642249da4..9cdd0c5e62a76bcb042f8b8d364803aac063a2fb 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/CMakeFiles/nhf.dir/view.c.o b/cmake-build-debug/CMakeFiles/nhf.dir/view.c.o index 892b6a9b105a6463db5fcc601161da4cd066c901..bf77b6e2bf01e700c7d93ed91eec7a05583f5b12 100644 Binary files a/cmake-build-debug/CMakeFiles/nhf.dir/view.c.o and b/cmake-build-debug/CMakeFiles/nhf.dir/view.c.o differ diff --git a/cmake-build-debug/nhf b/cmake-build-debug/nhf index 20cbcb3e29a8571586abe52408e1bb7dce4e947e..ebcac7722abbdef13c6ddef2572d78bd16ae40b1 100755 Binary files a/cmake-build-debug/nhf and b/cmake-build-debug/nhf differ diff --git a/main.c b/main.c index 46901bfa4178b1b457ca92a387b89006a8c56c98..c408f7c27a7947a670307216d2cd54a18e390ee0 100644 --- a/main.c +++ b/main.c @@ -1,40 +1,56 @@ -#include <SDL2/SDL_image.h> -#include <stdbool.h> #include "view.h" #include "move.h" +#include <SDL2/SDL_image.h> +#include <SDL2/SDL2_gfxPrimitives.h> +#include <stdbool.h> +#include <time.h> -int H = 600; -int W = 900; - -SDL_Window *window; -SDL_Renderer *renderer; +Uint32 idozit(Uint32 ms, void *param) { + SDL_Event ev; + ev.type = SDL_USEREVENT; + SDL_PushEvent(&ev); + return ms; /* ujabb varakozas */ +} int main(int argc, char *argv[]) { + srand(time(NULL)); + sdl_init(W, H, &window, &renderer); SDL_Texture *bagoly = kep_betolt(renderer, "infoc.png"); - SDL_RenderPresent(renderer); //az elvegzett rajzolasok a kepernyore + SDL_TimerID timer_id = SDL_AddTimer(1000/60, idozit, NULL); + SDL_RenderPresent(renderer); bool quit = false; bool moving = false; + bool reset = false; int elozo_x = 0; - int elozo_y = 0; + int elozo_y = 550 - owl; + + Palyaelem *elem = NULL; + + elem = palya_gen(elem, 20); + while (!quit) { SDL_Event ev; SDL_WaitEvent(&ev); + SDL_SetRenderDrawColor(renderer, 0, 0, 0, 255); SDL_RenderClear(renderer); + palyakirajzol(renderer, elem); - keywatcher(ev, bagoly, elozo_x, elozo_y, &quit, &moving, renderer); + + keywatcher(ev, bagoly, elozo_x, elozo_y, &quit, &moving); if (moving){ - move_draw(ev, bagoly, renderer, &elozo_x, &elozo_y); + move_draw(ev, bagoly, &elozo_x, &elozo_y, elem); + } SDL_RenderPresent(renderer); diff --git a/move.c b/move.c index 4096ecaa4a0e33a5da164055f122e35ea5db159a..0f76ee085f2b5b01972720f05f17b78128eadd02 100644 --- a/move.c +++ b/move.c @@ -2,80 +2,69 @@ // Created by blint on 2019. 11. 06.. // -#include <SDL.h> -#include <stdbool.h> #include "move.h" #include "view.h" +#include <SDL.h> +#include <stdbool.h> +#include <math.h> + -int v = 5; -int vx = 0; -int vy = 0; +int v = 8; +int vj = 25; +int t = 0; +int ipszilon = 0; +double g = 5; //saját gravitáció, mivel a 9.82 túl nehéz lenne... :'( +bool jump = false; -static void move(SDL_Event ev) +int VPos(int y0){ + int time = t/2; + return y0 - vj*time + ((int)g/2)*time*time; +} + +static void move(SDL_Event ev, int *x, int *y) { switch (ev.type) { + case SDL_MOUSEMOTION: + return; case SDL_KEYDOWN: - if (ev.key.keysym.sym == SDLK_a) { - vx = -1; - vx *= v; + if (ev.key.keysym.sym == SDLK_a || ev.key.keysym.sym == SDLK_LEFT) { + *x -= v; break; } - if (ev.key.keysym.sym == SDLK_d) { - vx = 1; - vx *= v; + if (ev.key.keysym.sym == SDLK_d || ev.key.keysym.sym == SDLK_RIGHT) { + *x += v; break; } - if (ev.key.keysym.sym == SDLK_w) { - vy = -1; - vy *= v; - break; - } + if (ev.key.keysym.sym == SDLK_w || ev.key.keysym.sym == SDLK_UP || ev.key.keysym.sym == SDLK_SPACE) { + //*y -= v; + t = 0; + ipszilon = *y; + jump = true; - if (ev.key.keysym.sym == SDLK_s) { - vy = 1; - vy *= v; break; } - case SDL_KEYUP: - switch (ev.key.keysym.sym) { - - case SDLK_a: - if (vx < 0) - vx = 0; - break; - - case SDLK_d: - if (vx > 0) - vx = 0; - break; + case SDL_USEREVENT: + t++; + break; - case SDLK_w: - if (vy < 0) - vy = 0; - break; - case SDLK_s: - if (vy > 0) - vy = 0; - break; - default: - break; - } - break; } + } -void keywatcher(SDL_Event ev, SDL_Texture *kep, int x, int y, bool *quit, bool *moving, SDL_Renderer *renderer) +void keywatcher(SDL_Event ev, SDL_Texture *kep, int x, int y, bool *quit, bool *moving) { switch (ev.type) { case SDL_KEYUP: switch (ev.key.keysym.sym) { case SDLK_i: kirajzol(renderer, kep, x, y); + t = 0; + ipszilon = 500; *moving = true; break; case SDLK_ESCAPE: @@ -90,11 +79,65 @@ void keywatcher(SDL_Event ev, SDL_Texture *kep, int x, int y, bool *quit, bool * } } -void move_draw(SDL_Event ev, SDL_Texture *kep, SDL_Renderer *renderer, int *x, int *y) +Palyaelem *palyamozgat(Palyaelem *eleje, int x) { - move(ev); - *x += vx; - *y += vy; - kirajzol(renderer, kep, *x, *y); + Palyaelem *mozgo; + + for (mozgo = eleje; mozgo != NULL; mozgo = mozgo->kov) + { + mozgo->x -= x; + } + return eleje; +} + + +void move_draw(SDL_Event ev, SDL_Texture *kep, int *x, int *y, Palyaelem *eleje) +{ + move(ev, x, y); + + Palyaelem *mozgo; + for (mozgo = eleje; mozgo != NULL; mozgo = mozgo->kov) + { + if ((*x <= mozgo->x && (*x + owl) > (mozgo->x) ) || (*x >= mozgo->x && (*x + owl) <= (mozgo->x + mozgo->hossz))) + { + if ((*y + owl) <= mozgo->y + mozgo->magassag && (*y + owl) >= mozgo->y) + { + *y = mozgo->y - owl; + jump = false; + if (ev.key.keysym.sym == SDLK_w || ev.key.keysym.sym == SDLK_UP || ev.key.keysym.sym == SDLK_SPACE) + jump = true; + } + } + } + if (jump) + { + *y = VPos(ipszilon); + } + + jump = true; + //talajszintnél lejjebb nem ugrik + if (*y >= (H -2*owl)) + { + *y = H - 2*owl; + } + + + + //pálya bal szélénél eltolja a koordinátákat + if (*x > (W - owl)) + { + *x = W - owl; + palyamozgat(eleje, v); + } + + //pálya jobb szélénél tolja el a koordinátákat + if (*x < 0) + { + *x = 0; + palyamozgat(eleje, -v); + } + + + kirajzol(renderer, kep, *x, *y); } \ No newline at end of file diff --git a/move.h b/move.h index ba4347096b371595619a37a301437871bd77ed9c..f956ebd5c7ce9ccd55672c66a09caa5a564e1825 100644 --- a/move.h +++ b/move.h @@ -4,13 +4,25 @@ #ifndef NHF_MOVE_H #define NHF_MOVE_H -#endif //NHF_MOVE_H + +#include "view.h" +#include <SDL.h> +#include <stdbool.h> +#include <math.h> + extern int v; extern int vx; extern int vy; +extern double g; +extern double pi; + + +//static void move(SDL_Event ev, int *x, int *y); + +void keywatcher(SDL_Event ev, SDL_Texture *kep, int x, int y, bool *quit, bool *moving); -static void move(SDL_Event ev); +void move_draw(SDL_Event ev, SDL_Texture *kep, int *x, int *y, Palyaelem *eleje); -void keywatcher(SDL_Event ev, SDL_Texture *kep, int x, int y, bool *quit, bool *moving, SDL_Renderer *renderer); +Palyaelem *palyamozgat(Palyaelem *eleje, int x); -void move_draw(SDL_Event ev, SDL_Texture *kep, SDL_Renderer *renderer, int *x, int *y); \ No newline at end of file +#endif //NHF_MOVE_H \ No newline at end of file diff --git a/view.c b/view.c index fe530958566daf6d1ae4107c6de7803633fbc595..e66865aef508164868108b46225a35608f321200 100644 --- a/view.c +++ b/view.c @@ -1,14 +1,20 @@ // // Created by blint on 2019. 11. 06.. // + +#include "view.h" #include <SDL2/SDL.h> #include <SDL2/SDL_image.h> #include <stdlib.h> #include <stdio.h> -#include "view.h" +int H = 600; +int W = 900; int owl = 50; +SDL_Window *window; +SDL_Renderer *renderer; + void sdl_init(int szeles, int magas, SDL_Window **pwindow, SDL_Renderer **prenderer) { if (SDL_Init(SDL_INIT_EVERYTHING) < 0) { SDL_Log("Nem indithato az SDL: %s", SDL_GetError()); @@ -47,4 +53,68 @@ void kirajzol(SDL_Renderer *renderer, SDL_Texture *kep, int x, int y) { SDL_Rect src = {0, 0, 128, 128}; SDL_Rect dest = {x, y, owl, owl}; SDL_RenderCopy(renderer, kep, &src, &dest); +} + +Palyaelem *gen_elem(Palyaelem *elem) +{ + Palyaelem *uj = (Palyaelem *) malloc(sizeof(Palyaelem)); + uj->kov = NULL; + + if (elem == NULL) + { + uj->hossz = rand() % (W / 3) + 100; + uj->x = (W/1/3); + uj->y = (H - (3*owl)); + uj->magassag = 20; + elem = uj; + return elem; + } + + Palyaelem *mozgo; + for (mozgo = elem; mozgo->kov != NULL; mozgo = mozgo->kov); + mozgo->kov = uj; + + uj->hossz = rand() % ((W / 2) + 1) + 100; + uj->x = rand() % (W - (mozgo->x + mozgo->hossz)) + (mozgo->x + mozgo->hossz + 2*owl); + uj->y = rand() % (mozgo->magassag + (4*owl)) + (mozgo->y - owl); + if (uj->y >= (H - owl)) + uj->y -= (3*owl); + uj->magassag = 20; + + return elem; +} + +void palyaelem_kirajzolo(Palyaelem *elem, SDL_Renderer *prenderer) +{ + SDL_Rect r; + r.x = elem->x; + r.y = elem->y; + r.w = elem->hossz; + r.h = elem->magassag; + + SDL_SetRenderDrawColor( renderer, 0, 255, 0, 255 ); + SDL_RenderFillRect( prenderer, &r ); +} + +Palyaelem* palya_gen(Palyaelem *eleje, int hany_elem) +{ + for (int i = 0; i < hany_elem; ++i) { + eleje = gen_elem(eleje); + } + return eleje; +} + +void palyakirajzol(SDL_Renderer *prenderer, Palyaelem *elem) +{ + Palyaelem alap; + alap.x = 0; + alap.y = 550; + alap.hossz = 900; + alap.magassag = 50; + + palyaelem_kirajzolo(&alap, prenderer); + Palyaelem * mozgo; + for (mozgo = elem; mozgo != NULL; mozgo = mozgo->kov) + palyaelem_kirajzolo(mozgo, prenderer); + } \ No newline at end of file diff --git a/view.h b/view.h index ac4f0fe5146a567e7cd548b78ae3a1bc5a92f341..6199da11ceeb64a524304a3f4e00f591085144e1 100644 --- a/view.h +++ b/view.h @@ -4,12 +4,37 @@ #ifndef NHF_VIEW_H #define NHF_VIEW_H -#endif //NHF_VIEW_H +#include <SDL2/SDL.h> +#include <SDL2/SDL_image.h> +#include <stdlib.h> +#include <stdio.h> + +typedef struct Palyaelem{ + int x, y; + int hossz, magassag; + struct Palyaelem *kov; +}Palyaelem; + +extern int H; +extern int W; extern int owl; +extern SDL_Window *window; +extern SDL_Renderer *renderer; + 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); + +Palyaelem *gen_elem(Palyaelem *elem); + +void palyaelem_kirajzolo(Palyaelem *elem, SDL_Renderer *prenderer); + +Palyaelem* palya_gen(Palyaelem *eleje, int hany_elem); + +void palyakirajzol(SDL_Renderer *prenderer, Palyaelem *elem); + +#endif //NHF_VIEW_H \ No newline at end of file