├── .appveyor.yml ├── .clang-format ├── .clang-tidy ├── .dockerignore ├── .github ├── FUNDING.yml ├── pull_request_template.md └── workflows │ ├── bundling.yml │ └── ci.yml ├── .gitignore ├── .gitmodules ├── 3rd_party ├── CMakeLists.txt ├── dbopl │ ├── CMakeLists.txt │ ├── dbopl.cpp │ └── dbopl.h ├── glad │ ├── 3.0 │ │ ├── include │ │ │ ├── KHR │ │ │ │ └── khrplatform.h │ │ │ └── glad │ │ │ │ └── glad.h │ │ └── src │ │ │ └── glad.c │ ├── CMakeLists.txt │ └── es2.0 │ │ ├── include │ │ ├── KHR │ │ │ └── khrplatform.h │ │ └── glad │ │ │ └── glad.h │ │ └── src │ │ └── glad.c ├── imgui-filebrowser │ ├── CMakeLists.txt │ ├── imfilebrowser.cpp │ └── imfilebrowser.h ├── imgui │ ├── CMakeLists.txt │ ├── imgui_impl_opengl3.cpp │ ├── imgui_impl_opengl3.h │ ├── imgui_impl_sdl.cpp │ └── imgui_impl_sdl.h ├── loguru │ ├── CMakeLists.txt │ ├── loguru.cpp │ └── loguru.hpp ├── lyra │ ├── LICENSE.txt │ ├── README.md │ └── include │ │ └── lyra │ │ ├── arg.hpp │ │ ├── args.hpp │ │ ├── arguments.hpp │ │ ├── cli.hpp │ │ ├── cli_parser.hpp │ │ ├── command.hpp │ │ ├── detail │ │ ├── bound.hpp │ │ ├── choices.hpp │ │ ├── deprecated_parser_customization.hpp │ │ ├── from_string.hpp │ │ ├── invoke_lambda.hpp │ │ ├── parse.hpp │ │ ├── print.hpp │ │ ├── result.hpp │ │ ├── tokens.hpp │ │ ├── trait_utils.hpp │ │ └── unary_lambda_traits.hpp │ │ ├── exe_name.hpp │ │ ├── group.hpp │ │ ├── help.hpp │ │ ├── literal.hpp │ │ ├── lyra.hpp │ │ ├── main.hpp │ │ ├── opt.hpp │ │ ├── option_style.hpp │ │ ├── parser.hpp │ │ ├── parser_result.hpp │ │ ├── val.hpp │ │ └── version.hpp ├── nlohmann │ └── nlohmann │ │ └── json.hpp ├── nuked-opl3 │ ├── CMakeLists.txt │ ├── LICENSE │ ├── opl3.c │ └── opl3.h ├── speex_resampler │ ├── CMakeLists.txt │ └── speex │ │ ├── arch.h │ │ ├── resample.c │ │ ├── resample_neon.h │ │ ├── resample_sse.h │ │ ├── speex_resampler.h │ │ └── stack_alloc.h ├── static_vector │ ├── README.md │ └── include │ │ └── experimental │ │ └── fixed_capacity_vector └── stb │ ├── CMakeLists.txt │ ├── stb.cpp │ ├── stb_image.h │ ├── stb_image_write.h │ └── stb_rect_pack.h ├── AUTHORS.md ├── BUILDING.md ├── CMakeLists.txt ├── CONTRIBUTING.md ├── LICENSE.md ├── README.md ├── benchmark ├── CMakeLists.txt └── bench_string_utils.cpp ├── cmake ├── Modules │ ├── FindFilesystem.cmake │ ├── FindSDL2.cmake │ └── FindSDL2_mixer.cmake ├── rigel.cmake ├── rigel_pack.cmake └── rigel_sanitizers.cmake ├── dist ├── README.md ├── emscripten │ ├── android-chrome-192x192.png │ ├── android-chrome-512x512.png │ ├── apple-touch-icon.png │ ├── browserconfig.xml │ ├── favicon-16x16.png │ ├── favicon-32x32.png │ ├── favicon.ico │ ├── mstile-150x150.png │ ├── robots.txt │ ├── safari-pinned-tab.svg │ ├── shell.html │ └── site.webmanifest ├── icon_original │ ├── 128.png │ ├── 16.png │ ├── 32.png │ ├── 48.png │ └── 64.png ├── linux │ ├── rigelengine.desktop │ ├── rigelengine.metainfo.xml │ ├── rigelengine_128.png │ ├── rigelengine_48.png │ └── rigelengine_64.png ├── osx │ ├── Info.plist │ └── RigelEngine.icns └── win │ ├── RigelEngine.ico │ └── RigelEngine.rc ├── docker ├── ubuntu-deps.sh └── ubuntu.Dockerfile ├── src ├── CMakeLists.txt ├── README.md ├── assets │ ├── actor_image_package.cpp │ ├── actor_image_package.hpp │ ├── audio_package.cpp │ ├── audio_package.hpp │ ├── bitwise_iter.hpp │ ├── byte_buffer.hpp │ ├── cmp_file_package.cpp │ ├── cmp_file_package.hpp │ ├── duke_script_loader.cpp │ ├── duke_script_loader.hpp │ ├── ega_image_decoder.cpp │ ├── ega_image_decoder.hpp │ ├── file_utils.cpp │ ├── file_utils.hpp │ ├── level_loader.cpp │ ├── level_loader.hpp │ ├── movie_loader.cpp │ ├── movie_loader.hpp │ ├── music_loader.cpp │ ├── music_loader.hpp │ ├── palette.cpp │ ├── palette.hpp │ ├── png_image.cpp │ ├── png_image.hpp │ ├── resource_loader.cpp │ ├── resource_loader.hpp │ ├── rle_compression.hpp │ ├── ultrawide_hud_image.ipp │ ├── user_profile_import.cpp │ ├── user_profile_import.hpp │ ├── voc_decoder.cpp │ ├── voc_decoder.hpp │ └── wide_hud_image.ipp ├── audio │ ├── adlib_emulator.hpp │ ├── software_imf_player.cpp │ ├── software_imf_player.hpp │ ├── sound_system.cpp │ └── sound_system.hpp ├── base │ ├── array_view.cpp │ ├── array_view.hpp │ ├── audio_buffer.hpp │ ├── clock.hpp │ ├── color.hpp │ ├── container_utils.hpp │ ├── defer.hpp │ ├── grid.hpp │ ├── image.cpp │ ├── image.hpp │ ├── match.hpp │ ├── math_utils.hpp │ ├── spatial_types.hpp │ ├── spatial_types_printing.hpp │ ├── static_vector.hpp │ ├── string_utils.cpp │ ├── string_utils.hpp │ └── warnings.hpp ├── data │ ├── actor_ids.hpp │ ├── bonus.hpp │ ├── duke_script.hpp │ ├── game_options.cpp │ ├── game_options.hpp │ ├── game_session_data.hpp │ ├── game_traits.hpp │ ├── high_score_list.cpp │ ├── high_score_list.hpp │ ├── level_hints.cpp │ ├── level_hints.hpp │ ├── map.cpp │ ├── map.hpp │ ├── mod_library.cpp │ ├── mod_library.hpp │ ├── movie.hpp │ ├── palette.hpp │ ├── player_model.cpp │ ├── player_model.hpp │ ├── saved_game.hpp │ ├── song.hpp │ ├── sound_ids.hpp │ ├── strings.hpp │ ├── tile_attributes.hpp │ ├── tile_attributes.ipp │ ├── tutorial_messages.cpp │ ├── tutorial_messages.hpp │ ├── unit_conversions.cpp │ └── unit_conversions.hpp ├── emscripten_main.cpp ├── engine │ ├── base_components.hpp │ ├── collision_checker.cpp │ ├── collision_checker.hpp │ ├── entity_activation_system.cpp │ ├── entity_activation_system.hpp │ ├── entity_tools.hpp │ ├── graphical_effects.cpp │ ├── graphical_effects.hpp │ ├── isprite_factory.hpp │ ├── life_time_components.hpp │ ├── life_time_system.cpp │ ├── life_time_system.hpp │ ├── map_renderer.cpp │ ├── map_renderer.hpp │ ├── motion_smoothing.hpp │ ├── movement.cpp │ ├── movement.hpp │ ├── particle_system.cpp │ ├── particle_system.hpp │ ├── physical_components.hpp │ ├── physics.cpp │ ├── physics.hpp │ ├── physics_system.cpp │ ├── physics_system.hpp │ ├── random_number_generator.cpp │ ├── random_number_generator.hpp │ ├── sprite_factory.cpp │ ├── sprite_factory.hpp │ ├── sprite_rendering_system.cpp │ ├── sprite_rendering_system.hpp │ ├── sprite_tools.hpp │ ├── tiled_texture.cpp │ ├── tiled_texture.hpp │ ├── timing.hpp │ └── visual_components.hpp ├── frontend │ ├── anti_piracy_screen_mode.cpp │ ├── anti_piracy_screen_mode.hpp │ ├── command_line_options.hpp │ ├── demo_player.cpp │ ├── demo_player.hpp │ ├── game.cpp │ ├── game.hpp │ ├── game_mode.cpp │ ├── game_mode.hpp │ ├── game_runner.cpp │ ├── game_runner.hpp │ ├── game_service_provider.hpp │ ├── game_session_mode.cpp │ ├── game_session_mode.hpp │ ├── input_handler.cpp │ ├── input_handler.hpp │ ├── intro_demo_loop_mode.cpp │ ├── intro_demo_loop_mode.hpp │ ├── json_utils.cpp │ ├── json_utils.hpp │ ├── menu_mode.cpp │ ├── menu_mode.hpp │ ├── user_profile.cpp │ └── user_profile.hpp ├── game_logic │ ├── README.md │ ├── actor_tag.hpp │ ├── behavior_controller.hpp │ ├── behavior_controller_system.cpp │ ├── behavior_controller_system.hpp │ ├── camera.cpp │ ├── camera.hpp │ ├── collectable_components.hpp │ ├── damage_components.hpp │ ├── damage_infliction_system.cpp │ ├── damage_infliction_system.hpp │ ├── debugging_system.cpp │ ├── debugging_system.hpp │ ├── destruction_effect_specs.ipp │ ├── dynamic_geometry_components.hpp │ ├── dynamic_geometry_system.cpp │ ├── dynamic_geometry_system.hpp │ ├── earth_quake_effect.cpp │ ├── earth_quake_effect.hpp │ ├── effect_actor_components.cpp │ ├── effect_actor_components.hpp │ ├── effect_components.hpp │ ├── effects_system.cpp │ ├── effects_system.hpp │ ├── enemies │ │ ├── big_green_cat.cpp │ │ ├── big_green_cat.hpp │ │ ├── blue_guard.cpp │ │ ├── blue_guard.hpp │ │ ├── bomber_plane.cpp │ │ ├── bomber_plane.hpp │ │ ├── boss_episode_1.cpp │ │ ├── boss_episode_1.hpp │ │ ├── boss_episode_2.cpp │ │ ├── boss_episode_2.hpp │ │ ├── boss_episode_3.cpp │ │ ├── boss_episode_3.hpp │ │ ├── boss_episode_4.cpp │ │ ├── boss_episode_4.hpp │ │ ├── ceiling_sucker.cpp │ │ ├── ceiling_sucker.hpp │ │ ├── dying_boss.cpp │ │ ├── dying_boss.hpp │ │ ├── enemy_rocket.cpp │ │ ├── enemy_rocket.hpp │ │ ├── eyeball_thrower.cpp │ │ ├── eyeball_thrower.hpp │ │ ├── flame_thrower_bot.cpp │ │ ├── flame_thrower_bot.hpp │ │ ├── floating_laser_bot.cpp │ │ ├── floating_laser_bot.hpp │ │ ├── grabber_claw.cpp │ │ ├── grabber_claw.hpp │ │ ├── green_bird.cpp │ │ ├── green_bird.hpp │ │ ├── hover_bot.cpp │ │ ├── hover_bot.hpp │ │ ├── laser_turret.cpp │ │ ├── laser_turret.hpp │ │ ├── messenger_drone.cpp │ │ ├── messenger_drone.hpp │ │ ├── prisoner.cpp │ │ ├── prisoner.hpp │ │ ├── red_bird.cpp │ │ ├── red_bird.hpp │ │ ├── rigelatin_soldier.cpp │ │ ├── rigelatin_soldier.hpp │ │ ├── rocket_turret.cpp │ │ ├── rocket_turret.hpp │ │ ├── security_camera.cpp │ │ ├── security_camera.hpp │ │ ├── simple_walker.cpp │ │ ├── simple_walker.hpp │ │ ├── slime_blob.cpp │ │ ├── slime_blob.hpp │ │ ├── small_flying_ship.cpp │ │ ├── small_flying_ship.hpp │ │ ├── snake.cpp │ │ ├── snake.hpp │ │ ├── spider.cpp │ │ ├── spider.hpp │ │ ├── spike_ball.cpp │ │ ├── spike_ball.hpp │ │ ├── spiked_green_creature.cpp │ │ ├── spiked_green_creature.hpp │ │ ├── unicycle_bot.cpp │ │ ├── unicycle_bot.hpp │ │ ├── wall_walker.cpp │ │ ├── wall_walker.hpp │ │ ├── watch_bot.cpp │ │ └── watch_bot.hpp │ ├── entity_configuration.ipp │ ├── entity_factory.cpp │ ├── entity_factory.hpp │ ├── game_world.cpp │ ├── game_world.hpp │ ├── global_dependencies.hpp │ ├── hazards │ │ ├── lava_fountain.cpp │ │ ├── lava_fountain.hpp │ │ ├── slime_pipe.cpp │ │ ├── slime_pipe.hpp │ │ ├── smash_hammer.cpp │ │ └── smash_hammer.hpp │ ├── ientity_factory.hpp │ ├── interactive │ │ ├── blowing_fan.cpp │ │ ├── blowing_fan.hpp │ │ ├── elevator.cpp │ │ ├── elevator.hpp │ │ ├── enemy_radar.cpp │ │ ├── enemy_radar.hpp │ │ ├── force_field.cpp │ │ ├── force_field.hpp │ │ ├── item_container.cpp │ │ ├── item_container.hpp │ │ ├── locked_door.cpp │ │ ├── locked_door.hpp │ │ ├── missile.cpp │ │ ├── missile.hpp │ │ ├── respawn_checkpoint.cpp │ │ ├── respawn_checkpoint.hpp │ │ ├── sliding_door.cpp │ │ ├── sliding_door.hpp │ │ ├── super_force_field.cpp │ │ ├── super_force_field.hpp │ │ ├── tile_burner.cpp │ │ └── tile_burner.hpp │ ├── player.cpp │ ├── player.hpp │ ├── player │ │ ├── components.hpp │ │ ├── damage_system.cpp │ │ ├── damage_system.hpp │ │ ├── interaction_system.cpp │ │ ├── interaction_system.hpp │ │ ├── level_exit_trigger.cpp │ │ ├── level_exit_trigger.hpp │ │ ├── projectile_system.cpp │ │ ├── projectile_system.hpp │ │ ├── ship.cpp │ │ └── ship.hpp │ ├── world_state.cpp │ └── world_state.hpp ├── game_logic_classic │ ├── actors.c │ ├── actors.h │ ├── game.h │ ├── game1.c │ ├── game2.c │ ├── game3.c │ ├── game_world_classic.cpp │ ├── game_world_classic.hpp │ ├── memory.c │ ├── misc.c │ ├── particls.c │ ├── player.c │ ├── sounds.h │ ├── sprite.c │ └── types.h ├── game_logic_common │ ├── igame_world.hpp │ ├── input.hpp │ └── utils.hpp ├── game_main.cpp ├── game_main.hpp ├── main.cpp ├── platform.cpp ├── platform.hpp ├── renderer │ ├── custom_quad_batch.cpp │ ├── custom_quad_batch.hpp │ ├── fps_limiter.cpp │ ├── fps_limiter.hpp │ ├── opengl.cpp │ ├── opengl.hpp │ ├── renderer.cpp │ ├── renderer.hpp │ ├── renderer_support.hpp │ ├── shader.cpp │ ├── shader.hpp │ ├── shader_code.cpp │ ├── shader_code.hpp │ ├── texture.cpp │ ├── texture.hpp │ ├── texture_atlas.cpp │ ├── texture_atlas.hpp │ ├── upscaling.cpp │ ├── upscaling.hpp │ ├── vertex_buffer_utils.hpp │ ├── viewport_utils.cpp │ └── viewport_utils.hpp ├── sdl_utils │ ├── error.cpp │ ├── error.hpp │ ├── key_code.hpp │ ├── platform.cpp │ ├── platform.hpp │ └── ptr.hpp ├── ui │ ├── apogee_logo.cpp │ ├── apogee_logo.hpp │ ├── bonus_screen.cpp │ ├── bonus_screen.hpp │ ├── credits.cpp │ ├── credits.hpp │ ├── duke_3d_teaser_screen.cpp │ ├── duke_3d_teaser_screen.hpp │ ├── duke_script_runner.cpp │ ├── duke_script_runner.hpp │ ├── episode_end_sequence.cpp │ ├── episode_end_sequence.hpp │ ├── fps_display.cpp │ ├── fps_display.hpp │ ├── game_path_browser.cpp │ ├── game_path_browser.hpp │ ├── high_score_list.cpp │ ├── high_score_list.hpp │ ├── hud_renderer.cpp │ ├── hud_renderer.hpp │ ├── imgui_integration.cpp │ ├── imgui_integration.hpp │ ├── ingame_menu.cpp │ ├── ingame_menu.hpp │ ├── ingame_message_display.cpp │ ├── ingame_message_display.hpp │ ├── intro_movie.cpp │ ├── intro_movie.hpp │ ├── menu_element_renderer.cpp │ ├── menu_element_renderer.hpp │ ├── menu_navigation.cpp │ ├── menu_navigation.hpp │ ├── movie_player.cpp │ ├── movie_player.hpp │ ├── options_menu.cpp │ ├── options_menu.hpp │ ├── text_entry_widget.cpp │ ├── text_entry_widget.hpp │ ├── utils.cpp │ └── utils.hpp └── version_info.hpp.in ├── test ├── CMakeLists.txt ├── test_array_view.cpp ├── test_duke_script_loader.cpp ├── test_elevator.cpp ├── test_high_score_list.cpp ├── test_json_utils.cpp ├── test_letter_collection.cpp ├── test_physics_system.cpp ├── test_player.cpp ├── test_rng.cpp ├── test_spike_ball.cpp ├── test_string_utils.cpp ├── test_timing.cpp └── utils.hpp └── tools ├── format-all.sh └── format-staged.sh /.appveyor.yml: -------------------------------------------------------------------------------- 1 | clone_depth: 50 2 | 3 | image: Visual Studio 2019 4 | 5 | branches: 6 | only: 7 | - master 8 | 9 | install: 10 | - git submodule update --init --recursive 11 | 12 | # Download headers and pre-built binaries for SDL2 and SDL2_mixer 13 | - mkdir C:\RigelLibs 14 | - ps: Invoke-WebRequest -Uri https://www.libsdl.org/release/SDL2-devel-2.0.14-VC.zip -OutFile C:\RigelLibs\SDL2.zip 15 | - ps: Invoke-WebRequest -Uri https://www.libsdl.org/projects/SDL_mixer/release/SDL2_mixer-devel-2.0.4-VC.zip -OutFile C:\RigelLibs\SDL2_mixer.zip 16 | - 7z x C:\RigelLibs\SDL2.zip -oC:\RigelLibs 17 | - 7z x C:\RigelLibs\SDL2_mixer.zip -oC:\RigelLibs 18 | 19 | platform: x64 20 | 21 | configuration: 22 | - Debug 23 | - Release 24 | 25 | before_build: 26 | - set SDL2DIR=C:\RigelLibs\SDL2-2.0.14 27 | - set SDL2MIXERDIR=C:\RigelLibs\SDL2_mixer-2.0.4 28 | 29 | - mkdir build 30 | - cd build 31 | - cmake .. -G "Visual Studio 16 2019" -DWARNINGS_AS_ERRORS=ON -DBUILD_BENCHMARKS=ON -DBUILD_TESTS=ON 32 | - cd .. 33 | 34 | build: 35 | parallel: true 36 | project: build/RigelEngine.sln 37 | verbosity: minimal 38 | 39 | before_test: 40 | - set PATH=%PATH%;%SDL2DIR%\lib\x64;%SDL2MIXERDIR%\lib\x64 41 | 42 | test_script: 43 | - cd build 44 | - ctest 45 | - C:\projects\rigelengine\build\src\%CONFIGURATION%\RigelEngine.exe --help 46 | 47 | after_build: 48 | - 7z a rigelengine_win_x64.zip C:\projects\rigelengine\build\src\%CONFIGURATION%\RigelEngine.exe %SDL2DIR%\lib\x64\SDL2.dll %SDL2MIXERDIR%\lib\x64\*.dll 49 | 50 | artifacts: 51 | - path: rigelengine_win_x64.zip 52 | name: RigelBuild 53 | -------------------------------------------------------------------------------- /.clang-format: -------------------------------------------------------------------------------- 1 | AccessModifierOffset: -2 2 | AlignAfterOpenBracket: AlwaysBreak 3 | AlignConsecutiveAssignments: false 4 | AlignConsecutiveBitFields: false 5 | AlignConsecutiveDeclarations: false 6 | AlignConsecutiveMacros: false 7 | AlignEscapedNewlines: Right 8 | AlignOperands: false 9 | AlignTrailingComments: false 10 | AllowAllArgumentsOnNextLine: true 11 | AllowAllConstructorInitializersOnNextLine: true 12 | AllowAllParametersOfDeclarationOnNextLine: false 13 | AllowShortBlocksOnASingleLine: false 14 | AllowShortCaseLabelsOnASingleLine: false 15 | AllowShortEnumsOnASingleLine: false 16 | AllowShortFunctionsOnASingleLine: Inline 17 | AllowShortIfStatementsOnASingleLine: false 18 | AllowShortLambdasOnASingleLine: Inline 19 | AllowShortLoopsOnASingleLine: false 20 | AlwaysBreakTemplateDeclarations: Yes 21 | BasedOnStyle: WebKit 22 | BinPackArguments: false 23 | BinPackParameters: false 24 | BreakBeforeBinaryOperators: None 25 | BreakBeforeBraces: Allman 26 | BreakStringLiterals: false 27 | ColumnLimit: 80 28 | ConstructorInitializerAllOnOneLineOrOnePerLine: false 29 | ConstructorInitializerIndentWidth : 2 30 | ContinuationIndentWidth: 2 31 | Cpp11BracedListStyle: true 32 | DerivePointerAlignment: false 33 | ExperimentalAutoDetectBinPacking: false 34 | FixNamespaceComments: true 35 | IndentCaseBlocks: true 36 | IndentCaseLabels: true 37 | IndentPPDirectives: BeforeHash 38 | IndentWidth: 2 39 | IndentWrappedFunctionNames: true 40 | KeepEmptyLinesAtTheStartOfBlocks: true 41 | Language: Cpp 42 | MaxEmptyLinesToKeep: 2 43 | NamespaceIndentation: None 44 | SpaceAfterTemplateKeyword: true 45 | SpaceBeforeCpp11BracedList: false 46 | Standard: Cpp11 47 | StatementMacros: 48 | - _Pragma 49 | - __pragma 50 | UseTab: Never 51 | -------------------------------------------------------------------------------- /.clang-tidy: -------------------------------------------------------------------------------- 1 | # To run: 2 | # clang-tidy -fix -p build $(git ls-files src/) 3 | 4 | Checks: > 5 | ,-*, 6 | ,google-explicit-constructor, 7 | ,misc-move-const-arg, 8 | ,misc-string-constructor, 9 | ,modernize-*, 10 | ,performance-*, 11 | ,-modernize-use-default-member-init, 12 | 13 | HeaderFilterRegex: 'src/' 14 | -------------------------------------------------------------------------------- /.dockerignore: -------------------------------------------------------------------------------- 1 | build* 2 | .git 3 | .vscode 4 | -------------------------------------------------------------------------------- /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | custom: ['https://www.paypal.com/donate?hosted_button_id=B3JBDMWJE6F4C'] 2 | -------------------------------------------------------------------------------- /.github/pull_request_template.md: -------------------------------------------------------------------------------- 1 | Thank you for taking the time to contribute to RigelEngine! 2 | I really appreciate it. 3 | 4 | Please read [the contribution guidelines](https://github.com/lethal-guitar/RigelEngine/blob/master/CONTRIBUTING.md) if you haven't already. 5 | 6 | To make the process as smooth as possible for both of us, 7 | I'd ask you to check a few things before submitting your PR: 8 | 9 | * [ ] I've compiled the code locally on my machine, and it builds without errors 10 | * [ ] I've launched the game on my machine after making my changes, and I can successfully start a new game from the main menu 11 | 12 | If your changes are only touching documentation or similar files, 13 | which have no influence on the behavior of the code, 14 | you can ignore this of course. 15 | 16 | Please remove this text before submitting your PR! 17 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | build/ 2 | build*/ 3 | .vs 4 | .vscode 5 | -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "3rd_party/entityx"] 2 | path = 3rd_party/entityx 3 | url = https://github.com/alecthomas/entityx.git 4 | [submodule "3rd_party/glm"] 5 | path = 3rd_party/glm 6 | url = https://github.com/g-truc/glm.git 7 | [submodule "3rd_party/imgui/imgui"] 8 | path = 3rd_party/imgui/imgui 9 | url = https://github.com/ocornut/imgui.git 10 | -------------------------------------------------------------------------------- /3rd_party/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Header-only targets 2 | ############################################################################### 3 | 4 | add_library(glm INTERFACE) 5 | target_include_directories(glm 6 | INTERFACE 7 | "${CMAKE_CURRENT_SOURCE_DIR}/glm" 8 | ) 9 | add_library(nlohmann-json INTERFACE) 10 | target_include_directories(nlohmann-json 11 | INTERFACE 12 | "${CMAKE_CURRENT_SOURCE_DIR}/nlohmann" 13 | ) 14 | add_library(static_vector INTERFACE) 15 | target_include_directories(static_vector 16 | INTERFACE 17 | "${CMAKE_CURRENT_SOURCE_DIR}/static_vector/include" 18 | ) 19 | add_library(lyra INTERFACE) 20 | target_include_directories(lyra 21 | INTERFACE 22 | "${CMAKE_CURRENT_SOURCE_DIR}/lyra/include" 23 | ) 24 | 25 | 26 | # Compiled targets 27 | ############################################################################### 28 | 29 | set(ENTITYX_BUILD_SHARED false CACHE INTERNAL "") 30 | set(ENTITYX_BUILD_TESTING false CACHE INTERNAL "") 31 | set(ENTITYX_DT_TYPE double CACHE INTERNAL "") 32 | set(ENTITYX_RUN_BENCHMARKS false CACHE INTERNAL "") 33 | set(ENTITYX_MAX_COMPONENTS 64 CACHE INTERNAL "") 34 | 35 | # EXCLUDE_FROM_ALL to disable installing these HO or static library deps 36 | add_subdirectory(dbopl EXCLUDE_FROM_ALL) 37 | add_subdirectory(entityx EXCLUDE_FROM_ALL) 38 | add_subdirectory(glad EXCLUDE_FROM_ALL) 39 | add_subdirectory(speex_resampler EXCLUDE_FROM_ALL) 40 | add_subdirectory(stb EXCLUDE_FROM_ALL) 41 | add_subdirectory(imgui EXCLUDE_FROM_ALL) 42 | add_subdirectory(imgui-filebrowser EXCLUDE_FROM_ALL) 43 | add_subdirectory(nuked-opl3 EXCLUDE_FROM_ALL) 44 | add_subdirectory(loguru EXCLUDE_FROM_ALL) 45 | 46 | rigel_disable_warnings(entityx) 47 | -------------------------------------------------------------------------------- /3rd_party/dbopl/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(sources 2 | dbopl.h 3 | dbopl.cpp 4 | ) 5 | 6 | add_library(dbopl STATIC ${sources}) 7 | target_include_directories(dbopl 8 | INTERFACE 9 | ${CMAKE_CURRENT_SOURCE_DIR} 10 | ) 11 | rigel_disable_warnings(dbopl) 12 | -------------------------------------------------------------------------------- /3rd_party/glad/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | if (USE_GL_ES) 2 | set(gl_variant "es2.0") 3 | else() 4 | set(gl_variant "3.0") 5 | endif() 6 | 7 | set(sources 8 | "${gl_variant}/src/glad.c" 9 | ) 10 | 11 | set(glad_include_dir "${CMAKE_CURRENT_SOURCE_DIR}/${gl_variant}/include") 12 | 13 | add_library(glad STATIC ${sources}) 14 | target_include_directories(glad PUBLIC ${glad_include_dir}) 15 | target_link_libraries(glad PRIVATE ${CMAKE_DL_LIBS}) 16 | rigel_disable_warnings(glad) 17 | 18 | if(CMAKE_CXX_COMPILER_ID MATCHES "Clang") 19 | target_compile_options(glad PRIVATE 20 | # This is required in order to successfully link the test executable 21 | # on Mac. 22 | -fno-common 23 | ) 24 | endif() 25 | -------------------------------------------------------------------------------- /3rd_party/imgui-filebrowser/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_library(imgui-filebrowser STATIC 2 | imfilebrowser.h 3 | imfilebrowser.cpp 4 | ) 5 | target_link_libraries(imgui-filebrowser 6 | PUBLIC 7 | dear_imgui 8 | ) 9 | target_include_directories(imgui-filebrowser 10 | INTERFACE 11 | ${CMAKE_SOURCE_DIR}/3rd_party/imgui-filebrowser 12 | ) 13 | -------------------------------------------------------------------------------- /3rd_party/imgui/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_library(dear_imgui STATIC 2 | imgui_impl_opengl3.cpp 3 | imgui_impl_sdl.cpp 4 | 5 | imgui/imgui.cpp 6 | imgui/imgui_draw.cpp 7 | imgui/imgui_tables.cpp 8 | imgui/imgui_widgets.cpp 9 | ) 10 | target_include_directories(dear_imgui 11 | PUBLIC 12 | ${CMAKE_SOURCE_DIR}/3rd_party/imgui/ 13 | ${CMAKE_SOURCE_DIR}/3rd_party/imgui/imgui 14 | ) 15 | target_link_libraries(dear_imgui 16 | PRIVATE 17 | SDL2::Core 18 | stb 19 | glad 20 | ) 21 | 22 | if (APPLE) 23 | target_link_libraries(dear_imgui 24 | PRIVATE 25 | "-framework AppKit" 26 | ) 27 | endif() 28 | 29 | 30 | target_compile_definitions(dear_imgui 31 | PRIVATE 32 | -DIMGUI_IMPL_OPENGL_LOADER_GLAD 33 | -DIMGUI_DISABLE_STB_RECT_PACK_IMPLEMENTATION 34 | "-DIMGUI_STB_RECT_PACK_FILENAME=" 35 | ) 36 | 37 | if (USE_GL_ES) 38 | target_compile_definitions(dear_imgui 39 | PRIVATE 40 | -DIMGUI_IMPL_OPENGL_ES2 41 | -DIMGUI_IMPL_OPENGL_ES_USE_LOADER 42 | ) 43 | endif() 44 | 45 | rigel_disable_warnings(dear_imgui) 46 | -------------------------------------------------------------------------------- /3rd_party/imgui/imgui_impl_sdl.h: -------------------------------------------------------------------------------- 1 | // dear imgui: Platform Binding for SDL2 2 | // This needs to be used along with a Renderer (e.g. DirectX11, OpenGL3, Vulkan..) 3 | // (Info: SDL2 is a cross-platform general purpose library for handling windows, inputs, graphics context creation, etc.) 4 | 5 | // Implemented features: 6 | // [X] Platform: Mouse cursor shape and visibility. Disable with 'io.ConfigFlags |= ImGuiConfigFlags_NoMouseCursorChange'. 7 | // [X] Platform: Clipboard support. 8 | // [X] Platform: Keyboard arrays indexed using SDL_SCANCODE_* codes, e.g. ImGui::IsKeyPressed(SDL_SCANCODE_SPACE). 9 | // [X] Platform: Gamepad support. Enabled with 'io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad'. 10 | // Missing features: 11 | // [ ] Platform: SDL2 handling of IME under Windows appears to be broken and it explicitly disable the regular Windows IME. You can restore Windows IME by compiling SDL with SDL_DISABLE_WINDOWS_IME. 12 | 13 | // You can copy and use unmodified imgui_impl_* files in your project. See main.cpp for an example of using this. 14 | // If you are new to dear imgui, read examples/README.txt and read the documentation at the top of imgui.cpp. 15 | // https://github.com/ocornut/imgui 16 | 17 | #pragma once 18 | #include "imgui.h" // IMGUI_IMPL_API 19 | 20 | struct SDL_Window; 21 | typedef union SDL_Event SDL_Event; 22 | 23 | IMGUI_IMPL_API bool ImGui_ImplSDL2_InitForOpenGL(SDL_Window* window, void* sdl_gl_context); 24 | IMGUI_IMPL_API bool ImGui_ImplSDL2_InitForVulkan(SDL_Window* window); 25 | IMGUI_IMPL_API bool ImGui_ImplSDL2_InitForD3D(SDL_Window* window); 26 | IMGUI_IMPL_API bool ImGui_ImplSDL2_InitForMetal(SDL_Window* window); 27 | IMGUI_IMPL_API void ImGui_ImplSDL2_Shutdown(); 28 | IMGUI_IMPL_API void ImGui_ImplSDL2_NewFrame(SDL_Window* window); 29 | IMGUI_IMPL_API bool ImGui_ImplSDL2_ProcessEvent(const SDL_Event* event); 30 | -------------------------------------------------------------------------------- /3rd_party/loguru/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(sources 2 | loguru.hpp 3 | loguru.cpp 4 | ) 5 | 6 | add_library(loguru STATIC ${sources}) 7 | target_include_directories(loguru 8 | INTERFACE 9 | ${CMAKE_CURRENT_SOURCE_DIR} 10 | ) 11 | target_link_libraries(loguru PRIVATE ${CMAKE_DL_LIBS}) 12 | 13 | 14 | if("${CMAKE_SYSTEM_NAME}" STREQUAL "Emscripten") 15 | target_compile_definitions(loguru PRIVATE "-DLOGURU_STACKTRACES=0") 16 | endif() 17 | 18 | rigel_disable_warnings(loguru) 19 | -------------------------------------------------------------------------------- /3rd_party/lyra/LICENSE.txt: -------------------------------------------------------------------------------- 1 | Boost Software License - Version 1.0 - August 17th, 2003 2 | 3 | Permission is hereby granted, free of charge, to any person or organization 4 | obtaining a copy of the software and accompanying documentation covered by 5 | this license (the "Software") to use, reproduce, display, distribute, 6 | execute, and transmit the Software, and to prepare derivative works of the 7 | Software, and to permit third-parties to whom the Software is furnished to 8 | do so, all subject to the following: 9 | 10 | The copyright notices in the Software and this entire statement, including 11 | the above license grant, this restriction and the following disclaimer, 12 | must be included in all copies of the Software, in whole or in part, and 13 | all derivative works of the Software, unless such copies or derivative 14 | works are solely in the form of machine-executable object code generated by 15 | a source language processor. 16 | 17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT 20 | SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE 21 | FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, 22 | ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 23 | DEALINGS IN THE SOFTWARE. 24 | -------------------------------------------------------------------------------- /3rd_party/lyra/README.md: -------------------------------------------------------------------------------- 1 | Copy of https://github.com/bfgroup/Lyra, branch `develop` at c3abca13edf495fe7d0f4b5c4983fe867d9f7f56 2 | -------------------------------------------------------------------------------- /3rd_party/lyra/include/lyra/args.hpp: -------------------------------------------------------------------------------- 1 | // Copyright 2018-2019 René Ferdinand Rivera Morell 2 | // Copyright 2017 Two Blue Cubes Ltd. All rights reserved. 3 | // 4 | // Distributed under the Boost Software License, Version 1.0. (See accompanying 5 | // file LICENSE.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 6 | 7 | #ifndef LYRA_ARGS_HPP 8 | #define LYRA_ARGS_HPP 9 | 10 | #include 11 | #include 12 | #include 13 | 14 | namespace lyra { 15 | /* tag::reference[] 16 | 17 | [#lyra_args] 18 | = `lyra::args` 19 | 20 | Transport for raw args (copied from main args, supplied via init list, or from a 21 | pair of iterators). 22 | 23 | */ // end::reference[] 24 | class args 25 | { 26 | public: 27 | // Construct from usual main() function arguments. 28 | args(int argc, char const * const * argv) 29 | : m_exeName(argv[0]) 30 | , m_args(argv + 1, argv + argc) 31 | {} 32 | 33 | // Construct directly from an initializer '{}'. 34 | args(std::initializer_list args) 35 | : m_exeName(*args.begin()) 36 | , m_args(args.begin() + 1, args.end()) 37 | {} 38 | 39 | // Construct from iterators. 40 | template 41 | args(const It & start, const It & end) 42 | : m_exeName(*start) 43 | , m_args(start+1, end) 44 | {} 45 | 46 | // The executable name taken from argument zero. 47 | std::string exe_name() const { return m_exeName; } 48 | 49 | // Arguments, excluding the exe name. 50 | std::vector::const_iterator begin() const 51 | { 52 | return m_args.begin(); 53 | } 54 | 55 | std::vector::const_iterator end() const 56 | { 57 | return m_args.end(); 58 | } 59 | 60 | private: 61 | std::string m_exeName; 62 | std::vector m_args; 63 | }; 64 | } // namespace lyra 65 | 66 | #endif 67 | -------------------------------------------------------------------------------- /3rd_party/lyra/include/lyra/cli_parser.hpp: -------------------------------------------------------------------------------- 1 | // Copyright 2018-2020 René Ferdinand Rivera Morell 2 | // 3 | // Distributed under the Boost Software License, Version 1.0. (See accompanying 4 | // file LICENSE.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 5 | 6 | #ifndef LYRA_CLI_PARSER_HPP 7 | #define LYRA_CLI_PARSER_HPP 8 | 9 | #include "lyra/cli.hpp" 10 | 11 | namespace lyra 12 | { 13 | using cli_parser = cli; 14 | } // namespace lyra 15 | 16 | #endif 17 | -------------------------------------------------------------------------------- /3rd_party/lyra/include/lyra/detail/deprecated_parser_customization.hpp: -------------------------------------------------------------------------------- 1 | // Copyright 2018-2021 René Ferdinand Rivera Morell 2 | // 3 | // Distributed under the Boost Software License, Version 1.0. (See accompanying 4 | // file LICENSE.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 5 | 6 | #ifndef LYRA_DETAIL_DEPRECATED_PARSER_CUSTOMIZATION_HPP 7 | #define LYRA_DETAIL_DEPRECATED_PARSER_CUSTOMIZATION_HPP 8 | 9 | #include 10 | 11 | namespace lyra { 12 | 13 | /* tag::reference[] 14 | 15 | [#lyra_parser_customization] 16 | = `lyra::parser_customization` 17 | 18 | Customization interface for parsing of options. 19 | 20 | [source] 21 | ---- 22 | virtual std::string token_delimiters() const = 0; 23 | ---- 24 | 25 | Specifies the characters to use for splitting a cli argument into the option 26 | and its value (if any). 27 | 28 | [source] 29 | ---- 30 | virtual std::string option_prefix() const = 0; 31 | ---- 32 | 33 | Specifies the characters to use as possible prefix, either single or double, 34 | for all options. 35 | 36 | end::reference[] */ 37 | struct parser_customization 38 | { 39 | virtual std::string token_delimiters() const = 0; 40 | virtual std::string option_prefix() const = 0; 41 | }; 42 | 43 | /* tag::reference[] 44 | 45 | [#lyra_default_parser_customization] 46 | = `lyra::default_parser_customization` 47 | 48 | Is-a `lyra::parser_customization` that defines token delimiters as space (" ") 49 | or equal (`=`). And specifies the option prefix character as dash (`-`) 50 | resulting in long options with `--` and short options with `-`. 51 | 52 | This customization is used as the default if none is given. 53 | 54 | end::reference[] */ 55 | struct default_parser_customization : parser_customization 56 | { 57 | std::string token_delimiters() const override { return " ="; } 58 | std::string option_prefix() const override { return "-"; } 59 | }; 60 | 61 | } // namespace lyra 62 | 63 | #endif 64 | -------------------------------------------------------------------------------- /3rd_party/lyra/include/lyra/detail/invoke_lambda.hpp: -------------------------------------------------------------------------------- 1 | // Copyright 2018-2019 René Ferdinand Rivera Morell 2 | // Copyright 2017 Two Blue Cubes Ltd. All rights reserved. 3 | // 4 | // Distributed under the Boost Software License, Version 1.0. (See accompanying 5 | // file LICENSE.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 6 | 7 | #ifndef LYRA_DETAIL_INVOKE_LAMBDA_HPP 8 | #define LYRA_DETAIL_INVOKE_LAMBDA_HPP 9 | 10 | #include "lyra/detail/parse.hpp" 11 | #include "lyra/detail/result.hpp" 12 | #include "lyra/detail/unary_lambda_traits.hpp" 13 | #include "lyra/parser_result.hpp" 14 | 15 | namespace lyra 16 | { 17 | namespace detail 18 | { 19 | template 20 | struct LambdaInvoker 21 | { 22 | template 23 | static parser_result invoke(L const& lambda, ArgType const& arg) 24 | { 25 | return lambda(arg); 26 | } 27 | }; 28 | 29 | template <> 30 | struct LambdaInvoker 31 | { 32 | template 33 | static parser_result invoke(L const& lambda, ArgType const& arg) 34 | { 35 | lambda(arg); 36 | return parser_result::ok(parser_result_type::matched); 37 | } 38 | }; 39 | 40 | template 41 | inline parser_result invokeLambda(L const& lambda, std::string const& arg) 42 | { 43 | ArgType temp{}; 44 | auto result = parse_string(arg, temp); 45 | return !result 46 | ? result 47 | : LambdaInvoker::ReturnType>:: 48 | invoke(lambda, temp); 49 | } 50 | } // namespace detail 51 | } // namespace lyra 52 | 53 | #endif 54 | -------------------------------------------------------------------------------- /3rd_party/lyra/include/lyra/detail/parse.hpp: -------------------------------------------------------------------------------- 1 | // Copyright 2018-2019 René Ferdinand Rivera Morell 2 | // Copyright 2017 Two Blue Cubes Ltd. All rights reserved. 3 | // 4 | // Distributed under the Boost Software License, Version 1.0. (See accompanying 5 | // file LICENSE.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 6 | 7 | #ifndef LYRA_DETAIL_PARSE_HPP 8 | #define LYRA_DETAIL_PARSE_HPP 9 | 10 | #include "lyra/detail/from_string.hpp" 11 | #include "lyra/parser_result.hpp" 12 | 13 | #include 14 | 15 | namespace lyra 16 | { 17 | namespace detail 18 | { 19 | template 20 | parser_result parse_string(S const& source, T& target) 21 | { 22 | if (from_string(source, target)) 23 | return parser_result::ok(parser_result_type::matched); 24 | else 25 | return parser_result::error( 26 | parser_result_type::no_match, 27 | "Unable to convert '" + source + "' to destination type"); 28 | } 29 | } // namespace detail 30 | } // namespace lyra 31 | 32 | #endif 33 | -------------------------------------------------------------------------------- /3rd_party/lyra/include/lyra/detail/print.hpp: -------------------------------------------------------------------------------- 1 | // Copyright 2021 René Ferdinand Rivera Morell 2 | // 3 | // Distributed under the Boost Software License, Version 1.0. (See accompanying 4 | // file LICENSE.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 5 | 6 | #ifndef LYRA_DETAIL_PRINT_HPP 7 | #define LYRA_DETAIL_PRINT_HPP 8 | 9 | #include 10 | #include 11 | 12 | #ifndef LYRA_DEBUG 13 | # define LYRA_DEBUG 0 14 | #endif 15 | 16 | namespace lyra { namespace detail { 17 | 18 | constexpr bool is_debug = LYRA_DEBUG; 19 | 20 | template 21 | std::string to_string(T && t) 22 | { 23 | return std::string(std::move(t)); 24 | } 25 | 26 | using std::to_string; 27 | 28 | struct print 29 | { 30 | print(const char * scope = nullptr) : scope(scope) 31 | { 32 | if (is_debug) print::depth() += 1; 33 | if (scope) debug(scope, "..."); 34 | } 35 | 36 | ~print() 37 | { 38 | if (scope) debug("...", scope); 39 | if (is_debug) print::depth() -= 1; 40 | } 41 | 42 | template 43 | void debug(A... arg) 44 | { 45 | if (is_debug) 46 | { 47 | std::cerr << "[DEBUG]" 48 | << std::string((print::depth() - 1) * 2, ' '); 49 | std::string args[] = { to_string(arg)... }; 50 | for (auto & arg_string : args) 51 | { 52 | std::cerr << " " << arg_string; 53 | } 54 | std::cerr << "\n"; 55 | } 56 | } 57 | 58 | private: 59 | const char * scope; 60 | static std::size_t & depth() 61 | { 62 | static std::size_t d = 0; 63 | return d; 64 | } 65 | }; 66 | 67 | }} // namespace lyra::detail 68 | 69 | #if LYRA_DEBUG 70 | # define LYRA_PRINT_SCOPE ::lyra::detail::print lyra_print_scope 71 | # define LYRA_PRINT_DEBUG lyra_print_scope.debug 72 | #else 73 | # define LYRA_PRINT_SCOPE(...) while(false) 74 | # define LYRA_PRINT_DEBUG(...) while(false) 75 | #endif 76 | 77 | #endif 78 | -------------------------------------------------------------------------------- /3rd_party/lyra/include/lyra/detail/unary_lambda_traits.hpp: -------------------------------------------------------------------------------- 1 | // Copyright 2018-2019 René Ferdinand Rivera Morell 2 | // Copyright 2017 Two Blue Cubes Ltd. All rights reserved. 3 | // 4 | // Distributed under the Boost Software License, Version 1.0. (See accompanying 5 | // file LICENSE.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 6 | 7 | #ifndef LYRA_DETAIL_UNARY_LAMBDA_TRAITS_HPP 8 | #define LYRA_DETAIL_UNARY_LAMBDA_TRAITS_HPP 9 | 10 | #include 11 | 12 | namespace lyra 13 | { 14 | namespace detail 15 | { 16 | // Traits for extracting arg and return type of lambdas (for single argument 17 | // lambdas) 18 | template 19 | struct unary_lambda_traits : unary_lambda_traits 20 | { 21 | }; 22 | 23 | template 24 | struct unary_lambda_traits 25 | { 26 | static const bool isValid = false; 27 | }; 28 | 29 | template 30 | struct unary_lambda_traits 31 | { 32 | static const bool isValid = true; 33 | using ArgType = typename std::remove_const< 34 | typename std::remove_reference::type>::type; 35 | using ReturnType = ReturnT; 36 | }; 37 | 38 | } // namespace detail 39 | } // namespace lyra 40 | 41 | #endif 42 | -------------------------------------------------------------------------------- /3rd_party/lyra/include/lyra/lyra.hpp: -------------------------------------------------------------------------------- 1 | // Copyright 2018-2020 René Ferdinand Rivera Morell 2 | // Copyright 2017 Two Blue Cubes Ltd. All rights reserved. 3 | // 4 | // Distributed under the Boost Software License, Version 1.0. (See accompanying 5 | // file LICENSE.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 6 | 7 | #ifndef LYRA_LYRA_HPP 8 | #define LYRA_LYRA_HPP 9 | 10 | #include "lyra/version.hpp" 11 | 12 | #include "lyra/arg.hpp" 13 | #include "lyra/arguments.hpp" 14 | #include "lyra/cli_parser.hpp" 15 | #include "lyra/cli.hpp" 16 | #include "lyra/command.hpp" 17 | #include "lyra/exe_name.hpp" 18 | #include "lyra/group.hpp" 19 | #include "lyra/help.hpp" 20 | #include "lyra/literal.hpp" 21 | #include "lyra/main.hpp" 22 | #include "lyra/opt.hpp" 23 | #include "lyra/option_style.hpp" 24 | #include "lyra/parser_result.hpp" 25 | #include "lyra/parser.hpp" 26 | #include "lyra/val.hpp" 27 | 28 | #endif // LYRA_HPP_INCLUDED 29 | -------------------------------------------------------------------------------- /3rd_party/lyra/include/lyra/parser_result.hpp: -------------------------------------------------------------------------------- 1 | // Copyright 2018-2019 René Ferdinand Rivera Morell 2 | // Copyright 2017 Two Blue Cubes Ltd. All rights reserved. 3 | // 4 | // Distributed under the Boost Software License, Version 1.0. (See accompanying 5 | // file LICENSE.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 6 | 7 | #ifndef LYRA_PARSER_RESULT_HPP 8 | #define LYRA_PARSER_RESULT_HPP 9 | 10 | #include "lyra/detail/result.hpp" 11 | #include 12 | 13 | namespace lyra { 14 | 15 | // enum of result types from a parse 16 | enum class parser_result_type 17 | { 18 | matched, 19 | no_match, 20 | short_circuit_all 21 | }; 22 | 23 | inline std::string to_string(parser_result_type v) 24 | { 25 | switch (v) 26 | { 27 | case parser_result_type::matched: return "matched"; 28 | case parser_result_type::no_match: return "no_match"; 29 | case parser_result_type::short_circuit_all: return "short_circuit_all"; 30 | } 31 | return "?"; 32 | } 33 | 34 | using result = detail::basic_result; 35 | 36 | // Result type for parser operation 37 | using parser_result = detail::basic_result; 38 | 39 | } // namespace lyra 40 | 41 | #endif 42 | -------------------------------------------------------------------------------- /3rd_party/lyra/include/lyra/val.hpp: -------------------------------------------------------------------------------- 1 | // Copyright 2020 René Ferdinand Rivera Morell 2 | // 3 | // Distributed under the Boost Software License, Version 1.0. (See accompanying 4 | // file LICENSE.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 5 | 6 | #ifndef LYRA_VAL_HPP 7 | #define LYRA_VAL_HPP 8 | 9 | #include "lyra/detail/bound.hpp" 10 | #include 11 | 12 | namespace lyra { 13 | 14 | /* tag::reference[] 15 | 16 | [#lyra_val] 17 | = `lyra::val` 18 | 19 | [source] 20 | ---- 21 | auto val(T && v); 22 | auto val(const char * v); 23 | ---- 24 | 25 | Makes a bound self-contained value of the type of the given r-value. The created 26 | bound values can be used in place of the value references for arguments. And can 27 | be retrieved with the 28 | <> call. 29 | 30 | */ // end::reference[] 31 | template 32 | detail::BoundVal val(T && v) 33 | { 34 | return detail::BoundVal(std::forward(v)); 35 | } 36 | 37 | inline detail::BoundVal val(const char * v) 38 | { 39 | return detail::BoundVal(v); 40 | } 41 | 42 | } // namespace lyra 43 | 44 | #endif 45 | -------------------------------------------------------------------------------- /3rd_party/lyra/include/lyra/version.hpp: -------------------------------------------------------------------------------- 1 | // Copyright 2019-2020 René Ferdinand Rivera Morell 2 | // 3 | // Distributed under the Boost Software License, Version 1.0. (See accompanying 4 | // file LICENSE.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 5 | 6 | #ifndef LYRA_VERSION_HPP 7 | #define LYRA_VERSION_HPP 8 | 9 | #define LYRA_VERSION_MAJOR 1 10 | #define LYRA_VERSION_MINOR 7 11 | #define LYRA_VERSION_PATCH 0 12 | 13 | #define LYRA_VERSION \ 14 | (((LYRA_VERSION_MAJOR)*10000000) + ((LYRA_VERSION_MINOR)*100000) \ 15 | + (LYRA_VERSION_PATCH)) 16 | 17 | #endif // LYRA_VERSION_HPP 18 | -------------------------------------------------------------------------------- /3rd_party/nuked-opl3/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(sources 2 | opl3.h 3 | opl3.c 4 | ) 5 | 6 | add_library(nuked-opl3 STATIC ${sources}) 7 | target_include_directories(nuked-opl3 8 | INTERFACE 9 | ${CMAKE_CURRENT_SOURCE_DIR} 10 | ) 11 | rigel_disable_warnings(nuked-opl3) 12 | -------------------------------------------------------------------------------- /3rd_party/speex_resampler/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(sources 2 | speex/speex_resampler.h 3 | speex/resample.c 4 | speex/resample_neon.h 5 | speex/resample_sse.h 6 | ) 7 | 8 | 9 | add_library(speex_resampler STATIC ${sources}) 10 | target_include_directories(speex_resampler 11 | INTERFACE 12 | ${CMAKE_CURRENT_SOURCE_DIR} 13 | ) 14 | target_compile_definitions(speex_resampler PUBLIC 15 | OUTSIDE_SPEEX 16 | RANDOM_PREFIX=rigel 17 | FLOATING_POINT 18 | ) 19 | 20 | rigel_disable_warnings(speex_resampler) 21 | -------------------------------------------------------------------------------- /3rd_party/static_vector/README.md: -------------------------------------------------------------------------------- 1 | Based on https://github.com/gnzlbg/static_vector, 2 | at commit 28606f87553425ab0ca14ceaf927eaf8ce414bce 3 | -------------------------------------------------------------------------------- /3rd_party/stb/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(sources 2 | stb_image.h 3 | stb_image_write.h 4 | stb_rect_pack.h 5 | stb.cpp 6 | ) 7 | 8 | add_library(stb STATIC ${sources}) 9 | target_include_directories(stb 10 | INTERFACE 11 | ${CMAKE_CURRENT_SOURCE_DIR} 12 | ) 13 | rigel_disable_warnings(stb) 14 | 15 | -------------------------------------------------------------------------------- /3rd_party/stb/stb.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2020, Nikolai Wuttke. All rights reserved. 2 | * 3 | * This program is free software: you can redistribute it and/or modify 4 | * it under the terms of the GNU General Public License as published by 5 | * the Free Software Foundation, either version 2 of the License, or 6 | * (at your option) any later version. 7 | * 8 | * This program is distributed in the hope that it will be useful, 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | * GNU General Public License for more details. 12 | * 13 | * You should have received a copy of the GNU General Public License 14 | * along with this program. If not, see . 15 | */ 16 | 17 | // This compilation unit contains the implementations of the STB libraries 18 | // used by RigelEngine. 19 | 20 | #define STB_IMAGE_WRITE_IMPLEMENTATION 21 | #include "stb_image_write.h" 22 | 23 | #define STB_IMAGE_IMPLEMENTATION 24 | #include "stb_image.h" 25 | 26 | #define STB_RECT_PACK_IMPLEMENTATION 27 | #include "stb_rect_pack.h" 28 | -------------------------------------------------------------------------------- /benchmark/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | include(FetchContent) 2 | 3 | FetchContent_Declare( 4 | benchmark 5 | GIT_REPOSITORY https://github.com/google/benchmark.git 6 | GIT_TAG v1.8.3 7 | ) 8 | FetchContent_GetProperties(benchmark) 9 | if(NOT benchmark_POPULATED) 10 | set(BENCHMARK_ENABLE_GTEST_TESTS OFF) 11 | set(BENCHMARK_ENABLE_INSTALL OFF) 12 | set(BENCHMARK_ENABLE_TESTING OFF) 13 | FetchContent_Populate(benchmark) 14 | add_subdirectory(${benchmark_SOURCE_DIR} ${benchmark_BINARY_DIR}) 15 | endif() 16 | 17 | add_executable(benchmarks 18 | bench_string_utils.cpp 19 | ) 20 | 21 | target_link_libraries(benchmarks PRIVATE 22 | rigel_core 23 | benchmark::benchmark_main 24 | ) 25 | 26 | rigel_enable_warnings(benchmarks) 27 | -------------------------------------------------------------------------------- /cmake/rigel_sanitizers.cmake: -------------------------------------------------------------------------------- 1 | # allow CTest to work with address sanitizer (requires cmake > 3.18) 2 | # eg. ctest -V -T MemCheck 3 | # https://gitlab.kitware.com/cmake/cmake/-/issues/20584 4 | if(CMAKE_BUILD_TYPE STREQUAL "Asan") 5 | # https://cmake.org/cmake/help/latest/variable/CTEST_MEMORYCHECK_TYPE.html 6 | set(MEMORYCHECK_TYPE "AddressSanitizer" CACHE STRING "Use ASAN in MemCheck" FORCE) 7 | endif() 8 | 9 | # only enable sanitizers on clang and gcc via CMAKE_BUILD_TYPE 10 | # flags for C/CXX are setup using `CMAKE_C_FLAGS_ 11 | # use CMAKE_BUILD_TYPE=Asan to enabled these flags 12 | if(CMAKE_CXX_COMPILER_ID MATCHES "Clang|GNU") 13 | # ASAN flags 14 | set(CMAKE_C_FLAGS_ASAN 15 | "${CMAKE_C_FLAGS_DEBUG} -fsanitize=address -fno-omit-frame-pointer" CACHE STRING 16 | "Flags used by the C compiler for Asan build type or configuration." FORCE) 17 | set(CMAKE_CXX_FLAGS_ASAN 18 | "${CMAKE_CXX_FLAGS_DEBUG} -fsanitize=address -fno-omit-frame-pointer" CACHE STRING 19 | "Flags used by the C++ compiler for Asan build type or configuration." FORCE) 20 | set(CMAKE_EXE_LINKER_FLAGS_ASAN 21 | "${CMAKE_SHARED_LINKER_FLAGS_DEBUG} -fsanitize=address" CACHE STRING 22 | "Linker flags to be used to create executables for Asan build type." FORCE) 23 | set(CMAKE_SHARED_LINKER_FLAGS_ASAN 24 | "${CMAKE_SHARED_LINKER_FLAGS_DEBUG} -fsanitize=address" CACHE STRING 25 | "Linker flags to be used to create shared libraries for Asan build type." FORCE) 26 | endif() 27 | -------------------------------------------------------------------------------- /dist/README.md: -------------------------------------------------------------------------------- 1 | # Platform-specific distribution files 2 | 3 | This folder contains platform-specific files necessary for binary distribution. 4 | This includes icons, description files etc. 5 | -------------------------------------------------------------------------------- /dist/emscripten/android-chrome-192x192.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lethal-guitar/RigelEngine/f05996f9b3ad3b3ea5bb818e49e7977636746343/dist/emscripten/android-chrome-192x192.png -------------------------------------------------------------------------------- /dist/emscripten/android-chrome-512x512.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lethal-guitar/RigelEngine/f05996f9b3ad3b3ea5bb818e49e7977636746343/dist/emscripten/android-chrome-512x512.png -------------------------------------------------------------------------------- /dist/emscripten/apple-touch-icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lethal-guitar/RigelEngine/f05996f9b3ad3b3ea5bb818e49e7977636746343/dist/emscripten/apple-touch-icon.png -------------------------------------------------------------------------------- /dist/emscripten/browserconfig.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | #da532c 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /dist/emscripten/favicon-16x16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lethal-guitar/RigelEngine/f05996f9b3ad3b3ea5bb818e49e7977636746343/dist/emscripten/favicon-16x16.png -------------------------------------------------------------------------------- /dist/emscripten/favicon-32x32.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lethal-guitar/RigelEngine/f05996f9b3ad3b3ea5bb818e49e7977636746343/dist/emscripten/favicon-32x32.png -------------------------------------------------------------------------------- /dist/emscripten/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lethal-guitar/RigelEngine/f05996f9b3ad3b3ea5bb818e49e7977636746343/dist/emscripten/favicon.ico -------------------------------------------------------------------------------- /dist/emscripten/mstile-150x150.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lethal-guitar/RigelEngine/f05996f9b3ad3b3ea5bb818e49e7977636746343/dist/emscripten/mstile-150x150.png -------------------------------------------------------------------------------- /dist/emscripten/robots.txt: -------------------------------------------------------------------------------- 1 | User-agent: * 2 | Allow: /*.html$ 3 | Allow: /*.png$ 4 | Allow: /*.ico$ 5 | Disallow: / 6 | -------------------------------------------------------------------------------- /dist/emscripten/site.webmanifest: -------------------------------------------------------------------------------- 1 | { 2 | "name": "RigelEngine", 3 | "short_name": "RigelEngine", 4 | "icons": [ 5 | { 6 | "src": "/android-chrome-192x192.png?v=2", 7 | "sizes": "192x192", 8 | "type": "image/png" 9 | }, 10 | { 11 | "src": "/android-chrome-512x512.png?v=2", 12 | "sizes": "512x512", 13 | "type": "image/png" 14 | } 15 | ], 16 | "theme_color": "#ffffff", 17 | "background_color": "#ffffff", 18 | "display": "standalone" 19 | } 20 | -------------------------------------------------------------------------------- /dist/icon_original/128.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lethal-guitar/RigelEngine/f05996f9b3ad3b3ea5bb818e49e7977636746343/dist/icon_original/128.png -------------------------------------------------------------------------------- /dist/icon_original/16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lethal-guitar/RigelEngine/f05996f9b3ad3b3ea5bb818e49e7977636746343/dist/icon_original/16.png -------------------------------------------------------------------------------- /dist/icon_original/32.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lethal-guitar/RigelEngine/f05996f9b3ad3b3ea5bb818e49e7977636746343/dist/icon_original/32.png -------------------------------------------------------------------------------- /dist/icon_original/48.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lethal-guitar/RigelEngine/f05996f9b3ad3b3ea5bb818e49e7977636746343/dist/icon_original/48.png -------------------------------------------------------------------------------- /dist/icon_original/64.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lethal-guitar/RigelEngine/f05996f9b3ad3b3ea5bb818e49e7977636746343/dist/icon_original/64.png -------------------------------------------------------------------------------- /dist/linux/rigelengine.desktop: -------------------------------------------------------------------------------- 1 | [Desktop Entry] 2 | Type=Application 3 | Name=RigelEngine 4 | Comment=A modern re-implementation of the classic DOS game Duke Nukem II 5 | Icon=rigelengine 6 | Exec=RigelEngine 7 | Terminal=false 8 | Categories=Game 9 | -------------------------------------------------------------------------------- /dist/linux/rigelengine_128.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lethal-guitar/RigelEngine/f05996f9b3ad3b3ea5bb818e49e7977636746343/dist/linux/rigelengine_128.png -------------------------------------------------------------------------------- /dist/linux/rigelengine_48.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lethal-guitar/RigelEngine/f05996f9b3ad3b3ea5bb818e49e7977636746343/dist/linux/rigelengine_48.png -------------------------------------------------------------------------------- /dist/linux/rigelengine_64.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lethal-guitar/RigelEngine/f05996f9b3ad3b3ea5bb818e49e7977636746343/dist/linux/rigelengine_64.png -------------------------------------------------------------------------------- /dist/osx/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en-US 7 | CFBundleExecutable 8 | ${MACOSX_BUNDLE_EXECUTABLE_NAME} 9 | CFBundleIdentifier 10 | de.nikolai-wuttke.RigelEngine 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | RigelEngine 15 | CFBundlePackageType 16 | APPL 17 | NSHighResolutionCapable 18 | 19 | CFBundleIconFile 20 | RigelEngine.icns 21 | 22 | 23 | -------------------------------------------------------------------------------- /dist/osx/RigelEngine.icns: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lethal-guitar/RigelEngine/f05996f9b3ad3b3ea5bb818e49e7977636746343/dist/osx/RigelEngine.icns -------------------------------------------------------------------------------- /dist/win/RigelEngine.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lethal-guitar/RigelEngine/f05996f9b3ad3b3ea5bb818e49e7977636746343/dist/win/RigelEngine.ico -------------------------------------------------------------------------------- /dist/win/RigelEngine.rc: -------------------------------------------------------------------------------- 1 | IDI_ICON1 ICON DISCARDABLE "RigelEngine.ico" 2 | -------------------------------------------------------------------------------- /docker/ubuntu-deps.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | set -ex 4 | 5 | apt-get update && \ 6 | DEBIAN_FRONTEND="noninteractive" apt-get install --no-install-recommends -y \ 7 | cmake \ 8 | g++-8 \ 9 | libsdl2-dev \ 10 | libsdl2-mixer-dev \ 11 | make 12 | -------------------------------------------------------------------------------- /docker/ubuntu.Dockerfile: -------------------------------------------------------------------------------- 1 | FROM ubuntu:latest 2 | 3 | COPY docker/ubuntu-deps.sh /tmp/ubuntu-deps.sh 4 | 5 | RUN ./tmp/ubuntu-deps.sh && \ 6 | update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-8 10 && \ 7 | update-alternatives --install /usr/bin/c++ c++ /usr/bin/g++ 20 && \ 8 | update-alternatives --set c++ /usr/bin/g++ && \ 9 | update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-8 10 && \ 10 | update-alternatives --install /usr/bin/cc cc /usr/bin/gcc 20 && \ 11 | update-alternatives --set cc /usr/bin/gcc && \ 12 | apt install -y gdb && \ 13 | apt install -y clang-format-11 && \ 14 | apt install -y git 15 | 16 | -------------------------------------------------------------------------------- /src/assets/audio_package.hpp: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2016, Nikolai Wuttke. All rights reserved. 2 | * 3 | * This program is free software: you can redistribute it and/or modify 4 | * it under the terms of the GNU General Public License as published by 5 | * the Free Software Foundation, either version 2 of the License, or 6 | * (at your option) any later version. 7 | * 8 | * This program is distributed in the hope that it will be useful, 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | * GNU General Public License for more details. 12 | * 13 | * You should have received a copy of the GNU General Public License 14 | * along with this program. If not, see . 15 | */ 16 | 17 | #pragma once 18 | 19 | #include "assets/byte_buffer.hpp" 20 | 21 | #include 22 | #include 23 | 24 | 25 | namespace rigel::assets 26 | { 27 | 28 | constexpr auto AUDIO_DICT_FILE = "AUDIOHED.MNI"; 29 | constexpr auto AUDIO_DATA_FILE = "AUDIOT.MNI"; 30 | 31 | 32 | struct AdlibSound 33 | { 34 | std::uint8_t mOctave = 0; 35 | std::array mInstrumentSettings; 36 | std::vector mSoundData; 37 | }; 38 | 39 | using AudioPackage = std::vector; 40 | 41 | AudioPackage loadAdlibSoundData( 42 | const ByteBuffer& audioDictData, 43 | const ByteBuffer& bundledAudioData); 44 | 45 | } // namespace rigel::assets 46 | -------------------------------------------------------------------------------- /src/assets/byte_buffer.hpp: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2016, Nikolai Wuttke. All rights reserved. 2 | * 3 | * This program is free software: you can redistribute it and/or modify 4 | * it under the terms of the GNU General Public License as published by 5 | * the Free Software Foundation, either version 2 of the License, or 6 | * (at your option) any later version. 7 | * 8 | * This program is distributed in the hope that it will be useful, 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | * GNU General Public License for more details. 12 | * 13 | * You should have received a copy of the GNU General Public License 14 | * along with this program. If not, see . 15 | */ 16 | 17 | #pragma once 18 | 19 | #include 20 | #include 21 | 22 | 23 | namespace rigel::assets 24 | { 25 | 26 | using ByteBuffer = std::vector; 27 | using ByteBuferIter = ByteBuffer::iterator; 28 | using ByteBufferCIter = ByteBuffer::const_iterator; 29 | 30 | 31 | } // namespace rigel::assets 32 | -------------------------------------------------------------------------------- /src/assets/cmp_file_package.hpp: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2016, Nikolai Wuttke. All rights reserved. 2 | * 3 | * This program is free software: you can redistribute it and/or modify 4 | * it under the terms of the GNU General Public License as published by 5 | * the Free Software Foundation, either version 2 of the License, or 6 | * (at your option) any later version. 7 | * 8 | * This program is distributed in the hope that it will be useful, 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | * GNU General Public License for more details. 12 | * 13 | * You should have received a copy of the GNU General Public License 14 | * along with this program. If not, see . 15 | */ 16 | 17 | #pragma once 18 | 19 | #include "assets/byte_buffer.hpp" 20 | 21 | #include 22 | #include 23 | #include 24 | #include 25 | #include 26 | 27 | 28 | namespace rigel::assets 29 | { 30 | 31 | 32 | class CMPFilePackage 33 | { 34 | public: 35 | explicit CMPFilePackage(const std::filesystem::path& filePath); 36 | 37 | ByteBuffer file(std::string_view name) const; 38 | 39 | bool hasFile(std::string_view name) const; 40 | 41 | private: 42 | struct DictEntry 43 | { 44 | DictEntry(std::uint32_t fileOffset, std::uint32_t fileSize); 45 | DictEntry(const DictEntry&) = default; 46 | DictEntry(DictEntry&&) = default; 47 | 48 | const std::uint32_t fileOffset = 0; 49 | const std::uint32_t fileSize = 0; 50 | }; 51 | 52 | using FileDict = std::unordered_map; 53 | 54 | FileDict::const_iterator findFileEntry(std::string_view name) const; 55 | 56 | private: 57 | std::vector mFileData; 58 | FileDict mFileDict; 59 | }; 60 | 61 | 62 | } // namespace rigel::assets 63 | -------------------------------------------------------------------------------- /src/assets/duke_script_loader.hpp: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2016, Nikolai Wuttke. All rights reserved. 2 | * 3 | * This program is free software: you can redistribute it and/or modify 4 | * it under the terms of the GNU General Public License as published by 5 | * the Free Software Foundation, either version 2 of the License, or 6 | * (at your option) any later version. 7 | * 8 | * This program is distributed in the hope that it will be useful, 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | * GNU General Public License for more details. 12 | * 13 | * You should have received a copy of the GNU General Public License 14 | * along with this program. If not, see . 15 | */ 16 | 17 | #pragma once 18 | 19 | #include "data/duke_script.hpp" 20 | #include "data/level_hints.hpp" 21 | 22 | #include 23 | #include 24 | 25 | 26 | namespace rigel::assets 27 | { 28 | 29 | using ScriptBundle = std::unordered_map; 30 | 31 | 32 | ScriptBundle loadScripts(const std::string& scriptSource); 33 | 34 | 35 | data::LevelHints loadHintMessages(const std::string& scriptSource); 36 | 37 | } // namespace rigel::assets 38 | -------------------------------------------------------------------------------- /src/assets/ega_image_decoder.hpp: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2016, Nikolai Wuttke. All rights reserved. 2 | * 3 | * This program is free software: you can redistribute it and/or modify 4 | * it under the terms of the GNU General Public License as published by 5 | * the Free Software Foundation, either version 2 of the License, or 6 | * (at your option) any later version. 7 | * 8 | * This program is distributed in the hope that it will be useful, 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | * GNU General Public License for more details. 12 | * 13 | * You should have received a copy of the GNU General Public License 14 | * along with this program. If not, see . 15 | */ 16 | 17 | #pragma once 18 | 19 | #include "assets/byte_buffer.hpp" 20 | #include "assets/palette.hpp" 21 | #include "base/image.hpp" 22 | #include "data/game_traits.hpp" 23 | 24 | 25 | namespace rigel::assets 26 | { 27 | 28 | data::PixelBuffer decodeSimplePlanarEgaBuffer( 29 | ByteBufferCIter begin, 30 | ByteBufferCIter end, 31 | const data::Palette16& palette); 32 | 33 | 34 | data::Image loadTiledImage( 35 | ByteBufferCIter begin, 36 | ByteBufferCIter end, 37 | std::size_t widthInTiles, 38 | const data::Palette16& palette, 39 | data::TileImageType type); 40 | 41 | 42 | inline data::Image loadTiledImage( 43 | const ByteBuffer& data, 44 | std::size_t widthInTiles, 45 | const data::Palette16& palette, 46 | const data::TileImageType type = data::TileImageType::Unmasked) 47 | { 48 | return loadTiledImage(data.begin(), data.end(), widthInTiles, palette, type); 49 | } 50 | 51 | data::Image loadTiledFontBitmap( 52 | ByteBufferCIter begin, 53 | ByteBufferCIter end, 54 | std::size_t widthInTiles); 55 | 56 | } // namespace rigel::assets 57 | -------------------------------------------------------------------------------- /src/assets/level_loader.hpp: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2016, Nikolai Wuttke. All rights reserved. 2 | * 3 | * This program is free software: you can redistribute it and/or modify 4 | * it under the terms of the GNU General Public License as published by 5 | * the Free Software Foundation, either version 2 of the License, or 6 | * (at your option) any later version. 7 | * 8 | * This program is distributed in the hope that it will be useful, 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | * GNU General Public License for more details. 12 | * 13 | * You should have received a copy of the GNU General Public License 14 | * along with this program. If not, see . 15 | */ 16 | 17 | #pragma once 18 | 19 | #include 20 | #include 21 | 22 | #include "assets/actor_image_package.hpp" 23 | #include "base/spatial_types.hpp" 24 | #include "data/game_session_data.hpp" 25 | #include "data/map.hpp" 26 | 27 | 28 | namespace rigel::assets 29 | { 30 | 31 | class ResourceLoader; 32 | 33 | std::string levelFileName(const int episode, const int level); 34 | 35 | data::map::TileIndex convertTileIndex(const uint16_t rawIndex); 36 | 37 | data::map::LevelData loadLevel( 38 | std::string_view mapName, 39 | const ResourceLoader& resources, 40 | data::Difficulty chosenDifficulty); 41 | 42 | } // namespace rigel::assets 43 | -------------------------------------------------------------------------------- /src/assets/movie_loader.hpp: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2016, Nikolai Wuttke. All rights reserved. 2 | * 3 | * This program is free software: you can redistribute it and/or modify 4 | * it under the terms of the GNU General Public License as published by 5 | * the Free Software Foundation, either version 2 of the License, or 6 | * (at your option) any later version. 7 | * 8 | * This program is distributed in the hope that it will be useful, 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | * GNU General Public License for more details. 12 | * 13 | * You should have received a copy of the GNU General Public License 14 | * along with this program. If not, see . 15 | */ 16 | 17 | #pragma once 18 | 19 | #include "assets/byte_buffer.hpp" 20 | #include "data/movie.hpp" 21 | 22 | 23 | namespace rigel::assets 24 | { 25 | 26 | data::Movie loadMovie(const ByteBuffer& file); 27 | 28 | 29 | } 30 | -------------------------------------------------------------------------------- /src/assets/music_loader.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2016, Nikolai Wuttke. All rights reserved. 2 | * 3 | * This program is free software: you can redistribute it and/or modify 4 | * it under the terms of the GNU General Public License as published by 5 | * the Free Software Foundation, either version 2 of the License, or 6 | * (at your option) any later version. 7 | * 8 | * This program is distributed in the hope that it will be useful, 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | * GNU General Public License for more details. 12 | * 13 | * You should have received a copy of the GNU General Public License 14 | * along with this program. If not, see . 15 | */ 16 | 17 | #include "music_loader.hpp" 18 | 19 | #include "assets/file_utils.hpp" 20 | 21 | 22 | namespace rigel::assets 23 | { 24 | 25 | namespace 26 | { 27 | 28 | data::ImfCommand readCommand(LeStreamReader& reader) 29 | { 30 | return {reader.readU8(), reader.readU8(), reader.readU16()}; 31 | } 32 | 33 | } // namespace 34 | 35 | data::Song loadSong(const ByteBuffer& imfData) 36 | { 37 | data::Song song; 38 | 39 | LeStreamReader reader(imfData); 40 | while (reader.hasData()) 41 | { 42 | song.push_back(readCommand(reader)); 43 | } 44 | 45 | return song; 46 | } 47 | 48 | } // namespace rigel::assets 49 | -------------------------------------------------------------------------------- /src/assets/music_loader.hpp: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2016, Nikolai Wuttke. All rights reserved. 2 | * 3 | * This program is free software: you can redistribute it and/or modify 4 | * it under the terms of the GNU General Public License as published by 5 | * the Free Software Foundation, either version 2 of the License, or 6 | * (at your option) any later version. 7 | * 8 | * This program is distributed in the hope that it will be useful, 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | * GNU General Public License for more details. 12 | * 13 | * You should have received a copy of the GNU General Public License 14 | * along with this program. If not, see . 15 | */ 16 | 17 | #pragma once 18 | 19 | #include "assets/byte_buffer.hpp" 20 | #include "data/song.hpp" 21 | 22 | 23 | namespace rigel::assets 24 | { 25 | 26 | data::Song loadSong(const ByteBuffer& imfData); 27 | 28 | } 29 | -------------------------------------------------------------------------------- /src/assets/palette.hpp: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2016, Nikolai Wuttke. All rights reserved. 2 | * 3 | * This program is free software: you can redistribute it and/or modify 4 | * it under the terms of the GNU General Public License as published by 5 | * the Free Software Foundation, either version 2 of the License, or 6 | * (at your option) any later version. 7 | * 8 | * This program is distributed in the hope that it will be useful, 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | * GNU General Public License for more details. 12 | * 13 | * You should have received a copy of the GNU General Public License 14 | * along with this program. If not, see . 15 | */ 16 | 17 | #pragma once 18 | 19 | #include "assets/byte_buffer.hpp" 20 | #include "data/palette.hpp" 21 | 22 | 23 | namespace rigel::assets 24 | { 25 | 26 | data::Palette16 load6bitPalette16(ByteBufferCIter begin, ByteBufferCIter end); 27 | data::Palette256 load6bitPalette256(ByteBufferCIter begin, ByteBufferCIter end); 28 | 29 | 30 | inline data::Palette16 load6bitPalette16(const ByteBuffer& buffer) 31 | { 32 | return load6bitPalette16(buffer.begin(), buffer.end()); 33 | } 34 | 35 | 36 | inline data::Palette256 load6bitPalette256(const ByteBuffer& buffer) 37 | { 38 | return load6bitPalette256(buffer.begin(), buffer.end()); 39 | } 40 | 41 | } // namespace rigel::assets 42 | -------------------------------------------------------------------------------- /src/assets/png_image.hpp: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2016, Nikolai Wuttke. All rights reserved. 2 | * 3 | * This program is free software: you can redistribute it and/or modify 4 | * it under the terms of the GNU General Public License as published by 5 | * the Free Software Foundation, either version 2 of the License, or 6 | * (at your option) any later version. 7 | * 8 | * This program is distributed in the hope that it will be useful, 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | * GNU General Public License for more details. 12 | * 13 | * You should have received a copy of the GNU General Public License 14 | * along with this program. If not, see . 15 | */ 16 | 17 | #pragma once 18 | 19 | #include "base/array_view.hpp" 20 | #include "base/image.hpp" 21 | 22 | #include 23 | #include 24 | #include 25 | 26 | namespace rigel::assets 27 | { 28 | 29 | std::optional loadPng(const std::filesystem::path& path); 30 | std::optional loadPng(base::ArrayView data); 31 | 32 | bool savePng(const std::filesystem::path& path, const data::Image& image); 33 | 34 | } // namespace rigel::assets 35 | -------------------------------------------------------------------------------- /src/assets/user_profile_import.hpp: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2019, Nikolai Wuttke. All rights reserved. 2 | * 3 | * This program is free software: you can redistribute it and/or modify 4 | * it under the terms of the GNU General Public License as published by 5 | * the Free Software Foundation, either version 2 of the License, or 6 | * (at your option) any later version. 7 | * 8 | * This program is distributed in the hope that it will be useful, 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | * GNU General Public License for more details. 12 | * 13 | * You should have received a copy of the GNU General Public License 14 | * along with this program. If not, see . 15 | */ 16 | 17 | #pragma once 18 | 19 | #include "data/high_score_list.hpp" 20 | #include "data/saved_game.hpp" 21 | 22 | #include 23 | #include 24 | #include 25 | 26 | 27 | namespace rigel::assets 28 | { 29 | 30 | struct GameOptions 31 | { 32 | using ScanCode = std::uint8_t; 33 | 34 | ScanCode mUpKeybinding; 35 | ScanCode mDownKeybinding; 36 | ScanCode mLeftKeybinding; 37 | ScanCode mRightKeybinding; 38 | ScanCode mJumpKeybinding; 39 | ScanCode mFireKeybinding; 40 | 41 | data::Difficulty mDifficulty; 42 | 43 | bool mSoundBlasterSoundsOn; 44 | bool mAdlibSoundsOn; 45 | bool mPcSpeakersSoundsOn; 46 | bool mMusicOn; 47 | 48 | std::uint8_t mGameSpeedIndex; 49 | }; 50 | 51 | 52 | data::SaveSlotArray loadSavedGames(const std::string& gamePath); 53 | 54 | std::array 55 | loadHighScoreLists(const std::string& gamePath); 56 | 57 | std::optional loadOptions(const std::string& gamePath); 58 | } // namespace rigel::assets 59 | -------------------------------------------------------------------------------- /src/assets/voc_decoder.hpp: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2016, Nikolai Wuttke. All rights reserved. 2 | * 3 | * This program is free software: you can redistribute it and/or modify 4 | * it under the terms of the GNU General Public License as published by 5 | * the Free Software Foundation, either version 2 of the License, or 6 | * (at your option) any later version. 7 | * 8 | * This program is distributed in the hope that it will be useful, 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | * GNU General Public License for more details. 12 | * 13 | * You should have received a copy of the GNU General Public License 14 | * along with this program. If not, see . 15 | */ 16 | 17 | #pragma once 18 | 19 | #include "assets/byte_buffer.hpp" 20 | #include "base/audio_buffer.hpp" 21 | 22 | 23 | namespace rigel::assets 24 | { 25 | 26 | base::AudioBuffer decodeVoc(const ByteBuffer& data); 27 | 28 | } 29 | -------------------------------------------------------------------------------- /src/audio/software_imf_player.hpp: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2016, Nikolai Wuttke. All rights reserved. 2 | * 3 | * This program is free software: you can redistribute it and/or modify 4 | * it under the terms of the GNU General Public License as published by 5 | * the Free Software Foundation, either version 2 of the License, or 6 | * (at your option) any later version. 7 | * 8 | * This program is distributed in the hope that it will be useful, 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | * GNU General Public License for more details. 12 | * 13 | * You should have received a copy of the GNU General Public License 14 | * along with this program. If not, see . 15 | */ 16 | 17 | #pragma once 18 | 19 | #include "audio/adlib_emulator.hpp" 20 | #include "data/song.hpp" 21 | 22 | #include 23 | #include 24 | 25 | 26 | namespace rigel::audio 27 | { 28 | 29 | class SoftwareImfPlayer 30 | { 31 | public: 32 | explicit SoftwareImfPlayer(int sampleRate); 33 | SoftwareImfPlayer(const SoftwareImfPlayer&) = delete; 34 | SoftwareImfPlayer& operator=(const SoftwareImfPlayer&) = delete; 35 | 36 | void setType(AdlibEmulator::Type type); 37 | 38 | void playSong(data::Song&& song); 39 | void setVolume(const float volume); 40 | 41 | void render(std::int16_t* pBuffer, std::size_t samplesRequired); 42 | 43 | private: 44 | AdlibEmulator mEmulator; 45 | std::mutex mAudioLock; 46 | data::Song mNextSongData; 47 | 48 | data::Song mSongData; 49 | data::Song::const_iterator miNextCommand; 50 | std::size_t mSamplesAvailable = 0; 51 | int mSampleRate; 52 | 53 | std::atomic mVolume; 54 | std::atomic mSongSwitchPending; 55 | std::atomic mTypeToUse; 56 | }; 57 | 58 | } // namespace rigel::audio 59 | -------------------------------------------------------------------------------- /src/base/array_view.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2021, Nikolai Wuttke. All rights reserved. 2 | * 3 | * This program is free software: you can redistribute it and/or modify 4 | * it under the terms of the GNU General Public License as published by 5 | * the Free Software Foundation, either version 2 of the License, or 6 | * (at your option) any later version. 7 | * 8 | * This program is distributed in the hope that it will be useful, 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | * GNU General Public License for more details. 12 | * 13 | * You should have received a copy of the GNU General Public License 14 | * along with this program. If not, see . 15 | */ 16 | 17 | #include "array_view.hpp" 18 | 19 | #include 20 | #include 21 | 22 | 23 | namespace rigel::base::detail 24 | { 25 | 26 | [[noreturn]] void throwOutOfRange(std::uint32_t index) 27 | { 28 | // This is an optimization for code size and compile times. To avoid 29 | // having every client of ArrayView pull in the (fairly expensive) 30 | // stdexcept and string headers into their translation units, and reduce 31 | // the amount of code generated for each instantiation of ArrayView::at(). 32 | using namespace std::string_literals; 33 | 34 | throw std::range_error("Index out of range: "s + std::to_string(index)); 35 | } 36 | 37 | } // namespace rigel::base::detail 38 | -------------------------------------------------------------------------------- /src/base/audio_buffer.hpp: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2016, Nikolai Wuttke. All rights reserved. 2 | * 3 | * This program is free software: you can redistribute it and/or modify 4 | * it under the terms of the GNU General Public License as published by 5 | * the Free Software Foundation, either version 2 of the License, or 6 | * (at your option) any later version. 7 | * 8 | * This program is distributed in the hope that it will be useful, 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | * GNU General Public License for more details. 12 | * 13 | * You should have received a copy of the GNU General Public License 14 | * along with this program. If not, see . 15 | */ 16 | 17 | #pragma once 18 | 19 | #include 20 | #include 21 | 22 | 23 | namespace rigel::base 24 | { 25 | 26 | using Sample = std::int16_t; 27 | 28 | /** Mono, 16-bit signed little-endian PCM */ 29 | struct AudioBuffer 30 | { 31 | int mSampleRate; 32 | std::vector mSamples; 33 | }; 34 | 35 | 36 | } // namespace rigel::base 37 | -------------------------------------------------------------------------------- /src/base/clock.hpp: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2020, Nikolai Wuttke. All rights reserved. 2 | * 3 | * This program is free software: you can redistribute it and/or modify 4 | * it under the terms of the GNU General Public License as published by 5 | * the Free Software Foundation, either version 2 of the License, or 6 | * (at your option) any later version. 7 | * 8 | * This program is distributed in the hope that it will be useful, 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | * GNU General Public License for more details. 12 | * 13 | * You should have received a copy of the GNU General Public License 14 | * along with this program. If not, see . 15 | */ 16 | 17 | #pragma once 18 | 19 | #include 20 | 21 | 22 | namespace rigel::base 23 | { 24 | 25 | using Clock = std::chrono::steady_clock; 26 | 27 | } 28 | -------------------------------------------------------------------------------- /src/base/color.hpp: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2016, Nikolai Wuttke. All rights reserved. 2 | * 3 | * This program is free software: you can redistribute it and/or modify 4 | * it under the terms of the GNU General Public License as published by 5 | * the Free Software Foundation, either version 2 of the License, or 6 | * (at your option) any later version. 7 | * 8 | * This program is distributed in the hope that it will be useful, 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | * GNU General Public License for more details. 12 | * 13 | * You should have received a copy of the GNU General Public License 14 | * along with this program. If not, see . 15 | */ 16 | 17 | #pragma once 18 | 19 | #include 20 | #include 21 | 22 | 23 | namespace rigel::base 24 | { 25 | 26 | struct Color 27 | { 28 | constexpr Color() = default; 29 | constexpr Color( 30 | std::uint8_t r_, 31 | std::uint8_t g_, 32 | std::uint8_t b_, 33 | std::uint8_t a_) noexcept 34 | : r(r_) 35 | , g(g_) 36 | , b(b_) 37 | , a(a_) 38 | { 39 | } 40 | 41 | bool operator==(const Color& other) const noexcept 42 | { 43 | return std::tie(r, g, b, a) == std::tie(other.r, other.g, other.b, other.a); 44 | } 45 | 46 | bool operator!=(const Color& other) const noexcept 47 | { 48 | return !(*this == other); 49 | } 50 | 51 | std::uint8_t r = 0; 52 | std::uint8_t g = 0; 53 | std::uint8_t b = 0; 54 | std::uint8_t a = 0; 55 | }; 56 | 57 | } // namespace rigel::base 58 | -------------------------------------------------------------------------------- /src/base/defer.hpp: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2020, Nikolai Wuttke. All rights reserved. 2 | * 3 | * This program is free software: you can redistribute it and/or modify 4 | * it under the terms of the GNU General Public License as published by 5 | * the Free Software Foundation, either version 2 of the License, or 6 | * (at your option) any later version. 7 | * 8 | * This program is distributed in the hope that it will be useful, 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | * GNU General Public License for more details. 12 | * 13 | * You should have received a copy of the GNU General Public License 14 | * along with this program. If not, see . 15 | */ 16 | 17 | #pragma once 18 | 19 | #include 20 | #include 21 | 22 | 23 | namespace rigel::base 24 | { 25 | 26 | class ScopeGuard 27 | { 28 | public: 29 | template 30 | explicit ScopeGuard(Callback&& callback) 31 | : mCallback(std::forward(callback)) 32 | { 33 | } 34 | 35 | ~ScopeGuard() { mCallback(); } 36 | 37 | ScopeGuard(ScopeGuard&& other) noexcept 38 | : mCallback(std::exchange(other.mCallback, []() {})) 39 | { 40 | } 41 | 42 | ScopeGuard& operator=(ScopeGuard&&) = delete; 43 | ScopeGuard(const ScopeGuard&) = delete; 44 | ScopeGuard& operator=(const ScopeGuard&) = delete; 45 | 46 | private: 47 | std::function mCallback; 48 | }; 49 | 50 | 51 | template 52 | [[nodiscard]] auto defer(Callback&& callback) 53 | { 54 | return ScopeGuard{std::forward(callback)}; 55 | } 56 | 57 | } // namespace rigel::base 58 | -------------------------------------------------------------------------------- /src/base/match.hpp: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2018, Nikolai Wuttke. All rights reserved. 2 | * 3 | * This program is free software: you can redistribute it and/or modify 4 | * it under the terms of the GNU General Public License as published by 5 | * the Free Software Foundation, either version 2 of the License, or 6 | * (at your option) any later version. 7 | * 8 | * This program is distributed in the hope that it will be useful, 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | * GNU General Public License for more details. 12 | * 13 | * You should have received a copy of the GNU General Public License 14 | * along with this program. If not, see . 15 | */ 16 | 17 | #pragma once 18 | 19 | #include 20 | #include 21 | 22 | 23 | namespace rigel::base 24 | { 25 | 26 | namespace detail 27 | { 28 | 29 | template 30 | struct overloaded : Ts... 31 | { 32 | using Ts::operator()...; 33 | }; 34 | 35 | template 36 | overloaded(Ts...) -> overloaded; 37 | 38 | } // namespace detail 39 | 40 | 41 | template 42 | auto match(Variant&& variant, Matchers&&... matchers) 43 | { 44 | return std::visit( 45 | detail::overloaded{std::forward(matchers)...}, 46 | std::forward(variant)); 47 | } 48 | 49 | } // namespace rigel::base 50 | -------------------------------------------------------------------------------- /src/base/spatial_types_printing.hpp: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2016, Nikolai Wuttke. All rights reserved. 2 | * 3 | * This program is free software: you can redistribute it and/or modify 4 | * it under the terms of the GNU General Public License as published by 5 | * the Free Software Foundation, either version 2 of the License, or 6 | * (at your option) any later version. 7 | * 8 | * This program is distributed in the hope that it will be useful, 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | * GNU General Public License for more details. 12 | * 13 | * You should have received a copy of the GNU General Public License 14 | * along with this program. If not, see . 15 | */ 16 | 17 | #pragma once 18 | 19 | #include "spatial_types.hpp" 20 | 21 | #include 22 | #include 23 | 24 | 25 | namespace rigel::base 26 | { 27 | 28 | template 29 | std::ostream& operator<<(std::ostream& stream, const Vec2T& point) 30 | { 31 | stream << "Vec2{" << point.x << ", " << point.y << '}'; 32 | return stream; 33 | } 34 | 35 | 36 | template 37 | std::ostream& operator<<(std::ostream& stream, const Rect& rect) 38 | { 39 | stream << "Rect{" << rect.topLeft.x << ", " << rect.topLeft.y << ", " 40 | << rect.size.width << ", " << rect.size.height << '}'; 41 | return stream; 42 | } 43 | 44 | 45 | template 46 | void outputFixedWidth( 47 | std::ostream& stream, 48 | const base::Vec2T& vec, 49 | const int width) 50 | { 51 | // clang-format off 52 | stream 53 | << std::setw(width) << std::fixed << std::setprecision(2) << vec.x << ", " 54 | << std::setw(width) << std::fixed << std::setprecision(2) << vec.y; 55 | // clang-format on 56 | } 57 | 58 | 59 | } // namespace rigel::base 60 | -------------------------------------------------------------------------------- /src/base/static_vector.hpp: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2019, Nikolai Wuttke. All rights reserved. 2 | * 3 | * This program is free software: you can redistribute it and/or modify 4 | * it under the terms of the GNU General Public License as published by 5 | * the Free Software Foundation, either version 2 of the License, or 6 | * (at your option) any later version. 7 | * 8 | * This program is distributed in the hope that it will be useful, 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | * GNU General Public License for more details. 12 | * 13 | * You should have received a copy of the GNU General Public License 14 | * along with this program. If not, see . 15 | */ 16 | 17 | #pragma once 18 | 19 | #include 20 | 21 | namespace rigel::base 22 | { 23 | 24 | template 25 | using static_vector = std::experimental::fixed_capacity_vector; 26 | 27 | } 28 | -------------------------------------------------------------------------------- /src/data/bonus.hpp: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2019, Nikolai Wuttke. All rights reserved. 2 | * 3 | * This program is free software: you can redistribute it and/or modify 4 | * it under the terms of the GNU General Public License as published by 5 | * the Free Software Foundation, either version 2 of the License, or 6 | * (at your option) any later version. 7 | * 8 | * This program is distributed in the hope that it will be useful, 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | * GNU General Public License for more details. 12 | * 13 | * You should have received a copy of the GNU General Public License 14 | * along with this program. If not, see . 15 | */ 16 | 17 | #pragma once 18 | 19 | #include "data/player_model.hpp" 20 | 21 | #include 22 | #include 23 | 24 | 25 | namespace rigel::data 26 | { 27 | 28 | constexpr int SCORE_ADDED_PER_BONUS = 100000; 29 | 30 | 31 | // Enum values match the bonus numbers shown on the bonus screen 32 | enum class Bonus : std::uint8_t 33 | { 34 | DestroyedAllCameras = 1, 35 | NoDamageTaken = 2, 36 | CollectedEveryWeapon = 3, 37 | CollectedAllMerchandise = 4, 38 | DestroyedAllSpinningLaserTurrets = 5, 39 | DestroyedAllFireBombs = 6, 40 | ShotAllBonusGlobes = 7 41 | }; 42 | 43 | 44 | constexpr int asNumber(const Bonus bonus) 45 | { 46 | return static_cast(bonus); 47 | } 48 | 49 | 50 | inline void addBonusScore( 51 | PersistentPlayerState& persistentPlayerState, 52 | const std::set& bonuses) 53 | { 54 | const auto numBonuses = static_cast(bonuses.size()); 55 | persistentPlayerState.giveScore(numBonuses * SCORE_ADDED_PER_BONUS); 56 | } 57 | 58 | } // namespace rigel::data 59 | -------------------------------------------------------------------------------- /src/data/game_session_data.hpp: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2019, Nikolai Wuttke. All rights reserved. 2 | * 3 | * This program is free software: you can redistribute it and/or modify 4 | * it under the terms of the GNU General Public License as published by 5 | * the Free Software Foundation, either version 2 of the License, or 6 | * (at your option) any later version. 7 | * 8 | * This program is distributed in the hope that it will be useful, 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | * GNU General Public License for more details. 12 | * 13 | * You should have received a copy of the GNU General Public License 14 | * along with this program. If not, see . 15 | */ 16 | 17 | #pragma once 18 | 19 | 20 | namespace rigel::data 21 | { 22 | 23 | constexpr auto NUM_EPISODES = 4; 24 | constexpr auto NUM_LEVELS_PER_EPISODE = 8; 25 | 26 | enum class Difficulty 27 | { 28 | Easy = 0, 29 | Medium = 1, 30 | Hard = 2 31 | }; 32 | 33 | 34 | struct GameSessionId 35 | { 36 | GameSessionId() = default; 37 | GameSessionId( 38 | const int episode, 39 | const int level, 40 | const Difficulty difficulty = Difficulty::Medium, 41 | const bool isDemo = false) 42 | : mEpisode(episode) 43 | , mLevel(level) 44 | , mDifficulty(difficulty) 45 | , mIsDemo(isDemo) 46 | { 47 | } 48 | 49 | bool needsRegisteredVersion() const { return mEpisode > 0; } 50 | 51 | int mEpisode = 0; 52 | int mLevel = 0; 53 | Difficulty mDifficulty = Difficulty::Medium; 54 | bool mIsDemo = false; 55 | }; 56 | 57 | 58 | constexpr bool isBossLevel(const int level) 59 | { 60 | return level == NUM_LEVELS_PER_EPISODE - 1; 61 | } 62 | 63 | 64 | } // namespace rigel::data 65 | -------------------------------------------------------------------------------- /src/data/high_score_list.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2019, Nikolai Wuttke. All rights reserved. 2 | * 3 | * This program is free software: you can redistribute it and/or modify 4 | * it under the terms of the GNU General Public License as published by 5 | * the Free Software Foundation, either version 2 of the License, or 6 | * (at your option) any later version. 7 | * 8 | * This program is distributed in the hope that it will be useful, 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | * GNU General Public License for more details. 12 | * 13 | * You should have received a copy of the GNU General Public License 14 | * along with this program. If not, see . 15 | */ 16 | 17 | #include "high_score_list.hpp" 18 | 19 | #include 20 | 21 | 22 | namespace rigel::data 23 | { 24 | 25 | namespace 26 | { 27 | 28 | template 29 | auto findInsertionSpotForNewScore(const int score, Range&& list) 30 | { 31 | using namespace std; 32 | 33 | return find_if(begin(list), end(list), [score](const HighScoreEntry& entry) { 34 | return entry.mScore <= score; 35 | }); 36 | } 37 | 38 | } // namespace 39 | 40 | 41 | bool scoreQualifiesForHighScoreList(const int score, const HighScoreList& list) 42 | { 43 | return score > 0 && 44 | findInsertionSpotForNewScore(score, list) != std::end(list); 45 | } 46 | 47 | 48 | void insertNewScore( 49 | const int score, 50 | const std::string& name, 51 | HighScoreList& list) 52 | { 53 | using namespace std; 54 | 55 | auto it = findInsertionSpotForNewScore(score, list); 56 | if (it != end(list)) 57 | { 58 | rotate(it, prev(end(list)), end(list)); 59 | *it = HighScoreEntry{name, score}; 60 | } 61 | } 62 | 63 | } // namespace rigel::data 64 | -------------------------------------------------------------------------------- /src/data/level_hints.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2018, Nikolai Wuttke. All rights reserved. 2 | * 3 | * This program is free software: you can redistribute it and/or modify 4 | * it under the terms of the GNU General Public License as published by 5 | * the Free Software Foundation, either version 2 of the License, or 6 | * (at your option) any later version. 7 | * 8 | * This program is distributed in the hope that it will be useful, 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | * GNU General Public License for more details. 12 | * 13 | * You should have received a copy of the GNU General Public License 14 | * along with this program. If not, see . 15 | */ 16 | 17 | #include "level_hints.hpp" 18 | 19 | #include 20 | 21 | 22 | namespace rigel::data 23 | { 24 | 25 | std::optional 26 | LevelHints::getHint(const int episode, const int level) const 27 | { 28 | using namespace std; 29 | 30 | auto iHint = find_if(begin(mHints), end(mHints), [&](const Hint& hint) { 31 | return hint.mEpisode == episode && hint.mLevel == level; 32 | }); 33 | 34 | return iHint != end(mHints) ? std::optional{iHint->mMessage} 35 | : std::nullopt; 36 | } 37 | 38 | } // namespace rigel::data 39 | -------------------------------------------------------------------------------- /src/data/level_hints.hpp: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2018, Nikolai Wuttke. All rights reserved. 2 | * 3 | * This program is free software: you can redistribute it and/or modify 4 | * it under the terms of the GNU General Public License as published by 5 | * the Free Software Foundation, either version 2 of the License, or 6 | * (at your option) any later version. 7 | * 8 | * This program is distributed in the hope that it will be useful, 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | * GNU General Public License for more details. 12 | * 13 | * You should have received a copy of the GNU General Public License 14 | * along with this program. If not, see . 15 | */ 16 | 17 | #pragma once 18 | 19 | #include 20 | #include 21 | #include 22 | #include 23 | 24 | 25 | namespace rigel::data 26 | { 27 | 28 | struct Hint 29 | { 30 | Hint(const int episode, const int level, std::string message) 31 | : mEpisode(episode) 32 | , mLevel(level) 33 | , mMessage(std::move(message)) 34 | { 35 | } 36 | 37 | int mEpisode; 38 | int mLevel; 39 | std::string mMessage; 40 | }; 41 | 42 | 43 | struct LevelHints 44 | { 45 | LevelHints() = default; 46 | explicit LevelHints(std::vector hints) 47 | : mHints(std::move(hints)) 48 | { 49 | } 50 | 51 | std::optional getHint(int episode, int level) const; 52 | 53 | std::vector mHints; 54 | }; 55 | 56 | } // namespace rigel::data 57 | -------------------------------------------------------------------------------- /src/data/movie.hpp: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2016, Nikolai Wuttke. All rights reserved. 2 | * 3 | * This program is free software: you can redistribute it and/or modify 4 | * it under the terms of the GNU General Public License as published by 5 | * the Free Software Foundation, either version 2 of the License, or 6 | * (at your option) any later version. 7 | * 8 | * This program is distributed in the hope that it will be useful, 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | * GNU General Public License for more details. 12 | * 13 | * You should have received a copy of the GNU General Public License 14 | * along with this program. If not, see . 15 | */ 16 | 17 | #pragma once 18 | 19 | #include 20 | #include 21 | #include 22 | 23 | 24 | namespace rigel::data 25 | { 26 | 27 | struct MovieFrame 28 | { 29 | MovieFrame(Image&& replacementImage, const int startRow) 30 | : mReplacementImage(std::move(replacementImage)) 31 | , mStartRow(startRow) 32 | { 33 | } 34 | 35 | Image mReplacementImage; 36 | int mStartRow; 37 | }; 38 | 39 | 40 | struct Movie 41 | { 42 | Image mBaseImage; 43 | std::vector mFrames; 44 | }; 45 | 46 | } // namespace rigel::data 47 | -------------------------------------------------------------------------------- /src/data/palette.hpp: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2021, Nikolai Wuttke. All rights reserved. 2 | * 3 | * This program is free software: you can redistribute it and/or modify 4 | * it under the terms of the GNU General Public License as published by 5 | * the Free Software Foundation, either version 2 of the License, or 6 | * (at your option) any later version. 7 | * 8 | * This program is distributed in the hope that it will be useful, 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | * GNU General Public License for more details. 12 | * 13 | * You should have received a copy of the GNU General Public License 14 | * along with this program. If not, see . 15 | */ 16 | 17 | #pragma once 18 | 19 | #include "base/image.hpp" 20 | 21 | #include 22 | 23 | 24 | namespace rigel::data 25 | { 26 | 27 | using Palette16 = std::array; 28 | 29 | using Palette256 = std::array; 30 | 31 | } // namespace rigel::data 32 | -------------------------------------------------------------------------------- /src/data/saved_game.hpp: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2019, Nikolai Wuttke. All rights reserved. 2 | * 3 | * This program is free software: you can redistribute it and/or modify 4 | * it under the terms of the GNU General Public License as published by 5 | * the Free Software Foundation, either version 2 of the License, or 6 | * (at your option) any later version. 7 | * 8 | * This program is distributed in the hope that it will be useful, 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | * GNU General Public License for more details. 12 | * 13 | * You should have received a copy of the GNU General Public License 14 | * along with this program. If not, see . 15 | */ 16 | 17 | #pragma once 18 | 19 | #include "data/game_session_data.hpp" 20 | #include "data/player_model.hpp" 21 | 22 | #include 23 | #include 24 | #include 25 | 26 | 27 | namespace rigel::data 28 | { 29 | 30 | constexpr auto NUM_SAVE_SLOTS = 8u; 31 | 32 | struct SavedGame 33 | { 34 | GameSessionId mSessionId; 35 | TutorialMessageState mTutorialMessagesAlreadySeen; 36 | std::string mName; 37 | WeaponType mWeapon = WeaponType::Normal; 38 | int mAmmo = 0; 39 | int mScore = 0; 40 | }; 41 | 42 | 43 | using SaveSlotArray = std::array, NUM_SAVE_SLOTS>; 44 | 45 | } // namespace rigel::data 46 | -------------------------------------------------------------------------------- /src/data/song.hpp: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2016, Nikolai Wuttke. All rights reserved. 2 | * 3 | * This program is free software: you can redistribute it and/or modify 4 | * it under the terms of the GNU General Public License as published by 5 | * the Free Software Foundation, either version 2 of the License, or 6 | * (at your option) any later version. 7 | * 8 | * This program is distributed in the hope that it will be useful, 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | * GNU General Public License for more details. 12 | * 13 | * You should have received a copy of the GNU General Public License 14 | * along with this program. If not, see . 15 | */ 16 | 17 | #pragma once 18 | 19 | #include 20 | #include 21 | 22 | namespace rigel::data 23 | { 24 | 25 | struct ImfCommand 26 | { 27 | std::uint8_t reg; 28 | std::uint8_t value; 29 | std::uint16_t delay; 30 | }; 31 | 32 | 33 | using Song = std::vector; 34 | 35 | } // namespace rigel::data 36 | -------------------------------------------------------------------------------- /src/data/unit_conversions.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2016, Nikolai Wuttke. All rights reserved. 2 | * 3 | * This program is free software: you can redistribute it and/or modify 4 | * it under the terms of the GNU General Public License as published by 5 | * the Free Software Foundation, either version 2 of the License, or 6 | * (at your option) any later version. 7 | * 8 | * This program is distributed in the hope that it will be useful, 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | * GNU General Public License for more details. 12 | * 13 | * You should have received a copy of the GNU General Public License 14 | * along with this program. If not, see . 15 | */ 16 | 17 | #include "unit_conversions.hpp" 18 | 19 | #include "game_traits.hpp" 20 | 21 | 22 | namespace rigel::data 23 | { 24 | 25 | using namespace base; 26 | 27 | 28 | Vec2 tilesToPixels(const Vec2& tileVec) 29 | { 30 | return { 31 | tilesToPixels(tileVec.x), 32 | tilesToPixels(tileVec.y), 33 | }; 34 | } 35 | 36 | 37 | Vec2 pixelsToTiles(const Vec2& pixelVector) 38 | { 39 | return { 40 | pixelsToTiles(pixelVector.x), 41 | pixelsToTiles(pixelVector.y), 42 | }; 43 | } 44 | 45 | 46 | Size tilesToPixels(const Size& tileExtents) 47 | { 48 | return { 49 | tilesToPixels(tileExtents.width), 50 | tilesToPixels(tileExtents.height), 51 | }; 52 | } 53 | 54 | 55 | Size pixelsToTiles(const Size& pixelExtents) 56 | { 57 | return { 58 | pixelsToTiles(pixelExtents.width), 59 | pixelsToTiles(pixelExtents.height), 60 | }; 61 | } 62 | 63 | 64 | } // namespace rigel::data 65 | -------------------------------------------------------------------------------- /src/data/unit_conversions.hpp: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2016, Nikolai Wuttke. All rights reserved. 2 | * 3 | * This program is free software: you can redistribute it and/or modify 4 | * it under the terms of the GNU General Public License as published by 5 | * the Free Software Foundation, either version 2 of the License, or 6 | * (at your option) any later version. 7 | * 8 | * This program is distributed in the hope that it will be useful, 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | * GNU General Public License for more details. 12 | * 13 | * You should have received a copy of the GNU General Public License 14 | * along with this program. If not, see . 15 | */ 16 | 17 | #pragma once 18 | 19 | #include "base/spatial_types.hpp" 20 | #include "data/game_traits.hpp" 21 | 22 | 23 | namespace rigel::data 24 | { 25 | 26 | template 27 | constexpr T pixelsToTiles(const T pixels) 28 | { 29 | return pixels / static_cast(GameTraits::tileSize); 30 | } 31 | 32 | template 33 | constexpr T tilesToPixels(const T tiles) 34 | { 35 | return tiles * static_cast(GameTraits::tileSize); 36 | } 37 | 38 | 39 | base::Vec2 tilesToPixels(const base::Vec2& tileVector); 40 | base::Vec2 pixelsToTiles(const base::Vec2& pixelVector); 41 | 42 | base::Size tilesToPixels(const base::Size& tileExtents); 43 | base::Size pixelsToTiles(const base::Size& pixelExtents); 44 | 45 | } // namespace rigel::data 46 | -------------------------------------------------------------------------------- /src/engine/entity_activation_system.hpp: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2016, Nikolai Wuttke. All rights reserved. 2 | * 3 | * This program is free software: you can redistribute it and/or modify 4 | * it under the terms of the GNU General Public License as published by 5 | * the Free Software Foundation, either version 2 of the License, or 6 | * (at your option) any later version. 7 | * 8 | * This program is distributed in the hope that it will be useful, 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | * GNU General Public License for more details. 12 | * 13 | * You should have received a copy of the GNU General Public License 14 | * along with this program. If not, see . 15 | */ 16 | 17 | #pragma once 18 | 19 | #include "base/spatial_types.hpp" 20 | #include "base/warnings.hpp" 21 | 22 | RIGEL_DISABLE_WARNINGS 23 | #include 24 | RIGEL_RESTORE_WARNINGS 25 | 26 | 27 | namespace rigel::engine 28 | { 29 | 30 | void markActiveEntities( 31 | entityx::EntityManager& es, 32 | const base::Vec2& cameraPosition, 33 | const base::Size& viewportSize); 34 | 35 | } 36 | -------------------------------------------------------------------------------- /src/engine/isprite_factory.hpp: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2020, Nikolai Wuttke. All rights reserved. 2 | * 3 | * This program is free software: you can redistribute it and/or modify 4 | * it under the terms of the GNU General Public License as published by 5 | * the Free Software Foundation, either version 2 of the License, or 6 | * (at your option) any later version. 7 | * 8 | * This program is distributed in the hope that it will be useful, 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | * GNU General Public License for more details. 12 | * 13 | * You should have received a copy of the GNU General Public License 14 | * along with this program. If not, see . 15 | */ 16 | 17 | #pragma once 18 | 19 | #include "base/spatial_types.hpp" 20 | #include "data/actor_ids.hpp" 21 | #include "engine/visual_components.hpp" 22 | 23 | 24 | namespace rigel::engine 25 | { 26 | 27 | struct ISpriteFactory 28 | { 29 | virtual ~ISpriteFactory() = default; 30 | 31 | virtual engine::components::Sprite createSprite(data::ActorID id) = 0; 32 | virtual base::Rect actorFrameRect(data::ActorID id, int frame) const = 0; 33 | virtual engine::SpriteFrame 34 | actorFrameData(data::ActorID id, int frame) const = 0; 35 | }; 36 | 37 | } // namespace rigel::engine 38 | -------------------------------------------------------------------------------- /src/engine/life_time_system.hpp: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2016, Nikolai Wuttke. All rights reserved. 2 | * 3 | * This program is free software: you can redistribute it and/or modify 4 | * it under the terms of the GNU General Public License as published by 5 | * the Free Software Foundation, either version 2 of the License, or 6 | * (at your option) any later version. 7 | * 8 | * This program is distributed in the hope that it will be useful, 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | * GNU General Public License for more details. 12 | * 13 | * You should have received a copy of the GNU General Public License 14 | * along with this program. If not, see . 15 | */ 16 | 17 | #pragma once 18 | 19 | #include "base/spatial_types.hpp" 20 | #include "engine/life_time_components.hpp" 21 | 22 | RIGEL_DISABLE_WARNINGS 23 | #include 24 | RIGEL_RESTORE_WARNINGS 25 | 26 | 27 | namespace rigel::engine 28 | { 29 | 30 | class LifeTimeSystem 31 | { 32 | public: 33 | void update( 34 | entityx::EntityManager& es, 35 | const base::Vec2& cameraPosition, 36 | const base::Size& viewportSize); 37 | }; 38 | 39 | } // namespace rigel::engine 40 | -------------------------------------------------------------------------------- /src/engine/particle_system.hpp: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2017, Nikolai Wuttke. All rights reserved. 2 | * 3 | * This program is free software: you can redistribute it and/or modify 4 | * it under the terms of the GNU General Public License as published by 5 | * the Free Software Foundation, either version 2 of the License, or 6 | * (at your option) any later version. 7 | * 8 | * This program is distributed in the hope that it will be useful, 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | * GNU General Public License for more details. 12 | * 13 | * You should have received a copy of the GNU General Public License 14 | * along with this program. If not, see . 15 | */ 16 | 17 | #pragma once 18 | 19 | #include "base/color.hpp" 20 | #include "base/spatial_types.hpp" 21 | 22 | #include 23 | 24 | namespace rigel::renderer 25 | { 26 | class Renderer; 27 | } 28 | 29 | 30 | namespace rigel::engine 31 | { 32 | 33 | class RandomNumberGenerator; 34 | 35 | struct ParticleGroup; 36 | 37 | 38 | class ParticleSystem 39 | { 40 | public: 41 | ParticleSystem( 42 | RandomNumberGenerator* pRandomGenerator, 43 | renderer::Renderer* pRenderer); 44 | ~ParticleSystem(); 45 | 46 | void synchronizeTo(const ParticleSystem& other); 47 | 48 | void spawnParticles( 49 | const base::Vec2& origin, 50 | const base::Color& color, 51 | int velocityScaleX = 0); 52 | 53 | void update(); 54 | void render(const base::Vec2& cameraPosition, float interpolation); 55 | 56 | private: 57 | std::vector mParticleGroups; 58 | RandomNumberGenerator* mpRandomGenerator; 59 | renderer::Renderer* mpRenderer; 60 | }; 61 | 62 | } // namespace rigel::engine 63 | -------------------------------------------------------------------------------- /src/engine/physics.hpp: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2021, Nikolai Wuttke. All rights reserved. 2 | * 3 | * This program is free software: you can redistribute it and/or modify 4 | * it under the terms of the GNU General Public License as published by 5 | * the Free Software Foundation, either version 2 of the License, or 6 | * (at your option) any later version. 7 | * 8 | * This program is distributed in the hope that it will be useful, 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | * GNU General Public License for more details. 12 | * 13 | * You should have received a copy of the GNU General Public License 14 | * along with this program. If not, see . 15 | */ 16 | 17 | #pragma once 18 | 19 | #include "base/warnings.hpp" 20 | #include "engine/base_components.hpp" 21 | #include "engine/physical_components.hpp" 22 | 23 | RIGEL_DISABLE_WARNINGS 24 | #include 25 | RIGEL_RESTORE_WARNINGS 26 | 27 | #include 28 | 29 | 30 | namespace rigel::data::map 31 | { 32 | class Map; 33 | } 34 | 35 | 36 | namespace rigel::engine 37 | { 38 | 39 | class CollisionChecker; 40 | 41 | struct PhysicsCollisionInfo 42 | { 43 | bool mLeft; 44 | bool mRight; 45 | bool mTop; 46 | bool mBottom; 47 | }; 48 | 49 | std::optional applyPhysics( 50 | const CollisionChecker& collisionChecker, 51 | const data::map::Map& map, 52 | entityx::Entity entity, 53 | components::MovingBody& body, 54 | components::WorldPosition& position, 55 | const components::BoundingBox& collisionRect); 56 | 57 | float applyGravity( 58 | const CollisionChecker& collisionChecker, 59 | const components::BoundingBox& bbox, 60 | float currentVelocity); 61 | 62 | } // namespace rigel::engine 63 | -------------------------------------------------------------------------------- /src/engine/random_number_generator.hpp: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2016, Nikolai Wuttke. All rights reserved. 2 | * 3 | * This program is free software: you can redistribute it and/or modify 4 | * it under the terms of the GNU General Public License as published by 5 | * the Free Software Foundation, either version 2 of the License, or 6 | * (at your option) any later version. 7 | * 8 | * This program is distributed in the hope that it will be useful, 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | * GNU General Public License for more details. 12 | * 13 | * You should have received a copy of the GNU General Public License 14 | * along with this program. If not, see . 15 | */ 16 | 17 | #pragma once 18 | 19 | #include 20 | #include 21 | 22 | 23 | namespace rigel::engine 24 | { 25 | 26 | extern const std::array RANDOM_NUMBER_TABLE; 27 | 28 | 29 | class RandomNumberGenerator 30 | { 31 | public: 32 | int gen(); 33 | 34 | private: 35 | std::uint8_t mNextNumberIndex = 0; 36 | }; 37 | 38 | } // namespace rigel::engine 39 | -------------------------------------------------------------------------------- /src/frontend/anti_piracy_screen_mode.hpp: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2019, Nikolai Wuttke. All rights reserved. 2 | * 3 | * This program is free software: you can redistribute it and/or modify 4 | * it under the terms of the GNU General Public License as published by 5 | * the Free Software Foundation, either version 2 of the License, or 6 | * (at your option) any later version. 7 | * 8 | * This program is distributed in the hope that it will be useful, 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | * GNU General Public License for more details. 12 | * 13 | * You should have received a copy of the GNU General Public License 14 | * along with this program. If not, see . 15 | */ 16 | 17 | #pragma once 18 | 19 | #include "frontend/game_mode.hpp" 20 | #include "renderer/texture.hpp" 21 | 22 | 23 | namespace rigel 24 | { 25 | 26 | /** Shows anti-piracy screen for registered version 27 | * 28 | * Shows the anti-piracy screen (LCR.MNI) until any key is pressed, then 29 | * switches to Intro/Demo loop. 30 | */ 31 | class AntiPiracyScreenMode : public GameMode 32 | { 33 | public: 34 | AntiPiracyScreenMode(Context context, bool isFirstLaunch); 35 | 36 | std::unique_ptr updateAndRender( 37 | engine::TimeDelta, 38 | const std::vector& events) override; 39 | 40 | private: 41 | Context mContext; 42 | renderer::Texture mTexture; 43 | bool mIsFirstLaunch; 44 | }; 45 | 46 | } // namespace rigel 47 | -------------------------------------------------------------------------------- /src/frontend/command_line_options.hpp: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2020, Nikolai Wuttke. All rights reserved. 2 | * 3 | * This program is free software: you can redistribute it and/or modify 4 | * it under the terms of the GNU General Public License as published by 5 | * the Free Software Foundation, either version 2 of the License, or 6 | * (at your option) any later version. 7 | * 8 | * This program is distributed in the hope that it will be useful, 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | * GNU General Public License for more details. 12 | * 13 | * You should have received a copy of the GNU General Public License 14 | * along with this program. If not, see . 15 | */ 16 | 17 | #pragma once 18 | 19 | #include "base/spatial_types.hpp" 20 | #include "data/game_session_data.hpp" 21 | 22 | #include 23 | #include 24 | #include 25 | 26 | 27 | namespace rigel 28 | { 29 | 30 | /** Settings that can be changed via command-line arguments/switches 31 | * 32 | * This represents the parsed representation of all command line arguments 33 | * (argc/argv). The parsing happens in main.cpp 34 | * For documentation on the individual members, refer to the parser code over 35 | * there. 36 | * 37 | * If you add something here, you'll want to extend the code in main.cpp 38 | * as well! 39 | */ 40 | struct CommandLineOptions 41 | { 42 | std::string mGamePath; 43 | std::optional mLevelToJumpTo; 44 | bool mSkipIntro = false; 45 | bool mDebugModeEnabled = false; 46 | bool mDisableAudio = false; 47 | bool mPlayDemo = false; 48 | std::optional mPlayerPosition; 49 | }; 50 | 51 | } // namespace rigel 52 | -------------------------------------------------------------------------------- /src/frontend/demo_player.hpp: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2020, Nikolai Wuttke. All rights reserved. 2 | * 3 | * This program is free software: you can redistribute it and/or modify 4 | * it under the terms of the GNU General Public License as published by 5 | * the Free Software Foundation, either version 2 of the License, or 6 | * (at your option) any later version. 7 | * 8 | * This program is distributed in the hope that it will be useful, 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | * GNU General Public License for more details. 12 | * 13 | * You should have received a copy of the GNU General Public License 14 | * along with this program. If not, see . 15 | */ 16 | 17 | #pragma once 18 | 19 | #include "data/player_model.hpp" 20 | #include "engine/timing.hpp" 21 | #include "frontend/game_mode.hpp" 22 | #include "game_logic_common/input.hpp" 23 | 24 | #include 25 | #include 26 | 27 | 28 | namespace rigel::game_logic 29 | { 30 | 31 | class GameWorld_Classic; 32 | 33 | 34 | struct DemoInput 35 | { 36 | PlayerInput mInput; 37 | bool mNextLevel; 38 | }; 39 | 40 | 41 | class DemoPlayer 42 | { 43 | public: 44 | explicit DemoPlayer(GameMode::Context context); 45 | ~DemoPlayer(); 46 | 47 | DemoPlayer(DemoPlayer&&); 48 | DemoPlayer& operator=(DemoPlayer&&); 49 | 50 | void updateAndRender(engine::TimeDelta dt); 51 | 52 | bool isFinished() const; 53 | 54 | private: 55 | GameMode::Context mContext; 56 | data::PersistentPlayerState mPersistentPlayerState; 57 | 58 | std::vector mFrames; 59 | std::size_t mCurrentFrameIndex = 1; 60 | std::size_t mLevelIndex = 0; 61 | engine::TimeDelta mElapsedTime = 0; 62 | 63 | std::unique_ptr mpWorld; 64 | }; 65 | 66 | } // namespace rigel::game_logic 67 | -------------------------------------------------------------------------------- /src/frontend/game_mode.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2019, Nikolai Wuttke. All rights reserved. 2 | * 3 | * This program is free software: you can redistribute it and/or modify 4 | * it under the terms of the GNU General Public License as published by 5 | * the Free Software Foundation, either version 2 of the License, or 6 | * (at your option) any later version. 7 | * 8 | * This program is distributed in the hope that it will be useful, 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | * GNU General Public License for more details. 12 | * 13 | * You should have received a copy of the GNU General Public License 14 | * along with this program. If not, see . 15 | */ 16 | 17 | #include "game_mode.hpp" 18 | 19 | #include "ui/duke_script_runner.hpp" 20 | 21 | 22 | namespace rigel 23 | { 24 | 25 | void runScript(GameMode::Context& context, const std::string& scriptName) 26 | { 27 | context.mpScriptRunner->executeScript(context.mpScripts->at(scriptName)); 28 | } 29 | 30 | } // namespace rigel 31 | -------------------------------------------------------------------------------- /src/frontend/input_handler.hpp: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2020, Nikolai Wuttke. All rights reserved. 2 | * 3 | * This program is free software: you can redistribute it and/or modify 4 | * it under the terms of the GNU General Public License as published by 5 | * the Free Software Foundation, either version 2 of the License, or 6 | * (at your option) any later version. 7 | * 8 | * This program is distributed in the hope that it will be useful, 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | * GNU General Public License for more details. 12 | * 13 | * You should have received a copy of the GNU General Public License 14 | * along with this program. If not, see . 15 | */ 16 | 17 | #pragma once 18 | 19 | #include "base/spatial_types.hpp" 20 | #include "base/warnings.hpp" 21 | #include "game_logic_common/input.hpp" 22 | 23 | RIGEL_DISABLE_WARNINGS 24 | #include 25 | RIGEL_RESTORE_WARNINGS 26 | 27 | #include 28 | 29 | 30 | namespace rigel 31 | { 32 | 33 | namespace data 34 | { 35 | struct GameOptions; 36 | } 37 | 38 | 39 | class InputHandler 40 | { 41 | public: 42 | enum class MenuCommand 43 | { 44 | None, 45 | QuickSave, 46 | QuickLoad 47 | }; 48 | 49 | explicit InputHandler(const data::GameOptions* pOptions); 50 | 51 | MenuCommand handleEvent(const SDL_Event& event, bool playerInShip); 52 | void reset(); 53 | 54 | game_logic::PlayerInput fetchInput(); 55 | 56 | private: 57 | MenuCommand handleKeyboardInput(const SDL_Event& event); 58 | MenuCommand handleControllerInput(const SDL_Event& event, bool playerInShip); 59 | 60 | game_logic::PlayerInput mPlayerInput; 61 | base::Vec2 mAnalogStickVector; 62 | const data::GameOptions* mpOptions; 63 | bool mQuickSaveModifierHeld = false; 64 | }; 65 | 66 | } // namespace rigel 67 | -------------------------------------------------------------------------------- /src/frontend/json_utils.hpp: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2019, Nikolai Wuttke. All rights reserved. 2 | * 3 | * This program is free software: you can redistribute it and/or modify 4 | * it under the terms of the GNU General Public License as published by 5 | * the Free Software Foundation, either version 2 of the License, or 6 | * (at your option) any later version. 7 | * 8 | * This program is distributed in the hope that it will be useful, 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | * GNU General Public License for more details. 12 | * 13 | * You should have received a copy of the GNU General Public License 14 | * along with this program. If not, see . 15 | */ 16 | 17 | #pragma once 18 | 19 | #include "base/warnings.hpp" 20 | 21 | RIGEL_DISABLE_WARNINGS 22 | #include 23 | RIGEL_RESTORE_WARNINGS 24 | 25 | 26 | namespace rigel 27 | { 28 | 29 | /** Merges values from extension into base 30 | * 31 | * This function merges the contents of extension into base by overwriting 32 | * any properties that exist in both objects with the values from extension. 33 | * Properties that don't exist in extension will be left unchanged in base. 34 | * 35 | * base and extension must be structurally equivalent. This means: 36 | * 37 | * * if a property in one of the two is an object or array, it must also be 38 | * an object or array in the other JSON tree, respectively. 39 | * * if a property is an array, it must have the same number of elements in 40 | * both JSON trees. 41 | */ 42 | nlohmann::json merge(nlohmann::json base, nlohmann::json extension); 43 | 44 | } // namespace rigel 45 | -------------------------------------------------------------------------------- /src/game_logic/behavior_controller_system.hpp: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2018, Nikolai Wuttke. All rights reserved. 2 | * 3 | * This program is free software: you can redistribute it and/or modify 4 | * it under the terms of the GNU General Public License as published by 5 | * the Free Software Foundation, either version 2 of the License, or 6 | * (at your option) any later version. 7 | * 8 | * This program is distributed in the hope that it will be useful, 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | * GNU General Public License for more details. 12 | * 13 | * You should have received a copy of the GNU General Public License 14 | * along with this program. If not, see . 15 | */ 16 | 17 | #pragma once 18 | 19 | #include "game_logic/damage_components.hpp" 20 | #include "game_logic/global_dependencies.hpp" 21 | #include "game_logic_common/input.hpp" 22 | 23 | namespace rigel::engine::events 24 | { 25 | struct CollidedWithWorld; 26 | } 27 | 28 | 29 | namespace rigel::game_logic 30 | { 31 | 32 | class BehaviorControllerSystem 33 | : public entityx::Receiver 34 | { 35 | public: 36 | BehaviorControllerSystem( 37 | GlobalDependencies dependencies, 38 | Player* pPlayer, 39 | const base::Vec2* pCameraPosition, 40 | data::map::Map* pMap); 41 | 42 | void update(entityx::EntityManager& es, const PerFrameState& s); 43 | 44 | void receive(const events::ShootableDamaged& event); 45 | void receive(const events::ShootableKilled& event); 46 | void receive(const engine::events::CollidedWithWorld& event); 47 | 48 | private: 49 | GlobalDependencies mDependencies; 50 | PerFrameState mPerFrameState; 51 | GlobalState mGlobalState; 52 | }; 53 | 54 | } // namespace rigel::game_logic 55 | -------------------------------------------------------------------------------- /src/game_logic/debugging_system.hpp: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2016, Nikolai Wuttke. All rights reserved. 2 | * 3 | * This program is free software: you can redistribute it and/or modify 4 | * it under the terms of the GNU General Public License as published by 5 | * the Free Software Foundation, either version 2 of the License, or 6 | * (at your option) any later version. 7 | * 8 | * This program is distributed in the hope that it will be useful, 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | * GNU General Public License for more details. 12 | * 13 | * You should have received a copy of the GNU General Public License 14 | * along with this program. If not, see . 15 | */ 16 | 17 | #pragma once 18 | 19 | #include "base/spatial_types.hpp" 20 | #include "base/warnings.hpp" 21 | #include "data/map.hpp" 22 | #include "renderer/renderer.hpp" 23 | 24 | RIGEL_DISABLE_WARNINGS 25 | #include 26 | RIGEL_RESTORE_WARNINGS 27 | 28 | 29 | namespace rigel::game_logic 30 | { 31 | 32 | class DebuggingSystem 33 | { 34 | public: 35 | DebuggingSystem(renderer::Renderer* pRenderer, data::map::Map* pMap); 36 | 37 | void toggleBoundingBoxDisplay(); 38 | void toggleWorldCollisionDataDisplay(); 39 | void toggleGridDisplay(); 40 | 41 | void update( 42 | entityx::EntityManager& es, 43 | const base::Vec2& cameraPosition, 44 | const base::Size& viewportSize, 45 | float interpolationFactor); 46 | 47 | private: 48 | renderer::Renderer* mpRenderer; 49 | data::map::Map* mpMap; 50 | 51 | bool mShowBoundingBoxes = false; 52 | bool mShowWorldCollisionData = false; 53 | bool mShowGrid = false; 54 | }; 55 | 56 | } // namespace rigel::game_logic 57 | -------------------------------------------------------------------------------- /src/game_logic/earth_quake_effect.hpp: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2016, Nikolai Wuttke. All rights reserved. 2 | * 3 | * This program is free software: you can redistribute it and/or modify 4 | * it under the terms of the GNU General Public License as published by 5 | * the Free Software Foundation, either version 2 of the License, or 6 | * (at your option) any later version. 7 | * 8 | * This program is distributed in the hope that it will be useful, 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | * GNU General Public License for more details. 12 | * 13 | * You should have received a copy of the GNU General Public License 14 | * along with this program. If not, see . 15 | */ 16 | 17 | #pragma once 18 | 19 | #include "base/warnings.hpp" 20 | 21 | RIGEL_DISABLE_WARNINGS 22 | #include 23 | RIGEL_RESTORE_WARNINGS 24 | 25 | 26 | namespace rigel 27 | { 28 | struct IGameServiceProvider; 29 | } 30 | namespace rigel::engine 31 | { 32 | class RandomNumberGenerator; 33 | } 34 | 35 | 36 | namespace rigel::game_logic 37 | { 38 | 39 | class EarthQuakeEffect 40 | { 41 | public: 42 | EarthQuakeEffect( 43 | IGameServiceProvider* pServiceProvider, 44 | engine::RandomNumberGenerator* pRandomGenerator, 45 | entityx::EventManager* pEvents); 46 | 47 | void synchronizeTo(const EarthQuakeEffect& other); 48 | 49 | void update(); 50 | bool isQuaking() const; 51 | 52 | private: 53 | int mCountdown; 54 | int mThreshold; 55 | 56 | IGameServiceProvider* mpServiceProvider; 57 | engine::RandomNumberGenerator* mpRandomGenerator; 58 | entityx::EventManager* mpEvents; 59 | }; 60 | 61 | } // namespace rigel::game_logic 62 | -------------------------------------------------------------------------------- /src/game_logic/effect_actor_components.hpp: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2016, Nikolai Wuttke. All rights reserved. 2 | * 3 | * This program is free software: you can redistribute it and/or modify 4 | * it under the terms of the GNU General Public License as published by 5 | * the Free Software Foundation, either version 2 of the License, or 6 | * (at your option) any later version. 7 | * 8 | * This program is distributed in the hope that it will be useful, 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | * GNU General Public License for more details. 12 | * 13 | * You should have received a copy of the GNU General Public License 14 | * along with this program. If not, see . 15 | */ 16 | 17 | #pragma once 18 | 19 | #include "game_logic/global_dependencies.hpp" 20 | 21 | 22 | namespace rigel::game_logic::components 23 | { 24 | 25 | struct WindBlownSpiderGenerator 26 | { 27 | void update( 28 | GlobalDependencies& dependencies, 29 | GlobalState& state, 30 | bool isOnScreen, 31 | entityx::Entity entity); 32 | }; 33 | 34 | 35 | struct WaterDropGenerator 36 | { 37 | void update( 38 | GlobalDependencies& dependencies, 39 | GlobalState& state, 40 | bool isOnScreen, 41 | entityx::Entity entity); 42 | }; 43 | 44 | 45 | struct ExplosionEffect 46 | { 47 | void update( 48 | GlobalDependencies& dependencies, 49 | GlobalState& state, 50 | bool isOnScreen, 51 | entityx::Entity entity); 52 | }; 53 | 54 | 55 | struct AirLockDeathTrigger 56 | { 57 | void update( 58 | GlobalDependencies& dependencies, 59 | GlobalState& state, 60 | bool isOnScreen, 61 | entityx::Entity entity); 62 | }; 63 | 64 | } // namespace rigel::game_logic::components 65 | -------------------------------------------------------------------------------- /src/game_logic/enemies/big_green_cat.hpp: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2019, Nikolai Wuttke. All rights reserved. 2 | * 3 | * This program is free software: you can redistribute it and/or modify 4 | * it under the terms of the GNU General Public License as published by 5 | * the Free Software Foundation, either version 2 of the License, or 6 | * (at your option) any later version. 7 | * 8 | * This program is distributed in the hope that it will be useful, 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | * GNU General Public License for more details. 12 | * 13 | * You should have received a copy of the GNU General Public License 14 | * along with this program. If not, see . 15 | */ 16 | 17 | #pragma once 18 | 19 | #include "base/warnings.hpp" 20 | 21 | RIGEL_DISABLE_WARNINGS 22 | #include 23 | RIGEL_RESTORE_WARNINGS 24 | 25 | 26 | namespace rigel::game_logic 27 | { 28 | struct GlobalDependencies; 29 | struct GlobalState; 30 | } // namespace rigel::game_logic 31 | 32 | 33 | namespace rigel::game_logic::behaviors 34 | { 35 | 36 | struct BigGreenCat 37 | { 38 | static constexpr auto FRAMES_TO_WAIT = 10; 39 | 40 | void update( 41 | GlobalDependencies& dependencies, 42 | GlobalState& state, 43 | bool isOnScreen, 44 | entityx::Entity entity); 45 | 46 | int mWaitFramesRemaining = FRAMES_TO_WAIT; 47 | int mAnimationStep = 0; 48 | }; 49 | 50 | } // namespace rigel::game_logic::behaviors 51 | -------------------------------------------------------------------------------- /src/game_logic/enemies/boss_episode_3.hpp: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2019, Nikolai Wuttke. All rights reserved. 2 | * 3 | * This program is free software: you can redistribute it and/or modify 4 | * it under the terms of the GNU General Public License as published by 5 | * the Free Software Foundation, either version 2 of the License, or 6 | * (at your option) any later version. 7 | * 8 | * This program is distributed in the hope that it will be useful, 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | * GNU General Public License for more details. 12 | * 13 | * You should have received a copy of the GNU General Public License 14 | * along with this program. If not, see . 15 | */ 16 | 17 | #pragma once 18 | 19 | #include "base/spatial_types.hpp" 20 | #include "base/warnings.hpp" 21 | 22 | RIGEL_DISABLE_WARNINGS 23 | #include 24 | RIGEL_RESTORE_WARNINGS 25 | 26 | 27 | namespace rigel::game_logic 28 | { 29 | struct GlobalDependencies; 30 | struct GlobalState; 31 | } // namespace rigel::game_logic 32 | 33 | 34 | namespace rigel::game_logic::behaviors 35 | { 36 | 37 | struct BossEpisode3 38 | { 39 | void update( 40 | GlobalDependencies& dependencies, 41 | GlobalState& state, 42 | bool isOnScreen, 43 | entityx::Entity entity); 44 | 45 | void onKilled( 46 | GlobalDependencies&, 47 | GlobalState&, 48 | const base::Vec2f&, 49 | entityx::Entity entity); 50 | 51 | bool mHasBeenSighted = false; 52 | }; 53 | 54 | } // namespace rigel::game_logic::behaviors 55 | -------------------------------------------------------------------------------- /src/game_logic/enemies/ceiling_sucker.hpp: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2018, Nikolai Wuttke. All rights reserved. 2 | * 3 | * This program is free software: you can redistribute it and/or modify 4 | * it under the terms of the GNU General Public License as published by 5 | * the Free Software Foundation, either version 2 of the License, or 6 | * (at your option) any later version. 7 | * 8 | * This program is distributed in the hope that it will be useful, 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | * GNU General Public License for more details. 12 | * 13 | * You should have received a copy of the GNU General Public License 14 | * along with this program. If not, see . 15 | */ 16 | 17 | #pragma once 18 | 19 | #include "game_logic/global_dependencies.hpp" 20 | 21 | #include 22 | 23 | 24 | namespace rigel::game_logic 25 | { 26 | 27 | namespace behaviors 28 | { 29 | 30 | struct CeilingSucker 31 | { 32 | struct Ready 33 | { 34 | }; 35 | 36 | 37 | struct Grabbing 38 | { 39 | int mFramesElapsed = 0; 40 | }; 41 | 42 | 43 | struct HoldingPlayer 44 | { 45 | int mFramesElapsed = 0; 46 | }; 47 | 48 | 49 | struct Waiting 50 | { 51 | int mFramesElapsed = 0; 52 | }; 53 | 54 | 55 | using State = std::variant; 56 | 57 | void update( 58 | GlobalDependencies& dependencies, 59 | GlobalState& state, 60 | bool isOnScreen, 61 | entityx::Entity entity); 62 | void onKilled( 63 | GlobalDependencies& dependencies, 64 | GlobalState& state, 65 | const base::Vec2f& inflictorVelocity, 66 | entityx::Entity entity); 67 | 68 | State mState; 69 | }; 70 | 71 | } // namespace behaviors 72 | } // namespace rigel::game_logic 73 | -------------------------------------------------------------------------------- /src/game_logic/enemies/dying_boss.hpp: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2019, Nikolai Wuttke. All rights reserved. 2 | * 3 | * This program is free software: you can redistribute it and/or modify 4 | * it under the terms of the GNU General Public License as published by 5 | * the Free Software Foundation, either version 2 of the License, or 6 | * (at your option) any later version. 7 | * 8 | * This program is distributed in the hope that it will be useful, 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | * GNU General Public License for more details. 12 | * 13 | * You should have received a copy of the GNU General Public License 14 | * along with this program. If not, see . 15 | */ 16 | 17 | #pragma once 18 | 19 | #include "base/warnings.hpp" 20 | 21 | RIGEL_DISABLE_WARNINGS 22 | #include 23 | RIGEL_RESTORE_WARNINGS 24 | 25 | 26 | namespace rigel::game_logic 27 | { 28 | struct GlobalDependencies; 29 | struct GlobalState; 30 | } // namespace rigel::game_logic 31 | 32 | 33 | namespace rigel::game_logic::behaviors 34 | { 35 | 36 | struct DyingBoss 37 | { 38 | explicit DyingBoss(int episodeNr); 39 | 40 | void update( 41 | GlobalDependencies& dependencies, 42 | GlobalState& state, 43 | bool isOnScreen, 44 | entityx::Entity entity); 45 | 46 | int mFramesElapsed = 0; 47 | bool mShowSpriteDuringFlyAway; 48 | }; 49 | 50 | } // namespace rigel::game_logic::behaviors 51 | -------------------------------------------------------------------------------- /src/game_logic/enemies/enemy_rocket.hpp: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2020, Nikolai Wuttke. All rights reserved. 2 | * 3 | * This program is free software: you can redistribute it and/or modify 4 | * it under the terms of the GNU General Public License as published by 5 | * the Free Software Foundation, either version 2 of the License, or 6 | * (at your option) any later version. 7 | * 8 | * This program is distributed in the hope that it will be useful, 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | * GNU General Public License for more details. 12 | * 13 | * You should have received a copy of the GNU General Public License 14 | * along with this program. If not, see . 15 | */ 16 | 17 | #pragma once 18 | 19 | #include "base/spatial_types.hpp" 20 | #include "base/warnings.hpp" 21 | 22 | RIGEL_DISABLE_WARNINGS 23 | #include 24 | RIGEL_RESTORE_WARNINGS 25 | 26 | 27 | namespace rigel::game_logic 28 | { 29 | struct GlobalDependencies; 30 | struct GlobalState; 31 | } // namespace rigel::game_logic 32 | 33 | 34 | namespace rigel::game_logic::behaviors 35 | { 36 | 37 | struct EnemyRocket 38 | { 39 | explicit EnemyRocket(const base::Vec2& direction) 40 | : mDirection(direction) 41 | { 42 | } 43 | 44 | void update( 45 | GlobalDependencies& dependencies, 46 | GlobalState& state, 47 | bool isOnScreen, 48 | entityx::Entity entity); 49 | 50 | base::Vec2 mDirection; 51 | int mFramesElapsed = 0; 52 | }; 53 | 54 | } // namespace rigel::game_logic::behaviors 55 | -------------------------------------------------------------------------------- /src/game_logic/enemies/eyeball_thrower.hpp: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2019, Nikolai Wuttke. All rights reserved. 2 | * 3 | * This program is free software: you can redistribute it and/or modify 4 | * it under the terms of the GNU General Public License as published by 5 | * the Free Software Foundation, either version 2 of the License, or 6 | * (at your option) any later version. 7 | * 8 | * This program is distributed in the hope that it will be useful, 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | * GNU General Public License for more details. 12 | * 13 | * You should have received a copy of the GNU General Public License 14 | * along with this program. If not, see . 15 | */ 16 | 17 | #pragma once 18 | 19 | #include "game_logic/global_dependencies.hpp" 20 | 21 | #include 22 | 23 | 24 | namespace rigel::game_logic::behaviors 25 | { 26 | 27 | struct EyeballThrower 28 | { 29 | struct GettingUp 30 | { 31 | int mFramesElapsed = 0; 32 | }; 33 | 34 | struct Walking 35 | { 36 | }; 37 | 38 | struct Attacking 39 | { 40 | int mFramesElapsed = 0; 41 | }; 42 | 43 | using State = std::variant; 44 | 45 | void update( 46 | GlobalDependencies& dependencies, 47 | GlobalState& state, 48 | bool isOnScreen, 49 | entityx::Entity entity); 50 | 51 | State mState = GettingUp(); 52 | 53 | // This stays persistent across state changes, therefore it's stored outside 54 | // of the state machine. 55 | int mFramesElapsedInWalkingState = 0; 56 | }; 57 | 58 | } // namespace rigel::game_logic::behaviors 59 | -------------------------------------------------------------------------------- /src/game_logic/enemies/flame_thrower_bot.hpp: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2019, Nikolai Wuttke. All rights reserved. 2 | * 3 | * This program is free software: you can redistribute it and/or modify 4 | * it under the terms of the GNU General Public License as published by 5 | * the Free Software Foundation, either version 2 of the License, or 6 | * (at your option) any later version. 7 | * 8 | * This program is distributed in the hope that it will be useful, 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | * GNU General Public License for more details. 12 | * 13 | * You should have received a copy of the GNU General Public License 14 | * along with this program. If not, see . 15 | */ 16 | 17 | #pragma once 18 | 19 | #include "base/warnings.hpp" 20 | 21 | RIGEL_DISABLE_WARNINGS 22 | #include 23 | RIGEL_RESTORE_WARNINGS 24 | 25 | 26 | namespace rigel::game_logic 27 | { 28 | struct GlobalDependencies; 29 | struct GlobalState; 30 | } // namespace rigel::game_logic 31 | 32 | 33 | namespace rigel::game_logic::behaviors 34 | { 35 | 36 | struct FlameThrowerBot 37 | { 38 | enum class MovementDirection 39 | { 40 | Up, 41 | Down 42 | }; 43 | 44 | void update( 45 | GlobalDependencies& dependencies, 46 | GlobalState& state, 47 | bool isOnScreen, 48 | entityx::Entity entity); 49 | 50 | int mFramesRemainingForFiring = 0; 51 | MovementDirection mMovementDirection = MovementDirection::Down; 52 | }; 53 | 54 | } // namespace rigel::game_logic::behaviors 55 | -------------------------------------------------------------------------------- /src/game_logic/enemies/floating_laser_bot.hpp: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2019, Nikolai Wuttke. All rights reserved. 2 | * 3 | * This program is free software: you can redistribute it and/or modify 4 | * it under the terms of the GNU General Public License as published by 5 | * the Free Software Foundation, either version 2 of the License, or 6 | * (at your option) any later version. 7 | * 8 | * This program is distributed in the hope that it will be useful, 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | * GNU General Public License for more details. 12 | * 13 | * You should have received a copy of the GNU General Public License 14 | * along with this program. If not, see . 15 | */ 16 | 17 | #pragma once 18 | 19 | #include "game_logic/global_dependencies.hpp" 20 | 21 | #include 22 | 23 | 24 | namespace rigel::game_logic::behaviors 25 | { 26 | 27 | struct FloatingLaserBot 28 | { 29 | struct Waiting 30 | { 31 | int mFramesElapsed = 0; 32 | }; 33 | 34 | 35 | struct Active 36 | { 37 | int mFramesElapsed = 0; 38 | }; 39 | 40 | using State = std::variant; 41 | 42 | void update( 43 | GlobalDependencies& dependencies, 44 | GlobalState& state, 45 | bool isOnScreen, 46 | entityx::Entity entity); 47 | 48 | State mState = Waiting(); 49 | }; 50 | 51 | } // namespace rigel::game_logic::behaviors 52 | -------------------------------------------------------------------------------- /src/game_logic/enemies/grabber_claw.hpp: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2019, Nikolai Wuttke. All rights reserved. 2 | * 3 | * This program is free software: you can redistribute it and/or modify 4 | * it under the terms of the GNU General Public License as published by 5 | * the Free Software Foundation, either version 2 of the License, or 6 | * (at your option) any later version. 7 | * 8 | * This program is distributed in the hope that it will be useful, 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | * GNU General Public License for more details. 12 | * 13 | * You should have received a copy of the GNU General Public License 14 | * along with this program. If not, see . 15 | */ 16 | 17 | #pragma once 18 | 19 | #include "base/warnings.hpp" 20 | #include "engine/base_components.hpp" 21 | 22 | RIGEL_DISABLE_WARNINGS 23 | #include 24 | RIGEL_RESTORE_WARNINGS 25 | 26 | #include 27 | 28 | 29 | namespace rigel::game_logic 30 | { 31 | struct GlobalDependencies; 32 | struct GlobalState; 33 | } // namespace rigel::game_logic 34 | 35 | 36 | namespace rigel::game_logic::behaviors 37 | { 38 | 39 | struct GrabberClaw 40 | { 41 | struct Extending 42 | { 43 | }; 44 | 45 | struct Grabbing 46 | { 47 | int mFramesElapsed = 0; 48 | }; 49 | 50 | struct Retracting 51 | { 52 | }; 53 | 54 | struct Waiting 55 | { 56 | int mFramesElapsed = 0; 57 | }; 58 | 59 | using State = std::variant; 60 | 61 | void update( 62 | GlobalDependencies& dependencies, 63 | GlobalState& state, 64 | bool isOnScreen, 65 | entityx::Entity entity); 66 | 67 | State mState; 68 | int mExtensionStep = 0; 69 | }; 70 | 71 | } // namespace rigel::game_logic::behaviors 72 | -------------------------------------------------------------------------------- /src/game_logic/enemies/green_bird.hpp: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2019, Nikolai Wuttke. All rights reserved. 2 | * 3 | * This program is free software: you can redistribute it and/or modify 4 | * it under the terms of the GNU General Public License as published by 5 | * the Free Software Foundation, either version 2 of the License, or 6 | * (at your option) any later version. 7 | * 8 | * This program is distributed in the hope that it will be useful, 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | * GNU General Public License for more details. 12 | * 13 | * You should have received a copy of the GNU General Public License 14 | * along with this program. If not, see . 15 | */ 16 | 17 | #pragma once 18 | 19 | #include "base/warnings.hpp" 20 | 21 | RIGEL_DISABLE_WARNINGS 22 | #include 23 | RIGEL_RESTORE_WARNINGS 24 | 25 | 26 | namespace rigel::game_logic 27 | { 28 | struct GlobalDependencies; 29 | struct GlobalState; 30 | } // namespace rigel::game_logic 31 | 32 | 33 | namespace rigel::game_logic::behaviors 34 | { 35 | 36 | struct GreenBird 37 | { 38 | void update( 39 | GlobalDependencies& dependencies, 40 | GlobalState& state, 41 | bool isOnScreen, 42 | entityx::Entity entity); 43 | }; 44 | 45 | } // namespace rigel::game_logic::behaviors 46 | -------------------------------------------------------------------------------- /src/game_logic/enemies/laser_turret.hpp: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2016, Nikolai Wuttke. All rights reserved. 2 | * 3 | * This program is free software: you can redistribute it and/or modify 4 | * it under the terms of the GNU General Public License as published by 5 | * the Free Software Foundation, either version 2 of the License, or 6 | * (at your option) any later version. 7 | * 8 | * This program is distributed in the hope that it will be useful, 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | * GNU General Public License for more details. 12 | * 13 | * You should have received a copy of the GNU General Public License 14 | * along with this program. If not, see . 15 | */ 16 | 17 | #pragma once 18 | 19 | #include "base/warnings.hpp" 20 | #include "engine/base_components.hpp" 21 | 22 | RIGEL_DISABLE_WARNINGS 23 | #include 24 | RIGEL_RESTORE_WARNINGS 25 | 26 | 27 | namespace rigel::game_logic 28 | { 29 | struct GlobalDependencies; 30 | struct GlobalState; 31 | } // namespace rigel::game_logic 32 | 33 | 34 | namespace rigel::game_logic::behaviors 35 | { 36 | 37 | struct LaserTurret 38 | { 39 | void update( 40 | GlobalDependencies& dependencies, 41 | GlobalState& state, 42 | bool isOnScreen, 43 | entityx::Entity entity); 44 | 45 | void onHit( 46 | GlobalDependencies& dependencies, 47 | GlobalState& state, 48 | entityx::Entity inflictorEntity, 49 | entityx::Entity entity); 50 | 51 | void onKilled( 52 | GlobalDependencies& dependencies, 53 | GlobalState& state, 54 | const base::Vec2f& inflictorVelocity, 55 | entityx::Entity entity); 56 | 57 | int mAngle = 0; 58 | int mSpinningTurnsLeft = 20; 59 | int mNextShotCountdown = 0; 60 | }; 61 | 62 | } // namespace rigel::game_logic::behaviors 63 | -------------------------------------------------------------------------------- /src/game_logic/enemies/prisoner.hpp: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2016, Nikolai Wuttke. All rights reserved. 2 | * 3 | * This program is free software: you can redistribute it and/or modify 4 | * it under the terms of the GNU General Public License as published by 5 | * the Free Software Foundation, either version 2 of the License, or 6 | * (at your option) any later version. 7 | * 8 | * This program is distributed in the hope that it will be useful, 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | * GNU General Public License for more details. 12 | * 13 | * You should have received a copy of the GNU General Public License 14 | * along with this program. If not, see . 15 | */ 16 | 17 | #pragma once 18 | 19 | #include "base/warnings.hpp" 20 | #include "engine/base_components.hpp" 21 | 22 | RIGEL_DISABLE_WARNINGS 23 | #include 24 | RIGEL_RESTORE_WARNINGS 25 | 26 | 27 | namespace rigel::game_logic 28 | { 29 | struct GlobalDependencies; 30 | struct GlobalState; 31 | } // namespace rigel::game_logic 32 | 33 | 34 | namespace rigel::game_logic::behaviors 35 | { 36 | 37 | struct AggressivePrisoner 38 | { 39 | void update( 40 | GlobalDependencies& dependencies, 41 | GlobalState& state, 42 | bool isOnScreen, 43 | entityx::Entity entity); 44 | 45 | void onKilled( 46 | GlobalDependencies& dependencies, 47 | GlobalState& state, 48 | const base::Vec2f& inflictorVelocity, 49 | entityx::Entity entity); 50 | 51 | int mGrabStep = 0; 52 | bool mIsGrabbing = false; 53 | }; 54 | 55 | 56 | struct PassivePrisoner 57 | { 58 | void update( 59 | GlobalDependencies& dependencies, 60 | GlobalState& state, 61 | bool isOnScreen, 62 | entityx::Entity entity); 63 | }; 64 | 65 | } // namespace rigel::game_logic::behaviors 66 | -------------------------------------------------------------------------------- /src/game_logic/enemies/rocket_turret.hpp: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2016, Nikolai Wuttke. All rights reserved. 2 | * 3 | * This program is free software: you can redistribute it and/or modify 4 | * it under the terms of the GNU General Public License as published by 5 | * the Free Software Foundation, either version 2 of the License, or 6 | * (at your option) any later version. 7 | * 8 | * This program is distributed in the hope that it will be useful, 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | * GNU General Public License for more details. 12 | * 13 | * You should have received a copy of the GNU General Public License 14 | * along with this program. If not, see . 15 | */ 16 | 17 | #pragma once 18 | 19 | #include "base/warnings.hpp" 20 | #include "engine/base_components.hpp" 21 | 22 | RIGEL_DISABLE_WARNINGS 23 | #include 24 | RIGEL_RESTORE_WARNINGS 25 | 26 | 27 | namespace rigel::game_logic 28 | { 29 | struct GlobalDependencies; 30 | struct GlobalState; 31 | } // namespace rigel::game_logic 32 | 33 | 34 | namespace rigel::game_logic::behaviors 35 | { 36 | 37 | struct RocketTurret 38 | { 39 | void update( 40 | GlobalDependencies& dependencies, 41 | GlobalState& state, 42 | bool isOnScreen, 43 | entityx::Entity entity); 44 | 45 | enum class Orientation 46 | { 47 | Left = 0, 48 | Top = 1, 49 | Right = 2 50 | }; 51 | 52 | Orientation mOrientation = Orientation::Left; 53 | bool mNeedsReorientation = true; 54 | int mNextShotCountdown = 0; 55 | }; 56 | 57 | } // namespace rigel::game_logic::behaviors 58 | -------------------------------------------------------------------------------- /src/game_logic/enemies/security_camera.hpp: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2016, Nikolai Wuttke. All rights reserved. 2 | * 3 | * This program is free software: you can redistribute it and/or modify 4 | * it under the terms of the GNU General Public License as published by 5 | * the Free Software Foundation, either version 2 of the License, or 6 | * (at your option) any later version. 7 | * 8 | * This program is distributed in the hope that it will be useful, 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | * GNU General Public License for more details. 12 | * 13 | * You should have received a copy of the GNU General Public License 14 | * along with this program. If not, see . 15 | */ 16 | 17 | #pragma once 18 | 19 | #include "game_logic/global_dependencies.hpp" 20 | 21 | 22 | namespace rigel::game_logic::behaviors 23 | { 24 | 25 | struct SecurityCamera 26 | { 27 | void update( 28 | GlobalDependencies& dependencies, 29 | GlobalState& state, 30 | bool isOnScreen, 31 | entityx::Entity entity); 32 | }; 33 | 34 | } // namespace rigel::game_logic::behaviors 35 | -------------------------------------------------------------------------------- /src/game_logic/enemies/simple_walker.hpp: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2016, Nikolai Wuttke. All rights reserved. 2 | * 3 | * This program is free software: you can redistribute it and/or modify 4 | * it under the terms of the GNU General Public License as published by 5 | * the Free Software Foundation, either version 2 of the License, or 6 | * (at your option) any later version. 7 | * 8 | * This program is distributed in the hope that it will be useful, 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | * GNU General Public License for more details. 12 | * 13 | * You should have received a copy of the GNU General Public License 14 | * along with this program. If not, see . 15 | */ 16 | 17 | #pragma once 18 | 19 | #include "base/warnings.hpp" 20 | 21 | RIGEL_DISABLE_WARNINGS 22 | #include 23 | RIGEL_RESTORE_WARNINGS 24 | 25 | 26 | namespace rigel::game_logic 27 | { 28 | struct GlobalDependencies; 29 | struct GlobalState; 30 | } // namespace rigel::game_logic 31 | 32 | 33 | namespace rigel::game_logic::behaviors 34 | { 35 | 36 | struct SimpleWalker 37 | { 38 | struct Configuration 39 | { 40 | int mAnimStart = 0; 41 | int mAnimEnd = 0; 42 | bool mWalkAtFullSpeed = false; 43 | bool mWalkOnCeiling = false; 44 | }; 45 | 46 | explicit SimpleWalker(const Configuration* pConfig) 47 | : mpConfig(pConfig) 48 | { 49 | } 50 | 51 | void update( 52 | GlobalDependencies& dependencies, 53 | GlobalState& state, 54 | bool isOnScreen, 55 | entityx::Entity entity); 56 | 57 | const Configuration* mpConfig; 58 | }; 59 | 60 | } // namespace rigel::game_logic::behaviors 61 | -------------------------------------------------------------------------------- /src/game_logic/enemies/small_flying_ship.hpp: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2019, Nikolai Wuttke. All rights reserved. 2 | * 3 | * This program is free software: you can redistribute it and/or modify 4 | * it under the terms of the GNU General Public License as published by 5 | * the Free Software Foundation, either version 2 of the License, or 6 | * (at your option) any later version. 7 | * 8 | * This program is distributed in the hope that it will be useful, 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | * GNU General Public License for more details. 12 | * 13 | * You should have received a copy of the GNU General Public License 14 | * along with this program. If not, see . 15 | */ 16 | 17 | #pragma once 18 | 19 | #include "base/warnings.hpp" 20 | 21 | RIGEL_DISABLE_WARNINGS 22 | #include 23 | RIGEL_RESTORE_WARNINGS 24 | 25 | #include 26 | 27 | 28 | namespace rigel::game_logic 29 | { 30 | struct GlobalDependencies; 31 | struct GlobalState; 32 | } // namespace rigel::game_logic 33 | 34 | 35 | namespace rigel::game_logic::behaviors 36 | { 37 | 38 | struct SmallFlyingShip 39 | { 40 | void update( 41 | GlobalDependencies& dependencies, 42 | GlobalState& state, 43 | bool isOnScreen, 44 | entityx::Entity entity); 45 | 46 | std::optional mInitialHeight; 47 | }; 48 | 49 | } // namespace rigel::game_logic::behaviors 50 | -------------------------------------------------------------------------------- /src/game_logic/enemies/snake.hpp: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2019, Nikolai Wuttke. All rights reserved. 2 | * 3 | * This program is free software: you can redistribute it and/or modify 4 | * it under the terms of the GNU General Public License as published by 5 | * the Free Software Foundation, either version 2 of the License, or 6 | * (at your option) any later version. 7 | * 8 | * This program is distributed in the hope that it will be useful, 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | * GNU General Public License for more details. 12 | * 13 | * You should have received a copy of the GNU General Public License 14 | * along with this program. If not, see . 15 | */ 16 | 17 | #pragma once 18 | 19 | #include "game_logic/global_dependencies.hpp" 20 | 21 | #include 22 | 23 | 24 | namespace rigel::game_logic 25 | { 26 | 27 | namespace behaviors 28 | { 29 | 30 | struct Snake 31 | { 32 | struct Walking 33 | { 34 | }; 35 | 36 | struct GrabbingPlayer 37 | { 38 | int mFramesElapsed = 0; 39 | }; 40 | 41 | struct SwallowedPlayer 42 | { 43 | }; 44 | 45 | 46 | using State = std::variant; 47 | 48 | void update( 49 | GlobalDependencies& dependencies, 50 | GlobalState& state, 51 | bool isOnScreen, 52 | entityx::Entity entity); 53 | void onKilled( 54 | GlobalDependencies& dependencies, 55 | GlobalState& state, 56 | const base::Vec2f& inflictorVelocity, 57 | entityx::Entity entity); 58 | 59 | State mState; 60 | }; 61 | 62 | } // namespace behaviors 63 | } // namespace rigel::game_logic 64 | -------------------------------------------------------------------------------- /src/game_logic/enemies/unicycle_bot.hpp: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2019, Nikolai Wuttke. All rights reserved. 2 | * 3 | * This program is free software: you can redistribute it and/or modify 4 | * it under the terms of the GNU General Public License as published by 5 | * the Free Software Foundation, either version 2 of the License, or 6 | * (at your option) any later version. 7 | * 8 | * This program is distributed in the hope that it will be useful, 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | * GNU General Public License for more details. 12 | * 13 | * You should have received a copy of the GNU General Public License 14 | * along with this program. If not, see . 15 | */ 16 | 17 | #pragma once 18 | 19 | #include "base/warnings.hpp" 20 | 21 | RIGEL_DISABLE_WARNINGS 22 | #include 23 | RIGEL_RESTORE_WARNINGS 24 | 25 | #include 26 | 27 | 28 | namespace rigel::game_logic 29 | { 30 | struct GlobalDependencies; 31 | struct GlobalState; 32 | } // namespace rigel::game_logic 33 | 34 | 35 | namespace rigel::game_logic::behaviors 36 | { 37 | 38 | struct UnicycleBot 39 | { 40 | struct Waiting 41 | { 42 | int mFramesElapsed = 0; 43 | }; 44 | 45 | struct Accelerating 46 | { 47 | int mFramesElapsed = 0; 48 | }; 49 | 50 | struct Moving 51 | { 52 | }; 53 | 54 | using State = std::variant; 55 | 56 | void update( 57 | GlobalDependencies& dependencies, 58 | GlobalState& state, 59 | bool isOnScreen, 60 | entityx::Entity entity); 61 | 62 | State mState = Waiting{}; 63 | int mFramesUntilNextTurn = 0; 64 | }; 65 | 66 | } // namespace rigel::game_logic::behaviors 67 | -------------------------------------------------------------------------------- /src/game_logic/enemies/wall_walker.hpp: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2019, Nikolai Wuttke. All rights reserved. 2 | * 3 | * This program is free software: you can redistribute it and/or modify 4 | * it under the terms of the GNU General Public License as published by 5 | * the Free Software Foundation, either version 2 of the License, or 6 | * (at your option) any later version. 7 | * 8 | * This program is distributed in the hope that it will be useful, 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | * GNU General Public License for more details. 12 | * 13 | * You should have received a copy of the GNU General Public License 14 | * along with this program. If not, see . 15 | */ 16 | 17 | #pragma once 18 | 19 | #include "base/warnings.hpp" 20 | 21 | RIGEL_DISABLE_WARNINGS 22 | #include 23 | RIGEL_RESTORE_WARNINGS 24 | 25 | namespace rigel::engine 26 | { 27 | class RandomNumberGenerator; 28 | } 29 | namespace rigel::game_logic 30 | { 31 | struct GlobalDependencies; 32 | struct GlobalState; 33 | } // namespace rigel::game_logic 34 | 35 | 36 | namespace rigel::game_logic::behaviors 37 | { 38 | 39 | struct WallWalker 40 | { 41 | enum class Direction 42 | { 43 | Up, 44 | Down, 45 | Left, 46 | Right 47 | }; 48 | 49 | explicit WallWalker(engine::RandomNumberGenerator& rng); 50 | 51 | void update( 52 | GlobalDependencies& dependencies, 53 | GlobalState& state, 54 | bool isOnScreen, 55 | entityx::Entity entity); 56 | 57 | Direction mDirection; 58 | int mFramesUntilDirectionSwitch = 20; 59 | int mMovementToggle = 0; 60 | bool mShouldSkipThisFrame = false; 61 | }; 62 | 63 | } // namespace rigel::game_logic::behaviors 64 | -------------------------------------------------------------------------------- /src/game_logic/hazards/lava_fountain.hpp: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2019, Nikolai Wuttke. All rights reserved. 2 | * 3 | * This program is free software: you can redistribute it and/or modify 4 | * it under the terms of the GNU General Public License as published by 5 | * the Free Software Foundation, either version 2 of the License, or 6 | * (at your option) any later version. 7 | * 8 | * This program is distributed in the hope that it will be useful, 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | * GNU General Public License for more details. 12 | * 13 | * You should have received a copy of the GNU General Public License 14 | * along with this program. If not, see . 15 | */ 16 | 17 | #pragma once 18 | 19 | #include "base/spatial_types.hpp" 20 | #include "base/warnings.hpp" 21 | 22 | RIGEL_DISABLE_WARNINGS 23 | #include 24 | RIGEL_RESTORE_WARNINGS 25 | 26 | #include 27 | 28 | namespace rigel::game_logic 29 | { 30 | struct GlobalDependencies; 31 | struct GlobalState; 32 | } // namespace rigel::game_logic 33 | 34 | 35 | namespace rigel::game_logic::behaviors 36 | { 37 | 38 | struct LavaFountain 39 | { 40 | struct Waiting 41 | { 42 | int mFramesElapsed = 0; 43 | }; 44 | 45 | struct Erupting 46 | { 47 | int mSequenceIndex = 0; 48 | }; 49 | 50 | using State = std::variant; 51 | 52 | void update( 53 | GlobalDependencies& dependencies, 54 | GlobalState& state, 55 | bool isOnScreen, 56 | entityx::Entity entity); 57 | 58 | State mState = Waiting{}; 59 | }; 60 | 61 | } // namespace rigel::game_logic::behaviors 62 | -------------------------------------------------------------------------------- /src/game_logic/hazards/slime_pipe.hpp: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2016, Nikolai Wuttke. All rights reserved. 2 | * 3 | * This program is free software: you can redistribute it and/or modify 4 | * it under the terms of the GNU General Public License as published by 5 | * the Free Software Foundation, either version 2 of the License, or 6 | * (at your option) any later version. 7 | * 8 | * This program is distributed in the hope that it will be useful, 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | * GNU General Public License for more details. 12 | * 13 | * You should have received a copy of the GNU General Public License 14 | * along with this program. If not, see . 15 | */ 16 | 17 | #pragma once 18 | 19 | #include "game_logic/global_dependencies.hpp" 20 | 21 | namespace rigel::engine::events 22 | { 23 | struct CollidedWithWorld; 24 | } 25 | 26 | 27 | namespace rigel::game_logic::behaviors 28 | { 29 | 30 | struct SlimePipe 31 | { 32 | int mGameFramesSinceLastDrop = 0; 33 | 34 | void update( 35 | GlobalDependencies& dependencies, 36 | GlobalState& state, 37 | bool isOnScreen, 38 | entityx::Entity entity); 39 | }; 40 | 41 | 42 | struct SlimeDrop 43 | { 44 | void update(GlobalDependencies&, GlobalState&, bool, entityx::Entity) { } 45 | 46 | void onCollision( 47 | GlobalDependencies& dependencies, 48 | GlobalState& state, 49 | const engine::events::CollidedWithWorld& event, 50 | entityx::Entity entity); 51 | }; 52 | 53 | } // namespace rigel::game_logic::behaviors 54 | -------------------------------------------------------------------------------- /src/game_logic/hazards/smash_hammer.hpp: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2019, Nikolai Wuttke. All rights reserved. 2 | * 3 | * This program is free software: you can redistribute it and/or modify 4 | * it under the terms of the GNU General Public License as published by 5 | * the Free Software Foundation, either version 2 of the License, or 6 | * (at your option) any later version. 7 | * 8 | * This program is distributed in the hope that it will be useful, 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | * GNU General Public License for more details. 12 | * 13 | * You should have received a copy of the GNU General Public License 14 | * along with this program. If not, see . 15 | */ 16 | 17 | #pragma once 18 | 19 | #include "game_logic/global_dependencies.hpp" 20 | 21 | #include 22 | 23 | 24 | namespace rigel::game_logic::behaviors 25 | { 26 | 27 | struct SmashHammer 28 | { 29 | struct Waiting 30 | { 31 | int mFramesElapsed = 0; 32 | }; 33 | 34 | struct PushingDown 35 | { 36 | }; 37 | struct PullingUp 38 | { 39 | }; 40 | 41 | using State = std::variant; 42 | 43 | void update( 44 | GlobalDependencies& dependencies, 45 | GlobalState& state, 46 | bool isOnScreen, 47 | entityx::Entity entity); 48 | 49 | State mState = Waiting{10}; 50 | int mExtensionStep = 0; 51 | }; 52 | 53 | } // namespace rigel::game_logic::behaviors 54 | -------------------------------------------------------------------------------- /src/game_logic/interactive/blowing_fan.hpp: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2019, Nikolai Wuttke. All rights reserved. 2 | * 3 | * This program is free software: you can redistribute it and/or modify 4 | * it under the terms of the GNU General Public License as published by 5 | * the Free Software Foundation, either version 2 of the License, or 6 | * (at your option) any later version. 7 | * 8 | * This program is distributed in the hope that it will be useful, 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | * GNU General Public License for more details. 12 | * 13 | * You should have received a copy of the GNU General Public License 14 | * along with this program. If not, see . 15 | */ 16 | 17 | #pragma once 18 | 19 | #include "game_logic/global_dependencies.hpp" 20 | 21 | #include 22 | 23 | 24 | namespace rigel::game_logic::behaviors 25 | { 26 | 27 | struct BlowingFan 28 | { 29 | enum class State : std::uint8_t 30 | { 31 | SpeedingUp, 32 | SlowingDown, 33 | }; 34 | 35 | void update( 36 | GlobalDependencies& dependencies, 37 | GlobalState& state, 38 | bool isOnScreen, 39 | entityx::Entity entity); 40 | 41 | int mStep = 0; 42 | State mState = State::SpeedingUp; 43 | bool mIsPushingPlayer = false; 44 | }; 45 | 46 | } // namespace rigel::game_logic::behaviors 47 | -------------------------------------------------------------------------------- /src/game_logic/interactive/elevator.hpp: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2016, Nikolai Wuttke. All rights reserved. 2 | * 3 | * This program is free software: you can redistribute it and/or modify 4 | * it under the terms of the GNU General Public License as published by 5 | * the Free Software Foundation, either version 2 of the License, or 6 | * (at your option) any later version. 7 | * 8 | * This program is distributed in the hope that it will be useful, 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | * GNU General Public License for more details. 12 | * 13 | * You should have received a copy of the GNU General Public License 14 | * along with this program. If not, see . 15 | */ 16 | 17 | #pragma once 18 | 19 | #include "base/warnings.hpp" 20 | #include "engine/base_components.hpp" 21 | 22 | RIGEL_DISABLE_WARNINGS 23 | #include 24 | RIGEL_RESTORE_WARNINGS 25 | 26 | #include 27 | 28 | 29 | namespace rigel::game_logic 30 | { 31 | struct GlobalDependencies; 32 | struct GlobalState; 33 | } // namespace rigel::game_logic 34 | 35 | 36 | namespace rigel::game_logic::behaviors 37 | { 38 | 39 | struct Elevator 40 | { 41 | void update( 42 | GlobalDependencies& dependencies, 43 | GlobalState& state, 44 | bool isOnScreen, 45 | entityx::Entity entity); 46 | 47 | struct State 48 | { 49 | int mPreviousPosY = 0; 50 | }; 51 | 52 | // Only present while player is attached 53 | std::optional mState; 54 | }; 55 | 56 | } // namespace rigel::game_logic::behaviors 57 | -------------------------------------------------------------------------------- /src/game_logic/interactive/force_field.hpp: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2016, Nikolai Wuttke. All rights reserved. 2 | * 3 | * This program is free software: you can redistribute it and/or modify 4 | * it under the terms of the GNU General Public License as published by 5 | * the Free Software Foundation, either version 2 of the License, or 6 | * (at your option) any later version. 7 | * 8 | * This program is distributed in the hope that it will be useful, 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | * GNU General Public License for more details. 12 | * 13 | * You should have received a copy of the GNU General Public License 14 | * along with this program. If not, see . 15 | */ 16 | 17 | #pragma once 18 | 19 | #include "base/warnings.hpp" 20 | #include "engine/base_components.hpp" 21 | 22 | RIGEL_DISABLE_WARNINGS 23 | #include 24 | RIGEL_RESTORE_WARNINGS 25 | 26 | namespace rigel::game_logic 27 | { 28 | struct GlobalDependencies; 29 | struct GlobalState; 30 | } // namespace rigel::game_logic 31 | 32 | 33 | namespace rigel::game_logic::interaction 34 | { 35 | 36 | void configureForceField(entityx::Entity entity, int spawnIndex); 37 | void configureKeyCardSlot( 38 | entityx::Entity entity, 39 | const engine::components::BoundingBox& boundingBox); 40 | void disableKeyCardSlot(entityx::Entity entity); 41 | 42 | void disableNextForceField(entityx::EntityManager& es); 43 | 44 | } // namespace rigel::game_logic::interaction 45 | 46 | 47 | namespace rigel::game_logic::behaviors 48 | { 49 | 50 | struct ForceField 51 | { 52 | void update( 53 | GlobalDependencies& dependencies, 54 | GlobalState& state, 55 | bool isOnScreen, 56 | entityx::Entity entity); 57 | }; 58 | 59 | } // namespace rigel::game_logic::behaviors 60 | -------------------------------------------------------------------------------- /src/game_logic/interactive/locked_door.hpp: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2018, Nikolai Wuttke. All rights reserved. 2 | * 3 | * This program is free software: you can redistribute it and/or modify 4 | * it under the terms of the GNU General Public License as published by 5 | * the Free Software Foundation, either version 2 of the License, or 6 | * (at your option) any later version. 7 | * 8 | * This program is distributed in the hope that it will be useful, 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | * GNU General Public License for more details. 12 | * 13 | * You should have received a copy of the GNU General Public License 14 | * along with this program. If not, see . 15 | */ 16 | 17 | #pragma once 18 | 19 | #include "base/warnings.hpp" 20 | #include "engine/base_components.hpp" 21 | 22 | RIGEL_DISABLE_WARNINGS 23 | #include 24 | RIGEL_RESTORE_WARNINGS 25 | 26 | 27 | namespace rigel::game_logic::interaction 28 | { 29 | 30 | void configureLockedDoor( 31 | entityx::Entity entity, 32 | int spawnIndex, 33 | const engine::components::BoundingBox& boundingBox); 34 | void configureKeyHole( 35 | entityx::Entity entity, 36 | const engine::components::BoundingBox& boundingBox); 37 | void disableKeyHole(entityx::Entity entity); 38 | 39 | } // namespace rigel::game_logic::interaction 40 | -------------------------------------------------------------------------------- /src/game_logic/interactive/respawn_checkpoint.hpp: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2017, Nikolai Wuttke. All rights reserved. 2 | * 3 | * This program is free software: you can redistribute it and/or modify 4 | * it under the terms of the GNU General Public License as published by 5 | * the Free Software Foundation, either version 2 of the License, or 6 | * (at your option) any later version. 7 | * 8 | * This program is distributed in the hope that it will be useful, 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | * GNU General Public License for more details. 12 | * 13 | * You should have received a copy of the GNU General Public License 14 | * along with this program. If not, see . 15 | */ 16 | 17 | #pragma once 18 | 19 | #include "game_logic/global_dependencies.hpp" 20 | 21 | #include 22 | 23 | 24 | namespace rigel::game_logic::interaction 25 | { 26 | 27 | struct RespawnCheckpoint 28 | { 29 | void update( 30 | GlobalDependencies& dependencies, 31 | GlobalState& state, 32 | bool isOnScreen, 33 | entityx::Entity entity); 34 | 35 | bool mInitialized = false; 36 | std::optional mActivationCountdown; 37 | }; 38 | 39 | } // namespace rigel::game_logic::interaction 40 | -------------------------------------------------------------------------------- /src/game_logic/interactive/super_force_field.hpp: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2019, Nikolai Wuttke. All rights reserved. 2 | * 3 | * This program is free software: you can redistribute it and/or modify 4 | * it under the terms of the GNU General Public License as published by 5 | * the Free Software Foundation, either version 2 of the License, or 6 | * (at your option) any later version. 7 | * 8 | * This program is distributed in the hope that it will be useful, 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | * GNU General Public License for more details. 12 | * 13 | * You should have received a copy of the GNU General Public License 14 | * along with this program. If not, see . 15 | */ 16 | 17 | #pragma once 18 | 19 | #include "game_logic/global_dependencies.hpp" 20 | 21 | #include 22 | 23 | 24 | namespace rigel::game_logic::behaviors 25 | { 26 | 27 | struct SuperForceField 28 | { 29 | void update( 30 | GlobalDependencies& dependencies, 31 | GlobalState& state, 32 | bool isOnScreen, 33 | entityx::Entity entity); 34 | 35 | void onHit( 36 | GlobalDependencies& dependencies, 37 | GlobalState& state, 38 | entityx::Entity inflictorEntity, 39 | entityx::Entity entity); 40 | 41 | void startFizzle(); 42 | 43 | std::optional mFizzleFramesElapsed; 44 | std::optional mDestructionFramesElapsed; 45 | }; 46 | 47 | } // namespace rigel::game_logic::behaviors 48 | -------------------------------------------------------------------------------- /src/game_logic/interactive/tile_burner.hpp: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2019, Nikolai Wuttke. All rights reserved. 2 | * 3 | * This program is free software: you can redistribute it and/or modify 4 | * it under the terms of the GNU General Public License as published by 5 | * the Free Software Foundation, either version 2 of the License, or 6 | * (at your option) any later version. 7 | * 8 | * This program is distributed in the hope that it will be useful, 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | * GNU General Public License for more details. 12 | * 13 | * You should have received a copy of the GNU General Public License 14 | * along with this program. If not, see . 15 | */ 16 | 17 | #pragma once 18 | 19 | #include "base/spatial_types.hpp" 20 | #include "game_logic/global_dependencies.hpp" 21 | 22 | #include 23 | 24 | 25 | namespace rigel::game_logic::behaviors 26 | { 27 | 28 | struct TileBurner 29 | { 30 | struct NewBurnerInfo 31 | { 32 | base::Vec2 mPosition; 33 | int mFramesToWait; 34 | }; 35 | 36 | void update( 37 | GlobalDependencies& dependencies, 38 | GlobalState& state, 39 | bool isOnScreen, 40 | entityx::Entity entity); 41 | 42 | std::vector mBurnersToSpawn; 43 | int mFramesElapsed = -1; 44 | }; 45 | 46 | } // namespace rigel::game_logic::behaviors 47 | -------------------------------------------------------------------------------- /src/game_logic/player/damage_system.hpp: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2016, Nikolai Wuttke. All rights reserved. 2 | * 3 | * This program is free software: you can redistribute it and/or modify 4 | * it under the terms of the GNU General Public License as published by 5 | * the Free Software Foundation, either version 2 of the License, or 6 | * (at your option) any later version. 7 | * 8 | * This program is distributed in the hope that it will be useful, 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | * GNU General Public License for more details. 12 | * 13 | * You should have received a copy of the GNU General Public License 14 | * along with this program. If not, see . 15 | */ 16 | 17 | #pragma once 18 | 19 | #include "base/warnings.hpp" 20 | 21 | RIGEL_DISABLE_WARNINGS 22 | #include 23 | RIGEL_RESTORE_WARNINGS 24 | 25 | 26 | namespace rigel::game_logic 27 | { 28 | class Player; 29 | } 30 | 31 | 32 | namespace rigel::game_logic::player 33 | { 34 | 35 | class DamageSystem 36 | { 37 | public: 38 | explicit DamageSystem(Player* pPlayer); 39 | 40 | void update(entityx::EntityManager& es); 41 | 42 | private: 43 | Player* mpPlayer; 44 | }; 45 | 46 | } // namespace rigel::game_logic::player 47 | -------------------------------------------------------------------------------- /src/game_logic/player/level_exit_trigger.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2020, Nikolai Wuttke. All rights reserved. 2 | * 3 | * This program is free software: you can redistribute it and/or modify 4 | * it under the terms of the GNU General Public License as published by 5 | * the Free Software Foundation, either version 2 of the License, or 6 | * (at your option) any later version. 7 | * 8 | * This program is distributed in the hope that it will be useful, 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | * GNU General Public License for more details. 12 | * 13 | * You should have received a copy of the GNU General Public License 14 | * along with this program. If not, see . 15 | */ 16 | 17 | #include "level_exit_trigger.hpp" 18 | 19 | #include "game_logic/global_dependencies.hpp" 20 | #include "game_logic/player.hpp" 21 | 22 | 23 | namespace rigel::game_logic::behaviors 24 | { 25 | 26 | void LevelExitTrigger::update( 27 | GlobalDependencies& d, 28 | GlobalState& s, 29 | bool isOnScreen, 30 | entityx::Entity entity) 31 | { 32 | using engine::components::WorldPosition; 33 | 34 | const auto& position = *entity.component(); 35 | const auto& playerBBox = s.mpPlayer->worldSpaceHitBox(); 36 | 37 | // clang-format off 38 | const auto playerAboveOrAtTriggerHeight = 39 | playerBBox.bottom() <= position.y; 40 | const auto touchingTriggerOnXAxis = 41 | position.x >= playerBBox.left() && 42 | position.x <= (playerBBox.right() + 1); 43 | // clang-format on 44 | 45 | if (playerAboveOrAtTriggerHeight && touchingTriggerOnXAxis) 46 | { 47 | d.mpEvents->emit(rigel::events::ExitReached{}); 48 | } 49 | } 50 | 51 | } // namespace rigel::game_logic::behaviors 52 | -------------------------------------------------------------------------------- /src/game_logic/player/level_exit_trigger.hpp: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2020, Nikolai Wuttke. All rights reserved. 2 | * 3 | * This program is free software: you can redistribute it and/or modify 4 | * it under the terms of the GNU General Public License as published by 5 | * the Free Software Foundation, either version 2 of the License, or 6 | * (at your option) any later version. 7 | * 8 | * This program is distributed in the hope that it will be useful, 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | * GNU General Public License for more details. 12 | * 13 | * You should have received a copy of the GNU General Public License 14 | * along with this program. If not, see . 15 | */ 16 | 17 | #pragma once 18 | 19 | #include "base/warnings.hpp" 20 | 21 | RIGEL_DISABLE_WARNINGS 22 | #include 23 | RIGEL_RESTORE_WARNINGS 24 | 25 | 26 | namespace rigel::game_logic 27 | { 28 | struct GlobalDependencies; 29 | struct GlobalState; 30 | } // namespace rigel::game_logic 31 | 32 | 33 | namespace rigel::game_logic::behaviors 34 | { 35 | 36 | struct LevelExitTrigger 37 | { 38 | void update( 39 | GlobalDependencies& dependencies, 40 | GlobalState& state, 41 | bool isOnScreen, 42 | entityx::Entity entity); 43 | }; 44 | 45 | } // namespace rigel::game_logic::behaviors 46 | -------------------------------------------------------------------------------- /src/game_logic/player/ship.hpp: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2019, Nikolai Wuttke. All rights reserved. 2 | * 3 | * This program is free software: you can redistribute it and/or modify 4 | * it under the terms of the GNU General Public License as published by 5 | * the Free Software Foundation, either version 2 of the License, or 6 | * (at your option) any later version. 7 | * 8 | * This program is distributed in the hope that it will be useful, 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | * GNU General Public License for more details. 12 | * 13 | * You should have received a copy of the GNU General Public License 14 | * along with this program. If not, see . 15 | */ 16 | 17 | #pragma once 18 | 19 | #include 20 | 21 | RIGEL_DISABLE_WARNINGS 22 | #include 23 | RIGEL_RESTORE_WARNINGS 24 | 25 | #include 26 | 27 | 28 | namespace rigel::game_logic 29 | { 30 | struct GlobalDependencies; 31 | struct GlobalState; 32 | } // namespace rigel::game_logic 33 | 34 | 35 | namespace rigel::game_logic::behaviors 36 | { 37 | 38 | struct PlayerShip 39 | { 40 | explicit PlayerShip(bool hasJustBeenExited); 41 | 42 | void update( 43 | GlobalDependencies& dependencies, 44 | GlobalState& state, 45 | bool isOnScreen, 46 | entityx::Entity entity); 47 | 48 | int mPickUpCoolDownFrames = 0; 49 | }; 50 | 51 | } // namespace rigel::game_logic::behaviors 52 | -------------------------------------------------------------------------------- /src/game_logic_classic/types.h: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2022, Nikolai Wuttke. All rights reserved. 2 | * 3 | * This program is free software: you can redistribute it and/or modify 4 | * it under the terms of the GNU General Public License as published by 5 | * the Free Software Foundation, either version 2 of the License, or 6 | * (at your option) any later version. 7 | * 8 | * This program is distributed in the hope that it will be useful, 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | * GNU General Public License for more details. 12 | * 13 | * You should have received a copy of the GNU General Public License 14 | * along with this program. If not, see . 15 | */ 16 | 17 | #pragma once 18 | 19 | #include 20 | #include 21 | 22 | typedef uint8_t byte; 23 | typedef uint16_t word; 24 | typedef uint32_t dword; 25 | typedef int16_t ibool; 26 | typedef int8_t sbyte; 27 | -------------------------------------------------------------------------------- /src/game_logic_common/input.hpp: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2018, Nikolai Wuttke. All rights reserved. 2 | * 3 | * This program is free software: you can redistribute it and/or modify 4 | * it under the terms of the GNU General Public License as published by 5 | * the Free Software Foundation, either version 2 of the License, or 6 | * (at your option) any later version. 7 | * 8 | * This program is distributed in the hope that it will be useful, 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | * GNU General Public License for more details. 12 | * 13 | * You should have received a copy of the GNU General Public License 14 | * along with this program. If not, see . 15 | */ 16 | 17 | #pragma once 18 | 19 | 20 | namespace rigel::game_logic 21 | { 22 | 23 | struct Button 24 | { 25 | /** True if the button is currently pressed (down) */ 26 | bool mIsPressed = false; 27 | 28 | /** True if there was at least one button-down event since the last update */ 29 | bool mWasTriggered = false; 30 | }; 31 | 32 | 33 | struct PlayerInput 34 | { 35 | bool mLeft = false; 36 | bool mRight = false; 37 | bool mUp = false; 38 | bool mDown = false; 39 | 40 | Button mInteract; 41 | Button mJump; 42 | Button mFire; 43 | 44 | void resetTriggeredStates() 45 | { 46 | mInteract.mWasTriggered = false; 47 | mJump.mWasTriggered = false; 48 | mFire.mWasTriggered = false; 49 | } 50 | }; 51 | 52 | } // namespace rigel::game_logic 53 | -------------------------------------------------------------------------------- /src/game_logic_common/utils.hpp: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2022, Nikolai Wuttke. All rights reserved. 2 | * 3 | * This program is free software: you can redistribute it and/or modify 4 | * it under the terms of the GNU General Public License as published by 5 | * the Free Software Foundation, either version 2 of the License, or 6 | * (at your option) any later version. 7 | * 8 | * This program is distributed in the hope that it will be useful, 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | * GNU General Public License for more details. 12 | * 13 | * You should have received a copy of the GNU General Public License 14 | * along with this program. If not, see . 15 | */ 16 | 17 | #pragma once 18 | 19 | #include "data/game_traits.hpp" 20 | #include "renderer/renderer.hpp" 21 | #include "renderer/viewport_utils.hpp" 22 | 23 | 24 | namespace rigel::game_logic 25 | { 26 | 27 | [[nodiscard]] inline auto setupIngameViewport( 28 | renderer::Renderer* pRenderer, 29 | const int screenShakeOffsetX) 30 | { 31 | auto saved = renderer::saveState(pRenderer); 32 | 33 | const auto offset = 34 | data::GameTraits::inGameViewportOffset + base::Vec2{screenShakeOffsetX, 0}; 35 | renderer::setLocalTranslation(pRenderer, offset); 36 | renderer::setLocalClipRect( 37 | pRenderer, base::Rect{{}, data::GameTraits::inGameViewportSize}); 38 | 39 | return saved; 40 | } 41 | 42 | } // namespace rigel::game_logic 43 | -------------------------------------------------------------------------------- /src/game_main.hpp: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2016, Nikolai Wuttke. All rights reserved. 2 | * 3 | * This program is free software: you can redistribute it and/or modify 4 | * it under the terms of the GNU General Public License as published by 5 | * the Free Software Foundation, either version 2 of the License, or 6 | * (at your option) any later version. 7 | * 8 | * This program is distributed in the hope that it will be useful, 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | * GNU General Public License for more details. 12 | * 13 | * You should have received a copy of the GNU General Public License 14 | * along with this program. If not, see . 15 | */ 16 | 17 | #pragma once 18 | 19 | #include "frontend/command_line_options.hpp" 20 | 21 | 22 | namespace rigel 23 | { 24 | 25 | /** Initialize platform, create game, run main loop. Returns exit code 26 | * 27 | * This function is meant for environments where Rigel can own the main loop. 28 | * It keeps running until the user quits the game. 29 | * 30 | * Running the game via this function implements the game path browser UI for 31 | * choosing a Duke Nukem II installation on first launch, and also implements 32 | * restarting the game in case the user switches to a different game path from 33 | * the options menu. 34 | */ 35 | int gameMain(const CommandLineOptions& options); 36 | 37 | } // namespace rigel 38 | -------------------------------------------------------------------------------- /src/platform.hpp: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2020, Nikolai Wuttke. All rights reserved. 2 | * 3 | * This program is free software: you can redistribute it and/or modify 4 | * it under the terms of the GNU General Public License as published by 5 | * the Free Software Foundation, either version 2 of the License, or 6 | * (at your option) any later version. 7 | * 8 | * This program is distributed in the hope that it will be useful, 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | * GNU General Public License for more details. 12 | * 13 | * You should have received a copy of the GNU General Public License 14 | * along with this program. If not, see . 15 | */ 16 | 17 | #pragma once 18 | 19 | #include "base/warnings.hpp" 20 | #include "data/game_options.hpp" 21 | #include "sdl_utils/ptr.hpp" 22 | 23 | RIGEL_DISABLE_WARNINGS 24 | #include 25 | RIGEL_RESTORE_WARNINGS 26 | 27 | 28 | namespace rigel::platform 29 | { 30 | 31 | void setGLAttributes(); 32 | sdl_utils::Ptr createWindow(const data::GameOptions& options); 33 | int flagsForWindowMode(const data::WindowMode mode); 34 | 35 | } // namespace rigel::platform 36 | -------------------------------------------------------------------------------- /src/renderer/custom_quad_batch.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2022, Nikolai Wuttke. All rights reserved. 2 | * 3 | * This program is free software: you can redistribute it and/or modify 4 | * it under the terms of the GNU General Public License as published by 5 | * the Free Software Foundation, either version 2 of the License, or 6 | * (at your option) any later version. 7 | * 8 | * This program is distributed in the hope that it will be useful, 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | * GNU General Public License for more details. 12 | * 13 | * You should have received a copy of the GNU General Public License 14 | * along with this program. If not, see . 15 | */ 16 | 17 | #include "custom_quad_batch.hpp" 18 | 19 | #include "renderer/renderer.hpp" 20 | #include "renderer/shader.hpp" 21 | 22 | 23 | namespace rigel::renderer 24 | { 25 | 26 | glm::mat4 computeTransformationMatrix(renderer::Renderer* pRenderer) 27 | { 28 | return renderer::computeTransformationMatrix( 29 | pRenderer->globalTranslation(), 30 | pRenderer->globalScale(), 31 | pRenderer->currentRenderTargetSize()); 32 | } 33 | 34 | } // namespace rigel::renderer 35 | -------------------------------------------------------------------------------- /src/renderer/fps_limiter.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2020, Nikolai Wuttke. All rights reserved. 2 | * 3 | * This program is free software: you can redistribute it and/or modify 4 | * it under the terms of the GNU General Public License as published by 5 | * the Free Software Foundation, either version 2 of the License, or 6 | * (at your option) any later version. 7 | * 8 | * This program is distributed in the hope that it will be useful, 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | * GNU General Public License for more details. 12 | * 13 | * You should have received a copy of the GNU General Public License 14 | * along with this program. If not, see . 15 | */ 16 | 17 | #include "fps_limiter.hpp" 18 | 19 | #include 20 | 21 | 22 | namespace rigel::renderer 23 | { 24 | 25 | FpsLimiter::FpsLimiter(const int targetFps) 26 | : mLastTime(base::Clock::now()) 27 | , mTargetFrameTime(1.0 / targetFps) 28 | { 29 | } 30 | 31 | 32 | void FpsLimiter::updateAndWait() 33 | { 34 | using namespace std::chrono; 35 | 36 | const auto now = base::Clock::now(); 37 | const auto delta = duration(now - mLastTime).count(); 38 | mLastTime = now; 39 | 40 | mError += mTargetFrameTime - delta; 41 | 42 | const auto timeToWaitFor = mTargetFrameTime + mError; 43 | if (timeToWaitFor > 0.0) 44 | { 45 | // We use SDL_Delay instead of std::this_thread::sleep_for, because the 46 | // former is more accurate on some platforms. 47 | SDL_Delay(static_cast(timeToWaitFor * 1000.0)); 48 | } 49 | } 50 | 51 | } // namespace rigel::renderer 52 | -------------------------------------------------------------------------------- /src/renderer/fps_limiter.hpp: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2020, Nikolai Wuttke. All rights reserved. 2 | * 3 | * This program is free software: you can redistribute it and/or modify 4 | * it under the terms of the GNU General Public License as published by 5 | * the Free Software Foundation, either version 2 of the License, or 6 | * (at your option) any later version. 7 | * 8 | * This program is distributed in the hope that it will be useful, 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | * GNU General Public License for more details. 12 | * 13 | * You should have received a copy of the GNU General Public License 14 | * along with this program. If not, see . 15 | */ 16 | 17 | #pragma once 18 | 19 | #include "base/clock.hpp" 20 | 21 | 22 | namespace rigel::renderer 23 | { 24 | 25 | class FpsLimiter 26 | { 27 | public: 28 | explicit FpsLimiter(int targetFps); 29 | 30 | void updateAndWait(); 31 | 32 | private: 33 | base::Clock::time_point mLastTime = {}; 34 | double mTargetFrameTime; 35 | double mError = 0.0; 36 | }; 37 | 38 | } // namespace rigel::renderer 39 | -------------------------------------------------------------------------------- /src/renderer/opengl.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2016, Nikolai Wuttke. All rights reserved. 2 | * 3 | * This program is free software: you can redistribute it and/or modify 4 | * it under the terms of the GNU General Public License as published by 5 | * the Free Software Foundation, either version 2 of the License, or 6 | * (at your option) any later version. 7 | * 8 | * This program is distributed in the hope that it will be useful, 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | * GNU General Public License for more details. 12 | * 13 | * You should have received a copy of the GNU General Public License 14 | * along with this program. If not, see . 15 | */ 16 | 17 | #include "opengl.hpp" 18 | 19 | #include "sdl_utils/error.hpp" 20 | 21 | RIGEL_DISABLE_WARNINGS 22 | #include 23 | RIGEL_RESTORE_WARNINGS 24 | 25 | #include 26 | 27 | 28 | void rigel::renderer::loadGlFunctions() 29 | { 30 | int result = 0; 31 | 32 | // clang-format off 33 | #ifdef RIGEL_USE_GL_ES 34 | result = gladLoadGLES2Loader([](const char* proc) { 35 | return sdl_utils::check(SDL_GL_GetProcAddress(proc)); 36 | }); 37 | #else 38 | result = gladLoadGLLoader([](const char* proc) { 39 | return sdl_utils::check(SDL_GL_GetProcAddress(proc)); 40 | }); 41 | #endif 42 | // clang-format on 43 | 44 | if (!result) 45 | { 46 | throw std::runtime_error("Failed to load OpenGL function pointers"); 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /src/renderer/opengl.hpp: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2016, Nikolai Wuttke. All rights reserved. 2 | * 3 | * This program is free software: you can redistribute it and/or modify 4 | * it under the terms of the GNU General Public License as published by 5 | * the Free Software Foundation, either version 2 of the License, or 6 | * (at your option) any later version. 7 | * 8 | * This program is distributed in the hope that it will be useful, 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | * GNU General Public License for more details. 12 | * 13 | * You should have received a copy of the GNU General Public License 14 | * along with this program. If not, see . 15 | */ 16 | 17 | #pragma once 18 | 19 | #include "base/warnings.hpp" 20 | 21 | RIGEL_DISABLE_WARNINGS 22 | #include 23 | RIGEL_RESTORE_WARNINGS 24 | 25 | #ifdef APIENTRY 26 | #undef APIENTRY 27 | #endif 28 | 29 | 30 | namespace rigel::renderer 31 | { 32 | 33 | #ifdef RIGEL_USE_GL_ES 34 | constexpr auto OPENGL_VARIANT_NAME = "OpenGL ES"; 35 | #else 36 | constexpr auto OPENGL_VARIANT_NAME = "OpenGL"; 37 | #endif 38 | 39 | void loadGlFunctions(); 40 | 41 | } // namespace rigel::renderer 42 | -------------------------------------------------------------------------------- /src/renderer/shader_code.hpp: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2021, Nikolai Wuttke. All rights reserved. 2 | * 3 | * This program is free software: you can redistribute it and/or modify 4 | * it under the terms of the GNU General Public License as published by 5 | * the Free Software Foundation, either version 2 of the License, or 6 | * (at your option) any later version. 7 | * 8 | * This program is distributed in the hope that it will be useful, 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | * GNU General Public License for more details. 12 | * 13 | * You should have received a copy of the GNU General Public License 14 | * along with this program. If not, see . 15 | */ 16 | 17 | #pragma once 18 | 19 | #include "renderer/shader.hpp" 20 | 21 | 22 | namespace rigel::renderer 23 | { 24 | 25 | extern const char* STANDARD_VERTEX_SOURCE; 26 | 27 | extern const ShaderSpec TEXTURED_QUAD_SHADER; 28 | extern const ShaderSpec SIMPLE_TEXTURED_QUAD_SHADER; 29 | extern const ShaderSpec SOLID_COLOR_SHADER; 30 | 31 | } // namespace rigel::renderer 32 | -------------------------------------------------------------------------------- /src/renderer/vertex_buffer_utils.hpp: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2022, Nikolai Wuttke. All rights reserved. 2 | * 3 | * This program is free software: you can redistribute it and/or modify 4 | * it under the terms of the GNU General Public License as published by 5 | * the Free Software Foundation, either version 2 of the License, or 6 | * (at your option) any later version. 7 | * 8 | * This program is distributed in the hope that it will be useful, 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | * GNU General Public License for more details. 12 | * 13 | * You should have received a copy of the GNU General Public License 14 | * along with this program. If not, see . 15 | */ 16 | 17 | #pragma once 18 | 19 | #include "base/warnings.hpp" 20 | #include "renderer/renderer_support.hpp" 21 | 22 | RIGEL_DISABLE_WARNINGS 23 | #include 24 | RIGEL_RESTORE_WARNINGS 25 | 26 | 27 | namespace rigel::renderer 28 | { 29 | 30 | inline QuadVertices createTexturedQuadVertices( 31 | const TexCoords& sourceRect, 32 | const base::Rect& destRect) 33 | { 34 | glm::vec2 posOffset(float(destRect.topLeft.x), float(destRect.topLeft.y)); 35 | glm::vec2 posScale(float(destRect.size.width), float(destRect.size.height)); 36 | 37 | const auto left = posOffset.x; 38 | const auto right = posScale.x + posOffset.x; 39 | const auto top = posOffset.y; 40 | const auto bottom = posScale.y + posOffset.y; 41 | 42 | // clang-format off 43 | return QuadVertices{{ 44 | left, bottom, sourceRect.left, sourceRect.bottom, 45 | left, top, sourceRect.left, sourceRect.top, 46 | right, bottom, sourceRect.right, sourceRect.bottom, 47 | right, top, sourceRect.right, sourceRect.top 48 | }}; 49 | // clang-format on 50 | } 51 | 52 | } // namespace rigel::renderer 53 | -------------------------------------------------------------------------------- /src/renderer/viewport_utils.hpp: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2022, Nikolai Wuttke. All rights reserved. 2 | * 3 | * This program is free software: you can redistribute it and/or modify 4 | * it under the terms of the GNU General Public License as published by 5 | * the Free Software Foundation, either version 2 of the License, or 6 | * (at your option) any later version. 7 | * 8 | * This program is distributed in the hope that it will be useful, 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | * GNU General Public License for more details. 12 | * 13 | * You should have received a copy of the GNU General Public License 14 | * along with this program. If not, see . 15 | */ 16 | 17 | #pragma once 18 | 19 | #include "base/spatial_types.hpp" 20 | 21 | 22 | namespace rigel::renderer 23 | { 24 | class Renderer; 25 | } 26 | 27 | 28 | namespace rigel::renderer 29 | { 30 | 31 | base::Vec2 scaleVec(const base::Vec2& vec, const base::Vec2f& scale); 32 | base::Size scaleSize(const base::Size& size, const base::Vec2f& scale); 33 | 34 | void setLocalTranslation( 35 | renderer::Renderer* pRenderer, 36 | const base::Vec2& translation); 37 | void setLocalClipRect( 38 | renderer::Renderer* pRenderer, 39 | const base::Rect& localRect); 40 | 41 | } // namespace rigel::renderer 42 | -------------------------------------------------------------------------------- /src/sdl_utils/error.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2016, Nikolai Wuttke. All rights reserved. 2 | * 3 | * This program is free software: you can redistribute it and/or modify 4 | * it under the terms of the GNU General Public License as published by 5 | * the Free Software Foundation, either version 2 of the License, or 6 | * (at your option) any later version. 7 | * 8 | * This program is distributed in the hope that it will be useful, 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | * GNU General Public License for more details. 12 | * 13 | * You should have received a copy of the GNU General Public License 14 | * along with this program. If not, see . 15 | */ 16 | 17 | #include "error.hpp" 18 | 19 | #include "base/warnings.hpp" 20 | 21 | RIGEL_DISABLE_WARNINGS 22 | #include 23 | RIGEL_RESTORE_WARNINGS 24 | 25 | 26 | namespace rigel::sdl_utils 27 | { 28 | 29 | Error::Error() 30 | : Error(SDL_GetError()) 31 | { 32 | } 33 | 34 | 35 | Error::Error(const std::string& message) 36 | : std::runtime_error(std::string("SDL error: ") + message) 37 | { 38 | } 39 | 40 | 41 | } // namespace rigel::sdl_utils 42 | -------------------------------------------------------------------------------- /src/sdl_utils/error.hpp: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2016, Nikolai Wuttke. All rights reserved. 2 | * 3 | * This program is free software: you can redistribute it and/or modify 4 | * it under the terms of the GNU General Public License as published by 5 | * the Free Software Foundation, either version 2 of the License, or 6 | * (at your option) any later version. 7 | * 8 | * This program is distributed in the hope that it will be useful, 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | * GNU General Public License for more details. 12 | * 13 | * You should have received a copy of the GNU General Public License 14 | * along with this program. If not, see . 15 | */ 16 | 17 | #pragma once 18 | 19 | #include 20 | #include 21 | 22 | 23 | namespace rigel::sdl_utils 24 | { 25 | 26 | class Error : public std::runtime_error 27 | { 28 | public: 29 | /** Will call SDL_GetError() to determine message */ 30 | Error(); 31 | 32 | explicit Error(const std::string& message); 33 | }; 34 | 35 | 36 | inline void check(int result) 37 | { 38 | if (result < 0) 39 | { 40 | throw Error(); 41 | } 42 | } 43 | 44 | template 45 | auto check(ObjectPtr pObject) 46 | { 47 | if (pObject == nullptr) 48 | { 49 | throw Error(); 50 | } 51 | return pObject; 52 | } 53 | 54 | } // namespace rigel::sdl_utils 55 | -------------------------------------------------------------------------------- /src/sdl_utils/platform.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2021, Nikolai Wuttke. All rights reserved. 2 | * 3 | * This program is free software: you can redistribute it and/or modify 4 | * it under the terms of the GNU General Public License as published by 5 | * the Free Software Foundation, either version 2 of the License, or 6 | * (at your option) any later version. 7 | * 8 | * This program is distributed in the hope that it will be useful, 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | * GNU General Public License for more details. 12 | * 13 | * You should have received a copy of the GNU General Public License 14 | * along with this program. If not, see . 15 | */ 16 | 17 | #include "platform.hpp" 18 | 19 | #include 20 | 21 | #include 22 | 23 | 24 | namespace rigel::sdl_utils 25 | { 26 | 27 | bool isRunningInDesktopEnvironment() 28 | { 29 | const auto sdlVideoDriver = std::string_view(SDL_GetCurrentVideoDriver()); 30 | 31 | // clang-format off 32 | return 33 | sdlVideoDriver == "cocoa" || 34 | sdlVideoDriver == "wayland" || 35 | sdlVideoDriver == "windows" || 36 | sdlVideoDriver == "x11"; 37 | // clang-format on 38 | } 39 | 40 | } // namespace rigel::sdl_utils 41 | -------------------------------------------------------------------------------- /src/sdl_utils/platform.hpp: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2021, Nikolai Wuttke. All rights reserved. 2 | * 3 | * This program is free software: you can redistribute it and/or modify 4 | * it under the terms of the GNU General Public License as published by 5 | * the Free Software Foundation, either version 2 of the License, or 6 | * (at your option) any later version. 7 | * 8 | * This program is distributed in the hope that it will be useful, 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | * GNU General Public License for more details. 12 | * 13 | * You should have received a copy of the GNU General Public License 14 | * along with this program. If not, see . 15 | */ 16 | 17 | #pragma once 18 | 19 | 20 | namespace rigel::sdl_utils 21 | { 22 | 23 | bool isRunningInDesktopEnvironment(); 24 | 25 | } 26 | -------------------------------------------------------------------------------- /src/sdl_utils/ptr.hpp: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2016, Nikolai Wuttke. All rights reserved. 2 | * 3 | * This program is free software: you can redistribute it and/or modify 4 | * it under the terms of the GNU General Public License as published by 5 | * the Free Software Foundation, either version 2 of the License, or 6 | * (at your option) any later version. 7 | * 8 | * This program is distributed in the hope that it will be useful, 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | * GNU General Public License for more details. 12 | * 13 | * You should have received a copy of the GNU General Public License 14 | * along with this program. If not, see . 15 | */ 16 | 17 | #pragma once 18 | 19 | #include "base/warnings.hpp" 20 | 21 | RIGEL_DISABLE_WARNINGS 22 | #include 23 | #include 24 | RIGEL_RESTORE_WARNINGS 25 | 26 | #include 27 | 28 | 29 | namespace rigel::sdl_utils 30 | { 31 | 32 | namespace detail 33 | { 34 | 35 | struct Deleter 36 | { 37 | void operator()(SDL_Window* ptr) { SDL_DestroyWindow(ptr); } 38 | 39 | void operator()(SDL_GameController* ptr) { SDL_GameControllerClose(ptr); } 40 | 41 | void operator()(Mix_Chunk* ptr) { Mix_FreeChunk(ptr); } 42 | 43 | void operator()(Mix_Music* ptr) { Mix_FreeMusic(ptr); } 44 | }; 45 | 46 | } // namespace detail 47 | 48 | 49 | template 50 | using Ptr = std::unique_ptr; 51 | 52 | 53 | template 54 | [[nodiscard]] auto wrap(SDLType* ptr) 55 | { 56 | return Ptr{ptr}; 57 | } 58 | 59 | } // namespace rigel::sdl_utils 60 | -------------------------------------------------------------------------------- /src/ui/apogee_logo.hpp: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2016, Nikolai Wuttke. All rights reserved. 2 | * 3 | * This program is free software: you can redistribute it and/or modify 4 | * it under the terms of the GNU General Public License as published by 5 | * the Free Software Foundation, either version 2 of the License, or 6 | * (at your option) any later version. 7 | * 8 | * This program is distributed in the hope that it will be useful, 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | * GNU General Public License for more details. 12 | * 13 | * You should have received a copy of the GNU General Public License 14 | * along with this program. If not, see . 15 | */ 16 | 17 | #pragma once 18 | 19 | #include "engine/timing.hpp" 20 | #include "frontend/game_mode.hpp" 21 | #include "ui/movie_player.hpp" 22 | 23 | 24 | namespace rigel::ui 25 | { 26 | 27 | class ApogeeLogo 28 | { 29 | public: 30 | explicit ApogeeLogo(GameMode::Context context); 31 | 32 | void start(); 33 | 34 | void updateAndRender(engine::TimeDelta dt); 35 | 36 | bool isFinished() const; 37 | 38 | private: 39 | ui::MoviePlayer mMoviePlayer; 40 | IGameServiceProvider* mpServiceProvider; 41 | data::Movie mLogoMovie; 42 | 43 | engine::TimeDelta mElapsedTime; 44 | }; 45 | 46 | } // namespace rigel::ui 47 | -------------------------------------------------------------------------------- /src/ui/credits.hpp: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2022, Nikolai Wuttke. All rights reserved. 2 | * 3 | * This program is free software: you can redistribute it and/or modify 4 | * it under the terms of the GNU General Public License as published by 5 | * the Free Software Foundation, either version 2 of the License, or 6 | * (at your option) any later version. 7 | * 8 | * This program is distributed in the hope that it will be useful, 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | * GNU General Public License for more details. 12 | * 13 | * You should have received a copy of the GNU General Public License 14 | * along with this program. If not, see . 15 | */ 16 | 17 | #pragma once 18 | 19 | 20 | namespace rigel::ui 21 | { 22 | 23 | void drawCredits(const float creditsBoxWidth); 24 | 25 | } 26 | -------------------------------------------------------------------------------- /src/ui/duke_3d_teaser_screen.hpp: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2020, Nikolai Wuttke. All rights reserved. 2 | * 3 | * This program is free software: you can redistribute it and/or modify 4 | * it under the terms of the GNU General Public License as published by 5 | * the Free Software Foundation, either version 2 of the License, or 6 | * (at your option) any later version. 7 | * 8 | * This program is distributed in the hope that it will be useful, 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | * GNU General Public License for more details. 12 | * 13 | * You should have received a copy of the GNU General Public License 14 | * along with this program. If not, see . 15 | */ 16 | 17 | #pragma once 18 | 19 | #include "engine/timing.hpp" 20 | #include "renderer/texture.hpp" 21 | 22 | namespace rigel::assets 23 | { 24 | class ResourceLoader; 25 | } 26 | namespace rigel::renderer 27 | { 28 | class Renderer; 29 | } 30 | 31 | 32 | namespace rigel::ui 33 | { 34 | 35 | class Duke3DTeaserScreen 36 | { 37 | public: 38 | Duke3DTeaserScreen( 39 | const assets::ResourceLoader& resources, 40 | renderer::Renderer* pRenderer); 41 | 42 | void updateAndRender(const engine::TimeDelta dt); 43 | bool isFinished() const; 44 | 45 | private: 46 | renderer::Texture mTextImage; 47 | renderer::Renderer* mpRenderer; 48 | engine::TimeDelta mElapsedTime = 0.0; 49 | }; 50 | 51 | } // namespace rigel::ui 52 | -------------------------------------------------------------------------------- /src/ui/fps_display.hpp: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2016, Nikolai Wuttke. All rights reserved. 2 | * 3 | * This program is free software: you can redistribute it and/or modify 4 | * it under the terms of the GNU General Public License as published by 5 | * the Free Software Foundation, either version 2 of the License, or 6 | * (at your option) any later version. 7 | * 8 | * This program is distributed in the hope that it will be useful, 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | * GNU General Public License for more details. 12 | * 13 | * You should have received a copy of the GNU General Public License 14 | * along with this program. If not, see . 15 | */ 16 | 17 | #pragma once 18 | 19 | #include "engine/timing.hpp" 20 | 21 | 22 | namespace rigel::ui 23 | { 24 | 25 | class FpsDisplay 26 | { 27 | public: 28 | void updateAndRender(engine::TimeDelta elapsed); 29 | 30 | 31 | private: 32 | float mPreFilteredFrameTime = 0.0f; 33 | float mFilteredFrameTime = 0.0f; 34 | }; 35 | 36 | } // namespace rigel::ui 37 | -------------------------------------------------------------------------------- /src/ui/game_path_browser.hpp: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2020, Nikolai Wuttke. All rights reserved. 2 | * 3 | * This program is free software: you can redistribute it and/or modify 4 | * it under the terms of the GNU General Public License as published by 5 | * the Free Software Foundation, either version 2 of the License, or 6 | * (at your option) any later version. 7 | * 8 | * This program is distributed in the hope that it will be useful, 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | * GNU General Public License for more details. 12 | * 13 | * You should have received a copy of the GNU General Public License 14 | * along with this program. If not, see . 15 | */ 16 | 17 | #pragma once 18 | 19 | #include "base/warnings.hpp" 20 | 21 | RIGEL_DISABLE_WARNINGS 22 | #include 23 | RIGEL_RESTORE_WARNINGS 24 | 25 | #include 26 | #include 27 | 28 | 29 | namespace rigel::ui 30 | { 31 | 32 | std::filesystem::path runFolderBrowser(SDL_Window* pWindow); 33 | 34 | void showErrorMessage(SDL_Window* pWindow, const std::string& error); 35 | 36 | } // namespace rigel::ui 37 | -------------------------------------------------------------------------------- /src/ui/high_score_list.hpp: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2019, Nikolai Wuttke. All rights reserved. 2 | * 3 | * This program is free software: you can redistribute it and/or modify 4 | * it under the terms of the GNU General Public License as published by 5 | * the Free Software Foundation, either version 2 of the License, or 6 | * (at your option) any later version. 7 | * 8 | * This program is distributed in the hope that it will be useful, 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | * GNU General Public License for more details. 12 | * 13 | * You should have received a copy of the GNU General Public License 14 | * along with this program. If not, see . 15 | */ 16 | 17 | #pragma once 18 | 19 | #include "data/high_score_list.hpp" 20 | #include "frontend/game_mode.hpp" 21 | #include "ui/text_entry_widget.hpp" 22 | 23 | 24 | namespace rigel::ui 25 | { 26 | 27 | void setupHighScoreListDisplay(GameMode::Context& context, int episode); 28 | 29 | void drawHighScoreList(GameMode::Context& context, int episode); 30 | 31 | ui::TextEntryWidget setupHighScoreNameEntry(GameMode::Context& context); 32 | } // namespace rigel::ui 33 | -------------------------------------------------------------------------------- /src/ui/imgui_integration.hpp: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2019, Nikolai Wuttke. All rights reserved. 2 | * 3 | * This program is free software: you can redistribute it and/or modify 4 | * it under the terms of the GNU General Public License as published by 5 | * the Free Software Foundation, either version 2 of the License, or 6 | * (at your option) any later version. 7 | * 8 | * This program is distributed in the hope that it will be useful, 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | * GNU General Public License for more details. 12 | * 13 | * You should have received a copy of the GNU General Public License 14 | * along with this program. If not, see . 15 | */ 16 | 17 | #pragma once 18 | 19 | #include "base/warnings.hpp" 20 | 21 | RIGEL_DISABLE_WARNINGS 22 | #include 23 | RIGEL_RESTORE_WARNINGS 24 | 25 | #include 26 | #include 27 | 28 | 29 | namespace rigel::ui::imgui_integration 30 | { 31 | 32 | void init( 33 | SDL_Window* pWindow, 34 | void* pGlContext, 35 | const std::optional& preferencesPath); 36 | void shutdown(); 37 | 38 | bool handleEvent(const SDL_Event& event); 39 | void beginFrame(SDL_Window* pWindow); 40 | void endFrame(); 41 | 42 | } // namespace rigel::ui::imgui_integration 43 | -------------------------------------------------------------------------------- /src/ui/intro_movie.hpp: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2016, Nikolai Wuttke. All rights reserved. 2 | * 3 | * This program is free software: you can redistribute it and/or modify 4 | * it under the terms of the GNU General Public License as published by 5 | * the Free Software Foundation, either version 2 of the License, or 6 | * (at your option) any later version. 7 | * 8 | * This program is distributed in the hope that it will be useful, 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | * GNU General Public License for more details. 12 | * 13 | * You should have received a copy of the GNU General Public License 14 | * along with this program. If not, see . 15 | */ 16 | 17 | #pragma once 18 | 19 | #include "data/movie.hpp" 20 | #include "frontend/game_mode.hpp" 21 | #include "ui/movie_player.hpp" 22 | 23 | #include 24 | #include 25 | 26 | 27 | namespace rigel::ui 28 | { 29 | 30 | class IntroMovie 31 | { 32 | public: 33 | explicit IntroMovie(GameMode::Context context); 34 | 35 | void start(); 36 | 37 | void updateAndRender(engine::TimeDelta dt); 38 | 39 | bool isFinished() const; 40 | 41 | private: 42 | void startNextMovie(); 43 | 44 | struct PlaybackConfig 45 | { 46 | data::Movie mMovie; 47 | 48 | const int mFrameDelay; 49 | const int mRepetitions; 50 | const ui::MoviePlayer::FrameCallbackFunc mFrameCallback; 51 | }; 52 | 53 | using PlaybackConfigList = std::vector; 54 | 55 | PlaybackConfigList 56 | createConfigurations(const assets::ResourceLoader& resources); 57 | 58 | private: 59 | IGameServiceProvider* mpServiceProvider; 60 | ui::MoviePlayer mMoviePlayer; 61 | 62 | PlaybackConfigList mMovieConfigurations; 63 | std::size_t mCurrentConfiguration; 64 | }; 65 | 66 | 67 | } // namespace rigel::ui 68 | -------------------------------------------------------------------------------- /src/ui/menu_navigation.hpp: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2020, Nikolai Wuttke. All rights reserved. 2 | * 3 | * This program is free software: you can redistribute it and/or modify 4 | * it under the terms of the GNU General Public License as published by 5 | * the Free Software Foundation, either version 2 of the License, or 6 | * (at your option) any later version. 7 | * 8 | * This program is distributed in the hope that it will be useful, 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | * GNU General Public License for more details. 12 | * 13 | * You should have received a copy of the GNU General Public License 14 | * along with this program. If not, see . 15 | */ 16 | 17 | #pragma once 18 | 19 | #include "base/spatial_types.hpp" 20 | #include "base/warnings.hpp" 21 | 22 | RIGEL_DISABLE_WARNINGS 23 | #include 24 | RIGEL_RESTORE_WARNINGS 25 | 26 | 27 | namespace rigel::ui 28 | { 29 | 30 | bool isNonRepeatKeyDown(const SDL_Event& event); 31 | bool isButtonPress(const SDL_Event& event); 32 | bool isConfirmButton(const SDL_Event& event); 33 | bool isMenuConfirmButton(const SDL_Event& event); 34 | bool isCancelButton(const SDL_Event& event); 35 | bool isQuitConfirmButton(const SDL_Event& event); 36 | 37 | 38 | enum class NavigationEvent 39 | { 40 | None, 41 | NavigateUp, 42 | NavigateDown, 43 | Confirm, 44 | Cancel, 45 | UnassignedButtonPress 46 | }; 47 | 48 | 49 | class MenuNavigationHelper 50 | { 51 | public: 52 | NavigationEvent convert(const SDL_Event& event); 53 | 54 | private: 55 | base::Vec2 mAnalogStickVector; 56 | }; 57 | 58 | } // namespace rigel::ui 59 | -------------------------------------------------------------------------------- /src/ui/text_entry_widget.hpp: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2019, Nikolai Wuttke. All rights reserved. 2 | * 3 | * This program is free software: you can redistribute it and/or modify 4 | * it under the terms of the GNU General Public License as published by 5 | * the Free Software Foundation, either version 2 of the License, or 6 | * (at your option) any later version. 7 | * 8 | * This program is distributed in the hope that it will be useful, 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | * GNU General Public License for more details. 12 | * 13 | * You should have received a copy of the GNU General Public License 14 | * along with this program. If not, see . 15 | */ 16 | 17 | #pragma once 18 | 19 | #include "base/warnings.hpp" 20 | #include "engine/timing.hpp" 21 | 22 | RIGEL_DISABLE_WARNINGS 23 | #include 24 | RIGEL_RESTORE_WARNINGS 25 | 26 | #include 27 | 28 | 29 | namespace rigel::ui 30 | { 31 | 32 | class MenuElementRenderer; 33 | 34 | class TextEntryWidget 35 | { 36 | public: 37 | enum class Style 38 | { 39 | Regular, 40 | BigText 41 | }; 42 | 43 | // Position is given in tiles 44 | TextEntryWidget( 45 | const ui::MenuElementRenderer* pUiRenderer, 46 | int posX, 47 | int posY, 48 | int maxTextLength, 49 | Style textStyle, 50 | std::string_view initialText = ""); 51 | 52 | void handleEvent(const SDL_Event& event); 53 | void updateAndRender(engine::TimeDelta dt); 54 | 55 | std::string_view text() const; 56 | 57 | private: 58 | std::string mText; 59 | engine::TimeDelta mElapsedTime = 0.0; 60 | const ui::MenuElementRenderer* mpUiRenderer; 61 | int mPosX; 62 | int mPosY; 63 | int mMaxTextLength; 64 | Style mTextStyle; 65 | }; 66 | 67 | } // namespace rigel::ui 68 | -------------------------------------------------------------------------------- /src/ui/utils.hpp: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2019, Nikolai Wuttke. All rights reserved. 2 | * 3 | * This program is free software: you can redistribute it and/or modify 4 | * it under the terms of the GNU General Public License as published by 5 | * the Free Software Foundation, either version 2 of the License, or 6 | * (at your option) any later version. 7 | * 8 | * This program is distributed in the hope that it will be useful, 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | * GNU General Public License for more details. 12 | * 13 | * You should have received a copy of the GNU General Public License 14 | * along with this program. If not, see . 15 | */ 16 | 17 | #pragma once 18 | 19 | #include "assets/palette.hpp" 20 | #include "base/color.hpp" 21 | #include "base/warnings.hpp" 22 | #include "engine/tiled_texture.hpp" 23 | #include "renderer/texture.hpp" 24 | 25 | RIGEL_DISABLE_WARNINGS 26 | #include 27 | RIGEL_RESTORE_WARNINGS 28 | 29 | #include 30 | 31 | 32 | namespace rigel::assets 33 | { 34 | class ResourceLoader; 35 | } 36 | 37 | namespace rigel::ui 38 | { 39 | 40 | ImU32 toImgui(const base::Color& color); 41 | 42 | renderer::Texture fullScreenImageAsTexture( 43 | renderer::Renderer* pRenderer, 44 | const assets::ResourceLoader& resources, 45 | std::string_view imageName); 46 | 47 | engine::TiledTexture makeUiSpriteSheet( 48 | renderer::Renderer* pRenderer, 49 | const assets::ResourceLoader& resourceLoader, 50 | const data::Palette16& palette); 51 | 52 | void drawText(std::string_view text, int x, int y, const base::Color& color); 53 | 54 | // TODO: There's probably a more appropriate place for this 55 | void drawLoadingScreenText(); 56 | 57 | } // namespace rigel::ui 58 | -------------------------------------------------------------------------------- /src/version_info.hpp.in: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2021, Nikolai Wuttke. All rights reserved. 2 | * 3 | * This program is free software: you can redistribute it and/or modify 4 | * it under the terms of the GNU General Public License as published by 5 | * the Free Software Foundation, either version 2 of the License, or 6 | * (at your option) any later version. 7 | * 8 | * This program is distributed in the hope that it will be useful, 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | * GNU General Public License for more details. 12 | * 13 | * You should have received a copy of the GNU General Public License 14 | * along with this program. If not, see . 15 | */ 16 | 17 | #pragma once 18 | 19 | 20 | namespace rigel 21 | { 22 | 23 | constexpr auto VERSION_MAJOR = ${PROJECT_VERSION_MAJOR}; 24 | constexpr auto VERSION_MINOR = ${PROJECT_VERSION_MINOR}; 25 | constexpr auto VERSION_PATCH = ${PROJECT_VERSION_PATCH}; 26 | 27 | constexpr auto COMMIT_HASH = "${RIGEL_COMMIT_HASH}"; 28 | 29 | constexpr auto IS_CUSTOM_BUILD = ${RIGEL_IS_CUSTOM_BUILD}; 30 | 31 | } 32 | -------------------------------------------------------------------------------- /test/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | Include(FetchContent) 2 | 3 | FetchContent_Declare( 4 | Catch2 5 | GIT_REPOSITORY https://github.com/catchorg/Catch2.git 6 | GIT_TAG v3.4.0 7 | ) 8 | 9 | FetchContent_MakeAvailable(Catch2) 10 | 11 | add_executable(tests 12 | test_array_view.cpp 13 | test_duke_script_loader.cpp 14 | test_elevator.cpp 15 | test_high_score_list.cpp 16 | test_json_utils.cpp 17 | test_letter_collection.cpp 18 | test_physics_system.cpp 19 | test_player.cpp 20 | test_rng.cpp 21 | test_spike_ball.cpp 22 | test_string_utils.cpp 23 | test_timing.cpp 24 | ) 25 | 26 | target_link_libraries(tests 27 | PRIVATE 28 | rigel_core 29 | Catch2::Catch2WithMain 30 | ) 31 | 32 | rigel_enable_warnings(tests) 33 | 34 | # Ignore warnings emitted from Catch macros 35 | if(CMAKE_COMPILER_IS_GNUCXX) 36 | target_compile_options(tests 37 | PRIVATE 38 | -Wno-parentheses 39 | ) 40 | endif() 41 | 42 | add_test(all-tests tests) 43 | -------------------------------------------------------------------------------- /test/test_timing.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2016, Nikolai Wuttke. All rights reserved. 2 | * 3 | * This program is free software: you can redistribute it and/or modify 4 | * it under the terms of the GNU General Public License as published by 5 | * the Free Software Foundation, either version 2 of the License, or 6 | * (at your option) any later version. 7 | * 8 | * This program is distributed in the hope that it will be useful, 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | * GNU General Public License for more details. 12 | * 13 | * You should have received a copy of the GNU General Public License 14 | * along with this program. If not, see . 15 | */ 16 | 17 | #include 18 | 19 | 20 | using namespace rigel::engine; 21 | 22 | static_assert(fastTicksToTime(280) == 1.0); 23 | static_assert(fastTicksToTime(280 * 2) == 2.0); 24 | static_assert(slowTicksToTime(140) == 1.0); 25 | static_assert(slowTicksToTime(70) == 0.5); 26 | 27 | constexpr auto EPSILON = 0.0000001; 28 | static_assert(timeToFastTicks(4.0) - 280.0 * 4 < EPSILON); 29 | static_assert(timeToFastTicks(1.0) - 280.0 < EPSILON); 30 | static_assert(timeToSlowTicks(2.0) - 140.0 * 2 < EPSILON); 31 | static_assert(timeToSlowTicks(1.0) - 140.0 < EPSILON); 32 | -------------------------------------------------------------------------------- /tools/format-all.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | CLANG_FORMAT="clang-format-11" 4 | 5 | if ! which $CLANG_FORMAT > /dev/null 2>&1; then 6 | CLANG_FORMAT="clang-format" 7 | fi 8 | 9 | if ! which $CLANG_FORMAT > /dev/null 2>&1; then 10 | echo "error: clang-format not found, make sure it's in the PATH" 11 | exit 1 12 | fi 13 | 14 | if ! $CLANG_FORMAT --version | grep "11\.\([0-9]\+\)\.\([0-9]\+\)" > /dev/null 2>&1; then 15 | echo "error: wrong version of clang-format found, version 11.x.x needed" 16 | exit 1 17 | fi 18 | 19 | find "$(pwd)/benchmark" "$(pwd)/src" "$(pwd)/test" -iname *.\[chi\]pp -exec $CLANG_FORMAT -i {} + 20 | -------------------------------------------------------------------------------- /tools/format-staged.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | CLANG_FORMAT="clang-format-11" 4 | 5 | if ! which $CLANG_FORMAT >/dev/null 2>&1; then 6 | CLANG_FORMAT="clang-format" 7 | fi 8 | 9 | if ! which $CLANG_FORMAT >/dev/null 2>&1; then 10 | echo "error: clang-format not found, make sure it's in the PATH" 11 | exit 1 12 | fi 13 | 14 | if ! $CLANG_FORMAT --version | grep "11\.\([0-9]\+\)\.\([0-9]\+\)" >/dev/null 2>&1; then 15 | echo "error: wrong version of clang-format found, version 11.x.x needed" 16 | exit 1 17 | fi 18 | 19 | STAGED_FILES="$(git diff --name-only --staged)" 20 | REPO_ROOT="$(git rev-parse --show-toplevel)" 21 | 22 | for file in $STAGED_FILES; do 23 | if [[ "$file" =~ \.[chi]pp$ ]]; then 24 | $CLANG_FORMAT -i "$REPO_ROOT/$file" 25 | fi 26 | done 27 | --------------------------------------------------------------------------------