From d5115606c96b0fe0affd72e6e0b72edce7e51042 Mon Sep 17 00:00:00 2001 From: Simon Chiang Date: Fri, 23 Apr 2021 09:46:41 -0600 Subject: Typo fixes --- samples/04_physics_and_collisions/02_moving_objects/app/main.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'samples/04_physics_and_collisions/02_moving_objects/app/main.rb') diff --git a/samples/04_physics_and_collisions/02_moving_objects/app/main.rb b/samples/04_physics_and_collisions/02_moving_objects/app/main.rb index e3e9261..9c39363 100644 --- a/samples/04_physics_and_collisions/02_moving_objects/app/main.rb +++ b/samples/04_physics_and_collisions/02_moving_objects/app/main.rb @@ -56,7 +56,7 @@ =end -# Calls methods needed for game to run properly +# Calls methods needed for the game to run properly def tick args tick_instructions args, "Use LEFT and RIGHT arrow keys to move and SPACE to jump." defaults args -- cgit v1.2.3 From a503afe87619ff82201c0a43818fa1c3f070a548 Mon Sep 17 00:00:00 2001 From: Amir Rajan Date: Sat, 7 Aug 2021 00:13:33 -0500 Subject: Samples folder synced. --- .../00_beginner_ruby_primer/app/main.rb | 10 +- .../00_intermediate_ruby_primer/app/repl.rb | 0 samples/01_rendering_basics/01_labels/app/main.rb | 10 +- .../03_solids_borders/app/main.rb | 2 +- samples/01_rendering_basics/05_sounds/app/main.rb | 163 +--- .../01_rendering_basics/06_audio_mixer/app/main.rb | 160 ---- .../06_audio_mixer/license-for-audio.txt | 48 - .../06_audio_mixer/license-for-sample.txt | 9 - .../06_audio_mixer/sounds/1.wav | Bin 409170 -> 0 bytes .../06_audio_mixer/sounds/2.wav | Bin 22374 -> 0 bytes .../06_audio_mixer/sounds/3.wav | Bin 420476 -> 0 bytes .../06_audio_mixer/sounds/4.wav | Bin 91358 -> 0 bytes .../06_audio_mixer/sounds/5.wav | Bin 117354 -> 0 bytes .../06_audio_mixer/sounds/6.ogg | Bin 330572 -> 0 bytes .../07_sound_synthesis/app/main.rb | 593 ------------ .../07_sound_synthesis/license-for-sample.txt | 9 - .../07_sound_synthesis/metadata/game_metadata.txt | 6 - .../07_sound_synthesis/metadata/icon.png | Bin 157056 -> 0 bytes .../07_sound_synthesis/sprites/square-black.png | Bin 250 -> 0 bytes .../07_sound_synthesis/sprites/square-white.png | Bin 279 -> 0 bytes samples/02_input_basics/01_keyboard/app/main.rb | 53 +- .../02_input_basics/01_moving_a_sprite/app/main.rb | 30 + .../01_moving_a_sprite/license-for-sample.txt | 9 + .../01_moving_a_sprite/sprites/square/green.png | Bin 0 -> 283 bytes samples/02_input_basics/02_mouse/app/main.rb | 12 +- .../03_mouse_point_to_rect/app/main.rb | 16 +- .../04_mouse_rect_to_rect/app/main.rb | 18 +- samples/02_input_basics/05_controller/app/main.rb | 68 +- samples/02_input_basics/06_touch/app/main.rb | 11 +- .../01_animation_using_separate_pngs/app/main.rb | 19 +- .../02_animation_using_sprite_sheet/replay.txt | 241 +++++ .../03_animation_states/replay.txt | 182 ++++ .../04_color_and_rotation/app/main.rb | 8 +- .../01_simple/app/main.rb | 6 +- .../02_moving_objects/app/main.rb | 4 +- .../04_box_collision/app/main.rb | 6 +- .../05_box_collision_2/app/main.rb | 4 +- .../06_box_collision_3/app/main.rb | 4 +- .../06_box_collision_3/replay.txt | 687 ++++++++++++++ .../06_jump_physics/app/main.rb | 195 ---- .../06_jump_physics/replay.txt | 124 --- .../07_jump_physics/app/main.rb | 3 +- .../08_bouncing_on_collision/app/block.rb | 8 +- .../08_bouncing_on_collision/app/main.rb | 2 +- .../08_bouncing_on_collision/app/peg.rb | 18 +- .../08_bouncing_on_collision/app/vector2d.rb | 2 +- .../docs/LinearCollider.md | 26 +- .../09_arbitrary_collision/app/linear_collider.rb | 4 +- .../09_arbitrary_collision/app/main.rb | 2 +- .../09_arbitrary_collision/app/vector2d.rb | 2 +- .../09_arbitrary_collision/docs/LinearCollider.md | 26 +- .../app/linear_collider.rb | 6 +- .../app/vector2d.rb | 2 +- samples/05_mouse/01_mouse_click/app/main.rb | 4 +- samples/05_mouse/02_mouse_move/app/main.rb | 6 +- .../05_mouse/03_mouse_move_paint_app/app/main.rb | 3 +- samples/05_mouse/04_coordinate_systems/app/main.rb | 4 + samples/06_save_load/01_save_load_game/app/main.rb | 9 +- .../07_advanced_audio/01_audio_mixer/app/main.rb | 376 ++++++++ .../01_audio_mixer/app/server_ip_address.txt | 1 + .../01_audio_mixer/license-for-audio.txt | 48 + .../01_audio_mixer/license-for-sample.txt | 9 + .../01_audio_mixer/metadata/game_metadata.txt | 6 + .../01_audio_mixer/metadata/icon.png | Bin 0 -> 157056 bytes .../01_audio_mixer/metadata/ios_metadata.txt | 9 + .../07_advanced_audio/01_audio_mixer/replay.txt | 995 +++++++++++++++++++++ .../01_audio_mixer/sounds/drum.wav | Bin 0 -> 420476 bytes .../01_audio_mixer/sounds/music.ogg | Bin 0 -> 330572 bytes .../01_audio_mixer/sounds/splash.wav | Bin 0 -> 22374 bytes .../01_audio_mixer/sounds/spring.wav | Bin 0 -> 117354 bytes .../01_audio_mixer/sounds/tada.wav | Bin 0 -> 409170 bytes .../01_audio_mixer/sounds/tink.wav | Bin 0 -> 91358 bytes .../02_sound_synthesis/app/main.rb | 593 ++++++++++++ .../02_sound_synthesis/license-for-sample.txt | 9 + .../02_sound_synthesis/metadata/game_metadata.txt | 6 + .../02_sound_synthesis/metadata/icon.png | Bin 0 -> 157056 bytes .../02_sound_synthesis/replay.txt | 237 +++++ .../02_sound_synthesis/sprites/square-white.png | Bin 0 -> 279 bytes .../02_render_targets_with_alphas/app/main.rb | 95 -- .../license-for-sample.txt | 9 - .../03_render_target_viewports/app/main.rb | 35 +- .../04_render_primitive_hierarchies/app/main.rb | 2 + .../05_render_primitives_as_hash/app/main.rb | 15 +- .../07_simple_camera/app/main.rb | 93 ++ .../07_simple_camera/replay.txt | 232 +++++ .../07_splitscreen_camera/app/main.rb | 395 -------- .../07_splitscreen_camera/run.bat | 6 - .../sprites/player/player_down_standing.png | Bin 186 -> 0 bytes .../sprites/player/player_left_standing.png | Bin 173 -> 0 bytes .../sprites/player/player_right_standing.png | Bin 170 -> 0 bytes .../sprites/player/player_up_standing.png | Bin 165 -> 0 bytes .../sprites/rooms/camera_room.png | Bin 2469 -> 0 bytes .../08_splitscreen_camera/app/main.rb | 395 ++++++++ .../08_splitscreen_camera/replay.txt | 226 +++++ .../sprites/player/player_down_standing.png | Bin 0 -> 186 bytes .../sprites/player/player_left_standing.png | Bin 0 -> 173 bytes .../sprites/player/player_right_standing.png | Bin 0 -> 170 bytes .../sprites/player/player_up_standing.png | Bin 0 -> 165 bytes .../sprites/rooms/camera_room.png | Bin 0 -> 2469 bytes .../08_z_targeting_camera/app/main.rb | 106 --- .../metadata/game_metadata.txt | 6 - .../08_z_targeting_camera/metadata/icon.png | Bin 14417 -> 0 bytes .../08_z_targeting_camera/sprites/arena.png | Bin 1072678 -> 0 bytes .../08_z_targeting_camera/sprites/player.png | Bin 9510 -> 0 bytes .../08_z_targeting_camera/sprites/square/black.png | Bin 250 -> 0 bytes .../09_z_targeting_camera/app/main.rb | 106 +++ .../metadata/game_metadata.txt | 6 + .../09_z_targeting_camera/metadata/icon.png | Bin 0 -> 14417 bytes .../09_z_targeting_camera/replay.txt | 185 ++++ .../09_z_targeting_camera/sprites/arena.png | Bin 0 -> 1072678 bytes .../09_z_targeting_camera/sprites/player.png | Bin 0 -> 9510 bytes .../09_z_targeting_camera/sprites/square/black.png | Bin 0 -> 250 bytes .../10_blend_modes/app/main.rb | 49 + .../10_blend_modes/sprites/blue-feathered.png | Bin 0 -> 7204 bytes .../09_performance/01_sprites_as_hash/app/main.rb | 6 +- .../02_sprites_as_entities/app/main.rb | 8 +- .../03_sprites_as_strict_entities/app/main.rb | 6 +- .../04_sprites_as_classes/app/main.rb | 7 +- .../05_static_sprites_as_classes/app/main.rb | 9 +- .../app/main.rb | 20 +- .../09_performance/07_collision_limits/app/main.rb | 2 + .../03_unit_tests/benchmark_api_tests.rb | 43 + .../03_unit_tests/pretty_format_tests.rb | 130 +++ .../03_unit_tests/run-bash.sh | 4 - .../03_unit_tests/run-tests.sh | 27 +- .../01_breadth_first_search/app/main.rb | 176 ++-- .../02_detailed_breadth_first_search/app/main.rb | 2 +- .../06_heuristic/app/main.rb | 218 ++--- .../07_heuristic_with_walls/app/main.rb | 218 ++--- samples/99_genre_3d/3d_cube/app/main.rb | 50 -- .../99_genre_3d/3d_cube/sprites/square-blue.png | Bin 283 -> 0 bytes samples/99_genre_arcade/snakemoji/app/main.rb | 6 +- samples/99_genre_arcade/twinstick/app/main.rb | 2 +- .../craft_game_starting_point/app/main.rb | 32 +- .../farming_game_starting_point/app/main.rb | 84 ++ .../farming_game_starting_point/app/repl.rb | 307 +++++++ .../farming_game_starting_point/app/tests.rb | 29 + .../sprites/background.png | Bin 0 -> 29236 bytes .../animation_creator_starting_point/app/main.rb | 38 +- .../tile_editor_starting_point/app/main.rb | 4 + .../classics_jam/app/main.rb | 213 +++++ .../classics_jam/sprites/circle/green.png | Bin 0 -> 2887 bytes .../classics_jam/sprites/square/blue.png | Bin 0 -> 283 bytes .../classics_jam/sprites/square/gray.png | Bin 0 -> 251 bytes .../classics_jam/sprites/square/red.png | Bin 0 -> 274 bytes .../01_special_move_inputs/app/main.rb | 297 ++++++ .../sprites/isometric/indigo.png | Bin 0 -> 361 bytes .../sprites/isometric/violet.png | Bin 0 -> 361 bytes .../01_special_move_inputs/sprites/square/blue.png | Bin 0 -> 283 bytes .../sprites/square/indigo.png | Bin 0 -> 283 bytes .../sprites/square/white.png | Bin 0 -> 279 bytes .../sprites/square/yellow.png | Bin 0 -> 286 bytes samples/99_genre_lowrez/nokia_3310/app/main.rb | 10 +- samples/99_genre_lowrez/nokia_3310/app/nokia.rb | 4 +- .../99_genre_lowrez/resolution_64x64/app/main.rb | 14 +- .../99_genre_platformer/clepto_frog/app/main.rb | 2 +- .../99_genre_platformer/gorillas_basic/app/repl.rb | 17 - .../the_little_probe/app/main.rb | 2 +- .../choose_your_own_adventure/app/decision.rb | 2 +- .../choose_your_own_adventure/app/main.rb | 6 +- .../return_of_serenity/app/repl.rb | 1 - .../return_of_serenity/app/storyline_anka.rb | 8 +- .../return_of_serenity/app/storyline_day_one.rb | 2 +- .../app/storyline_serenity_bio.rb | 6 +- .../01_roguelike_starting_point/app/main.rb | 2 +- .../app/sprite_lookup.rb | 2 +- .../02_roguelike_line_of_sight/app/main.rb | 2 +- .../roguelike_line_of_sight/app/constants.rb | 8 - .../roguelike_line_of_sight/app/legend.rb | 65 -- .../roguelike_line_of_sight/app/main.rb | 97 -- .../roguelike_line_of_sight/app/sprite_lookup.rb | 124 --- .../roguelike_line_of_sight/license-for-sample.txt | 9 - .../sprites/simple-mood-16x16.png | Bin 14424 -> 0 bytes .../roguelike_starting_point/app/main.rb | 438 --------- .../license-for-sample.txt | 9 - .../roguelike_starting_point/replay.txt | 555 ------------ .../gameboard_movement/app/main.rb | 529 ----------- .../gameboard_movement/sprites/border-black.png | Bin 908 -> 0 bytes .../gameboard_movement/sprites/circle-black.png | Bin 1882 -> 0 bytes .../gameboard_movement/sprites/circle-blue.png | Bin 2901 -> 0 bytes .../gameboard_movement/sprites/circle-gray.png | Bin 3006 -> 0 bytes .../gameboard_movement/sprites/circle-green.png | Bin 2887 -> 0 bytes .../gameboard_movement/sprites/circle-indigo.png | Bin 2433 -> 0 bytes .../gameboard_movement/sprites/circle-orange.png | Bin 2670 -> 0 bytes .../gameboard_movement/sprites/circle-red.png | Bin 2233 -> 0 bytes .../gameboard_movement/sprites/circle-violet.png | Bin 2439 -> 0 bytes .../gameboard_movement/sprites/circle-white.png | Bin 1754 -> 0 bytes .../gameboard_movement/sprites/circle-yellow.png | Bin 2456 -> 0 bytes .../gameboard_movement/sprites/dragon-0.png | Bin 12896 -> 0 bytes .../gameboard_movement/sprites/dragon-1.png | Bin 2964 -> 0 bytes .../gameboard_movement/sprites/dragon-2.png | Bin 3047 -> 0 bytes .../gameboard_movement/sprites/dragon-3.png | Bin 2655 -> 0 bytes .../gameboard_movement/sprites/dragon-4.png | Bin 2725 -> 0 bytes .../gameboard_movement/sprites/dragon-5.png | Bin 2655 -> 0 bytes .../gameboard_movement/sprites/explosion-0.png | Bin 267 -> 0 bytes .../gameboard_movement/sprites/explosion-1.png | Bin 4585 -> 0 bytes .../gameboard_movement/sprites/explosion-2.png | Bin 4675 -> 0 bytes .../gameboard_movement/sprites/explosion-3.png | Bin 4724 -> 0 bytes .../gameboard_movement/sprites/explosion-4.png | Bin 4773 -> 0 bytes .../gameboard_movement/sprites/explosion-5.png | Bin 4742 -> 0 bytes .../gameboard_movement/sprites/explosion-6.png | Bin 4665 -> 0 bytes .../gameboard_movement/sprites/explosion-sheet.png | Bin 2584 -> 0 bytes .../gameboard_movement/sprites/hexagon-black.png | Bin 2602 -> 0 bytes .../gameboard_movement/sprites/hexagon-blue.png | Bin 4842 -> 0 bytes .../gameboard_movement/sprites/hexagon-gray.png | Bin 5184 -> 0 bytes .../gameboard_movement/sprites/hexagon-green.png | Bin 4695 -> 0 bytes .../gameboard_movement/sprites/hexagon-indigo.png | Bin 4918 -> 0 bytes .../gameboard_movement/sprites/hexagon-orange.png | Bin 4825 -> 0 bytes .../gameboard_movement/sprites/hexagon-red.png | Bin 3753 -> 0 bytes .../gameboard_movement/sprites/hexagon-violet.png | Bin 5069 -> 0 bytes .../gameboard_movement/sprites/hexagon-white.png | Bin 5326 -> 0 bytes .../gameboard_movement/sprites/hexagon-yellow.png | Bin 5249 -> 0 bytes .../gameboard_movement/sprites/isometric-black.png | Bin 264 -> 0 bytes .../gameboard_movement/sprites/isometric-blue.png | Bin 361 -> 0 bytes .../gameboard_movement/sprites/isometric-gray.png | Bin 493 -> 0 bytes .../gameboard_movement/sprites/isometric-green.png | Bin 361 -> 0 bytes .../sprites/isometric-indigo.png | Bin 361 -> 0 bytes .../sprites/isometric-orange.png | Bin 361 -> 0 bytes .../gameboard_movement/sprites/isometric-red.png | Bin 361 -> 0 bytes .../sprites/isometric-violet.png | Bin 361 -> 0 bytes .../gameboard_movement/sprites/isometric-white.png | Bin 361 -> 0 bytes .../sprites/isometric-yellow.png | Bin 361 -> 0 bytes .../gameboard_movement/sprites/roy-0.png | Bin 20775 -> 0 bytes .../gameboard_movement/sprites/roy-1.png | Bin 3132 -> 0 bytes .../gameboard_movement/sprites/square-black.png | Bin 250 -> 0 bytes .../gameboard_movement/sprites/square-blue.png | Bin 283 -> 0 bytes .../gameboard_movement/sprites/square-gray.png | Bin 251 -> 0 bytes .../gameboard_movement/sprites/square-green.png | Bin 283 -> 0 bytes .../gameboard_movement/sprites/square-indigo.png | Bin 283 -> 0 bytes .../gameboard_movement/sprites/square-orange.png | Bin 282 -> 0 bytes .../gameboard_movement/sprites/square-red.png | Bin 274 -> 0 bytes .../gameboard_movement/sprites/square-violet.png | Bin 284 -> 0 bytes .../gameboard_movement/sprites/square-white.png | Bin 279 -> 0 bytes .../gameboard_movement/sprites/square-yellow.png | Bin 286 -> 0 bytes .../gameboard_movement/sprites/star.png | Bin 711 -> 0 bytes .../gameboard_movement/sprites/water-1.png | Bin 656794 -> 0 bytes .../gameboard_movement/sprites/water-2.png | Bin 655810 -> 0 bytes .../isometric_grid/app/main.rb | 8 +- .../99_genre_rpg_tactical/taking_turns/app/main.rb | 189 ---- samples/99_genre_rpg_tactical/taking_turns/run.bat | 6 - .../taking_turns/sprites/circle-blue.png | Bin 2901 -> 0 bytes .../taking_turns/sprites/circle-gray.png | Bin 3006 -> 0 bytes .../taking_turns/sprites/circle-green.png | Bin 2887 -> 0 bytes .../taking_turns/sprites/circle-orange.png | Bin 2670 -> 0 bytes .../taking_turns/sprites/explosion-0.png | Bin 267 -> 0 bytes .../taking_turns/sprites/explosion-1.png | Bin 4585 -> 0 bytes .../taking_turns/sprites/explosion-2.png | Bin 4675 -> 0 bytes .../taking_turns/sprites/explosion-3.png | Bin 4724 -> 0 bytes .../taking_turns/sprites/explosion-4.png | Bin 4773 -> 0 bytes .../taking_turns/sprites/explosion-5.png | Bin 4742 -> 0 bytes .../taking_turns/sprites/explosion-6.png | Bin 4665 -> 0 bytes .../taking_turns/sprites/star.png | Bin 711 -> 0 bytes .../topdown_starting_point/app/main.rb | 1 + 253 files changed, 6514 insertions(+), 4626 deletions(-) delete mode 100644 samples/00_learn_ruby_optional/00_intermediate_ruby_primer/app/repl.rb delete mode 100644 samples/01_rendering_basics/06_audio_mixer/app/main.rb delete mode 100644 samples/01_rendering_basics/06_audio_mixer/license-for-audio.txt delete mode 100644 samples/01_rendering_basics/06_audio_mixer/license-for-sample.txt delete mode 100644 samples/01_rendering_basics/06_audio_mixer/sounds/1.wav delete mode 100644 samples/01_rendering_basics/06_audio_mixer/sounds/2.wav delete mode 100644 samples/01_rendering_basics/06_audio_mixer/sounds/3.wav delete mode 100644 samples/01_rendering_basics/06_audio_mixer/sounds/4.wav delete mode 100644 samples/01_rendering_basics/06_audio_mixer/sounds/5.wav delete mode 100644 samples/01_rendering_basics/06_audio_mixer/sounds/6.ogg delete mode 100644 samples/01_rendering_basics/07_sound_synthesis/app/main.rb delete mode 100644 samples/01_rendering_basics/07_sound_synthesis/license-for-sample.txt delete mode 100644 samples/01_rendering_basics/07_sound_synthesis/metadata/game_metadata.txt delete mode 100644 samples/01_rendering_basics/07_sound_synthesis/metadata/icon.png delete mode 100644 samples/01_rendering_basics/07_sound_synthesis/sprites/square-black.png delete mode 100644 samples/01_rendering_basics/07_sound_synthesis/sprites/square-white.png create mode 100644 samples/02_input_basics/01_moving_a_sprite/app/main.rb create mode 100644 samples/02_input_basics/01_moving_a_sprite/license-for-sample.txt create mode 100644 samples/02_input_basics/01_moving_a_sprite/sprites/square/green.png create mode 100644 samples/03_rendering_sprites/02_animation_using_sprite_sheet/replay.txt create mode 100644 samples/03_rendering_sprites/03_animation_states/replay.txt create mode 100644 samples/04_physics_and_collisions/06_box_collision_3/replay.txt delete mode 100644 samples/04_physics_and_collisions/06_jump_physics/app/main.rb delete mode 100644 samples/04_physics_and_collisions/06_jump_physics/replay.txt create mode 100644 samples/07_advanced_audio/01_audio_mixer/app/main.rb create mode 100644 samples/07_advanced_audio/01_audio_mixer/app/server_ip_address.txt create mode 100644 samples/07_advanced_audio/01_audio_mixer/license-for-audio.txt create mode 100644 samples/07_advanced_audio/01_audio_mixer/license-for-sample.txt create mode 100644 samples/07_advanced_audio/01_audio_mixer/metadata/game_metadata.txt create mode 100644 samples/07_advanced_audio/01_audio_mixer/metadata/icon.png create mode 100644 samples/07_advanced_audio/01_audio_mixer/metadata/ios_metadata.txt create mode 100644 samples/07_advanced_audio/01_audio_mixer/replay.txt create mode 100644 samples/07_advanced_audio/01_audio_mixer/sounds/drum.wav create mode 100644 samples/07_advanced_audio/01_audio_mixer/sounds/music.ogg create mode 100644 samples/07_advanced_audio/01_audio_mixer/sounds/splash.wav create mode 100644 samples/07_advanced_audio/01_audio_mixer/sounds/spring.wav create mode 100644 samples/07_advanced_audio/01_audio_mixer/sounds/tada.wav create mode 100644 samples/07_advanced_audio/01_audio_mixer/sounds/tink.wav create mode 100644 samples/07_advanced_audio/02_sound_synthesis/app/main.rb create mode 100644 samples/07_advanced_audio/02_sound_synthesis/license-for-sample.txt create mode 100644 samples/07_advanced_audio/02_sound_synthesis/metadata/game_metadata.txt create mode 100644 samples/07_advanced_audio/02_sound_synthesis/metadata/icon.png create mode 100644 samples/07_advanced_audio/02_sound_synthesis/replay.txt create mode 100644 samples/07_advanced_audio/02_sound_synthesis/sprites/square-white.png delete mode 100644 samples/07_advanced_rendering/02_render_targets_with_alphas/app/main.rb delete mode 100644 samples/07_advanced_rendering/02_render_targets_with_alphas/license-for-sample.txt create mode 100644 samples/07_advanced_rendering/07_simple_camera/app/main.rb create mode 100644 samples/07_advanced_rendering/07_simple_camera/replay.txt delete mode 100644 samples/07_advanced_rendering/07_splitscreen_camera/app/main.rb delete mode 100644 samples/07_advanced_rendering/07_splitscreen_camera/run.bat delete mode 100644 samples/07_advanced_rendering/07_splitscreen_camera/sprites/player/player_down_standing.png delete mode 100644 samples/07_advanced_rendering/07_splitscreen_camera/sprites/player/player_left_standing.png delete mode 100644 samples/07_advanced_rendering/07_splitscreen_camera/sprites/player/player_right_standing.png delete mode 100644 samples/07_advanced_rendering/07_splitscreen_camera/sprites/player/player_up_standing.png delete mode 100644 samples/07_advanced_rendering/07_splitscreen_camera/sprites/rooms/camera_room.png create mode 100644 samples/07_advanced_rendering/08_splitscreen_camera/app/main.rb create mode 100644 samples/07_advanced_rendering/08_splitscreen_camera/replay.txt create mode 100644 samples/07_advanced_rendering/08_splitscreen_camera/sprites/player/player_down_standing.png create mode 100644 samples/07_advanced_rendering/08_splitscreen_camera/sprites/player/player_left_standing.png create mode 100644 samples/07_advanced_rendering/08_splitscreen_camera/sprites/player/player_right_standing.png create mode 100644 samples/07_advanced_rendering/08_splitscreen_camera/sprites/player/player_up_standing.png create mode 100644 samples/07_advanced_rendering/08_splitscreen_camera/sprites/rooms/camera_room.png delete mode 100644 samples/07_advanced_rendering/08_z_targeting_camera/app/main.rb delete mode 100644 samples/07_advanced_rendering/08_z_targeting_camera/metadata/game_metadata.txt delete mode 100644 samples/07_advanced_rendering/08_z_targeting_camera/metadata/icon.png delete mode 100644 samples/07_advanced_rendering/08_z_targeting_camera/sprites/arena.png delete mode 100644 samples/07_advanced_rendering/08_z_targeting_camera/sprites/player.png delete mode 100644 samples/07_advanced_rendering/08_z_targeting_camera/sprites/square/black.png create mode 100644 samples/07_advanced_rendering/09_z_targeting_camera/app/main.rb create mode 100644 samples/07_advanced_rendering/09_z_targeting_camera/metadata/game_metadata.txt create mode 100644 samples/07_advanced_rendering/09_z_targeting_camera/metadata/icon.png create mode 100644 samples/07_advanced_rendering/09_z_targeting_camera/replay.txt create mode 100644 samples/07_advanced_rendering/09_z_targeting_camera/sprites/arena.png create mode 100644 samples/07_advanced_rendering/09_z_targeting_camera/sprites/player.png create mode 100644 samples/07_advanced_rendering/09_z_targeting_camera/sprites/square/black.png create mode 100644 samples/07_advanced_rendering/10_blend_modes/app/main.rb create mode 100644 samples/07_advanced_rendering/10_blend_modes/sprites/blue-feathered.png create mode 100644 samples/10_advanced_debugging/03_unit_tests/benchmark_api_tests.rb create mode 100644 samples/10_advanced_debugging/03_unit_tests/pretty_format_tests.rb delete mode 100644 samples/10_advanced_debugging/03_unit_tests/run-bash.sh delete mode 100644 samples/99_genre_3d/3d_cube/app/main.rb delete mode 100644 samples/99_genre_3d/3d_cube/sprites/square-blue.png create mode 100644 samples/99_genre_crafting/farming_game_starting_point/app/main.rb create mode 100644 samples/99_genre_crafting/farming_game_starting_point/app/repl.rb create mode 100644 samples/99_genre_crafting/farming_game_starting_point/app/tests.rb create mode 100644 samples/99_genre_crafting/farming_game_starting_point/sprites/background.png create mode 100644 samples/99_genre_dungeon_crawl/classics_jam/app/main.rb create mode 100644 samples/99_genre_dungeon_crawl/classics_jam/sprites/circle/green.png create mode 100644 samples/99_genre_dungeon_crawl/classics_jam/sprites/square/blue.png create mode 100644 samples/99_genre_dungeon_crawl/classics_jam/sprites/square/gray.png create mode 100644 samples/99_genre_dungeon_crawl/classics_jam/sprites/square/red.png create mode 100644 samples/99_genre_fighting/01_special_move_inputs/app/main.rb create mode 100644 samples/99_genre_fighting/01_special_move_inputs/sprites/isometric/indigo.png create mode 100644 samples/99_genre_fighting/01_special_move_inputs/sprites/isometric/violet.png create mode 100644 samples/99_genre_fighting/01_special_move_inputs/sprites/square/blue.png create mode 100644 samples/99_genre_fighting/01_special_move_inputs/sprites/square/indigo.png create mode 100644 samples/99_genre_fighting/01_special_move_inputs/sprites/square/white.png create mode 100644 samples/99_genre_fighting/01_special_move_inputs/sprites/square/yellow.png delete mode 100644 samples/99_genre_platformer/gorillas_basic/app/repl.rb delete mode 100644 samples/99_genre_rpg_narrative/return_of_serenity/app/repl.rb delete mode 100644 samples/99_genre_rpg_roguelike/roguelike_line_of_sight/app/constants.rb delete mode 100644 samples/99_genre_rpg_roguelike/roguelike_line_of_sight/app/legend.rb delete mode 100644 samples/99_genre_rpg_roguelike/roguelike_line_of_sight/app/main.rb delete mode 100644 samples/99_genre_rpg_roguelike/roguelike_line_of_sight/app/sprite_lookup.rb delete mode 100644 samples/99_genre_rpg_roguelike/roguelike_line_of_sight/license-for-sample.txt delete mode 100644 samples/99_genre_rpg_roguelike/roguelike_line_of_sight/sprites/simple-mood-16x16.png delete mode 100644 samples/99_genre_rpg_roguelike/roguelike_starting_point/app/main.rb delete mode 100644 samples/99_genre_rpg_roguelike/roguelike_starting_point/license-for-sample.txt delete mode 100644 samples/99_genre_rpg_roguelike/roguelike_starting_point/replay.txt delete mode 100644 samples/99_genre_rpg_tactical/gameboard_movement/app/main.rb delete mode 100644 samples/99_genre_rpg_tactical/gameboard_movement/sprites/border-black.png delete mode 100644 samples/99_genre_rpg_tactical/gameboard_movement/sprites/circle-black.png delete mode 100644 samples/99_genre_rpg_tactical/gameboard_movement/sprites/circle-blue.png delete mode 100644 samples/99_genre_rpg_tactical/gameboard_movement/sprites/circle-gray.png delete mode 100644 samples/99_genre_rpg_tactical/gameboard_movement/sprites/circle-green.png delete mode 100644 samples/99_genre_rpg_tactical/gameboard_movement/sprites/circle-indigo.png delete mode 100644 samples/99_genre_rpg_tactical/gameboard_movement/sprites/circle-orange.png delete mode 100644 samples/99_genre_rpg_tactical/gameboard_movement/sprites/circle-red.png delete mode 100644 samples/99_genre_rpg_tactical/gameboard_movement/sprites/circle-violet.png delete mode 100644 samples/99_genre_rpg_tactical/gameboard_movement/sprites/circle-white.png delete mode 100644 samples/99_genre_rpg_tactical/gameboard_movement/sprites/circle-yellow.png delete mode 100644 samples/99_genre_rpg_tactical/gameboard_movement/sprites/dragon-0.png delete mode 100644 samples/99_genre_rpg_tactical/gameboard_movement/sprites/dragon-1.png delete mode 100644 samples/99_genre_rpg_tactical/gameboard_movement/sprites/dragon-2.png delete mode 100644 samples/99_genre_rpg_tactical/gameboard_movement/sprites/dragon-3.png delete mode 100644 samples/99_genre_rpg_tactical/gameboard_movement/sprites/dragon-4.png delete mode 100644 samples/99_genre_rpg_tactical/gameboard_movement/sprites/dragon-5.png delete mode 100644 samples/99_genre_rpg_tactical/gameboard_movement/sprites/explosion-0.png delete mode 100644 samples/99_genre_rpg_tactical/gameboard_movement/sprites/explosion-1.png delete mode 100644 samples/99_genre_rpg_tactical/gameboard_movement/sprites/explosion-2.png delete mode 100644 samples/99_genre_rpg_tactical/gameboard_movement/sprites/explosion-3.png delete mode 100644 samples/99_genre_rpg_tactical/gameboard_movement/sprites/explosion-4.png delete mode 100644 samples/99_genre_rpg_tactical/gameboard_movement/sprites/explosion-5.png delete mode 100644 samples/99_genre_rpg_tactical/gameboard_movement/sprites/explosion-6.png delete mode 100644 samples/99_genre_rpg_tactical/gameboard_movement/sprites/explosion-sheet.png delete mode 100644 samples/99_genre_rpg_tactical/gameboard_movement/sprites/hexagon-black.png delete mode 100644 samples/99_genre_rpg_tactical/gameboard_movement/sprites/hexagon-blue.png delete mode 100644 samples/99_genre_rpg_tactical/gameboard_movement/sprites/hexagon-gray.png delete mode 100644 samples/99_genre_rpg_tactical/gameboard_movement/sprites/hexagon-green.png delete mode 100644 samples/99_genre_rpg_tactical/gameboard_movement/sprites/hexagon-indigo.png delete mode 100644 samples/99_genre_rpg_tactical/gameboard_movement/sprites/hexagon-orange.png delete mode 100644 samples/99_genre_rpg_tactical/gameboard_movement/sprites/hexagon-red.png delete mode 100644 samples/99_genre_rpg_tactical/gameboard_movement/sprites/hexagon-violet.png delete mode 100644 samples/99_genre_rpg_tactical/gameboard_movement/sprites/hexagon-white.png delete mode 100644 samples/99_genre_rpg_tactical/gameboard_movement/sprites/hexagon-yellow.png delete mode 100644 samples/99_genre_rpg_tactical/gameboard_movement/sprites/isometric-black.png delete mode 100644 samples/99_genre_rpg_tactical/gameboard_movement/sprites/isometric-blue.png delete mode 100644 samples/99_genre_rpg_tactical/gameboard_movement/sprites/isometric-gray.png delete mode 100644 samples/99_genre_rpg_tactical/gameboard_movement/sprites/isometric-green.png delete mode 100644 samples/99_genre_rpg_tactical/gameboard_movement/sprites/isometric-indigo.png delete mode 100644 samples/99_genre_rpg_tactical/gameboard_movement/sprites/isometric-orange.png delete mode 100644 samples/99_genre_rpg_tactical/gameboard_movement/sprites/isometric-red.png delete mode 100644 samples/99_genre_rpg_tactical/gameboard_movement/sprites/isometric-violet.png delete mode 100644 samples/99_genre_rpg_tactical/gameboard_movement/sprites/isometric-white.png delete mode 100644 samples/99_genre_rpg_tactical/gameboard_movement/sprites/isometric-yellow.png delete mode 100644 samples/99_genre_rpg_tactical/gameboard_movement/sprites/roy-0.png delete mode 100644 samples/99_genre_rpg_tactical/gameboard_movement/sprites/roy-1.png delete mode 100644 samples/99_genre_rpg_tactical/gameboard_movement/sprites/square-black.png delete mode 100644 samples/99_genre_rpg_tactical/gameboard_movement/sprites/square-blue.png delete mode 100644 samples/99_genre_rpg_tactical/gameboard_movement/sprites/square-gray.png delete mode 100644 samples/99_genre_rpg_tactical/gameboard_movement/sprites/square-green.png delete mode 100644 samples/99_genre_rpg_tactical/gameboard_movement/sprites/square-indigo.png delete mode 100644 samples/99_genre_rpg_tactical/gameboard_movement/sprites/square-orange.png delete mode 100644 samples/99_genre_rpg_tactical/gameboard_movement/sprites/square-red.png delete mode 100644 samples/99_genre_rpg_tactical/gameboard_movement/sprites/square-violet.png delete mode 100644 samples/99_genre_rpg_tactical/gameboard_movement/sprites/square-white.png delete mode 100644 samples/99_genre_rpg_tactical/gameboard_movement/sprites/square-yellow.png delete mode 100644 samples/99_genre_rpg_tactical/gameboard_movement/sprites/star.png delete mode 100644 samples/99_genre_rpg_tactical/gameboard_movement/sprites/water-1.png delete mode 100644 samples/99_genre_rpg_tactical/gameboard_movement/sprites/water-2.png delete mode 100644 samples/99_genre_rpg_tactical/taking_turns/app/main.rb delete mode 100644 samples/99_genre_rpg_tactical/taking_turns/run.bat delete mode 100644 samples/99_genre_rpg_tactical/taking_turns/sprites/circle-blue.png delete mode 100644 samples/99_genre_rpg_tactical/taking_turns/sprites/circle-gray.png delete mode 100644 samples/99_genre_rpg_tactical/taking_turns/sprites/circle-green.png delete mode 100644 samples/99_genre_rpg_tactical/taking_turns/sprites/circle-orange.png delete mode 100644 samples/99_genre_rpg_tactical/taking_turns/sprites/explosion-0.png delete mode 100644 samples/99_genre_rpg_tactical/taking_turns/sprites/explosion-1.png delete mode 100644 samples/99_genre_rpg_tactical/taking_turns/sprites/explosion-2.png delete mode 100644 samples/99_genre_rpg_tactical/taking_turns/sprites/explosion-3.png delete mode 100644 samples/99_genre_rpg_tactical/taking_turns/sprites/explosion-4.png delete mode 100644 samples/99_genre_rpg_tactical/taking_turns/sprites/explosion-5.png delete mode 100644 samples/99_genre_rpg_tactical/taking_turns/sprites/explosion-6.png delete mode 100644 samples/99_genre_rpg_tactical/taking_turns/sprites/star.png (limited to 'samples/04_physics_and_collisions/02_moving_objects/app/main.rb') diff --git a/samples/00_learn_ruby_optional/00_beginner_ruby_primer/app/main.rb b/samples/00_learn_ruby_optional/00_beginner_ruby_primer/app/main.rb index 711ca74..6822cf3 100644 --- a/samples/00_learn_ruby_optional/00_beginner_ruby_primer/app/main.rb +++ b/samples/00_learn_ruby_optional/00_beginner_ruby_primer/app/main.rb @@ -83,8 +83,8 @@ def tick_reset_button end end -def separator - @separator = "=" * 80 +def seperator + @seperator = "=" * 80 end def tick_intro @@ -286,11 +286,11 @@ def queue_message message $gtk.args.state.messages << message last_three = [$gtk.console.log[-3], $gtk.console.log[-2], $gtk.console.log[-1]].reject_nil $gtk.console.log.clear - puts separator + puts seperator $gtk.console.log += last_three - puts separator + puts seperator puts message - puts separator + puts seperator end def console_has? message diff --git a/samples/00_learn_ruby_optional/00_intermediate_ruby_primer/app/repl.rb b/samples/00_learn_ruby_optional/00_intermediate_ruby_primer/app/repl.rb deleted file mode 100644 index e69de29..0000000 diff --git a/samples/01_rendering_basics/01_labels/app/main.rb b/samples/01_rendering_basics/01_labels/app/main.rb index 8a5e866..837954f 100644 --- a/samples/01_rendering_basics/01_labels/app/main.rb +++ b/samples/01_rendering_basics/01_labels/app/main.rb @@ -2,12 +2,12 @@ APIs listing that haven't been encountered in a previous sample apps: -- args.outputs.labels: An array. Values in this array generate labels on +- args.outputs.labels: An array. Values in this array generate labels the screen. - args.grid.(left|right|top|bottom): Pixel value for the boundaries of the virtual 720 p screen (Dragon Ruby Game Toolkits's virtual resolution is always 1280x720). - Numeric#shift_(left|right|up|down): Shifts the Numeric in the correct direction - by adding or subtracting. + by adding or subracting. =end @@ -27,7 +27,7 @@ APIs listing that haven't been encountered in a previous sample apps: # The tick method is called by DragonRuby every frame # args contains all the information regarding the game. def tick args - tick_instructions args, "Sample app shows different versions of label sizes and alignments. And how to use hashes instead of arrays." + tick_instructions args, "Sample app shows different version of label sizes and alignments. And how to use hashes instead of arrays." # Here are some examples of simple labels, with the minimum number of parameters # Note that the default values for the other parameters are 0, except for Alpha which is 255 and Font Style which is the default font args.outputs.labels << [400, 620, "Here is a label with just an x, y, and text"] @@ -67,7 +67,7 @@ def tick args g: 0, b: 200, a: 255, - font: "manaspc.ttf" }.label + font: "manaspc.ttf" }.label! # Primitives can hold anything, and can be given a label in the following forms args.outputs.primitives << [690 + 150, 330 - 80, "Custom font (.primitives Array)", 0, 1, 125, 0, 200, 255, "manaspc.ttf" ].label @@ -81,7 +81,7 @@ def tick args g: 0, b: 200, a: 255, - font: "manaspc.ttf" }.label + font: "manaspc.ttf" }.label! end def tick_instructions args, text, y = 715 diff --git a/samples/01_rendering_basics/03_solids_borders/app/main.rb b/samples/01_rendering_basics/03_solids_borders/app/main.rb index 2b9b1c4..8d1bfef 100644 --- a/samples/01_rendering_basics/03_solids_borders/app/main.rb +++ b/samples/01_rendering_basics/03_solids_borders/app/main.rb @@ -15,7 +15,7 @@ APIs listing that haven't been encountered in a previous sample apps: # Borders are added to args.outputs.borders # The parameters required for rects are: -# 1. The bottom left corner (x, y) +# 1. The upper right corner (x, y) # 2. The width (w) # 3. The height (h) # 4. The rgba values for the color and transparency (r, g, b, a) diff --git a/samples/01_rendering_basics/05_sounds/app/main.rb b/samples/01_rendering_basics/05_sounds/app/main.rb index 630ce11..787d303 100644 --- a/samples/01_rendering_basics/05_sounds/app/main.rb +++ b/samples/01_rendering_basics/05_sounds/app/main.rb @@ -13,16 +13,7 @@ - args.outputs.labels: An array. The values generate a label. The parameters are [X, Y, TEXT, SIZE, ALIGNMENT, RED, GREEN, BLUE, ALPHA, FONT STYLE] - - - reject: Removes elements from a collection if they meet certain requirements. - - - first: Returns the first element of an array. - - - inside_rect: Returns true or false depending on if the point is inside the rect. - - - to_sym: Returns symbol corresponding to string. Will create a symbol if it does - not already exist. - + For more information about labels, go to mygame/documentation/02-labels.md. =end # This sample app allows users to test their musical skills by matching the piano sound that plays in each @@ -30,153 +21,11 @@ # Runs all the methods necessary for the game to function properly. def tick args - defaults args - render args - calc args - input_mouse args - tick_instructions args, "Sample app shows how to play sounds. args.outputs.sounds << \"path_to_wav.wav\"" -end - -# Sets default values and creates empty collections -# Initialization happens in the first frame only -def defaults _ - _.state.notes ||= [] - _.state.click_feedbacks ||= [] - _.state.current_level ||= 1 - _.state.times_wrong ||= 0 # when game starts, user hasn't guessed wrong yet -end - -# Uses a label to display current level, and shows the score -# Creates a button to play the sample note, and displays the available notes that could be a potential match -def render _ - - # grid.w_half positions the label in the horizontal center of the screen. - _.outputs.labels << [_.grid.w_half, _.grid.top.shift_down(40), "Hole #{_.state.current_level} of 9", 0, 1, 0, 0, 0] - - render_score _ # shows score on screen - - if _.state.game_over # if game is over, a "play again" button is shown - # Calculations ensure that Play Again label is displayed in center of border - # Remove calculations from y parameters and see what happens to border and label placement - _.state.play_again_border ||= _.state.with_meta([560, _.grid.h * 3 / 4 - 40, 160, 60], 'again') # array definition, text/title - _.outputs.labels << [_.grid.w_half, _.grid.h * 3 / 4, "Play Again", 0, 1, 0, 0, 0] # outputs label - _.outputs.borders << _.state.play_again_border # outputs border - else # otherwise, if game is not over - # Calculations ensure that label appears in center of border - _.state.play_note_border ||= _.state.with_meta([560, _.grid.h * 3 / 4 - 40, 160, 60], 'play') # array definition, text/title - _.outputs.labels << [_.grid.w_half, _.grid.h * 3 / 4, "Play Note ##{_.state.current_level}", 0, 1, 0, 0, 0] # outputs label - _.outputs.borders << _.state.play_note_border # outputs border - end - - return if _.state.game_over # return if game is over - - _.outputs.labels << [_.grid.w_half, 400, "I think the note is a(n)...", 0, 1, 0, 0, 0] # outputs label - - # Shows all of the available notes that can be potential matches. - available_notes.each_with_index do |note, i| - _.state.notes[i] ||= piano_button(_, note, i + 1) # calls piano_button method on each note (creates label and border) - _.outputs.labels << _.state.notes[i].label # outputs note on screen with a label and a border - _.outputs.borders << _.state.notes[i].border - end - - # Shows whether or not the user is correct by filling the screen with either red or green - _.outputs.solids << _.state.click_feedbacks.map { |c| c.solid } -end - -# Shows the score (number of times the user guesses wrong) onto the screen using labels. -def render_score _ - if _.state.times_wrong == 0 # if the user has guessed wrong zero times, the score is par - _.outputs.labels << [_.grid.w_half, _.grid.top.shift_down(80), "Score: PAR", 0, 1, 0, 0, 0] - else # otherwise, number of times the user has guessed wrong is shown - _.outputs.labels << [_.grid.w_half, _.grid.top.shift_down(80), "Score: +#{_.state.times_wrong}", 0, 1, 0, 0, 0] # shows score using string interpolation - end -end - -# Sets the target note for the level and performs calculations on click_feedbacks. -def calc _ - _.state.target_note ||= available_notes.sample # chooses a note from available_notes collection as target note - _.state.click_feedbacks.each { |c| c.solid[-1] -= 5 } # remove this line and solid color will remain on screen indefinitely - # comment this line out and the solid color will keep flashing on screen instead of being removed from click_feedbacks collection - _.state.click_feedbacks.reject! { |c| c.solid[-1] <= 0 } -end - -# Uses input from the user to play the target note, as well as the other notes that could be a potential match. -def input_mouse _ - return unless _.inputs.mouse.click # return unless the mouse is clicked - - # finds button that was clicked by user - button_clicked = _.outputs.borders.find_all do |b| # go through borders collection to find all borders that meet requirements - _.inputs.mouse.click.point.inside_rect? b # find button border that mouse was clicked inside of - end.reject {|b| !_.state.meta(b)}.first # reject, return first element - - return unless button_clicked # return unless button_clicked as a value (a button was clicked) + args.outputs.labels << [640, 360, "Click anywhere to play a random sound.", 0, 1] + args.state.notes ||= [:C3, :D3, :E3, :F3, :G3, :A3, :B3, :C4] - queue_click_feedback _, # calls queue_click_feedback method on the button that was clicked - button_clicked.x, - button_clicked.y, - button_clicked.w, - button_clicked.h, - 150, 100, 200 # sets color of button to shade of purple - - if _.state.meta(button_clicked) == 'play' # if "play note" button is pressed - _.outputs.sounds << "sounds/#{_.state.target_note}.wav" # sound of target note is output - elsif _.state.meta(button_clicked) == 'again' # if "play game again" button is pressed - _.state.target_note = nil # no target note - _.state.current_level = 1 # starts at level 1 again - _.state.times_wrong = 0 # starts off with 0 wrong guesses - _.state.game_over = false # the game is not over (because it has just been restarted) - else # otherwise if neither of those buttons were pressed - _.outputs.sounds << "sounds/#{_.state.meta(button_clicked)}.wav" # sound of clicked note is played - if _.state.meta(button_clicked).to_sym == _.state.target_note # if clicked note is target note - _.state.target_note = nil # target note is emptied - - if _.state.current_level < 9 # if game hasn't reached level 9 - _.state.current_level += 1 # game goes to next level - else # otherwise, if game has reached level 9 - _.state.game_over = true # the game is over - end - - queue_click_feedback _, 0, 0, _.grid.w, _.grid.h, 100, 200, 100 # green shown if user guesses correctly - else # otherwise, if clicked note is not target note - _.state.times_wrong += 1 # increments times user guessed wrong - queue_click_feedback _, 0, 0, _.grid.w, _.grid.h, 200, 100, 100 # red shown is user guesses wrong - end + if args.inputs.mouse.click + # Play a sound by adding a string to args.outputs.sounds + args.outputs.sounds << "sounds/#{args.state.notes.sample}.wav" # sound of target note is output end end - -# Creates a collection of all of the available notes as symbols -def available_notes - [:C3, :D3, :E3, :F3, :G3, :A3, :B3, :C4] -end - -# Creates buttons for each note, and sets a label (the note's name) and border for each note's button. -def piano_button _, note, position - _.state.new_entity(:button) do |b| # declares button as new entity - b.label = [460 + 40.mult(position), _.grid.h * 0.4, "#{note}", 0, 1, 0, 0, 0] # label definition - b.border = _.state.with_meta([460 + 40.mult(position) - 20, _.grid.h * 0.4 - 32, 40, 40], note) # border definition, text/title; 20 subtracted so label is in center of border - end -end - -# Color of click feedback changes depending on what button was clicked, and whether the guess is right or wrong -# If a button is clicked, the inside of button is purple (see input_mouse method) -# If correct note is clicked, screen turns green -# If incorrect note is clicked, screen turns red (again, see input_mouse method) -def queue_click_feedback _, x, y, w, h, *color - _.state.click_feedbacks << _.state.new_entity(:click_feedback) do |c| # declares feedback as new entity - c.solid = [x, y, w, h, *color, 255] # sets color - end -end - -def tick_instructions args, text, y = 715 - return if args.state.key_event_occurred - if args.inputs.mouse.click || - args.inputs.keyboard.directional_vector || - args.inputs.keyboard.key_down.enter || - args.inputs.keyboard.key_down.escape - args.state.key_event_occurred = true - end - - args.outputs.debug << [0, y - 50, 1280, 60].solid - args.outputs.debug << [640, y, text, 1, 1, 255, 255, 255].label - args.outputs.debug << [640, y - 25, "(click to dismiss instructions)" , -2, 1, 255, 255, 255].label -end diff --git a/samples/01_rendering_basics/06_audio_mixer/app/main.rb b/samples/01_rendering_basics/06_audio_mixer/app/main.rb deleted file mode 100644 index ce48d3f..0000000 --- a/samples/01_rendering_basics/06_audio_mixer/app/main.rb +++ /dev/null @@ -1,160 +0,0 @@ -$gtk.reset - -$boxsize = 30 - -def render_sources args - mouse_in_panel = (args.state.selected != 0) && args.inputs.mouse.position.inside_rect?([900, 450, 340, 250]) - mouse_new_down = (args.state.mouse_held == 1) - - if (mouse_new_down && !mouse_in_panel) - args.state.selected = 0 # will reset below if we hit something. - end - - args.audio.keys.each { |k| - s = args.audio[k] - - if (mouse_new_down) && !mouse_in_panel && args.inputs.mouse.position.inside_rect?([s[:screenx], s[:screeny], $boxsize, $boxsize]) - args.state.selected = k - args.state.dragging_source = true - end - - isselected = (k == args.state.selected) - - if isselected && args.state.dragging_source - # you can hang anything on the audio hashes you want, so we store the - # actual screen position so it doesn't scale weirdly vs your mouse. - s[:screenx] = args.inputs.mouse.x - ($boxsize / 2) - s[:screeny] = args.inputs.mouse.y - ($boxsize / 2) - - s[:screeny] = 50 if s[:screeny] < 50 - s[:screeny] = (719 - $boxsize) if s[:screeny] > (719 - $boxsize) - s[:screenx] = 0 if s[:screenx] < 0 - s[:screenx] = (1279 - $boxsize) if s[:screenx] > (1279 - $boxsize) - - s[:x] = ((s[:screenx] / 1279.0) * 2.0) - 1.0 # scale to -1.0 - 1.0 range - s[:y] = ((s[:screeny] / 719.0) * 2.0) - 1.0 # scale to -1.0 - 1.0 range - end - - color = isselected ? [ 0, 255, 0, 255 ] : [ 0, 0, 255, 255 ] - args.outputs.primitives << [s[:screenx], s[:screeny], $boxsize, $boxsize, *color].solid - } -end - -def render_panel args - s = args.audio[args.state.selected] - return if s.nil? - mouse_down = (args.state.mouse_held > 0) - - args.outputs.primitives << [900, 450, 340, 250, 127, 127, 200, 255].solid - args.outputs.primitives << [1075, 690, "Source ##{args.state.selected}", 3, 1, 255, 255, 255].label - args.outputs.primitives << [910, 660, 1230, 660, 255, 255, 255].line - args.outputs.primitives << [910, 650, "screen: (#{s[:screenx].to_i}, #{s[:screeny].to_i})", 0, 0, 255, 255, 255].label - args.outputs.primitives << [910, 625, "position: (#{s[:x].round(5).to_s[0..6]}, #{s[:y].round(5).to_s[0..6]})", 0, 0, 255, 255, 255].label - - slider = [1022, 586, 200, 7] - if mouse_down && args.inputs.mouse.position.inside_rect?(slider) - s[:pitch] = ((args.inputs.mouse.x - slider[0]).to_f / (slider[2]-1.0)) * 2.0 - end - slidercolor = (s[:pitch] / 2.0) * 255 - args.outputs.primitives << [*slider, slidercolor, slidercolor, slidercolor, 255].solid - args.outputs.primitives << [910, 600, "pitch: #{s[:pitch].round(3).to_s[0..2]}", 0, 0, 255, 255, 255].label - - slider = [1022, 561, 200, 7] - if mouse_down && args.inputs.mouse.position.inside_rect?(slider) - s[:gain] = (args.inputs.mouse.x - slider[0]).to_f / (slider[2]-1.0) - end - slidercolor = s[:gain] * 255 - args.outputs.primitives << [*slider, slidercolor, slidercolor, slidercolor, 255].solid - args.outputs.primitives << [910, 575, "gain: #{s[:gain].round(3).to_s[0..2]}", 0, 0, 255, 255, 255].label - - checkbox = [1022, 533, 10, 12] - if (args.state.mouse_held == 1) && args.inputs.mouse.position.inside_rect?(checkbox) - s[:looping] = !s[:looping] - end - checkboxcolor = s[:looping] ? 255 : 0 - args.outputs.primitives << [*checkbox, checkboxcolor, checkboxcolor, checkboxcolor, 255].solid - args.outputs.primitives << [910, 550, "looping:", 0, 0, 255, 255, 255].label - - checkbox = [1022, 508, 10, 12] - if (args.state.mouse_held == 1) && args.inputs.mouse.position.inside_rect?(checkbox) - s[:paused] = !s[:paused] - end - checkboxcolor = s[:paused] ? 255 : 0 - args.outputs.primitives << [*checkbox, checkboxcolor, checkboxcolor, checkboxcolor, 255].solid - args.outputs.primitives << [910, 525, "paused:", 0, 0, 255, 255, 255].label - - button = [910, 460, 320, 20] - if (args.state.mouse_held == 1) && args.inputs.mouse.position.inside_rect?(button) - args.audio.delete(args.state.selected) - args.state.selected = 0 - end - args.outputs.primitives << [*button, 255, 0, 0, 255].solid - args.outputs.primitives << [button[0] + (button[2] / 2), button[1]+20, "DELETE SOURCE", 0, 1, 255, 255, 0].label -end - -def spawn_new_sound args, num - input = nil - input = "sounds/#{num}.#{(num == 6) ? 'ogg' : 'wav'}" - - # Spawn randomly in an area that won't be covered by UI. - screenx = (rand * 600.0) + 200.0 - screeny = (rand * 400.0) + 100.0 - - args.state.next_sound_index += 1 - - # you can hang anything on the audio hashes you want, so we store the - # actual screen position in here for convenience. - args.audio[args.state.next_sound_index] = { - input: input, - screenx: screenx, - screeny: screeny, - x: ((screenx / 1279.0) * 2.0) - 1.0, # scale to -1.0 - 1.0 range - y: ((screeny / 719.0) * 2.0) - 1.0, # scale to -1.0 - 1.0 range - z: 0.0, - gain: 1.0, - pitch: 1.0, - looping: true, - paused: false - } - - args.state.selected = args.state.next_sound_index -end - -def render_launcher args - total = 6 - x = (1280 - (total * $boxsize * 3)) / 2 - y = 10 - args.outputs.primitives << [0, 0, 1280, ((y*2) + $boxsize), 127, 127, 127, 255].solid - for i in 1..total - args.outputs.primitives << [x, y, $boxsize, $boxsize, 255, 255, 255, 255].solid - args.outputs.primitives << [x+8, y+28, i.to_s, 3, 0, 0, 0, 255, 255].label - if args.inputs.mouse.click && args.inputs.mouse.click.point.inside_rect?([x, y, $boxsize, $boxsize]) - spawn_new_sound args, i - end - x = x + ($boxsize * 3) - end -end - -def render_ui args - render_launcher args - render_panel args -end - -def tick args - args.state.mouse_held ||= 0 - args.state.dragging_source ||= false - args.state.selected ||= 0 - args.state.next_sound_index ||= 0 - - if args.inputs.mouse.up - args.state.mouse_held = 0 - args.state.dragging_source = false - elsif args.inputs.mouse.down || (args.state.mouse_held > 0) - args.state.mouse_held += 1 - else - end - - args.outputs.background_color = [ 0, 0, 0, 255 ] - render_sources args - render_ui args -end diff --git a/samples/01_rendering_basics/06_audio_mixer/license-for-audio.txt b/samples/01_rendering_basics/06_audio_mixer/license-for-audio.txt deleted file mode 100644 index f05c25c..0000000 --- a/samples/01_rendering_basics/06_audio_mixer/license-for-audio.txt +++ /dev/null @@ -1,48 +0,0 @@ -The audio files in this sample are used under various Creative Common licenses: - - -sounds/1.wav: - - Party Pack, Horn Coil 01, Long, 01.wav by InspectorJ (www.jshaw.co.uk) of Freesound.org - (We converted this to mono output.) - Original: https://freesound.org/s/484267/ - License: https://creativecommons.org/licenses/by/3.0/ - - -sounds/2.wav: - - SPLASH.wav by petenice - Original: https://freesound.org/s/9508/ - License: https://creativecommons.org/publicdomain/zero/1.0/ - - -sounds/3.wav: - - buzz roll.wav by bigjoedrummer - (We converted this to mono output.) - Original: https://freesound.org/s/77305/ - License: https://creativecommons.org/publicdomain/zero/1.0/ - - -sounds/4.wav: - - sword04.wav by Erdie - Original: https://freesound.org/s/27858/ - License: https://creativecommons.org/licenses/by/3.0/ - - -sounds/5.wav: - - Game Over Arcade.wav by myfox14 - (We converted this to mono output.) - Original: https://freesound.org/s/382310/ - License: https://creativecommons.org/publicdomain/zero/1.0/ - - -sounds/6.ogg: - - Arcade Music Loop.wav by joshuaempyre ( https://www.empyreanma.com/welcome ) - (We converted this to Ogg Vorbis format, and mono output.) - Original: https://freesound.org/s/251461/ - License: https://creativecommons.org/licenses/by/3.0/ - diff --git a/samples/01_rendering_basics/06_audio_mixer/license-for-sample.txt b/samples/01_rendering_basics/06_audio_mixer/license-for-sample.txt deleted file mode 100644 index 100dcec..0000000 --- a/samples/01_rendering_basics/06_audio_mixer/license-for-sample.txt +++ /dev/null @@ -1,9 +0,0 @@ -Copyright 2019 DragonRuby LLC - -MIT License - -Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/samples/01_rendering_basics/06_audio_mixer/sounds/1.wav b/samples/01_rendering_basics/06_audio_mixer/sounds/1.wav deleted file mode 100644 index 8aa1be3..0000000 Binary files a/samples/01_rendering_basics/06_audio_mixer/sounds/1.wav and /dev/null differ diff --git a/samples/01_rendering_basics/06_audio_mixer/sounds/2.wav b/samples/01_rendering_basics/06_audio_mixer/sounds/2.wav deleted file mode 100644 index 52a09c2..0000000 Binary files a/samples/01_rendering_basics/06_audio_mixer/sounds/2.wav and /dev/null differ diff --git a/samples/01_rendering_basics/06_audio_mixer/sounds/3.wav b/samples/01_rendering_basics/06_audio_mixer/sounds/3.wav deleted file mode 100644 index c7bde27..0000000 Binary files a/samples/01_rendering_basics/06_audio_mixer/sounds/3.wav and /dev/null differ diff --git a/samples/01_rendering_basics/06_audio_mixer/sounds/4.wav b/samples/01_rendering_basics/06_audio_mixer/sounds/4.wav deleted file mode 100644 index 193cf54..0000000 Binary files a/samples/01_rendering_basics/06_audio_mixer/sounds/4.wav and /dev/null differ diff --git a/samples/01_rendering_basics/06_audio_mixer/sounds/5.wav b/samples/01_rendering_basics/06_audio_mixer/sounds/5.wav deleted file mode 100644 index 112f3cc..0000000 Binary files a/samples/01_rendering_basics/06_audio_mixer/sounds/5.wav and /dev/null differ diff --git a/samples/01_rendering_basics/06_audio_mixer/sounds/6.ogg b/samples/01_rendering_basics/06_audio_mixer/sounds/6.ogg deleted file mode 100644 index a952191..0000000 Binary files a/samples/01_rendering_basics/06_audio_mixer/sounds/6.ogg and /dev/null differ diff --git a/samples/01_rendering_basics/07_sound_synthesis/app/main.rb b/samples/01_rendering_basics/07_sound_synthesis/app/main.rb deleted file mode 100644 index 391ce68..0000000 --- a/samples/01_rendering_basics/07_sound_synthesis/app/main.rb +++ /dev/null @@ -1,593 +0,0 @@ -begin # region: top level tick methods - def tick args - defaults args - render args - input args - process_audio_queue args - end - - def defaults args - args.state.sine_waves ||= {} - args.state.square_waves ||= {} - args.state.saw_tooth_waves ||= {} - args.state.triangle_waves ||= {} - args.state.audio_queue ||= [] - args.state.buttons ||= [ - (frequency_buttons args), - (sine_wave_note_buttons args), - (bell_buttons args), - (square_wave_note_buttons args), - (saw_tooth_wave_note_buttons args), - (triangle_wave_note_buttons args), - ].flatten - end - - def render args - args.outputs.borders << args.state.buttons.map { |b| b[:border] } - args.outputs.labels << args.state.buttons.map { |b| b[:label] } - args.outputs.labels << args.layout - .rect(row: 0, col: 11.5) - .yield_self { |r| r.merge y: r.y + r.h } - .merge(text: "This is a Pro only feature. Click here to watch the YouTube video if you are on the Standard License.", - alignment_enum: 1) - end - - - def input args - args.state.buttons.each do |b| - if args.inputs.mouse.click.inside_rect? b[:rect] - parameter_string = (b.slice :frequency, :note, :octave).map { |k, v| "#{k}: #{v}" }.join ", " - args.gtk.notify! "#{b[:method_to_call]} #{parameter_string}" - send b[:method_to_call], args, b - end - end - - if args.inputs.mouse.click.inside_rect? (args.layout.rect(row: 0).yield_self { |r| r.merge y: r.y + r.h.half, h: r.h.half }) - args.gtk.openurl 'https://www.youtube.com/watch?v=zEzovM5jT-k&ab_channel=AmirRajan' - end - end - - def process_audio_queue args - to_queue = args.state.audio_queue.find_all { |v| v[:queue_at] <= args.tick_count } - args.state.audio_queue -= to_queue - to_queue.each { |a| args.audio[a[:id]] = a } - - args.audio.find_all { |k, v| v[:decay_rate] } - .each { |k, v| v[:gain] -= v[:decay_rate] } - - sounds_to_stop = args.audio - .find_all { |k, v| v[:stop_at] && args.state.tick_count >= v[:stop_at] } - .map { |k, v| k } - - sounds_to_stop.each { |k| args.audio.delete k } - end -end - -begin # region: button definitions, ui layout, callback functions - def button args, opts - button_def = opts.merge rect: (args.layout.rect (opts.merge w: 2, h: 1)) - - button_def[:border] = button_def[:rect].merge r: 0, g: 0, b: 0 - - label_offset_x = 5 - label_offset_y = 30 - - button_def[:label] = button_def[:rect].merge text: opts[:text], - size_enum: -2.5, - x: button_def[:rect].x + label_offset_x, - y: button_def[:rect].y + label_offset_y - - button_def - end - - def play_sine_wave args, sender - queue_sine_wave args, - frequency: sender[:frequency], - duration: 1.seconds, - fade_out: true - end - - def play_note args, sender - method_to_call = :queue_sine_wave - method_to_call = :queue_square_wave if sender[:type] == :square - method_to_call = :queue_saw_tooth_wave if sender[:type] == :saw_tooth - method_to_call = :queue_triangle_wave if sender[:type] == :triangle - method_to_call = :queue_bell if sender[:type] == :bell - - send method_to_call, args, - frequency: (frequency_for note: sender[:note], octave: sender[:octave]), - duration: 1.seconds, - fade_out: true - end - - def frequency_buttons args - [ - (button args, - row: 4.0, col: 0, text: "300hz", - frequency: 300, - method_to_call: :play_sine_wave), - (button args, - row: 5.0, col: 0, text: "400hz", - frequency: 400, - method_to_call: :play_sine_wave), - (button args, - row: 6.0, col: 0, text: "500hz", - frequency: 500, - method_to_call: :play_sine_wave), - ] - end - - def sine_wave_note_buttons args - [ - (button args, - row: 1.5, col: 2, text: "Sine C4", - note: :c, octave: 4, type: :sine, method_to_call: :play_note), - (button args, - row: 2.5, col: 2, text: "Sine D4", - note: :d, octave: 4, type: :sine, method_to_call: :play_note), - (button args, - row: 3.5, col: 2, text: "Sine E4", - note: :e, octave: 4, type: :sine, method_to_call: :play_note), - (button args, - row: 4.5, col: 2, text: "Sine F4", - note: :f, octave: 4, type: :sine, method_to_call: :play_note), - (button args, - row: 5.5, col: 2, text: "Sine G4", - note: :g, octave: 4, type: :sine, method_to_call: :play_note), - (button args, - row: 6.5, col: 2, text: "Sine A5", - note: :a, octave: 5, type: :sine, method_to_call: :play_note), - (button args, - row: 7.5, col: 2, text: "Sine B5", - note: :b, octave: 5, type: :sine, method_to_call: :play_note), - (button args, - row: 8.5, col: 2, text: "Sine C5", - note: :c, octave: 5, type: :sine, method_to_call: :play_note), - ] - end - - def square_wave_note_buttons args - [ - (button args, - row: 1.5, col: 6, text: "Square C4", - note: :c, octave: 4, type: :square, method_to_call: :play_note), - (button args, - row: 2.5, col: 6, text: "Square D4", - note: :d, octave: 4, type: :square, method_to_call: :play_note), - (button args, - row: 3.5, col: 6, text: "Square E4", - note: :e, octave: 4, type: :square, method_to_call: :play_note), - (button args, - row: 4.5, col: 6, text: "Square F4", - note: :f, octave: 4, type: :square, method_to_call: :play_note), - (button args, - row: 5.5, col: 6, text: "Square G4", - note: :g, octave: 4, type: :square, method_to_call: :play_note), - (button args, - row: 6.5, col: 6, text: "Square A5", - note: :a, octave: 5, type: :square, method_to_call: :play_note), - (button args, - row: 7.5, col: 6, text: "Square B5", - note: :b, octave: 5, type: :square, method_to_call: :play_note), - (button args, - row: 8.5, col: 6, text: "Square C5", - note: :c, octave: 5, type: :square, method_to_call: :play_note), - ] - end - def saw_tooth_wave_note_buttons args - [ - (button args, - row: 1.5, col: 8, text: "Saw C4", - note: :c, octave: 4, type: :saw_tooth, method_to_call: :play_note), - (button args, - row: 2.5, col: 8, text: "Saw D4", - note: :d, octave: 4, type: :saw_tooth, method_to_call: :play_note), - (button args, - row: 3.5, col: 8, text: "Saw E4", - note: :e, octave: 4, type: :saw_tooth, method_to_call: :play_note), - (button args, - row: 4.5, col: 8, text: "Saw F4", - note: :f, octave: 4, type: :saw_tooth, method_to_call: :play_note), - (button args, - row: 5.5, col: 8, text: "Saw G4", - note: :g, octave: 4, type: :saw_tooth, method_to_call: :play_note), - (button args, - row: 6.5, col: 8, text: "Saw A5", - note: :a, octave: 5, type: :saw_tooth, method_to_call: :play_note), - (button args, - row: 7.5, col: 8, text: "Saw B5", - note: :b, octave: 5, type: :saw_tooth, method_to_call: :play_note), - (button args, - row: 8.5, col: 8, text: "Saw C5", - note: :c, octave: 5, type: :saw_tooth, method_to_call: :play_note), - ] - end - - def triangle_wave_note_buttons args - [ - (button args, - row: 1.5, col: 10, text: "Triangle C4", - note: :c, octave: 4, type: :triangle, method_to_call: :play_note), - (button args, - row: 2.5, col: 10, text: "Triangle D4", - note: :d, octave: 4, type: :triangle, method_to_call: :play_note), - (button args, - row: 3.5, col: 10, text: "Triangle E4", - note: :e, octave: 4, type: :triangle, method_to_call: :play_note), - (button args, - row: 4.5, col: 10, text: "Triangle F4", - note: :f, octave: 4, type: :triangle, method_to_call: :play_note), - (button args, - row: 5.5, col: 10, text: "Triangle G4", - note: :g, octave: 4, type: :triangle, method_to_call: :play_note), - (button args, - row: 6.5, col: 10, text: "Triangle A5", - note: :a, octave: 5, type: :triangle, method_to_call: :play_note), - (button args, - row: 7.5, col: 10, text: "Triangle B5", - note: :b, octave: 5, type: :triangle, method_to_call: :play_note), - (button args, - row: 8.5, col: 10, text: "Triangle C5", - note: :c, octave: 5, type: :triangle, method_to_call: :play_note), - ] - end - - def bell_buttons args - [ - (button args, - row: 1.5, col: 4, text: "Bell C4", - note: :c, octave: 4, type: :bell, method_to_call: :play_note), - (button args, - row: 2.5, col: 4, text: "Bell D4", - note: :d, octave: 4, type: :bell, method_to_call: :play_note), - (button args, - row: 3.5, col: 4, text: "Bell E4", - note: :e, octave: 4, type: :bell, method_to_call: :play_note), - (button args, - row: 4.5, col: 4, text: "Bell F4", - note: :f, octave: 4, type: :bell, method_to_call: :play_note), - (button args, - row: 5.5, col: 4, text: "Bell G4", - note: :g, octave: 4, type: :bell, method_to_call: :play_note), - (button args, - row: 6.5, col: 4, text: "Bell A5", - note: :a, octave: 5, type: :bell, method_to_call: :play_note), - (button args, - row: 7.5, col: 4, text: "Bell B5", - note: :b, octave: 5, type: :bell, method_to_call: :play_note), - (button args, - row: 8.5, col: 4, text: "Bell C5", - note: :c, octave: 5, type: :bell, method_to_call: :play_note), - ] - end -end - -begin # region: wave generation - begin # sine wave - def defaults_sine_wave_for - { frequency: 440, sample_rate: 48000 } - end - - def sine_wave_for opts = {} - opts = defaults_sine_wave_for.merge opts - frequency = opts[:frequency] - sample_rate = opts[:sample_rate] - period_size = (sample_rate.fdiv frequency).ceil - period_size.map_with_index do |i| - Math::sin((2.0 * Math::PI) / (sample_rate.to_f / frequency.to_f) * i) - end.to_a - end - - def defaults_queue_sine_wave - { frequency: 440, duration: 60, gain: 1.0, fade_out: false, queue_in: 0 } - end - - def queue_sine_wave args, opts = {} - opts = defaults_queue_sine_wave.merge opts - frequency = opts[:frequency] - sample_rate = 48000 - - sine_wave = sine_wave_for frequency: frequency, sample_rate: sample_rate - args.state.sine_waves[frequency] ||= sine_wave_for frequency: frequency, sample_rate: sample_rate - - proc = lambda do - generate_audio_data args.state.sine_waves[frequency], sample_rate - end - - audio_state = new_audio_state args, opts - audio_state[:input] = [1, sample_rate, proc] - queue_audio args, audio_state: audio_state, wave: sine_wave - end - end - - begin # region: square wave - def defaults_square_wave_for - { frequency: 440, sample_rate: 48000 } - end - - def square_wave_for opts = {} - opts = defaults_square_wave_for.merge opts - sine_wave = sine_wave_for opts - sine_wave.map do |v| - if v >= 0 - 1.0 - else - -1.0 - end - end.to_a - end - - def defaults_queue_square_wave - { frequency: 440, duration: 60, gain: 0.3, fade_out: false, queue_in: 0 } - end - - def queue_square_wave args, opts = {} - opts = defaults_queue_square_wave.merge opts - frequency = opts[:frequency] - sample_rate = 48000 - - square_wave = square_wave_for frequency: frequency, sample_rate: sample_rate - args.state.square_waves[frequency] ||= square_wave_for frequency: frequency, sample_rate: sample_rate - - proc = lambda do - generate_audio_data args.state.square_waves[frequency], sample_rate - end - - audio_state = new_audio_state args, opts - audio_state[:input] = [1, sample_rate, proc] - queue_audio args, audio_state: audio_state, wave: square_wave - end - end - - begin # region: saw tooth wave - def defaults_saw_tooth_wave_for - { frequency: 440, sample_rate: 48000 } - end - - def saw_tooth_wave_for opts = {} - opts = defaults_saw_tooth_wave_for.merge opts - sine_wave = sine_wave_for opts - period_size = sine_wave.length - sine_wave.map_with_index do |v, i| - (((i % period_size).fdiv period_size) * 2) - 1 - end - end - - def defaults_queue_saw_tooth_wave - { frequency: 440, duration: 60, gain: 0.3, fade_out: false, queue_in: 0 } - end - - def queue_saw_tooth_wave args, opts = {} - opts = defaults_queue_saw_tooth_wave.merge opts - frequency = opts[:frequency] - sample_rate = 48000 - - saw_tooth_wave = saw_tooth_wave_for frequency: frequency, sample_rate: sample_rate - args.state.saw_tooth_waves[frequency] ||= saw_tooth_wave_for frequency: frequency, sample_rate: sample_rate - - proc = lambda do - generate_audio_data args.state.saw_tooth_waves[frequency], sample_rate - end - - audio_state = new_audio_state args, opts - audio_state[:input] = [1, sample_rate, proc] - queue_audio args, audio_state: audio_state, wave: saw_tooth_wave - end - end - - begin # region: triangle wave - def defaults_triangle_wave_for - { frequency: 440, sample_rate: 48000 } - end - - def triangle_wave_for opts = {} - opts = defaults_saw_tooth_wave_for.merge opts - sine_wave = sine_wave_for opts - period_size = sine_wave.length - sine_wave.map_with_index do |v, i| - ratio = (i.fdiv period_size) - if ratio <= 0.5 - (ratio * 4) - 1 - else - ratio -= 0.5 - 1 - (ratio * 4) - end - end - end - - def defaults_queue_triangle_wave - { frequency: 440, duration: 60, gain: 1.0, fade_out: false, queue_in: 0 } - end - - def queue_triangle_wave args, opts = {} - opts = defaults_queue_triangle_wave.merge opts - frequency = opts[:frequency] - sample_rate = 48000 - - triangle_wave = triangle_wave_for frequency: frequency, sample_rate: sample_rate - args.state.triangle_waves[frequency] ||= triangle_wave_for frequency: frequency, sample_rate: sample_rate - - proc = lambda do - generate_audio_data args.state.triangle_waves[frequency], sample_rate - end - - audio_state = new_audio_state args, opts - audio_state[:input] = [1, sample_rate, proc] - queue_audio args, audio_state: audio_state, wave: triangle_wave - end - end - - begin # region: bell - def defaults_queue_bell - { frequency: 440, duration: 1.seconds, queue_in: 0 } - end - - def queue_bell args, opts = {} - (bell_to_sine_waves (defaults_queue_bell.merge opts)).each { |b| queue_sine_wave args, b } - end - - def bell_harmonics - [ - { frequency_ratio: 0.5, duration_ratio: 1.00 }, - { frequency_ratio: 1.0, duration_ratio: 0.80 }, - { frequency_ratio: 2.0, duration_ratio: 0.60 }, - { frequency_ratio: 3.0, duration_ratio: 0.40 }, - { frequency_ratio: 4.2, duration_ratio: 0.25 }, - { frequency_ratio: 5.4, duration_ratio: 0.20 }, - { frequency_ratio: 6.8, duration_ratio: 0.15 } - ] - end - - def defaults_bell_to_sine_waves - { frequency: 440, duration: 1.seconds, queue_in: 0 } - end - - def bell_to_sine_waves opts = {} - opts = defaults_bell_to_sine_waves.merge opts - bell_harmonics.map do |b| - { - frequency: opts[:frequency] * b[:frequency_ratio], - duration: opts[:duration] * b[:duration_ratio], - queue_in: opts[:queue_in], - gain: (1.fdiv bell_harmonics.length), - fade_out: true - } - end - end - end - - begin # audio entity construction - def generate_audio_data sine_wave, sample_rate - sample_size = (sample_rate.fdiv (1000.fdiv 60)).ceil - copy_count = (sample_size.fdiv sine_wave.length).ceil - sine_wave * copy_count - end - - def defaults_new_audio_state - { frequency: 440, duration: 60, gain: 1.0, fade_out: false, queue_in: 0 } - end - - def new_audio_state args, opts = {} - opts = defaults_new_audio_state.merge opts - decay_rate = 0 - decay_rate = 1.fdiv(opts[:duration]) * opts[:gain] if opts[:fade_out] - frequency = opts[:frequency] - sample_rate = 48000 - - { - id: (new_id! args), - frequency: frequency, - sample_rate: 48000, - stop_at: args.tick_count + opts[:queue_in] + opts[:duration], - gain: opts[:gain].to_f, - queue_at: args.state.tick_count + opts[:queue_in], - decay_rate: decay_rate, - pitch: 1.0, - looping: true, - paused: false - } - end - - def queue_audio args, opts = {} - graph_wave args, opts[:wave], opts[:audio_state][:frequency] - args.state.audio_queue << opts[:audio_state] - end - - def new_id! args - args.state.audio_id ||= 0 - args.state.audio_id += 1 - end - - def graph_wave args, wave, frequency - if args.state.tick_count != args.state.graphed_at - args.outputs.static_lines.clear - args.outputs.static_sprites.clear - end - - wave = wave - - r, g, b = frequency.to_i % 85, - frequency.to_i % 170, - frequency.to_i % 255 - - starting_rect = args.layout.rect(row: 5, col: 13) - x_scale = 10 - y_scale = 100 - max_points = 25 - - points = wave - if wave.length > max_points - resolution = wave.length.idiv max_points - points = wave.find_all.with_index { |y, i| (i % resolution == 0) } - end - - args.outputs.static_lines << points.map_with_index do |y, x| - next_y = points[x + 1] - - if next_y - { - x: starting_rect.x + (x * x_scale), - y: starting_rect.y + starting_rect.h.half + y_scale * y, - x2: starting_rect.x + ((x + 1) * x_scale), - y2: starting_rect.y + starting_rect.h.half + y_scale * next_y, - r: r, - g: g, - b: b - } - end - end - - args.outputs.static_sprites << points.map_with_index do |y, x| - { - x: (starting_rect.x + (x * x_scale)) - 2, - y: (starting_rect.y + starting_rect.h.half + y_scale * y) - 2, - w: 4, - h: 4, - path: 'sprites/square-white.png', - r: r, - g: g, - b: b - } - end - - args.state.graphed_at = args.state.tick_count - end - end - - begin # region: musical note mapping - def defaults_frequency_for - { note: :a, octave: 5, sharp: false, flat: false } - end - - def frequency_for opts = {} - opts = defaults_frequency_for.merge opts - octave_offset_multiplier = opts[:octave] - 5 - note = note_frequencies_octave_5[opts[:note]] - if octave_offset_multiplier < 0 - note = note * 1 / (octave_offset_multiplier.abs + 1) - elsif octave_offset_multiplier > 0 - note = note * (octave_offset_multiplier.abs + 1) / 1 - end - note - end - - def note_frequencies_octave_5 - { - a: 440.0, - a_sharp: 466.16, b_flat: 466.16, - b: 493.88, - c: 523.25, - c_sharp: 554.37, d_flat: 587.33, - d: 587.33, - d_sharp: 622.25, e_flat: 659.25, - e: 659.25, - f: 698.25, - f_sharp: 739.99, g_flat: 739.99, - g: 783.99, - g_sharp: 830.61, a_flat: 830.61 - } - end - end -end - -$gtk.reset diff --git a/samples/01_rendering_basics/07_sound_synthesis/license-for-sample.txt b/samples/01_rendering_basics/07_sound_synthesis/license-for-sample.txt deleted file mode 100644 index 100dcec..0000000 --- a/samples/01_rendering_basics/07_sound_synthesis/license-for-sample.txt +++ /dev/null @@ -1,9 +0,0 @@ -Copyright 2019 DragonRuby LLC - -MIT License - -Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/samples/01_rendering_basics/07_sound_synthesis/metadata/game_metadata.txt b/samples/01_rendering_basics/07_sound_synthesis/metadata/game_metadata.txt deleted file mode 100644 index 16cef1d..0000000 --- a/samples/01_rendering_basics/07_sound_synthesis/metadata/game_metadata.txt +++ /dev/null @@ -1,6 +0,0 @@ -devid=amirrajan -devtitle=Amir Rajan -gameid=hello-world -gametitle=Hello World -version=1.0 -icon=metadata/icon.png diff --git a/samples/01_rendering_basics/07_sound_synthesis/metadata/icon.png b/samples/01_rendering_basics/07_sound_synthesis/metadata/icon.png deleted file mode 100644 index e20e8c2..0000000 Binary files a/samples/01_rendering_basics/07_sound_synthesis/metadata/icon.png and /dev/null differ diff --git a/samples/01_rendering_basics/07_sound_synthesis/sprites/square-black.png b/samples/01_rendering_basics/07_sound_synthesis/sprites/square-black.png deleted file mode 100644 index cea7bd7..0000000 Binary files a/samples/01_rendering_basics/07_sound_synthesis/sprites/square-black.png and /dev/null differ diff --git a/samples/01_rendering_basics/07_sound_synthesis/sprites/square-white.png b/samples/01_rendering_basics/07_sound_synthesis/sprites/square-white.png deleted file mode 100644 index 378c565..0000000 Binary files a/samples/01_rendering_basics/07_sound_synthesis/sprites/square-white.png and /dev/null differ diff --git a/samples/02_input_basics/01_keyboard/app/main.rb b/samples/02_input_basics/01_keyboard/app/main.rb index d0321ef..f97c134 100644 --- a/samples/02_input_basics/01_keyboard/app/main.rb +++ b/samples/02_input_basics/01_keyboard/app/main.rb @@ -4,7 +4,8 @@ APIs listing that haven't been encountered in a previous sample apps: - args.inputs.keyboard.key_up.KEY: The value of the properties will be set to the frame that the key_up event occurred (the frame correlates - to args.state.tick_count). Otherwise the value will be nil. + to args.state.tick_count). Otherwise the value will be nil. For a + full listing of keys, take a look at mygame/documentation/06-keyboard.md. - args.state.PROPERTY: The state property on args is a dynamic structure. You can define ANY property here with ANY type of arbitrary nesting. Properties defined on args.state will be retained @@ -24,11 +25,11 @@ APIs listing that haven't been encountered in a previous sample apps: def tick args tick_instructions args, "Sample app shows how keyboard events are registered and accessed.", 360 # Notice how small_font accounts for all the remaining parameters - args.outputs.labels << [460, row_to_px(args, 0), "Current game time: #{args.state.tick_count}", small_font] - args.outputs.labels << [460, row_to_px(args, 2), "Keyboard input: args.inputs.keyboard.key_up.h", small_font] - args.outputs.labels << [460, row_to_px(args, 3), "Press \"h\" on the keyboard.", small_font] + args.outputs.labels << { x: 460, y: row_to_px(args, 0), text: "Current game time: #{args.state.tick_count}", size_enum: -1 } + args.outputs.labels << { x: 460, y: row_to_px(args, 2), text: "Keyboard input: args.inputs.keyboard.key_up.h", size_enum: -1 } + args.outputs.labels << { x: 460, y: row_to_px(args, 3), text: "Press \"h\" on the keyboard.", size_enum: -1 } - # Input on a specific key can be found through args.inputs.keyboard.key_up followed by the key + # Input on a specifc key can be found through args.inputs.keyboard.key_up followed by the key if args.inputs.keyboard.key_up.h args.state.h_pressed_at = args.state.tick_count end @@ -37,27 +38,19 @@ def tick args args.state.h_pressed_at ||= false if args.state.h_pressed_at - args.outputs.labels << [460, row_to_px(args, 4), "\"h\" was pressed at time: #{args.state.h_pressed_at}", small_font] + args.outputs.labels << { x: 460, y: row_to_px(args, 4), text: "\"h\" was pressed at time: #{args.state.h_pressed_at}", size_enum: -1 } else - args.outputs.labels << [460, row_to_px(args, 4), "\"h\" has never been pressed.", small_font] + args.outputs.labels << { x: 460, y: row_to_px(args, 4), text: "\"h\" has never been pressed.", size_enum: -1 } end tick_help_text args end -def small_font - # This method provides some values for the construction of labels - # Specifically, Size, Alignment, & RGBA - # This makes it so that custom parameters don't have to be repeatedly typed. - # Additionally "small_font" provides programmers with more information than some numbers - [-2, 0, 0, 0, 0, 255] -end - -def row_to_px args, row_number +def row_to_px args, row_number, y_offset = 20 # This takes a row_number and converts it to pixels DragonRuby understands. # Row 0 starts 5 units below the top of the grid # Each row afterward is 20 units lower - args.grid.top.shift_down(5).shift_down(20 * row_number) + args.grid.top - 5 - (y_offset * row_number) end # Don't worry about understanding the code within this method just yet. @@ -87,17 +80,17 @@ def tick_help_text args end end - args.outputs.labels << [10, row_to_px(args, 6), "Advanced Help:", small_font] + args.outputs.labels << { x: 10, y: row_to_px(args, 6), text: "This is the api for the keys you've pressed:", size_enum: -1, r: 180 } if !args.state.help_available args.outputs.labels << [10, row_to_px(args, 7), "Press a key and I'll show code to access the key and what value will be returned if you used the code.", small_font] return end - args.outputs.labels << [10 , row_to_px(args, 7), "args.inputs.keyboard", small_font] - args.outputs.labels << [330, row_to_px(args, 7), "args.inputs.keyboard.key_down", small_font] - args.outputs.labels << [650, row_to_px(args, 7), "args.inputs.keyboard.key_held", small_font] - args.outputs.labels << [990, row_to_px(args, 7), "args.inputs.keyboard.key_up", small_font] + args.outputs.labels << { x: 10 , y: row_to_px(args, 7), text: "args.inputs.keyboard", size_enum: -2 } + args.outputs.labels << { x: 330, y: row_to_px(args, 7), text: "args.inputs.keyboard.key_down", size_enum: -2 } + args.outputs.labels << { x: 650, y: row_to_px(args, 7), text: "args.inputs.keyboard.key_held", size_enum: -2 } + args.outputs.labels << { x: 990, y: row_to_px(args, 7), text: "args.inputs.keyboard.key_up", size_enum: -2 } fill_history args, :key_value_history, :down_or_held, nil fill_history args, :key_down_value_history, :down, :key_down @@ -143,12 +136,8 @@ def render_help_labels args, history_key, state_key, keyboard_method, x end idx += 2 [ - [x, row_to_px(args, idx - 2), - " .#{k} is #{current_value || "nil"}", - small_font], - [x, row_to_px(args, idx - 1), - " was #{v}", - small_font] + { x: x, y: row_to_px(args, idx + 0, 16), text: " .#{k} is #{current_value || "nil"}", size_enum: -2 }, + { x: x, y: row_to_px(args, idx + 1, 16), text: " was #{v}", size_enum: -2 } ] end end @@ -163,7 +152,9 @@ def tick_instructions args, text, y = 715 args.state.key_event_occurred = true end - args.outputs.debug << [0, y - 50, 1280, 60].solid - args.outputs.debug << [640, y, text, 1, 1, 255, 255, 255].label - args.outputs.debug << [640, y - 25, "(click to dismiss instructions)" , -2, 1, 255, 255, 255].label + args.outputs.debug << { x: 0, y: y - 50, w: 1280, h: 60 }.solid! + args.outputs.debug << { x: 640, y: y, text: text, + size_enum: 1, alignment_enum: 1, r: 255, g: 255, b: 255 }.label! + args.outputs.debug << { x: 640, y: y - 25, text: "(click to dismiss instructions)", + size_enum: -2, alignment_enum: 1, r: 255, g: 255, b: 255 }.label! end diff --git a/samples/02_input_basics/01_moving_a_sprite/app/main.rb b/samples/02_input_basics/01_moving_a_sprite/app/main.rb new file mode 100644 index 0000000..da699a0 --- /dev/null +++ b/samples/02_input_basics/01_moving_a_sprite/app/main.rb @@ -0,0 +1,30 @@ +def tick args + # create a player and set default values + # for the player's x, y, w (width), and h (height) + args.state.player.x ||= 100 + args.state.player.y ||= 100 + args.state.player.w ||= 50 + args.state.player.h ||= 50 + + # render the player to the screen + args.outputs.sprites << { x: args.state.player.x, + y: args.state.player.y, + w: args.state.player.w, + h: args.state.player.h, + path: 'sprites/square/green.png' } + + # move the player around using the keyboard + if args.inputs.up + args.state.player.y += 10 + elsif args.inputs.down + args.state.player.y -= 10 + end + + if args.inputs.left + args.state.player.x -= 10 + elsif args.inputs.right + args.state.player.x += 10 + end +end + +$gtk.reset diff --git a/samples/02_input_basics/01_moving_a_sprite/license-for-sample.txt b/samples/02_input_basics/01_moving_a_sprite/license-for-sample.txt new file mode 100644 index 0000000..100dcec --- /dev/null +++ b/samples/02_input_basics/01_moving_a_sprite/license-for-sample.txt @@ -0,0 +1,9 @@ +Copyright 2019 DragonRuby LLC + +MIT License + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/samples/02_input_basics/01_moving_a_sprite/sprites/square/green.png b/samples/02_input_basics/01_moving_a_sprite/sprites/square/green.png new file mode 100644 index 0000000..5ef7f75 Binary files /dev/null and b/samples/02_input_basics/01_moving_a_sprite/sprites/square/green.png differ diff --git a/samples/02_input_basics/02_mouse/app/main.rb b/samples/02_input_basics/02_mouse/app/main.rb index 43217f5..823336c 100644 --- a/samples/02_input_basics/02_mouse/app/main.rb +++ b/samples/02_input_basics/02_mouse/app/main.rb @@ -61,11 +61,7 @@ def small_label args, x, row, message # This method effectively combines the row_to_px and small_font methods # It changes the given row value to a DragonRuby pixel value # and adds the customization parameters - [x, row_to_px(args, row), message, small_font] -end - -def small_font - [-2, 0, 0, 0, 0, 255] + { x: x, y: row_to_px(args, row), text: message, alignment_enum: -2 } end def row_to_px args, row_number @@ -81,7 +77,7 @@ def tick_instructions args, text, y = 715 args.state.key_event_occurred = true end - args.outputs.debug << [0, y - 50, 1280, 60].solid - args.outputs.debug << [640, y, text, 1, 1, 255, 255, 255].label - args.outputs.debug << [640, y - 25, "(click to dismiss instructions)" , -2, 1, 255, 255, 255].label + args.outputs.debug << { x: 0, y: y - 50, w: 1280, h: 60 }.solid! + args.outputs.debug << { x: 640, y: y, text: text, size_enum: 1, alignment_enum: 1, r: 255, g: 255, b: 255 }.label! + args.outputs.debug << { x: 640, y: y - 25, text: "(click to dismiss instructions)", size_enum: -2, alignment_enum: 1, r: 255, g: 255, b: 255 }.label! end diff --git a/samples/02_input_basics/03_mouse_point_to_rect/app/main.rb b/samples/02_input_basics/03_mouse_point_to_rect/app/main.rb index 1e30943..7d4394c 100644 --- a/samples/02_input_basics/03_mouse_point_to_rect/app/main.rb +++ b/samples/02_input_basics/03_mouse_point_to_rect/app/main.rb @@ -36,13 +36,13 @@ APIs that haven't been encountered in a previous sample apps: # This is useful to determine if a click occurred in a rect def tick args - tick_instructions args, "Sample app shows how to determine if a click happened inside a rectangle." + tick_instructions args, "Sample app shows how to determing if a click happened inside a rectangle." x = 460 args.outputs.labels << small_label(args, x, 15, "Click inside the blue box maybe ---->") - box = [785, 370, 50, 50, 0, 0, 170] + box = { x: 785, y: 370, w: 50, h: 50, r: 0, g: 0, b: 170 } args.outputs.borders << box # Saves the most recent click into args.state @@ -64,11 +64,7 @@ def tick args end def small_label args, x, row, message - [x, row_to_px(args, row), message, small_font] -end - -def small_font - [-2, 0, 0, 0, 0, 255] + { x: x, y: row_to_px(args, row), text: message, size_enum: -2 } end def row_to_px args, row_number @@ -84,7 +80,7 @@ def tick_instructions args, text, y = 715 args.state.key_event_occurred = true end - args.outputs.debug << [0, y - 50, 1280, 60].solid - args.outputs.debug << [640, y, text, 1, 1, 255, 255, 255].label - args.outputs.debug << [640, y - 25, "(click to dismiss instructions)" , -2, 1, 255, 255, 255].label + args.outputs.debug << { x: 0, y: y - 50, w: 1280, h: 60 }.solid! + args.outputs.debug << { x: 640, y: y, text: text, size_enum: 1, alignment_enum: 1, r: 255, g: 255, b: 255 }.label! + args.outputs.debug << { x: 640, y: y - 25, text: "(click to dismiss instructions)", size_enum: -2, alignment_enum: 1, r: 255, g: 255, b: 255 }.label! end diff --git a/samples/02_input_basics/04_mouse_rect_to_rect/app/main.rb b/samples/02_input_basics/04_mouse_rect_to_rect/app/main.rb index 1a00a41..8250598 100644 --- a/samples/02_input_basics/04_mouse_rect_to_rect/app/main.rb +++ b/samples/02_input_basics/04_mouse_rect_to_rect/app/main.rb @@ -42,9 +42,15 @@ def tick args # They are stored in game so that they do not get reset every tick if args.inputs.mouse.click if !args.state.box_collision_one - args.state.box_collision_one = [args.inputs.mouse.click.point.x - 25, args.inputs.mouse.click.point.y - 25, 125, 125, 180, 0, 0, 180] + args.state.box_collision_one = { x: args.inputs.mouse.click.point.x - 25, + y: args.inputs.mouse.click.point.y - 25, + w: 125, h: 125, + r: 180, g: 0, b: 0, a: 180 } elsif !args.state.box_collision_two - args.state.box_collision_two = [args.inputs.mouse.click.point.x - 25, args.inputs.mouse.click.point.y - 25, 125, 125, 0, 0, 180, 180] + args.state.box_collision_two = { x: args.inputs.mouse.click.point.x - 25, + y: args.inputs.mouse.click.point.y - 25, + w: 125, h: 125, + r: 0, g: 0, b: 180, a: 180 } else args.state.box_collision_one = nil args.state.box_collision_two = nil @@ -71,15 +77,11 @@ def tick args end def small_label args, x, row, message - [x, row_to_px(args, row), message, small_font] -end - -def small_font - [-2, 0, 0, 0, 0, 255] + { x: x, y: row_to_px(args, row), text: message, size_enum: -2 } end def row_to_px args, row_number - args.grid.top.shift_down(5).shift_down(20 * row_number) + args.grid.top - 5 - (20 * row_number) end def tick_instructions args, text, y = 715 diff --git a/samples/02_input_basics/05_controller/app/main.rb b/samples/02_input_basics/05_controller/app/main.rb index c986fa9..0ca4bbb 100644 --- a/samples/02_input_basics/05_controller/app/main.rb +++ b/samples/02_input_basics/05_controller/app/main.rb @@ -7,6 +7,8 @@ If there is more than one controller being used, they can be differentiated by using names like controller_one and controller_two. + For a full listing of buttons, take a look at mygame/documentation/08-controllers.md. + Reminder: - args.state.PROPERTY: The state property on args is a dynamic @@ -40,57 +42,51 @@ class ControllerDemo def process_inputs state.buttons = [] - state.buttons << [100, 500, inputs.controller_one.key_held.l1, "L1"] - state.buttons << [100, 600, inputs.controller_one.key_held.l2, "L2"] - - state.buttons << [1100, 500, inputs.controller_one.key_held.r1, "R1"] - state.buttons << [1100, 600, inputs.controller_one.key_held.r2, "R2"] - - state.buttons << [540, 450, inputs.controller_one.key_held.select, "Select"] - state.buttons << [660, 450, inputs.controller_one.key_held.start, "Start"] - - state.buttons << [200, 300, inputs.controller_one.key_held.left, "Left"] - state.buttons << [300, 400, inputs.controller_one.key_held.up, "Up"] - state.buttons << [400, 300, inputs.controller_one.key_held.right, "Right"] - state.buttons << [300, 200, inputs.controller_one.key_held.down, "Down"] - - state.buttons << [800, 300, inputs.controller_one.key_held.x, "X"] - state.buttons << [900, 400, inputs.controller_one.key_held.y, "Y"] - state.buttons << [1000, 300, inputs.controller_one.key_held.a, "A"] - state.buttons << [900, 200, inputs.controller_one.key_held.b, "B"] - - state.buttons << [450 + inputs.controller_one.left_analog_x_perc * 100, - 100 + inputs.controller_one.left_analog_y_perc * 100, - inputs.controller_one.key_held.l3, - "L3"] - - state.buttons << [750 + inputs.controller_one.right_analog_x_perc * 100, - 100 + inputs.controller_one.right_analog_y_perc * 100, - inputs.controller_one.key_held.r3, - "R3"] + state.buttons << { x: 100, y: 500, active: inputs.controller_one.key_held.l1, text: "L1"} + state.buttons << { x: 100, y: 600, active: inputs.controller_one.key_held.l2, text: "L2"} + state.buttons << { x: 1100, y: 500, active: inputs.controller_one.key_held.r1, text: "R1"} + state.buttons << { x: 1100, y: 600, active: inputs.controller_one.key_held.r2, text: "R2"} + state.buttons << { x: 540, y: 450, active: inputs.controller_one.key_held.select, text: "Select"} + state.buttons << { x: 660, y: 450, active: inputs.controller_one.key_held.start, text: "Start"} + state.buttons << { x: 200, y: 300, active: inputs.controller_one.key_held.left, text: "Left"} + state.buttons << { x: 300, y: 400, active: inputs.controller_one.key_held.up, text: "Up"} + state.buttons << { x: 400, y: 300, active: inputs.controller_one.key_held.right, text: "Right"} + state.buttons << { x: 300, y: 200, active: inputs.controller_one.key_held.down, text: "Down"} + state.buttons << { x: 800, y: 300, active: inputs.controller_one.key_held.x, text: "X"} + state.buttons << { x: 900, y: 400, active: inputs.controller_one.key_held.y, text: "Y"} + state.buttons << { x: 1000, y: 300, active: inputs.controller_one.key_held.a, text: "A"} + state.buttons << { x: 900, y: 200, active: inputs.controller_one.key_held.b, text: "B"} + state.buttons << { x: 450 + inputs.controller_one.left_analog_x_perc * 100, + y: 100 + inputs.controller_one.left_analog_y_perc * 100, + active: inputs.controller_one.key_held.l3, + text: "L3" } + state.buttons << { x: 750 + inputs.controller_one.right_analog_x_perc * 100, + y: 100 + inputs.controller_one.right_analog_y_perc * 100, + active: inputs.controller_one.key_held.r3, + text: "R3" } end # Gives each button a square shape. # If the button is being pressed or held (which means it is considered active), # the square is filled in. Otherwise, the button simply has a border. def render - state.buttons.each do |x, y, active, text| - rect = [x, y, 75, 75] + state.buttons.each do |b| + rect = { x: b.x, y: b.y, w: 75, h: 75 } - if active # if button is pressed + if b.active # if button is pressed outputs.solids << rect # rect is output as solid (filled in) else outputs.borders << rect # otherwise, output as border end # Outputs the text of each button using labels. - outputs.labels << [x, y + 95, text] # add 95 to place label above button + outputs.labels << { x: b.x, y: b.y + 95, text: b.text } # add 95 to place label above button end - outputs.labels << [10, 60, "Left Analog x: #{inputs.controller_one.left_analog_x_raw} (#{inputs.controller_one.left_analog_x_perc * 100}%)"] - outputs.labels << [10, 30, "Left Analog y: #{inputs.controller_one.left_analog_y_raw} (#{inputs.controller_one.left_analog_y_perc * 100}%)"] - outputs.labels << [900, 60, "Right Analog x: #{inputs.controller_one.right_analog_x_raw} (#{inputs.controller_one.right_analog_x_perc * 100}%)"] - outputs.labels << [900, 30, "Right Analog y: #{inputs.controller_one.right_analog_y_raw} (#{inputs.controller_one.right_analog_y_perc * 100}%)"] + outputs.labels << { x: 10, y: 60, text: "Left Analog x: #{inputs.controller_one.left_analog_x_raw} (#{inputs.controller_one.left_analog_x_perc * 100}%)" } + outputs.labels << { x: 10, y: 30, text: "Left Analog y: #{inputs.controller_one.left_analog_y_raw} (#{inputs.controller_one.left_analog_y_perc * 100}%)" } + outputs.labels << { x: 900, y: 60, text: "Right Analog x: #{inputs.controller_one.right_analog_x_raw} (#{inputs.controller_one.right_analog_x_perc * 100}%)" } + outputs.labels << { x: 900, y: 30, text: "Right Analog y: #{inputs.controller_one.right_analog_y_raw} (#{inputs.controller_one.right_analog_y_perc * 100}%)" } end end diff --git a/samples/02_input_basics/06_touch/app/main.rb b/samples/02_input_basics/06_touch/app/main.rb index 8b006c7..501fa74 100644 --- a/samples/02_input_basics/06_touch/app/main.rb +++ b/samples/02_input_basics/06_touch/app/main.rb @@ -11,10 +11,12 @@ def tick args # the next new touch will be finger_one again, but until then, new touches # don't fill in earlier slots. if !args.inputs.finger_one.nil? - args.outputs.primitives << [640, 650, "Finger #1 is touching at (#{args.inputs.finger_one.x}, #{args.inputs.finger_one.y}).", 5, 1, 255, 255, 255].label + args.outputs.primitives << { x: 640, y: 650, text: "Finger #1 is touching at (#{args.inputs.finger_one.x}, #{args.inputs.finger_one.y}).", + size_enum: 5, alignment_enum: 1, r: 255, g: 255, b: 255 }.label! end if !args.inputs.finger_two.nil? - args.outputs.primitives << [640, 600, "Finger #2 is touching at (#{args.inputs.finger_two.x}, #{args.inputs.finger_two.y}).", 5, 1, 255, 255, 255].label + args.outputs.primitives << { x: 640, y: 600, text: "Finger #2 is touching at (#{args.inputs.finger_two.x}, #{args.inputs.finger_two.y}).", + size_enum: 5, alignment_enum: 1, r: 255, g: 255, b: 255 }.label! end # Here's the more flexible interface: this will report as many simultaneous @@ -35,8 +37,7 @@ def tick args r = (color & 0xFF0000) >> 16 g = (color & 0x00FF00) >> 8 b = (color & 0x0000FF) - args.outputs.primitives << [v.x - (size / 2), v.y + (size / 2), size, size, r, g, b, 255].solid - args.outputs.primitives << [v.x, v.y + size, k.to_s, 0, 1, 0, 0, 0].label + args.outputs.primitives << { x: v.x - (size / 2), y: v.y + (size / 2), w: size, h: size, r: r, g: g, b: b, a: 255 }.solid! + args.outputs.primitives << { x: v.x, y: v.y + size, text: k.to_s, alignment_enum: 1 }.label! } end - diff --git a/samples/03_rendering_sprites/01_animation_using_separate_pngs/app/main.rb b/samples/03_rendering_sprites/01_animation_using_separate_pngs/app/main.rb index 1f88366..b25aa83 100644 --- a/samples/03_rendering_sprites/01_animation_using_separate_pngs/app/main.rb +++ b/samples/03_rendering_sprites/01_animation_using_separate_pngs/app/main.rb @@ -10,12 +10,15 @@ - args.outputs.sprites: An array. Values in this array generate sprites on the screen. The parameters are [X, Y, WIDTH, HEIGHT, IMAGE PATH] + For more information about sprites, go to mygame/documentation/05-sprites.md. - args.outputs.labels: An array. Values in the array generate labels on the screen. The parameters are [X, Y, TEXT, SIZE, ALIGNMENT, RED, GREEN, BLUE, ALPHA, FONT STYLE] + For more information about labels, go to mygame/documentation/02-labels.md. - args.inputs.keyboard.key_down.KEY: Determines if a key is in the down state, or pressed. Stores the frame that key was pressed on. + For more information about the keyboard, go to mygame/documentation/06-keyboard.md. =end @@ -28,6 +31,8 @@ # in this tick "entry point": `looping_animation`, and the # second method is `one_time_animation`. def tick args + # uncomment the line below to see animation play out in slow motion + # args.gtk.slowmo! 6 looping_animation args one_time_animation args end @@ -60,22 +65,22 @@ def looping_animation args does_sprite_loop # Now that we have `sprite_index, we can present the correct file. - args.outputs.sprites << [100, 100, 100, 100, "sprites/dragon_fly_#{sprite_index}.png"] + args.outputs.sprites << { x: 100, y: 100, w: 100, h: 100, path: "sprites/dragon_fly_#{sprite_index}.png" } # Try changing the numbers below to see how the animation changes: - args.outputs.sprites << [100, 200, 100, 100, "sprites/dragon_fly_#{0.frame_index 6, 4, true}.png"] + args.outputs.sprites << { x: 100, y: 200, w: 100, h: 100, path: "sprites/dragon_fly_#{0.frame_index 6, 4, true}.png" } end # This function shows how to animate a sprite that executes # only once when the "f" key is pressed. def one_time_animation args - # This is just a label that shows instructions within the game. - args.outputs.labels << [220, 350, "(press f to animate)"] + # This is just a label the shows instructions within the game. + args.outputs.labels << { x: 220, y: 350, text: "(press f to animate)" } # If "f" is pressed on the keyboard... if args.inputs.keyboard.key_down.f # Print the frame that "f" was pressed on. - puts "Hello from main.rb! The \"f\" key was in the down state on frame: #{args.inputs.keyboard.key_down.f}" + puts "Hello from main.rb! The \"f\" key was in the down state on frame: #{args.state.tick_count}" # And MOST IMPORTANTLY set the point it time to start the animation, # equal to "now" which is represented as args.state.tick_count. @@ -104,11 +109,11 @@ def one_time_animation args # This line sets the frame index to zero, if # the animation duration has passed (frame_index returned nil). - # Remember: we are not looping forever here. + # Remeber: we are not looping forever here. sprite_index ||= 0 # Present the sprite. - args.outputs.sprites << [100, 300, 100, 100, "sprites/dragon_fly_#{sprite_index}.png"] + args.outputs.sprites << { x: 100, y: 300, w: 100, h: 100, path: "sprites/dragon_fly_#{sprite_index}.png" } tick_instructions args, "Sample app shows how to use Numeric#frame_index and string interpolation to animate a sprite over time." end diff --git a/samples/03_rendering_sprites/02_animation_using_sprite_sheet/replay.txt b/samples/03_rendering_sprites/02_animation_using_sprite_sheet/replay.txt new file mode 100644 index 0000000..8927ef0 --- /dev/null +++ b/samples/03_rendering_sprites/02_animation_using_sprite_sheet/replay.txt @@ -0,0 +1,241 @@ +replay_version 2.0 +stopped_at 805 +seed 100 +recorded_at Sat Jul 17 09:26:10 2021 +[:mouse_button_up, 1, 0, 1, 1, 6] +[:key_down_raw, 1073741906, 0, 2, 2, 69] +[:key_down_raw, 1073741906, 0, 2, 3, 83] +[:key_down_raw, 1073741906, 0, 2, 4, 85] +[:key_down_raw, 1073741906, 0, 2, 5, 87] +[:key_down_raw, 1073741906, 0, 2, 6, 89] +[:key_down_raw, 1073741906, 0, 2, 7, 91] +[:key_down_raw, 1073741906, 0, 2, 8, 93] +[:key_down_raw, 1073741906, 0, 2, 9, 95] +[:key_down_raw, 1073741906, 0, 2, 10, 97] +[:key_down_raw, 1073741906, 0, 2, 11, 99] +[:key_down_raw, 1073741906, 0, 2, 12, 101] +[:key_down_raw, 1073741906, 0, 2, 13, 103] +[:key_down_raw, 1073741906, 0, 2, 14, 105] +[:key_down_raw, 1073741906, 0, 2, 15, 107] +[:key_down_raw, 1073741906, 0, 2, 16, 109] +[:key_down_raw, 1073741906, 0, 2, 17, 111] +[:key_down_raw, 1073741906, 0, 2, 18, 113] +[:key_down_raw, 1073741906, 0, 2, 19, 115] +[:key_down_raw, 1073741906, 0, 2, 20, 117] +[:key_down_raw, 1073741906, 0, 2, 21, 119] +[:key_down_raw, 1073741906, 0, 2, 22, 121] +[:key_down_raw, 1073741906, 0, 2, 23, 123] +[:key_down_raw, 1073741906, 0, 2, 24, 125] +[:key_down_raw, 1073741906, 0, 2, 25, 127] +[:key_down_raw, 1073741906, 0, 2, 26, 129] +[:key_up_raw, 1073741906, 0, 2, 27, 130] +[:key_down_raw, 1073741903, 0, 2, 28, 131] +[:key_down_raw, 1073741903, 0, 2, 29, 146] +[:key_down_raw, 1073741903, 0, 2, 30, 148] +[:key_down_raw, 1073741903, 0, 2, 31, 150] +[:key_down_raw, 1073741903, 0, 2, 32, 152] +[:key_down_raw, 1073741903, 0, 2, 33, 154] +[:key_down_raw, 1073741903, 0, 2, 34, 156] +[:key_down_raw, 1073741903, 0, 2, 35, 158] +[:key_down_raw, 1073741903, 0, 2, 36, 160] +[:key_down_raw, 1073741903, 0, 2, 37, 162] +[:key_down_raw, 1073741903, 0, 2, 38, 164] +[:key_down_raw, 1073741903, 0, 2, 39, 166] +[:key_down_raw, 1073741903, 0, 2, 40, 168] +[:key_down_raw, 1073741903, 0, 2, 41, 170] +[:key_down_raw, 1073741903, 0, 2, 42, 172] +[:key_down_raw, 1073741903, 0, 2, 43, 174] +[:key_down_raw, 1073741903, 0, 2, 44, 176] +[:key_down_raw, 1073741903, 0, 2, 45, 178] +[:key_down_raw, 1073741903, 0, 2, 46, 180] +[:key_down_raw, 1073741903, 0, 2, 47, 182] +[:key_down_raw, 1073741903, 0, 2, 48, 184] +[:key_down_raw, 1073741903, 0, 2, 49, 186] +[:key_down_raw, 1073741903, 0, 2, 50, 189] +[:key_down_raw, 1073741903, 0, 2, 51, 190] +[:key_down_raw, 1073741903, 0, 2, 52, 192] +[:key_down_raw, 1073741903, 0, 2, 53, 194] +[:key_down_raw, 1073741903, 0, 2, 54, 196] +[:key_down_raw, 1073741903, 0, 2, 55, 198] +[:key_down_raw, 1073741903, 0, 2, 56, 200] +[:key_down_raw, 1073741903, 0, 2, 57, 203] +[:key_down_raw, 1073741903, 0, 2, 58, 204] +[:key_down_raw, 1073741903, 0, 2, 59, 206] +[:key_down_raw, 1073741903, 0, 2, 60, 208] +[:key_down_raw, 1073741903, 0, 2, 61, 210] +[:key_down_raw, 1073741903, 0, 2, 62, 212] +[:key_down_raw, 1073741903, 0, 2, 63, 214] +[:key_down_raw, 1073741903, 0, 2, 64, 216] +[:key_down_raw, 1073741903, 0, 2, 65, 218] +[:key_down_raw, 1073741903, 0, 2, 66, 220] +[:key_down_raw, 1073741904, 0, 2, 67, 221] +[:key_up_raw, 1073741903, 0, 2, 68, 225] +[:key_down_raw, 1073741904, 0, 2, 69, 236] +[:key_down_raw, 1073741904, 0, 2, 70, 238] +[:key_down_raw, 1073741904, 0, 2, 71, 240] +[:key_down_raw, 1073741904, 0, 2, 72, 242] +[:key_down_raw, 1073741904, 0, 2, 73, 244] +[:key_down_raw, 1073741904, 0, 2, 74, 246] +[:key_down_raw, 1073741904, 0, 2, 75, 248] +[:key_down_raw, 1073741904, 0, 2, 76, 250] +[:key_up_raw, 1073741904, 0, 2, 77, 251] +[:key_down_raw, 1073741906, 0, 2, 78, 253] +[:key_down_raw, 1073741906, 0, 2, 79, 268] +[:key_down_raw, 1073741906, 0, 2, 80, 270] +[:key_down_raw, 1073741906, 0, 2, 81, 272] +[:key_down_raw, 1073741906, 0, 2, 82, 275] +[:key_down_raw, 1073741906, 0, 2, 83, 276] +[:key_down_raw, 1073741906, 0, 2, 84, 278] +[:key_down_raw, 1073741906, 0, 2, 85, 280] +[:key_down_raw, 1073741906, 0, 2, 86, 283] +[:key_down_raw, 1073741906, 0, 2, 87, 285] +[:key_down_raw, 1073741906, 0, 2, 88, 287] +[:key_down_raw, 1073741906, 0, 2, 89, 289] +[:key_down_raw, 1073741906, 0, 2, 90, 291] +[:key_down_raw, 1073741906, 0, 2, 91, 293] +[:key_down_raw, 1073741906, 0, 2, 92, 294] +[:key_down_raw, 1073741906, 0, 2, 93, 296] +[:key_down_raw, 1073741906, 0, 2, 94, 299] +[:key_down_raw, 1073741906, 0, 2, 95, 301] +[:key_down_raw, 1073741906, 0, 2, 96, 303] +[:key_up_raw, 1073741906, 0, 2, 97, 303] +[:key_down_raw, 1073741905, 0, 2, 98, 307] +[:key_down_raw, 1073741905, 0, 2, 99, 322] +[:key_down_raw, 1073741905, 0, 2, 100, 324] +[:key_down_raw, 1073741905, 0, 2, 101, 326] +[:key_down_raw, 1073741905, 0, 2, 102, 328] +[:key_down_raw, 1073741905, 0, 2, 103, 330] +[:key_down_raw, 1073741905, 0, 2, 104, 332] +[:key_down_raw, 1073741905, 0, 2, 105, 334] +[:key_down_raw, 1073741905, 0, 2, 106, 336] +[:key_up_raw, 1073741905, 0, 2, 107, 336] +[:key_down_raw, 1073741903, 0, 2, 108, 337] +[:key_down_raw, 1073741906, 0, 2, 109, 342] +[:key_down_raw, 1073741906, 0, 2, 110, 357] +[:key_down_raw, 1073741906, 0, 2, 111, 359] +[:key_down_raw, 1073741906, 0, 2, 112, 361] +[:key_down_raw, 1073741906, 0, 2, 113, 363] +[:key_down_raw, 1073741906, 0, 2, 114, 365] +[:key_down_raw, 1073741906, 0, 2, 115, 367] +[:key_down_raw, 1073741906, 0, 2, 116, 369] +[:key_down_raw, 1073741906, 0, 2, 117, 371] +[:key_down_raw, 1073741906, 0, 2, 118, 373] +[:key_down_raw, 1073741906, 0, 2, 119, 375] +[:key_down_raw, 1073741906, 0, 2, 120, 377] +[:key_down_raw, 1073741906, 0, 2, 121, 379] +[:key_down_raw, 1073741906, 0, 2, 122, 381] +[:key_down_raw, 1073741906, 0, 2, 123, 383] +[:key_down_raw, 1073741906, 0, 2, 124, 385] +[:key_down_raw, 1073741906, 0, 2, 125, 387] +[:key_down_raw, 1073741906, 0, 2, 126, 389] +[:key_down_raw, 1073741906, 0, 2, 127, 391] +[:key_up_raw, 1073741903, 0, 2, 128, 392] +[:key_down_raw, 1073741906, 0, 2, 129, 393] +[:key_up_raw, 1073741906, 0, 2, 130, 394] +[:key_down_raw, 1073741904, 0, 2, 131, 404] +[:key_down_raw, 1073741905, 0, 2, 132, 407] +[:key_down_raw, 1073741905, 0, 2, 133, 421] +[:key_down_raw, 1073741905, 0, 2, 134, 423] +[:key_down_raw, 1073741905, 0, 2, 135, 425] +[:key_down_raw, 1073741905, 0, 2, 136, 428] +[:key_down_raw, 1073741905, 0, 2, 137, 429] +[:key_down_raw, 1073741905, 0, 2, 138, 431] +[:key_down_raw, 1073741905, 0, 2, 139, 433] +[:key_down_raw, 1073741905, 0, 2, 140, 435] +[:key_down_raw, 1073741905, 0, 2, 141, 437] +[:key_down_raw, 1073741905, 0, 2, 142, 439] +[:key_down_raw, 1073741905, 0, 2, 143, 441] +[:key_down_raw, 1073741905, 0, 2, 144, 443] +[:key_down_raw, 1073741905, 0, 2, 145, 445] +[:key_down_raw, 1073741905, 0, 2, 146, 447] +[:key_down_raw, 1073741905, 0, 2, 147, 449] +[:key_up_raw, 1073741905, 0, 2, 148, 451] +[:key_up_raw, 1073741904, 0, 2, 149, 453] +[:key_down_raw, 1073741904, 0, 2, 150, 456] +[:key_up_raw, 1073741904, 0, 2, 151, 462] +[:key_down_raw, 1073741905, 0, 2, 152, 464] +[:key_down_raw, 1073741905, 0, 2, 153, 479] +[:key_down_raw, 1073741905, 0, 2, 154, 481] +[:key_down_raw, 1073741905, 0, 2, 155, 483] +[:key_down_raw, 1073741905, 0, 2, 156, 485] +[:key_down_raw, 1073741905, 0, 2, 157, 487] +[:key_down_raw, 1073741905, 0, 2, 158, 489] +[:key_down_raw, 1073741905, 0, 2, 159, 491] +[:key_down_raw, 1073741905, 0, 2, 160, 493] +[:key_down_raw, 1073741905, 0, 2, 161, 495] +[:key_down_raw, 1073741905, 0, 2, 162, 497] +[:key_down_raw, 1073741905, 0, 2, 163, 499] +[:key_down_raw, 1073741906, 0, 2, 164, 500] +[:key_down_raw, 1073741906, 0, 2, 165, 515] +[:key_down_raw, 1073741906, 0, 2, 166, 517] +[:key_down_raw, 1073741906, 0, 2, 167, 519] +[:key_down_raw, 1073741906, 0, 2, 168, 521] +[:key_down_raw, 1073741906, 0, 2, 169, 523] +[:key_down_raw, 1073741906, 0, 2, 170, 525] +[:key_down_raw, 1073741906, 0, 2, 171, 527] +[:key_down_raw, 1073741906, 0, 2, 172, 529] +[:key_down_raw, 1073741906, 0, 2, 173, 531] +[:key_down_raw, 1073741906, 0, 2, 174, 533] +[:key_down_raw, 1073741906, 0, 2, 175, 535] +[:key_down_raw, 1073741906, 0, 2, 176, 537] +[:key_down_raw, 1073741906, 0, 2, 177, 539] +[:key_down_raw, 1073741906, 0, 2, 178, 541] +[:key_down_raw, 1073741906, 0, 2, 179, 543] +[:key_down_raw, 1073741906, 0, 2, 180, 545] +[:key_down_raw, 1073741903, 0, 2, 181, 547] +[:key_up_raw, 1073741905, 0, 2, 182, 555] +[:key_down_raw, 1073741905, 0, 2, 183, 558] +[:key_up_raw, 1073741906, 0, 2, 184, 564] +[:key_down_raw, 1073741905, 0, 2, 185, 573] +[:key_down_raw, 1073741905, 0, 2, 186, 575] +[:key_down_raw, 1073741905, 0, 2, 187, 577] +[:key_down_raw, 1073741905, 0, 2, 188, 579] +[:key_down_raw, 1073741905, 0, 2, 189, 581] +[:key_down_raw, 1073741905, 0, 2, 190, 583] +[:key_down_raw, 1073741905, 0, 2, 191, 585] +[:key_down_raw, 1073741905, 0, 2, 192, 587] +[:key_down_raw, 1073741905, 0, 2, 193, 589] +[:key_down_raw, 1073741905, 0, 2, 194, 591] +[:key_down_raw, 1073741905, 0, 2, 195, 593] +[:key_down_raw, 1073741905, 0, 2, 196, 595] +[:key_down_raw, 1073741905, 0, 2, 197, 597] +[:key_down_raw, 1073741905, 0, 2, 198, 599] +[:key_down_raw, 1073741905, 0, 2, 199, 601] +[:key_down_raw, 1073741905, 0, 2, 200, 603] +[:key_down_raw, 1073741905, 0, 2, 201, 605] +[:key_up_raw, 1073741905, 0, 2, 202, 605] +[:key_up_raw, 1073741903, 0, 2, 203, 606] +[:key_down_raw, 96, 0, 2, 204, 640] +[:key_up_raw, 96, 0, 2, 205, 646] +[:mouse_move, 796, 95, 2, 206, 683] +[:mouse_move, 798, 95, 2, 207, 684] +[:mouse_move, 808, 94, 2, 208, 685] +[:mouse_move, 814, 94, 2, 209, 686] +[:mouse_move, 826, 94, 2, 210, 687] +[:mouse_move, 832, 94, 2, 211, 688] +[:mouse_move, 842, 94, 2, 212, 689] +[:mouse_move, 846, 94, 2, 213, 690] +[:mouse_move, 856, 93, 2, 214, 691] +[:mouse_move, 860, 93, 2, 215, 692] +[:mouse_move, 867, 93, 2, 216, 693] +[:mouse_move, 869, 93, 2, 217, 694] +[:mouse_move, 870, 93, 2, 218, 695] +[:mouse_move, 871, 93, 2, 219, 697] +[:mouse_move, 872, 93, 2, 220, 698] +[:mouse_move, 873, 93, 2, 221, 699] +[:mouse_move, 874, 93, 2, 222, 701] +[:mouse_move, 875, 93, 2, 223, 703] +[:mouse_move, 877, 94, 2, 224, 704] +[:mouse_move, 878, 94, 2, 225, 705] +[:mouse_move, 879, 94, 2, 226, 706] +[:mouse_move, 869, 95, 2, 227, 758] +[:mouse_move, 864, 96, 2, 228, 759] +[:mouse_move, 856, 96, 2, 229, 760] +[:mouse_move, 852, 96, 2, 230, 761] +[:mouse_move, 834, 96, 2, 231, 762] +[:mouse_move, 821, 96, 2, 232, 763] +[:mouse_move, 797, 96, 2, 233, 764] +[:mouse_move, 789, 96, 2, 234, 765] +[:mouse_move, 780, 94, 2, 235, 766] +[:mouse_move, 779, 94, 2, 236, 767] +[:key_down_raw, 13, 0, 2, 237, 805] diff --git a/samples/03_rendering_sprites/03_animation_states/replay.txt b/samples/03_rendering_sprites/03_animation_states/replay.txt new file mode 100644 index 0000000..f9d1962 --- /dev/null +++ b/samples/03_rendering_sprites/03_animation_states/replay.txt @@ -0,0 +1,182 @@ +replay_version 2.0 +stopped_at 770 +seed 100 +recorded_at Sat Jul 17 09:29:30 2021 +[:mouse_button_up, 1, 0, 1, 1, 4] +[:key_down_raw, 1073741903, 0, 2, 2, 75] +[:key_down_raw, 1073741903, 0, 2, 3, 89] +[:key_down_raw, 1073741903, 0, 2, 4, 91] +[:key_down_raw, 1073741903, 0, 2, 5, 93] +[:key_down_raw, 1073741903, 0, 2, 6, 95] +[:key_down_raw, 1073741903, 0, 2, 7, 97] +[:key_down_raw, 1073741903, 0, 2, 8, 99] +[:key_down_raw, 1073741903, 0, 2, 9, 101] +[:key_down_raw, 1073741903, 0, 2, 10, 103] +[:key_down_raw, 1073741903, 0, 2, 11, 105] +[:key_down_raw, 1073741903, 0, 2, 12, 107] +[:key_down_raw, 1073741903, 0, 2, 13, 109] +[:key_down_raw, 1073741903, 0, 2, 14, 111] +[:key_down_raw, 1073741903, 0, 2, 15, 113] +[:key_down_raw, 1073741903, 0, 2, 16, 115] +[:key_down_raw, 1073741903, 0, 2, 17, 117] +[:key_down_raw, 1073741903, 0, 2, 18, 119] +[:key_down_raw, 1073741903, 0, 2, 19, 121] +[:key_down_raw, 1073741903, 0, 2, 20, 123] +[:key_down_raw, 1073741903, 0, 2, 21, 125] +[:key_down_raw, 1073741903, 0, 2, 22, 127] +[:key_down_raw, 1073741903, 0, 2, 23, 129] +[:key_down_raw, 1073741903, 0, 2, 24, 131] +[:key_down_raw, 1073741903, 0, 2, 25, 133] +[:key_down_raw, 1073741903, 0, 2, 26, 135] +[:key_down_raw, 1073741903, 0, 2, 27, 137] +[:key_down_raw, 1073741903, 0, 2, 28, 139] +[:key_down_raw, 1073741903, 0, 2, 29, 141] +[:key_down_raw, 1073741903, 0, 2, 30, 143] +[:key_down_raw, 1073741903, 0, 2, 31, 145] +[:key_down_raw, 1073741903, 0, 2, 32, 147] +[:key_down_raw, 1073741903, 0, 2, 33, 149] +[:key_down_raw, 1073741903, 0, 2, 34, 151] +[:key_down_raw, 1073741903, 0, 2, 35, 153] +[:key_down_raw, 1073741903, 0, 2, 36, 155] +[:key_down_raw, 1073741903, 0, 2, 37, 157] +[:key_down_raw, 1073741903, 0, 2, 38, 159] +[:key_down_raw, 1073741903, 0, 2, 39, 161] +[:key_down_raw, 1073741903, 0, 2, 40, 163] +[:key_down_raw, 1073741903, 0, 2, 41, 165] +[:key_down_raw, 1073741903, 0, 2, 42, 167] +[:key_down_raw, 1073741903, 0, 2, 43, 169] +[:key_down_raw, 1073741903, 0, 2, 44, 171] +[:key_down_raw, 1073741903, 0, 2, 45, 173] +[:key_down_raw, 1073741903, 0, 2, 46, 175] +[:key_down_raw, 1073741903, 0, 2, 47, 177] +[:key_down_raw, 1073741903, 0, 2, 48, 179] +[:key_down_raw, 1073741903, 0, 2, 49, 181] +[:key_down_raw, 1073741903, 0, 2, 50, 183] +[:key_down_raw, 1073741903, 0, 2, 51, 185] +[:key_down_raw, 1073741903, 0, 2, 52, 187] +[:key_down_raw, 1073741903, 0, 2, 53, 189] +[:key_down_raw, 1073741903, 0, 2, 54, 191] +[:key_down_raw, 1073741903, 0, 2, 55, 193] +[:key_down_raw, 1073741903, 0, 2, 56, 195] +[:key_down_raw, 1073741903, 0, 2, 57, 197] +[:key_down_raw, 1073741903, 0, 2, 58, 199] +[:key_down_raw, 1073741903, 0, 2, 59, 201] +[:key_down_raw, 1073741903, 0, 2, 60, 203] +[:key_down_raw, 1073741903, 0, 2, 61, 205] +[:key_down_raw, 1073741903, 0, 2, 62, 207] +[:key_down_raw, 1073741903, 0, 2, 63, 209] +[:key_down_raw, 1073741903, 0, 2, 64, 211] +[:key_down_raw, 1073741903, 0, 2, 65, 213] +[:key_down_raw, 1073741903, 0, 2, 66, 215] +[:key_down_raw, 1073741903, 0, 2, 67, 217] +[:key_down_raw, 1073741903, 0, 2, 68, 219] +[:key_down_raw, 1073741903, 0, 2, 69, 221] +[:key_down_raw, 1073741903, 0, 2, 70, 223] +[:key_down_raw, 1073741903, 0, 2, 71, 225] +[:key_down_raw, 1073741903, 0, 2, 72, 227] +[:key_down_raw, 1073741903, 0, 2, 73, 229] +[:key_down_raw, 1073741903, 0, 2, 74, 231] +[:key_down_raw, 1073741903, 0, 2, 75, 233] +[:key_down_raw, 1073741903, 0, 2, 76, 235] +[:key_down_raw, 1073741903, 0, 2, 77, 237] +[:key_down_raw, 1073741903, 0, 2, 78, 239] +[:key_down_raw, 1073741903, 0, 2, 79, 241] +[:key_down_raw, 1073741903, 0, 2, 80, 243] +[:key_down_raw, 1073741903, 0, 2, 81, 245] +[:key_down_raw, 1073741903, 0, 2, 82, 247] +[:key_down_raw, 1073741903, 0, 2, 83, 249] +[:key_up_raw, 1073741903, 0, 2, 84, 250] +[:key_down_raw, 106, 0, 2, 85, 269] +[:key_up_raw, 106, 0, 2, 86, 277] +[:key_down_raw, 1073741905, 0, 2, 87, 299] +[:key_down_raw, 1073741905, 0, 2, 88, 314] +[:key_down_raw, 1073741905, 0, 2, 89, 316] +[:key_down_raw, 1073741905, 0, 2, 90, 318] +[:key_down_raw, 1073741905, 0, 2, 91, 320] +[:key_down_raw, 1073741905, 0, 2, 92, 322] +[:key_down_raw, 1073741905, 0, 2, 93, 324] +[:key_down_raw, 1073741905, 0, 2, 94, 326] +[:key_down_raw, 1073741905, 0, 2, 95, 328] +[:key_down_raw, 1073741905, 0, 2, 96, 330] +[:key_down_raw, 1073741905, 0, 2, 97, 332] +[:key_down_raw, 1073741905, 0, 2, 98, 334] +[:key_down_raw, 1073741905, 0, 2, 99, 336] +[:key_down_raw, 1073741905, 0, 2, 100, 338] +[:key_down_raw, 1073741905, 0, 2, 101, 340] +[:key_down_raw, 1073741904, 0, 2, 102, 341] +[:key_down_raw, 1073741904, 0, 2, 103, 356] +[:key_down_raw, 1073741904, 0, 2, 104, 358] +[:key_down_raw, 1073741904, 0, 2, 105, 360] +[:key_down_raw, 1073741904, 0, 2, 106, 362] +[:key_down_raw, 1073741904, 0, 2, 107, 364] +[:key_down_raw, 1073741904, 0, 2, 108, 366] +[:key_down_raw, 1073741904, 0, 2, 109, 368] +[:key_down_raw, 1073741904, 0, 2, 110, 370] +[:key_up_raw, 1073741904, 0, 2, 111, 371] +[:key_up_raw, 1073741905, 0, 2, 112, 373] +[:key_down_raw, 1073741906, 0, 2, 113, 378] +[:key_down_raw, 1073741906, 0, 2, 114, 393] +[:key_down_raw, 1073741906, 0, 2, 115, 395] +[:key_down_raw, 1073741906, 0, 2, 116, 397] +[:key_down_raw, 1073741906, 0, 2, 117, 399] +[:key_up_raw, 1073741906, 0, 2, 118, 401] +[:key_down_raw, 1073741904, 0, 2, 119, 402] +[:key_down_raw, 1073741904, 0, 2, 120, 419] +[:key_down_raw, 1073741904, 0, 2, 121, 421] +[:key_down_raw, 1073741904, 0, 2, 122, 423] +[:key_down_raw, 1073741904, 0, 2, 123, 425] +[:key_down_raw, 1073741904, 0, 2, 124, 427] +[:key_up_raw, 1073741904, 0, 2, 125, 429] +[:key_down_raw, 1073741904, 0, 2, 126, 434] +[:key_up_raw, 1073741904, 0, 2, 127, 437] +[:key_down_raw, 106, 0, 2, 128, 457] +[:key_up_raw, 106, 0, 2, 129, 463] +[:key_down_raw, 1073741903, 0, 2, 130, 490] +[:key_up_raw, 1073741903, 0, 2, 131, 500] +[:key_down_raw, 1073741906, 0, 2, 132, 501] +[:key_down_raw, 1073741906, 0, 2, 133, 516] +[:key_down_raw, 1073741906, 0, 2, 134, 518] +[:key_down_raw, 1073741906, 0, 2, 135, 520] +[:key_up_raw, 1073741906, 0, 2, 136, 521] +[:key_down_raw, 1073741904, 0, 2, 137, 532] +[:key_down_raw, 1073741904, 0, 2, 138, 547] +[:key_down_raw, 1073741904, 0, 2, 139, 549] +[:key_up_raw, 1073741904, 0, 2, 140, 550] +[:key_down_raw, 1073741903, 0, 2, 141, 552] +[:key_down_raw, 1073741903, 0, 2, 142, 567] +[:key_up_raw, 1073741903, 0, 2, 143, 568] +[:key_down_raw, 106, 0, 2, 144, 574] +[:key_up_raw, 106, 0, 2, 145, 580] +[:key_down_raw, 96, 0, 2, 146, 661] +[:key_up_raw, 96, 0, 2, 147, 666] +[:mouse_move, 799, 92, 2, 148, 693] +[:mouse_move, 803, 92, 2, 149, 694] +[:mouse_move, 811, 91, 2, 150, 695] +[:mouse_move, 816, 90, 2, 151, 696] +[:mouse_move, 827, 88, 2, 152, 697] +[:mouse_move, 830, 87, 2, 153, 698] +[:mouse_move, 835, 87, 2, 154, 699] +[:mouse_move, 837, 87, 2, 155, 700] +[:mouse_move, 838, 87, 2, 156, 701] +[:mouse_move, 838, 86, 2, 157, 702] +[:mouse_move, 839, 86, 2, 158, 704] +[:mouse_move, 838, 86, 2, 159, 712] +[:mouse_move, 838, 87, 2, 160, 713] +[:mouse_move, 835, 87, 2, 161, 714] +[:mouse_move, 832, 87, 2, 162, 715] +[:mouse_move, 824, 87, 2, 163, 716] +[:mouse_move, 820, 87, 2, 164, 717] +[:mouse_move, 809, 87, 2, 165, 718] +[:mouse_move, 805, 87, 2, 166, 719] +[:mouse_move, 800, 86, 2, 167, 720] +[:mouse_move, 799, 86, 2, 168, 721] +[:mouse_move, 798, 86, 2, 169, 722] +[:mouse_move, 797, 86, 2, 170, 723] +[:mouse_move, 796, 86, 2, 171, 724] +[:mouse_move, 798, 86, 2, 172, 742] +[:mouse_move, 805, 86, 2, 173, 743] +[:mouse_move, 807, 86, 2, 174, 744] +[:mouse_move, 810, 86, 2, 175, 745] +[:mouse_move, 811, 86, 2, 176, 747] +[:mouse_move, 811, 85, 2, 177, 760] +[:key_down_raw, 13, 0, 2, 178, 770] diff --git a/samples/03_rendering_sprites/04_color_and_rotation/app/main.rb b/samples/03_rendering_sprites/04_color_and_rotation/app/main.rb index 7e0fc3c..c3f2d8f 100644 --- a/samples/03_rendering_sprites/04_color_and_rotation/app/main.rb +++ b/samples/03_rendering_sprites/04_color_and_rotation/app/main.rb @@ -21,10 +21,14 @@ - args.outputs.sprites: An array. The values generate a sprite. The parameters are [X, Y, WIDTH, HEIGHT, PATH, ANGLE, ALPHA, RED, GREEN, BLUE] + Before continuing with this sample app, it is HIGHLY recommended that you look + at mygame/documentation/05-sprites.md. - args.inputs.keyboard.key_held.KEY: Determines if a key is being pressed. + For more information about the keyboard, go to mygame/documentation/06-keyboard.md. - args.inputs.controller_one: Takes input from the controller based on what key is pressed. + For more information about the controller, go to mygame/documentation/08-controllers.md. - num1.lesser(num2): Finds the lower value of the given options. @@ -117,7 +121,7 @@ def create_sprite path, options = {} source_w: -1, source_h: -1, - # flip horizontally, flip vertically + # flip horiztonally, flip vertically flip_h: false, flip_v: false, @@ -153,7 +157,7 @@ end def calc_wrap state # car returns to left side of screen if it disappears on right side of screen - # sprite.width refers to tile's size, which is multiplied by scale (4) to make it bigger + # sprite.width refers to tile's size, which is multipled by scale (4) to make it bigger state.x = -state.sprite.width * state.sprite.scale if state.x - 20 > 1280 # car wraps around to right side of screen if it disappears on the left side diff --git a/samples/04_physics_and_collisions/01_simple/app/main.rb b/samples/04_physics_and_collisions/01_simple/app/main.rb index 9075d89..5e3f9b7 100644 --- a/samples/04_physics_and_collisions/01_simple/app/main.rb +++ b/samples/04_physics_and_collisions/01_simple/app/main.rb @@ -10,7 +10,7 @@ # This sample app shows collisions between two boxes. -# Runs methods needed for the game to run properly. +# Runs methods needed for game to run properly. def tick args tick_instructions args, "Sample app shows how to move a square over time and determine collision." defaults args @@ -33,7 +33,7 @@ def defaults args end def render args - # If the game state denotes that a collision has occurred, + # If the game state denotes that a collision has occured, # render a solid square, otherwise render a border instead. if args.state.center_box_collision args.outputs.solids << args.state.center_box @@ -47,7 +47,7 @@ end # Generally in a pipeline for a game engine, you have rendering, # game simulation (calculation), and input processing. -# This function represents the game simulation. +# This fuction represents the game simulation. def calc args position_moving_box args determine_collision_center_box args diff --git a/samples/04_physics_and_collisions/02_moving_objects/app/main.rb b/samples/04_physics_and_collisions/02_moving_objects/app/main.rb index 9c39363..35eabfb 100644 --- a/samples/04_physics_and_collisions/02_moving_objects/app/main.rb +++ b/samples/04_physics_and_collisions/02_moving_objects/app/main.rb @@ -48,15 +48,17 @@ Reminders: - args.inputs.keyboard.KEY: Determines if a key has been pressed. + For more information about the keyboard, take a look at mygame/documentation/06-keyboard.md. - ARRAY#intersect_rect?: Returns true or false depending on if the two rectangles intersect. - args.outputs.solids: An array. The values generate a solid. The parameters are [X, Y, WIDTH, HEIGHT, RED, GREEN, BLUE] + For more information about solids, go to mygame/documentation/03-solids-and-borders.md. =end -# Calls methods needed for the game to run properly +# Calls methods needed for game to run properly def tick args tick_instructions args, "Use LEFT and RIGHT arrow keys to move and SPACE to jump." defaults args diff --git a/samples/04_physics_and_collisions/04_box_collision/app/main.rb b/samples/04_physics_and_collisions/04_box_collision/app/main.rb index e407f0d..af85fef 100644 --- a/samples/04_physics_and_collisions/04_box_collision/app/main.rb +++ b/samples/04_physics_and_collisions/04_box_collision/app/main.rb @@ -42,7 +42,7 @@ class PoorManPlatformerPhysics # Sets default values for variables. # The ||= sign means that the variable will only be set to the value following the = sign if the value has - # not already been set before. Initialization happens only in the first frame. + # not already been set before. Intialization happens only in the first frame. def defaults state.tile_size = 64 state.gravity = -0.2 @@ -161,7 +161,7 @@ class PoorManPlatformerPhysics # Calls methods needed to determine collisions between player and world_collision rects. def calc_box_collision - return unless state.world_lookup.keys.length > 0 # return unless hash has at least 1 key + return unless state.world_lookup.keys.length > 0 # return unless hash has atleast 1 key collision_floor! collision_left! collision_right! @@ -189,7 +189,7 @@ class PoorManPlatformerPhysics return unless state.dx < 0 # return unless player is moving left player_rect = [state.x - 0.1, state.y, state.tile_size, state.tile_size] - # Goes through world_collision_rects to find all intersections between the player's left side and the + # Goes through world_collision_rects to find all intersections beween the player's left side and the # right side of a world_collision_rect. left_side_collisions = state.world_collision_rects .find_all { |r| r[:left_right].intersect_rect?(player_rect, collision_tollerance) } diff --git a/samples/04_physics_and_collisions/05_box_collision_2/app/main.rb b/samples/04_physics_and_collisions/05_box_collision_2/app/main.rb index 42ccf22..126759a 100644 --- a/samples/04_physics_and_collisions/05_box_collision_2/app/main.rb +++ b/samples/04_physics_and_collisions/05_box_collision_2/app/main.rb @@ -91,7 +91,7 @@ class MetroidvaniaStarter state.sprite_selected ||= 1 state.map_saved_at ||= 0 - # Sets all the coordinate values for the sprite selection screen into a grid + # Sets all the cordinate values for the sprite selection screen into a grid # Displayed when 's' is pressed by player to access sprites if state.sprite_coords == [] # if sprite_coords is an empty array count = 1 @@ -223,7 +223,7 @@ class MetroidvaniaStarter # Calls methods that determine whether the player collides with any world_collision_rects. def calc_box_collision - return unless state.world_lookup.keys.length > 0 # return unless hash has at least 1 key + return unless state.world_lookup.keys.length > 0 # return unless hash has atleast 1 key collision_floor collision_left collision_right diff --git a/samples/04_physics_and_collisions/06_box_collision_3/app/main.rb b/samples/04_physics_and_collisions/06_box_collision_3/app/main.rb index 2e32eee..4f5b483 100644 --- a/samples/04_physics_and_collisions/06_box_collision_3/app/main.rb +++ b/samples/04_physics_and_collisions/06_box_collision_3/app/main.rb @@ -46,9 +46,9 @@ class Game mouse_overlay = mouse_overlay.merge r: 255 if state.delete_mode if state.mouse_held - outputs.primitives << mouse_overlay.border + outputs.primitives << mouse_overlay.border! else - outputs.primitives << mouse_overlay.solid + outputs.primitives << mouse_overlay.solid! end end diff --git a/samples/04_physics_and_collisions/06_box_collision_3/replay.txt b/samples/04_physics_and_collisions/06_box_collision_3/replay.txt new file mode 100644 index 0000000..0f4373e --- /dev/null +++ b/samples/04_physics_and_collisions/06_box_collision_3/replay.txt @@ -0,0 +1,687 @@ +replay_version 2.0 +stopped_at 2166 +seed 100 +recorded_at Sat Jul 17 09:33:34 2021 +[:mouse_button_up, 1, 0, 1, 1, 5] +[:mouse_move, 805, 89, 2, 2, 19] +[:mouse_move, 805, 91, 2, 3, 20] +[:mouse_move, 803, 96, 2, 4, 21] +[:mouse_move, 802, 99, 2, 5, 22] +[:mouse_move, 799, 103, 2, 6, 23] +[:mouse_move, 797, 107, 2, 7, 24] +[:mouse_move, 786, 124, 2, 8, 25] +[:mouse_move, 772, 141, 2, 9, 26] +[:mouse_move, 716, 207, 2, 10, 27] +[:mouse_move, 638, 289, 2, 11, 29] +[:mouse_move, 608, 314, 2, 12, 29] +[:mouse_move, 562, 342, 2, 13, 31] +[:mouse_move, 541, 350, 2, 14, 31] +[:mouse_move, 520, 356, 2, 15, 32] +[:mouse_move, 459, 360, 2, 16, 34] +[:mouse_move, 411, 357, 2, 17, 34] +[:mouse_move, 319, 340, 2, 18, 35] +[:mouse_move, 287, 330, 2, 19, 37] +[:mouse_move, 248, 308, 2, 20, 37] +[:mouse_move, 233, 298, 2, 21, 38] +[:mouse_move, 211, 283, 2, 22, 39] +[:mouse_move, 204, 278, 2, 23, 40] +[:mouse_move, 195, 272, 2, 24, 42] +[:mouse_move, 192, 269, 2, 25, 42] +[:mouse_move, 187, 266, 2, 26, 44] +[:mouse_move, 184, 263, 2, 27, 44] +[:mouse_move, 181, 261, 2, 28, 45] +[:mouse_move, 174, 255, 2, 29, 46] +[:mouse_move, 170, 252, 2, 30, 47] +[:mouse_move, 155, 244, 2, 31, 48] +[:mouse_move, 122, 232, 2, 32, 50] +[:mouse_move, 107, 227, 2, 33, 50] +[:mouse_move, 88, 224, 2, 34, 52] +[:mouse_move, 80, 223, 2, 35, 52] +[:mouse_move, 73, 223, 2, 36, 53] +[:mouse_move, 57, 224, 2, 37, 54] +[:mouse_move, 54, 224, 2, 38, 55] +[:mouse_move, 51, 224, 2, 39, 56] +[:mouse_move, 51, 223, 2, 40, 60] +[:mouse_move, 52, 221, 2, 41, 62] +[:mouse_move, 54, 219, 2, 42, 64] +[:mouse_move, 54, 218, 2, 43, 64] +[:mouse_move, 54, 219, 2, 44, 73] +[:mouse_move, 55, 221, 2, 45, 75] +[:mouse_move, 55, 224, 2, 46, 75] +[:mouse_move, 55, 230, 2, 47, 77] +[:mouse_move, 55, 232, 2, 48, 77] +[:mouse_move, 55, 238, 2, 49, 79] +[:mouse_move, 55, 243, 2, 50, 79] +[:mouse_move, 57, 254, 2, 51, 81] +[:mouse_move, 58, 256, 2, 52, 81] +[:mouse_button_pressed, 1, 0, 1, 53, 91] +[:mouse_move, 60, 256, 2, 54, 95] +[:mouse_move, 63, 256, 2, 55, 97] +[:mouse_move, 73, 256, 2, 56, 97] +[:mouse_move, 83, 256, 2, 57, 99] +[:mouse_move, 111, 257, 2, 58, 99] +[:mouse_move, 128, 257, 2, 59, 101] +[:mouse_move, 163, 257, 2, 60, 101] +[:mouse_move, 179, 257, 2, 61, 103] +[:mouse_move, 203, 257, 2, 62, 103] +[:mouse_move, 214, 257, 2, 63, 105] +[:mouse_move, 236, 257, 2, 64, 105] +[:mouse_move, 247, 257, 2, 65, 107] +[:mouse_move, 267, 257, 2, 66, 107] +[:mouse_move, 276, 257, 2, 67, 109] +[:mouse_move, 288, 257, 2, 68, 109] +[:mouse_move, 293, 257, 2, 69, 111] +[:mouse_move, 302, 257, 2, 70, 111] +[:mouse_move, 308, 257, 2, 71, 113] +[:mouse_move, 322, 257, 2, 72, 113] +[:mouse_move, 330, 257, 2, 73, 115] +[:mouse_move, 334, 257, 2, 74, 115] +[:mouse_move, 340, 257, 2, 75, 117] +[:mouse_move, 342, 257, 2, 76, 117] +[:mouse_move, 348, 257, 2, 77, 119] +[:mouse_move, 350, 257, 2, 78, 119] +[:mouse_move, 354, 257, 2, 79, 121] +[:mouse_button_up, 1, 0, 1, 80, 135] +[:mouse_move, 351, 257, 2, 81, 145] +[:mouse_move, 345, 257, 2, 82, 145] +[:mouse_move, 339, 258, 2, 83, 147] +[:mouse_move, 314, 261, 2, 84, 147] +[:mouse_move, 300, 262, 2, 85, 149] +[:mouse_move, 278, 264, 2, 86, 149] +[:mouse_move, 264, 265, 2, 87, 151] +[:mouse_move, 231, 265, 2, 88, 151] +[:mouse_move, 215, 264, 2, 89, 153] +[:mouse_move, 194, 262, 2, 90, 153] +[:mouse_move, 190, 261, 2, 91, 155] +[:mouse_move, 186, 260, 2, 92, 155] +[:mouse_move, 185, 260, 2, 93, 157] +[:mouse_move, 184, 259, 2, 94, 157] +[:mouse_move, 183, 259, 2, 95, 159] +[:mouse_move, 179, 259, 2, 96, 161] +[:mouse_move, 172, 259, 2, 97, 163] +[:mouse_move, 153, 259, 2, 98, 163] +[:mouse_move, 142, 259, 2, 99, 165] +[:mouse_move, 129, 258, 2, 100, 165] +[:mouse_move, 127, 257, 2, 101, 167] +[:mouse_move, 126, 257, 2, 102, 167] +[:mouse_move, 125, 257, 2, 103, 169] +[:mouse_move, 126, 257, 2, 104, 175] +[:mouse_move, 127, 257, 2, 105, 175] +[:mouse_move, 128, 257, 2, 106, 177] +[:mouse_move, 130, 257, 2, 107, 179] +[:mouse_move, 131, 257, 2, 108, 181] +[:mouse_move, 132, 256, 2, 109, 183] +[:mouse_move, 133, 256, 2, 110, 185] +[:mouse_move, 134, 256, 2, 111, 187] +[:mouse_move, 135, 256, 2, 112, 187] +[:mouse_move, 136, 256, 2, 113, 189] +[:mouse_move, 137, 256, 2, 114, 191] +[:mouse_move, 138, 256, 2, 115, 193] +[:mouse_button_pressed, 1, 0, 1, 116, 199] +[:mouse_move, 138, 255, 2, 117, 201] +[:mouse_button_up, 1, 0, 1, 118, 206] +[:mouse_move, 138, 256, 2, 119, 211] +[:mouse_move, 138, 257, 2, 120, 215] +[:mouse_move, 142, 267, 2, 121, 216] +[:mouse_move, 146, 274, 2, 122, 217] +[:mouse_move, 158, 291, 2, 123, 218] +[:mouse_move, 172, 304, 2, 124, 219] +[:mouse_move, 246, 354, 2, 125, 220] +[:mouse_move, 292, 380, 2, 126, 221] +[:mouse_move, 382, 424, 2, 127, 222] +[:mouse_move, 403, 436, 2, 128, 225] +[:mouse_move, 408, 437, 2, 129, 282] +[:mouse_move, 409, 437, 2, 130, 283] +[:mouse_move, 408, 438, 2, 131, 293] +[:mouse_move, 393, 438, 2, 132, 295] +[:mouse_move, 373, 435, 2, 133, 296] +[:mouse_move, 305, 421, 2, 134, 297] +[:mouse_move, 265, 410, 2, 135, 298] +[:mouse_move, 191, 391, 2, 136, 299] +[:mouse_move, 170, 386, 2, 137, 300] +[:mouse_move, 154, 380, 2, 138, 301] +[:mouse_move, 153, 381, 2, 139, 305] +[:mouse_move, 152, 381, 2, 140, 313] +[:mouse_move, 150, 381, 2, 141, 314] +[:mouse_move, 148, 379, 2, 142, 315] +[:mouse_move, 137, 372, 2, 143, 316] +[:mouse_move, 128, 366, 2, 144, 317] +[:mouse_move, 112, 359, 2, 145, 318] +[:mouse_move, 111, 359, 2, 146, 319] +[:mouse_move, 111, 358, 2, 147, 320] +[:mouse_move, 110, 358, 2, 148, 322] +[:mouse_move, 107, 357, 2, 149, 324] +[:mouse_move, 107, 356, 2, 150, 325] +[:mouse_move, 105, 356, 2, 151, 326] +[:mouse_move, 104, 356, 2, 152, 327] +[:mouse_move, 101, 354, 2, 153, 328] +[:mouse_move, 99, 352, 2, 154, 329] +[:mouse_move, 95, 350, 2, 155, 330] +[:mouse_move, 92, 348, 2, 156, 331] +[:mouse_move, 82, 345, 2, 157, 332] +[:mouse_move, 76, 343, 2, 158, 333] +[:mouse_move, 74, 342, 2, 159, 334] +[:mouse_move, 73, 342, 2, 160, 336] +[:mouse_move, 72, 342, 2, 161, 337] +[:mouse_move, 71, 343, 2, 162, 338] +[:mouse_move, 70, 343, 2, 163, 341] +[:mouse_move, 69, 343, 2, 164, 342] +[:mouse_move, 66, 344, 2, 165, 343] +[:mouse_move, 63, 345, 2, 166, 344] +[:mouse_move, 55, 348, 2, 167, 345] +[:mouse_move, 52, 348, 2, 168, 346] +[:mouse_move, 48, 350, 2, 169, 347] +[:mouse_move, 47, 350, 2, 170, 348] +[:mouse_move, 46, 350, 2, 171, 350] +[:mouse_move, 46, 349, 2, 172, 351] +[:mouse_move, 46, 348, 2, 173, 357] +[:mouse_move, 47, 348, 2, 174, 359] +[:mouse_move, 47, 347, 2, 175, 360] +[:mouse_move, 47, 346, 2, 176, 362] +[:mouse_move, 48, 345, 2, 177, 366] +[:mouse_button_pressed, 1, 0, 1, 178, 370] +[:mouse_move, 49, 346, 2, 179, 376] +[:mouse_move, 53, 346, 2, 180, 377] +[:mouse_move, 64, 348, 2, 181, 378] +[:mouse_move, 71, 348, 2, 182, 379] +[:mouse_move, 85, 350, 2, 183, 380] +[:mouse_move, 95, 351, 2, 184, 381] +[:mouse_move, 116, 351, 2, 185, 382] +[:mouse_move, 128, 351, 2, 186, 383] +[:mouse_move, 153, 351, 2, 187, 384] +[:mouse_move, 166, 352, 2, 188, 385] +[:mouse_move, 189, 354, 2, 189, 386] +[:mouse_move, 198, 354, 2, 190, 387] +[:mouse_move, 217, 354, 2, 191, 388] +[:mouse_move, 226, 354, 2, 192, 389] +[:mouse_move, 249, 355, 2, 193, 390] +[:mouse_move, 261, 355, 2, 194, 391] +[:mouse_move, 282, 355, 2, 195, 392] +[:mouse_move, 291, 355, 2, 196, 393] +[:mouse_move, 299, 354, 2, 197, 394] +[:mouse_move, 309, 353, 2, 198, 395] +[:mouse_move, 310, 353, 2, 199, 396] +[:mouse_move, 311, 353, 2, 200, 398] +[:mouse_move, 317, 352, 2, 201, 399] +[:mouse_move, 320, 352, 2, 202, 400] +[:mouse_move, 327, 352, 2, 203, 401] +[:mouse_move, 330, 352, 2, 204, 402] +[:mouse_move, 333, 351, 2, 205, 403] +[:mouse_move, 335, 351, 2, 206, 404] +[:mouse_move, 337, 351, 2, 207, 405] +[:mouse_move, 338, 351, 2, 208, 412] +[:mouse_move, 339, 351, 2, 209, 417] +[:mouse_move, 340, 351, 2, 210, 420] +[:mouse_move, 341, 351, 2, 211, 421] +[:mouse_move, 343, 351, 2, 212, 422] +[:mouse_move, 349, 351, 2, 213, 424] +[:mouse_move, 351, 351, 2, 214, 425] +[:mouse_move, 353, 351, 2, 215, 426] +[:mouse_move, 354, 351, 2, 216, 427] +[:mouse_move, 355, 351, 2, 217, 428] +[:mouse_move, 356, 351, 2, 218, 428] +[:mouse_move, 357, 351, 2, 219, 429] +[:mouse_move, 358, 351, 2, 220, 430] +[:mouse_move, 359, 351, 2, 221, 431] +[:mouse_move, 360, 351, 2, 222, 432] +[:mouse_move, 361, 351, 2, 223, 433] +[:mouse_move, 362, 351, 2, 224, 434] +[:mouse_move, 365, 351, 2, 225, 435] +[:mouse_move, 366, 351, 2, 226, 436] +[:mouse_move, 367, 351, 2, 227, 439] +[:mouse_move, 368, 351, 2, 228, 446] +[:mouse_move, 369, 351, 2, 229, 456] +[:mouse_move, 370, 351, 2, 230, 460] +[:mouse_button_up, 1, 0, 1, 231, 471] +[:key_down_raw, 1073741905, 0, 2, 232, 514] +[:key_down_raw, 1073741905, 0, 2, 233, 528] +[:key_down_raw, 32, 0, 2, 234, 529] +[:key_up_raw, 32, 0, 2, 235, 535] +[:key_up_raw, 1073741905, 0, 2, 236, 547] +[:key_down_raw, 1073741905, 0, 2, 237, 567] +[:key_down_raw, 32, 0, 2, 238, 577] +[:key_up_raw, 32, 0, 2, 239, 584] +[:key_up_raw, 1073741905, 0, 2, 240, 589] +[:key_down_raw, 32, 0, 2, 241, 608] +[:key_up_raw, 32, 0, 2, 242, 612] +[:key_down_raw, 32, 0, 2, 243, 619] +[:key_up_raw, 32, 0, 2, 244, 623] +[:key_down_raw, 32, 0, 2, 245, 627] +[:key_up_raw, 32, 0, 2, 246, 631] +[:mouse_move, 363, 354, 2, 247, 695] +[:mouse_move, 355, 354, 2, 248, 696] +[:mouse_move, 337, 351, 2, 249, 697] +[:mouse_move, 323, 347, 2, 250, 698] +[:mouse_move, 252, 326, 2, 251, 699] +[:mouse_move, 206, 312, 2, 252, 700] +[:mouse_move, 146, 292, 2, 253, 701] +[:mouse_move, 127, 286, 2, 254, 702] +[:mouse_move, 104, 279, 2, 255, 703] +[:mouse_move, 100, 277, 2, 256, 704] +[:mouse_move, 99, 277, 2, 257, 706] +[:mouse_move, 100, 277, 2, 258, 714] +[:mouse_move, 102, 277, 2, 259, 715] +[:mouse_move, 103, 277, 2, 260, 716] +[:mouse_move, 104, 276, 2, 261, 717] +[:mouse_move, 107, 273, 2, 262, 718] +[:mouse_move, 107, 272, 2, 263, 719] +[:mouse_move, 110, 270, 2, 264, 720] +[:mouse_move, 110, 269, 2, 265, 721] +[:mouse_move, 110, 268, 2, 266, 722] +[:mouse_move, 111, 266, 2, 267, 724] +[:mouse_move, 112, 264, 2, 268, 725] +[:mouse_move, 112, 261, 2, 269, 726] +[:mouse_move, 112, 260, 2, 270, 727] +[:mouse_move, 112, 259, 2, 271, 728] +[:key_down_raw, 120, 0, 2, 272, 739] +[:mouse_move, 111, 259, 2, 273, 745] +[:key_down_raw, 120, 0, 2, 274, 754] +[:key_down_raw, 120, 0, 2, 275, 756] +[:key_down_raw, 120, 0, 2, 276, 758] +[:key_down_raw, 120, 0, 2, 277, 760] +[:key_down_raw, 120, 0, 2, 278, 762] +[:mouse_button_pressed, 1, 0, 1, 279, 763] +[:key_down_raw, 120, 0, 2, 280, 764] +[:key_down_raw, 120, 0, 2, 281, 766] +[:key_down_raw, 120, 0, 2, 282, 768] +[:key_down_raw, 120, 0, 2, 283, 770] +[:mouse_button_up, 1, 0, 1, 284, 770] +[:key_down_raw, 120, 0, 2, 285, 772] +[:key_down_raw, 120, 0, 2, 286, 774] +[:key_down_raw, 120, 0, 2, 287, 776] +[:key_down_raw, 120, 0, 2, 288, 778] +[:mouse_move, 111, 262, 2, 289, 779] +[:mouse_move, 111, 271, 2, 290, 780] +[:key_down_raw, 120, 0, 2, 291, 780] +[:mouse_move, 110, 276, 2, 292, 781] +[:mouse_move, 108, 288, 2, 293, 782] +[:key_down_raw, 120, 0, 2, 294, 782] +[:mouse_move, 107, 295, 2, 295, 783] +[:mouse_move, 104, 312, 2, 296, 784] +[:key_down_raw, 120, 0, 2, 297, 784] +[:mouse_move, 104, 317, 2, 298, 785] +[:mouse_move, 102, 325, 2, 299, 786] +[:key_down_raw, 120, 0, 2, 300, 786] +[:mouse_move, 102, 328, 2, 301, 787] +[:mouse_move, 102, 332, 2, 302, 788] +[:key_down_raw, 120, 0, 2, 303, 788] +[:mouse_move, 102, 335, 2, 304, 789] +[:mouse_move, 102, 341, 2, 305, 790] +[:key_down_raw, 120, 0, 2, 306, 790] +[:mouse_move, 102, 343, 2, 307, 791] +[:mouse_move, 102, 345, 2, 308, 792] +[:key_down_raw, 120, 0, 2, 309, 792] +[:mouse_move, 102, 346, 2, 310, 793] +[:key_down_raw, 120, 0, 2, 311, 794] +[:mouse_move, 102, 347, 2, 312, 795] +[:key_down_raw, 120, 0, 2, 313, 796] +[:key_down_raw, 120, 0, 2, 314, 798] +[:mouse_move, 102, 348, 2, 315, 799] +[:key_down_raw, 120, 0, 2, 316, 800] +[:mouse_move, 103, 348, 2, 317, 801] +[:key_down_raw, 120, 0, 2, 318, 802] +[:key_down_raw, 120, 0, 2, 319, 804] +[:key_down_raw, 120, 0, 2, 320, 806] +[:key_down_raw, 120, 0, 2, 321, 808] +[:key_down_raw, 120, 0, 2, 322, 810] +[:mouse_move, 103, 349, 2, 323, 810] +[:mouse_move, 104, 349, 2, 324, 811] +[:key_down_raw, 120, 0, 2, 325, 812] +[:mouse_move, 104, 350, 2, 326, 813] +[:key_down_raw, 120, 0, 2, 327, 814] +[:key_down_raw, 120, 0, 2, 328, 816] +[:mouse_move, 105, 350, 2, 329, 817] +[:mouse_button_pressed, 1, 0, 1, 330, 817] +[:key_down_raw, 120, 0, 2, 331, 818] +[:key_down_raw, 120, 0, 2, 332, 820] +[:key_down_raw, 120, 0, 2, 333, 822] +[:key_down_raw, 120, 0, 2, 334, 824] +[:mouse_button_up, 1, 0, 1, 335, 826] +[:key_down_raw, 120, 0, 2, 336, 826] +[:key_down_raw, 120, 0, 2, 337, 828] +[:key_down_raw, 120, 0, 2, 338, 830] +[:key_down_raw, 120, 0, 2, 339, 832] +[:key_down_raw, 120, 0, 2, 340, 834] +[:mouse_move, 106, 350, 2, 341, 836] +[:key_down_raw, 120, 0, 2, 342, 836] +[:key_down_raw, 120, 0, 2, 343, 838] +[:key_up_raw, 120, 0, 2, 344, 839] +[:mouse_move, 107, 348, 2, 345, 842] +[:mouse_move, 108, 345, 2, 346, 843] +[:mouse_move, 109, 343, 2, 347, 844] +[:mouse_move, 109, 342, 2, 348, 845] +[:mouse_move, 109, 341, 2, 349, 852] +[:mouse_move, 111, 337, 2, 350, 853] +[:mouse_move, 113, 332, 2, 351, 854] +[:mouse_move, 116, 322, 2, 352, 855] +[:mouse_move, 118, 316, 2, 353, 856] +[:mouse_move, 119, 303, 2, 354, 857] +[:mouse_move, 120, 295, 2, 355, 858] +[:mouse_move, 120, 282, 2, 356, 859] +[:mouse_move, 120, 279, 2, 357, 860] +[:mouse_move, 121, 278, 2, 358, 861] +[:mouse_move, 121, 277, 2, 359, 865] +[:mouse_move, 121, 276, 2, 360, 868] +[:mouse_move, 120, 275, 2, 361, 869] +[:mouse_move, 120, 274, 2, 362, 870] +[:mouse_move, 118, 270, 2, 363, 871] +[:mouse_move, 118, 269, 2, 364, 872] +[:mouse_move, 117, 267, 2, 365, 873] +[:mouse_move, 117, 266, 2, 366, 880] +[:mouse_move, 118, 266, 2, 367, 881] +[:mouse_move, 118, 264, 2, 368, 882] +[:mouse_move, 118, 263, 2, 369, 883] +[:mouse_move, 118, 262, 2, 370, 884] +[:mouse_move, 118, 261, 2, 371, 887] +[:mouse_move, 119, 261, 2, 372, 888] +[:mouse_button_pressed, 1, 0, 1, 373, 909] +[:mouse_button_up, 1, 0, 1, 374, 912] +[:mouse_move, 118, 264, 2, 375, 914] +[:mouse_move, 116, 269, 2, 376, 915] +[:mouse_move, 113, 280, 2, 377, 916] +[:mouse_move, 111, 285, 2, 378, 917] +[:mouse_move, 109, 293, 2, 379, 918] +[:mouse_move, 108, 297, 2, 380, 919] +[:mouse_move, 105, 307, 2, 381, 920] +[:mouse_move, 103, 315, 2, 382, 921] +[:mouse_move, 101, 328, 2, 383, 922] +[:mouse_move, 101, 333, 2, 384, 923] +[:mouse_move, 102, 341, 2, 385, 924] +[:mouse_move, 102, 342, 2, 386, 925] +[:mouse_move, 103, 346, 2, 387, 926] +[:mouse_move, 103, 347, 2, 388, 927] +[:mouse_move, 103, 349, 2, 389, 928] +[:mouse_move, 104, 350, 2, 390, 930] +[:mouse_move, 104, 351, 2, 391, 933] +[:mouse_move, 104, 352, 2, 392, 939] +[:mouse_move, 105, 352, 2, 393, 940] +[:mouse_move, 106, 358, 2, 394, 941] +[:mouse_move, 107, 363, 2, 395, 942] +[:mouse_move, 108, 370, 2, 396, 943] +[:mouse_move, 109, 371, 2, 397, 944] +[:mouse_move, 109, 372, 2, 398, 945] +[:mouse_move, 109, 369, 2, 399, 953] +[:mouse_move, 109, 368, 2, 400, 954] +[:mouse_move, 109, 360, 2, 401, 955] +[:mouse_move, 109, 358, 2, 402, 956] +[:mouse_move, 109, 356, 2, 403, 957] +[:mouse_move, 109, 355, 2, 404, 958] +[:mouse_button_pressed, 1, 0, 1, 405, 970] +[:mouse_move, 109, 354, 2, 406, 970] +[:mouse_button_up, 1, 0, 1, 407, 975] +[:mouse_move, 109, 353, 2, 408, 985] +[:mouse_move, 109, 352, 2, 409, 987] +[:mouse_move, 109, 350, 2, 410, 988] +[:mouse_move, 109, 349, 2, 411, 990] +[:mouse_move, 109, 355, 2, 412, 996] +[:mouse_move, 109, 357, 2, 413, 997] +[:mouse_move, 106, 366, 2, 414, 998] +[:mouse_move, 104, 374, 2, 415, 999] +[:mouse_move, 100, 387, 2, 416, 1000] +[:mouse_move, 100, 391, 2, 417, 1001] +[:mouse_move, 101, 391, 2, 418, 1002] +[:mouse_move, 101, 390, 2, 419, 1008] +[:mouse_move, 102, 389, 2, 420, 1009] +[:mouse_move, 103, 387, 2, 421, 1010] +[:mouse_move, 103, 384, 2, 422, 1011] +[:mouse_move, 104, 382, 2, 423, 1012] +[:mouse_move, 104, 381, 2, 424, 1013] +[:mouse_move, 104, 380, 2, 425, 1014] +[:mouse_move, 105, 380, 2, 426, 1015] +[:mouse_move, 105, 379, 2, 427, 1030] +[:mouse_button_pressed, 1, 0, 1, 428, 1031] +[:mouse_move, 107, 379, 2, 429, 1039] +[:mouse_move, 111, 380, 2, 430, 1040] +[:mouse_move, 113, 380, 2, 431, 1041] +[:mouse_move, 124, 380, 2, 432, 1042] +[:mouse_move, 133, 381, 2, 433, 1043] +[:mouse_move, 145, 381, 2, 434, 1044] +[:mouse_move, 149, 381, 2, 435, 1045] +[:mouse_move, 152, 382, 2, 436, 1045] +[:mouse_move, 153, 382, 2, 437, 1046] +[:mouse_move, 154, 382, 2, 438, 1047] +[:mouse_move, 155, 382, 2, 439, 1048] +[:mouse_move, 158, 382, 2, 440, 1049] +[:mouse_move, 159, 382, 2, 441, 1050] +[:mouse_move, 162, 383, 2, 442, 1051] +[:mouse_move, 164, 383, 2, 443, 1052] +[:mouse_move, 168, 383, 2, 444, 1053] +[:mouse_move, 170, 384, 2, 445, 1053] +[:mouse_move, 172, 384, 2, 446, 1054] +[:mouse_move, 173, 384, 2, 447, 1055] +[:mouse_move, 176, 384, 2, 448, 1056] +[:mouse_move, 178, 384, 2, 449, 1057] +[:mouse_move, 180, 384, 2, 450, 1058] +[:mouse_move, 181, 384, 2, 451, 1059] +[:mouse_move, 183, 384, 2, 452, 1075] +[:mouse_move, 184, 384, 2, 453, 1076] +[:mouse_move, 186, 384, 2, 454, 1077] +[:mouse_move, 187, 384, 2, 455, 1078] +[:mouse_move, 190, 384, 2, 456, 1079] +[:mouse_move, 191, 384, 2, 457, 1080] +[:mouse_move, 193, 385, 2, 458, 1081] +[:mouse_move, 194, 385, 2, 459, 1083] +[:mouse_move, 195, 385, 2, 460, 1087] +[:mouse_move, 196, 385, 2, 461, 1090] +[:mouse_move, 197, 385, 2, 462, 1091] +[:mouse_move, 198, 385, 2, 463, 1093] +[:mouse_button_up, 1, 0, 1, 464, 1108] +[:mouse_move, 199, 385, 2, 465, 1110] +[:key_down_raw, 1073741905, 0, 2, 466, 1148] +[:key_down_raw, 1073741905, 0, 2, 467, 1163] +[:key_down_raw, 1073741905, 0, 2, 468, 1165] +[:key_down_raw, 1073741905, 0, 2, 469, 1167] +[:key_down_raw, 32, 0, 2, 470, 1168] +[:key_up_raw, 32, 0, 2, 471, 1174] +[:key_down_raw, 32, 0, 2, 472, 1210] +[:key_up_raw, 32, 0, 2, 473, 1217] +[:key_down_raw, 32, 0, 2, 474, 1225] +[:key_up_raw, 32, 0, 2, 475, 1231] +[:key_up_raw, 1073741905, 0, 2, 476, 1238] +[:mouse_move, 204, 382, 2, 477, 1263] +[:mouse_move, 213, 375, 2, 478, 1264] +[:mouse_move, 217, 364, 2, 479, 1265] +[:mouse_move, 217, 358, 2, 480, 1266] +[:mouse_move, 212, 345, 2, 481, 1267] +[:mouse_move, 208, 337, 2, 482, 1268] +[:mouse_move, 194, 319, 2, 483, 1269] +[:mouse_move, 183, 305, 2, 484, 1270] +[:mouse_move, 160, 280, 2, 485, 1271] +[:mouse_move, 150, 270, 2, 486, 1272] +[:mouse_move, 137, 258, 2, 487, 1273] +[:mouse_move, 135, 256, 2, 488, 1274] +[:key_down_raw, 32, 0, 2, 489, 1303] +[:key_up_raw, 32, 0, 2, 490, 1307] +[:key_down_raw, 1073741905, 0, 2, 491, 1341] +[:key_down_raw, 1073741905, 0, 2, 492, 1356] +[:key_down_raw, 1073741905, 0, 2, 493, 1358] +[:key_down_raw, 1073741905, 0, 2, 494, 1360] +[:key_down_raw, 32, 0, 2, 495, 1361] +[:key_up_raw, 32, 0, 2, 496, 1367] +[:key_up_raw, 1073741905, 0, 2, 497, 1381] +[:key_down_raw, 1073741904, 0, 2, 498, 1397] +[:key_up_raw, 1073741904, 0, 2, 499, 1403] +[:key_down_raw, 1073741905, 0, 2, 500, 1425] +[:key_down_raw, 1073741905, 0, 2, 501, 1440] +[:key_down_raw, 32, 0, 2, 502, 1441] +[:key_up_raw, 32, 0, 2, 503, 1450] +[:key_up_raw, 1073741905, 0, 2, 504, 1457] +[:key_down_raw, 1073741903, 0, 2, 505, 1470] +[:key_down_raw, 32, 0, 2, 506, 1479] +[:key_up_raw, 32, 0, 2, 507, 1485] +[:key_up_raw, 1073741903, 0, 2, 508, 1499] +[:key_down_raw, 32, 0, 2, 509, 1500] +[:key_up_raw, 32, 0, 2, 510, 1506] +[:key_down_raw, 32, 0, 2, 511, 1511] +[:key_up_raw, 32, 0, 2, 512, 1516] +[:key_down_raw, 32, 0, 2, 513, 1520] +[:key_up_raw, 32, 0, 2, 514, 1524] +[:key_down_raw, 32, 0, 2, 515, 1528] +[:key_up_raw, 32, 0, 2, 516, 1534] +[:key_down_raw, 32, 0, 2, 517, 1538] +[:key_down_raw, 1073741903, 0, 2, 518, 1540] +[:key_up_raw, 32, 0, 2, 519, 1545] +[:key_down_raw, 1073741903, 0, 2, 520, 1555] +[:key_down_raw, 32, 0, 2, 521, 1557] +[:key_up_raw, 1073741903, 0, 2, 522, 1558] +[:key_up_raw, 32, 0, 2, 523, 1563] +[:key_down_raw, 32, 0, 2, 524, 1567] +[:key_up_raw, 32, 0, 2, 525, 1581] +[:key_down_raw, 1073741904, 0, 2, 526, 1592] +[:key_down_raw, 1073741904, 0, 2, 527, 1607] +[:key_down_raw, 1073741904, 0, 2, 528, 1609] +[:key_down_raw, 1073741904, 0, 2, 529, 1611] +[:key_down_raw, 1073741904, 0, 2, 530, 1613] +[:key_down_raw, 1073741904, 0, 2, 531, 1615] +[:key_down_raw, 1073741904, 0, 2, 532, 1617] +[:key_down_raw, 1073741904, 0, 2, 533, 1619] +[:key_down_raw, 1073741904, 0, 2, 534, 1621] +[:key_down_raw, 1073741904, 0, 2, 535, 1623] +[:key_down_raw, 1073741904, 0, 2, 536, 1625] +[:key_down_raw, 1073741904, 0, 2, 537, 1627] +[:key_down_raw, 1073741904, 0, 2, 538, 1629] +[:key_down_raw, 1073741904, 0, 2, 539, 1631] +[:key_down_raw, 1073741904, 0, 2, 540, 1633] +[:key_up_raw, 1073741904, 0, 2, 541, 1633] +[:mouse_move, 137, 254, 2, 542, 1666] +[:mouse_move, 137, 253, 2, 543, 1667] +[:mouse_move, 137, 252, 2, 544, 1668] +[:mouse_move, 138, 248, 2, 545, 1669] +[:mouse_move, 141, 243, 2, 546, 1670] +[:mouse_move, 141, 242, 2, 547, 1675] +[:mouse_move, 142, 240, 2, 548, 1676] +[:mouse_move, 143, 240, 2, 549, 1677] +[:mouse_move, 143, 239, 2, 550, 1678] +[:mouse_move, 143, 238, 2, 551, 1682] +[:mouse_move, 144, 237, 2, 552, 1683] +[:mouse_move, 144, 236, 2, 553, 1684] +[:mouse_move, 144, 235, 2, 554, 1685] +[:mouse_move, 144, 234, 2, 555, 1686] +[:mouse_move, 146, 228, 2, 556, 1687] +[:mouse_move, 147, 226, 2, 557, 1688] +[:mouse_move, 147, 225, 2, 558, 1689] +[:mouse_button_pressed, 1, 0, 1, 559, 1703] +[:mouse_move, 148, 225, 2, 560, 1713] +[:mouse_move, 150, 225, 2, 561, 1714] +[:mouse_move, 157, 225, 2, 562, 1715] +[:mouse_move, 160, 225, 2, 563, 1716] +[:mouse_move, 170, 226, 2, 564, 1717] +[:mouse_move, 174, 226, 2, 565, 1718] +[:mouse_move, 179, 226, 2, 566, 1718] +[:mouse_move, 181, 226, 2, 567, 1719] +[:mouse_move, 185, 226, 2, 568, 1720] +[:mouse_move, 188, 226, 2, 569, 1721] +[:mouse_move, 195, 226, 2, 570, 1722] +[:mouse_move, 199, 226, 2, 571, 1723] +[:mouse_move, 205, 226, 2, 572, 1724] +[:mouse_move, 208, 226, 2, 573, 1724] +[:mouse_move, 216, 226, 2, 574, 1725] +[:mouse_move, 220, 226, 2, 575, 1726] +[:mouse_move, 225, 226, 2, 576, 1727] +[:mouse_move, 229, 226, 2, 577, 1728] +[:mouse_move, 236, 226, 2, 578, 1729] +[:mouse_move, 238, 226, 2, 579, 1729] +[:mouse_move, 240, 226, 2, 580, 1730] +[:mouse_move, 242, 226, 2, 581, 1731] +[:mouse_button_up, 1, 0, 1, 582, 1747] +[:mouse_move, 243, 227, 2, 583, 1749] +[:key_down_raw, 1073741903, 0, 2, 584, 1774] +[:key_up_raw, 1073741903, 0, 2, 585, 1783] +[:key_down_raw, 1073741906, 0, 2, 586, 1785] +[:key_up_raw, 1073741906, 0, 2, 587, 1789] +[:key_down_raw, 32, 0, 2, 588, 1815] +[:key_up_raw, 32, 0, 2, 589, 1819] +[:key_down_raw, 32, 0, 2, 590, 1825] +[:key_up_raw, 32, 0, 2, 591, 1831] +[:key_down_raw, 32, 0, 2, 592, 1845] +[:key_up_raw, 32, 0, 2, 593, 1851] +[:key_down_raw, 32, 0, 2, 594, 1856] +[:key_up_raw, 32, 0, 2, 595, 1863] +[:key_down_raw, 1073741904, 0, 2, 596, 1881] +[:key_down_raw, 1073741904, 0, 2, 597, 1896] +[:key_down_raw, 1073741904, 0, 2, 598, 1898] +[:key_down_raw, 1073741904, 0, 2, 599, 1900] +[:key_down_raw, 1073741904, 0, 2, 600, 1903] +[:key_down_raw, 1073741904, 0, 2, 601, 1904] +[:key_down_raw, 1073741904, 0, 2, 602, 1906] +[:key_up_raw, 1073741904, 0, 2, 603, 1908] +[:key_down_raw, 32, 0, 2, 604, 1920] +[:key_down_raw, 32, 0, 2, 605, 1935] +[:key_down_raw, 1073741903, 0, 2, 606, 1936] +[:key_down_raw, 1073741903, 0, 2, 607, 1951] +[:key_down_raw, 1073741903, 0, 2, 608, 1953] +[:key_up_raw, 32, 0, 2, 609, 1954] +[:key_up_raw, 1073741903, 0, 2, 610, 1954] +[:key_down_raw, 32, 0, 2, 611, 1985] +[:key_down_raw, 1073741903, 0, 2, 612, 1989] +[:key_up_raw, 32, 0, 2, 613, 1999] +[:key_up_raw, 1073741903, 0, 2, 614, 2002] +[:mouse_move, 245, 226, 2, 615, 2037] +[:mouse_move, 308, 213, 2, 616, 2038] +[:mouse_move, 380, 203, 2, 617, 2039] +[:mouse_move, 567, 189, 2, 618, 2040] +[:mouse_move, 663, 187, 2, 619, 2041] +[:mouse_move, 862, 189, 2, 620, 2042] +[:mouse_move, 931, 190, 2, 621, 2043] +[:mouse_move, 1002, 195, 2, 622, 2044] +[:mouse_move, 1016, 195, 2, 623, 2045] +[:mouse_move, 1031, 195, 2, 624, 2046] +[:key_down_raw, 96, 0, 2, 625, 2064] +[:key_up_raw, 96, 0, 2, 626, 2069] +[:mouse_move, 1031, 193, 2, 627, 2074] +[:mouse_move, 1031, 191, 2, 628, 2074] +[:mouse_move, 1031, 189, 2, 629, 2075] +[:mouse_move, 1031, 188, 2, 630, 2077] +[:mouse_move, 1031, 187, 2, 631, 2079] +[:mouse_move, 1029, 185, 2, 632, 2082] +[:mouse_move, 1023, 174, 2, 633, 2082] +[:mouse_move, 1017, 168, 2, 634, 2083] +[:mouse_move, 1005, 155, 2, 635, 2084] +[:mouse_move, 1000, 149, 2, 636, 2085] +[:mouse_move, 986, 140, 2, 637, 2086] +[:mouse_move, 980, 138, 2, 638, 2086] +[:mouse_move, 965, 131, 2, 639, 2087] +[:mouse_move, 953, 126, 2, 640, 2088] +[:mouse_move, 925, 115, 2, 641, 2089] +[:mouse_move, 912, 109, 2, 642, 2089] +[:mouse_move, 902, 105, 2, 643, 2090] +[:mouse_move, 891, 101, 2, 644, 2091] +[:mouse_move, 886, 99, 2, 645, 2092] +[:mouse_move, 877, 98, 2, 646, 2092] +[:mouse_move, 861, 97, 2, 647, 2093] +[:mouse_move, 857, 97, 2, 648, 2094] +[:mouse_move, 850, 98, 2, 649, 2095] +[:mouse_move, 849, 98, 2, 650, 2096] +[:mouse_move, 847, 99, 2, 651, 2096] +[:mouse_move, 846, 99, 2, 652, 2097] +[:mouse_move, 845, 99, 2, 653, 2098] +[:mouse_move, 842, 101, 2, 654, 2099] +[:mouse_move, 841, 101, 2, 655, 2100] +[:mouse_move, 840, 102, 2, 656, 2100] +[:mouse_move, 839, 103, 2, 657, 2104] +[:mouse_move, 840, 103, 2, 658, 2109] +[:mouse_move, 841, 103, 2, 659, 2110] +[:mouse_move, 843, 103, 2, 660, 2112] +[:mouse_move, 845, 103, 2, 661, 2113] +[:mouse_move, 846, 102, 2, 662, 2115] +[:mouse_move, 848, 102, 2, 663, 2116] +[:mouse_move, 855, 101, 2, 664, 2116] +[:mouse_move, 858, 100, 2, 665, 2117] +[:mouse_move, 862, 99, 2, 666, 2118] +[:mouse_move, 865, 98, 2, 667, 2119] +[:mouse_move, 867, 98, 2, 668, 2120] +[:mouse_move, 868, 97, 2, 669, 2121] +[:mouse_move, 869, 97, 2, 670, 2122] +[:mouse_move, 868, 97, 2, 671, 2128] +[:mouse_move, 864, 95, 2, 672, 2129] +[:mouse_move, 846, 92, 2, 673, 2129] +[:mouse_move, 834, 90, 2, 674, 2130] +[:mouse_move, 818, 88, 2, 675, 2131] +[:mouse_move, 813, 87, 2, 676, 2132] +[:mouse_move, 806, 87, 2, 677, 2132] +[:mouse_move, 803, 87, 2, 678, 2133] +[:mouse_move, 798, 87, 2, 679, 2134] +[:mouse_move, 796, 87, 2, 680, 2134] +[:mouse_move, 795, 87, 2, 681, 2135] +[:mouse_move, 794, 87, 2, 682, 2137] +[:key_down_raw, 13, 0, 2, 683, 2166] diff --git a/samples/04_physics_and_collisions/06_jump_physics/app/main.rb b/samples/04_physics_and_collisions/06_jump_physics/app/main.rb deleted file mode 100644 index 9d7a976..0000000 --- a/samples/04_physics_and_collisions/06_jump_physics/app/main.rb +++ /dev/null @@ -1,195 +0,0 @@ -=begin - - Reminders: - - - args.state.new_entity: Used when we want to create a new object, like a sprite or button. - For example, if we want to create a new button, we would declare it as a new entity and - then define its properties. (Remember, you can use state to define ANY property and it will - be retained across frames.) - - - args.outputs.solids: An array. The values generate a solid. - The parameters for a solid are [X, Y, WIDTH, HEIGHT, RED, GREEN, BLUE] - - - num1.greater(num2): Returns the greater value. - - - Hashes: Collection of unique keys and their corresponding values. The value can be found - using their keys. - - - ARRAY#inside_rect?: Returns true or false depending on if the point is inside the rect. - -=end - -# This sample app is a game that requires the user to jump from one platform to the next. -# As the player successfully clears platforms, they become smaller and move faster. - -class VerticalPlatformer - attr_gtk - - # declares vertical platformer as new entity - def s - state.vertical_platformer ||= state.new_entity(:vertical_platformer) - state.vertical_platformer - end - - # creates a new platform using a hash - def new_platform hash - s.new_entity_strict(:platform, hash) # platform key - end - - # calls methods needed for the game to run properly - def tick - defaults - render - calc - input - end - - # Sets default values - def defaults - s.platforms ||= [ # initializes platforms collection with two platforms using hashes - new_platform(x: 0, y: 0, w: 700, h: 32, dx: 1, speed: 0, rect: nil), - new_platform(x: 0, y: 300, w: 700, h: 32, dx: 1, speed: 0, rect: nil), # 300 pixels higher - ] - - s.tick_count = args.state.tick_count - s.gravity = -0.3 # what goes up must come down because of gravity - s.player.platforms_cleared ||= 0 # counts how many platforms the player has successfully cleared - s.player.x ||= 0 # sets player values - s.player.y ||= 100 - s.player.w ||= 64 - s.player.h ||= 64 - s.player.dy ||= 0 # change in position - s.player.dx ||= 0 - s.player_jump_power = 15 - s.player_jump_power_duration = 10 - s.player_max_run_speed = 5 - s.player_speed_slowdown_rate = 0.9 - s.player_acceleration = 1 - s.camera ||= { y: -100 } # shows view on screen (as the player moves upward, the camera does too) - end - - # Outputs objects onto the screen - def render - outputs.solids << s.platforms.map do |p| # outputs platforms onto screen - [p.x + 300, p.y - s.camera[:y], p.w, p.h] # add 300 to place platform in horizontal center - # don't forget, position of platform is denoted by bottom left hand corner - end - - # outputs player using hash - outputs.solids << { - x: s.player.x + 300, # player positioned on top of platform - y: s.player.y - s.camera[:y], - w: s.player.w, - h: s.player.h, - r: 100, # color saturation - g: 100, - b: 200 - } - end - - # Performs calculations - def calc - s.platforms.each do |p| # for each platform in the collection - p.rect = [p.x, p.y, p.w, p.h] # set the definition - end - - # sets player point by adding half the player's width to the player's x - s.player.point = [s.player.x + s.player.w.half, s.player.y] # change + to - and see what happens! - - # search the platforms collection to find if the player's point is inside the rect of a platform - collision = s.platforms.find { |p| s.player.point.inside_rect? p.rect } - - # if collision occurred and player is moving down (or not moving vertically at all) - if collision && s.player.dy <= 0 - s.player.y = collision.rect.y + collision.rect.h - 2 # player positioned on top of platform - s.player.dy = 0 if s.player.dy < 0 # player stops moving vertically - if !s.player.platform - s.player.dx = 0 # no horizontal movement - end - # changes horizontal position of player by multiplying collision change in x (dx) by speed and adding it to current x - s.player.x += collision.dx * collision.speed - s.player.platform = collision # player is on the platform that it collided with (or landed on) - if s.player.falling # if player is falling - s.player.dx = 0 # no horizontal movement - end - s.player.falling = false - s.player.jumped_at = nil - else - s.player.platform = nil # player is not on a platform - s.player.y += s.player.dy # velocity is the change in position - s.player.dy += s.gravity # acceleration is the change in velocity; what goes up must come down - end - - s.platforms.each do |p| # for each platform in the collection - p.x += p.dx * p.speed # x is incremented by product of dx and speed (causes platform to move horizontally) - # changes platform's x so it moves left and right across the screen (between -300 and 300 pixels) - if p.x < -300 # if platform goes too far left - p.dx *= -1 # dx is scaled down - p.x = -300 # as far left as possible within scope - elsif p.x > (1000 - p.w) # if platform's x is greater than 300 - p.dx *= -1 - p.x = (1000 - p.w) # set to 300 (as far right as possible within scope) - end - end - - delta = (s.player.y - s.camera[:y] - 100) # used to position camera view - - if delta > -200 - s.camera[:y] += delta * 0.01 # allows player to see view as they move upwards - s.player.x += s.player.dx # velocity is change in position; change in x increases by dx - - # searches platform collection to find platforms located more than 300 pixels above the player - has_platforms = s.platforms.find { |p| p.y > (s.player.y + 300) } - if !has_platforms # if there are no platforms 300 pixels above the player - width = 700 - (700 * (0.1 * s.player.platforms_cleared)) # the next platform is smaller than previous - s.player.platforms_cleared += 1 # player successfully cleared another platform - last_platform = s.platforms[-1] # platform just cleared becomes last platform - # another platform is created 300 pixels above the last platform, and this - # new platform has a smaller width and moves faster than all previous platforms - s.platforms << new_platform(x: (700 - width) * rand, # random x position - y: last_platform.y + 300, - w: width, - h: 32, - dx: 1.randomize(:sign), # random change in x - speed: 2 * s.player.platforms_cleared, - rect: nil) - end - else - s.as_hash.clear # otherwise clear the hash (no new platform is necessary) - end - end - - # Takes input from the user to move the player - def input - if inputs.keyboard.space # if the space bar is pressed - s.player.jumped_at ||= s.tick_count # set to current frame - - # if the time that has passed since the jump is less than the duration of a jump (10 frames) - # and the player is not falling - if s.player.jumped_at.elapsed_time < s.player_jump_power_duration && !s.player.falling - s.player.dy = s.player_jump_power # player jumps up - end - end - - if inputs.keyboard.key_up.space # if space bar is in "up" state - s.player.falling = true # player is falling - end - - if inputs.keyboard.left # if left key is pressed - s.player.dx -= s.player_acceleration # player's position changes, decremented by acceleration - s.player.dx = s.player.dx.greater(-s.player_max_run_speed) # dx is either current dx or -5, whichever is greater - elsif inputs.keyboard.right # if right key is pressed - s.player.dx += s.player_acceleration # player's position changes, incremented by acceleration - s.player.dx = s.player.dx.lesser(s.player_max_run_speed) # dx is either current dx or 5, whichever is lesser - else - s.player.dx *= s.player_speed_slowdown_rate # scales dx down - end - end -end - -$game = VerticalPlatformer.new - -def tick args - $game.args = args - $game.tick -end diff --git a/samples/04_physics_and_collisions/06_jump_physics/replay.txt b/samples/04_physics_and_collisions/06_jump_physics/replay.txt deleted file mode 100644 index 966dbcd..0000000 --- a/samples/04_physics_and_collisions/06_jump_physics/replay.txt +++ /dev/null @@ -1,124 +0,0 @@ -replay_version 2.0 -stopped_at 1260 -seed 100 -recorded_at Sun Sep 29 22:23:22 2019 -[:key_down_raw, 1073741903, 0, 2, 1, 45] -[:key_down_raw, 1073741903, 0, 2, 2, 70] -[:key_down_raw, 1073741903, 0, 2, 3, 72] -[:key_down_raw, 1073741903, 0, 2, 4, 74] -[:key_down_raw, 1073741903, 0, 2, 5, 76] -[:key_down_raw, 1073741903, 0, 2, 6, 78] -[:key_down_raw, 1073741903, 0, 2, 7, 80] -[:key_down_raw, 1073741903, 0, 2, 8, 82] -[:key_down_raw, 1073741903, 0, 2, 9, 84] -[:key_down_raw, 1073741903, 0, 2, 10, 86] -[:key_down_raw, 1073741903, 0, 2, 11, 88] -[:key_up_raw, 1073741903, 0, 2, 12, 89] -[:key_down_raw, 1073741904, 0, 2, 13, 92] -[:key_down_raw, 1073741903, 0, 2, 14, 112] -[:key_up_raw, 1073741904, 0, 2, 15, 115] -[:key_down_raw, 1073741903, 0, 2, 16, 137] -[:key_down_raw, 1073741903, 0, 2, 17, 139] -[:key_down_raw, 8, 0, 2, 18, 141] -[:key_up_raw, 1073741903, 0, 2, 19, 146] -[:key_down_raw, 1073741903, 0, 2, 20, 147] -[:key_up_raw, 1073741903, 0, 2, 21, 147] -[:key_down_raw, 1073741904, 0, 2, 22, 154] -[:key_up_raw, 8, 0, 2, 23, 172] -[:key_down_raw, 1073741903, 0, 2, 24, 175] -[:key_up_raw, 1073741904, 0, 2, 25, 175] -[:key_down_raw, 32, 0, 2, 26, 194] -[:key_down_raw, 1073741904, 0, 2, 27, 201] -[:key_up_raw, 1073741903, 0, 2, 28, 202] -[:key_down_raw, 1073741903, 0, 2, 29, 222] -[:key_up_raw, 1073741904, 0, 2, 30, 226] -[:key_up_raw, 32, 0, 2, 31, 233] -[:key_down_raw, 1073741903, 0, 2, 32, 247] -[:key_down_raw, 1073741903, 0, 2, 33, 249] -[:key_down_raw, 1073741903, 0, 2, 34, 251] -[:key_down_raw, 1073741903, 0, 2, 35, 253] -[:key_down_raw, 1073741903, 0, 2, 36, 255] -[:key_down_raw, 1073741903, 0, 2, 37, 257] -[:key_down_raw, 1073741903, 0, 2, 38, 259] -[:key_down_raw, 1073741903, 0, 2, 39, 261] -[:key_down_raw, 1073741903, 0, 2, 40, 263] -[:key_down_raw, 1073741903, 0, 2, 41, 265] -[:key_down_raw, 1073741903, 0, 2, 42, 267] -[:key_down_raw, 1073741903, 0, 2, 43, 269] -[:key_down_raw, 1073741903, 0, 2, 44, 271] -[:key_down_raw, 1073741903, 0, 2, 45, 273] -[:key_down_raw, 1073741903, 0, 2, 46, 275] -[:key_up_raw, 1073741903, 0, 2, 47, 276] -[:key_down_raw, 1073741904, 0, 2, 48, 280] -[:key_up_raw, 1073741904, 0, 2, 49, 297] -[:key_down_raw, 1073741903, 0, 2, 50, 300] -[:key_down_raw, 32, 0, 2, 51, 303] -[:key_up_raw, 32, 0, 2, 52, 308] -[:key_up_raw, 1073741903, 0, 2, 53, 334] -[:key_down_raw, 1073741904, 0, 2, 54, 336] -[:key_down_raw, 1073741903, 0, 2, 55, 355] -[:key_up_raw, 1073741904, 0, 2, 56, 355] -[:key_up_raw, 1073741903, 0, 2, 57, 373] -[:key_down_raw, 1073741904, 0, 2, 58, 380] -[:key_down_raw, 32, 0, 2, 59, 398] -[:key_up_raw, 32, 0, 2, 60, 404] -[:key_up_raw, 1073741904, 0, 2, 61, 490] -[:key_down_raw, 32, 0, 2, 62, 510] -[:key_up_raw, 32, 0, 2, 63, 516] -[:key_down_raw, 1073741903, 0, 2, 64, 517] -[:key_up_raw, 1073741903, 0, 2, 65, 537] -[:key_down_raw, 1073741904, 0, 2, 66, 538] -[:key_up_raw, 1073741904, 0, 2, 67, 553] -[:key_down_raw, 32, 0, 2, 68, 653] -[:key_up_raw, 32, 0, 2, 69, 659] -[:key_down_raw, 1073741903, 0, 2, 70, 661] -[:key_down_raw, 1073741903, 0, 2, 71, 686] -[:key_up_raw, 1073741903, 0, 2, 72, 687] -[:key_down_raw, 1073741904, 0, 2, 73, 690] -[:key_down_raw, 1073741904, 0, 2, 74, 715] -[:key_down_raw, 1073741904, 0, 2, 75, 717] -[:key_down_raw, 1073741904, 0, 2, 76, 719] -[:key_down_raw, 1073741904, 0, 2, 77, 721] -[:key_down_raw, 1073741904, 0, 2, 78, 723] -[:key_down_raw, 1073741904, 0, 2, 79, 725] -[:key_down_raw, 1073741904, 0, 2, 80, 727] -[:key_down_raw, 1073741904, 0, 2, 81, 729] -[:key_up_raw, 1073741904, 0, 2, 82, 731] -[:key_down_raw, 1073741903, 0, 2, 83, 740] -[:key_down_raw, 32, 0, 2, 84, 749] -[:key_up_raw, 32, 0, 2, 85, 756] -[:key_up_raw, 1073741903, 0, 2, 86, 789] -[:key_down_raw, 1073741904, 0, 2, 87, 792] -[:key_down_raw, 1073741904, 0, 2, 88, 817] -[:key_up_raw, 1073741904, 0, 2, 89, 817] -[:key_down_raw, 32, 0, 2, 90, 844] -[:key_down_raw, 1073741903, 0, 2, 91, 846] -[:key_up_raw, 32, 0, 2, 92, 852] -[:key_down_raw, 1073741903, 0, 2, 93, 871] -[:key_down_raw, 1073741903, 0, 2, 94, 873] -[:key_down_raw, 1073741903, 0, 2, 95, 875] -[:key_down_raw, 1073741903, 0, 2, 96, 877] -[:key_down_raw, 1073741903, 0, 2, 97, 879] -[:key_down_raw, 1073741903, 0, 2, 98, 881] -[:key_down_raw, 1073741903, 0, 2, 99, 883] -[:key_down_raw, 1073741903, 0, 2, 100, 885] -[:key_down_raw, 1073741903, 0, 2, 101, 887] -[:key_up_raw, 1073741903, 0, 2, 102, 887] -[:key_down_raw, 1073741904, 0, 2, 103, 897] -[:key_up_raw, 1073741904, 0, 2, 104, 901] -[:key_down_raw, 32, 0, 2, 105, 948] -[:key_up_raw, 32, 0, 2, 106, 953] -[:key_down_raw, 1073741904, 0, 2, 107, 977] -[:key_up_raw, 1073741904, 0, 2, 108, 991] -[:key_down_raw, 32, 0, 2, 109, 1056] -[:key_up_raw, 32, 0, 2, 110, 1060] -[:key_down_raw, 1073741904, 0, 2, 111, 1065] -[:key_down_raw, 1073741904, 0, 2, 112, 1090] -[:key_down_raw, 1073741904, 0, 2, 113, 1092] -[:key_down_raw, 1073741904, 0, 2, 114, 1094] -[:key_down_raw, 1073741904, 0, 2, 115, 1096] -[:key_up_raw, 1073741904, 0, 2, 116, 1098] -[:key_down_raw, 1073741903, 0, 2, 117, 1108] -[:key_up_raw, 1073741903, 0, 2, 118, 1127] -[:key_down_raw, 1073742051, 1024, 2, 119, 1258] -[:key_down_raw, 113, 1024, 2, 120, 1259] diff --git a/samples/04_physics_and_collisions/07_jump_physics/app/main.rb b/samples/04_physics_and_collisions/07_jump_physics/app/main.rb index 9d7a976..3fcb9e9 100644 --- a/samples/04_physics_and_collisions/07_jump_physics/app/main.rb +++ b/samples/04_physics_and_collisions/07_jump_physics/app/main.rb @@ -9,6 +9,7 @@ - args.outputs.solids: An array. The values generate a solid. The parameters for a solid are [X, Y, WIDTH, HEIGHT, RED, GREEN, BLUE] + For more information about solids, go to mygame/documentation/03-solids-and-borders.md. - num1.greater(num2): Returns the greater value. @@ -36,7 +37,7 @@ class VerticalPlatformer s.new_entity_strict(:platform, hash) # platform key end - # calls methods needed for the game to run properly + # calls methods needed for game to run properly def tick defaults render diff --git a/samples/04_physics_and_collisions/08_bouncing_on_collision/app/block.rb b/samples/04_physics_and_collisions/08_bouncing_on_collision/app/block.rb index db6687a..9254ee4 100644 --- a/samples/04_physics_and_collisions/08_bouncing_on_collision/app/block.rb +++ b/samples/04_physics_and_collisions/08_bouncing_on_collision/app/block.rb @@ -110,8 +110,8 @@ class Block #Find the vector that is perpendicular to the slope perpVect = { x: x, y: y } - mag = (perpVect.x**2 + perpVect.y**2)**0.5 # find the magnitude of the perpVect - perpVect = {x: perpVect.x/(mag), y: perpVect.y/(mag)} # divide the perpVect by the magnitude to make it a unit vector + mag = (perpVect.x**2 + perpVect.y**2)**0.5 # find the magniude of the perpVect + perpVect = {x: perpVect.x/(mag), y: perpVect.y/(mag)} # divide the perpVect by the magniude to make it a unit vector previousPosition = { # calculate an ESTIMATE of the previousPosition of the ball x:args.state.ball.center.x-args.state.ball.velocity.x, @@ -140,7 +140,7 @@ class Block dampener = 0.3 ynew *= dampener * 0.5 - #If the bounce is very low, that means the ball is rolling and we don't want to dampen the X velocity + #If the bounce is very low, that means the ball is rolling and we don't want to dampenen the X velocity if ynew > -0.1 xnew *= dampener end @@ -152,7 +152,7 @@ class Block args.state.ball.velocity.x = -xnew args.state.ball.velocity.y = -ynew - #Set the position of the ball to the previous position so it doesn't warp through the block + #Set the position of the ball to the previous position so it doesn't warp throught the block args.state.ball.center.x = previousPosition.x args.state.ball.center.y = previousPosition.y end diff --git a/samples/04_physics_and_collisions/08_bouncing_on_collision/app/main.rb b/samples/04_physics_and_collisions/08_bouncing_on_collision/app/main.rb index 22d3711..f5883ad 100644 --- a/samples/04_physics_and_collisions/08_bouncing_on_collision/app/main.rb +++ b/samples/04_physics_and_collisions/08_bouncing_on_collision/app/main.rb @@ -60,7 +60,7 @@ begin :default_methods center = args.grid.w / 2 for i in (0...5) - #Create a ramp of blocks. Not going to be perfect because of the float to integer conversion and anisotropic to isotropic conversion + #Create a ramp of blocks. Not going to be perfect because of the float to integer conversion and anisotropic to isotropic coversion args.state.blocks.append(Block.new((center + 100 + (i * horizontal_offset)).to_i, 100 + (vertical_offset * i) + (i * block_size), block_size, rotation)) args.state.blocks.append(Block.new((center - 100 - (i * horizontal_offset)).to_i, 100 + (vertical_offset * i) + (i * block_size), block_size, -rotation)) end diff --git a/samples/04_physics_and_collisions/08_bouncing_on_collision/app/peg.rb b/samples/04_physics_and_collisions/08_bouncing_on_collision/app/peg.rb index daf95ec..52045de 100644 --- a/samples/04_physics_and_collisions/08_bouncing_on_collision/app/peg.rb +++ b/samples/04_physics_and_collisions/08_bouncing_on_collision/app/peg.rb @@ -1,11 +1,11 @@ class Peg def initialize(x, y, block_size) - @x = x # x coordinate of the LEFT side of the peg - @y = y # y coordinate of the RIGHT side of the peg + @x = x # x cordinate of the LEFT side of the peg + @y = y # y cordinate of the RIGHT side of the peg @block_size = block_size # diameter of the peg @radius = @block_size/2.0 # radius of the peg - @center = { # coordinatees of the CENTER of the peg + @center = { # cordinatees of the CENTER of the peg x: @x+@block_size/2.0, y: @y+@block_size/2.0 } @@ -116,8 +116,8 @@ class Peg } perpVect = {x: pointB.x - pointA.x, y:pointB.y - pointA.y} # perpVect is to be VECTOR of the perpendicular tangent - mag = (perpVect.x**2 + perpVect.y**2)**0.5 # find the magnitude of the perpVect - perpVect = {x: perpVect.x/(mag), y: perpVect.y/(mag)} # divide the perpVect by the magnitude to make it a unit vector + mag = (perpVect.x**2 + perpVect.y**2)**0.5 # find the magniude of the perpVect + perpVect = {x: perpVect.x/(mag), y: perpVect.y/(mag)} # divide the perpVect by the magniude to make it a unit vector perpVect = {x: -perpVect.y, y: perpVect.x} # swap the x and y and multiply by -1 to make the vector perpendicular args.state.display_value = perpVect if perpVect.y > 0 #ensure perpVect points upward @@ -130,12 +130,12 @@ class Peg } yInterc = pointA.y + -slope*pointA.x - if slope == INFINITY # the perpVect presently either points in the correct direction or it is 180 degrees off we need to correct this + if slope == INFINITY # the perpVect presently either points in the correct dirrection or it is 180 degrees off we need to correct this if previousPosition.x < pointA.x perpVect = {x: perpVect.x*-1, y: perpVect.y*-1} yInterc = -INFINITY end - elsif previousPosition.y < slope*previousPosition.x + yInterc # check if ball is below or above the collider to determine if perpVect is - or + + elsif previousPosition.y < slope*previousPosition.x + yInterc # check if ball is bellow or above the collider to determine if perpVect is - or + perpVect = {x: perpVect.x*-1, y: perpVect.y*-1} end @@ -148,7 +148,7 @@ class Peg fbx = velocityMag * Math.cos(theta_ball) #the x component of the ball's velocity fby = velocityMag * Math.sin(theta_ball) #the y component of the ball's velocity - repelMag = getRepelMagnitude( # the magnitude of the collision vector + repelMag = getRepelMagnitude( # the magniude of the collision vector args, fbx, fby, @@ -173,7 +173,7 @@ class Peg if args.state.ball.center.y > @center.y # if the ball is above the middle of the peg we need to temporarily ignore some of the gravity args.state.ball.velocity.y = ynew + GRAVITY * 0.01 else - args.state.ball.velocity.y = ynew - GRAVITY * 0.01 # if the ball is below the middle of the peg we need to temporarily increase the power of the gravity + args.state.ball.velocity.y = ynew - GRAVITY * 0.01 # if the ball is bellow the middle of the peg we need to temporarily increase the power of the gravity end args.state.ball.center.x+= args.state.ball.velocity.x # update the position of the ball so it never looks like the ball is intersecting the circle diff --git a/samples/04_physics_and_collisions/08_bouncing_on_collision/app/vector2d.rb b/samples/04_physics_and_collisions/08_bouncing_on_collision/app/vector2d.rb index 0b302f3..9cb1954 100644 --- a/samples/04_physics_and_collisions/08_bouncing_on_collision/app/vector2d.rb +++ b/samples/04_physics_and_collisions/08_bouncing_on_collision/app/vector2d.rb @@ -42,7 +42,7 @@ class Vector2d Vector2d.new(@x/mag, @y/mag) end - #TODO delete? + #TODO delet? def distABS vect (((vect.x-@x)**2+(vect.y-@y)**2)**0.5).abs() end diff --git a/samples/04_physics_and_collisions/08_bouncing_on_collision/docs/LinearCollider.md b/samples/04_physics_and_collisions/08_bouncing_on_collision/docs/LinearCollider.md index 41227a2..315ecf8 100644 --- a/samples/04_physics_and_collisions/08_bouncing_on_collision/docs/LinearCollider.md +++ b/samples/04_physics_and_collisions/08_bouncing_on_collision/docs/LinearCollider.md @@ -1,13 +1,13 @@ -
- -
- -
- -
- -
- -
- -
+
+ +
+ +
+ +
+ +
+ +
+ +
diff --git a/samples/04_physics_and_collisions/09_arbitrary_collision/app/linear_collider.rb b/samples/04_physics_and_collisions/09_arbitrary_collision/app/linear_collider.rb index 679f3a4..9571669 100644 --- a/samples/04_physics_and_collisions/09_arbitrary_collision/app/linear_collider.rb +++ b/samples/04_physics_and_collisions/09_arbitrary_collision/app/linear_collider.rb @@ -82,7 +82,7 @@ class LinearCollider #if at least on point is in the rectangle then collision? is true - otherwise false for point in points #Check whether a given point lies inside a rectangle or not: - #if the sum of the area of traingls, PAB, PBC, PCD, PAD equal the area of the rec, then an intersection has occurred + #if the sum of the area of traingls, PAB, PBC, PCD, PAD equal the area of the rec, then an intersection has occured areaRec = triArea.call(rpointA, rpointB, rpointC)+triArea.call(rpointA, rpointC, rpointD) areaSum = [ triArea.call(point, rpointA, rpointB),triArea.call(point, rpointB, rpointC), @@ -148,7 +148,7 @@ class LinearCollider perpVect = {x: perpVect.x*-1, y: perpVect.y*-1} yInterc = -INFINITY end - elsif previousPosition.y < slope*previousPosition.x + yInterc #check if ball is below or above the collider to determine if perpVect is - or + + elsif previousPosition.y < slope*previousPosition.x + yInterc #check if ball is bellow or above the collider to determine if perpVect is - or + perpVect = {x: perpVect.x*-1, y: perpVect.y*-1} end diff --git a/samples/04_physics_and_collisions/09_arbitrary_collision/app/main.rb b/samples/04_physics_and_collisions/09_arbitrary_collision/app/main.rb index 228eb9d..b2905fb 100644 --- a/samples/04_physics_and_collisions/09_arbitrary_collision/app/main.rb +++ b/samples/04_physics_and_collisions/09_arbitrary_collision/app/main.rb @@ -29,7 +29,7 @@ end begin :default_methods def init_blocks args block_size = args.state.board_width / 8 - #Space in between each block + #Space inbetween each block block_offset = 4 args.state.squares ||=[ diff --git a/samples/04_physics_and_collisions/09_arbitrary_collision/app/vector2d.rb b/samples/04_physics_and_collisions/09_arbitrary_collision/app/vector2d.rb index 0b302f3..9cb1954 100644 --- a/samples/04_physics_and_collisions/09_arbitrary_collision/app/vector2d.rb +++ b/samples/04_physics_and_collisions/09_arbitrary_collision/app/vector2d.rb @@ -42,7 +42,7 @@ class Vector2d Vector2d.new(@x/mag, @y/mag) end - #TODO delete? + #TODO delet? def distABS vect (((vect.x-@x)**2+(vect.y-@y)**2)**0.5).abs() end diff --git a/samples/04_physics_and_collisions/09_arbitrary_collision/docs/LinearCollider.md b/samples/04_physics_and_collisions/09_arbitrary_collision/docs/LinearCollider.md index 41227a2..315ecf8 100644 --- a/samples/04_physics_and_collisions/09_arbitrary_collision/docs/LinearCollider.md +++ b/samples/04_physics_and_collisions/09_arbitrary_collision/docs/LinearCollider.md @@ -1,13 +1,13 @@ -
- -
- -
- -
- -
- -
- -
+
+ +
+ +
+ +
+ +
+ +
+ +
diff --git a/samples/04_physics_and_collisions/10_collision_with_object_removal/app/linear_collider.rb b/samples/04_physics_and_collisions/10_collision_with_object_removal/app/linear_collider.rb index 0a20583..69ada5b 100644 --- a/samples/04_physics_and_collisions/10_collision_with_object_removal/app/linear_collider.rb +++ b/samples/04_physics_and_collisions/10_collision_with_object_removal/app/linear_collider.rb @@ -1,4 +1,4 @@ -#The LinearCollider (theoretically) produces collisions upon a line segment defined point.y two x,y coordinates +#The LinearCollider (theoretically) produces collisions upon a line segment defined point.y two x,y cordinates class LinearCollider @@ -6,13 +6,13 @@ class LinearCollider #last [Array of length 2] end of the line segment as a x,y cordinate #inorder for the LinearCollider to be functional the line segment must be said to have a thickness - #(as it is unlikely that a colliding object will land exactly on the linesegment) + #(as it is unlikly that a colliding object will land exactly on the linesegment) #extension defines if the line's thickness extends negatively or positively #extension :pos extends positively #extension :neg extends negatively - #thickness [float] how thick the line should be (should always be at least as large as the magnitude of the colliding object) + #thickness [float] how thick the line should be (should always be atleast as large as the magnitude of the colliding object) def initialize (pointA, pointB, extension=:neg, thickness=10) @pointA = pointA @pointB = pointB diff --git a/samples/04_physics_and_collisions/10_collision_with_object_removal/app/vector2d.rb b/samples/04_physics_and_collisions/10_collision_with_object_removal/app/vector2d.rb index 37ea141..97cf286 100644 --- a/samples/04_physics_and_collisions/10_collision_with_object_removal/app/vector2d.rb +++ b/samples/04_physics_and_collisions/10_collision_with_object_removal/app/vector2d.rb @@ -43,7 +43,7 @@ class Vector2d Vector2d.new(@x/mag, @y/mag) end - #TODO delete? + #TODO delet? def distABS vect (((vect.x-@x)**2+(vect.y-@y)**2)**0.5).abs() end diff --git a/samples/05_mouse/01_mouse_click/app/main.rb b/samples/05_mouse/01_mouse_click/app/main.rb index 80b91df..8969a6e 100644 --- a/samples/05_mouse/01_mouse_click/app/main.rb +++ b/samples/05_mouse/01_mouse_click/app/main.rb @@ -33,9 +33,11 @@ - args.outputs.borders: An array. The values generate a border. The parameters are [X, Y, WIDTH, HEIGHT, RED, GREEN, BLUE] + For more information about borders, go to mygame/documentation/03-solids-and-borders.md. - args.outputs.labels: An array. The values generate a label. The parameters are [X, Y, TEXT, SIZE, ALIGNMENT, RED, GREEN, BLUE, ALPHA, FONT STYLE] + For more information about labels, go to mygame/documentation/02-labels. =end @@ -120,7 +122,7 @@ class TicTacToe space.piece = state.current_turn # This ternary operator statement allows us to change the current player's turn. - # If it is currently x's turn, it becomes o's turn. If it is not x's turn, it becomes x's turn. + # If it is currently x's turn, it becomes o's turn. If it is not x's turn, it become's x's turn. state.current_turn = state.current_turn == :x ? :o : :x end diff --git a/samples/05_mouse/02_mouse_move/app/main.rb b/samples/05_mouse/02_mouse_move/app/main.rb index 684928b..97edbe7 100644 --- a/samples/05_mouse/02_mouse_move/app/main.rb +++ b/samples/05_mouse/02_mouse_move/app/main.rb @@ -14,9 +14,11 @@ - args.inputs.keyboard.key_down.KEY: Determines if a key is being held or pressed. Stores the frame the "down" event occurred. + For more information about the keyboard, go to mygame/documentation/06-keyboard.md. - args.outputs.sprites: An array. The values generate a sprite. The parameters are [X, Y, WIDTH, HEIGHT, PATH, ANGLE, ALPHA, RED, GREEN, BLUE] + For more information about sprites, go to mygame/documentation/05-sprites.md. - args.state.new_entity: Used when we want to create a new object, like a sprite or button. When we want to create a new object, we can declare it as a new entity and then define @@ -198,13 +200,13 @@ class ProtectThePuppiesFromTheZombies state.zombies = state.zombies - killed_this_frame # remove newly killed zombies from zombies collection state.killed_zombies += killed_this_frame # add newly killed zombies to killed zombies - if killed_this_frame.length > 0 # if at least one zombie was killed in the frame + if killed_this_frame.length > 0 # if atleast one zombie was killed in the frame state.flash_at = state.tick_count # flash_at set to the frame when the zombie was killed # Don't forget, the rendered flash lasts for 10 frames after the zombie is killed (look at render_flash method) end # Sets the tick_count (passage of time) as the value of the death_at variable for each killed zombie. - # Death_at stores the frame where a zombie was killed. + # Death_at stores the frame a zombie was killed. killed_this_frame.each do |z| z.death_at = state.tick_count end diff --git a/samples/05_mouse/03_mouse_move_paint_app/app/main.rb b/samples/05_mouse/03_mouse_move_paint_app/app/main.rb index be983a8..9303949 100644 --- a/samples/05_mouse/03_mouse_move_paint_app/app/main.rb +++ b/samples/05_mouse/03_mouse_move_paint_app/app/main.rb @@ -34,13 +34,14 @@ - args.outputs.labels: An array. The values in the array generate a label. The parameters are [X, Y, TEXT, SIZE, ALIGN, RED, GREEN, BLUE, ALPHA, FONT STYLE] + For more information about labels, go to mygame/documentation/02-labels.md. - ARRAY#inside_rect?: Returns true or false depending on if the point is inside the rect. =end # This sample app shows an empty grid that the user can paint on. -# To paint, the user must keep their mouse pressed and drag it around the grid. +# To paint, the user must keep their mouse presssed and drag it around the grid. # The "clear" button allows users to clear the grid so they can start over. class PaintApp diff --git a/samples/05_mouse/04_coordinate_systems/app/main.rb b/samples/05_mouse/04_coordinate_systems/app/main.rb index 8e5578f..fcfa090 100644 --- a/samples/05_mouse/04_coordinate_systems/app/main.rb +++ b/samples/05_mouse/04_coordinate_systems/app/main.rb @@ -5,6 +5,7 @@ - args.inputs.mouse.click.position: Coordinates of the mouse's position on the screen. Unlike args.inputs.mouse.click.point, the mouse does not need to be pressed down for position to know the mouse's coordinates. + For more information about the mouse, go to mygame/documentation/07-mouse.md. Reminders: @@ -20,12 +21,15 @@ - args.outputs.labels: An array that generates a label. The parameters are [X, Y, TEXT, SIZE, ALIGN, RED, GREEN, BLUE, ALPHA, FONT STYLE] + For more information about labels, go to mygame/documentation/02-labels.md. - args.outputs.solids: An array that generates a solid. The parameters are [X, Y, WIDTH, HEIGHT, RED, GREEN, BLUE, ALPHA] + For more information about solids, go to mygame/documentation/03-solids-and-borders.md. - args.outputs.lines: An array that generates a line. The parameters are [X, Y, X2, Y2, RED, GREEN, BLUE, ALPHA] + For more information about lines, go to mygame/documentation/04-lines.md. =end diff --git a/samples/06_save_load/01_save_load_game/app/main.rb b/samples/06_save_load/01_save_load_game/app/main.rb index 2d2bc41..251848a 100644 --- a/samples/06_save_load/01_save_load_game/app/main.rb +++ b/samples/06_save_load/01_save_load_game/app/main.rb @@ -36,6 +36,7 @@ - args.outputs.labels: An array. Values generate a label. Parameters are [X, Y, TEXT, SIZE, ALIGN, RED, GREEN, BLUE, ALPHA, FONT STYLE] + For more information, go to mygame/documentation/02-labels.md. - ARRAY#inside_rect?: An array with at least two values is considered a point. An array with at least four values is considered a rect. The inside_rect? function returns true @@ -48,7 +49,7 @@ class TextedBasedGame - # Contains methods needed for the game to run properly. + # Contains methods needed for game to run properly. # Increments tick count by 1 each time it runs (60 times in a single second) def tick default @@ -59,7 +60,7 @@ class TextedBasedGame # Sets default values. # The ||= ensures that a variable's value is only set to the value following the = sign - # if the value has not already been set before. Initialization happens only in the first frame. + # if the value has not already been set before. Intialization happens only in the first frame. def default state.engine_tick_count ||= 0 state.active_module ||= :room @@ -286,7 +287,7 @@ class TextedBasedGamePresenter end # instructions for users on how to add the missing method_to_call to the code - puts "It looks like #{method_to_call} doesn't exist on TextedBasedGamePresenter. Please add this method:" + puts "It looks like #{method_to_call} doesn't exists on TextedBasedGamePresenter. Please add this method:" puts "Just copy the code below and put it in the #{TextedBasedGamePresenter} class definition." puts "" puts "```" @@ -345,7 +346,7 @@ class TextedBasedGamePresenter @game end - # Initializes the game and creates an empty list of buttons. + # Initalizes the game and creates an empty list of buttons. def initialize @game = TextedBasedGame.new self @button_list ||= {} diff --git a/samples/07_advanced_audio/01_audio_mixer/app/main.rb b/samples/07_advanced_audio/01_audio_mixer/app/main.rb new file mode 100644 index 0000000..3a85d47 --- /dev/null +++ b/samples/07_advanced_audio/01_audio_mixer/app/main.rb @@ -0,0 +1,376 @@ +# these are the properties that you can sent on args.audio +def spawn_new_sound args, name, path + # Spawn randomly in an area that won't be covered by UI. + screenx = (rand * 600.0) + 200.0 + screeny = (rand * 400.0) + 100.0 + + id = new_sound_id! args + # you can hang anything on the audio hashes you want, so we store the + # actual screen position in here for convenience. + args.audio[id] = { + name: name, + input: path, + screenx: screenx, + screeny: screeny, + x: ((screenx / 1279.0) * 2.0) - 1.0, # scale to -1.0 - 1.0 range + y: ((screeny / 719.0) * 2.0) - 1.0, # scale to -1.0 - 1.0 range + z: 0.0, + gain: 1.0, + pitch: 1.0, + looping: true, + paused: false + } + + args.state.selected = id +end + +# these are values you can change on the ~args.audio~ data structure +def input_panel args + return unless args.state.panel + return if args.state.dragging + + audio_entry = args.audio[args.state.selected] + results = args.state.panel + + if args.state.mouse_state == :held && args.inputs.mouse.position.inside_rect?(results.pitch_slider_rect.rect) + audio_entry.pitch = 2.0 * ((args.inputs.mouse.x - results.pitch_slider_rect.x).to_f / (results.pitch_slider_rect.w - 1.0)) + elsif args.state.mouse_state == :held && args.inputs.mouse.position.inside_rect?(results.playtime_slider_rect.rect) + audio_entry.playtime = audio_entry.length_ * ((args.inputs.mouse.x - results.playtime_slider_rect.x).to_f / (results.playtime_slider_rect.w - 1.0)) + elsif args.state.mouse_state == :held && args.inputs.mouse.position.inside_rect?(results.gain_slider_rect.rect) + audio_entry.gain = (args.inputs.mouse.x - results.gain_slider_rect.x).to_f / (results.gain_slider_rect.w - 1.0) + elsif args.inputs.mouse.click && args.inputs.mouse.position.inside_rect?(results.looping_checkbox_rect.rect) + audio_entry.looping = !audio_entry.looping + elsif args.inputs.mouse.click && args.inputs.mouse.position.inside_rect?(results.paused_checkbox_rect.rect) + audio_entry.paused = !audio_entry.paused + elsif args.inputs.mouse.click && args.inputs.mouse.position.inside_rect?(results.delete_button_rect.rect) + args.audio.delete args.state.selected + end +end + +def render_sources args + args.outputs.primitives << args.audio.keys.map do |k| + s = args.audio[k] + + isselected = (k == args.state.selected) + + color = isselected ? [ 0, 255, 0, 255 ] : [ 0, 0, 255, 255 ] + [ + [s.screenx, s.screeny, args.state.boxsize, args.state.boxsize, *color].solid, + + { + x: s.screenx + args.state.boxsize.half, + y: s.screeny, + text: s.name, + r: 255, + g: 255, + b: 255, + alignment_enum: 1 + }.label! + ] + end +end + +def playtime_str t + minutes = (t / 60.0).floor + seconds = t - (minutes * 60.0).to_f + return minutes.to_s + ':' + seconds.floor.to_s + ((seconds - seconds.floor).to_s + "000")[1..3] +end + +def label_with_drop_shadow x, y, text + [ + { x: x + 1, y: y + 1, text: text, vertical_alignment_enum: 1, alignment_enum: 1, r: 0, g: 0, b: 0 }.label!, + { x: x + 2, y: y + 0, text: text, vertical_alignment_enum: 1, alignment_enum: 1, r: 0, g: 0, b: 0 }.label!, + { x: x + 0, y: y + 1, text: text, vertical_alignment_enum: 1, alignment_enum: 1, r: 200, g: 200, b: 200 }.label! + ] +end + +def check_box opts = {} + checkbox_template = opts.args.layout.rect(w: 0.5, h: 0.5, col: 2) + final_rect = checkbox_template.center_inside_rect_y(opts.args.layout.rect(row: opts.row, col: opts.col)) + color = { r: 0, g: 0, b: 0 } + color = { r: 255, g: 255, b: 255 } if opts.checked + + { + rect: final_rect, + primitives: [ + (final_rect.to_solid color) + ] + } +end + +def progress_bar opts = {} + outer_rect = opts.args.layout.rect(row: opts.row, col: opts.col, w: 5, h: 1) + color = opts.percentage * 255 + baseline_progress_bar = opts.args + .layout + .rect(w: 5, h: 0.5) + + final_rect = baseline_progress_bar.center_inside_rect(outer_rect) + center = final_rect.rect_center_point + + { + rect: final_rect, + primitives: [ + final_rect.merge(r: color, g: color, b: color, a: 128).solid!, + label_with_drop_shadow(center.x, center.y, opts.text) + ] + } +end + +def panel_primitives args, audio_entry + results = { primitives: [] } + + return results unless audio_entry + + # this uses DRGTK's layout apis to layout the controls + # imagine the screen is split into equal cells (24 cells across, 12 cells up and down) + # args.layout.rect returns a hash which we merge values with to create primitives + # using args.layout.rect removes the need for pixel pushing + + # args.outputs.debug << args.layout.debug_primitives(r: 255, g: 255, b: 255) + + white_color = { r: 255, g: 255, b: 255 } + label_style = white_color.merge(vertical_alignment_enum: 1) + + # panel background + results.primitives << args.layout.rect(row: 0, col: 0, w: 7, h: 6, include_col_gutter: true, include_row_gutter: true) + .border!(r: 255, g: 255, b: 255) + + # title + results.primitives << args.layout.point(row: 0, col: 3.5, row_anchor: 0.5) + .merge(label_style) + .merge(text: "Source #{args.state.selected} (#{args.audio[args.state.selected].name})", + size_enum: 3, + alignment_enum: 1) + + # seperator line + results.primitives << args.layout.rect(row: 1, col: 0, w: 7, h: 0) + .line!(white_color) + + # screen location + results.primitives << args.layout.point(row: 1.0, col: 0, row_anchor: 0.5) + .merge(label_style) + .merge(text: "screen:") + + results.primitives << args.layout.point(row: 1.0, col: 2, row_anchor: 0.5) + .merge(label_style) + .merge(text: "(#{audio_entry.screenx.to_i}, #{audio_entry.screeny.to_i})") + + # position + results.primitives << args.layout.point(row: 1.5, col: 0, row_anchor: 0.5) + .merge(label_style) + .merge(text: "position:") + + results.primitives << args.layout.point(row: 1.5, col: 2, row_anchor: 0.5) + .merge(label_style) + .merge(text: "(#{audio_entry[:x].round(5).to_s[0..6]}, #{audio_entry[:y].round(5).to_s[0..6]})") + + results.primitives << args.layout.point(row: 2.0, col: 0, row_anchor: 0.5) + .merge(label_style) + .merge(text: "pitch:") + + results.pitch_slider_rect = progress_bar(row: 2.0, col: 2, + percentage: audio_entry.pitch / 2.0, + text: "#{audio_entry.pitch.to_sf}", + args: args) + + results.primitives << results.pitch_slider_rect.primitives + + results.primitives << args.layout.point(row: 2.5, col: 0, row_anchor: 0.5) + .merge(label_style) + .merge(text: "playtime:") + + results.playtime_slider_rect = progress_bar(args: args, + row: 2.5, + col: 2, + percentage: audio_entry.playtime / audio_entry.length_, + text: "#{playtime_str(audio_entry.playtime)} / #{playtime_str(audio_entry.length_)}") + + results.primitives << results.playtime_slider_rect.primitives + + results.primitives << args.layout.point(row: 3.0, col: 0, row_anchor: 0.5) + .merge(label_style) + .merge(text: "gain:") + + results.gain_slider_rect = progress_bar(args: args, + row: 3.0, + col: 2, + percentage: audio_entry.gain, + text: "#{audio_entry.gain.to_sf}") + + results.primitives << results.gain_slider_rect.primitives + + + results.primitives << args.layout.point(row: 3.5, col: 0, row_anchor: 0.5) + .merge(label_style) + .merge(text: "looping:") + + checkbox_template = args.layout.rect(w: 0.5, h: 0.5, col: 2) + + results.looping_checkbox_rect = check_box(args: args, row: 3.5, col: 2, checked: audio_entry.looping) + results.primitives << results.looping_checkbox_rect.primitives + + results.primitives << args.layout.point(row: 4.0, col: 0, row_anchor: 0.5) + .merge(label_style) + .merge(text: "paused:") + + checkbox_template = args.layout.rect(w: 0.5, h: 0.5, col: 2) + + results.paused_checkbox_rect = check_box(args: args, row: 4.0, col: 2, checked: !audio_entry.paused) + results.primitives << results.paused_checkbox_rect.primitives + + results.delete_button_rect = { rect: args.layout.rect(row: 5, col: 0, w: 7, h: 1) } + + results.primitives << results.delete_button_rect.to_solid(r: 180) + + results.primitives << args.layout.point(row: 5, col: 3.5, row_anchor: 0.5) + .merge(label_style) + .merge(text: "DELETE", alignment_enum: 1) + + return results +end + +def render_panel args + args.state.panel = nil + audio_entry = args.audio[args.state.selected] + return unless audio_entry + + mouse_down = (args.state.mouse_held >= 0) + args.state.panel = panel_primitives args, audio_entry + args.outputs.primitives << args.state.panel.primitives +end + +def new_sound_id! args + args.state.sound_id ||= 0 + args.state.sound_id += 1 + args.state.sound_id +end + +def render_launcher args + args.outputs.primitives << args.state.spawn_sound_buttons.map(&:primitives) +end + +def render_ui args + render_launcher args + render_panel args +end + +def tick args + defaults args + render args + input args +end + +def input args + if !args.audio[args.state.selected] + args.state.selected = nil + args.state.dragging = nil + end + + # spawn button and node interaction + if args.inputs.mouse.click + spawn_sound_button = args.state.spawn_sound_buttons.find { |b| args.inputs.mouse.inside_rect? b.rect } + + audio_click_key, audio_click_value = args.audio.find do |k, v| + args.inputs.mouse.inside_rect? [v.screenx, v.screeny, args.state.boxsize, args.state.boxsize] + end + + if spawn_sound_button + args.state.selected = nil + spawn_new_sound args, spawn_sound_button.name, spawn_sound_button.path + elsif audio_click_key + args.state.selected = audio_click_key + end + end + + if args.state.mouse_state == :held && args.state.selected + v = args.audio[args.state.selected] + if args.inputs.mouse.inside_rect? [v.screenx, v.screeny, args.state.boxsize, args.state.boxsize] + args.state.dragging = args.state.selected + end + + if args.state.dragging + s = args.audio[args.state.selected] + # you can hang anything on the audio hashes you want, so we store the + # actual screen position so it doesn't scale weirdly vs your mouse. + s.screenx = args.inputs.mouse.x - (args.state.boxsize / 2) + s.screeny = args.inputs.mouse.y - (args.state.boxsize / 2) + + s.screeny = 50 if s.screeny < 50 + s.screeny = (719 - args.state.boxsize) if s.screeny > (719 - args.state.boxsize) + s.screenx = 0 if s.screenx < 0 + s.screenx = (1279 - args.state.boxsize) if s.screenx > (1279 - args.state.boxsize) + + s.x = ((s.screenx / 1279.0) * 2.0) - 1.0 # scale to -1.0 - 1.0 range + s.y = ((s.screeny / 719.0) * 2.0) - 1.0 # scale to -1.0 - 1.0 range + end + elsif args.state.mouse_state == :released + args.state.dragging = nil + end + + input_panel args +end + +def defaults args + args.state.mouse_state ||= :released + args.state.dragging_source ||= false + args.state.selected ||= 0 + args.state.next_sound_index ||= 0 + args.state.boxsize ||= 30 + args.state.sound_files ||= [ + { name: :tada, path: "sounds/tada.wav" }, + { name: :splash, path: "sounds/splash.wav" }, + { name: :drum, path: "sounds/drum.wav" }, + { name: :spring, path: "sounds/spring.wav" }, + { name: :music, path: "sounds/music.ogg" } + ] + + # generate buttons based off the sound collection above + args.state.spawn_sound_buttons ||= begin + # create a group of buttons + # column centered (using col_offset to calculate the column offset) + # where each item is 2 columns apart + rects = args.layout.rect_group row: 11, + col_offset: { + count: args.state.sound_files.length, + w: 2 + }, + dcol: 2, + w: 2, + h: 1, + group: args.state.sound_files + + # now that you have the rects + # construct the metadata for the buttons + rects.map do |rect| + { + rect: rect, + name: rect.name, + path: rect.path, + primitives: [ + rect.to_border(r: 255, g: 255, b: 255), + rect.to_label(x: rect.center_x, + y: rect.center_y, + text: "#{rect.name}", + alignment_enum: 1, + vertical_alignment_enum: 1, + r: 255, g: 255, b: 255) + ] + } + end + end + + if args.inputs.mouse.up + args.state.mouse_state = :released + args.state.dragging_source = false + elsif args.inputs.mouse.down + args.state.mouse_state = :held + end + + args.outputs.background_color = [ 0, 0, 0, 255 ] +end + +def render args + render_ui args + render_sources args +end diff --git a/samples/07_advanced_audio/01_audio_mixer/app/server_ip_address.txt b/samples/07_advanced_audio/01_audio_mixer/app/server_ip_address.txt new file mode 100644 index 0000000..531e136 --- /dev/null +++ b/samples/07_advanced_audio/01_audio_mixer/app/server_ip_address.txt @@ -0,0 +1 @@ +192.168.1.65 \ No newline at end of file diff --git a/samples/07_advanced_audio/01_audio_mixer/license-for-audio.txt b/samples/07_advanced_audio/01_audio_mixer/license-for-audio.txt new file mode 100644 index 0000000..f05c25c --- /dev/null +++ b/samples/07_advanced_audio/01_audio_mixer/license-for-audio.txt @@ -0,0 +1,48 @@ +The audio files in this sample are used under various Creative Common licenses: + + +sounds/1.wav: + + Party Pack, Horn Coil 01, Long, 01.wav by InspectorJ (www.jshaw.co.uk) of Freesound.org + (We converted this to mono output.) + Original: https://freesound.org/s/484267/ + License: https://creativecommons.org/licenses/by/3.0/ + + +sounds/2.wav: + + SPLASH.wav by petenice + Original: https://freesound.org/s/9508/ + License: https://creativecommons.org/publicdomain/zero/1.0/ + + +sounds/3.wav: + + buzz roll.wav by bigjoedrummer + (We converted this to mono output.) + Original: https://freesound.org/s/77305/ + License: https://creativecommons.org/publicdomain/zero/1.0/ + + +sounds/4.wav: + + sword04.wav by Erdie + Original: https://freesound.org/s/27858/ + License: https://creativecommons.org/licenses/by/3.0/ + + +sounds/5.wav: + + Game Over Arcade.wav by myfox14 + (We converted this to mono output.) + Original: https://freesound.org/s/382310/ + License: https://creativecommons.org/publicdomain/zero/1.0/ + + +sounds/6.ogg: + + Arcade Music Loop.wav by joshuaempyre ( https://www.empyreanma.com/welcome ) + (We converted this to Ogg Vorbis format, and mono output.) + Original: https://freesound.org/s/251461/ + License: https://creativecommons.org/licenses/by/3.0/ + diff --git a/samples/07_advanced_audio/01_audio_mixer/license-for-sample.txt b/samples/07_advanced_audio/01_audio_mixer/license-for-sample.txt new file mode 100644 index 0000000..100dcec --- /dev/null +++ b/samples/07_advanced_audio/01_audio_mixer/license-for-sample.txt @@ -0,0 +1,9 @@ +Copyright 2019 DragonRuby LLC + +MIT License + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/samples/07_advanced_audio/01_audio_mixer/metadata/game_metadata.txt b/samples/07_advanced_audio/01_audio_mixer/metadata/game_metadata.txt new file mode 100644 index 0000000..16cef1d --- /dev/null +++ b/samples/07_advanced_audio/01_audio_mixer/metadata/game_metadata.txt @@ -0,0 +1,6 @@ +devid=amirrajan +devtitle=Amir Rajan +gameid=hello-world +gametitle=Hello World +version=1.0 +icon=metadata/icon.png diff --git a/samples/07_advanced_audio/01_audio_mixer/metadata/icon.png b/samples/07_advanced_audio/01_audio_mixer/metadata/icon.png new file mode 100644 index 0000000..e20e8c2 Binary files /dev/null and b/samples/07_advanced_audio/01_audio_mixer/metadata/icon.png differ diff --git a/samples/07_advanced_audio/01_audio_mixer/metadata/ios_metadata.txt b/samples/07_advanced_audio/01_audio_mixer/metadata/ios_metadata.txt new file mode 100644 index 0000000..fbd92f5 --- /dev/null +++ b/samples/07_advanced_audio/01_audio_mixer/metadata/ios_metadata.txt @@ -0,0 +1,9 @@ +# ios_metadata.txt is used by the Pro version of DragonRuby Game Toolkit to create iOS apps. +# Information about the Pro version can be found at: http://dragonruby.org/toolkit/game#purchase + +# teamid needs to be set to your assigned Team Id which can be found at https://developer.apple.com/account/#/membership/ +teamid= +# appid needs to be set to your application identifier which can be found at https://developer.apple.com/account/resources/identifiers/list +appid= +# appname is the name you want to show up underneath the app icon on the device. Keep it under 10 characters. +appname= diff --git a/samples/07_advanced_audio/01_audio_mixer/replay.txt b/samples/07_advanced_audio/01_audio_mixer/replay.txt new file mode 100644 index 0000000..3ddde51 --- /dev/null +++ b/samples/07_advanced_audio/01_audio_mixer/replay.txt @@ -0,0 +1,995 @@ +replay_version 2.0 +stopped_at 2551 +seed 100 +recorded_at Wed Jul 14 23:43:22 2021 +[:mouse_button_up, 1, 0, 1, 1, 3] +[:mouse_move, 797, 90, 2, 2, 111] +[:mouse_move, 796, 93, 2, 3, 112] +[:mouse_move, 794, 97, 2, 4, 113] +[:mouse_move, 794, 98, 2, 5, 114] +[:mouse_move, 794, 104, 2, 6, 115] +[:mouse_move, 793, 106, 2, 7, 116] +[:mouse_move, 794, 105, 2, 8, 117] +[:mouse_move, 796, 104, 2, 9, 128] +[:mouse_move, 798, 103, 2, 10, 129] +[:mouse_move, 802, 100, 2, 11, 130] +[:mouse_move, 805, 100, 2, 12, 131] +[:mouse_move, 809, 100, 2, 13, 132] +[:mouse_move, 810, 100, 2, 14, 133] +[:mouse_move, 811, 100, 2, 15, 134] +[:mouse_move, 812, 100, 2, 16, 135] +[:mouse_move, 814, 102, 2, 17, 138] +[:mouse_move, 817, 105, 2, 18, 139] +[:mouse_move, 823, 118, 2, 19, 140] +[:mouse_move, 826, 130, 2, 20, 141] +[:mouse_move, 832, 169, 2, 21, 142] +[:mouse_move, 834, 196, 2, 22, 143] +[:mouse_move, 834, 262, 2, 23, 144] +[:mouse_move, 833, 295, 2, 24, 145] +[:mouse_move, 829, 327, 2, 25, 146] +[:mouse_move, 825, 352, 2, 26, 147] +[:mouse_move, 815, 390, 2, 27, 148] +[:mouse_move, 805, 414, 2, 28, 149] +[:mouse_move, 798, 424, 2, 29, 150] +[:mouse_move, 786, 439, 2, 30, 151] +[:mouse_move, 783, 443, 2, 31, 152] +[:mouse_move, 779, 450, 2, 32, 153] +[:mouse_move, 777, 454, 2, 33, 154] +[:mouse_move, 775, 461, 2, 34, 155] +[:mouse_move, 775, 465, 2, 35, 157] +[:mouse_move, 777, 470, 2, 36, 158] +[:mouse_move, 783, 490, 2, 37, 159] +[:mouse_move, 787, 502, 2, 38, 160] +[:mouse_move, 791, 528, 2, 39, 161] +[:mouse_move, 794, 548, 2, 40, 162] +[:mouse_move, 802, 623, 2, 41, 163] +[:mouse_move, 809, 662, 2, 42, 164] +[:mouse_move, 819, 691, 2, 43, 165] +[:mouse_move, 820, 692, 2, 44, 166] +[:mouse_move, 820, 690, 2, 45, 169] +[:mouse_move, 821, 685, 2, 46, 170] +[:mouse_move, 823, 681, 2, 47, 171] +[:mouse_move, 823, 680, 2, 48, 172] +[:mouse_move, 823, 679, 2, 49, 173] +[:mouse_move, 824, 678, 2, 50, 174] +[:mouse_move, 825, 677, 2, 51, 175] +[:mouse_move, 826, 675, 2, 52, 176] +[:mouse_move, 827, 674, 2, 53, 177] +[:mouse_move, 828, 673, 2, 54, 178] +[:mouse_move, 829, 673, 2, 55, 179] +[:mouse_move, 831, 672, 2, 56, 180] +[:mouse_move, 832, 671, 2, 57, 181] +[:mouse_move, 835, 669, 2, 58, 182] +[:mouse_move, 837, 667, 2, 59, 183] +[:mouse_move, 839, 663, 2, 60, 184] +[:mouse_move, 839, 662, 2, 61, 185] +[:mouse_move, 840, 661, 2, 62, 189] +[:mouse_move, 841, 659, 2, 63, 190] +[:mouse_move, 841, 658, 2, 64, 191] +[:mouse_move, 842, 654, 2, 65, 192] +[:mouse_move, 843, 652, 2, 66, 193] +[:mouse_move, 845, 644, 2, 67, 194] +[:mouse_move, 846, 641, 2, 68, 195] +[:mouse_move, 847, 640, 2, 69, 196] +[:mouse_button_pressed, 1, 0, 1, 70, 221] +[:mouse_button_up, 1, 0, 1, 71, 225] +[:mouse_move, 846, 640, 2, 72, 227] +[:mouse_move, 839, 634, 2, 73, 254] +[:mouse_move, 830, 624, 2, 74, 255] +[:mouse_move, 782, 580, 2, 75, 256] +[:mouse_move, 735, 541, 2, 76, 257] +[:mouse_move, 650, 468, 2, 77, 258] +[:mouse_move, 626, 444, 2, 78, 259] +[:mouse_move, 615, 431, 2, 79, 260] +[:mouse_move, 601, 412, 2, 80, 261] +[:mouse_move, 597, 405, 2, 81, 262] +[:mouse_move, 589, 393, 2, 82, 263] +[:mouse_move, 587, 388, 2, 83, 264] +[:mouse_move, 585, 383, 2, 84, 265] +[:mouse_move, 585, 381, 2, 85, 266] +[:mouse_move, 581, 372, 2, 86, 267] +[:mouse_move, 576, 365, 2, 87, 268] +[:mouse_move, 568, 350, 2, 88, 269] +[:mouse_move, 566, 345, 2, 89, 270] +[:mouse_move, 563, 340, 2, 90, 271] +[:mouse_move, 563, 339, 2, 91, 272] +[:mouse_move, 562, 337, 2, 92, 273] +[:mouse_move, 562, 336, 2, 93, 275] +[:mouse_move, 561, 336, 2, 94, 278] +[:mouse_move, 560, 336, 2, 95, 279] +[:mouse_move, 559, 336, 2, 96, 280] +[:mouse_move, 557, 335, 2, 97, 281] +[:mouse_move, 556, 335, 2, 98, 282] +[:mouse_move, 555, 335, 2, 99, 287] +[:mouse_move, 555, 336, 2, 100, 288] +[:mouse_move, 554, 337, 2, 101, 290] +[:mouse_move, 547, 340, 2, 102, 292] +[:mouse_move, 544, 340, 2, 103, 293] +[:mouse_move, 537, 342, 2, 104, 294] +[:mouse_move, 533, 343, 2, 105, 295] +[:mouse_move, 525, 343, 2, 106, 296] +[:mouse_move, 524, 343, 2, 107, 297] +[:mouse_move, 524, 342, 2, 108, 304] +[:mouse_move, 524, 341, 2, 109, 306] +[:mouse_move, 524, 340, 2, 110, 307] +[:mouse_move, 524, 339, 2, 111, 308] +[:mouse_move, 525, 338, 2, 112, 310] +[:mouse_move, 525, 337, 2, 113, 311] +[:mouse_move, 525, 336, 2, 114, 314] +[:mouse_move, 526, 336, 2, 115, 316] +[:mouse_button_pressed, 1, 0, 1, 116, 318] +[:mouse_move, 520, 336, 2, 117, 321] +[:mouse_move, 512, 337, 2, 118, 322] +[:mouse_move, 488, 340, 2, 119, 323] +[:mouse_move, 471, 344, 2, 120, 324] +[:mouse_move, 426, 353, 2, 121, 325] +[:mouse_move, 400, 359, 2, 122, 326] +[:mouse_move, 354, 371, 2, 123, 327] +[:mouse_move, 335, 375, 2, 124, 328] +[:mouse_move, 306, 381, 2, 125, 329] +[:mouse_move, 295, 385, 2, 126, 330] +[:mouse_move, 278, 390, 2, 127, 331] +[:mouse_move, 268, 393, 2, 128, 332] +[:mouse_move, 247, 401, 2, 129, 333] +[:mouse_move, 238, 407, 2, 130, 334] +[:mouse_move, 225, 416, 2, 131, 335] +[:mouse_move, 219, 420, 2, 132, 336] +[:mouse_move, 208, 428, 2, 133, 337] +[:mouse_move, 201, 434, 2, 134, 338] +[:mouse_move, 186, 444, 2, 135, 339] +[:mouse_move, 181, 448, 2, 136, 340] +[:mouse_move, 177, 452, 2, 137, 341] +[:mouse_button_up, 1, 0, 1, 138, 349] +[:mouse_move, 178, 452, 2, 139, 349] +[:mouse_move, 192, 442, 2, 140, 350] +[:mouse_move, 208, 432, 2, 141, 351] +[:mouse_move, 259, 405, 2, 142, 352] +[:mouse_move, 294, 391, 2, 143, 353] +[:mouse_move, 380, 369, 2, 144, 354] +[:mouse_move, 415, 361, 2, 145, 355] +[:mouse_move, 459, 351, 2, 146, 356] +[:mouse_move, 475, 348, 2, 147, 357] +[:mouse_move, 505, 342, 2, 148, 358] +[:mouse_move, 519, 341, 2, 149, 359] +[:mouse_move, 538, 337, 2, 150, 360] +[:mouse_move, 544, 335, 2, 151, 361] +[:mouse_move, 546, 334, 2, 152, 362] +[:mouse_button_pressed, 1, 0, 1, 153, 379] +[:mouse_move, 542, 336, 2, 154, 383] +[:mouse_move, 537, 340, 2, 155, 384] +[:mouse_move, 509, 356, 2, 156, 385] +[:mouse_move, 489, 366, 2, 157, 386] +[:mouse_move, 435, 389, 2, 158, 387] +[:mouse_move, 409, 400, 2, 159, 388] +[:mouse_move, 353, 423, 2, 160, 389] +[:mouse_move, 332, 432, 2, 161, 390] +[:mouse_move, 301, 445, 2, 162, 391] +[:mouse_move, 290, 450, 2, 163, 392] +[:mouse_move, 278, 457, 2, 164, 393] +[:mouse_move, 275, 459, 2, 165, 394] +[:mouse_move, 267, 465, 2, 166, 395] +[:mouse_move, 261, 469, 2, 167, 396] +[:mouse_move, 254, 474, 2, 168, 397] +[:mouse_move, 244, 481, 2, 169, 398] +[:mouse_move, 241, 484, 2, 170, 399] +[:mouse_move, 240, 485, 2, 171, 400] +[:mouse_move, 237, 488, 2, 172, 402] +[:mouse_move, 234, 491, 2, 173, 404] +[:mouse_move, 231, 493, 2, 174, 405] +[:mouse_move, 224, 500, 2, 175, 406] +[:mouse_move, 222, 502, 2, 176, 407] +[:mouse_move, 219, 505, 2, 177, 408] +[:mouse_move, 218, 505, 2, 178, 409] +[:mouse_move, 214, 506, 2, 179, 412] +[:mouse_move, 211, 507, 2, 180, 413] +[:mouse_move, 202, 509, 2, 181, 414] +[:mouse_move, 198, 509, 2, 182, 415] +[:mouse_move, 183, 511, 2, 183, 416] +[:mouse_move, 174, 511, 2, 184, 417] +[:mouse_move, 169, 511, 2, 185, 418] +[:mouse_move, 166, 511, 2, 186, 420] +[:mouse_move, 164, 511, 2, 187, 421] +[:mouse_move, 163, 511, 2, 188, 422] +[:mouse_move, 164, 511, 2, 189, 434] +[:mouse_move, 164, 510, 2, 190, 436] +[:mouse_move, 166, 510, 2, 191, 437] +[:mouse_move, 167, 510, 2, 192, 438] +[:mouse_move, 171, 509, 2, 193, 439] +[:mouse_move, 174, 508, 2, 194, 440] +[:mouse_move, 186, 504, 2, 195, 441] +[:mouse_move, 197, 501, 2, 196, 442] +[:mouse_move, 247, 487, 2, 197, 443] +[:mouse_move, 298, 477, 2, 198, 444] +[:mouse_move, 429, 457, 2, 199, 445] +[:mouse_move, 481, 451, 2, 200, 446] +[:mouse_move, 586, 439, 2, 201, 447] +[:mouse_move, 632, 437, 2, 202, 448] +[:mouse_move, 728, 439, 2, 203, 449] +[:mouse_move, 785, 440, 2, 204, 450] +[:mouse_move, 905, 441, 2, 205, 451] +[:mouse_move, 943, 445, 2, 206, 452] +[:mouse_move, 981, 449, 2, 207, 453] +[:mouse_move, 997, 451, 2, 208, 454] +[:mouse_move, 1020, 455, 2, 209, 455] +[:mouse_move, 1034, 456, 2, 210, 456] +[:mouse_move, 1049, 458, 2, 211, 457] +[:mouse_move, 1065, 459, 2, 212, 458] +[:mouse_move, 1088, 460, 2, 213, 459] +[:mouse_move, 1101, 461, 2, 214, 460] +[:mouse_move, 1106, 461, 2, 215, 461] +[:mouse_move, 1116, 463, 2, 216, 462] +[:mouse_move, 1123, 465, 2, 217, 463] +[:mouse_move, 1137, 468, 2, 218, 464] +[:mouse_move, 1140, 468, 2, 219, 465] +[:mouse_move, 1141, 468, 2, 220, 466] +[:mouse_move, 1141, 469, 2, 221, 469] +[:mouse_move, 1142, 469, 2, 222, 472] +[:mouse_move, 1143, 469, 2, 223, 476] +[:mouse_move, 1144, 469, 2, 224, 478] +[:mouse_move, 1143, 469, 2, 225, 487] +[:mouse_move, 1137, 469, 2, 226, 488] +[:mouse_move, 1106, 463, 2, 227, 489] +[:mouse_move, 1082, 456, 2, 228, 490] +[:mouse_move, 1025, 442, 2, 229, 491] +[:mouse_move, 985, 434, 2, 230, 492] +[:mouse_move, 889, 417, 2, 231, 493] +[:mouse_move, 841, 410, 2, 232, 494] +[:mouse_move, 749, 402, 2, 233, 495] +[:mouse_move, 705, 399, 2, 234, 496] +[:mouse_move, 647, 396, 2, 235, 497] +[:mouse_move, 632, 396, 2, 236, 498] +[:mouse_move, 609, 398, 2, 237, 499] +[:mouse_move, 597, 400, 2, 238, 500] +[:mouse_move, 585, 403, 2, 239, 501] +[:mouse_move, 584, 403, 2, 240, 502] +[:mouse_move, 585, 403, 2, 241, 521] +[:mouse_move, 585, 402, 2, 242, 522] +[:mouse_move, 587, 400, 2, 243, 523] +[:mouse_move, 595, 395, 2, 244, 524] +[:mouse_move, 602, 392, 2, 245, 525] +[:mouse_move, 617, 388, 2, 246, 526] +[:mouse_move, 626, 387, 2, 247, 527] +[:mouse_move, 641, 385, 2, 248, 528] +[:mouse_move, 645, 385, 2, 249, 529] +[:mouse_move, 646, 385, 2, 250, 530] +[:mouse_move, 646, 384, 2, 251, 539] +[:mouse_move, 645, 384, 2, 252, 545] +[:mouse_move, 644, 384, 2, 253, 547] +[:mouse_button_up, 1, 0, 1, 254, 547] +[:mouse_move, 641, 383, 2, 255, 547] +[:mouse_move, 634, 381, 2, 256, 548] +[:mouse_move, 608, 370, 2, 257, 549] +[:mouse_move, 573, 355, 2, 258, 550] +[:mouse_move, 415, 301, 2, 259, 551] +[:mouse_move, 315, 267, 2, 260, 552] +[:mouse_move, 161, 209, 2, 261, 553] +[:mouse_move, 117, 193, 2, 262, 554] +[:mouse_move, 91, 178, 2, 263, 555] +[:mouse_move, 91, 177, 2, 264, 556] +[:mouse_move, 92, 176, 2, 265, 557] +[:mouse_move, 94, 174, 2, 266, 559] +[:mouse_move, 97, 172, 2, 267, 560] +[:mouse_move, 101, 169, 2, 268, 561] +[:mouse_move, 102, 169, 2, 269, 562] +[:mouse_move, 107, 163, 2, 270, 563] +[:mouse_move, 109, 159, 2, 271, 564] +[:mouse_move, 114, 154, 2, 272, 565] +[:mouse_move, 116, 153, 2, 273, 566] +[:mouse_move, 118, 153, 2, 274, 567] +[:mouse_move, 124, 154, 2, 275, 568] +[:mouse_move, 131, 156, 2, 276, 569] +[:mouse_move, 156, 162, 2, 277, 570] +[:mouse_move, 166, 165, 2, 278, 571] +[:mouse_move, 185, 170, 2, 279, 572] +[:mouse_move, 194, 172, 2, 280, 573] +[:mouse_move, 205, 175, 2, 281, 574] +[:mouse_move, 206, 176, 2, 282, 575] +[:mouse_move, 203, 176, 2, 283, 580] +[:mouse_move, 202, 176, 2, 284, 582] +[:mouse_button_pressed, 1, 0, 1, 285, 607] +[:mouse_move, 206, 176, 2, 286, 615] +[:mouse_move, 210, 176, 2, 287, 616] +[:mouse_move, 222, 178, 2, 288, 617] +[:mouse_move, 228, 180, 2, 289, 618] +[:mouse_move, 243, 183, 2, 290, 619] +[:mouse_move, 248, 184, 2, 291, 620] +[:mouse_move, 254, 185, 2, 292, 621] +[:mouse_move, 263, 186, 2, 293, 622] +[:mouse_move, 268, 187, 2, 294, 623] +[:mouse_move, 274, 187, 2, 295, 624] +[:mouse_move, 276, 188, 2, 296, 625] +[:mouse_move, 280, 188, 2, 297, 626] +[:mouse_move, 282, 188, 2, 298, 627] +[:mouse_move, 291, 189, 2, 299, 628] +[:mouse_move, 295, 189, 2, 300, 629] +[:mouse_move, 303, 191, 2, 301, 630] +[:mouse_move, 307, 191, 2, 302, 631] +[:mouse_move, 313, 192, 2, 303, 632] +[:mouse_move, 317, 192, 2, 304, 633] +[:mouse_move, 327, 193, 2, 305, 634] +[:mouse_move, 332, 193, 2, 306, 635] +[:mouse_move, 339, 193, 2, 307, 636] +[:mouse_move, 341, 193, 2, 308, 637] +[:mouse_move, 344, 193, 2, 309, 638] +[:mouse_move, 346, 194, 2, 310, 639] +[:mouse_move, 350, 194, 2, 311, 640] +[:mouse_move, 352, 194, 2, 312, 641] +[:mouse_move, 353, 194, 2, 313, 642] +[:mouse_move, 354, 194, 2, 314, 643] +[:mouse_move, 354, 193, 2, 315, 644] +[:mouse_move, 355, 193, 2, 316, 645] +[:mouse_move, 356, 193, 2, 317, 649] +[:mouse_move, 357, 192, 2, 318, 651] +[:mouse_move, 358, 192, 2, 319, 654] +[:mouse_move, 359, 191, 2, 320, 659] +[:mouse_move, 360, 191, 2, 321, 660] +[:mouse_move, 361, 190, 2, 322, 661] +[:mouse_move, 362, 189, 2, 323, 662] +[:mouse_move, 363, 189, 2, 324, 663] +[:mouse_move, 364, 188, 2, 325, 664] +[:mouse_move, 365, 188, 2, 326, 665] +[:mouse_move, 366, 188, 2, 327, 667] +[:mouse_move, 367, 187, 2, 328, 669] +[:mouse_move, 368, 187, 2, 329, 671] +[:mouse_move, 369, 187, 2, 330, 672] +[:mouse_move, 370, 186, 2, 331, 673] +[:mouse_move, 371, 186, 2, 332, 675] +[:mouse_move, 371, 185, 2, 333, 676] +[:mouse_move, 372, 185, 2, 334, 678] +[:mouse_move, 372, 184, 2, 335, 679] +[:mouse_move, 372, 183, 2, 336, 683] +[:mouse_move, 371, 183, 2, 337, 684] +[:mouse_move, 372, 183, 2, 338, 692] +[:mouse_move, 372, 182, 2, 339, 694] +[:mouse_move, 373, 182, 2, 340, 695] +[:mouse_move, 374, 182, 2, 341, 696] +[:mouse_move, 374, 181, 2, 342, 698] +[:mouse_move, 375, 181, 2, 343, 699] +[:mouse_move, 376, 180, 2, 344, 700] +[:mouse_move, 377, 180, 2, 345, 702] +[:mouse_move, 376, 180, 2, 346, 709] +[:mouse_move, 375, 180, 2, 347, 711] +[:mouse_move, 374, 180, 2, 348, 715] +[:mouse_move, 371, 180, 2, 349, 730] +[:mouse_move, 363, 180, 2, 350, 731] +[:mouse_move, 358, 180, 2, 351, 732] +[:mouse_move, 352, 180, 2, 352, 733] +[:mouse_move, 338, 182, 2, 353, 734] +[:mouse_move, 333, 182, 2, 354, 735] +[:mouse_move, 327, 183, 2, 355, 736] +[:mouse_move, 324, 183, 2, 356, 737] +[:mouse_move, 309, 183, 2, 357, 738] +[:mouse_move, 303, 183, 2, 358, 739] +[:mouse_move, 295, 182, 2, 359, 740] +[:mouse_move, 293, 182, 2, 360, 741] +[:mouse_move, 292, 182, 2, 361, 742] +[:mouse_move, 291, 182, 2, 362, 744] +[:mouse_move, 288, 182, 2, 363, 746] +[:mouse_move, 286, 182, 2, 364, 747] +[:mouse_move, 281, 182, 2, 365, 748] +[:mouse_move, 278, 182, 2, 366, 749] +[:mouse_move, 270, 183, 2, 367, 750] +[:mouse_move, 268, 183, 2, 368, 751] +[:mouse_move, 266, 183, 2, 369, 752] +[:mouse_move, 265, 183, 2, 370, 753] +[:mouse_move, 262, 183, 2, 371, 754] +[:mouse_move, 257, 183, 2, 372, 755] +[:mouse_move, 252, 183, 2, 373, 756] +[:mouse_move, 251, 183, 2, 374, 757] +[:mouse_move, 250, 183, 2, 375, 758] +[:mouse_move, 249, 183, 2, 376, 769] +[:mouse_move, 247, 182, 2, 377, 773] +[:mouse_move, 243, 182, 2, 378, 774] +[:mouse_move, 242, 182, 2, 379, 775] +[:mouse_move, 243, 182, 2, 380, 796] +[:mouse_move, 244, 182, 2, 381, 800] +[:mouse_move, 245, 182, 2, 382, 806] +[:mouse_move, 246, 182, 2, 383, 824] +[:mouse_move, 247, 182, 2, 384, 827] +[:mouse_move, 248, 183, 2, 385, 850] +[:mouse_move, 249, 183, 2, 386, 855] +[:mouse_button_up, 1, 0, 1, 387, 893] +[:mouse_move, 249, 184, 2, 388, 904] +[:mouse_move, 249, 185, 2, 389, 905] +[:mouse_move, 249, 191, 2, 390, 906] +[:mouse_move, 249, 196, 2, 391, 907] +[:mouse_move, 247, 208, 2, 392, 908] +[:mouse_move, 246, 214, 2, 393, 909] +[:mouse_move, 244, 223, 2, 394, 910] +[:mouse_move, 244, 225, 2, 395, 911] +[:mouse_move, 243, 226, 2, 396, 912] +[:mouse_move, 243, 227, 2, 397, 913] +[:mouse_move, 242, 229, 2, 398, 914] +[:mouse_move, 241, 229, 2, 399, 915] +[:mouse_move, 241, 230, 2, 400, 916] +[:mouse_move, 240, 230, 2, 401, 919] +[:mouse_move, 240, 231, 2, 402, 920] +[:mouse_move, 239, 232, 2, 403, 922] +[:mouse_move, 239, 231, 2, 404, 945] +[:mouse_move, 240, 230, 2, 405, 947] +[:mouse_button_pressed, 1, 0, 1, 406, 960] +[:mouse_button_up, 1, 0, 1, 407, 966] +[:mouse_move, 243, 230, 2, 408, 1005] +[:mouse_move, 245, 229, 2, 409, 1007] +[:mouse_move, 247, 229, 2, 410, 1009] +[:mouse_move, 251, 229, 2, 411, 1010] +[:mouse_move, 259, 228, 2, 412, 1011] +[:mouse_move, 262, 228, 2, 413, 1012] +[:mouse_move, 264, 228, 2, 414, 1013] +[:mouse_move, 271, 227, 2, 415, 1014] +[:mouse_move, 277, 227, 2, 416, 1015] +[:mouse_move, 288, 226, 2, 417, 1016] +[:mouse_move, 292, 225, 2, 418, 1017] +[:mouse_move, 304, 225, 2, 419, 1018] +[:mouse_move, 308, 225, 2, 420, 1019] +[:mouse_move, 316, 225, 2, 421, 1020] +[:mouse_move, 319, 224, 2, 422, 1021] +[:mouse_move, 324, 223, 2, 423, 1022] +[:mouse_move, 327, 222, 2, 424, 1023] +[:mouse_move, 334, 222, 2, 425, 1024] +[:mouse_move, 340, 222, 2, 426, 1025] +[:mouse_move, 351, 224, 2, 427, 1026] +[:mouse_move, 355, 225, 2, 428, 1027] +[:mouse_move, 359, 225, 2, 429, 1028] +[:mouse_move, 360, 225, 2, 430, 1029] +[:mouse_move, 361, 225, 2, 431, 1034] +[:mouse_move, 362, 225, 2, 432, 1036] +[:mouse_move, 363, 225, 2, 433, 1037] +[:mouse_move, 365, 225, 2, 434, 1038] +[:mouse_move, 366, 226, 2, 435, 1040] +[:mouse_move, 367, 227, 2, 436, 1043] +[:mouse_move, 368, 227, 2, 437, 1047] +[:mouse_move, 369, 227, 2, 438, 1051] +[:mouse_move, 370, 227, 2, 439, 1052] +[:mouse_move, 371, 228, 2, 440, 1053] +[:mouse_move, 372, 228, 2, 441, 1054] +[:mouse_move, 373, 228, 2, 442, 1057] +[:mouse_move, 374, 228, 2, 443, 1061] +[:mouse_button_pressed, 1, 0, 1, 444, 1066] +[:mouse_move, 375, 229, 2, 445, 1079] +[:mouse_move, 377, 229, 2, 446, 1080] +[:mouse_move, 378, 229, 2, 447, 1082] +[:mouse_move, 378, 230, 2, 448, 1088] +[:mouse_move, 379, 230, 2, 449, 1089] +[:mouse_move, 380, 230, 2, 450, 1090] +[:mouse_move, 381, 230, 2, 451, 1091] +[:mouse_move, 382, 230, 2, 452, 1092] +[:mouse_move, 383, 230, 2, 453, 1094] +[:mouse_button_up, 1, 0, 1, 454, 1123] +[:mouse_move, 382, 230, 2, 455, 1124] +[:mouse_move, 381, 230, 2, 456, 1125] +[:mouse_move, 377, 229, 2, 457, 1126] +[:mouse_move, 371, 229, 2, 458, 1127] +[:mouse_move, 351, 233, 2, 459, 1128] +[:mouse_move, 340, 236, 2, 460, 1129] +[:mouse_move, 312, 244, 2, 461, 1130] +[:mouse_move, 232, 261, 2, 462, 1132] +[:mouse_move, 213, 263, 2, 463, 1133] +[:mouse_move, 185, 265, 2, 464, 1134] +[:mouse_move, 172, 265, 2, 465, 1135] +[:mouse_move, 155, 265, 2, 466, 1136] +[:mouse_move, 153, 265, 2, 467, 1137] +[:mouse_move, 152, 265, 2, 468, 1143] +[:mouse_move, 152, 264, 2, 469, 1148] +[:mouse_move, 151, 264, 2, 470, 1150] +[:mouse_move, 150, 264, 2, 471, 1151] +[:mouse_move, 147, 266, 2, 472, 1152] +[:mouse_move, 142, 271, 2, 473, 1153] +[:mouse_move, 141, 273, 2, 474, 1154] +[:mouse_move, 139, 279, 2, 475, 1155] +[:mouse_move, 139, 280, 2, 476, 1156] +[:mouse_move, 138, 283, 2, 477, 1157] +[:mouse_move, 138, 285, 2, 478, 1158] +[:mouse_move, 138, 286, 2, 479, 1159] +[:mouse_move, 138, 287, 2, 480, 1163] +[:mouse_move, 138, 288, 2, 481, 1164] +[:mouse_move, 139, 289, 2, 482, 1165] +[:mouse_move, 138, 289, 2, 483, 1171] +[:mouse_move, 137, 288, 2, 484, 1172] +[:mouse_move, 136, 286, 2, 485, 1173] +[:mouse_move, 135, 285, 2, 486, 1174] +[:mouse_move, 135, 284, 2, 487, 1177] +[:mouse_button_pressed, 1, 0, 1, 488, 1183] +[:mouse_button_up, 1, 0, 1, 489, 1186] +[:mouse_move, 136, 284, 2, 490, 1190] +[:mouse_move, 137, 284, 2, 491, 1193] +[:mouse_button_pressed, 1, 0, 1, 492, 1231] +[:mouse_button_up, 1, 0, 1, 493, 1233] +[:mouse_move, 138, 281, 2, 494, 1242] +[:mouse_move, 140, 279, 2, 495, 1243] +[:mouse_move, 150, 267, 2, 496, 1244] +[:mouse_move, 157, 260, 2, 497, 1245] +[:mouse_move, 171, 248, 2, 498, 1246] +[:mouse_move, 180, 242, 2, 499, 1247] +[:mouse_move, 206, 229, 2, 500, 1248] +[:mouse_move, 222, 224, 2, 501, 1249] +[:mouse_move, 248, 217, 2, 502, 1250] +[:mouse_move, 257, 216, 2, 503, 1251] +[:mouse_move, 266, 215, 2, 504, 1252] +[:mouse_move, 266, 214, 2, 505, 1261] +[:mouse_move, 266, 208, 2, 506, 1263] +[:mouse_move, 265, 207, 2, 507, 1264] +[:mouse_move, 258, 202, 2, 508, 1265] +[:mouse_move, 256, 201, 2, 509, 1266] +[:mouse_move, 250, 200, 2, 510, 1267] +[:mouse_move, 249, 200, 2, 511, 1268] +[:mouse_move, 249, 199, 2, 512, 1269] +[:mouse_move, 248, 199, 2, 513, 1272] +[:mouse_move, 248, 200, 2, 514, 1285] +[:mouse_move, 245, 202, 2, 515, 1286] +[:mouse_move, 244, 205, 2, 516, 1287] +[:mouse_move, 243, 205, 2, 517, 1288] +[:mouse_move, 241, 207, 2, 518, 1289] +[:mouse_move, 241, 208, 2, 519, 1290] +[:mouse_move, 240, 208, 2, 520, 1291] +[:mouse_move, 239, 209, 2, 521, 1292] +[:mouse_move, 238, 209, 2, 522, 1293] +[:mouse_move, 238, 208, 2, 523, 1299] +[:mouse_move, 238, 207, 2, 524, 1300] +[:mouse_move, 238, 206, 2, 525, 1302] +[:mouse_move, 238, 205, 2, 526, 1304] +[:mouse_move, 239, 205, 2, 527, 1305] +[:mouse_move, 239, 204, 2, 528, 1306] +[:mouse_move, 243, 205, 2, 529, 1336] +[:mouse_move, 257, 207, 2, 530, 1337] +[:mouse_move, 267, 208, 2, 531, 1338] +[:mouse_move, 294, 210, 2, 532, 1339] +[:mouse_move, 308, 211, 2, 533, 1340] +[:mouse_move, 337, 212, 2, 534, 1341] +[:mouse_move, 350, 212, 2, 535, 1342] +[:mouse_move, 361, 212, 2, 536, 1343] +[:mouse_move, 363, 211, 2, 537, 1344] +[:mouse_move, 365, 211, 2, 538, 1345] +[:mouse_move, 366, 211, 2, 539, 1346] +[:mouse_move, 367, 210, 2, 540, 1348] +[:mouse_button_pressed, 1, 0, 1, 541, 1356] +[:mouse_button_up, 1, 0, 1, 542, 1361] +[:mouse_move, 363, 210, 2, 543, 1388] +[:mouse_move, 346, 213, 2, 544, 1389] +[:mouse_move, 331, 214, 2, 545, 1390] +[:mouse_move, 290, 218, 2, 546, 1391] +[:mouse_move, 271, 218, 2, 547, 1392] +[:mouse_move, 241, 218, 2, 548, 1393] +[:mouse_move, 232, 218, 2, 549, 1394] +[:mouse_move, 224, 217, 2, 550, 1395] +[:mouse_move, 222, 217, 2, 551, 1396] +[:mouse_move, 218, 216, 2, 552, 1397] +[:mouse_move, 215, 215, 2, 553, 1398] +[:mouse_move, 211, 214, 2, 554, 1399] +[:mouse_move, 211, 213, 2, 555, 1400] +[:mouse_move, 210, 213, 2, 556, 1401] +[:mouse_move, 210, 212, 2, 557, 1404] +[:mouse_move, 211, 212, 2, 558, 1405] +[:mouse_move, 212, 212, 2, 559, 1406] +[:mouse_move, 213, 211, 2, 560, 1407] +[:mouse_move, 215, 210, 2, 561, 1408] +[:mouse_move, 218, 210, 2, 562, 1409] +[:mouse_move, 224, 210, 2, 563, 1410] +[:mouse_button_pressed, 1, 0, 1, 564, 1414] +[:mouse_button_up, 1, 0, 1, 565, 1420] +[:mouse_move, 227, 210, 2, 566, 1427] +[:mouse_move, 233, 209, 2, 567, 1428] +[:mouse_move, 236, 209, 2, 568, 1429] +[:mouse_move, 237, 209, 2, 569, 1430] +[:mouse_move, 239, 208, 2, 570, 1431] +[:mouse_move, 241, 208, 2, 571, 1433] +[:mouse_move, 242, 208, 2, 572, 1434] +[:mouse_move, 244, 207, 2, 573, 1435] +[:mouse_move, 245, 207, 2, 574, 1436] +[:mouse_move, 246, 207, 2, 575, 1437] +[:mouse_move, 247, 207, 2, 576, 1450] +[:mouse_move, 249, 207, 2, 577, 1451] +[:mouse_move, 251, 206, 2, 578, 1452] +[:mouse_move, 255, 205, 2, 579, 1453] +[:mouse_move, 256, 205, 2, 580, 1455] +[:mouse_move, 255, 205, 2, 581, 1470] +[:mouse_move, 251, 206, 2, 582, 1471] +[:mouse_move, 233, 207, 2, 583, 1472] +[:mouse_move, 223, 207, 2, 584, 1473] +[:mouse_move, 201, 208, 2, 585, 1474] +[:mouse_move, 185, 209, 2, 586, 1475] +[:mouse_move, 127, 210, 2, 587, 1476] +[:mouse_move, 107, 211, 2, 588, 1477] +[:mouse_move, 97, 211, 2, 589, 1478] +[:mouse_move, 98, 211, 2, 590, 1485] +[:mouse_move, 99, 211, 2, 591, 1486] +[:mouse_move, 100, 211, 2, 592, 1487] +[:mouse_move, 102, 210, 2, 593, 1488] +[:mouse_move, 106, 209, 2, 594, 1489] +[:mouse_move, 110, 208, 2, 595, 1490] +[:mouse_move, 119, 206, 2, 596, 1491] +[:mouse_move, 124, 206, 2, 597, 1492] +[:mouse_move, 126, 205, 2, 598, 1493] +[:mouse_move, 127, 205, 2, 599, 1494] +[:mouse_move, 128, 205, 2, 600, 1499] +[:mouse_move, 128, 204, 2, 601, 1502] +[:mouse_move, 128, 203, 2, 602, 1507] +[:mouse_move, 127, 203, 2, 603, 1511] +[:mouse_button_pressed, 1, 0, 1, 604, 1516] +[:mouse_button_up, 1, 0, 1, 605, 1521] +[:mouse_move, 131, 205, 2, 606, 1534] +[:mouse_move, 132, 206, 2, 607, 1535] +[:mouse_move, 138, 211, 2, 608, 1536] +[:mouse_move, 142, 214, 2, 609, 1537] +[:mouse_move, 151, 223, 2, 610, 1538] +[:mouse_move, 157, 229, 2, 611, 1539] +[:mouse_move, 171, 248, 2, 612, 1540] +[:mouse_move, 179, 259, 2, 613, 1541] +[:mouse_move, 184, 270, 2, 614, 1542] +[:mouse_move, 195, 289, 2, 615, 1543] +[:mouse_move, 200, 297, 2, 616, 1544] +[:mouse_move, 207, 309, 2, 617, 1545] +[:mouse_move, 209, 313, 2, 618, 1546] +[:mouse_move, 211, 316, 2, 619, 1547] +[:mouse_move, 211, 317, 2, 620, 1548] +[:mouse_move, 212, 319, 2, 621, 1549] +[:mouse_move, 212, 320, 2, 622, 1551] +[:mouse_move, 213, 320, 2, 623, 1552] +[:mouse_move, 213, 322, 2, 624, 1554] +[:mouse_move, 216, 327, 2, 625, 1555] +[:mouse_move, 217, 329, 2, 626, 1556] +[:mouse_move, 220, 333, 2, 627, 1557] +[:mouse_move, 221, 335, 2, 628, 1558] +[:mouse_move, 221, 336, 2, 629, 1559] +[:mouse_move, 222, 337, 2, 630, 1560] +[:mouse_move, 223, 340, 2, 631, 1561] +[:mouse_move, 226, 343, 2, 632, 1562] +[:mouse_move, 232, 348, 2, 633, 1563] +[:mouse_move, 235, 350, 2, 634, 1564] +[:mouse_move, 236, 350, 2, 635, 1565] +[:mouse_move, 236, 349, 2, 636, 1602] +[:mouse_move, 241, 339, 2, 637, 1603] +[:mouse_move, 242, 332, 2, 638, 1604] +[:mouse_move, 246, 318, 2, 639, 1605] +[:mouse_move, 246, 311, 2, 640, 1606] +[:mouse_move, 245, 288, 2, 641, 1607] +[:mouse_move, 241, 271, 2, 642, 1608] +[:mouse_move, 226, 240, 2, 643, 1609] +[:mouse_move, 219, 228, 2, 644, 1610] +[:mouse_move, 214, 218, 2, 645, 1611] +[:mouse_move, 214, 217, 2, 646, 1612] +[:mouse_move, 214, 215, 2, 647, 1613] +[:mouse_move, 214, 214, 2, 648, 1614] +[:mouse_move, 214, 213, 2, 649, 1617] +[:mouse_move, 215, 212, 2, 650, 1619] +[:mouse_move, 216, 212, 2, 651, 1620] +[:mouse_move, 223, 214, 2, 652, 1621] +[:mouse_move, 226, 216, 2, 653, 1622] +[:mouse_move, 230, 218, 2, 654, 1623] +[:mouse_move, 231, 218, 2, 655, 1624] +[:mouse_move, 232, 218, 2, 656, 1625] +[:mouse_move, 232, 219, 2, 657, 1628] +[:mouse_move, 233, 220, 2, 658, 1633] +[:mouse_move, 237, 223, 2, 659, 1634] +[:mouse_move, 238, 224, 2, 660, 1635] +[:mouse_move, 241, 226, 2, 661, 1636] +[:mouse_move, 242, 227, 2, 662, 1637] +[:mouse_move, 243, 227, 2, 663, 1640] +[:mouse_move, 244, 227, 2, 664, 1642] +[:mouse_move, 245, 227, 2, 665, 1644] +[:mouse_move, 246, 227, 2, 666, 1651] +[:mouse_move, 247, 227, 2, 667, 1654] +[:mouse_move, 248, 228, 2, 668, 1656] +[:mouse_button_pressed, 1, 0, 1, 669, 1675] +[:mouse_button_up, 1, 0, 1, 670, 1679] +[:mouse_move, 250, 235, 2, 671, 1698] +[:mouse_move, 254, 245, 2, 672, 1699] +[:mouse_move, 265, 275, 2, 673, 1700] +[:mouse_move, 274, 296, 2, 674, 1701] +[:mouse_move, 301, 366, 2, 675, 1702] +[:mouse_move, 322, 417, 2, 676, 1703] +[:mouse_move, 346, 474, 2, 677, 1704] +[:mouse_move, 386, 571, 2, 678, 1705] +[:mouse_move, 409, 614, 2, 679, 1706] +[:mouse_move, 417, 626, 2, 680, 1707] +[:mouse_move, 425, 638, 2, 681, 1708] +[:mouse_move, 435, 657, 2, 682, 1710] +[:mouse_move, 437, 662, 2, 683, 1710] +[:mouse_move, 438, 664, 2, 684, 1711] +[:mouse_move, 438, 665, 2, 685, 1712] +[:mouse_move, 438, 666, 2, 686, 1714] +[:mouse_move, 434, 672, 2, 687, 1715] +[:mouse_move, 430, 675, 2, 688, 1716] +[:mouse_move, 429, 678, 2, 689, 1717] +[:mouse_move, 429, 679, 2, 690, 1721] +[:mouse_move, 428, 683, 2, 691, 1722] +[:mouse_move, 424, 694, 2, 692, 1723] +[:mouse_move, 423, 697, 2, 693, 1724] +[:mouse_move, 423, 698, 2, 694, 1725] +[:mouse_move, 424, 698, 2, 695, 1727] +[:mouse_move, 424, 697, 2, 696, 1728] +[:mouse_move, 430, 686, 2, 697, 1729] +[:mouse_move, 430, 679, 2, 698, 1730] +[:mouse_move, 434, 669, 2, 699, 1731] +[:mouse_move, 435, 667, 2, 700, 1732] +[:mouse_move, 435, 664, 2, 701, 1733] +[:mouse_move, 435, 663, 2, 702, 1734] +[:mouse_move, 435, 662, 2, 703, 1735] +[:mouse_move, 435, 661, 2, 704, 1736] +[:mouse_move, 435, 660, 2, 705, 1738] +[:mouse_move, 436, 659, 2, 706, 1739] +[:mouse_move, 436, 658, 2, 707, 1740] +[:mouse_move, 437, 655, 2, 708, 1741] +[:mouse_move, 440, 649, 2, 709, 1742] +[:mouse_move, 440, 648, 2, 710, 1744] +[:mouse_move, 440, 647, 2, 711, 1744] +[:mouse_move, 458, 647, 2, 712, 1761] +[:mouse_move, 473, 647, 2, 713, 1762] +[:mouse_move, 503, 646, 2, 714, 1763] +[:mouse_move, 511, 644, 2, 715, 1764] +[:mouse_move, 512, 644, 2, 716, 1765] +[:mouse_move, 515, 644, 2, 717, 1770] +[:mouse_move, 533, 641, 2, 718, 1771] +[:mouse_move, 546, 641, 2, 719, 1772] +[:mouse_move, 580, 640, 2, 720, 1773] +[:mouse_move, 600, 640, 2, 721, 1774] +[:mouse_move, 643, 639, 2, 722, 1775] +[:mouse_move, 661, 639, 2, 723, 1776] +[:mouse_move, 682, 639, 2, 724, 1777] +[:mouse_move, 690, 639, 2, 725, 1778] +[:mouse_move, 693, 639, 2, 726, 1779] +[:mouse_move, 696, 639, 2, 727, 1783] +[:mouse_move, 697, 639, 2, 728, 1784] +[:mouse_move, 698, 639, 2, 729, 1785] +[:mouse_move, 699, 639, 2, 730, 1786] +[:mouse_move, 702, 641, 2, 731, 1787] +[:mouse_move, 704, 643, 2, 732, 1788] +[:mouse_move, 709, 645, 2, 733, 1789] +[:mouse_move, 712, 645, 2, 734, 1790] +[:mouse_move, 715, 645, 2, 735, 1791] +[:mouse_move, 717, 645, 2, 736, 1792] +[:mouse_move, 721, 645, 2, 737, 1793] +[:mouse_move, 723, 645, 2, 738, 1794] +[:mouse_move, 724, 645, 2, 739, 1795] +[:mouse_move, 730, 645, 2, 740, 1796] +[:mouse_move, 733, 645, 2, 741, 1797] +[:mouse_move, 734, 645, 2, 742, 1798] +[:mouse_button_pressed, 1, 0, 1, 743, 1800] +[:mouse_move, 735, 645, 2, 744, 1801] +[:mouse_button_up, 1, 0, 1, 745, 1804] +[:mouse_move, 735, 644, 2, 746, 1810] +[:mouse_move, 734, 644, 2, 747, 1818] +[:mouse_move, 728, 642, 2, 748, 1820] +[:mouse_move, 719, 637, 2, 749, 1821] +[:mouse_move, 708, 632, 2, 750, 1822] +[:mouse_move, 665, 611, 2, 751, 1823] +[:mouse_move, 623, 591, 2, 752, 1824] +[:mouse_move, 509, 533, 2, 753, 1825] +[:mouse_move, 473, 514, 2, 754, 1826] +[:mouse_move, 453, 502, 2, 755, 1827] +[:mouse_move, 451, 500, 2, 756, 1829] +[:mouse_move, 448, 495, 2, 757, 1829] +[:mouse_move, 440, 482, 2, 758, 1831] +[:mouse_move, 439, 480, 2, 759, 1832] +[:mouse_move, 434, 474, 2, 760, 1833] +[:mouse_move, 430, 469, 2, 761, 1834] +[:mouse_move, 417, 459, 2, 762, 1835] +[:mouse_move, 411, 456, 2, 763, 1836] +[:mouse_move, 399, 452, 2, 764, 1837] +[:mouse_move, 390, 449, 2, 765, 1838] +[:mouse_move, 369, 442, 2, 766, 1839] +[:mouse_move, 362, 440, 2, 767, 1840] +[:mouse_move, 357, 439, 2, 768, 1841] +[:mouse_move, 360, 440, 2, 769, 1848] +[:mouse_move, 362, 441, 2, 770, 1849] +[:mouse_move, 364, 442, 2, 771, 1850] +[:mouse_move, 365, 442, 2, 772, 1854] +[:mouse_move, 365, 443, 2, 773, 1856] +[:mouse_move, 367, 443, 2, 774, 1856] +[:mouse_move, 368, 443, 2, 775, 1858] +[:mouse_move, 370, 443, 2, 776, 1859] +[:mouse_move, 375, 445, 2, 777, 1860] +[:mouse_move, 378, 445, 2, 778, 1861] +[:mouse_move, 381, 445, 2, 779, 1862] +[:mouse_move, 382, 445, 2, 780, 1863] +[:mouse_move, 383, 445, 2, 781, 1865] +[:mouse_move, 383, 444, 2, 782, 1927] +[:mouse_button_pressed, 1, 0, 1, 783, 1936] +[:mouse_move, 377, 443, 2, 784, 1937] +[:mouse_move, 370, 443, 2, 785, 1939] +[:mouse_move, 347, 443, 2, 786, 1940] +[:mouse_move, 331, 444, 2, 787, 1941] +[:mouse_move, 301, 448, 2, 788, 1942] +[:mouse_move, 281, 452, 2, 789, 1943] +[:mouse_move, 239, 461, 2, 790, 1944] +[:mouse_move, 219, 467, 2, 791, 1945] +[:mouse_move, 188, 476, 2, 792, 1946] +[:mouse_move, 179, 482, 2, 793, 1947] +[:mouse_move, 168, 491, 2, 794, 1948] +[:mouse_move, 164, 495, 2, 795, 1949] +[:mouse_move, 160, 499, 2, 796, 1950] +[:mouse_move, 160, 500, 2, 797, 1951] +[:mouse_move, 162, 498, 2, 798, 1961] +[:mouse_move, 165, 496, 2, 799, 1962] +[:mouse_move, 183, 486, 2, 800, 1963] +[:mouse_move, 200, 476, 2, 801, 1964] +[:mouse_move, 281, 430, 2, 802, 1965] +[:mouse_move, 344, 398, 2, 803, 1966] +[:mouse_move, 506, 339, 2, 804, 1967] +[:mouse_move, 596, 318, 2, 805, 1968] +[:mouse_move, 743, 293, 2, 806, 1969] +[:mouse_move, 795, 284, 2, 807, 1970] +[:mouse_move, 874, 275, 2, 808, 1971] +[:mouse_move, 900, 274, 2, 809, 1972] +[:mouse_move, 942, 275, 2, 810, 1973] +[:mouse_move, 959, 278, 2, 811, 1974] +[:mouse_move, 994, 284, 2, 812, 1975] +[:mouse_move, 1008, 288, 2, 813, 1976] +[:mouse_move, 1031, 295, 2, 814, 1976] +[:mouse_move, 1044, 299, 2, 815, 1978] +[:mouse_move, 1068, 310, 2, 816, 1979] +[:mouse_move, 1080, 314, 2, 817, 1980] +[:mouse_move, 1103, 325, 2, 818, 1981] +[:mouse_move, 1110, 328, 2, 819, 1982] +[:mouse_move, 1121, 334, 2, 820, 1983] +[:mouse_move, 1123, 336, 2, 821, 1984] +[:mouse_move, 1126, 338, 2, 822, 1985] +[:mouse_move, 1127, 338, 2, 823, 1986] +[:mouse_move, 1126, 338, 2, 824, 1995] +[:mouse_move, 1112, 335, 2, 825, 1996] +[:mouse_move, 1097, 332, 2, 826, 1997] +[:mouse_move, 1053, 323, 2, 827, 1998] +[:mouse_move, 1020, 317, 2, 828, 1999] +[:mouse_move, 948, 304, 2, 829, 2000] +[:mouse_move, 915, 298, 2, 830, 2001] +[:mouse_move, 832, 290, 2, 831, 2002] +[:mouse_move, 788, 288, 2, 832, 2003] +[:mouse_move, 722, 287, 2, 833, 2004] +[:mouse_move, 691, 291, 2, 834, 2005] +[:mouse_move, 628, 305, 2, 835, 2006] +[:mouse_move, 601, 315, 2, 836, 2007] +[:mouse_move, 557, 333, 2, 837, 2008] +[:mouse_move, 538, 343, 2, 838, 2009] +[:mouse_move, 502, 361, 2, 839, 2010] +[:mouse_move, 486, 372, 2, 840, 2011] +[:mouse_move, 463, 390, 2, 841, 2012] +[:mouse_move, 458, 394, 2, 842, 2013] +[:mouse_move, 458, 396, 2, 843, 2016] +[:mouse_move, 457, 397, 2, 844, 2017] +[:mouse_move, 457, 398, 2, 845, 2018] +[:mouse_move, 457, 399, 2, 846, 2019] +[:mouse_move, 456, 400, 2, 847, 2020] +[:mouse_move, 454, 405, 2, 848, 2021] +[:mouse_move, 454, 406, 2, 849, 2022] +[:mouse_move, 453, 408, 2, 850, 2029] +[:mouse_move, 453, 409, 2, 851, 2030] +[:mouse_move, 450, 413, 2, 852, 2031] +[:mouse_move, 449, 416, 2, 853, 2032] +[:mouse_move, 448, 418, 2, 854, 2033] +[:mouse_button_up, 1, 0, 1, 855, 2054] +[:mouse_move, 449, 416, 2, 856, 2073] +[:mouse_move, 450, 415, 2, 857, 2074] +[:mouse_move, 450, 414, 2, 858, 2075] +[:mouse_move, 449, 412, 2, 859, 2076] +[:mouse_move, 436, 402, 2, 860, 2077] +[:mouse_move, 419, 393, 2, 861, 2078] +[:mouse_move, 337, 363, 2, 862, 2079] +[:mouse_move, 279, 346, 2, 863, 2080] +[:mouse_move, 192, 321, 2, 864, 2081] +[:mouse_move, 175, 315, 2, 865, 2082] +[:mouse_move, 162, 308, 2, 866, 2083] +[:mouse_move, 161, 307, 2, 867, 2084] +[:mouse_move, 157, 306, 2, 868, 2085] +[:mouse_move, 156, 306, 2, 869, 2086] +[:mouse_move, 154, 306, 2, 870, 2087] +[:mouse_move, 154, 305, 2, 871, 2088] +[:mouse_move, 153, 304, 2, 872, 2090] +[:mouse_move, 150, 301, 2, 873, 2091] +[:mouse_move, 148, 300, 2, 874, 2092] +[:mouse_move, 142, 294, 2, 875, 2093] +[:mouse_move, 136, 289, 2, 876, 2094] +[:mouse_move, 125, 277, 2, 877, 2095] +[:mouse_move, 122, 274, 2, 878, 2096] +[:mouse_move, 122, 273, 2, 879, 2097] +[:mouse_move, 122, 272, 2, 880, 2098] +[:mouse_move, 128, 273, 2, 881, 2104] +[:mouse_move, 137, 274, 2, 882, 2105] +[:mouse_move, 166, 275, 2, 883, 2106] +[:mouse_move, 199, 276, 2, 884, 2107] +[:mouse_move, 320, 286, 2, 885, 2108] +[:mouse_move, 394, 295, 2, 886, 2109] +[:mouse_move, 533, 320, 2, 887, 2110] +[:mouse_move, 591, 335, 2, 888, 2111] +[:mouse_move, 645, 351, 2, 889, 2112] +[:mouse_move, 654, 354, 2, 890, 2113] +[:mouse_move, 667, 360, 2, 891, 2114] +[:mouse_move, 675, 365, 2, 892, 2115] +[:mouse_move, 690, 378, 2, 893, 2116] +[:mouse_move, 695, 383, 2, 894, 2117] +[:mouse_move, 699, 389, 2, 895, 2118] +[:mouse_move, 699, 390, 2, 896, 2119] +[:mouse_move, 700, 390, 2, 897, 2120] +[:mouse_move, 692, 387, 2, 898, 2124] +[:mouse_move, 681, 384, 2, 899, 2125] +[:mouse_move, 656, 381, 2, 900, 2126] +[:mouse_move, 650, 381, 2, 901, 2127] +[:mouse_move, 647, 381, 2, 902, 2128] +[:mouse_move, 649, 381, 2, 903, 2137] +[:mouse_move, 650, 382, 2, 904, 2138] +[:mouse_move, 651, 382, 2, 905, 2139] +[:mouse_button_pressed, 1, 0, 1, 906, 2144] +[:mouse_button_up, 1, 0, 1, 907, 2148] +[:mouse_move, 650, 382, 2, 908, 2165] +[:mouse_move, 647, 383, 2, 909, 2166] +[:mouse_move, 643, 384, 2, 910, 2167] +[:mouse_move, 629, 387, 2, 911, 2168] +[:mouse_move, 617, 390, 2, 912, 2169] +[:mouse_move, 587, 395, 2, 913, 2170] +[:mouse_move, 573, 397, 2, 914, 2171] +[:mouse_move, 541, 399, 2, 915, 2172] +[:mouse_move, 524, 401, 2, 916, 2173] +[:mouse_move, 488, 405, 2, 917, 2174] +[:mouse_move, 476, 407, 2, 918, 2175] +[:mouse_move, 465, 409, 2, 919, 2176] +[:mouse_move, 464, 409, 2, 920, 2177] +[:mouse_move, 462, 410, 2, 921, 2178] +[:mouse_move, 461, 410, 2, 922, 2179] +[:mouse_move, 459, 411, 2, 923, 2180] +[:mouse_move, 459, 412, 2, 924, 2186] +[:mouse_move, 459, 413, 2, 925, 2189] +[:mouse_move, 458, 413, 2, 926, 2190] +[:mouse_move, 451, 419, 2, 927, 2191] +[:mouse_move, 449, 421, 2, 928, 2192] +[:mouse_move, 448, 421, 2, 929, 2193] +[:mouse_move, 447, 421, 2, 930, 2194] +[:mouse_move, 445, 422, 2, 931, 2195] +[:mouse_move, 444, 422, 2, 932, 2196] +[:mouse_button_pressed, 1, 0, 1, 933, 2216] +[:mouse_button_up, 1, 0, 1, 934, 2220] +[:mouse_move, 442, 420, 2, 935, 2229] +[:mouse_move, 424, 411, 2, 936, 2230] +[:mouse_move, 406, 403, 2, 937, 2231] +[:mouse_move, 336, 378, 2, 938, 2232] +[:mouse_move, 286, 359, 2, 939, 2233] +[:mouse_move, 225, 334, 2, 940, 2234] +[:mouse_move, 213, 328, 2, 941, 2235] +[:mouse_move, 201, 321, 2, 942, 2236] +[:mouse_move, 198, 318, 2, 943, 2237] +[:mouse_move, 191, 314, 2, 944, 2238] +[:mouse_move, 185, 310, 2, 945, 2239] +[:mouse_move, 179, 305, 2, 946, 2240] +[:mouse_move, 171, 299, 2, 947, 2241] +[:mouse_move, 170, 297, 2, 948, 2242] +[:mouse_move, 170, 295, 2, 949, 2243] +[:mouse_move, 170, 294, 2, 950, 2244] +[:mouse_move, 169, 293, 2, 951, 2245] +[:mouse_move, 169, 291, 2, 952, 2246] +[:mouse_move, 168, 289, 2, 953, 2247] +[:mouse_move, 167, 289, 2, 954, 2248] +[:mouse_move, 167, 287, 2, 955, 2249] +[:mouse_move, 167, 286, 2, 956, 2250] +[:mouse_move, 164, 283, 2, 957, 2251] +[:mouse_move, 160, 279, 2, 958, 2252] +[:mouse_move, 143, 270, 2, 959, 2253] +[:mouse_move, 136, 267, 2, 960, 2254] +[:mouse_move, 130, 265, 2, 961, 2255] +[:mouse_move, 128, 265, 2, 962, 2256] +[:mouse_move, 125, 264, 2, 963, 2257] +[:mouse_move, 123, 263, 2, 964, 2258] +[:mouse_move, 120, 262, 2, 965, 2259] +[:mouse_move, 120, 261, 2, 966, 2260] +[:mouse_move, 120, 260, 2, 967, 2265] +[:mouse_move, 120, 259, 2, 968, 2267] +[:mouse_move, 121, 259, 2, 969, 2268] +[:mouse_move, 122, 259, 2, 970, 2269] +[:mouse_move, 124, 258, 2, 971, 2270] +[:mouse_move, 126, 257, 2, 972, 2271] +[:mouse_move, 130, 256, 2, 973, 2272] +[:mouse_move, 131, 256, 2, 974, 2274] +[:mouse_move, 132, 256, 2, 975, 2275] +[:mouse_button_pressed, 1, 0, 1, 976, 2290] +[:mouse_button_up, 1, 0, 1, 977, 2292] +[:mouse_move, 132, 258, 2, 978, 2305] +[:mouse_move, 133, 262, 2, 979, 2306] +[:mouse_move, 135, 278, 2, 980, 2307] +[:mouse_move, 136, 290, 2, 981, 2308] +[:mouse_move, 143, 325, 2, 982, 2309] +[:mouse_move, 146, 347, 2, 983, 2310] +[:mouse_move, 162, 411, 2, 984, 2311] +[:mouse_move, 173, 445, 2, 985, 2312] +[:mouse_move, 189, 482, 2, 986, 2313] +[:mouse_move, 195, 490, 2, 987, 2314] +[:mouse_move, 198, 492, 2, 988, 2315] +[:key_down_raw, 96, 0, 2, 989, 2426] +[:key_up_raw, 96, 0, 2, 990, 2430] +[:key_down_raw, 13, 0, 2, 991, 2551] diff --git a/samples/07_advanced_audio/01_audio_mixer/sounds/drum.wav b/samples/07_advanced_audio/01_audio_mixer/sounds/drum.wav new file mode 100644 index 0000000..c7bde27 Binary files /dev/null and b/samples/07_advanced_audio/01_audio_mixer/sounds/drum.wav differ diff --git a/samples/07_advanced_audio/01_audio_mixer/sounds/music.ogg b/samples/07_advanced_audio/01_audio_mixer/sounds/music.ogg new file mode 100644 index 0000000..a952191 Binary files /dev/null and b/samples/07_advanced_audio/01_audio_mixer/sounds/music.ogg differ diff --git a/samples/07_advanced_audio/01_audio_mixer/sounds/splash.wav b/samples/07_advanced_audio/01_audio_mixer/sounds/splash.wav new file mode 100644 index 0000000..52a09c2 Binary files /dev/null and b/samples/07_advanced_audio/01_audio_mixer/sounds/splash.wav differ diff --git a/samples/07_advanced_audio/01_audio_mixer/sounds/spring.wav b/samples/07_advanced_audio/01_audio_mixer/sounds/spring.wav new file mode 100644 index 0000000..112f3cc Binary files /dev/null and b/samples/07_advanced_audio/01_audio_mixer/sounds/spring.wav differ diff --git a/samples/07_advanced_audio/01_audio_mixer/sounds/tada.wav b/samples/07_advanced_audio/01_audio_mixer/sounds/tada.wav new file mode 100644 index 0000000..8aa1be3 Binary files /dev/null and b/samples/07_advanced_audio/01_audio_mixer/sounds/tada.wav differ diff --git a/samples/07_advanced_audio/01_audio_mixer/sounds/tink.wav b/samples/07_advanced_audio/01_audio_mixer/sounds/tink.wav new file mode 100644 index 0000000..193cf54 Binary files /dev/null and b/samples/07_advanced_audio/01_audio_mixer/sounds/tink.wav differ diff --git a/samples/07_advanced_audio/02_sound_synthesis/app/main.rb b/samples/07_advanced_audio/02_sound_synthesis/app/main.rb new file mode 100644 index 0000000..af2be9d --- /dev/null +++ b/samples/07_advanced_audio/02_sound_synthesis/app/main.rb @@ -0,0 +1,593 @@ +begin # region: top level tick methods + def tick args + defaults args + render args + input args + process_audio_queue args + end + + def defaults args + args.state.sine_waves ||= {} + args.state.square_waves ||= {} + args.state.saw_tooth_waves ||= {} + args.state.triangle_waves ||= {} + args.state.audio_queue ||= [] + args.state.buttons ||= [ + (frequency_buttons args), + (sine_wave_note_buttons args), + (bell_buttons args), + (square_wave_note_buttons args), + (saw_tooth_wave_note_buttons args), + (triangle_wave_note_buttons args), + ].flatten + end + + def render args + args.outputs.borders << args.state.buttons.map { |b| b[:border] } + args.outputs.labels << args.state.buttons.map { |b| b[:label] } + args.outputs.labels << args.layout + .rect(row: 0, col: 11.5) + .yield_self { |r| r.merge y: r.y + r.h } + .merge(text: "This is a Pro only feature. Click here to watch the YouTube video if you are on the Standard License.", + alignment_enum: 1) + end + + + def input args + args.state.buttons.each do |b| + if args.inputs.mouse.click && (args.inputs.mouse.click.inside_rect? b[:rect]) + parameter_string = (b.slice :frequency, :note, :octave).map { |k, v| "#{k}: #{v}" }.join ", " + args.gtk.notify! "#{b[:method_to_call]} #{parameter_string}" + send b[:method_to_call], args, b + end + end + + if args.inputs.mouse.click && (args.inputs.mouse.click.inside_rect? (args.layout.rect(row: 0).yield_self { |r| r.merge y: r.y + r.h.half, h: r.h.half })) + args.gtk.openurl 'https://www.youtube.com/watch?v=zEzovM5jT-k&ab_channel=AmirRajan' + end + end + + def process_audio_queue args + to_queue = args.state.audio_queue.find_all { |v| v[:queue_at] <= args.tick_count } + args.state.audio_queue -= to_queue + to_queue.each { |a| args.audio[a[:id]] = a } + + args.audio.find_all { |k, v| v[:decay_rate] } + .each { |k, v| v[:gain] -= v[:decay_rate] } + + sounds_to_stop = args.audio + .find_all { |k, v| v[:stop_at] && args.state.tick_count >= v[:stop_at] } + .map { |k, v| k } + + sounds_to_stop.each { |k| args.audio.delete k } + end +end + +begin # region: button definitions, ui layout, callback functions + def button args, opts + button_def = opts.merge rect: (args.layout.rect (opts.merge w: 2, h: 1)) + + button_def[:border] = button_def[:rect].merge r: 0, g: 0, b: 0 + + label_offset_x = 5 + label_offset_y = 30 + + button_def[:label] = button_def[:rect].merge text: opts[:text], + size_enum: -2.5, + x: button_def[:rect].x + label_offset_x, + y: button_def[:rect].y + label_offset_y + + button_def + end + + def play_sine_wave args, sender + queue_sine_wave args, + frequency: sender[:frequency], + duration: 1.seconds, + fade_out: true + end + + def play_note args, sender + method_to_call = :queue_sine_wave + method_to_call = :queue_square_wave if sender[:type] == :square + method_to_call = :queue_saw_tooth_wave if sender[:type] == :saw_tooth + method_to_call = :queue_triangle_wave if sender[:type] == :triangle + method_to_call = :queue_bell if sender[:type] == :bell + + send method_to_call, args, + frequency: (frequency_for note: sender[:note], octave: sender[:octave]), + duration: 1.seconds, + fade_out: true + end + + def frequency_buttons args + [ + (button args, + row: 4.0, col: 0, text: "300hz", + frequency: 300, + method_to_call: :play_sine_wave), + (button args, + row: 5.0, col: 0, text: "400hz", + frequency: 400, + method_to_call: :play_sine_wave), + (button args, + row: 6.0, col: 0, text: "500hz", + frequency: 500, + method_to_call: :play_sine_wave), + ] + end + + def sine_wave_note_buttons args + [ + (button args, + row: 1.5, col: 2, text: "Sine C4", + note: :c, octave: 4, type: :sine, method_to_call: :play_note), + (button args, + row: 2.5, col: 2, text: "Sine D4", + note: :d, octave: 4, type: :sine, method_to_call: :play_note), + (button args, + row: 3.5, col: 2, text: "Sine E4", + note: :e, octave: 4, type: :sine, method_to_call: :play_note), + (button args, + row: 4.5, col: 2, text: "Sine F4", + note: :f, octave: 4, type: :sine, method_to_call: :play_note), + (button args, + row: 5.5, col: 2, text: "Sine G4", + note: :g, octave: 4, type: :sine, method_to_call: :play_note), + (button args, + row: 6.5, col: 2, text: "Sine A5", + note: :a, octave: 5, type: :sine, method_to_call: :play_note), + (button args, + row: 7.5, col: 2, text: "Sine B5", + note: :b, octave: 5, type: :sine, method_to_call: :play_note), + (button args, + row: 8.5, col: 2, text: "Sine C5", + note: :c, octave: 5, type: :sine, method_to_call: :play_note), + ] + end + + def square_wave_note_buttons args + [ + (button args, + row: 1.5, col: 6, text: "Square C4", + note: :c, octave: 4, type: :square, method_to_call: :play_note), + (button args, + row: 2.5, col: 6, text: "Square D4", + note: :d, octave: 4, type: :square, method_to_call: :play_note), + (button args, + row: 3.5, col: 6, text: "Square E4", + note: :e, octave: 4, type: :square, method_to_call: :play_note), + (button args, + row: 4.5, col: 6, text: "Square F4", + note: :f, octave: 4, type: :square, method_to_call: :play_note), + (button args, + row: 5.5, col: 6, text: "Square G4", + note: :g, octave: 4, type: :square, method_to_call: :play_note), + (button args, + row: 6.5, col: 6, text: "Square A5", + note: :a, octave: 5, type: :square, method_to_call: :play_note), + (button args, + row: 7.5, col: 6, text: "Square B5", + note: :b, octave: 5, type: :square, method_to_call: :play_note), + (button args, + row: 8.5, col: 6, text: "Square C5", + note: :c, octave: 5, type: :square, method_to_call: :play_note), + ] + end + def saw_tooth_wave_note_buttons args + [ + (button args, + row: 1.5, col: 8, text: "Saw C4", + note: :c, octave: 4, type: :saw_tooth, method_to_call: :play_note), + (button args, + row: 2.5, col: 8, text: "Saw D4", + note: :d, octave: 4, type: :saw_tooth, method_to_call: :play_note), + (button args, + row: 3.5, col: 8, text: "Saw E4", + note: :e, octave: 4, type: :saw_tooth, method_to_call: :play_note), + (button args, + row: 4.5, col: 8, text: "Saw F4", + note: :f, octave: 4, type: :saw_tooth, method_to_call: :play_note), + (button args, + row: 5.5, col: 8, text: "Saw G4", + note: :g, octave: 4, type: :saw_tooth, method_to_call: :play_note), + (button args, + row: 6.5, col: 8, text: "Saw A5", + note: :a, octave: 5, type: :saw_tooth, method_to_call: :play_note), + (button args, + row: 7.5, col: 8, text: "Saw B5", + note: :b, octave: 5, type: :saw_tooth, method_to_call: :play_note), + (button args, + row: 8.5, col: 8, text: "Saw C5", + note: :c, octave: 5, type: :saw_tooth, method_to_call: :play_note), + ] + end + + def triangle_wave_note_buttons args + [ + (button args, + row: 1.5, col: 10, text: "Triangle C4", + note: :c, octave: 4, type: :triangle, method_to_call: :play_note), + (button args, + row: 2.5, col: 10, text: "Triangle D4", + note: :d, octave: 4, type: :triangle, method_to_call: :play_note), + (button args, + row: 3.5, col: 10, text: "Triangle E4", + note: :e, octave: 4, type: :triangle, method_to_call: :play_note), + (button args, + row: 4.5, col: 10, text: "Triangle F4", + note: :f, octave: 4, type: :triangle, method_to_call: :play_note), + (button args, + row: 5.5, col: 10, text: "Triangle G4", + note: :g, octave: 4, type: :triangle, method_to_call: :play_note), + (button args, + row: 6.5, col: 10, text: "Triangle A5", + note: :a, octave: 5, type: :triangle, method_to_call: :play_note), + (button args, + row: 7.5, col: 10, text: "Triangle B5", + note: :b, octave: 5, type: :triangle, method_to_call: :play_note), + (button args, + row: 8.5, col: 10, text: "Triangle C5", + note: :c, octave: 5, type: :triangle, method_to_call: :play_note), + ] + end + + def bell_buttons args + [ + (button args, + row: 1.5, col: 4, text: "Bell C4", + note: :c, octave: 4, type: :bell, method_to_call: :play_note), + (button args, + row: 2.5, col: 4, text: "Bell D4", + note: :d, octave: 4, type: :bell, method_to_call: :play_note), + (button args, + row: 3.5, col: 4, text: "Bell E4", + note: :e, octave: 4, type: :bell, method_to_call: :play_note), + (button args, + row: 4.5, col: 4, text: "Bell F4", + note: :f, octave: 4, type: :bell, method_to_call: :play_note), + (button args, + row: 5.5, col: 4, text: "Bell G4", + note: :g, octave: 4, type: :bell, method_to_call: :play_note), + (button args, + row: 6.5, col: 4, text: "Bell A5", + note: :a, octave: 5, type: :bell, method_to_call: :play_note), + (button args, + row: 7.5, col: 4, text: "Bell B5", + note: :b, octave: 5, type: :bell, method_to_call: :play_note), + (button args, + row: 8.5, col: 4, text: "Bell C5", + note: :c, octave: 5, type: :bell, method_to_call: :play_note), + ] + end +end + +begin # region: wave generation + begin # sine wave + def defaults_sine_wave_for + { frequency: 440, sample_rate: 48000 } + end + + def sine_wave_for opts = {} + opts = defaults_sine_wave_for.merge opts + frequency = opts[:frequency] + sample_rate = opts[:sample_rate] + period_size = (sample_rate.fdiv frequency).ceil + period_size.map_with_index do |i| + Math::sin((2.0 * Math::PI) / (sample_rate.to_f / frequency.to_f) * i) + end.to_a + end + + def defaults_queue_sine_wave + { frequency: 440, duration: 60, gain: 1.0, fade_out: false, queue_in: 0 } + end + + def queue_sine_wave args, opts = {} + opts = defaults_queue_sine_wave.merge opts + frequency = opts[:frequency] + sample_rate = 48000 + + sine_wave = sine_wave_for frequency: frequency, sample_rate: sample_rate + args.state.sine_waves[frequency] ||= sine_wave_for frequency: frequency, sample_rate: sample_rate + + proc = lambda do + generate_audio_data args.state.sine_waves[frequency], sample_rate + end + + audio_state = new_audio_state args, opts + audio_state[:input] = [1, sample_rate, proc] + queue_audio args, audio_state: audio_state, wave: sine_wave + end + end + + begin # region: square wave + def defaults_square_wave_for + { frequency: 440, sample_rate: 48000 } + end + + def square_wave_for opts = {} + opts = defaults_square_wave_for.merge opts + sine_wave = sine_wave_for opts + sine_wave.map do |v| + if v >= 0 + 1.0 + else + -1.0 + end + end.to_a + end + + def defaults_queue_square_wave + { frequency: 440, duration: 60, gain: 0.3, fade_out: false, queue_in: 0 } + end + + def queue_square_wave args, opts = {} + opts = defaults_queue_square_wave.merge opts + frequency = opts[:frequency] + sample_rate = 48000 + + square_wave = square_wave_for frequency: frequency, sample_rate: sample_rate + args.state.square_waves[frequency] ||= square_wave_for frequency: frequency, sample_rate: sample_rate + + proc = lambda do + generate_audio_data args.state.square_waves[frequency], sample_rate + end + + audio_state = new_audio_state args, opts + audio_state[:input] = [1, sample_rate, proc] + queue_audio args, audio_state: audio_state, wave: square_wave + end + end + + begin # region: saw tooth wave + def defaults_saw_tooth_wave_for + { frequency: 440, sample_rate: 48000 } + end + + def saw_tooth_wave_for opts = {} + opts = defaults_saw_tooth_wave_for.merge opts + sine_wave = sine_wave_for opts + period_size = sine_wave.length + sine_wave.map_with_index do |v, i| + (((i % period_size).fdiv period_size) * 2) - 1 + end + end + + def defaults_queue_saw_tooth_wave + { frequency: 440, duration: 60, gain: 0.3, fade_out: false, queue_in: 0 } + end + + def queue_saw_tooth_wave args, opts = {} + opts = defaults_queue_saw_tooth_wave.merge opts + frequency = opts[:frequency] + sample_rate = 48000 + + saw_tooth_wave = saw_tooth_wave_for frequency: frequency, sample_rate: sample_rate + args.state.saw_tooth_waves[frequency] ||= saw_tooth_wave_for frequency: frequency, sample_rate: sample_rate + + proc = lambda do + generate_audio_data args.state.saw_tooth_waves[frequency], sample_rate + end + + audio_state = new_audio_state args, opts + audio_state[:input] = [1, sample_rate, proc] + queue_audio args, audio_state: audio_state, wave: saw_tooth_wave + end + end + + begin # region: triangle wave + def defaults_triangle_wave_for + { frequency: 440, sample_rate: 48000 } + end + + def triangle_wave_for opts = {} + opts = defaults_saw_tooth_wave_for.merge opts + sine_wave = sine_wave_for opts + period_size = sine_wave.length + sine_wave.map_with_index do |v, i| + ratio = (i.fdiv period_size) + if ratio <= 0.5 + (ratio * 4) - 1 + else + ratio -= 0.5 + 1 - (ratio * 4) + end + end + end + + def defaults_queue_triangle_wave + { frequency: 440, duration: 60, gain: 1.0, fade_out: false, queue_in: 0 } + end + + def queue_triangle_wave args, opts = {} + opts = defaults_queue_triangle_wave.merge opts + frequency = opts[:frequency] + sample_rate = 48000 + + triangle_wave = triangle_wave_for frequency: frequency, sample_rate: sample_rate + args.state.triangle_waves[frequency] ||= triangle_wave_for frequency: frequency, sample_rate: sample_rate + + proc = lambda do + generate_audio_data args.state.triangle_waves[frequency], sample_rate + end + + audio_state = new_audio_state args, opts + audio_state[:input] = [1, sample_rate, proc] + queue_audio args, audio_state: audio_state, wave: triangle_wave + end + end + + begin # region: bell + def defaults_queue_bell + { frequency: 440, duration: 1.seconds, queue_in: 0 } + end + + def queue_bell args, opts = {} + (bell_to_sine_waves (defaults_queue_bell.merge opts)).each { |b| queue_sine_wave args, b } + end + + def bell_harmonics + [ + { frequency_ratio: 0.5, duration_ratio: 1.00 }, + { frequency_ratio: 1.0, duration_ratio: 0.80 }, + { frequency_ratio: 2.0, duration_ratio: 0.60 }, + { frequency_ratio: 3.0, duration_ratio: 0.40 }, + { frequency_ratio: 4.2, duration_ratio: 0.25 }, + { frequency_ratio: 5.4, duration_ratio: 0.20 }, + { frequency_ratio: 6.8, duration_ratio: 0.15 } + ] + end + + def defaults_bell_to_sine_waves + { frequency: 440, duration: 1.seconds, queue_in: 0 } + end + + def bell_to_sine_waves opts = {} + opts = defaults_bell_to_sine_waves.merge opts + bell_harmonics.map do |b| + { + frequency: opts[:frequency] * b[:frequency_ratio], + duration: opts[:duration] * b[:duration_ratio], + queue_in: opts[:queue_in], + gain: (1.fdiv bell_harmonics.length), + fade_out: true + } + end + end + end + + begin # audio entity construction + def generate_audio_data sine_wave, sample_rate + sample_size = (sample_rate.fdiv (1000.fdiv 60)).ceil + copy_count = (sample_size.fdiv sine_wave.length).ceil + sine_wave * copy_count + end + + def defaults_new_audio_state + { frequency: 440, duration: 60, gain: 1.0, fade_out: false, queue_in: 0 } + end + + def new_audio_state args, opts = {} + opts = defaults_new_audio_state.merge opts + decay_rate = 0 + decay_rate = 1.fdiv(opts[:duration]) * opts[:gain] if opts[:fade_out] + frequency = opts[:frequency] + sample_rate = 48000 + + { + id: (new_id! args), + frequency: frequency, + sample_rate: 48000, + stop_at: args.tick_count + opts[:queue_in] + opts[:duration], + gain: opts[:gain].to_f, + queue_at: args.state.tick_count + opts[:queue_in], + decay_rate: decay_rate, + pitch: 1.0, + looping: true, + paused: false + } + end + + def queue_audio args, opts = {} + graph_wave args, opts[:wave], opts[:audio_state][:frequency] + args.state.audio_queue << opts[:audio_state] + end + + def new_id! args + args.state.audio_id ||= 0 + args.state.audio_id += 1 + end + + def graph_wave args, wave, frequency + if args.state.tick_count != args.state.graphed_at + args.outputs.static_lines.clear + args.outputs.static_sprites.clear + end + + wave = wave + + r, g, b = frequency.to_i % 85, + frequency.to_i % 170, + frequency.to_i % 255 + + starting_rect = args.layout.rect(row: 5, col: 13) + x_scale = 10 + y_scale = 100 + max_points = 25 + + points = wave + if wave.length > max_points + resolution = wave.length.idiv max_points + points = wave.find_all.with_index { |y, i| (i % resolution == 0) } + end + + args.outputs.static_lines << points.map_with_index do |y, x| + next_y = points[x + 1] + + if next_y + { + x: starting_rect.x + (x * x_scale), + y: starting_rect.y + starting_rect.h.half + y_scale * y, + x2: starting_rect.x + ((x + 1) * x_scale), + y2: starting_rect.y + starting_rect.h.half + y_scale * next_y, + r: r, + g: g, + b: b + } + end + end + + args.outputs.static_sprites << points.map_with_index do |y, x| + { + x: (starting_rect.x + (x * x_scale)) - 2, + y: (starting_rect.y + starting_rect.h.half + y_scale * y) - 2, + w: 4, + h: 4, + path: 'sprites/square-white.png', + r: r, + g: g, + b: b + } + end + + args.state.graphed_at = args.state.tick_count + end + end + + begin # region: musical note mapping + def defaults_frequency_for + { note: :a, octave: 5, sharp: false, flat: false } + end + + def frequency_for opts = {} + opts = defaults_frequency_for.merge opts + octave_offset_multiplier = opts[:octave] - 5 + note = note_frequencies_octave_5[opts[:note]] + if octave_offset_multiplier < 0 + note = note * 1 / (octave_offset_multiplier.abs + 1) + elsif octave_offset_multiplier > 0 + note = note * (octave_offset_multiplier.abs + 1) / 1 + end + note + end + + def note_frequencies_octave_5 + { + a: 440.0, + a_sharp: 466.16, b_flat: 466.16, + b: 493.88, + c: 523.25, + c_sharp: 554.37, d_flat: 587.33, + d: 587.33, + d_sharp: 622.25, e_flat: 659.25, + e: 659.25, + f: 698.25, + f_sharp: 739.99, g_flat: 739.99, + g: 783.99, + g_sharp: 830.61, a_flat: 830.61 + } + end + end +end + +$gtk.reset diff --git a/samples/07_advanced_audio/02_sound_synthesis/license-for-sample.txt b/samples/07_advanced_audio/02_sound_synthesis/license-for-sample.txt new file mode 100644 index 0000000..100dcec --- /dev/null +++ b/samples/07_advanced_audio/02_sound_synthesis/license-for-sample.txt @@ -0,0 +1,9 @@ +Copyright 2019 DragonRuby LLC + +MIT License + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/samples/07_advanced_audio/02_sound_synthesis/metadata/game_metadata.txt b/samples/07_advanced_audio/02_sound_synthesis/metadata/game_metadata.txt new file mode 100644 index 0000000..16cef1d --- /dev/null +++ b/samples/07_advanced_audio/02_sound_synthesis/metadata/game_metadata.txt @@ -0,0 +1,6 @@ +devid=amirrajan +devtitle=Amir Rajan +gameid=hello-world +gametitle=Hello World +version=1.0 +icon=metadata/icon.png diff --git a/samples/07_advanced_audio/02_sound_synthesis/metadata/icon.png b/samples/07_advanced_audio/02_sound_synthesis/metadata/icon.png new file mode 100644 index 0000000..e20e8c2 Binary files /dev/null and b/samples/07_advanced_audio/02_sound_synthesis/metadata/icon.png differ diff --git a/samples/07_advanced_audio/02_sound_synthesis/replay.txt b/samples/07_advanced_audio/02_sound_synthesis/replay.txt new file mode 100644 index 0000000..0d7c6d5 --- /dev/null +++ b/samples/07_advanced_audio/02_sound_synthesis/replay.txt @@ -0,0 +1,237 @@ +replay_version 2.0 +stopped_at 425 +seed 100 +recorded_at Sat Jul 17 09:17:17 2021 +[:mouse_button_up, 1, 0, 1, 1, 4] +[:mouse_move, 790, 90, 2, 2, 31] +[:mouse_move, 781, 91, 2, 3, 32] +[:mouse_move, 753, 101, 2, 4, 33] +[:mouse_move, 737, 106, 2, 5, 34] +[:mouse_move, 716, 109, 2, 6, 35] +[:mouse_move, 633, 122, 2, 7, 36] +[:mouse_move, 583, 132, 2, 8, 37] +[:mouse_move, 489, 167, 2, 9, 38] +[:mouse_move, 443, 189, 2, 10, 39] +[:mouse_move, 356, 237, 2, 11, 40] +[:mouse_move, 330, 255, 2, 12, 41] +[:mouse_move, 307, 276, 2, 13, 42] +[:mouse_move, 300, 282, 2, 14, 43] +[:mouse_move, 285, 293, 2, 15, 43] +[:mouse_move, 271, 298, 2, 16, 44] +[:mouse_move, 222, 308, 2, 17, 45] +[:mouse_move, 178, 314, 2, 18, 46] +[:mouse_move, 104, 327, 2, 19, 47] +[:mouse_move, 82, 331, 2, 20, 48] +[:mouse_move, 55, 332, 2, 21, 49] +[:mouse_move, 47, 330, 2, 22, 50] +[:mouse_move, 41, 325, 2, 23, 51] +[:mouse_move, 38, 322, 2, 24, 52] +[:mouse_move, 35, 315, 2, 25, 53] +[:mouse_move, 33, 312, 2, 26, 54] +[:mouse_move, 35, 299, 2, 27, 55] +[:mouse_move, 37, 290, 2, 28, 56] +[:mouse_move, 43, 277, 2, 29, 57] +[:mouse_move, 47, 271, 2, 30, 58] +[:mouse_move, 54, 262, 2, 31, 59] +[:mouse_move, 61, 256, 2, 32, 60] +[:mouse_move, 71, 247, 2, 33, 61] +[:mouse_move, 90, 231, 2, 34, 62] +[:mouse_move, 103, 223, 2, 35, 63] +[:mouse_move, 128, 209, 2, 36, 64] +[:mouse_move, 138, 205, 2, 37, 65] +[:mouse_move, 157, 194, 2, 38, 66] +[:mouse_move, 168, 186, 2, 39, 67] +[:mouse_move, 187, 169, 2, 40, 68] +[:mouse_move, 193, 163, 2, 41, 69] +[:mouse_move, 197, 157, 2, 42, 70] +[:mouse_move, 199, 154, 2, 43, 71] +[:mouse_move, 202, 148, 2, 44, 72] +[:mouse_move, 204, 143, 2, 45, 73] +[:mouse_move, 206, 139, 2, 46, 74] +[:mouse_move, 204, 142, 2, 47, 82] +[:mouse_move, 203, 145, 2, 48, 83] +[:mouse_move, 194, 152, 2, 49, 84] +[:mouse_move, 189, 157, 2, 50, 85] +[:mouse_move, 169, 172, 2, 51, 86] +[:mouse_move, 155, 185, 2, 52, 87] +[:mouse_move, 128, 217, 2, 53, 88] +[:mouse_move, 119, 232, 2, 54, 89] +[:mouse_move, 112, 243, 2, 55, 90] +[:mouse_move, 106, 255, 2, 56, 91] +[:mouse_move, 104, 258, 2, 57, 92] +[:mouse_move, 102, 262, 2, 58, 93] +[:mouse_move, 101, 265, 2, 59, 94] +[:mouse_move, 96, 272, 2, 60, 95] +[:mouse_move, 95, 273, 2, 61, 96] +[:mouse_move, 93, 274, 2, 62, 100] +[:mouse_move, 85, 277, 2, 63, 101] +[:mouse_move, 84, 277, 2, 64, 102] +[:mouse_move, 83, 277, 2, 65, 103] +[:mouse_button_pressed, 1, 0, 1, 66, 106] +[:mouse_button_up, 1, 0, 1, 67, 112] +[:mouse_move, 83, 278, 2, 68, 113] +[:mouse_move, 84, 285, 2, 69, 114] +[:mouse_move, 82, 292, 2, 70, 116] +[:mouse_move, 78, 309, 2, 71, 117] +[:mouse_move, 76, 318, 2, 72, 118] +[:mouse_move, 76, 326, 2, 73, 119] +[:mouse_move, 76, 333, 2, 74, 120] +[:mouse_move, 75, 336, 2, 75, 122] +[:mouse_move, 73, 344, 2, 76, 123] +[:mouse_move, 71, 347, 2, 77, 124] +[:mouse_move, 70, 349, 2, 78, 125] +[:mouse_button_pressed, 1, 0, 1, 79, 131] +[:mouse_button_up, 1, 0, 1, 80, 136] +[:mouse_move, 70, 350, 2, 81, 142] +[:mouse_move, 70, 353, 2, 82, 143] +[:mouse_move, 68, 362, 2, 83, 144] +[:mouse_move, 68, 367, 2, 84, 145] +[:mouse_move, 67, 370, 2, 85, 146] +[:mouse_move, 66, 376, 2, 86, 147] +[:mouse_move, 66, 379, 2, 87, 148] +[:mouse_move, 65, 385, 2, 88, 149] +[:mouse_move, 65, 387, 2, 89, 150] +[:mouse_move, 66, 387, 2, 90, 151] +[:mouse_button_pressed, 1, 0, 1, 91, 155] +[:mouse_button_up, 1, 0, 1, 92, 160] +[:mouse_move, 68, 386, 2, 93, 160] +[:mouse_move, 84, 365, 2, 94, 161] +[:mouse_move, 99, 342, 2, 95, 162] +[:mouse_move, 142, 284, 2, 96, 163] +[:mouse_move, 159, 260, 2, 97, 164] +[:mouse_move, 181, 220, 2, 98, 165] +[:mouse_move, 189, 189, 2, 99, 167] +[:mouse_move, 190, 177, 2, 100, 168] +[:mouse_move, 190, 167, 2, 101, 169] +[:mouse_move, 192, 149, 2, 102, 170] +[:mouse_move, 192, 147, 2, 103, 171] +[:mouse_move, 190, 152, 2, 104, 178] +[:mouse_move, 187, 157, 2, 105, 179] +[:mouse_move, 184, 168, 2, 106, 180] +[:mouse_move, 183, 171, 2, 107, 181] +[:mouse_move, 183, 173, 2, 108, 182] +[:mouse_move, 183, 172, 2, 109, 186] +[:mouse_move, 184, 172, 2, 110, 187] +[:mouse_move, 184, 171, 2, 111, 188] +[:mouse_move, 185, 168, 2, 112, 189] +[:mouse_move, 187, 163, 2, 113, 190] +[:mouse_move, 188, 160, 2, 114, 191] +[:mouse_move, 188, 159, 2, 115, 192] +[:mouse_button_pressed, 1, 0, 1, 116, 193] +[:mouse_button_up, 1, 0, 1, 117, 198] +[:mouse_move, 189, 159, 2, 118, 198] +[:mouse_move, 195, 163, 2, 119, 200] +[:mouse_move, 202, 167, 2, 120, 201] +[:mouse_move, 214, 173, 2, 121, 202] +[:mouse_move, 240, 187, 2, 122, 203] +[:mouse_move, 251, 194, 2, 123, 204] +[:mouse_move, 269, 205, 2, 124, 205] +[:mouse_move, 277, 210, 2, 125, 206] +[:mouse_move, 290, 216, 2, 126, 207] +[:mouse_move, 291, 217, 2, 127, 208] +[:mouse_button_pressed, 1, 0, 1, 128, 217] +[:mouse_button_up, 1, 0, 1, 129, 219] +[:mouse_move, 292, 217, 2, 130, 220] +[:mouse_move, 298, 222, 2, 131, 220] +[:mouse_move, 306, 226, 2, 132, 221] +[:mouse_move, 322, 234, 2, 133, 221] +[:mouse_move, 330, 238, 2, 134, 221] +[:mouse_move, 338, 241, 2, 135, 222] +[:mouse_move, 351, 244, 2, 136, 222] +[:mouse_move, 359, 246, 2, 137, 223] +[:mouse_move, 374, 251, 2, 138, 223] +[:mouse_move, 382, 253, 2, 139, 223] +[:mouse_move, 392, 256, 2, 140, 224] +[:mouse_move, 393, 256, 2, 141, 224] +[:mouse_button_pressed, 1, 0, 1, 142, 227] +[:mouse_button_up, 1, 0, 1, 143, 232] +[:mouse_move, 402, 262, 2, 144, 235] +[:mouse_move, 410, 268, 2, 145, 236] +[:mouse_move, 431, 279, 2, 146, 237] +[:mouse_move, 440, 283, 2, 147, 238] +[:mouse_move, 448, 287, 2, 148, 239] +[:mouse_move, 458, 292, 2, 149, 240] +[:mouse_move, 463, 295, 2, 150, 242] +[:mouse_move, 471, 299, 2, 151, 243] +[:mouse_move, 474, 301, 2, 152, 244] +[:mouse_move, 478, 302, 2, 153, 245] +[:mouse_button_pressed, 1, 0, 1, 154, 253] +[:mouse_button_up, 1, 0, 1, 155, 259] +[:mouse_move, 479, 303, 2, 156, 259] +[:mouse_move, 484, 307, 2, 157, 260] +[:mouse_move, 504, 321, 2, 158, 261] +[:mouse_move, 516, 329, 2, 159, 262] +[:mouse_move, 538, 342, 2, 160, 263] +[:mouse_move, 546, 345, 2, 161, 264] +[:mouse_move, 555, 349, 2, 162, 265] +[:mouse_move, 558, 350, 2, 163, 267] +[:mouse_move, 560, 351, 2, 164, 268] +[:mouse_move, 561, 351, 2, 165, 270] +[:mouse_move, 562, 351, 2, 166, 271] +[:mouse_move, 563, 351, 2, 167, 273] +[:mouse_move, 564, 351, 2, 168, 274] +[:mouse_move, 565, 352, 2, 169, 278] +[:mouse_button_pressed, 1, 0, 1, 170, 281] +[:mouse_button_up, 1, 0, 1, 171, 287] +[:mouse_move, 563, 358, 2, 172, 287] +[:mouse_move, 559, 363, 2, 173, 288] +[:mouse_move, 553, 371, 2, 174, 289] +[:mouse_move, 550, 375, 2, 175, 291] +[:mouse_move, 543, 381, 2, 176, 292] +[:mouse_move, 539, 384, 2, 177, 293] +[:mouse_move, 529, 389, 2, 178, 294] +[:mouse_move, 523, 393, 2, 179, 295] +[:mouse_move, 503, 402, 2, 180, 296] +[:mouse_move, 494, 405, 2, 181, 299] +[:mouse_move, 493, 406, 2, 182, 301] +[:mouse_move, 492, 406, 2, 183, 302] +[:mouse_button_pressed, 1, 0, 1, 184, 307] +[:mouse_button_up, 1, 0, 1, 185, 312] +[:mouse_move, 483, 413, 2, 186, 314] +[:mouse_move, 476, 417, 2, 187, 315] +[:mouse_move, 460, 424, 2, 188, 316] +[:mouse_move, 452, 427, 2, 189, 317] +[:mouse_move, 433, 433, 2, 190, 318] +[:mouse_move, 423, 436, 2, 191, 320] +[:mouse_move, 404, 443, 2, 192, 321] +[:mouse_move, 396, 448, 2, 193, 322] +[:mouse_move, 386, 453, 2, 194, 323] +[:mouse_move, 383, 454, 2, 195, 324] +[:mouse_move, 374, 456, 2, 196, 325] +[:mouse_move, 369, 457, 2, 197, 327] +[:mouse_move, 365, 458, 2, 198, 328] +[:mouse_button_pressed, 1, 0, 1, 199, 334] +[:mouse_button_up, 1, 0, 1, 200, 341] +[:mouse_move, 364, 460, 2, 201, 343] +[:mouse_move, 364, 461, 2, 202, 344] +[:mouse_move, 359, 465, 2, 203, 345] +[:mouse_move, 352, 467, 2, 204, 346] +[:mouse_move, 341, 471, 2, 205, 347] +[:mouse_move, 336, 473, 2, 206, 348] +[:mouse_move, 324, 478, 2, 207, 349] +[:mouse_move, 316, 482, 2, 208, 351] +[:mouse_move, 297, 491, 2, 209, 352] +[:mouse_move, 288, 494, 2, 210, 353] +[:mouse_move, 278, 498, 2, 211, 354] +[:mouse_move, 274, 499, 2, 212, 355] +[:mouse_move, 270, 502, 2, 213, 356] +[:mouse_move, 269, 502, 2, 214, 357] +[:mouse_move, 269, 503, 2, 215, 358] +[:mouse_move, 268, 503, 2, 216, 359] +[:mouse_move, 266, 505, 2, 217, 360] +[:mouse_move, 266, 506, 2, 218, 362] +[:mouse_move, 265, 506, 2, 219, 364] +[:mouse_move, 265, 507, 2, 220, 365] +[:mouse_move, 265, 508, 2, 221, 367] +[:mouse_button_pressed, 1, 0, 1, 222, 370] +[:mouse_button_up, 1, 0, 1, 223, 372] +[:mouse_move, 266, 508, 2, 224, 375] +[:mouse_move, 267, 508, 2, 225, 382] +[:mouse_move, 268, 508, 2, 226, 383] +[:mouse_move, 270, 509, 2, 227, 383] +[:mouse_move, 271, 509, 2, 228, 385] +[:mouse_move, 272, 509, 2, 229, 385] +[:key_down_raw, 96, 0, 2, 230, 386] +[:mouse_move, 272, 508, 2, 231, 386] +[:key_up_raw, 96, 0, 2, 232, 388] +[:key_down_raw, 13, 0, 2, 233, 425] diff --git a/samples/07_advanced_audio/02_sound_synthesis/sprites/square-white.png b/samples/07_advanced_audio/02_sound_synthesis/sprites/square-white.png new file mode 100644 index 0000000..378c565 Binary files /dev/null and b/samples/07_advanced_audio/02_sound_synthesis/sprites/square-white.png differ diff --git a/samples/07_advanced_rendering/02_render_targets_with_alphas/app/main.rb b/samples/07_advanced_rendering/02_render_targets_with_alphas/app/main.rb deleted file mode 100644 index 2caec43..0000000 --- a/samples/07_advanced_rendering/02_render_targets_with_alphas/app/main.rb +++ /dev/null @@ -1,95 +0,0 @@ -# This sample is meant to show you how to do that dripping transition thing -# at the start of the original Doom. Most of this file is here to animate -# a scene to wipe away; the actual wipe effect is in the last 20 lines or -# so. - -$gtk.reset # reset all game state if reloaded. - -def circle_of_blocks pass, xoffset, yoffset, angleoffset, blocksize, distance - numblocks = 10 - - for i in 1..numblocks do - angle = ((360 / numblocks) * i) + angleoffset - radians = angle * (Math::PI / 180) - x = (xoffset + (distance * Math.cos(radians))).round - y = (yoffset + (distance * Math.sin(radians))).round - pass.solids << [ x, y, blocksize, blocksize, 255, 255, 0 ] - end -end - -def draw_scene args, pass - pass.solids << [0, 360, 1280, 360, 0, 0, 200] - pass.solids << [0, 0, 1280, 360, 0, 127, 0] - - blocksize = 100 - angleoffset = args.state.tick_count * 2.5 - centerx = (1280 - blocksize) / 2 - centery = (720 - blocksize) / 2 - - circle_of_blocks pass, centerx, centery, angleoffset, blocksize * 2, 500 - circle_of_blocks pass, centerx, centery, angleoffset, blocksize, 325 - circle_of_blocks pass, centerx, centery, angleoffset, blocksize / 2, 200 - circle_of_blocks pass, centerx, centery, angleoffset, blocksize / 4, 100 -end - -def tick args - segments = 160 - - # On the first tick, initialize some stuff. - if !args.state.yoffsets - args.state.baseyoff = 0 - args.state.yoffsets = [] - for i in 0..segments do - args.state.yoffsets << rand * 100 - end - end - - # Just draw some random stuff for a few seconds. - args.state.static_debounce ||= 60 * 2.5 - if args.state.static_debounce > 0 - last_frame = args.state.static_debounce == 1 - target = last_frame ? args.render_target(:last_frame) : args.outputs - draw_scene args, target - args.state.static_debounce -= 1 - return unless last_frame - end - - # build up the wipe... - - # this is the thing we're wiping to. - args.outputs.sprites << [ 0, 0, 1280, 720, 'dragonruby.png' ] - - return if (args.state.baseyoff > (1280 + 100)) # stop when done sliding - - segmentw = 1280 / segments - - x = 0 - for i in 0..segments do - yoffset = 0 - if args.state.yoffsets[i] < args.state.baseyoff - yoffset = args.state.baseyoff - args.state.yoffsets[i] - end - - # (720 - yoffset) flips the coordinate system, (- 720) adjusts for the height of the segment. - args.outputs.sprites << [ x, (720 - yoffset) - 720, segmentw, 720, 'last_frame', 0, 255, 255, 255, 255, x, 0, segmentw, 720 ] - x += segmentw - end - - args.state.baseyoff += 4 - - tick_instructions args, "Sample app shows an advanced usage of render_target." -end - -def tick_instructions args, text, y = 715 - return if args.state.key_event_occurred - if args.inputs.mouse.click || - args.inputs.keyboard.directional_vector || - args.inputs.keyboard.key_down.enter || - args.inputs.keyboard.key_down.escape - args.state.key_event_occurred = true - end - - args.outputs.debug << [0, y - 50, 1280, 60].solid - args.outputs.debug << [640, y, text, 1, 1, 255, 255, 255].label - args.outputs.debug << [640, y - 25, "(click to dismiss instructions)" , -2, 1, 255, 255, 255].label -end diff --git a/samples/07_advanced_rendering/02_render_targets_with_alphas/license-for-sample.txt b/samples/07_advanced_rendering/02_render_targets_with_alphas/license-for-sample.txt deleted file mode 100644 index 100dcec..0000000 --- a/samples/07_advanced_rendering/02_render_targets_with_alphas/license-for-sample.txt +++ /dev/null @@ -1,9 +0,0 @@ -Copyright 2019 DragonRuby LLC - -MIT License - -Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/samples/07_advanced_rendering/03_render_target_viewports/app/main.rb b/samples/07_advanced_rendering/03_render_target_viewports/app/main.rb index 0dd6c18..dbceab3 100644 --- a/samples/07_advanced_rendering/03_render_target_viewports/app/main.rb +++ b/samples/07_advanced_rendering/03_render_target_viewports/app/main.rb @@ -25,7 +25,7 @@ would print "How are you, Ruby?" to the console. (Remember, string interpolation only works with double quotes!) - - Ternary operator (?): Similar to if statement; first evaluates whether a statement is + - Ternary operator (?): Similar to if statement; first evalulates whether a statement is true or false, and then executes a command depending on that result. For example, if we had a variable grade = 75 @@ -39,7 +39,7 @@ 720 p screen (Dragon Ruby Game Toolkits's virtual resolution is always 1280x720). - Numeric#shift_(left|right|up|down): Shifts the Numeric in the correct direction - by adding or subtracting. + by adding or subracting. - ARRAY#inside_rect?: An array with at least two values is considered a point. An array with at least four values is considered a rect. The inside_rect? function returns true @@ -48,10 +48,12 @@ - ARRAY#intersect_rect?: Returns true or false depending on if the two rectangles intersect. - args.inputs.mouse.click: This property will be set if the mouse was clicked. + For more information about the mouse, go to mygame/documentation/07-mouse.md. - args.inputs.keyboard.key_up.KEY: The value of the properties will be set to the frame that the key_up event occurred (the frame correlates to args.state.tick_count). + For more information about the keyboard, go to mygame/documentation/06-keyboard.md. - args.state.labels: The parameters for a label are @@ -61,6 +63,7 @@ 4. the alignment 5. the color (red, green, and blue saturations) 6. the alpha (or transparency) + For more information about labels, go to mygame/documentation/02-labels.md. - args.state.lines: The parameters for a line are @@ -68,6 +71,7 @@ 2. the ending position (x2, y2) 3. the color (red, green, and blue saturations) 4. the alpha (or transparency) + For more information about lines, go to mygame/documentation/04-lines.md. - args.state.solids (and args.state.borders): The parameters for a solid (or border) are @@ -76,6 +80,7 @@ 3. the height (h) 4. the color (r, g, b) 5. the alpha (or transparency) + For more information about solids and borders, go to mygame/documentation/03-solids-and-borders.md. - args.state.sprites: The parameters for a sprite are @@ -85,7 +90,7 @@ 4. the image path 5. the angle 6. the alpha (or transparency) - + For more information about sprites, go to mygame/documentation/05-sprites.md. =end # This sample app shows different objects that can be used when making games, such as labels, @@ -111,7 +116,7 @@ class TechDemo button_tech_demo export_game_state_demo window_state_demo - render_separators + render_seperators end # Shows output of different kinds of labels on the screen @@ -408,28 +413,28 @@ class TechDemo end #Sets values for the horizontal separator (divides demo sections) - def horizontal_separator y, x, x2 + def horizontal_seperator y, x, x2 [x, y, x2, y, 150, 150, 150] end #Sets the values for the vertical separator (divides demo sections) - def vertical_separator x, y, y2 + def vertical_seperator x, y, y2 [x, y, x, y2, 150, 150, 150] end # Outputs vertical and horizontal separators onto the screen to separate each demo section. - def render_separators - outputs.lines << horizontal_separator(505, grid.left, 445) - outputs.lines << horizontal_separator(353, grid.left, 445) - outputs.lines << horizontal_separator(264, grid.left, 445) - outputs.lines << horizontal_separator(174, grid.left, 445) + def render_seperators + outputs.lines << horizontal_seperator(505, grid.left, 445) + outputs.lines << horizontal_seperator(353, grid.left, 445) + outputs.lines << horizontal_seperator(264, grid.left, 445) + outputs.lines << horizontal_seperator(174, grid.left, 445) - outputs.lines << vertical_separator(445, grid.top, grid.bottom) + outputs.lines << vertical_seperator(445, grid.top, grid.bottom) - outputs.lines << horizontal_separator(690, 445, 820) - outputs.lines << horizontal_separator(426, 445, 820) + outputs.lines << horizontal_seperator(690, 445, 820) + outputs.lines << horizontal_seperator(426, 445, 820) - outputs.lines << vertical_separator(820, grid.top, grid.bottom) + outputs.lines << vertical_seperator(820, grid.top, grid.bottom) end end diff --git a/samples/07_advanced_rendering/04_render_primitive_hierarchies/app/main.rb b/samples/07_advanced_rendering/04_render_primitive_hierarchies/app/main.rb index 7f345ac..aedd830 100644 --- a/samples/07_advanced_rendering/04_render_primitive_hierarchies/app/main.rb +++ b/samples/07_advanced_rendering/04_render_primitive_hierarchies/app/main.rb @@ -39,6 +39,7 @@ Here is an example of a (red) border or solid definition: [100, 100, 400, 500, 255, 0, 0] It will be a solid or border depending on if it is added to args.outputs.solids or args.outputs.borders. + For more information about solids and borders, go to mygame/documentation/03-solids-and-borders.md. - args.outputs.sprites: An array. The values generate a sprite. The parameters for sprites are @@ -49,6 +50,7 @@ Here is an example of a sprite definition: [100, 100, 400, 500, 'sprites/dragonruby.png'] + For more information about sprites, go to mygame/documentation/05-sprites.md. =end diff --git a/samples/07_advanced_rendering/05_render_primitives_as_hash/app/main.rb b/samples/07_advanced_rendering/05_render_primitives_as_hash/app/main.rb index 53e0f3d..907b0fb 100644 --- a/samples/07_advanced_rendering/05_render_primitives_as_hash/app/main.rb +++ b/samples/07_advanced_rendering/05_render_primitives_as_hash/app/main.rb @@ -16,18 +16,23 @@ - args.outputs.sprites: An array. The values generate a sprite. The parameters are [X, Y, WIDTH, HEIGHT, PATH, ANGLE, ALPHA, RED, GREEN, BLUE] + For more information about sprites, go to mygame/documentation/05-sprites.md. - args.outputs.labels: An array. The values generate a label. The parameters are [X, Y, TEXT, SIZE, ALIGNMENT, RED, GREEN, BLUE, ALPHA, FONT STYLE] + For more information about labels, go to mygame/documentation/02-labels.md. - args.outputs.solids: An array. The values generate a solid. The parameters are [X, Y, WIDTH, HEIGHT, RED, GREEN, BLUE, ALPHA] + For more information about solids, go to mygame/documentation/03-solids-and-borders.md. - args.outputs.borders: An array. The values generate a border. The parameters are the same as a solid. + For more information about borders, go to mygame/documentation/03-solids-and-borders.md. - args.outputs.lines: An array. The values generate a line. The parameters are [X1, Y1, X2, Y2, RED, GREEN, BLUE] + For more information about labels, go to mygame/documentation/02-labels.md. =end @@ -131,7 +136,7 @@ def tick args flip_horizontally: false, angle_anchor_x: 0.5, # rotation center set to middle angle_anchor_y: 0.5 - }.sprite + }.sprite! # Outputs label as primitive using a hash args.outputs.primitives << { @@ -145,7 +150,7 @@ def tick args b: 50, a: 255, # transparency font: "fonts/manaspc.ttf" # font style - }.label + }.label! # Outputs solid as primitive using a hash args.outputs.primitives << { @@ -157,7 +162,7 @@ def tick args g: 50, b: 50, a: 255 # transparency - }.solid + }.solid! # Outputs border as primitive using a hash # Same parameters as solid @@ -170,7 +175,7 @@ def tick args g: 50, b: 50, a: 255 # transparency - }.border + }.border! # Outputs line as primitive using a hash args.outputs.primitives << { @@ -182,5 +187,5 @@ def tick args g: 50, b: 50, a: 255 # transparency - }.line + }.line! end diff --git a/samples/07_advanced_rendering/07_simple_camera/app/main.rb b/samples/07_advanced_rendering/07_simple_camera/app/main.rb new file mode 100644 index 0000000..e8d96ea --- /dev/null +++ b/samples/07_advanced_rendering/07_simple_camera/app/main.rb @@ -0,0 +1,93 @@ +def tick args + # variables you can play around with + args.state.world.w ||= 1280 + args.state.world.h ||= 720 + + args.state.player.x ||= 0 + args.state.player.y ||= 0 + args.state.player.size ||= 32 + + args.state.enemy.x ||= 700 + args.state.enemy.y ||= 700 + args.state.enemy.size ||= 16 + + args.state.camera.x ||= 640 + args.state.camera.y ||= 300 + args.state.camera.scale ||= 1.0 + args.state.camera.show_empty_space ||= :yes + + # instructions + args.outputs.primitives << { x: 0, y: 80.from_top, w: 360, h: 80, r: 0, g: 0, b: 0, a: 128 }.solid! + args.outputs.primitives << { x: 10, y: 10.from_top, text: "arrow keys to move around", r: 255, g: 255, b: 255}.label! + args.outputs.primitives << { x: 10, y: 30.from_top, text: "+/- to change zoom of camera", r: 255, g: 255, b: 255}.label! + args.outputs.primitives << { x: 10, y: 50.from_top, text: "tab to change camera edge behavior", r: 255, g: 255, b: 255}.label! + + # render scene + args.outputs[:scene].w = args.state.world.w + args.outputs[:scene].h = args.state.world.h + + args.outputs[:scene].solids << { x: 0, y: 0, w: args.state.world.w, h: args.state.world.h, r: 20, g: 60, b: 80 } + args.outputs[:scene].solids << { x: args.state.player.x, y: args.state.player.y, + w: args.state.player.size, h: args.state.player.size, r: 80, g: 155, b: 80 } + args.outputs[:scene].solids << { x: args.state.enemy.x, y: args.state.enemy.y, + w: args.state.enemy.size, h: args.state.enemy.size, r: 155, g: 80, b: 80 } + + # render camera + scene_position = calc_scene_position args + args.outputs.sprites << { x: scene_position.x, + y: scene_position.y, + w: scene_position.w, + h: scene_position.h, + path: :scene } + + # move player + if args.inputs.directional_angle + args.state.player.x += args.inputs.directional_angle.vector_x * 5 + args.state.player.y += args.inputs.directional_angle.vector_y * 5 + args.state.player.x = args.state.player.x.clamp(0, args.state.world.w - args.state.player.size) + args.state.player.y = args.state.player.y.clamp(0, args.state.world.h - args.state.player.size) + end + + # +/- to zoom in and out + if args.inputs.keyboard.plus && args.state.tick_count.zmod?(3) + args.state.camera.scale += 0.05 + elsif args.inputs.keyboard.hyphen && args.state.tick_count.zmod?(3) + args.state.camera.scale -= 0.05 + elsif args.inputs.keyboard.key_down.tab + if args.state.camera.show_empty_space == :yes + args.state.camera.show_empty_space = :no + else + args.state.camera.show_empty_space = :yes + end + end + + args.state.camera.scale = args.state.camera.scale.greater(0.1) +end + +def calc_scene_position args + result = { x: args.state.camera.x - (args.state.player.x * args.state.camera.scale), + y: args.state.camera.y - (args.state.player.y * args.state.camera.scale), + w: args.state.world.w * args.state.camera.scale, + h: args.state.world.h * args.state.camera.scale, + scale: args.state.camera.scale } + + return result if args.state.camera.show_empty_space == :yes + + if result.w < args.grid.w + result.merge!(x: (args.grid.w - result.w).half) + elsif (args.state.player.x * result.scale) < args.grid.w.half + result.merge!(x: 10) + elsif (result.x + result.w) < args.grid.w + result.merge!(x: - result.w + (args.grid.w - 10)) + end + + if result.h < args.grid.h + result.merge!(y: (args.grid.h - result.h).half) + elsif (result.y) > 10 + result.merge!(y: 10) + elsif (result.y + result.h) < args.grid.h + result.merge!(y: - result.h + (args.grid.h - 10)) + end + + result +end diff --git a/samples/07_advanced_rendering/07_simple_camera/replay.txt b/samples/07_advanced_rendering/07_simple_camera/replay.txt new file mode 100644 index 0000000..532f46c --- /dev/null +++ b/samples/07_advanced_rendering/07_simple_camera/replay.txt @@ -0,0 +1,232 @@ +replay_version 2.0 +stopped_at 1551 +seed 100 +recorded_at Sat Jul 17 09:21:44 2021 +[:mouse_button_up, 1, 0, 1, 1, 6] +[:mouse_button_pressed, 1, 0, 1, 2, 140] +[:mouse_button_up, 1, 0, 1, 3, 146] +[:key_down_raw, 1073741903, 0, 2, 4, 245] +[:key_down_raw, 1073741903, 0, 2, 5, 259] +[:key_down_raw, 1073741903, 0, 2, 6, 261] +[:key_down_raw, 1073741903, 0, 2, 7, 263] +[:key_down_raw, 1073741903, 0, 2, 8, 265] +[:key_down_raw, 1073741903, 0, 2, 9, 267] +[:key_down_raw, 1073741903, 0, 2, 10, 269] +[:key_down_raw, 1073741906, 0, 2, 11, 269] +[:key_up_raw, 1073741903, 0, 2, 12, 280] +[:key_down_raw, 1073741903, 0, 2, 13, 284] +[:key_down_raw, 1073741903, 0, 2, 14, 299] +[:key_down_raw, 1073741903, 0, 2, 15, 301] +[:key_down_raw, 1073741903, 0, 2, 16, 303] +[:key_down_raw, 1073741903, 0, 2, 17, 305] +[:key_down_raw, 1073741903, 0, 2, 18, 307] +[:key_down_raw, 1073741903, 0, 2, 19, 309] +[:key_down_raw, 1073741903, 0, 2, 20, 311] +[:key_down_raw, 1073741903, 0, 2, 21, 313] +[:key_down_raw, 1073741903, 0, 2, 22, 315] +[:key_down_raw, 1073741903, 0, 2, 23, 317] +[:key_down_raw, 1073741903, 0, 2, 24, 319] +[:key_down_raw, 1073741903, 0, 2, 25, 321] +[:key_down_raw, 1073741903, 0, 2, 26, 323] +[:key_down_raw, 1073741903, 0, 2, 27, 325] +[:key_down_raw, 1073741903, 0, 2, 28, 327] +[:key_down_raw, 1073741903, 0, 2, 29, 329] +[:key_down_raw, 1073741903, 0, 2, 30, 331] +[:key_down_raw, 1073741903, 0, 2, 31, 333] +[:key_down_raw, 1073741903, 0, 2, 32, 335] +[:key_down_raw, 1073741903, 0, 2, 33, 337] +[:key_down_raw, 1073741903, 0, 2, 34, 339] +[:key_up_raw, 1073741906, 0, 2, 35, 341] +[:key_down_raw, 1073741903, 0, 2, 36, 341] +[:key_down_raw, 1073741903, 0, 2, 37, 343] +[:key_down_raw, 1073741903, 0, 2, 38, 345] +[:key_down_raw, 1073741903, 0, 2, 39, 347] +[:key_down_raw, 1073741903, 0, 2, 40, 349] +[:key_down_raw, 1073741903, 0, 2, 41, 351] +[:key_down_raw, 1073741903, 0, 2, 42, 353] +[:key_down_raw, 1073741903, 0, 2, 43, 355] +[:key_down_raw, 1073741906, 0, 2, 44, 357] +[:key_down_raw, 1073741906, 0, 2, 45, 372] +[:key_down_raw, 1073741906, 0, 2, 46, 374] +[:key_down_raw, 1073741906, 0, 2, 47, 376] +[:key_down_raw, 1073741906, 0, 2, 48, 378] +[:key_down_raw, 1073741906, 0, 2, 49, 380] +[:key_down_raw, 1073741906, 0, 2, 50, 382] +[:key_down_raw, 1073741906, 0, 2, 51, 384] +[:key_down_raw, 1073741906, 0, 2, 52, 386] +[:key_down_raw, 1073741906, 0, 2, 53, 388] +[:key_down_raw, 1073741906, 0, 2, 54, 390] +[:key_down_raw, 1073741906, 0, 2, 55, 392] +[:key_down_raw, 1073741906, 0, 2, 56, 395] +[:key_up_raw, 1073741906, 0, 2, 57, 396] +[:key_up_raw, 1073741903, 0, 2, 58, 397] +[:key_down_raw, 8, 0, 2, 59, 466] +[:key_up_raw, 8, 0, 2, 60, 466] +[:key_down_raw, 8, 0, 2, 61, 470] +[:key_up_raw, 8, 0, 2, 62, 475] +[:key_down_raw, 45, 0, 2, 63, 540] +[:key_up_raw, 45, 0, 2, 64, 545] +[:key_down_raw, 45, 0, 2, 65, 551] +[:key_up_raw, 45, 0, 2, 66, 556] +[:key_down_raw, 45, 0, 2, 67, 566] +[:key_up_raw, 45, 0, 2, 68, 571] +[:key_down_raw, 45, 0, 2, 69, 577] +[:key_up_raw, 45, 0, 2, 70, 581] +[:key_down_raw, 45, 0, 2, 71, 595] +[:key_up_raw, 45, 0, 2, 72, 600] +[:key_down_raw, 1073741905, 0, 2, 73, 715] +[:key_down_raw, 1073741905, 0, 2, 74, 730] +[:key_down_raw, 1073741905, 0, 2, 75, 732] +[:key_down_raw, 1073741905, 0, 2, 76, 734] +[:key_down_raw, 1073741905, 0, 2, 77, 736] +[:key_down_raw, 1073741905, 0, 2, 78, 738] +[:key_down_raw, 1073741904, 0, 2, 79, 739] +[:key_up_raw, 1073741905, 0, 2, 80, 743] +[:key_down_raw, 1073741904, 0, 2, 81, 754] +[:key_down_raw, 1073741904, 0, 2, 82, 756] +[:key_down_raw, 1073741904, 0, 2, 83, 758] +[:key_down_raw, 1073741904, 0, 2, 84, 760] +[:key_down_raw, 1073741904, 0, 2, 85, 762] +[:key_down_raw, 1073741904, 0, 2, 86, 764] +[:key_down_raw, 1073741904, 0, 2, 87, 766] +[:key_down_raw, 1073741904, 0, 2, 88, 768] +[:key_down_raw, 1073741904, 0, 2, 89, 770] +[:key_down_raw, 1073741904, 0, 2, 90, 772] +[:key_down_raw, 1073741905, 0, 2, 91, 774] +[:key_down_raw, 1073741906, 0, 2, 92, 781] +[:key_up_raw, 1073741904, 0, 2, 93, 785] +[:key_up_raw, 1073741905, 0, 2, 94, 791] +[:key_down_raw, 1073741906, 0, 2, 95, 796] +[:key_down_raw, 1073741903, 0, 2, 96, 797] +[:key_up_raw, 1073741906, 0, 2, 97, 804] +[:key_up_raw, 1073741903, 0, 2, 98, 810] +[:key_down_raw, 1073742049, 1, 2, 99, 884] +[:key_down_raw, 61, 1, 2, 100, 885] +[:key_up_raw, 61, 1, 2, 101, 888] +[:key_up_raw, 1073742049, 0, 2, 102, 888] +[:key_down_raw, 1073742049, 1, 2, 103, 898] +[:key_down_raw, 61, 1, 2, 104, 899] +[:key_up_raw, 61, 1, 2, 105, 903] +[:key_up_raw, 1073742049, 0, 2, 106, 903] +[:key_down_raw, 1073742049, 1, 2, 107, 909] +[:key_down_raw, 61, 1, 2, 108, 909] +[:key_up_raw, 61, 1, 2, 109, 912] +[:key_up_raw, 1073742049, 0, 2, 110, 913] +[:key_down_raw, 1073742049, 1, 2, 111, 918] +[:key_down_raw, 61, 1, 2, 112, 918] +[:key_up_raw, 61, 1, 2, 113, 921] +[:key_up_raw, 1073742049, 0, 2, 114, 922] +[:key_down_raw, 1073742049, 1, 2, 115, 926] +[:key_down_raw, 61, 1, 2, 116, 926] +[:key_up_raw, 61, 1, 2, 117, 930] +[:key_up_raw, 1073742049, 0, 2, 118, 931] +[:key_down_raw, 1073742049, 1, 2, 119, 935] +[:key_down_raw, 61, 1, 2, 120, 935] +[:key_up_raw, 61, 1, 2, 121, 940] +[:key_up_raw, 1073742049, 0, 2, 122, 941] +[:key_down_raw, 1073742049, 1, 2, 123, 947] +[:key_down_raw, 61, 1, 2, 124, 947] +[:key_up_raw, 61, 1, 2, 125, 950] +[:key_up_raw, 1073742049, 0, 2, 126, 951] +[:key_down_raw, 1073742049, 1, 2, 127, 955] +[:key_down_raw, 61, 1, 2, 128, 956] +[:key_up_raw, 61, 1, 2, 129, 960] +[:key_up_raw, 1073742049, 0, 2, 130, 960] +[:key_down_raw, 9, 0, 2, 131, 986] +[:key_up_raw, 9, 0, 2, 132, 991] +[:key_down_raw, 1073741904, 0, 2, 133, 1015] +[:key_down_raw, 1073741904, 0, 2, 134, 1030] +[:key_down_raw, 1073741904, 0, 2, 135, 1032] +[:key_down_raw, 1073741904, 0, 2, 136, 1034] +[:key_down_raw, 1073741904, 0, 2, 137, 1036] +[:key_down_raw, 1073741904, 0, 2, 138, 1038] +[:key_down_raw, 1073741904, 0, 2, 139, 1040] +[:key_down_raw, 1073741904, 0, 2, 140, 1042] +[:key_up_raw, 1073741904, 0, 2, 141, 1044] +[:key_down_raw, 1073741903, 0, 2, 142, 1048] +[:key_down_raw, 1073741903, 0, 2, 143, 1063] +[:key_down_raw, 1073741903, 0, 2, 144, 1065] +[:key_down_raw, 1073741903, 0, 2, 145, 1067] +[:key_down_raw, 1073741903, 0, 2, 146, 1069] +[:key_down_raw, 1073741903, 0, 2, 147, 1071] +[:key_down_raw, 1073741903, 0, 2, 148, 1073] +[:key_down_raw, 1073741903, 0, 2, 149, 1075] +[:key_down_raw, 1073741903, 0, 2, 150, 1077] +[:key_down_raw, 1073741903, 0, 2, 151, 1079] +[:key_down_raw, 1073741903, 0, 2, 152, 1081] +[:key_down_raw, 1073741903, 0, 2, 153, 1083] +[:key_down_raw, 1073741903, 0, 2, 154, 1085] +[:key_down_raw, 1073741903, 0, 2, 155, 1087] +[:key_down_raw, 1073741903, 0, 2, 156, 1089] +[:key_down_raw, 1073741903, 0, 2, 157, 1091] +[:key_down_raw, 1073741903, 0, 2, 158, 1093] +[:key_down_raw, 1073741903, 0, 2, 159, 1095] +[:key_down_raw, 1073741903, 0, 2, 160, 1097] +[:key_down_raw, 1073741903, 0, 2, 161, 1099] +[:key_down_raw, 1073741903, 0, 2, 162, 1101] +[:key_down_raw, 1073741903, 0, 2, 163, 1103] +[:key_down_raw, 1073741903, 0, 2, 164, 1105] +[:key_down_raw, 1073741903, 0, 2, 165, 1107] +[:key_down_raw, 1073741903, 0, 2, 166, 1109] +[:key_down_raw, 1073741903, 0, 2, 167, 1111] +[:key_down_raw, 1073741903, 0, 2, 168, 1113] +[:key_down_raw, 1073741903, 0, 2, 169, 1115] +[:key_down_raw, 1073741903, 0, 2, 170, 1117] +[:key_down_raw, 1073741903, 0, 2, 171, 1119] +[:key_down_raw, 1073741903, 0, 2, 172, 1121] +[:key_down_raw, 1073741903, 0, 2, 173, 1123] +[:key_down_raw, 1073741903, 0, 2, 174, 1125] +[:key_down_raw, 1073741903, 0, 2, 175, 1127] +[:key_down_raw, 1073741903, 0, 2, 176, 1129] +[:key_down_raw, 1073741903, 0, 2, 177, 1131] +[:key_down_raw, 1073741903, 0, 2, 178, 1133] +[:key_down_raw, 1073741903, 0, 2, 179, 1135] +[:key_down_raw, 1073741903, 0, 2, 180, 1137] +[:key_down_raw, 1073741903, 0, 2, 181, 1139] +[:key_down_raw, 1073741903, 0, 2, 182, 1141] +[:key_down_raw, 1073741903, 0, 2, 183, 1143] +[:key_down_raw, 1073741903, 0, 2, 184, 1145] +[:key_down_raw, 1073741903, 0, 2, 185, 1147] +[:key_down_raw, 1073741903, 0, 2, 186, 1149] +[:key_down_raw, 1073741903, 0, 2, 187, 1151] +[:key_down_raw, 1073741903, 0, 2, 188, 1153] +[:key_down_raw, 1073741903, 0, 2, 189, 1155] +[:key_down_raw, 1073741903, 0, 2, 190, 1157] +[:key_down_raw, 1073741903, 0, 2, 191, 1159] +[:key_down_raw, 1073741903, 0, 2, 192, 1161] +[:key_down_raw, 1073741903, 0, 2, 193, 1163] +[:key_down_raw, 1073741905, 0, 2, 194, 1164] +[:key_down_raw, 1073741905, 0, 2, 195, 1180] +[:key_down_raw, 1073741905, 0, 2, 196, 1182] +[:key_down_raw, 1073741905, 0, 2, 197, 1184] +[:key_down_raw, 1073741905, 0, 2, 198, 1186] +[:key_down_raw, 1073741905, 0, 2, 199, 1188] +[:key_down_raw, 1073741905, 0, 2, 200, 1190] +[:key_down_raw, 1073741905, 0, 2, 201, 1192] +[:key_down_raw, 1073741905, 0, 2, 202, 1194] +[:key_down_raw, 1073741905, 0, 2, 203, 1196] +[:key_down_raw, 1073741905, 0, 2, 204, 1198] +[:key_down_raw, 1073741905, 0, 2, 205, 1200] +[:key_down_raw, 1073741905, 0, 2, 206, 1202] +[:key_down_raw, 1073741905, 0, 2, 207, 1204] +[:key_down_raw, 1073741905, 0, 2, 208, 1206] +[:key_down_raw, 1073741905, 0, 2, 209, 1208] +[:key_down_raw, 1073741905, 0, 2, 210, 1210] +[:key_down_raw, 1073741905, 0, 2, 211, 1212] +[:key_down_raw, 1073741905, 0, 2, 212, 1214] +[:key_down_raw, 1073741905, 0, 2, 213, 1216] +[:key_up_raw, 1073741903, 0, 2, 214, 1216] +[:key_up_raw, 1073741905, 0, 2, 215, 1217] +[:key_down_raw, 45, 0, 2, 216, 1263] +[:key_up_raw, 45, 0, 2, 217, 1265] +[:key_down_raw, 45, 0, 2, 218, 1271] +[:key_up_raw, 45, 0, 2, 219, 1275] +[:key_down_raw, 45, 0, 2, 220, 1282] +[:key_up_raw, 45, 0, 2, 221, 1287] +[:key_down_raw, 45, 0, 2, 222, 1296] +[:key_up_raw, 45, 0, 2, 223, 1301] +[:key_down_raw, 45, 0, 2, 224, 1308] +[:key_up_raw, 45, 0, 2, 225, 1312] +[:key_down_raw, 96, 0, 2, 226, 1386] +[:key_up_raw, 96, 0, 2, 227, 1391] +[:key_down_raw, 13, 0, 2, 228, 1551] diff --git a/samples/07_advanced_rendering/07_splitscreen_camera/app/main.rb b/samples/07_advanced_rendering/07_splitscreen_camera/app/main.rb deleted file mode 100644 index 9b08e1e..0000000 --- a/samples/07_advanced_rendering/07_splitscreen_camera/app/main.rb +++ /dev/null @@ -1,395 +0,0 @@ -class CameraMovement - attr_accessor :state, :inputs, :outputs, :grid - - #============================================================================================== - #Serialize - def serialize - {state: state, inputs: inputs, outputs: outputs, grid: grid } - end - - def inspect - serialize.to_s - end - - def to_s - serialize.to_s - end - - #============================================================================================== - #Tick - def tick - defaults - calc - render - input - end - - #============================================================================================== - #Default functions - def defaults - outputs[:scene].background_color = [0,0,0] - state.trauma ||= 0.0 - state.trauma_power ||= 2 - state.player_cyan ||= new_player_cyan - state.player_magenta ||= new_player_magenta - state.camera_magenta ||= new_camera_magenta - state.camera_cyan ||= new_camera_cyan - state.camera_center ||= new_camera_center - state.room ||= new_room - end - - def default_player x, y, w, h, sprite_path - state.new_entity(:player, - { x: x, - y: y, - dy: 0, - dx: 0, - w: w, - h: h, - damage: 0, - dead: false, - orientation: "down", - max_alpha: 255, - sprite_path: sprite_path}) - end - - def default_floor_tile x, y, w, h, sprite_path - state.new_entity(:room, - { x: x, - y: y, - w: w, - h: h, - sprite_path: sprite_path}) - end - - def default_camera x, y, w, h - state.new_entity(:camera, - { x: x, - y: y, - dx: 0, - dy: 0, - w: w, - h: h}) - end - - def new_player_cyan - default_player(0, 0, 64, 64, - "sprites/player/player_#{state.player_cyan.orientation}_standing.png") - end - - def new_player_magenta - default_player(64, 0, 64, 64, - "sprites/player/player_#{state.player_magenta.orientation}_standing.png") - end - - def new_camera_magenta - default_camera(0,0,720,720) - end - - def new_camera_cyan - default_camera(0,0,720,720) - end - - def new_camera_center - default_camera(0,0,1280,720) - end - - def new_room - default_floor_tile(0,0,1024,1024,'sprites/rooms/camera_room.png') - end - - #============================================================================================== - #Calculation functions - def calc - calc_camera_magenta - calc_camera_cyan - calc_camera_center - calc_player_cyan - calc_player_magenta - calc_trauma_decay - end - - def center_camera_tolerance - return Math.sqrt(((state.player_magenta.x - state.player_cyan.x) ** 2) + - ((state.player_magenta.y - state.player_cyan.y) ** 2)) > 640 - end - - def calc_player_cyan - state.player_cyan.x += state.player_cyan.dx - state.player_cyan.y += state.player_cyan.dy - end - - def calc_player_magenta - state.player_magenta.x += state.player_magenta.dx - state.player_magenta.y += state.player_magenta.dy - end - - def calc_camera_center - timeScale = 1 - midX = (state.player_magenta.x + state.player_cyan.x)/2 - midY = (state.player_magenta.y + state.player_cyan.y)/2 - targetX = midX - state.camera_center.w/2 - targetY = midY - state.camera_center.h/2 - state.camera_center.x += (targetX - state.camera_center.x) * 0.1 * timeScale - state.camera_center.y += (targetY - state.camera_center.y) * 0.1 * timeScale - end - - - def calc_camera_magenta - timeScale = 1 - targetX = state.player_magenta.x + state.player_magenta.w - state.camera_magenta.w/2 - targetY = state.player_magenta.y + state.player_magenta.h - state.camera_magenta.h/2 - state.camera_magenta.x += (targetX - state.camera_magenta.x) * 0.1 * timeScale - state.camera_magenta.y += (targetY - state.camera_magenta.y) * 0.1 * timeScale - end - - def calc_camera_cyan - timeScale = 1 - targetX = state.player_cyan.x + state.player_cyan.w - state.camera_cyan.w/2 - targetY = state.player_cyan.y + state.player_cyan.h - state.camera_cyan.h/2 - state.camera_cyan.x += (targetX - state.camera_cyan.x) * 0.1 * timeScale - state.camera_cyan.y += (targetY - state.camera_cyan.y) * 0.1 * timeScale - end - - def calc_player_quadrant angle - if angle < 45 and angle > -45 and state.player_cyan.x < state.player_magenta.x - return 1 - elsif angle < 45 and angle > -45 and state.player_cyan.x > state.player_magenta.x - return 3 - elsif (angle > 45 or angle < -45) and state.player_cyan.y < state.player_magenta.y - return 2 - elsif (angle > 45 or angle < -45) and state.player_cyan.y > state.player_magenta.y - return 4 - end - end - - def calc_camera_shake - state.trauma - end - - def calc_trauma_decay - state.trauma = state.trauma * 0.9 - end - - def calc_random_float_range(min, max) - rand * (max-min) + min - end - - #============================================================================================== - #Render Functions - def render - render_floor - render_player_cyan - render_player_magenta - if center_camera_tolerance - render_split_camera_scene - else - render_camera_center_scene - end - end - - def render_player_cyan - outputs[:scene].sprites << {x: state.player_cyan.x, - y: state.player_cyan.y, - w: state.player_cyan.w, - h: state.player_cyan.h, - path: "sprites/player/player_#{state.player_cyan.orientation}_standing.png", - r: 0, - g: 255, - b: 255} - end - - def render_player_magenta - outputs[:scene].sprites << {x: state.player_magenta.x, - y: state.player_magenta.y, - w: state.player_magenta.w, - h: state.player_magenta.h, - path: "sprites/player/player_#{state.player_magenta.orientation}_standing.png", - r: 255, - g: 0, - b: 255} - end - - def render_floor - outputs[:scene].sprites << [state.room.x, state.room.y, - state.room.w, state.room.h, - state.room.sprite_path] - end - - def render_camera_center_scene - zoomFactor = 1 - outputs[:scene].width = state.room.w - outputs[:scene].height = state.room.h - - maxAngle = 10.0 - maxOffset = 20.0 - angle = maxAngle * calc_camera_shake * calc_random_float_range(-1,1) - offsetX = 32 - (maxOffset * calc_camera_shake * calc_random_float_range(-1,1)) - offsetY = 32 - (maxOffset * calc_camera_shake * calc_random_float_range(-1,1)) - - outputs.sprites << {x: (-state.camera_center.x - offsetX)/zoomFactor, - y: (-state.camera_center.y - offsetY)/zoomFactor, - w: outputs[:scene].width/zoomFactor, - h: outputs[:scene].height/zoomFactor, - path: :scene, - angle: angle, - source_w: -1, - source_h: -1} - outputs.labels << [128,64,"#{state.trauma.round(1)}",8,2,255,0,255,255] - end - - def render_split_camera_scene - outputs[:scene].width = state.room.w - outputs[:scene].height = state.room.h - render_camera_magenta_scene - render_camera_cyan_scene - - angle = Math.atan((state.player_magenta.y - state.player_cyan.y)/(state.player_magenta.x- state.player_cyan.x)) * 180/Math::PI - output_split_camera angle - - end - - def render_camera_magenta_scene - zoomFactor = 1 - offsetX = 32 - offsetY = 32 - - outputs[:scene_magenta].sprites << {x: (-state.camera_magenta.x*2), - y: (-state.camera_magenta.y), - w: outputs[:scene].width*2, - h: outputs[:scene].height, - path: :scene} - - end - - def render_camera_cyan_scene - zoomFactor = 1 - offsetX = 32 - offsetY = 32 - outputs[:scene_cyan].sprites << {x: (-state.camera_cyan.x*2), - y: (-state.camera_cyan.y), - w: outputs[:scene].width*2, - h: outputs[:scene].height, - path: :scene} - end - - def output_split_camera angle - #TODO: Clean this up! - quadrant = calc_player_quadrant angle - outputs.labels << [128,64,"#{quadrant}",8,2,255,0,255,255] - if quadrant == 1 - set_camera_attributes(w: 640, h: 720, m_x: 640, m_y: 0, c_x: 0, c_y: 0) - - elsif quadrant == 2 - set_camera_attributes(w: 1280, h: 360, m_x: 0, m_y: 360, c_x: 0, c_y: 0) - - elsif quadrant == 3 - set_camera_attributes(w: 640, h: 720, m_x: 0, m_y: 0, c_x: 640, c_y: 0) - - elsif quadrant == 4 - set_camera_attributes(w: 1280, h: 360, m_x: 0, m_y: 0, c_x: 0, c_y: 360) - - end - end - - def set_camera_attributes(w: 0, h: 0, m_x: 0, m_y: 0, c_x: 0, c_y: 0) - state.camera_cyan.w = w + 64 - state.camera_cyan.h = h + 64 - outputs[:scene_cyan].width = (w) * 2 - outputs[:scene_cyan].height = h - - state.camera_magenta.w = w + 64 - state.camera_magenta.h = h + 64 - outputs[:scene_magenta].width = (w) * 2 - outputs[:scene_magenta].height = h - outputs.sprites << {x: m_x, - y: m_y, - w: w, - h: h, - path: :scene_magenta} - outputs.sprites << {x: c_x, - y: c_y, - w: w, - h: h, - path: :scene_cyan} - end - - def add_trauma amount - state.trauma = [state.trauma + amount, 1.0].min - end - - def remove_trauma amount - state.trauma = [state.trauma - amount, 0.0].max - end - #============================================================================================== - #Input functions - def input - input_move_cyan - input_move_magenta - - if inputs.keyboard.key_down.t - add_trauma(0.5) - elsif inputs.keyboard.key_down.y - remove_trauma(0.1) - end - end - - def input_move_cyan - if inputs.keyboard.key_held.up - state.player_cyan.dy = 5 - state.player_cyan.orientation = "up" - elsif inputs.keyboard.key_held.down - state.player_cyan.dy = -5 - state.player_cyan.orientation = "down" - else - state.player_cyan.dy *= 0.8 - end - if inputs.keyboard.key_held.left - state.player_cyan.dx = -5 - state.player_cyan.orientation = "left" - elsif inputs.keyboard.key_held.right - state.player_cyan.dx = 5 - state.player_cyan.orientation = "right" - else - state.player_cyan.dx *= 0.8 - end - - outputs.labels << [128,512,"#{state.player_cyan.x.round()}",8,2,0,255,255,255] - outputs.labels << [128,480,"#{state.player_cyan.y.round()}",8,2,0,255,255,255] - end - - def input_move_magenta - if inputs.keyboard.key_held.w - state.player_magenta.dy = 5 - state.player_magenta.orientation = "up" - elsif inputs.keyboard.key_held.s - state.player_magenta.dy = -5 - state.player_magenta.orientation = "down" - else - state.player_magenta.dy *= 0.8 - end - if inputs.keyboard.key_held.a - state.player_magenta.dx = -5 - state.player_magenta.orientation = "left" - elsif inputs.keyboard.key_held.d - state.player_magenta.dx = 5 - state.player_magenta.orientation = "right" - else - state.player_magenta.dx *= 0.8 - end - - outputs.labels << [128,360,"#{state.player_magenta.x.round()}",8,2,255,0,255,255] - outputs.labels << [128,328,"#{state.player_magenta.y.round()}",8,2,255,0,255,255] - end -end - -$camera_movement = CameraMovement.new - -def tick args - args.outputs.background_color = [0,0,0] - $camera_movement.inputs = args.inputs - $camera_movement.outputs = args.outputs - $camera_movement.state = args.state - $camera_movement.grid = args.grid - $camera_movement.tick -end diff --git a/samples/07_advanced_rendering/07_splitscreen_camera/run.bat b/samples/07_advanced_rendering/07_splitscreen_camera/run.bat deleted file mode 100644 index 08e7ed8..0000000 --- a/samples/07_advanced_rendering/07_splitscreen_camera/run.bat +++ /dev/null @@ -1,6 +0,0 @@ -cd /d %~dp0 - -cd .. -cd .. -cd .. -dragonruby samples/99_camera/splitscreen diff --git a/samples/07_advanced_rendering/07_splitscreen_camera/sprites/player/player_down_standing.png b/samples/07_advanced_rendering/07_splitscreen_camera/sprites/player/player_down_standing.png deleted file mode 100644 index 9e27489..0000000 Binary files a/samples/07_advanced_rendering/07_splitscreen_camera/sprites/player/player_down_standing.png and /dev/null differ diff --git a/samples/07_advanced_rendering/07_splitscreen_camera/sprites/player/player_left_standing.png b/samples/07_advanced_rendering/07_splitscreen_camera/sprites/player/player_left_standing.png deleted file mode 100644 index 2fea35b..0000000 Binary files a/samples/07_advanced_rendering/07_splitscreen_camera/sprites/player/player_left_standing.png and /dev/null differ diff --git a/samples/07_advanced_rendering/07_splitscreen_camera/sprites/player/player_right_standing.png b/samples/07_advanced_rendering/07_splitscreen_camera/sprites/player/player_right_standing.png deleted file mode 100644 index 6f3402e..0000000 Binary files a/samples/07_advanced_rendering/07_splitscreen_camera/sprites/player/player_right_standing.png and /dev/null differ diff --git a/samples/07_advanced_rendering/07_splitscreen_camera/sprites/player/player_up_standing.png b/samples/07_advanced_rendering/07_splitscreen_camera/sprites/player/player_up_standing.png deleted file mode 100644 index 9ebdca7..0000000 Binary files a/samples/07_advanced_rendering/07_splitscreen_camera/sprites/player/player_up_standing.png and /dev/null differ diff --git a/samples/07_advanced_rendering/07_splitscreen_camera/sprites/rooms/camera_room.png b/samples/07_advanced_rendering/07_splitscreen_camera/sprites/rooms/camera_room.png deleted file mode 100644 index e0ca375..0000000 Binary files a/samples/07_advanced_rendering/07_splitscreen_camera/sprites/rooms/camera_room.png and /dev/null differ diff --git a/samples/07_advanced_rendering/08_splitscreen_camera/app/main.rb b/samples/07_advanced_rendering/08_splitscreen_camera/app/main.rb new file mode 100644 index 0000000..9b08e1e --- /dev/null +++ b/samples/07_advanced_rendering/08_splitscreen_camera/app/main.rb @@ -0,0 +1,395 @@ +class CameraMovement + attr_accessor :state, :inputs, :outputs, :grid + + #============================================================================================== + #Serialize + def serialize + {state: state, inputs: inputs, outputs: outputs, grid: grid } + end + + def inspect + serialize.to_s + end + + def to_s + serialize.to_s + end + + #============================================================================================== + #Tick + def tick + defaults + calc + render + input + end + + #============================================================================================== + #Default functions + def defaults + outputs[:scene].background_color = [0,0,0] + state.trauma ||= 0.0 + state.trauma_power ||= 2 + state.player_cyan ||= new_player_cyan + state.player_magenta ||= new_player_magenta + state.camera_magenta ||= new_camera_magenta + state.camera_cyan ||= new_camera_cyan + state.camera_center ||= new_camera_center + state.room ||= new_room + end + + def default_player x, y, w, h, sprite_path + state.new_entity(:player, + { x: x, + y: y, + dy: 0, + dx: 0, + w: w, + h: h, + damage: 0, + dead: false, + orientation: "down", + max_alpha: 255, + sprite_path: sprite_path}) + end + + def default_floor_tile x, y, w, h, sprite_path + state.new_entity(:room, + { x: x, + y: y, + w: w, + h: h, + sprite_path: sprite_path}) + end + + def default_camera x, y, w, h + state.new_entity(:camera, + { x: x, + y: y, + dx: 0, + dy: 0, + w: w, + h: h}) + end + + def new_player_cyan + default_player(0, 0, 64, 64, + "sprites/player/player_#{state.player_cyan.orientation}_standing.png") + end + + def new_player_magenta + default_player(64, 0, 64, 64, + "sprites/player/player_#{state.player_magenta.orientation}_standing.png") + end + + def new_camera_magenta + default_camera(0,0,720,720) + end + + def new_camera_cyan + default_camera(0,0,720,720) + end + + def new_camera_center + default_camera(0,0,1280,720) + end + + def new_room + default_floor_tile(0,0,1024,1024,'sprites/rooms/camera_room.png') + end + + #============================================================================================== + #Calculation functions + def calc + calc_camera_magenta + calc_camera_cyan + calc_camera_center + calc_player_cyan + calc_player_magenta + calc_trauma_decay + end + + def center_camera_tolerance + return Math.sqrt(((state.player_magenta.x - state.player_cyan.x) ** 2) + + ((state.player_magenta.y - state.player_cyan.y) ** 2)) > 640 + end + + def calc_player_cyan + state.player_cyan.x += state.player_cyan.dx + state.player_cyan.y += state.player_cyan.dy + end + + def calc_player_magenta + state.player_magenta.x += state.player_magenta.dx + state.player_magenta.y += state.player_magenta.dy + end + + def calc_camera_center + timeScale = 1 + midX = (state.player_magenta.x + state.player_cyan.x)/2 + midY = (state.player_magenta.y + state.player_cyan.y)/2 + targetX = midX - state.camera_center.w/2 + targetY = midY - state.camera_center.h/2 + state.camera_center.x += (targetX - state.camera_center.x) * 0.1 * timeScale + state.camera_center.y += (targetY - state.camera_center.y) * 0.1 * timeScale + end + + + def calc_camera_magenta + timeScale = 1 + targetX = state.player_magenta.x + state.player_magenta.w - state.camera_magenta.w/2 + targetY = state.player_magenta.y + state.player_magenta.h - state.camera_magenta.h/2 + state.camera_magenta.x += (targetX - state.camera_magenta.x) * 0.1 * timeScale + state.camera_magenta.y += (targetY - state.camera_magenta.y) * 0.1 * timeScale + end + + def calc_camera_cyan + timeScale = 1 + targetX = state.player_cyan.x + state.player_cyan.w - state.camera_cyan.w/2 + targetY = state.player_cyan.y + state.player_cyan.h - state.camera_cyan.h/2 + state.camera_cyan.x += (targetX - state.camera_cyan.x) * 0.1 * timeScale + state.camera_cyan.y += (targetY - state.camera_cyan.y) * 0.1 * timeScale + end + + def calc_player_quadrant angle + if angle < 45 and angle > -45 and state.player_cyan.x < state.player_magenta.x + return 1 + elsif angle < 45 and angle > -45 and state.player_cyan.x > state.player_magenta.x + return 3 + elsif (angle > 45 or angle < -45) and state.player_cyan.y < state.player_magenta.y + return 2 + elsif (angle > 45 or angle < -45) and state.player_cyan.y > state.player_magenta.y + return 4 + end + end + + def calc_camera_shake + state.trauma + end + + def calc_trauma_decay + state.trauma = state.trauma * 0.9 + end + + def calc_random_float_range(min, max) + rand * (max-min) + min + end + + #============================================================================================== + #Render Functions + def render + render_floor + render_player_cyan + render_player_magenta + if center_camera_tolerance + render_split_camera_scene + else + render_camera_center_scene + end + end + + def render_player_cyan + outputs[:scene].sprites << {x: state.player_cyan.x, + y: state.player_cyan.y, + w: state.player_cyan.w, + h: state.player_cyan.h, + path: "sprites/player/player_#{state.player_cyan.orientation}_standing.png", + r: 0, + g: 255, + b: 255} + end + + def render_player_magenta + outputs[:scene].sprites << {x: state.player_magenta.x, + y: state.player_magenta.y, + w: state.player_magenta.w, + h: state.player_magenta.h, + path: "sprites/player/player_#{state.player_magenta.orientation}_standing.png", + r: 255, + g: 0, + b: 255} + end + + def render_floor + outputs[:scene].sprites << [state.room.x, state.room.y, + state.room.w, state.room.h, + state.room.sprite_path] + end + + def render_camera_center_scene + zoomFactor = 1 + outputs[:scene].width = state.room.w + outputs[:scene].height = state.room.h + + maxAngle = 10.0 + maxOffset = 20.0 + angle = maxAngle * calc_camera_shake * calc_random_float_range(-1,1) + offsetX = 32 - (maxOffset * calc_camera_shake * calc_random_float_range(-1,1)) + offsetY = 32 - (maxOffset * calc_camera_shake * calc_random_float_range(-1,1)) + + outputs.sprites << {x: (-state.camera_center.x - offsetX)/zoomFactor, + y: (-state.camera_center.y - offsetY)/zoomFactor, + w: outputs[:scene].width/zoomFactor, + h: outputs[:scene].height/zoomFactor, + path: :scene, + angle: angle, + source_w: -1, + source_h: -1} + outputs.labels << [128,64,"#{state.trauma.round(1)}",8,2,255,0,255,255] + end + + def render_split_camera_scene + outputs[:scene].width = state.room.w + outputs[:scene].height = state.room.h + render_camera_magenta_scene + render_camera_cyan_scene + + angle = Math.atan((state.player_magenta.y - state.player_cyan.y)/(state.player_magenta.x- state.player_cyan.x)) * 180/Math::PI + output_split_camera angle + + end + + def render_camera_magenta_scene + zoomFactor = 1 + offsetX = 32 + offsetY = 32 + + outputs[:scene_magenta].sprites << {x: (-state.camera_magenta.x*2), + y: (-state.camera_magenta.y), + w: outputs[:scene].width*2, + h: outputs[:scene].height, + path: :scene} + + end + + def render_camera_cyan_scene + zoomFactor = 1 + offsetX = 32 + offsetY = 32 + outputs[:scene_cyan].sprites << {x: (-state.camera_cyan.x*2), + y: (-state.camera_cyan.y), + w: outputs[:scene].width*2, + h: outputs[:scene].height, + path: :scene} + end + + def output_split_camera angle + #TODO: Clean this up! + quadrant = calc_player_quadrant angle + outputs.labels << [128,64,"#{quadrant}",8,2,255,0,255,255] + if quadrant == 1 + set_camera_attributes(w: 640, h: 720, m_x: 640, m_y: 0, c_x: 0, c_y: 0) + + elsif quadrant == 2 + set_camera_attributes(w: 1280, h: 360, m_x: 0, m_y: 360, c_x: 0, c_y: 0) + + elsif quadrant == 3 + set_camera_attributes(w: 640, h: 720, m_x: 0, m_y: 0, c_x: 640, c_y: 0) + + elsif quadrant == 4 + set_camera_attributes(w: 1280, h: 360, m_x: 0, m_y: 0, c_x: 0, c_y: 360) + + end + end + + def set_camera_attributes(w: 0, h: 0, m_x: 0, m_y: 0, c_x: 0, c_y: 0) + state.camera_cyan.w = w + 64 + state.camera_cyan.h = h + 64 + outputs[:scene_cyan].width = (w) * 2 + outputs[:scene_cyan].height = h + + state.camera_magenta.w = w + 64 + state.camera_magenta.h = h + 64 + outputs[:scene_magenta].width = (w) * 2 + outputs[:scene_magenta].height = h + outputs.sprites << {x: m_x, + y: m_y, + w: w, + h: h, + path: :scene_magenta} + outputs.sprites << {x: c_x, + y: c_y, + w: w, + h: h, + path: :scene_cyan} + end + + def add_trauma amount + state.trauma = [state.trauma + amount, 1.0].min + end + + def remove_trauma amount + state.trauma = [state.trauma - amount, 0.0].max + end + #============================================================================================== + #Input functions + def input + input_move_cyan + input_move_magenta + + if inputs.keyboard.key_down.t + add_trauma(0.5) + elsif inputs.keyboard.key_down.y + remove_trauma(0.1) + end + end + + def input_move_cyan + if inputs.keyboard.key_held.up + state.player_cyan.dy = 5 + state.player_cyan.orientation = "up" + elsif inputs.keyboard.key_held.down + state.player_cyan.dy = -5 + state.player_cyan.orientation = "down" + else + state.player_cyan.dy *= 0.8 + end + if inputs.keyboard.key_held.left + state.player_cyan.dx = -5 + state.player_cyan.orientation = "left" + elsif inputs.keyboard.key_held.right + state.player_cyan.dx = 5 + state.player_cyan.orientation = "right" + else + state.player_cyan.dx *= 0.8 + end + + outputs.labels << [128,512,"#{state.player_cyan.x.round()}",8,2,0,255,255,255] + outputs.labels << [128,480,"#{state.player_cyan.y.round()}",8,2,0,255,255,255] + end + + def input_move_magenta + if inputs.keyboard.key_held.w + state.player_magenta.dy = 5 + state.player_magenta.orientation = "up" + elsif inputs.keyboard.key_held.s + state.player_magenta.dy = -5 + state.player_magenta.orientation = "down" + else + state.player_magenta.dy *= 0.8 + end + if inputs.keyboard.key_held.a + state.player_magenta.dx = -5 + state.player_magenta.orientation = "left" + elsif inputs.keyboard.key_held.d + state.player_magenta.dx = 5 + state.player_magenta.orientation = "right" + else + state.player_magenta.dx *= 0.8 + end + + outputs.labels << [128,360,"#{state.player_magenta.x.round()}",8,2,255,0,255,255] + outputs.labels << [128,328,"#{state.player_magenta.y.round()}",8,2,255,0,255,255] + end +end + +$camera_movement = CameraMovement.new + +def tick args + args.outputs.background_color = [0,0,0] + $camera_movement.inputs = args.inputs + $camera_movement.outputs = args.outputs + $camera_movement.state = args.state + $camera_movement.grid = args.grid + $camera_movement.tick +end diff --git a/samples/07_advanced_rendering/08_splitscreen_camera/replay.txt b/samples/07_advanced_rendering/08_splitscreen_camera/replay.txt new file mode 100644 index 0000000..b0c548e --- /dev/null +++ b/samples/07_advanced_rendering/08_splitscreen_camera/replay.txt @@ -0,0 +1,226 @@ +replay_version 2.0 +stopped_at 1047 +seed 100 +recorded_at Sat Jul 17 09:23:22 2021 +[:mouse_button_up, 1, 0, 1, 1, 5] +[:mouse_move, 795, 98, 2, 2, 75] +[:mouse_move, 797, 100, 2, 3, 77] +[:mouse_move, 799, 101, 2, 4, 78] +[:mouse_move, 800, 101, 2, 5, 78] +[:mouse_button_pressed, 1, 0, 1, 6, 88] +[:mouse_button_up, 1, 0, 1, 7, 92] +[:key_down_raw, 1073741903, 0, 2, 8, 124] +[:key_down_raw, 1073741903, 0, 2, 9, 138] +[:key_down_raw, 1073741903, 0, 2, 10, 141] +[:key_down_raw, 1073741903, 0, 2, 11, 142] +[:key_down_raw, 1073741903, 0, 2, 12, 144] +[:key_down_raw, 1073741903, 0, 2, 13, 147] +[:key_down_raw, 1073741903, 0, 2, 14, 148] +[:key_down_raw, 1073741903, 0, 2, 15, 151] +[:key_down_raw, 1073741906, 0, 2, 16, 151] +[:key_down_raw, 1073741906, 0, 2, 17, 166] +[:key_down_raw, 1073741906, 0, 2, 18, 169] +[:key_down_raw, 1073741906, 0, 2, 19, 170] +[:key_down_raw, 1073741906, 0, 2, 20, 172] +[:key_down_raw, 1073741906, 0, 2, 21, 174] +[:key_down_raw, 1073741906, 0, 2, 22, 177] +[:key_down_raw, 1073741906, 0, 2, 23, 178] +[:key_down_raw, 1073741906, 0, 2, 24, 180] +[:key_down_raw, 1073741906, 0, 2, 25, 182] +[:key_down_raw, 1073741906, 0, 2, 26, 184] +[:key_down_raw, 1073741906, 0, 2, 27, 186] +[:key_down_raw, 1073741906, 0, 2, 28, 188] +[:key_down_raw, 1073741906, 0, 2, 29, 190] +[:key_down_raw, 1073741906, 0, 2, 30, 193] +[:key_down_raw, 1073741906, 0, 2, 31, 194] +[:key_up_raw, 1073741906, 0, 2, 32, 195] +[:key_up_raw, 1073741903, 0, 2, 33, 291] +[:key_down_raw, 119, 0, 2, 34, 360] +[:key_down_raw, 119, 0, 2, 35, 375] +[:key_down_raw, 119, 0, 2, 36, 378] +[:key_down_raw, 119, 0, 2, 37, 379] +[:key_down_raw, 119, 0, 2, 38, 381] +[:key_down_raw, 119, 0, 2, 39, 383] +[:key_down_raw, 119, 0, 2, 40, 385] +[:key_down_raw, 119, 0, 2, 41, 387] +[:key_down_raw, 119, 0, 2, 42, 389] +[:key_down_raw, 119, 0, 2, 43, 391] +[:key_down_raw, 119, 0, 2, 44, 393] +[:key_down_raw, 119, 0, 2, 45, 395] +[:key_down_raw, 119, 0, 2, 46, 397] +[:key_down_raw, 119, 0, 2, 47, 401] +[:key_down_raw, 119, 0, 2, 48, 403] +[:key_down_raw, 119, 0, 2, 49, 405] +[:key_down_raw, 119, 0, 2, 50, 407] +[:key_down_raw, 119, 0, 2, 51, 409] +[:key_down_raw, 119, 0, 2, 52, 411] +[:key_down_raw, 119, 0, 2, 53, 412] +[:key_down_raw, 119, 0, 2, 54, 414] +[:key_down_raw, 119, 0, 2, 55, 416] +[:key_down_raw, 119, 0, 2, 56, 419] +[:key_down_raw, 119, 0, 2, 57, 421] +[:key_down_raw, 119, 0, 2, 58, 422] +[:key_down_raw, 119, 0, 2, 59, 424] +[:key_down_raw, 119, 0, 2, 60, 426] +[:key_down_raw, 119, 0, 2, 61, 429] +[:key_down_raw, 119, 0, 2, 62, 431] +[:key_down_raw, 119, 0, 2, 63, 432] +[:key_down_raw, 119, 0, 2, 64, 434] +[:key_down_raw, 119, 0, 2, 65, 436] +[:key_down_raw, 119, 0, 2, 66, 438] +[:key_down_raw, 119, 0, 2, 67, 441] +[:key_down_raw, 119, 0, 2, 68, 443] +[:key_down_raw, 119, 0, 2, 69, 444] +[:key_down_raw, 119, 0, 2, 70, 446] +[:key_down_raw, 119, 0, 2, 71, 449] +[:key_down_raw, 119, 0, 2, 72, 451] +[:key_down_raw, 119, 0, 2, 73, 453] +[:key_down_raw, 119, 0, 2, 74, 455] +[:key_down_raw, 119, 0, 2, 75, 457] +[:key_down_raw, 119, 0, 2, 76, 459] +[:key_down_raw, 119, 0, 2, 77, 460] +[:key_down_raw, 119, 0, 2, 78, 462] +[:key_down_raw, 119, 0, 2, 79, 464] +[:key_down_raw, 119, 0, 2, 80, 467] +[:key_down_raw, 119, 0, 2, 81, 468] +[:key_down_raw, 119, 0, 2, 82, 471] +[:key_down_raw, 119, 0, 2, 83, 473] +[:key_down_raw, 119, 0, 2, 84, 474] +[:key_down_raw, 119, 0, 2, 85, 476] +[:key_down_raw, 119, 0, 2, 86, 478] +[:key_down_raw, 119, 0, 2, 87, 481] +[:key_down_raw, 119, 0, 2, 88, 482] +[:key_down_raw, 119, 0, 2, 89, 484] +[:key_down_raw, 119, 0, 2, 90, 486] +[:key_down_raw, 119, 0, 2, 91, 489] +[:key_down_raw, 119, 0, 2, 92, 491] +[:key_down_raw, 119, 0, 2, 93, 493] +[:key_down_raw, 119, 0, 2, 94, 494] +[:key_down_raw, 119, 0, 2, 95, 496] +[:key_down_raw, 119, 0, 2, 96, 498] +[:key_down_raw, 119, 0, 2, 97, 501] +[:key_down_raw, 119, 0, 2, 98, 502] +[:key_down_raw, 119, 0, 2, 99, 505] +[:key_down_raw, 119, 0, 2, 100, 507] +[:key_down_raw, 119, 0, 2, 101, 509] +[:key_down_raw, 119, 0, 2, 102, 511] +[:key_down_raw, 119, 0, 2, 103, 512] +[:key_down_raw, 119, 0, 2, 104, 514] +[:key_down_raw, 119, 0, 2, 105, 516] +[:key_down_raw, 119, 0, 2, 106, 519] +[:key_down_raw, 119, 0, 2, 107, 521] +[:key_down_raw, 119, 0, 2, 108, 523] +[:key_down_raw, 119, 0, 2, 109, 524] +[:key_down_raw, 119, 0, 2, 110, 526] +[:key_down_raw, 119, 0, 2, 111, 529] +[:key_down_raw, 119, 0, 2, 112, 530] +[:key_down_raw, 119, 0, 2, 113, 533] +[:key_down_raw, 119, 0, 2, 114, 535] +[:key_down_raw, 119, 0, 2, 115, 536] +[:key_up_raw, 119, 0, 2, 116, 536] +[:key_down_raw, 100, 0, 2, 117, 548] +[:key_down_raw, 100, 0, 2, 118, 563] +[:key_down_raw, 100, 0, 2, 119, 565] +[:key_down_raw, 100, 0, 2, 120, 567] +[:key_down_raw, 100, 0, 2, 121, 569] +[:key_down_raw, 100, 0, 2, 122, 572] +[:key_down_raw, 100, 0, 2, 123, 573] +[:key_down_raw, 100, 0, 2, 124, 576] +[:key_down_raw, 100, 0, 2, 125, 577] +[:key_down_raw, 100, 0, 2, 126, 579] +[:key_down_raw, 100, 0, 2, 127, 582] +[:key_down_raw, 100, 0, 2, 128, 584] +[:key_down_raw, 100, 0, 2, 129, 585] +[:key_down_raw, 100, 0, 2, 130, 588] +[:key_down_raw, 100, 0, 2, 131, 589] +[:key_down_raw, 100, 0, 2, 132, 591] +[:key_down_raw, 100, 0, 2, 133, 593] +[:key_down_raw, 100, 0, 2, 134, 595] +[:key_down_raw, 100, 0, 2, 135, 597] +[:key_down_raw, 100, 0, 2, 136, 599] +[:key_down_raw, 100, 0, 2, 137, 601] +[:key_down_raw, 100, 0, 2, 138, 603] +[:key_down_raw, 100, 0, 2, 139, 605] +[:key_down_raw, 100, 0, 2, 140, 607] +[:key_up_raw, 100, 0, 2, 141, 608] +[:key_down_raw, 100, 0, 2, 142, 646] +[:key_up_raw, 100, 0, 2, 143, 654] +[:key_down_raw, 1073741906, 0, 2, 144, 696] +[:key_down_raw, 1073741906, 0, 2, 145, 711] +[:key_down_raw, 1073741906, 0, 2, 146, 713] +[:key_down_raw, 1073741906, 0, 2, 147, 715] +[:key_down_raw, 1073741906, 0, 2, 148, 717] +[:key_down_raw, 1073741906, 0, 2, 149, 719] +[:key_down_raw, 1073741906, 0, 2, 150, 721] +[:key_down_raw, 1073741906, 0, 2, 151, 723] +[:key_down_raw, 1073741906, 0, 2, 152, 725] +[:key_down_raw, 1073741906, 0, 2, 153, 727] +[:key_down_raw, 1073741906, 0, 2, 154, 729] +[:key_down_raw, 1073741906, 0, 2, 155, 731] +[:key_down_raw, 1073741906, 0, 2, 156, 733] +[:key_down_raw, 1073741906, 0, 2, 157, 735] +[:key_down_raw, 1073741906, 0, 2, 158, 737] +[:key_down_raw, 1073741906, 0, 2, 159, 739] +[:key_down_raw, 1073741906, 0, 2, 160, 741] +[:key_down_raw, 1073741906, 0, 2, 161, 743] +[:key_down_raw, 1073741906, 0, 2, 162, 745] +[:key_down_raw, 1073741906, 0, 2, 163, 747] +[:key_down_raw, 1073741906, 0, 2, 164, 749] +[:key_down_raw, 1073741906, 0, 2, 165, 751] +[:key_down_raw, 1073741906, 0, 2, 166, 753] +[:key_down_raw, 1073741906, 0, 2, 167, 755] +[:key_down_raw, 1073741906, 0, 2, 168, 757] +[:key_down_raw, 1073741906, 0, 2, 169, 759] +[:key_down_raw, 1073741906, 0, 2, 170, 761] +[:key_down_raw, 1073741906, 0, 2, 171, 763] +[:key_down_raw, 1073741906, 0, 2, 172, 765] +[:key_down_raw, 1073741906, 0, 2, 173, 767] +[:key_down_raw, 1073741906, 0, 2, 174, 769] +[:key_down_raw, 1073741906, 0, 2, 175, 771] +[:key_down_raw, 1073741906, 0, 2, 176, 773] +[:key_down_raw, 1073741906, 0, 2, 177, 775] +[:key_down_raw, 1073741906, 0, 2, 178, 777] +[:key_down_raw, 1073741906, 0, 2, 179, 779] +[:key_down_raw, 1073741906, 0, 2, 180, 781] +[:key_down_raw, 1073741906, 0, 2, 181, 783] +[:key_down_raw, 1073741904, 0, 2, 182, 784] +[:key_down_raw, 1073741904, 0, 2, 183, 798] +[:key_down_raw, 1073741904, 0, 2, 184, 800] +[:key_down_raw, 1073741904, 0, 2, 185, 802] +[:key_down_raw, 1073741904, 0, 2, 186, 804] +[:key_down_raw, 1073741904, 0, 2, 187, 806] +[:key_down_raw, 1073741904, 0, 2, 188, 810] +[:key_down_raw, 1073741904, 0, 2, 189, 810] +[:key_down_raw, 1073741904, 0, 2, 190, 814] +[:key_down_raw, 1073741904, 0, 2, 191, 815] +[:key_down_raw, 1073741904, 0, 2, 192, 818] +[:key_down_raw, 1073741904, 0, 2, 193, 819] +[:key_down_raw, 1073741904, 0, 2, 194, 822] +[:key_down_raw, 1073741904, 0, 2, 195, 824] +[:key_up_raw, 1073741906, 0, 2, 196, 824] +[:key_down_raw, 1073741904, 0, 2, 197, 825] +[:key_down_raw, 1073741904, 0, 2, 198, 828] +[:key_up_raw, 1073741904, 0, 2, 199, 828] +[:key_down_raw, 96, 0, 2, 200, 870] +[:key_up_raw, 96, 0, 2, 201, 875] +[:mouse_move, 802, 100, 2, 202, 933] +[:mouse_move, 803, 100, 2, 203, 934] +[:mouse_move, 806, 99, 2, 204, 935] +[:mouse_move, 808, 98, 2, 205, 936] +[:mouse_move, 813, 96, 2, 206, 937] +[:mouse_move, 816, 95, 2, 207, 938] +[:mouse_move, 824, 93, 2, 208, 939] +[:mouse_move, 827, 92, 2, 209, 940] +[:mouse_move, 837, 90, 2, 210, 941] +[:mouse_move, 843, 90, 2, 211, 942] +[:mouse_move, 857, 89, 2, 212, 943] +[:mouse_move, 864, 89, 2, 213, 944] +[:mouse_move, 874, 88, 2, 214, 945] +[:mouse_move, 876, 88, 2, 215, 946] +[:mouse_move, 878, 88, 2, 216, 947] +[:mouse_move, 881, 87, 2, 217, 948] +[:mouse_move, 882, 87, 2, 218, 950] +[:mouse_move, 884, 87, 2, 219, 950] +[:mouse_move, 885, 87, 2, 220, 951] +[:mouse_move, 887, 87, 2, 221, 952] +[:key_down_raw, 13, 0, 2, 222, 1047] diff --git a/samples/07_advanced_rendering/08_splitscreen_camera/sprites/player/player_down_standing.png b/samples/07_advanced_rendering/08_splitscreen_camera/sprites/player/player_down_standing.png new file mode 100644 index 0000000..9e27489 Binary files /dev/null and b/samples/07_advanced_rendering/08_splitscreen_camera/sprites/player/player_down_standing.png differ diff --git a/samples/07_advanced_rendering/08_splitscreen_camera/sprites/player/player_left_standing.png b/samples/07_advanced_rendering/08_splitscreen_camera/sprites/player/player_left_standing.png new file mode 100644 index 0000000..2fea35b Binary files /dev/null and b/samples/07_advanced_rendering/08_splitscreen_camera/sprites/player/player_left_standing.png differ diff --git a/samples/07_advanced_rendering/08_splitscreen_camera/sprites/player/player_right_standing.png b/samples/07_advanced_rendering/08_splitscreen_camera/sprites/player/player_right_standing.png new file mode 100644 index 0000000..6f3402e Binary files /dev/null and b/samples/07_advanced_rendering/08_splitscreen_camera/sprites/player/player_right_standing.png differ diff --git a/samples/07_advanced_rendering/08_splitscreen_camera/sprites/player/player_up_standing.png b/samples/07_advanced_rendering/08_splitscreen_camera/sprites/player/player_up_standing.png new file mode 100644 index 0000000..9ebdca7 Binary files /dev/null and b/samples/07_advanced_rendering/08_splitscreen_camera/sprites/player/player_up_standing.png differ diff --git a/samples/07_advanced_rendering/08_splitscreen_camera/sprites/rooms/camera_room.png b/samples/07_advanced_rendering/08_splitscreen_camera/sprites/rooms/camera_room.png new file mode 100644 index 0000000..e0ca375 Binary files /dev/null and b/samples/07_advanced_rendering/08_splitscreen_camera/sprites/rooms/camera_room.png differ diff --git a/samples/07_advanced_rendering/08_z_targeting_camera/app/main.rb b/samples/07_advanced_rendering/08_z_targeting_camera/app/main.rb deleted file mode 100644 index ecdbfd3..0000000 --- a/samples/07_advanced_rendering/08_z_targeting_camera/app/main.rb +++ /dev/null @@ -1,106 +0,0 @@ -class Game - attr_gtk - - def tick - defaults - render - input - calc - end - - def defaults - outputs.background_color = [219, 208, 191] - player.x ||= 634 - player.y ||= 153 - player.angle ||= 90 - player.distance ||= arena_radius - target.x ||= 634 - target.y ||= 359 - end - - def render - outputs[:scene].sprites << ([0, 0, 933, 700, 'sprites/arena.png'].center_inside_rect grid.rect) - outputs[:scene].sprites << target_sprite - outputs[:scene].sprites << player_sprite - outputs.sprites << scene - end - - def target_sprite - { - x: target.x, y: target.y, - w: 10, h: 10, - path: 'sprites/square/black.png' - }.anchor_rect 0.5, 0.5 - end - - def input - if inputs.up && player.distance > 30 - player.distance -= 2 - elsif inputs.down && player.distance < 200 - player.distance += 2 - end - - player.angle += inputs.left_right * -1 - end - - def calc - player.x = target.x + ((player.angle * 1).vector_x player.distance) - player.y = target.y + ((player.angle * -1).vector_y player.distance) - end - - def player_sprite - { - x: player.x, - y: player.y, - w: 50, - h: 100, - path: 'sprites/player.png', - angle: (player.angle * -1) + 90 - }.anchor_rect 0.5, 0 - end - - def center_map - { x: 634, y: 359 } - end - - def zoom_factor_single - 2 - ((args.geometry.distance player, center_map).fdiv arena_radius) - end - - def zoom_factor - zoom_factor_single ** 2 - end - - def arena_radius - 206 - end - - def scene - { - x: (640 - player.x) + (640 - (640 * zoom_factor)), - y: (360 - player.y - (75 * zoom_factor)) + (320 - (320 * zoom_factor)), - w: 1280 * zoom_factor, - h: 720 * zoom_factor, - path: :scene, - angle: player.angle - 90, - angle_anchor_x: (player.x.fdiv 1280), - angle_anchor_y: (player.y.fdiv 720) - } - end - - def player - state.player - end - - def target - state.target - end -end - -def tick args - $game ||= Game.new - $game.args = args - $game.tick -end - -$gtk.reset diff --git a/samples/07_advanced_rendering/08_z_targeting_camera/metadata/game_metadata.txt b/samples/07_advanced_rendering/08_z_targeting_camera/metadata/game_metadata.txt deleted file mode 100644 index 3ad3a1a..0000000 --- a/samples/07_advanced_rendering/08_z_targeting_camera/metadata/game_metadata.txt +++ /dev/null @@ -1,6 +0,0 @@ -devid=dragonruby -devtitle=DragonRuby LLC -gameid=httpserverexample -gametitle=DragonRuby GTK HTTP Server Example -version=0.1 -icon=metadata/icon.png diff --git a/samples/07_advanced_rendering/08_z_targeting_camera/metadata/icon.png b/samples/07_advanced_rendering/08_z_targeting_camera/metadata/icon.png deleted file mode 100644 index 57254fe..0000000 Binary files a/samples/07_advanced_rendering/08_z_targeting_camera/metadata/icon.png and /dev/null differ diff --git a/samples/07_advanced_rendering/08_z_targeting_camera/sprites/arena.png b/samples/07_advanced_rendering/08_z_targeting_camera/sprites/arena.png deleted file mode 100644 index 5c92e91..0000000 Binary files a/samples/07_advanced_rendering/08_z_targeting_camera/sprites/arena.png and /dev/null differ diff --git a/samples/07_advanced_rendering/08_z_targeting_camera/sprites/player.png b/samples/07_advanced_rendering/08_z_targeting_camera/sprites/player.png deleted file mode 100644 index 332a80b..0000000 Binary files a/samples/07_advanced_rendering/08_z_targeting_camera/sprites/player.png and /dev/null differ diff --git a/samples/07_advanced_rendering/08_z_targeting_camera/sprites/square/black.png b/samples/07_advanced_rendering/08_z_targeting_camera/sprites/square/black.png deleted file mode 100644 index cea7bd7..0000000 Binary files a/samples/07_advanced_rendering/08_z_targeting_camera/sprites/square/black.png and /dev/null differ diff --git a/samples/07_advanced_rendering/09_z_targeting_camera/app/main.rb b/samples/07_advanced_rendering/09_z_targeting_camera/app/main.rb new file mode 100644 index 0000000..ecdbfd3 --- /dev/null +++ b/samples/07_advanced_rendering/09_z_targeting_camera/app/main.rb @@ -0,0 +1,106 @@ +class Game + attr_gtk + + def tick + defaults + render + input + calc + end + + def defaults + outputs.background_color = [219, 208, 191] + player.x ||= 634 + player.y ||= 153 + player.angle ||= 90 + player.distance ||= arena_radius + target.x ||= 634 + target.y ||= 359 + end + + def render + outputs[:scene].sprites << ([0, 0, 933, 700, 'sprites/arena.png'].center_inside_rect grid.rect) + outputs[:scene].sprites << target_sprite + outputs[:scene].sprites << player_sprite + outputs.sprites << scene + end + + def target_sprite + { + x: target.x, y: target.y, + w: 10, h: 10, + path: 'sprites/square/black.png' + }.anchor_rect 0.5, 0.5 + end + + def input + if inputs.up && player.distance > 30 + player.distance -= 2 + elsif inputs.down && player.distance < 200 + player.distance += 2 + end + + player.angle += inputs.left_right * -1 + end + + def calc + player.x = target.x + ((player.angle * 1).vector_x player.distance) + player.y = target.y + ((player.angle * -1).vector_y player.distance) + end + + def player_sprite + { + x: player.x, + y: player.y, + w: 50, + h: 100, + path: 'sprites/player.png', + angle: (player.angle * -1) + 90 + }.anchor_rect 0.5, 0 + end + + def center_map + { x: 634, y: 359 } + end + + def zoom_factor_single + 2 - ((args.geometry.distance player, center_map).fdiv arena_radius) + end + + def zoom_factor + zoom_factor_single ** 2 + end + + def arena_radius + 206 + end + + def scene + { + x: (640 - player.x) + (640 - (640 * zoom_factor)), + y: (360 - player.y - (75 * zoom_factor)) + (320 - (320 * zoom_factor)), + w: 1280 * zoom_factor, + h: 720 * zoom_factor, + path: :scene, + angle: player.angle - 90, + angle_anchor_x: (player.x.fdiv 1280), + angle_anchor_y: (player.y.fdiv 720) + } + end + + def player + state.player + end + + def target + state.target + end +end + +def tick args + $game ||= Game.new + $game.args = args + $game.tick +end + +$gtk.reset diff --git a/samples/07_advanced_rendering/09_z_targeting_camera/metadata/game_metadata.txt b/samples/07_advanced_rendering/09_z_targeting_camera/metadata/game_metadata.txt new file mode 100644 index 0000000..3ad3a1a --- /dev/null +++ b/samples/07_advanced_rendering/09_z_targeting_camera/metadata/game_metadata.txt @@ -0,0 +1,6 @@ +devid=dragonruby +devtitle=DragonRuby LLC +gameid=httpserverexample +gametitle=DragonRuby GTK HTTP Server Example +version=0.1 +icon=metadata/icon.png diff --git a/samples/07_advanced_rendering/09_z_targeting_camera/metadata/icon.png b/samples/07_advanced_rendering/09_z_targeting_camera/metadata/icon.png new file mode 100644 index 0000000..57254fe Binary files /dev/null and b/samples/07_advanced_rendering/09_z_targeting_camera/metadata/icon.png differ diff --git a/samples/07_advanced_rendering/09_z_targeting_camera/replay.txt b/samples/07_advanced_rendering/09_z_targeting_camera/replay.txt new file mode 100644 index 0000000..db9130a --- /dev/null +++ b/samples/07_advanced_rendering/09_z_targeting_camera/replay.txt @@ -0,0 +1,185 @@ +replay_version 2.0 +stopped_at 741 +seed 100 +recorded_at Sat Jul 17 09:24:36 2021 +[:mouse_button_up, 1, 0, 1, 1, 4] +[:key_down_raw, 1073741906, 0, 2, 2, 104] +[:key_down_raw, 1073741906, 0, 2, 3, 118] +[:key_down_raw, 1073741906, 0, 2, 4, 120] +[:key_down_raw, 1073741906, 0, 2, 5, 122] +[:key_down_raw, 1073741906, 0, 2, 6, 124] +[:key_down_raw, 1073741906, 0, 2, 7, 126] +[:key_down_raw, 1073741906, 0, 2, 8, 128] +[:key_down_raw, 1073741906, 0, 2, 9, 130] +[:key_down_raw, 1073741906, 0, 2, 10, 132] +[:key_down_raw, 1073741906, 0, 2, 11, 134] +[:key_down_raw, 1073741906, 0, 2, 12, 136] +[:key_down_raw, 1073741906, 0, 2, 13, 138] +[:key_down_raw, 1073741906, 0, 2, 14, 140] +[:key_down_raw, 1073741906, 0, 2, 15, 142] +[:key_down_raw, 1073741906, 0, 2, 16, 144] +[:key_down_raw, 1073741906, 0, 2, 17, 146] +[:key_down_raw, 1073741906, 0, 2, 18, 148] +[:key_down_raw, 1073741906, 0, 2, 19, 150] +[:key_down_raw, 1073741906, 0, 2, 20, 152] +[:key_down_raw, 1073741906, 0, 2, 21, 154] +[:key_up_raw, 1073741906, 0, 2, 22, 156] +[:key_down_raw, 1073741904, 0, 2, 23, 165] +[:key_down_raw, 1073741904, 0, 2, 24, 180] +[:key_down_raw, 1073741904, 0, 2, 25, 182] +[:key_down_raw, 1073741904, 0, 2, 26, 184] +[:key_down_raw, 1073741904, 0, 2, 27, 186] +[:key_down_raw, 1073741904, 0, 2, 28, 188] +[:key_down_raw, 1073741904, 0, 2, 29, 190] +[:key_down_raw, 1073741904, 0, 2, 30, 192] +[:key_down_raw, 1073741904, 0, 2, 31, 194] +[:key_down_raw, 1073741904, 0, 2, 32, 196] +[:key_down_raw, 1073741904, 0, 2, 33, 198] +[:key_down_raw, 1073741904, 0, 2, 34, 200] +[:key_down_raw, 1073741904, 0, 2, 35, 202] +[:key_down_raw, 1073741904, 0, 2, 36, 204] +[:key_down_raw, 1073741904, 0, 2, 37, 206] +[:key_down_raw, 1073741904, 0, 2, 38, 208] +[:key_down_raw, 1073741904, 0, 2, 39, 210] +[:key_down_raw, 1073741904, 0, 2, 40, 212] +[:key_down_raw, 1073741904, 0, 2, 41, 214] +[:key_down_raw, 1073741904, 0, 2, 42, 216] +[:key_down_raw, 1073741904, 0, 2, 43, 218] +[:key_down_raw, 1073741904, 0, 2, 44, 220] +[:key_down_raw, 1073741904, 0, 2, 45, 222] +[:key_down_raw, 1073741904, 0, 2, 46, 224] +[:key_down_raw, 1073741904, 0, 2, 47, 226] +[:key_down_raw, 1073741904, 0, 2, 48, 228] +[:key_down_raw, 1073741904, 0, 2, 49, 230] +[:key_down_raw, 1073741904, 0, 2, 50, 232] +[:key_down_raw, 1073741904, 0, 2, 51, 234] +[:key_down_raw, 1073741904, 0, 2, 52, 236] +[:key_down_raw, 1073741904, 0, 2, 53, 238] +[:key_down_raw, 1073741904, 0, 2, 54, 240] +[:key_down_raw, 1073741904, 0, 2, 55, 242] +[:key_down_raw, 1073741904, 0, 2, 56, 244] +[:key_down_raw, 1073741904, 0, 2, 57, 246] +[:key_down_raw, 1073741904, 0, 2, 58, 248] +[:key_down_raw, 1073741904, 0, 2, 59, 250] +[:key_down_raw, 1073741904, 0, 2, 60, 252] +[:key_down_raw, 1073741904, 0, 2, 61, 254] +[:key_down_raw, 1073741906, 0, 2, 62, 256] +[:key_down_raw, 1073741906, 0, 2, 63, 271] +[:key_down_raw, 1073741906, 0, 2, 64, 273] +[:key_down_raw, 1073741906, 0, 2, 65, 275] +[:key_down_raw, 1073741906, 0, 2, 66, 277] +[:key_down_raw, 1073741906, 0, 2, 67, 279] +[:key_down_raw, 1073741906, 0, 2, 68, 281] +[:key_down_raw, 1073741906, 0, 2, 69, 283] +[:key_down_raw, 1073741906, 0, 2, 70, 285] +[:key_down_raw, 1073741906, 0, 2, 71, 287] +[:key_down_raw, 1073741906, 0, 2, 72, 289] +[:key_down_raw, 1073741906, 0, 2, 73, 291] +[:key_down_raw, 1073741906, 0, 2, 74, 293] +[:key_down_raw, 1073741906, 0, 2, 75, 295] +[:key_down_raw, 1073741906, 0, 2, 76, 297] +[:key_down_raw, 1073741906, 0, 2, 77, 299] +[:key_down_raw, 1073741906, 0, 2, 78, 301] +[:key_down_raw, 1073741906, 0, 2, 79, 303] +[:key_down_raw, 1073741906, 0, 2, 80, 305] +[:key_down_raw, 1073741906, 0, 2, 81, 307] +[:key_down_raw, 1073741906, 0, 2, 82, 309] +[:key_down_raw, 1073741906, 0, 2, 83, 311] +[:key_down_raw, 1073741906, 0, 2, 84, 313] +[:key_up_raw, 1073741906, 0, 2, 85, 314] +[:key_up_raw, 1073741904, 0, 2, 86, 316] +[:key_down_raw, 1073741903, 0, 2, 87, 338] +[:key_down_raw, 1073741903, 0, 2, 88, 353] +[:key_down_raw, 1073741903, 0, 2, 89, 355] +[:key_down_raw, 1073741903, 0, 2, 90, 357] +[:key_down_raw, 1073741903, 0, 2, 91, 359] +[:key_down_raw, 1073741903, 0, 2, 92, 361] +[:key_down_raw, 1073741903, 0, 2, 93, 363] +[:key_down_raw, 1073741903, 0, 2, 94, 365] +[:key_down_raw, 1073741903, 0, 2, 95, 367] +[:key_down_raw, 1073741903, 0, 2, 96, 369] +[:key_down_raw, 1073741903, 0, 2, 97, 371] +[:key_down_raw, 1073741903, 0, 2, 98, 373] +[:key_down_raw, 1073741903, 0, 2, 99, 375] +[:key_down_raw, 1073741903, 0, 2, 100, 377] +[:key_down_raw, 1073741903, 0, 2, 101, 379] +[:key_down_raw, 1073741903, 0, 2, 102, 381] +[:key_down_raw, 1073741905, 0, 2, 103, 382] +[:key_down_raw, 1073741905, 0, 2, 104, 397] +[:key_down_raw, 1073741905, 0, 2, 105, 399] +[:key_down_raw, 1073741905, 0, 2, 106, 401] +[:key_down_raw, 1073741905, 0, 2, 107, 403] +[:key_down_raw, 1073741905, 0, 2, 108, 405] +[:key_down_raw, 1073741905, 0, 2, 109, 407] +[:key_down_raw, 1073741905, 0, 2, 110, 409] +[:key_down_raw, 1073741905, 0, 2, 111, 411] +[:key_down_raw, 1073741905, 0, 2, 112, 413] +[:key_down_raw, 1073741905, 0, 2, 113, 415] +[:key_down_raw, 1073741905, 0, 2, 114, 417] +[:key_down_raw, 1073741905, 0, 2, 115, 419] +[:key_down_raw, 1073741905, 0, 2, 116, 421] +[:key_down_raw, 1073741905, 0, 2, 117, 423] +[:key_down_raw, 1073741905, 0, 2, 118, 425] +[:key_down_raw, 1073741905, 0, 2, 119, 427] +[:key_down_raw, 1073741905, 0, 2, 120, 429] +[:key_down_raw, 1073741905, 0, 2, 121, 431] +[:key_down_raw, 1073741905, 0, 2, 122, 433] +[:key_up_raw, 1073741905, 0, 2, 123, 435] +[:key_down_raw, 1073741905, 0, 2, 124, 447] +[:key_up_raw, 1073741905, 0, 2, 125, 460] +[:key_down_raw, 1073741905, 0, 2, 126, 485] +[:key_down_raw, 1073741905, 0, 2, 127, 500] +[:key_down_raw, 1073741905, 0, 2, 128, 502] +[:key_down_raw, 1073741905, 0, 2, 129, 504] +[:key_down_raw, 1073741905, 0, 2, 130, 506] +[:key_up_raw, 1073741905, 0, 2, 131, 507] +[:key_up_raw, 1073741903, 0, 2, 132, 548] +[:key_down_raw, 1073741905, 0, 2, 133, 561] +[:key_down_raw, 1073741905, 0, 2, 134, 576] +[:key_down_raw, 1073741905, 0, 2, 135, 578] +[:key_down_raw, 1073741905, 0, 2, 136, 580] +[:key_down_raw, 1073741905, 0, 2, 137, 582] +[:key_up_raw, 1073741905, 0, 2, 138, 584] +[:key_down_raw, 96, 0, 2, 139, 648] +[:key_up_raw, 96, 0, 2, 140, 653] +[:mouse_move, 815, 98, 2, 141, 654] +[:mouse_move, 816, 101, 2, 142, 655] +[:mouse_move, 816, 104, 2, 143, 656] +[:mouse_move, 816, 112, 2, 144, 657] +[:mouse_move, 816, 117, 2, 145, 658] +[:mouse_move, 810, 130, 2, 146, 659] +[:mouse_move, 803, 137, 2, 147, 660] +[:mouse_move, 782, 157, 2, 148, 661] +[:mouse_move, 767, 168, 2, 149, 662] +[:mouse_move, 734, 188, 2, 150, 663] +[:mouse_move, 716, 197, 2, 151, 664] +[:mouse_move, 682, 215, 2, 152, 665] +[:mouse_move, 665, 223, 2, 153, 666] +[:mouse_move, 645, 234, 2, 154, 667] +[:mouse_move, 643, 235, 2, 155, 668] +[:mouse_move, 643, 236, 2, 156, 669] +[:mouse_move, 647, 237, 2, 157, 672] +[:mouse_move, 670, 244, 2, 158, 673] +[:mouse_move, 687, 245, 2, 159, 674] +[:mouse_move, 720, 242, 2, 160, 675] +[:mouse_move, 737, 237, 2, 161, 676] +[:mouse_move, 764, 224, 2, 162, 677] +[:mouse_move, 777, 216, 2, 163, 678] +[:mouse_move, 796, 197, 2, 164, 679] +[:mouse_move, 804, 187, 2, 165, 680] +[:mouse_move, 815, 164, 2, 166, 681] +[:mouse_move, 820, 152, 2, 167, 682] +[:mouse_move, 825, 142, 2, 168, 683] +[:mouse_move, 831, 128, 2, 169, 684] +[:mouse_move, 832, 126, 2, 170, 685] +[:mouse_move, 832, 125, 2, 171, 686] +[:mouse_move, 833, 123, 2, 172, 688] +[:mouse_move, 836, 120, 2, 173, 690] +[:mouse_move, 837, 118, 2, 174, 691] +[:mouse_move, 842, 113, 2, 175, 692] +[:mouse_move, 844, 112, 2, 176, 693] +[:mouse_move, 844, 111, 2, 177, 694] +[:mouse_move, 844, 110, 2, 178, 696] +[:mouse_move, 845, 110, 2, 179, 697] +[:mouse_move, 845, 109, 2, 180, 699] +[:key_down_raw, 13, 0, 2, 181, 741] diff --git a/samples/07_advanced_rendering/09_z_targeting_camera/sprites/arena.png b/samples/07_advanced_rendering/09_z_targeting_camera/sprites/arena.png new file mode 100644 index 0000000..5c92e91 Binary files /dev/null and b/samples/07_advanced_rendering/09_z_targeting_camera/sprites/arena.png differ diff --git a/samples/07_advanced_rendering/09_z_targeting_camera/sprites/player.png b/samples/07_advanced_rendering/09_z_targeting_camera/sprites/player.png new file mode 100644 index 0000000..332a80b Binary files /dev/null and b/samples/07_advanced_rendering/09_z_targeting_camera/sprites/player.png differ diff --git a/samples/07_advanced_rendering/09_z_targeting_camera/sprites/square/black.png b/samples/07_advanced_rendering/09_z_targeting_camera/sprites/square/black.png new file mode 100644 index 0000000..cea7bd7 Binary files /dev/null and b/samples/07_advanced_rendering/09_z_targeting_camera/sprites/square/black.png differ diff --git a/samples/07_advanced_rendering/10_blend_modes/app/main.rb b/samples/07_advanced_rendering/10_blend_modes/app/main.rb new file mode 100644 index 0000000..7e28ba8 --- /dev/null +++ b/samples/07_advanced_rendering/10_blend_modes/app/main.rb @@ -0,0 +1,49 @@ +$gtk.reset + +def draw_blendmode args, mode + w = 160 + h = w + args.state.x += (1280-w) / (args.state.blendmodes.length + 1) + x = args.state.x + y = (720 - h) / 2 + s = 'sprites/blue-feathered.png' + args.outputs.sprites << { blendmode_enum: mode.value, x: x, y: y, w: w, h: h, path: s } + args.outputs.labels << [x + (w/2), y, mode.name.to_s, 1, 1, 255, 255, 255] +end + +def tick args + + # Different blend modes do different things, depending on what they + # blend against (in this case, the pixels of the background color). + args.state.bg_element ||= 1 + args.state.bg_color ||= 255 + args.state.bg_color_direction ||= 1 + bg_r = (args.state.bg_element == 1) ? args.state.bg_color : 0 + bg_g = (args.state.bg_element == 2) ? args.state.bg_color : 0 + bg_b = (args.state.bg_element == 3) ? args.state.bg_color : 0 + args.state.bg_color += args.state.bg_color_direction + if (args.state.bg_color_direction > 0) && (args.state.bg_color >= 255) + args.state.bg_color_direction = -1 + args.state.bg_color = 255 + elsif (args.state.bg_color_direction < 0) && (args.state.bg_color <= 0) + args.state.bg_color_direction = 1 + args.state.bg_color = 0 + args.state.bg_element += 1 + if args.state.bg_element >= 4 + args.state.bg_element = 1 + end + end + + args.outputs.background_color = [ bg_r, bg_g, bg_b, 255 ] + + args.state.blendmodes ||= [ + { name: :none, value: 0 }, + { name: :blend, value: 1 }, + { name: :add, value: 2 }, + { name: :mod, value: 3 }, + { name: :mul, value: 4 } + ] + + args.state.x = 0 # reset this, draw_blendmode will increment it. + args.state.blendmodes.each { |blendmode| draw_blendmode args, blendmode } +end diff --git a/samples/07_advanced_rendering/10_blend_modes/sprites/blue-feathered.png b/samples/07_advanced_rendering/10_blend_modes/sprites/blue-feathered.png new file mode 100644 index 0000000..a8bf6b5 Binary files /dev/null and b/samples/07_advanced_rendering/10_blend_modes/sprites/blue-feathered.png differ diff --git a/samples/09_performance/01_sprites_as_hash/app/main.rb b/samples/09_performance/01_sprites_as_hash/app/main.rb index 6bbb295..d032900 100644 --- a/samples/09_performance/01_sprites_as_hash/app/main.rb +++ b/samples/09_performance/01_sprites_as_hash/app/main.rb @@ -39,7 +39,11 @@ def tick args # sets console command when sample app initially opens if Kernel.global_tick_count == 0 - puts "* INFO - Please specify the number of sprites to render." + puts "" + puts "" + puts "=========================================================" + puts "* INFO: Sprites, Hashes" + puts "* INFO: Please specify the number of sprites to render." args.gtk.console.set_command "reset_with count: 100" end diff --git a/samples/09_performance/02_sprites_as_entities/app/main.rb b/samples/09_performance/02_sprites_as_entities/app/main.rb index 203dbe0..dba02ae 100644 --- a/samples/09_performance/02_sprites_as_entities/app/main.rb +++ b/samples/09_performance/02_sprites_as_entities/app/main.rb @@ -1,5 +1,5 @@ # Sprites represented as Entities using the queue ~args.outputs.sprites~ -# yields nicer access apis over Hashes, but requires a bit more code upfront. +# yields nicer access apis over Hashes, but require a bit more code upfront. # The hash sample has to use star[:s] to get the speed of the star, but # an entity can use .s instead. def random_x args @@ -39,7 +39,11 @@ def tick args # sets console command when sample app initially opens if Kernel.global_tick_count == 0 - puts "* INFO - Please specify the number of sprites to render." + puts "" + puts "" + puts "=========================================================" + puts "* INFO: Sprites, Open Entities" + puts "* INFO: Please specify the number of sprites to render." args.gtk.console.set_command "reset_with count: 100" end diff --git a/samples/09_performance/03_sprites_as_strict_entities/app/main.rb b/samples/09_performance/03_sprites_as_strict_entities/app/main.rb index 376d9a1..a2688c2 100644 --- a/samples/09_performance/03_sprites_as_strict_entities/app/main.rb +++ b/samples/09_performance/03_sprites_as_strict_entities/app/main.rb @@ -43,7 +43,11 @@ def tick args # sets console command when sample app initially opens if Kernel.global_tick_count == 0 - puts "* INFO - Please specify the number of sprites to render." + puts "" + puts "" + puts "=========================================================" + puts "* INFO: Sprites, Strict Entities" + puts "* INFO: Please specify the number of sprites to render." args.gtk.console.set_command "reset_with count: 100" end diff --git a/samples/09_performance/04_sprites_as_classes/app/main.rb b/samples/09_performance/04_sprites_as_classes/app/main.rb index d69dc66..67cde79 100644 --- a/samples/09_performance/04_sprites_as_classes/app/main.rb +++ b/samples/09_performance/04_sprites_as_classes/app/main.rb @@ -22,10 +22,15 @@ class Star end end -# calls methods needed for the game to run properly +# calls methods needed for game to run properly def tick args # sets console command when sample app initially opens if Kernel.global_tick_count == 0 + puts "" + puts "" + puts "=========================================================" + puts "* INFO: Sprites, Classes" + puts "* INFO: Please specify the number of sprites to render." args.gtk.console.set_command "reset_with count: 100" end diff --git a/samples/09_performance/05_static_sprites_as_classes/app/main.rb b/samples/09_performance/05_static_sprites_as_classes/app/main.rb index f87b110..db5bf8e 100644 --- a/samples/09_performance/05_static_sprites_as_classes/app/main.rb +++ b/samples/09_performance/05_static_sprites_as_classes/app/main.rb @@ -23,23 +23,28 @@ class Star end end -# calls methods needed for the game to run properly +# calls methods needed for game to run properly def tick args # sets console command when sample app initially opens if Kernel.global_tick_count == 0 + puts "" + puts "" + puts "=========================================================" + puts "* INFO: Static Sprites, Classes" + puts "* INFO: Please specify the number of sprites to render." args.gtk.console.set_command "reset_with count: 100" end # init if args.state.tick_count == 0 args.state.stars = args.state.star_count.map { |i| Star.new args.grid } + args.outputs.static_sprites << args.state.stars end # update args.state.stars.each(&:move) # render - args.outputs.sprites << args.state.stars args.outputs.background_color = [0, 0, 0] args.outputs.primitives << args.gtk.current_framerate_primitives end diff --git a/samples/09_performance/06_static_sprites_as_classes_with_custom_drawing/app/main.rb b/samples/09_performance/06_static_sprites_as_classes_with_custom_drawing/app/main.rb index 31f5c9f..3291f5e 100644 --- a/samples/09_performance/06_static_sprites_as_classes_with_custom_drawing/app/main.rb +++ b/samples/09_performance/06_static_sprites_as_classes_with_custom_drawing/app/main.rb @@ -39,18 +39,34 @@ class Star # x, y, w, h, # path, # angle, - # alpha, red_saturation, green_saturation, blue_saturation, + # alpha, red_saturation, green_saturation, blue_saturation # tile_x, tile_y, tile_w, tile_h, # flip_horizontally, flip_vertically, # angle_anchor_x, angle_anchor_y, # source_x, source_y, source_w, source_h + + # The argument order for ffi_draw.draw_sprite_4 is: + # x, y, w, h, + # path, + # angle, + # alpha, red_saturation, green_saturation, blue_saturation + # tile_x, tile_y, tile_w, tile_h, + # flip_horizontally, flip_vertically, + # angle_anchor_x, angle_anchor_y, + # source_x, source_y, source_w, source_h, + # blendmode_enum end end -# calls methods needed for the game to run properly +# calls methods needed for game to run properly def tick args # sets console command when sample app initially opens if Kernel.global_tick_count == 0 + puts "" + puts "" + puts "=========================================================" + puts "* INFO: Static Sprites, Classes, Draw Override" + puts "* INFO: Please specify the number of sprites to render." args.gtk.console.set_command "reset_with count: 100" end diff --git a/samples/09_performance/07_collision_limits/app/main.rb b/samples/09_performance/07_collision_limits/app/main.rb index 4a7945c..01ad308 100644 --- a/samples/09_performance/07_collision_limits/app/main.rb +++ b/samples/09_performance/07_collision_limits/app/main.rb @@ -6,9 +6,11 @@ - args.outputs.solids: An array. The values generate a solid. The parameters are [X, Y, WIDTH, HEIGHT, RED, GREEN, BLUE] + For more information about solids, go to mygame/documentation/03-solids-and-borders.md. - args.outputs.labels: An array. The values generate a label. The parameters are [X, Y, TEXT, SIZE, ALIGNMENT, RED, GREEN, BLUE, ALPHA, FONT STYLE] + For more information about labels, go to mygame/documentation/02-labels.md. - ARRAY#intersect_rect?: Returns true or false depending on if two rectangles intersect. diff --git a/samples/10_advanced_debugging/03_unit_tests/benchmark_api_tests.rb b/samples/10_advanced_debugging/03_unit_tests/benchmark_api_tests.rb new file mode 100644 index 0000000..2c06f1a --- /dev/null +++ b/samples/10_advanced_debugging/03_unit_tests/benchmark_api_tests.rb @@ -0,0 +1,43 @@ +def test_benchmark_api args, assert + result = args.gtk.benchmark iterations: 100, + only_one: -> () { + r = 0 + (1..100).each do |i| + r += 1 + end + } + + assert.equal! result.first_place.name, :only_one + + result = args.gtk.benchmark iterations: 100, + iterations_100: -> () { + r = 0 + (1..100).each do |i| + r += 1 + end + }, + iterations_50: -> () { + r = 0 + (1..50).each do |i| + r += 1 + end + } + + assert.equal! result.first_place.name, :iterations_50 + + result = args.gtk.benchmark iterations: 1, + iterations_100: -> () { + r = 0 + (1..100).each do |i| + r += 1 + end + }, + iterations_50: -> () { + r = 0 + (1..50).each do |i| + r += 1 + end + } + + assert.equal! result.too_small_to_measure, true +end diff --git a/samples/10_advanced_debugging/03_unit_tests/pretty_format_tests.rb b/samples/10_advanced_debugging/03_unit_tests/pretty_format_tests.rb new file mode 100644 index 0000000..6ac7b05 --- /dev/null +++ b/samples/10_advanced_debugging/03_unit_tests/pretty_format_tests.rb @@ -0,0 +1,130 @@ +def H opts + opts +end + +def A *opts + opts +end + +def assert_format args, assert, hash, expected + actual = args.fn.pretty_format hash + assert.are_equal! actual, expected +end + +def test_pretty_print args, assert + # ============================= + # hash with single value + # ============================= + input = (H first_name: "John") + expected = <<-S +{:first_name "John"} +S + (assert_format args, assert, input, expected) + + # ============================= + # hash with two values + # ============================= + input = (H first_name: "John", last_name: "Smith") + expected = <<-S +{:first_name "John" + :last_name "Smith"} +S + + (assert_format args, assert, input, expected) + + # ============================= + # hash with inner hash + # ============================= + input = (H first_name: "John", + last_name: "Smith", + middle_initial: "I", + so: (H first_name: "Pocahontas", + last_name: "Tsenacommacah"), + friends: (A (H first_name: "Side", last_name: "Kick"), + (H first_name: "Tim", last_name: "Wizard"))) + expected = <<-S +{:first_name "John" + :last_name "Smith" + :middle_initial "I" + :so {:first_name "Pocahontas" + :last_name "Tsenacommacah"} + :friends [{:first_name "Side" + :last_name "Kick"} + {:first_name "Tim" + :last_name "Wizard"}]} +S + + (assert_format args, assert, input, expected) + + # ============================= + # array with one value + # ============================= + input = (A 1) + expected = <<-S +[1] +S + (assert_format args, assert, input, expected) + + # ============================= + # array with multiple values + # ============================= + input = (A 1, 2, 3) + expected = <<-S +[1 + 2 + 3] +S + (assert_format args, assert, input, expected) + + # ============================= + # array with multiple values hashes + # ============================= + input = (A (H first_name: "Side", last_name: "Kick"), + (H first_name: "Tim", last_name: "Wizard")) + expected = <<-S +[{:first_name "Side" + :last_name "Kick"} + {:first_name "Tim" + :last_name "Wizard"}] +S + + (assert_format args, assert, input, expected) +end + +def test_nested_nested args, assert + # ============================= + # nested array in nested hash + # ============================= + input = (H type: :root, + text: "Root", + children: (A (H level: 1, + text: "Level 1", + children: (A (H level: 2, + text: "Level 2", + children: []))))) + + expected = <<-S +{:type :root + :text "Root" + :children [{:level 1 + :text "Level 1" + :children [{:level 2 + :text "Level 2" + :children []}]}]} + +S + + (assert_format args, assert, input, expected) +end + +def test_scene args, assert + script = <<-S +* Scene 1 +** Narrator +They say happy endings don't exist. +** Narrator +They say true love is a lie. +S + input = parse_org args, script + puts (args.fn.pretty_format input) +end diff --git a/samples/10_advanced_debugging/03_unit_tests/run-bash.sh b/samples/10_advanced_debugging/03_unit_tests/run-bash.sh deleted file mode 100644 index 005077b..0000000 --- a/samples/10_advanced_debugging/03_unit_tests/run-bash.sh +++ /dev/null @@ -1,4 +0,0 @@ -sh ./amir-build-and-run.sh --eval samples/99_zz_gtk_unit_tests/geometry_tests.rb --no-tick -sh ./amir-build-and-run.sh --eval samples/99_zz_gtk_unit_tests/parsing_tests.rb --no-tick -sh ./amir-build-and-run.sh --eval samples/99_zz_gtk_unit_tests/http_tests.rb --no-tick -sh ./amir-build-and-run.sh --eval samples/99_zz_gtk_unit_tests/array_to_primitive_tests.rb --no-tick diff --git a/samples/10_advanced_debugging/03_unit_tests/run-tests.sh b/samples/10_advanced_debugging/03_unit_tests/run-tests.sh index e551edf..d8b1a4a 100644 --- a/samples/10_advanced_debugging/03_unit_tests/run-tests.sh +++ b/samples/10_advanced_debugging/03_unit_tests/run-tests.sh @@ -1,10 +1,17 @@ -./dragonruby mygame --test samples/10_advanced_debugging/03_unit_tests/require_tests.rb -./dragonruby mygame --test samples/10_advanced_debugging/03_unit_tests/gen_docs.rb -./dragonruby mygame --test samples/10_advanced_debugging/03_unit_tests/geometry_tests.rb -./dragonruby mygame --test samples/10_advanced_debugging/03_unit_tests/http_tests.rb -./dragonruby mygame --test samples/10_advanced_debugging/03_unit_tests/object_to_primitive_tests.rb -./dragonruby mygame --test samples/10_advanced_debugging/03_unit_tests/parsing_tests.rb -./dragonruby mygame --test samples/10_advanced_debugging/03_unit_tests/require_tests.rb -./dragonruby mygame --test samples/10_advanced_debugging/03_unit_tests/serialize_deserialize_tests.rb -./dragonruby mygame --test samples/10_advanced_debugging/03_unit_tests/state_serialization_experimental_tests.rb -./dragonruby mygame --test samples/10_advanced_debugging/03_unit_tests/suggest_autocompletion_tests.rb +# fswatch ./samples/10_advanced_debugging/03_unit_tests/benchmark_api_tests.rb | xargs -n1 -I{} sh ./samples/10_advanced_debugging/03_unit_tests/run-tests.sh +# set -e +# rake +# ./dragonruby mygame --test samples/10_advanced_debugging/03_unit_tests/require_tests.rb +# ./dragonruby mygame --test samples/10_advanced_debugging/03_unit_tests/gen_docs.rb +# ./dragonruby mygame --test samples/10_advanced_debugging/03_unit_tests/geometry_tests.rb +# ./dragonruby mygame --test samples/10_advanced_debugging/03_unit_tests/http_tests.rb +# ./dragonruby mygame --test samples/10_advanced_debugging/03_unit_tests/object_to_primitive_tests.rb +# ./dragonruby mygame --test samples/10_advanced_debugging/03_unit_tests/parsing_tests.rb +# ./dragonruby mygame --test samples/10_advanced_debugging/03_unit_tests/require_tests.rb +# ./dragonruby mygame --test samples/10_advanced_debugging/03_unit_tests/serialize_deserialize_tests.rb +# ./dragonruby mygame --test samples/10_advanced_debugging/03_unit_tests/state_serialization_experimental_tests.rb +# ./dragonruby mygame --test samples/10_advanced_debugging/03_unit_tests/suggest_autocompletion_tests.rb +# ./dragonruby mygame --test samples/10_advanced_debugging/03_unit_tests/nil_coercion_tests.rb +# ./dragonruby mygame --test samples/10_advanced_debugging/03_unit_tests/fn_tests.rb +# ./dragonruby mygame --test samples/10_advanced_debugging/03_unit_tests/pretty_format_test.rb +./dragonruby mygame --test samples/10_advanced_debugging/03_unit_tests/benchmark_api_tests.rb diff --git a/samples/13_path_finding_algorithms/01_breadth_first_search/app/main.rb b/samples/13_path_finding_algorithms/01_breadth_first_search/app/main.rb index c8e1633..8b84f1c 100644 --- a/samples/13_path_finding_algorithms/01_breadth_first_search/app/main.rb +++ b/samples/13_path_finding_algorithms/01_breadth_first_search/app/main.rb @@ -35,19 +35,19 @@ class BreadthFirstSearch # Stores which step of the animation is being rendered # When the user moves the star or messes with the walls, # the breadth first search is recalculated up to this step - args.state.anim_steps = 0 + args.state.anim_steps = 0 # At some step the animation will end, # and further steps won't change anything (the whole grid will be explored) # This step is roughly the grid's width * height # When anim_steps equals max_steps no more calculations will occur # and the slider will be at the end - args.state.max_steps = args.state.grid.width * args.state.grid.height + args.state.max_steps = args.state.grid.width * args.state.grid.height # Whether the animation should play or not # If true, every tick moves anim_steps forward one # Pressing the stepwise animation buttons will pause the animation - args.state.play = true + args.state.play = true # The location of the star and walls of the grid # They can be modified to have a different initial grid @@ -116,7 +116,7 @@ class BreadthFirstSearch [24, 9] => true, [25, 8] => true, [25, 9] => true, - } + } # Variables that are used by the breadth first search # Storing cells that the search has visited, prevents unnecessary steps @@ -132,7 +132,7 @@ class BreadthFirstSearch # We store this value, because we want to remember the value even when # the user's cursor is no longer over what they're interacting with, but # they are still clicking down on the mouse. - args.state.click_and_drag = :none + args.state.click_and_drag = :none # Store the rects of the buttons that control the animation # They are here for user customization @@ -166,13 +166,13 @@ class BreadthFirstSearch # User input is processed, and # The next step in the search is calculated def tick - render - input + render + input # If animation is playing, and max steps have not been reached # Move the search a step forward if state.play && state.anim_steps < state.max_steps # Variable that tells the program what step to recalculate up to - state.anim_steps += 1 + state.anim_steps += 1 calc end end @@ -182,8 +182,8 @@ class BreadthFirstSearch render_buttons render_slider - render_background - render_visited + render_background + render_visited render_frontier render_walls render_star @@ -251,7 +251,7 @@ class BreadthFirstSearch outputs.primitives << [slider.x, slider.y, slider.x + slider.w, slider.y].line # The circle needs to be offset so that the center of the circle # overlaps the line instead of the upper right corner of the circle - # The circle's x value is also moved based on the current search step + # The circle's x value is also moved based on the current seach step circle_x = (slider.x - slider.offset) + (state.anim_steps * slider.spacing) circle_y = (slider.y - slider.offset) circle_rect = [circle_x, circle_y, 37, 37] @@ -260,8 +260,8 @@ class BreadthFirstSearch # Draws what the grid looks like with nothing on it def render_background - render_unvisited - render_grid_lines + render_unvisited + render_grid_lines end # Draws a rectangle the size of the entire grid to represent unvisited cells @@ -276,7 +276,7 @@ class BreadthFirstSearch end for y in 0..grid.height - outputs.lines << horizontal_line(y) + outputs.lines << horizontal_line(y) end end @@ -294,28 +294,28 @@ class BreadthFirstSearch # The frontier is the most outward parts of the search def render_frontier outputs.solids << state.frontier.map do |cell| - [scale_up(cell), frontier_color] + [scale_up([cell.x, cell.y]), frontier_color] end end # Draws the walls def render_walls outputs.solids << state.walls.map do |wall| - [scale_up(wall), wall_color] + [scale_up([wall.x, wall.y]), wall_color] end end # Renders cells that have been searched in the appropriate color def render_visited outputs.solids << state.visited.map do |cell| - [scale_up(cell), visited_color] + [scale_up([cell.x, cell.y]), visited_color] end end # Renders the star def render_star outputs.sprites << [scale_up(state.star), 'star.png'] - end + end # In code, the cells are represented as 1x1 rectangles # When drawn, the cells are larger than 1x1 rectangles @@ -369,20 +369,20 @@ class BreadthFirstSearch # The detection and processing of click and drag inputs are separate # The program has to remember that the user is dragging an object # even when the mouse is no longer over that object - detect_click_and_drag - process_click_and_drag + detect_click_and_drag + process_click_and_drag end # Detects and Process input for each button def input_buttons - input_left_button - input_center_button - input_next_step_button + input_left_button + input_center_button + input_next_step_button end # Checks if the previous step button is clicked # If it is, it pauses the animation and moves the search one step backward - def input_left_button + def input_left_button if left_button_clicked? state.play = false state.anim_steps -= 1 @@ -394,7 +394,7 @@ class BreadthFirstSearch # Inverses whether the animation is playing or not when clicked def input_center_button if center_button_clicked? or inputs.keyboard.key_down.space - state.play = !state.play + state.play = !state.play end end @@ -402,8 +402,8 @@ class BreadthFirstSearch # If it is, it pauses the animation and moves the search one step forward def input_next_step_button if right_button_clicked? - state.play = false - state.anim_steps += 1 + state.play = false + state.anim_steps += 1 calc end end @@ -412,29 +412,29 @@ class BreadthFirstSearch # Storing the value allows the user to continue the same edit as long as the # mouse left click is held def detect_click_and_drag - if inputs.mouse.up - state.click_and_drag = :none - elsif star_clicked? - state.click_and_drag = :star - elsif wall_clicked? - state.click_and_drag = :remove_wall - elsif grid_clicked? - state.click_and_drag = :add_wall - elsif slider_clicked? - state.click_and_drag = :slider + if inputs.mouse.up + state.click_and_drag = :none + elsif star_clicked? + state.click_and_drag = :star + elsif wall_clicked? + state.click_and_drag = :remove_wall + elsif grid_clicked? + state.click_and_drag = :add_wall + elsif slider_clicked? + state.click_and_drag = :slider end end # Processes click and drag based on what the user is currently dragging def process_click_and_drag - if state.click_and_drag == :star - input_star - elsif state.click_and_drag == :remove_wall - input_remove_wall - elsif state.click_and_drag == :add_wall - input_add_wall - elsif state.click_and_drag == :slider - input_slider + if state.click_and_drag == :star + input_star + elsif state.click_and_drag == :remove_wall + input_remove_wall + elsif state.click_and_drag == :add_wall + input_add_wall + elsif state.click_and_drag == :slider + input_slider end end @@ -442,10 +442,10 @@ class BreadthFirstSearch # Only recalculates the search if the star changes position # Called whenever the user is editing the star (puts mouse down on star) def input_star - old_star = state.star.clone + old_star = state.star.clone state.star = cell_closest_to_mouse - unless old_star == state.star - recalculate + unless old_star == state.star + recalculate end end @@ -454,20 +454,20 @@ class BreadthFirstSearch # The mouse needs to be inside the grid, because we only want to remove walls # the cursor is directly over # Recalculations should only occur when a wall is actually deleted - if mouse_inside_grid? + if mouse_inside_grid? if state.walls.has_key?(cell_closest_to_mouse) - state.walls.delete(cell_closest_to_mouse) - recalculate + state.walls.delete(cell_closest_to_mouse) + recalculate end end end # Adds walls at cells under the cursor def input_add_wall - if mouse_inside_grid? + if mouse_inside_grid? unless state.walls.has_key?(cell_closest_to_mouse) - state.walls[cell_closest_to_mouse] = true - recalculate + state.walls[cell_closest_to_mouse] = true + recalculate end end end @@ -477,18 +477,18 @@ class BreadthFirstSearch # on the slider # Changes the step of the search to be animated def input_slider - state.play = false + state.play = false mouse_x = inputs.mouse.point.x # Bounds the mouse_x to the closest x value on the slider line - mouse_x = slider.x if mouse_x < slider.x - mouse_x = slider.x + slider.w if mouse_x > slider.x + slider.w + mouse_x = slider.x if mouse_x < slider.x + mouse_x = slider.x + slider.w if mouse_x > slider.x + slider.w # Sets the current search step to the one represented by the mouse x value # The slider's circle moves due to the render_slider method using anim_steps state.anim_steps = ((mouse_x - slider.x) / slider.spacing).to_i - recalculate + recalculate end # Whenever the user edits the grid, @@ -496,11 +496,11 @@ class BreadthFirstSearch # with the current grid as the initial state of the grid def recalculate # Resets the search - state.frontier = [] - state.visited = {} + state.frontier = [] + state.visited = {} # Moves the animation forward one step at a time - state.anim_steps.times { calc } + state.anim_steps.times { calc } end @@ -515,39 +515,39 @@ class BreadthFirstSearch # The setup to the search # Runs once when the there is no frontier or visited cells - if state.frontier.empty? && state.visited.empty? - state.frontier << state.star - state.visited[state.star] = true + if state.frontier.empty? && state.visited.empty? + state.frontier << state.star + state.visited[state.star] = true end # A step in the search - unless state.frontier.empty? + unless state.frontier.empty? # Takes the next frontier cell - new_frontier = state.frontier.shift + new_frontier = state.frontier.shift # For each of its neighbors - adjacent_neighbors(new_frontier).each do |neighbor| + adjacent_neighbors(new_frontier).each do |neighbor| # That have not been visited and are not walls - unless state.visited.has_key?(neighbor) || state.walls.has_key?(neighbor) + unless state.visited.has_key?(neighbor) || state.walls.has_key?(neighbor) # Add them to the frontier and mark them as visited - state.frontier << neighbor - state.visited[neighbor] = true + state.frontier << neighbor + state.visited[neighbor] = true end end end end - + # Returns a list of adjacent cells # Used to determine what the next cells to be added to the frontier are def adjacent_neighbors(cell) - neighbors = [] + neighbors = [] - neighbors << [cell.x, cell.y + 1] unless cell.y == grid.height - 1 - neighbors << [cell.x + 1, cell.y] unless cell.x == grid.width - 1 - neighbors << [cell.x, cell.y - 1] unless cell.y == 0 - neighbors << [cell.x - 1, cell.y] unless cell.x == 0 + neighbors << [cell.x, cell.y + 1] unless cell.y == grid.height - 1 + neighbors << [cell.x + 1, cell.y] unless cell.x == grid.width - 1 + neighbors << [cell.x, cell.y - 1] unless cell.y == 0 + neighbors << [cell.x - 1, cell.y] unless cell.x == 0 - neighbors + neighbors end # When the user grabs the star and puts their cursor to the far right @@ -555,13 +555,13 @@ class BreadthFirstSearch # Finding the cell closest to the mouse helps with this def cell_closest_to_mouse # Closest cell to the mouse - x = (inputs.mouse.point.x / grid.cell_size).to_i - y = (inputs.mouse.point.y / grid.cell_size).to_i + x = (inputs.mouse.point.x / grid.cell_size).to_i + y = (inputs.mouse.point.y / grid.cell_size).to_i # Bound x and y to the grid - x = grid.width - 1 if x > grid.width - 1 - y = grid.height - 1 if y > grid.height - 1 + x = grid.width - 1 if x > grid.width - 1 + y = grid.height - 1 if y > grid.height - 1 # Return closest cell - [x, y] + [x, y] end # These methods detect when the buttons are clicked @@ -605,7 +605,7 @@ class BreadthFirstSearch # Part of the condition that checks whether the user is removing a wall def mouse_inside_a_wall? state.walls.each_key do | wall | - return true if inputs.mouse.point.inside_rect?(scale_up(wall)) + return true if inputs.mouse.point.inside_rect?(scale_up([wall.x, wall.y])) end false @@ -622,27 +622,27 @@ class BreadthFirstSearch # Light brown def unvisited_color - [221, 212, 213] + [221, 212, 213] end # Black def grid_line_color - [255, 255, 255] + [255, 255, 255] end # Dark Brown def visited_color - [204, 191, 179] + [204, 191, 179] end # Blue def frontier_color - [103, 136, 204] + [103, 136, 204] end # Camo Green def wall_color - [134, 134, 120] + [134, 134, 120] end # Button Background diff --git a/samples/13_path_finding_algorithms/02_detailed_breadth_first_search/app/main.rb b/samples/13_path_finding_algorithms/02_detailed_breadth_first_search/app/main.rb index d4c9c1c..810ff7b 100644 --- a/samples/13_path_finding_algorithms/02_detailed_breadth_first_search/app/main.rb +++ b/samples/13_path_finding_algorithms/02_detailed_breadth_first_search/app/main.rb @@ -168,7 +168,7 @@ class DetailedBreadthFirstSearch outputs.primitives << [slider.x, slider.y, slider.x + slider.w, slider.y].line # The circle needs to be offset so that the center of the circle # overlaps the line instead of the upper right corner of the circle - # The circle's x value is also moved based on the current search step + # The circle's x value is also moved based on the current seach step circle_x = (slider.x - slider.offset) + (state.anim_steps * slider.spacing) circle_y = (slider.y - slider.offset) circle_rect = [circle_x, circle_y, 37, 37] diff --git a/samples/13_path_finding_algorithms/06_heuristic/app/main.rb b/samples/13_path_finding_algorithms/06_heuristic/app/main.rb index 10beba3..cbdfca7 100644 --- a/samples/13_path_finding_algorithms/06_heuristic/app/main.rb +++ b/samples/13_path_finding_algorithms/06_heuristic/app/main.rb @@ -10,13 +10,13 @@ class Heuristic_With_Walls def tick defaults - render - input + render + input # If animation is playing, and max steps have not been reached # Move the search a step forward if state.play && state.current_step < state.max_steps # Variable that tells the program what step to recalculate up to - state.current_step += 1 + state.current_step += 1 move_searches_one_step_forward end end @@ -38,7 +38,7 @@ class Heuristic_With_Walls # We store this value, because we want to remember the value even when # the user's cursor is no longer over what they're interacting with, but # they are still clicking down on the mouse. - state.user_input ||= :none + state.user_input ||= :none # These variables allow the breadth first search to take place # Came_from is a hash with a key of a cell and a value of the cell that was expanded from to find the key. @@ -63,7 +63,7 @@ class Heuristic_With_Walls # Unless the current step has a value unless state.current_step # Set the current step to 10 - state.current_step = 10 + state.current_step = 10 # And calculate the searches up to step 10 recalculate_searches end @@ -73,7 +73,7 @@ class Heuristic_With_Walls # This step is roughly the grid's width * height # When anim_steps equals max_steps no more calculations will occur # and the slider will be at the end - state.max_steps = grid.width * grid.height + state.max_steps = grid.width * grid.height # Whether the animation should play or not # If true, every tick moves anim_steps forward one @@ -166,7 +166,7 @@ class Heuristic_With_Walls # If the mouse was clicked this tick if inputs.mouse.down # Determine what the user is editing and appropriately edit the state.user_input variable - determine_input + determine_input end # Process user input based on user_input variable and current mouse position @@ -179,35 +179,35 @@ class Heuristic_With_Walls if mouse_over_slider? state.user_input = :slider # If the mouse is over the star in the first grid - elsif bfs_mouse_over_star? + elsif bfs_mouse_over_star? # The user is editing the star from the first grid - state.user_input = :bfs_star + state.user_input = :bfs_star # If the mouse is over the star in the second grid - elsif heuristic_mouse_over_star? + elsif heuristic_mouse_over_star? # The user is editing the star from the second grid - state.user_input = :heuristic_star + state.user_input = :heuristic_star # If the mouse is over the target in the first grid - elsif bfs_mouse_over_target? + elsif bfs_mouse_over_target? # The user is editing the target from the first grid - state.user_input = :bfs_target + state.user_input = :bfs_target # If the mouse is over the target in the second grid - elsif heuristic_mouse_over_target? + elsif heuristic_mouse_over_target? # The user is editing the target from the second grid - state.user_input = :heuristic_target + state.user_input = :heuristic_target # If the mouse is over a wall in the first grid - elsif bfs_mouse_over_wall? + elsif bfs_mouse_over_wall? # The user is removing a wall from the first grid - state.user_input = :bfs_remove_wall + state.user_input = :bfs_remove_wall # If the mouse is over a wall in the second grid - elsif heuristic_mouse_over_wall? + elsif heuristic_mouse_over_wall? # The user is removing a wall from the second grid state.user_input = :heuristic_remove_wall # If the mouse is over the first grid - elsif bfs_mouse_over_grid? + elsif bfs_mouse_over_grid? # The user is adding a wall from the first grid state.user_input = :bfs_add_wall # If the mouse is over the second grid - elsif heuristic_mouse_over_grid? + elsif heuristic_mouse_over_grid? # The user is adding a wall from the second grid state.user_input = :heuristic_add_wall end @@ -217,22 +217,22 @@ class Heuristic_With_Walls def process_input if state.user_input == :slider process_input_slider - elsif state.user_input == :bfs_star - process_input_bfs_star + elsif state.user_input == :bfs_star + process_input_bfs_star elsif state.user_input == :heuristic_star - process_input_heuristic_star - elsif state.user_input == :bfs_target - process_input_bfs_target - elsif state.user_input == :heuristic_target - process_input_heuristic_target - elsif state.user_input == :bfs_remove_wall - process_input_bfs_remove_wall + process_input_heuristic_star + elsif state.user_input == :bfs_target + process_input_bfs_target + elsif state.user_input == :heuristic_target + process_input_heuristic_target + elsif state.user_input == :bfs_remove_wall + process_input_bfs_remove_wall elsif state.user_input == :heuristic_remove_wall - process_input_heuristic_remove_wall - elsif state.user_input == :bfs_add_wall - process_input_bfs_add_wall - elsif state.user_input == :heuristic_add_wall - process_input_heuristic_add_wall + process_input_heuristic_remove_wall + elsif state.user_input == :bfs_add_wall + process_input_bfs_add_wall + elsif state.user_input == :heuristic_add_wall + process_input_heuristic_add_wall end end @@ -242,7 +242,7 @@ class Heuristic_With_Walls outputs.primitives << [slider.x, slider.y, slider.x + slider.w, slider.y].line # The circle needs to be offset so that the center of the circle # overlaps the line instead of the upper right corner of the circle - # The circle's x value is also moved based on the current search step + # The circle's x value is also moved based on the current seach step circle_x = (slider.x - slider.offset) + (state.current_step * slider.spacing) circle_y = (slider.y - slider.offset) circle_rect = [circle_x, circle_y, 37, 37] @@ -309,7 +309,7 @@ class Heuristic_With_Walls # The horizontal grid lines for y in 0..grid.height - outputs.lines << bfs_horizontal_line(y) + outputs.lines << bfs_horizontal_line(y) end end @@ -324,10 +324,10 @@ class Heuristic_With_Walls # The horizontal grid lines for y in 0..grid.height - outputs.lines << heuristic_horizontal_line(y) + outputs.lines << heuristic_horizontal_line(y) end end - + # Returns a vertical line for a column of the first grid def bfs_vertical_line column bfs_scale_up([column, 0, column, grid.height]) @@ -362,7 +362,7 @@ class Heuristic_With_Walls def render_bfs_target outputs.sprites << [bfs_scale_up(grid.target), 'target.png'] end - + # Renders the target on the second grid def render_heuristic_target outputs.sprites << [heuristic_scale_up(grid.target), 'target.png'] @@ -370,14 +370,14 @@ class Heuristic_With_Walls # Renders the walls on the first grid def render_bfs_walls - grid.walls.each_key do | wall | + grid.walls.each_key do | wall | outputs.solids << [bfs_scale_up(wall), wall_color] end end # Renders the walls on the second grid def render_heuristic_walls - grid.walls.each_key do | wall | + grid.walls.each_key do | wall | outputs.solids << [heuristic_scale_up(wall), wall_color] end end @@ -398,14 +398,14 @@ class Heuristic_With_Walls # Renders the frontier cells on the first grid def render_bfs_frontier - bfs.frontier.each do | frontier_cell | + bfs.frontier.each do | frontier_cell | outputs.solids << [bfs_scale_up(frontier_cell), frontier_color, 200] end end # Renders the frontier cells on the second grid def render_heuristic_frontier - heuristic.frontier.each do | frontier_cell | + heuristic.frontier.each do | frontier_cell | outputs.solids << [heuristic_scale_up(frontier_cell), frontier_color, 200] end end @@ -489,14 +489,14 @@ class Heuristic_With_Walls # Checks and handles input for the buttons # Called when the mouse is lifted def input_buttons - input_left_button - input_center_button - input_right_button + input_left_button + input_center_button + input_right_button end # Checks if the previous step button is clicked # If it is, it pauses the animation and moves the search one step backward - def input_left_button + def input_left_button if left_button_clicked? state.play = false state.current_step -= 1 @@ -508,7 +508,7 @@ class Heuristic_With_Walls # Inverses whether the animation is playing or not when clicked def input_center_button if center_button_clicked? || inputs.keyboard.key_down.space - state.play = !state.play + state.play = !state.play end end @@ -516,8 +516,8 @@ class Heuristic_With_Walls # If it is, it pauses the animation and moves the search one step forward def input_right_button if right_button_clicked? - state.play = false - state.current_step += 1 + state.play = false + state.current_step += 1 move_searches_one_step_forward end end @@ -598,12 +598,12 @@ class Heuristic_With_Walls # on the slider # Changes the step of the search to be animated def process_input_slider - state.play = false + state.play = false mouse_x = inputs.mouse.point.x # Bounds the mouse_x to the closest x value on the slider line - mouse_x = slider.x if mouse_x < slider.x - mouse_x = slider.x + slider.w if mouse_x > slider.x + slider.w + mouse_x = slider.x if mouse_x < slider.x + mouse_x = slider.x + slider.w if mouse_x > slider.x + slider.w # Sets the current search step to the one represented by the mouse x value # The slider's circle moves due to the render_slider method using anim_steps @@ -616,12 +616,12 @@ class Heuristic_With_Walls # Only resets the search if the star changes position # Called whenever the user is editing the star (puts mouse down on star) def process_input_bfs_star - old_star = grid.star.clone + old_star = grid.star.clone unless bfs_cell_closest_to_mouse == grid.target - grid.star = bfs_cell_closest_to_mouse + grid.star = bfs_cell_closest_to_mouse end - unless old_star == grid.star - recalculate_searches + unless old_star == grid.star + recalculate_searches end end @@ -629,12 +629,12 @@ class Heuristic_With_Walls # Only resets the search if the star changes position # Called whenever the user is editing the star (puts mouse down on star) def process_input_heuristic_star - old_star = grid.star.clone + old_star = grid.star.clone unless heuristic_cell_closest_to_mouse == grid.target grid.star = heuristic_cell_closest_to_mouse end - unless old_star == grid.star - recalculate_searches + unless old_star == grid.star + recalculate_searches end end @@ -642,12 +642,12 @@ class Heuristic_With_Walls # Only recalculate_searchess the search if the target changes position # Called whenever the user is editing the target (puts mouse down on target) def process_input_bfs_target - old_target = grid.target.clone + old_target = grid.target.clone unless bfs_cell_closest_to_mouse == grid.star grid.target = bfs_cell_closest_to_mouse end - unless old_target == grid.target - recalculate_searches + unless old_target == grid.target + recalculate_searches end end @@ -655,12 +655,12 @@ class Heuristic_With_Walls # Only recalculate_searchess the search if the target changes position # Called whenever the user is editing the target (puts mouse down on target) def process_input_heuristic_target - old_target = grid.target.clone + old_target = grid.target.clone unless heuristic_cell_closest_to_mouse == grid.star grid.target = heuristic_cell_closest_to_mouse end - unless old_target == grid.target - recalculate_searches + unless old_target == grid.target + recalculate_searches end end @@ -669,10 +669,10 @@ class Heuristic_With_Walls # The mouse needs to be inside the grid, because we only want to remove walls # the cursor is directly over # Recalculations should only occur when a wall is actually deleted - if bfs_mouse_over_grid? + if bfs_mouse_over_grid? if grid.walls.has_key?(bfs_cell_closest_to_mouse) - grid.walls.delete(bfs_cell_closest_to_mouse) - recalculate_searches + grid.walls.delete(bfs_cell_closest_to_mouse) + recalculate_searches end end end @@ -682,29 +682,29 @@ class Heuristic_With_Walls # The mouse needs to be inside the grid, because we only want to remove walls # the cursor is directly over # Recalculations should only occur when a wall is actually deleted - if heuristic_mouse_over_grid? + if heuristic_mouse_over_grid? if grid.walls.has_key?(heuristic_cell_closest_to_mouse) - grid.walls.delete(heuristic_cell_closest_to_mouse) - recalculate_searches + grid.walls.delete(heuristic_cell_closest_to_mouse) + recalculate_searches end end end # Adds a wall in the first grid in the cell the mouse is over def process_input_bfs_add_wall - if bfs_mouse_over_grid? + if bfs_mouse_over_grid? unless grid.walls.has_key?(bfs_cell_closest_to_mouse) - grid.walls[bfs_cell_closest_to_mouse] = true - recalculate_searches + grid.walls[bfs_cell_closest_to_mouse] = true + recalculate_searches end end end # Adds a wall in the second grid in the cell the mouse is over def process_input_heuristic_add_wall - if heuristic_mouse_over_grid? + if heuristic_mouse_over_grid? unless grid.walls.has_key?(heuristic_cell_closest_to_mouse) - grid.walls[heuristic_cell_closest_to_mouse] = true - recalculate_searches + grid.walls[heuristic_cell_closest_to_mouse] = true + recalculate_searches end end end @@ -714,13 +714,13 @@ class Heuristic_With_Walls # Finding the cell closest to the mouse helps with this def bfs_cell_closest_to_mouse # Closest cell to the mouse in the first grid - x = (inputs.mouse.point.x / grid.cell_size).to_i - y = (inputs.mouse.point.y / grid.cell_size).to_i + x = (inputs.mouse.point.x / grid.cell_size).to_i + y = (inputs.mouse.point.y / grid.cell_size).to_i # Bound x and y to the grid - x = grid.width - 1 if x > grid.width - 1 - y = grid.height - 1 if y > grid.height - 1 + x = grid.width - 1 if x > grid.width - 1 + y = grid.height - 1 if y > grid.height - 1 # Return closest cell - [x, y] + [x, y] end # When the user grabs the star and puts their cursor to the far right @@ -728,17 +728,17 @@ class Heuristic_With_Walls # Finding the cell closest to the mouse in the second grid helps with this def heuristic_cell_closest_to_mouse # Closest cell grid to the mouse in the second - x = (inputs.mouse.point.x / grid.cell_size).to_i - y = (inputs.mouse.point.y / grid.cell_size).to_i + x = (inputs.mouse.point.x / grid.cell_size).to_i + y = (inputs.mouse.point.y / grid.cell_size).to_i # Translate the cell to the first grid x -= grid.width + 1 # Bound x and y to the first grid x = 0 if x < 0 y = 0 if y < 0 - x = grid.width - 1 if x > grid.width - 1 - y = grid.height - 1 if y > grid.height - 1 + x = grid.width - 1 if x > grid.width - 1 + y = grid.height - 1 if y > grid.height - 1 # Return closest cell - [x, y] + [x, y] end def recalculate_searches @@ -763,22 +763,22 @@ class Heuristic_With_Walls return if bfs.came_from.has_key?(grid.target) # Only runs at the beginning of the search as setup. - if bfs.came_from.empty? - bfs.frontier << grid.star - bfs.came_from[grid.star] = nil + if bfs.came_from.empty? + bfs.frontier << grid.star + bfs.came_from[grid.star] = nil end # A step in the search - unless bfs.frontier.empty? + unless bfs.frontier.empty? # Takes the next frontier cell - new_frontier = bfs.frontier.shift + new_frontier = bfs.frontier.shift # For each of its neighbors - adjacent_neighbors(new_frontier).each do |neighbor| + adjacent_neighbors(new_frontier).each do |neighbor| # That have not been visited and are not walls - unless bfs.came_from.has_key?(neighbor) || grid.walls.has_key?(neighbor) + unless bfs.came_from.has_key?(neighbor) || grid.walls.has_key?(neighbor) # Add them to the frontier and mark them as visited - bfs.frontier << neighbor - bfs.came_from[neighbor] = new_frontier + bfs.frontier << neighbor + bfs.came_from[neighbor] = new_frontier end end end @@ -833,12 +833,12 @@ class Heuristic_With_Walls # Get the next cell to explore from new_frontier = heuristic.frontier.shift # For each of its neighbors - adjacent_neighbors(new_frontier).each do |neighbor| + adjacent_neighbors(new_frontier).each do |neighbor| # That have not been visited and are not walls - unless heuristic.came_from.has_key?(neighbor) || grid.walls.has_key?(neighbor) + unless heuristic.came_from.has_key?(neighbor) || grid.walls.has_key?(neighbor) # Add them to the frontier and mark them as visited - heuristic.frontier << neighbor - heuristic.came_from[neighbor] = new_frontier + heuristic.frontier << neighbor + heuristic.came_from[neighbor] = new_frontier end end end @@ -882,16 +882,16 @@ class Heuristic_With_Walls # Returns a list of adjacent cells # Used to determine what the next cells to be added to the frontier are def adjacent_neighbors(cell) - neighbors = [] + neighbors = [] # Gets all the valid neighbors into the array # From southern neighbor, clockwise - neighbors << [cell.x , cell.y - 1] unless cell.y == 0 - neighbors << [cell.x - 1, cell.y ] unless cell.x == 0 - neighbors << [cell.x , cell.y + 1] unless cell.y == grid.height - 1 - neighbors << [cell.x + 1, cell.y ] unless cell.x == grid.width - 1 + neighbors << [cell.x , cell.y - 1] unless cell.y == 0 + neighbors << [cell.x - 1, cell.y ] unless cell.x == 0 + neighbors << [cell.x , cell.y + 1] unless cell.y == grid.height - 1 + neighbors << [cell.x + 1, cell.y ] unless cell.x == grid.width - 1 - neighbors + neighbors end # Finds the vertical and horizontal distance of a cell from the star @@ -940,7 +940,7 @@ class Heuristic_With_Walls def wall_color [134, 134, 120] # Camo Green end - + def visited_color [204, 191, 179] # Dark Brown end @@ -948,7 +948,7 @@ class Heuristic_With_Walls def frontier_color [103, 136, 204] # Blue end - + def path_color [231, 230, 228] # Pastel White end diff --git a/samples/13_path_finding_algorithms/07_heuristic_with_walls/app/main.rb b/samples/13_path_finding_algorithms/07_heuristic_with_walls/app/main.rb index 7b8f653..b106e34 100644 --- a/samples/13_path_finding_algorithms/07_heuristic_with_walls/app/main.rb +++ b/samples/13_path_finding_algorithms/07_heuristic_with_walls/app/main.rb @@ -10,13 +10,13 @@ class Heuristic def tick defaults - render - input + render + input # If animation is playing, and max steps have not been reached # Move the search a step forward if state.play && state.current_step < state.max_steps # Variable that tells the program what step to recalculate up to - state.current_step += 1 + state.current_step += 1 move_searches_one_step_forward end end @@ -71,7 +71,7 @@ class Heuristic # We store this value, because we want to remember the value even when # the user's cursor is no longer over what they're interacting with, but # they are still clicking down on the mouse. - state.user_input ||= :none + state.user_input ||= :none # These variables allow the breadth first search to take place # Came_from is a hash with a key of a cell and a value of the cell that was expanded from to find the key. @@ -96,7 +96,7 @@ class Heuristic # Unless the current step has a value unless state.current_step # Set the current step to 10 - state.current_step = 10 + state.current_step = 10 # And calculate the searches up to step 10 recalculate_searches end @@ -106,7 +106,7 @@ class Heuristic # This step is roughly the grid's width * height # When anim_steps equals max_steps no more calculations will occur # and the slider will be at the end - state.max_steps = grid.width * grid.height + state.max_steps = grid.width * grid.height # Whether the animation should play or not # If true, every tick moves anim_steps forward one @@ -199,7 +199,7 @@ class Heuristic # If the mouse was clicked this tick if inputs.mouse.down # Determine what the user is editing and appropriately edit the state.user_input variable - determine_input + determine_input end # Process user input based on user_input variable and current mouse position @@ -212,35 +212,35 @@ class Heuristic if mouse_over_slider? state.user_input = :slider # If the mouse is over the star in the first grid - elsif bfs_mouse_over_star? + elsif bfs_mouse_over_star? # The user is editing the star from the first grid - state.user_input = :bfs_star + state.user_input = :bfs_star # If the mouse is over the star in the second grid - elsif heuristic_mouse_over_star? + elsif heuristic_mouse_over_star? # The user is editing the star from the second grid - state.user_input = :heuristic_star + state.user_input = :heuristic_star # If the mouse is over the target in the first grid - elsif bfs_mouse_over_target? + elsif bfs_mouse_over_target? # The user is editing the target from the first grid - state.user_input = :bfs_target + state.user_input = :bfs_target # If the mouse is over the target in the second grid - elsif heuristic_mouse_over_target? + elsif heuristic_mouse_over_target? # The user is editing the target from the second grid - state.user_input = :heuristic_target + state.user_input = :heuristic_target # If the mouse is over a wall in the first grid - elsif bfs_mouse_over_wall? + elsif bfs_mouse_over_wall? # The user is removing a wall from the first grid - state.user_input = :bfs_remove_wall + state.user_input = :bfs_remove_wall # If the mouse is over a wall in the second grid - elsif heuristic_mouse_over_wall? + elsif heuristic_mouse_over_wall? # The user is removing a wall from the second grid state.user_input = :heuristic_remove_wall # If the mouse is over the first grid - elsif bfs_mouse_over_grid? + elsif bfs_mouse_over_grid? # The user is adding a wall from the first grid state.user_input = :bfs_add_wall # If the mouse is over the second grid - elsif heuristic_mouse_over_grid? + elsif heuristic_mouse_over_grid? # The user is adding a wall from the second grid state.user_input = :heuristic_add_wall end @@ -250,22 +250,22 @@ class Heuristic def process_input if state.user_input == :slider process_input_slider - elsif state.user_input == :bfs_star - process_input_bfs_star + elsif state.user_input == :bfs_star + process_input_bfs_star elsif state.user_input == :heuristic_star - process_input_heuristic_star - elsif state.user_input == :bfs_target - process_input_bfs_target - elsif state.user_input == :heuristic_target - process_input_heuristic_target - elsif state.user_input == :bfs_remove_wall - process_input_bfs_remove_wall + process_input_heuristic_star + elsif state.user_input == :bfs_target + process_input_bfs_target + elsif state.user_input == :heuristic_target + process_input_heuristic_target + elsif state.user_input == :bfs_remove_wall + process_input_bfs_remove_wall elsif state.user_input == :heuristic_remove_wall - process_input_heuristic_remove_wall - elsif state.user_input == :bfs_add_wall - process_input_bfs_add_wall - elsif state.user_input == :heuristic_add_wall - process_input_heuristic_add_wall + process_input_heuristic_remove_wall + elsif state.user_input == :bfs_add_wall + process_input_bfs_add_wall + elsif state.user_input == :heuristic_add_wall + process_input_heuristic_add_wall end end @@ -275,7 +275,7 @@ class Heuristic outputs.primitives << [slider.x, slider.y, slider.x + slider.w, slider.y].line # The circle needs to be offset so that the center of the circle # overlaps the line instead of the upper right corner of the circle - # The circle's x value is also moved based on the current search step + # The circle's x value is also moved based on the current seach step circle_x = (slider.x - slider.offset) + (state.current_step * slider.spacing) circle_y = (slider.y - slider.offset) circle_rect = [circle_x, circle_y, 37, 37] @@ -342,7 +342,7 @@ class Heuristic # The horizontal grid lines for y in 0..grid.height - outputs.lines << bfs_horizontal_line(y) + outputs.lines << bfs_horizontal_line(y) end end @@ -357,10 +357,10 @@ class Heuristic # The horizontal grid lines for y in 0..grid.height - outputs.lines << heuristic_horizontal_line(y) + outputs.lines << heuristic_horizontal_line(y) end end - + # Returns a vertical line for a column of the first grid def bfs_vertical_line column bfs_scale_up([column, 0, column, grid.height]) @@ -395,7 +395,7 @@ class Heuristic def render_bfs_target outputs.sprites << [bfs_scale_up(grid.target), 'target.png'] end - + # Renders the target on the second grid def render_heuristic_target outputs.sprites << [heuristic_scale_up(grid.target), 'target.png'] @@ -403,14 +403,14 @@ class Heuristic # Renders the walls on the first grid def render_bfs_walls - grid.walls.each_key do | wall | + grid.walls.each_key do | wall | outputs.solids << [bfs_scale_up(wall), wall_color] end end # Renders the walls on the second grid def render_heuristic_walls - grid.walls.each_key do | wall | + grid.walls.each_key do | wall | outputs.solids << [heuristic_scale_up(wall), wall_color] end end @@ -431,14 +431,14 @@ class Heuristic # Renders the frontier cells on the first grid def render_bfs_frontier - bfs.frontier.each do | frontier_cell | + bfs.frontier.each do | frontier_cell | outputs.solids << [bfs_scale_up(frontier_cell), frontier_color, 200] end end # Renders the frontier cells on the second grid def render_heuristic_frontier - heuristic.frontier.each do | frontier_cell | + heuristic.frontier.each do | frontier_cell | outputs.solids << [heuristic_scale_up(frontier_cell), frontier_color, 200] end end @@ -522,14 +522,14 @@ class Heuristic # Checks and handles input for the buttons # Called when the mouse is lifted def input_buttons - input_left_button - input_center_button - input_right_button + input_left_button + input_center_button + input_right_button end # Checks if the previous step button is clicked # If it is, it pauses the animation and moves the search one step backward - def input_left_button + def input_left_button if left_button_clicked? state.play = false state.current_step -= 1 @@ -541,7 +541,7 @@ class Heuristic # Inverses whether the animation is playing or not when clicked def input_center_button if center_button_clicked? || inputs.keyboard.key_down.space - state.play = !state.play + state.play = !state.play end end @@ -549,8 +549,8 @@ class Heuristic # If it is, it pauses the animation and moves the search one step forward def input_right_button if right_button_clicked? - state.play = false - state.current_step += 1 + state.play = false + state.current_step += 1 move_searches_one_step_forward end end @@ -631,12 +631,12 @@ class Heuristic # on the slider # Changes the step of the search to be animated def process_input_slider - state.play = false + state.play = false mouse_x = inputs.mouse.point.x # Bounds the mouse_x to the closest x value on the slider line - mouse_x = slider.x if mouse_x < slider.x - mouse_x = slider.x + slider.w if mouse_x > slider.x + slider.w + mouse_x = slider.x if mouse_x < slider.x + mouse_x = slider.x + slider.w if mouse_x > slider.x + slider.w # Sets the current search step to the one represented by the mouse x value # The slider's circle moves due to the render_slider method using anim_steps @@ -649,12 +649,12 @@ class Heuristic # Only resets the search if the star changes position # Called whenever the user is editing the star (puts mouse down on star) def process_input_bfs_star - old_star = grid.star.clone + old_star = grid.star.clone unless bfs_cell_closest_to_mouse == grid.target - grid.star = bfs_cell_closest_to_mouse + grid.star = bfs_cell_closest_to_mouse end - unless old_star == grid.star - recalculate_searches + unless old_star == grid.star + recalculate_searches end end @@ -662,12 +662,12 @@ class Heuristic # Only resets the search if the star changes position # Called whenever the user is editing the star (puts mouse down on star) def process_input_heuristic_star - old_star = grid.star.clone + old_star = grid.star.clone unless heuristic_cell_closest_to_mouse == grid.target grid.star = heuristic_cell_closest_to_mouse end - unless old_star == grid.star - recalculate_searches + unless old_star == grid.star + recalculate_searches end end @@ -675,12 +675,12 @@ class Heuristic # Only recalculate_searchess the search if the target changes position # Called whenever the user is editing the target (puts mouse down on target) def process_input_bfs_target - old_target = grid.target.clone + old_target = grid.target.clone unless bfs_cell_closest_to_mouse == grid.star grid.target = bfs_cell_closest_to_mouse end - unless old_target == grid.target - recalculate_searches + unless old_target == grid.target + recalculate_searches end end @@ -688,12 +688,12 @@ class Heuristic # Only recalculate_searchess the search if the target changes position # Called whenever the user is editing the target (puts mouse down on target) def process_input_heuristic_target - old_target = grid.target.clone + old_target = grid.target.clone unless heuristic_cell_closest_to_mouse == grid.star grid.target = heuristic_cell_closest_to_mouse end - unless old_target == grid.target - recalculate_searches + unless old_target == grid.target + recalculate_searches end end @@ -702,10 +702,10 @@ class Heuristic # The mouse needs to be inside the grid, because we only want to remove walls # the cursor is directly over # Recalculations should only occur when a wall is actually deleted - if bfs_mouse_over_grid? + if bfs_mouse_over_grid? if grid.walls.has_key?(bfs_cell_closest_to_mouse) - grid.walls.delete(bfs_cell_closest_to_mouse) - recalculate_searches + grid.walls.delete(bfs_cell_closest_to_mouse) + recalculate_searches end end end @@ -715,29 +715,29 @@ class Heuristic # The mouse needs to be inside the grid, because we only want to remove walls # the cursor is directly over # Recalculations should only occur when a wall is actually deleted - if heuristic_mouse_over_grid? + if heuristic_mouse_over_grid? if grid.walls.has_key?(heuristic_cell_closest_to_mouse) - grid.walls.delete(heuristic_cell_closest_to_mouse) - recalculate_searches + grid.walls.delete(heuristic_cell_closest_to_mouse) + recalculate_searches end end end # Adds a wall in the first grid in the cell the mouse is over def process_input_bfs_add_wall - if bfs_mouse_over_grid? + if bfs_mouse_over_grid? unless grid.walls.has_key?(bfs_cell_closest_to_mouse) - grid.walls[bfs_cell_closest_to_mouse] = true - recalculate_searches + grid.walls[bfs_cell_closest_to_mouse] = true + recalculate_searches end end end # Adds a wall in the second grid in the cell the mouse is over def process_input_heuristic_add_wall - if heuristic_mouse_over_grid? + if heuristic_mouse_over_grid? unless grid.walls.has_key?(heuristic_cell_closest_to_mouse) - grid.walls[heuristic_cell_closest_to_mouse] = true - recalculate_searches + grid.walls[heuristic_cell_closest_to_mouse] = true + recalculate_searches end end end @@ -747,13 +747,13 @@ class Heuristic # Finding the cell closest to the mouse helps with this def bfs_cell_closest_to_mouse # Closest cell to the mouse in the first grid - x = (inputs.mouse.point.x / grid.cell_size).to_i - y = (inputs.mouse.point.y / grid.cell_size).to_i + x = (inputs.mouse.point.x / grid.cell_size).to_i + y = (inputs.mouse.point.y / grid.cell_size).to_i # Bound x and y to the grid - x = grid.width - 1 if x > grid.width - 1 - y = grid.height - 1 if y > grid.height - 1 + x = grid.width - 1 if x > grid.width - 1 + y = grid.height - 1 if y > grid.height - 1 # Return closest cell - [x, y] + [x, y] end # When the user grabs the star and puts their cursor to the far right @@ -761,17 +761,17 @@ class Heuristic # Finding the cell closest to the mouse in the second grid helps with this def heuristic_cell_closest_to_mouse # Closest cell grid to the mouse in the second - x = (inputs.mouse.point.x / grid.cell_size).to_i - y = (inputs.mouse.point.y / grid.cell_size).to_i + x = (inputs.mouse.point.x / grid.cell_size).to_i + y = (inputs.mouse.point.y / grid.cell_size).to_i # Translate the cell to the first grid x -= grid.width + 1 # Bound x and y to the first grid x = 0 if x < 0 y = 0 if y < 0 - x = grid.width - 1 if x > grid.width - 1 - y = grid.height - 1 if y > grid.height - 1 + x = grid.width - 1 if x > grid.width - 1 + y = grid.height - 1 if y > grid.height - 1 # Return closest cell - [x, y] + [x, y] end def recalculate_searches @@ -796,22 +796,22 @@ class Heuristic return if bfs.came_from.has_key?(grid.target) # Only runs at the beginning of the search as setup. - if bfs.came_from.empty? - bfs.frontier << grid.star - bfs.came_from[grid.star] = nil + if bfs.came_from.empty? + bfs.frontier << grid.star + bfs.came_from[grid.star] = nil end # A step in the search - unless bfs.frontier.empty? + unless bfs.frontier.empty? # Takes the next frontier cell - new_frontier = bfs.frontier.shift + new_frontier = bfs.frontier.shift # For each of its neighbors - adjacent_neighbors(new_frontier).each do |neighbor| + adjacent_neighbors(new_frontier).each do |neighbor| # That have not been visited and are not walls - unless bfs.came_from.has_key?(neighbor) || grid.walls.has_key?(neighbor) + unless bfs.came_from.has_key?(neighbor) || grid.walls.has_key?(neighbor) # Add them to the frontier and mark them as visited - bfs.frontier << neighbor - bfs.came_from[neighbor] = new_frontier + bfs.frontier << neighbor + bfs.came_from[neighbor] = new_frontier end end end @@ -866,12 +866,12 @@ class Heuristic # Get the next cell to explore from new_frontier = heuristic.frontier.shift # For each of its neighbors - adjacent_neighbors(new_frontier).each do |neighbor| + adjacent_neighbors(new_frontier).each do |neighbor| # That have not been visited and are not walls - unless heuristic.came_from.has_key?(neighbor) || grid.walls.has_key?(neighbor) + unless heuristic.came_from.has_key?(neighbor) || grid.walls.has_key?(neighbor) # Add them to the frontier and mark them as visited - heuristic.frontier << neighbor - heuristic.came_from[neighbor] = new_frontier + heuristic.frontier << neighbor + heuristic.came_from[neighbor] = new_frontier end end end @@ -915,16 +915,16 @@ class Heuristic # Returns a list of adjacent cells # Used to determine what the next cells to be added to the frontier are def adjacent_neighbors(cell) - neighbors = [] + neighbors = [] # Gets all the valid neighbors into the array # From southern neighbor, clockwise - neighbors << [cell.x , cell.y - 1] unless cell.y == 0 - neighbors << [cell.x - 1, cell.y ] unless cell.x == 0 - neighbors << [cell.x , cell.y + 1] unless cell.y == grid.height - 1 - neighbors << [cell.x + 1, cell.y ] unless cell.x == grid.width - 1 + neighbors << [cell.x , cell.y - 1] unless cell.y == 0 + neighbors << [cell.x - 1, cell.y ] unless cell.x == 0 + neighbors << [cell.x , cell.y + 1] unless cell.y == grid.height - 1 + neighbors << [cell.x + 1, cell.y ] unless cell.x == grid.width - 1 - neighbors + neighbors end # Finds the vertical and horizontal distance of a cell from the star @@ -973,7 +973,7 @@ class Heuristic def wall_color [134, 134, 120] # Camo Green end - + def visited_color [204, 191, 179] # Dark Brown end @@ -981,7 +981,7 @@ class Heuristic def frontier_color [103, 136, 204] # Blue end - + def path_color [231, 230, 228] # Pastel White end diff --git a/samples/99_genre_3d/3d_cube/app/main.rb b/samples/99_genre_3d/3d_cube/app/main.rb deleted file mode 100644 index fc95291..0000000 --- a/samples/99_genre_3d/3d_cube/app/main.rb +++ /dev/null @@ -1,50 +0,0 @@ -STARTX = 0.0 -STARTY = 0.0 -ENDY = 20.0 -ENDX = 20.0 -SPINPOINT = 10 -SPINDURATION = 400 -POINTSIZE = 8 -BOXDEPTH = 40 -YAW = 1 -DISTANCE = 10 - -def tick args - args.outputs.background_color = [0, 0, 0] - a = Math.sin(args.state.tick_count / SPINDURATION) * Math.tan(args.state.tick_count / SPINDURATION) - s = Math.sin(a) - c = Math.cos(a) - x = STARTX - y = STARTY - offset_x = (1280 - (ENDX - STARTX)) / 2 - offset_y = (360 - (ENDY - STARTY)) / 2 - - srand(1) - while y < ENDY do - while x < ENDX do - if (y == STARTY || - y == (ENDY / 0.5) * 2 || - y == (ENDY / 0.5) * 2 + 0.5 || - y == ENDY - 0.5 || - x == STARTX || - x == ENDX - 0.5) - z = rand(BOXDEPTH) - z *= Math.sin(a / 2) - x -= SPINPOINT - u = (x * c) - (z * s) - v = (x * s) + (z * c) - k = DISTANCE.fdiv(100) + (v / 500 * YAW) - u = u / k - v = y / k - w = POINTSIZE / 10 / k - args.outputs.sprites << { x: offset_x + u - w, y: offset_y + v - w, w: w, h: w, path: 'sprites/square-blue.png'} - x += SPINPOINT - end - x += 0.5 - end - y += 0.5 - x = STARTX - end -end - -$gtk.reset diff --git a/samples/99_genre_3d/3d_cube/sprites/square-blue.png b/samples/99_genre_3d/3d_cube/sprites/square-blue.png deleted file mode 100644 index b840849..0000000 Binary files a/samples/99_genre_3d/3d_cube/sprites/square-blue.png and /dev/null differ diff --git a/samples/99_genre_arcade/snakemoji/app/main.rb b/samples/99_genre_arcade/snakemoji/app/main.rb index 648b728..3bffa22 100644 --- a/samples/99_genre_arcade/snakemoji/app/main.rb +++ b/samples/99_genre_arcade/snakemoji/app/main.rb @@ -10,8 +10,8 @@ # https://gist.github.com/scorp200 #############LICENSE############ # Feel free to use this anywhere and however you want -# You can sell this to EA for $1,000,000 if you want, it's completely free. -# Just remember you are helping this... thing... to spread... +# You can sell this to EA for $1,000,000 if you want, its completely free. +# Just rememeber you are helping this... thing... to spread... # ALSO! I am not liable for any mental, physical or financial damage caused. #############LICENSE############ @@ -156,7 +156,7 @@ def defaults 🎮 🎮.🐍 ||= [] #Direction the head moves to 🎮.🚗 ||= [0, 0] - #Next_Direction, during input check only change this variable and then when game updates assign this to Direction + #Next_Direction, during input check only change this variable and then when game updates asign this to Direction 🎮.🚦 ||= [*🎮.🚗] #Your score 🎮.💰 ||= 0 diff --git a/samples/99_genre_arcade/twinstick/app/main.rb b/samples/99_genre_arcade/twinstick/app/main.rb index 2ce1d50..4edef92 100644 --- a/samples/99_genre_arcade/twinstick/app/main.rb +++ b/samples/99_genre_arcade/twinstick/app/main.rb @@ -64,7 +64,7 @@ def move_enemies args theta = Math.atan2(enemy.y - args.state.player.y, enemy.x - args.state.player.x) # Convert the angle to a vector pointing at the player dx, dy = theta.to_degrees.vector 5 - # Move the enemy towards the player + # Move the enemy towards thr player enemy.x -= dx enemy.y -= dy end diff --git a/samples/99_genre_crafting/craft_game_starting_point/app/main.rb b/samples/99_genre_crafting/craft_game_starting_point/app/main.rb index 549e73d..d7478e4 100644 --- a/samples/99_genre_crafting/craft_game_starting_point/app/main.rb +++ b/samples/99_genre_crafting/craft_game_starting_point/app/main.rb @@ -1,13 +1,13 @@ # ================================================== # A NOTE TO JAM CRAFT PARTICIPANTS: -# The comments and code in here are just a small piece of DragonRuby's capabilities. +# The comments and code in here are just as small piece of DragonRuby's capabilities. # Be sure to check out the rest of the sample apps. Start with README.txt and go from there! # ================================================== # def tick args is the entry point into your game. This function is called at # a fixed update time of 60hz (60 fps). def tick args - # The defaults function initializes the game. + # The defaults function intitializes the game. defaults args # After the game is initialized, render it. @@ -38,7 +38,7 @@ def defaults args # Bottom left is 0, 0. Top right is 1280, 720. # The inventory area is at the top of the screen # the number 80 is the size of all the sprites, so that is what is being - # used to decide the width and height + # used to decide the with and height args.state.sprite_size = 80 args.state.inventory_border.w = args.state.sprite_size * 10 @@ -49,7 +49,7 @@ def defaults args # define the borders for where the crafting area is located # the crafting area is below the inventory area # the number 80 is the size of all the sprites, so that is what is being - # used to decide the width and height + # used to decide the with and height args.state.craft_border.x = 10 args.state.craft_border.y = 220 args.state.craft_border.w = args.state.sprite_size * 3 @@ -92,12 +92,12 @@ def defaults args }, ] - # after initializing the ordinal positions, derive the pixel + # after initializing the oridinal positions, derive the pixel # locations assuming that the width and height are 80 args.state.items.each { |item| set_inventory_position args, item } end - # define all the ordinal positions of the inventory slots + # define all the oridinal positions of the inventory slots if !args.state.inventory_area args.state.inventory_area = [ { ordinal_x: 0, ordinal_y: 0 }, @@ -132,7 +132,7 @@ def defaults args { ordinal_x: 9, ordinal_y: 2 }, ] - # after initializing the ordinal positions, derive the pixel + # after initializing the oridinal positions, derive the pixel # locations assuming that the width and height are 80 args.state.inventory_area.each { |i| set_inventory_position args, i } @@ -144,7 +144,7 @@ def defaults args # To bring up DragonRuby's Console, press the ~ key within the game. end - # define all the ordinal positions of the craft slots + # define all the oridinal positions of the craft slots if !args.state.craft_area args.state.craft_area = [ { ordinal_x: 0, ordinal_y: 0 }, @@ -158,7 +158,7 @@ def defaults args { ordinal_x: 2, ordinal_y: 2 }, ] - # after initializing the ordinal positions, derive the pixel + # after initializing the oridinal positions, derive the pixel # locations assuming that the width and height are 80 args.state.craft_area.each { |c| set_craft_position args, c } end @@ -244,7 +244,7 @@ def input args found[:location] = :held end - # if the mouse is clicked and an item is currently being held.... + # if the mouse is clicked and an item is currently beign held.... elsif args.state.held_item # determine if a slot within the craft area was clicked craft_area = args.state.craft_area.find { |a| args.inputs.mouse.click.point.inside_rect? a } @@ -255,7 +255,7 @@ def input args # if the click was within a craft area if craft_area # check to see if an item is already there and ignore the click if an item is found - # item_at_craft_slot is a helper method that returns an item or nil for a given ordinal + # item_at_craft_slot is a helper method that returns an item or nil for a given oridinal # position item_already_there = item_at_craft_slot args, craft_area[:ordinal_x], craft_area[:ordinal_y] @@ -263,8 +263,8 @@ def input args if !item_already_there # if the quantity they are currently holding is greater than 1 if args.state.held_item[:quantity] > 1 - # remove one item (creating a separate item of the same type), and place it - # at the ordinal position and location of the craft area + # remove one item (creating a seperate item of the same type), and place it + # at the oridinal position and location of the craft area # the .merge method on Hash creates a new Hash, but updates any values # passed as arguments to merge new_item = args.state.held_item.merge(quantity: 1, @@ -272,7 +272,7 @@ def input args ordinal_x: craft_area[:ordinal_x], ordinal_y: craft_area[:ordinal_y]) - # after the item is created, place it into the args.state.items collection + # after the item is crated, place it into the args.state.items collection args.state.items << new_item # then subtract one from the held item @@ -281,7 +281,7 @@ def input args # if the craft area is available and there is only one item being held elsif args.state.held_item[:quantity] == 1 # instead of creating any new items just set the location of the held item - # to the ordinal position of the craft area, and then nil out the + # to the oridinal position of the craft area, and then nil out the # held item state so that a new item can be picked up args.state.held_item[:location] = :craft args.state.held_item[:ordinal_x] = craft_area[:ordinal_x] @@ -326,7 +326,7 @@ end def calc args # make sure that the real position of the inventory # items are updated every frame to ensure that they - # are placed correctly given their location and ordinal positions + # are placed correctly given their location and oridinal positions # instead of using .map, here we use .each (since we are not returning a new item and just updating the items in place) args.state.items.each do |item| # based on the location of the item, invoke the correct pixel conversion method diff --git a/samples/99_genre_crafting/farming_game_starting_point/app/main.rb b/samples/99_genre_crafting/farming_game_starting_point/app/main.rb new file mode 100644 index 0000000..4c7dd61 --- /dev/null +++ b/samples/99_genre_crafting/farming_game_starting_point/app/main.rb @@ -0,0 +1,84 @@ +def tick args + args.state.tile_size = 80 + args.state.player_speed = 4 + args.state.player ||= tile(args, 7, 3, 0, 128, 180) + generate_map args + #press j to plant a green onion + if args.inputs.keyboard.j + #change this part you can change what you want to plant + args.state.walls << tile(args, ((args.state.player.x+80)/args.state.tile_size), ((args.state.player.y)/args.state.tile_size), 255, 255, 255) + args.state.plants << tile(args, ((args.state.player.x+80)/args.state.tile_size), ((args.state.player.y+80)/args.state.tile_size), 0, 160, 0) + end + # Adds walls, background, and player to args.outputs.solids so they appear on screen + args.outputs.solids << [0,0,1280,720, 237,189,101] + args.outputs.sprites << [0, 0, 1280, 720, 'sprites/background.png'] + args.outputs.solids << args.state.walls + args.outputs.solids << args.state.player + args.outputs.solids << args.state.plants + args.outputs.labels << [320, 640, "press J to plant", 3, 1, 255, 0, 0, 200] + + move_player args, -1, 0 if args.inputs.keyboard.left # x position decreases by 1 if left key is pressed + move_player args, 1, 0 if args.inputs.keyboard.right # x position increases by 1 if right key is pressed + move_player args, 0, 1 if args.inputs.keyboard.up # y position increases by 1 if up is pressed + move_player args, 0, -1 if args.inputs.keyboard.down # y position decreases by 1 if down is pressed +end + +# Sets position, size, and color of the tile +def tile args, x, y, *color + [x * args.state.tile_size, # sets definition for array using method parameters + y * args.state.tile_size, # multiplying by tile_size sets x and y to correct position using pixel values + args.state.tile_size, + args.state.tile_size, + *color] +end + +# Creates map by adding tiles to the wall, as well as a goal (that the player needs to reach) +def generate_map args + return if args.state.area + + # Creates the area of the map. There are 9 rows running horizontally across the screen + # and 16 columns running vertically on the screen. Any spot with a "1" is not + # open for the player to move into (and is green), and any spot with a "0" is available + # for the player to move in. + args.state.area = [ + [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,], + [1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1,], + [1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1,], + [1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1,], + [1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1,], + [1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1,], + [1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1,], + [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,], + [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ], + ].reverse # reverses the order of the area collection + + # By reversing the order, the way that the area appears above is how it appears + # on the screen in the game. If we did not reverse, the map would appear inverted. + + #The wall starts off with no tiles. + args.state.walls = [] + args.state.plants = [] + + # If v is 1, a green tile is added to args.state.walls. + # If v is 2, a black tile is created as the goal. + args.state.area.map_2d do |y, x, v| + if v == 1 + args.state.walls << tile(args, x, y, 255, 160, 156) # green tile + end + end +end + +# Allows the player to move their box around the screen +def move_player args, *vector + box = args.state.player.shift_rect(vector) # box is able to move at an angle + + # If the player's box hits a wall, it is not able to move further in that direction + return if args.state.walls + .any_intersect_rect?(box) + + # Player's box is able to move at angles (not just the four general directions) fast + args.state.player = + args.state.player + .shift_rect(vector.x * args.state.player_speed, # if we don't multiply by speed, then + vector.y * args.state.player_speed) # the box will move extremely slow +end diff --git a/samples/99_genre_crafting/farming_game_starting_point/app/repl.rb b/samples/99_genre_crafting/farming_game_starting_point/app/repl.rb new file mode 100644 index 0000000..f4c8292 --- /dev/null +++ b/samples/99_genre_crafting/farming_game_starting_point/app/repl.rb @@ -0,0 +1,307 @@ +# =============================================================== +# Welcome to repl.rb +# =============================================================== +# You can experiement with code within this file. Code in this +# file is only executed when you save (and only excecuted ONCE). +# =============================================================== + +# =============================================================== +# REMOVE the "x" from the word "xrepl" and save the file to RUN +# the code in between the do/end block delimiters. +# =============================================================== + +# =============================================================== +# ADD the "x" to the word "repl" (make it xrepl) and save the +# file to IGNORE the code in between the do/end block delimiters. +# =============================================================== + +# Remove the x from xrepl to run the code. Add the x back to ignore to code. +xrepl do + puts "The result of 1 + 2 is: #{1 + 2}" +end + +# ==================================================================================== +# Ruby Crash Course: +# Strings, Numeric, Booleans, Conditionals, Looping, Enumerables, Arrays +# ==================================================================================== + +# ==================================================================================== +# Strings +# ==================================================================================== +# Remove the x from xrepl to run the code. Add the x back to ignore to code. +xrepl do + message = "Hello World" + puts "The value of message is: " + message + puts "Any value can be interpolated within a string using \#{}." + puts "Interpolated message: #{message}." + puts 'This #{message} is not interpolated because the string uses single quotes.' +end + +# ==================================================================================== +# Numerics +# ==================================================================================== +# Remove the x from xrepl to run the code. Add the x back to ignore to code. +xrepl do + a = 10 + puts "The value of a is: #{a}" + puts "a + 1 is: #{a + 1}" + puts "a / 3 is: #{a / 3}" +end + +# Remove the x from xrepl to run the code. Add the x back to ignore to code. +xrepl do + b = 10.12 + puts "The value of b is: #{b}" + puts "b + 1 is: #{b + 1}" + puts "b as an integer is: #{b.to_i}" + puts '' +end + +# ==================================================================================== +# Booleans +# ==================================================================================== +# Remove the x from xrepl to run the code. Add the x back to ignore to code. +xrepl do + c = 30 + puts "The value of c is #{c}." + + if c + puts "This if statement ran because c is truthy." + end +end + +# Remove the x from xrepl to run the code. Add the x back to ignore to code. +xrepl do + d = false + puts "The value of d is #{d}." + + if !d + puts "This if statement ran because d is falsey, using the not operator (!) makes d evaluate to true." + end + + e = nil + puts "Nil is also considered falsey. The value of e is: #{e}." + + if !e + puts "This if statement ran because e is nil (a falsey value)." + end +end + +# ==================================================================================== +# Conditionals +# ==================================================================================== +# Remove the x from xrepl to run the code. Add the x back to ignore to code. +xrepl do + i_am_true = true + i_am_nil = nil + i_am_false = false + i_am_hi = "hi" + + puts "======== if statement" + i_am_one = 1 + if i_am_one + puts "This was printed because i_am_one is truthy." + end + + puts "======== if/else statement" + if i_am_false + puts "This will NOT get printed because i_am_false is false." + else + puts "This was printed because i_am_false is false." + end + + puts "======== if/elsif/else statement" + if i_am_false + puts "This will NOT get printed because i_am_false is false." + elsif i_am_true + puts "This was printed because i_am_true is true." + else + puts "This will NOT get printed i_am_true was true." + end + + puts "======== case statement " + i_am_one = 1 + case i_am_one + when 10 + puts "case equaled: 10" + when 9 + puts "case equaled: 9" + when 5 + puts "case equaled: 5" + when 1 + puts "case equaled: 1" + else + puts "Value wasn't cased." + end + + puts "======== different types of comparisons" + if 4 == 4 + puts "equal (4 == 4)" + end + + if 4 != 3 + puts "not equal (4 != 3)" + end + + if 3 < 4 + puts "less than (3 < 4)" + end + + if 4 > 3 + puts "greater than (4 > 3)" + end + + if ((4 > 3) || (3 < 4) || false) + puts "or statement ((4 > 3) || (3 < 4) || false)" + end + + if ((4 > 3) && (3 < 4)) + puts "and statement ((4 > 3) && (3 < 4))" + end +end + +# ==================================================================================== +# Looping +# ==================================================================================== +# Remove the x from xrepl to run the code. Add the x back to ignore to code. +xrepl do + puts "======== times block" + 3.times do |i| + puts i + end + puts "======== range block exclusive" + (0...3).each do |i| + puts i + end + puts "======== range block inclusive" + (0..3).each do |i| + puts i + end +end + +# ==================================================================================== +# Enumerables +# ==================================================================================== +# Remove the x from xrepl to run the code. Add the x back to ignore to code. +xrepl do + puts "======== array each" + colors = ["red", "blue", "yellow"] + colors.each do |color| + puts color + end + + puts '======== array each_with_index' + colors = ["red", "blue", "yellow"] + colors.each_with_index do |color, i| + puts "#{color} at index #{i}" + end +end + +# Remove the x from xrepl to run the code. Add the x back to ignore to code. +xrepl do + puts "======== single parameter function" + def add_one_to n + n + 5 + end + + puts add_one_to(3) + + puts "======== function with default value" + def function_with_default_value v = 10 + v * 10 + end + + puts "passing three: #{function_with_default_value(3)}" + puts "passing nil: #{function_with_default_value}" + + puts "======== Or Equal (||=) operator for nil values" + def function_with_nil_default_with_local a = nil + result = a + result ||= "or equal operator was exected and set a default value" + end + + puts "passing 'hi': #{function_with_nil_default_with_local 'hi'}" + puts "passing nil: #{function_with_nil_default_with_local}" +end + +# ==================================================================================== +# Arrays +# ==================================================================================== +# Remove the x from xrepl to run the code. Add the x back to ignore to code. +xrepl do + puts "======== Create an array with the numbers 1 to 10." + one_to_ten = (1..10).to_a + puts one_to_ten + + puts "======== Create a new array that only contains even numbers from the previous array." + one_to_ten = (1..10).to_a + evens = one_to_ten.find_all do |number| + number % 2 == 0 + end + puts evens + + puts "======== Create a new array that rejects odd numbers." + one_to_ten = (1..10).to_a + also_even = one_to_ten.reject do |number| + number % 2 != 0 + end + puts also_even + + puts "======== Create an array that doubles every number." + one_to_ten = (1..10).to_a + doubled = one_to_ten.map do |number| + number * 2 + end + puts doubled + + puts "======== Create an array that selects only odd numbers and then multiply those by 10." + one_to_ten = (1..10).to_a + odd_doubled = one_to_ten.find_all do |number| + number % 2 != 0 + end.map do |odd_number| + odd_number * 10 + end + puts odd_doubled + + puts "======== All combination of numbers 1 to 10." + one_to_ten = (1..10).to_a + all_combinations = one_to_ten.product(one_to_ten) + puts all_combinations + + puts "======== All uniq combinations of numbers. For example: [1, 2] is the same as [2, 1]." + one_to_ten = (1..10).to_a + uniq_combinations = + one_to_ten.product(one_to_ten) + .map do |unsorted_number| + unsorted_number.sort + end.uniq + puts uniq_combinations +end + +# ==================================================================================== +# Advanced Arrays +# ==================================================================================== +# Remove the x from xrepl to run the code. Add the x back to ignore to code. +xrepl do + puts "======== All unique Pythagorean Triples between 1 and 40 sorted by area of the triangle." + + one_to_hundred = (1..40).to_a + triples = + one_to_hundred.product(one_to_hundred).map do |width, height| + [width, height, Math.sqrt(width ** 2 + height ** 2)] + end.find_all do |_, _, hypotenuse| + hypotenuse.to_i == hypotenuse + end.map do |triangle| + triangle.map(&:to_i) + end.uniq do |triangle| + triangle.sort + end.map do |width, height, hypotenuse| + [width, height, hypotenuse, (width * height) / 2] + end.sort_by do |_, _, _, area| + area + end + + triples.each do |width, height, hypotenuse, area| + puts "(#{width}, #{height}, #{hypotenuse}) = #{area}" + end +end diff --git a/samples/99_genre_crafting/farming_game_starting_point/app/tests.rb b/samples/99_genre_crafting/farming_game_starting_point/app/tests.rb new file mode 100644 index 0000000..458bc18 --- /dev/null +++ b/samples/99_genre_crafting/farming_game_starting_point/app/tests.rb @@ -0,0 +1,29 @@ +# For advanced users: +# You can put some quick verification tests here, any method +# that starts with the `test_` will be run when you save this file. + +# Here is an example test and game + +# To run the test: ./dragonruby mygame --eval app/tests.rb --no-tick + +class MySuperHappyFunGame + attr_gtk + + def tick + outputs.solids << [100, 100, 300, 300] + end +end + +def test_universe args, assert + game = MySuperHappyFunGame.new + game.args = args + game.tick + assert.true! args.outputs.solids.length == 1, "failure: a solid was not added after tick" + assert.false! 1 == 2, "failure: some how, 1 equals 2, the world is ending" + puts "test_universe completed successfully" +end + +puts "running tests" +$gtk.reset 100 +$gtk.log_level = :off +$gtk.tests.start diff --git a/samples/99_genre_crafting/farming_game_starting_point/sprites/background.png b/samples/99_genre_crafting/farming_game_starting_point/sprites/background.png new file mode 100644 index 0000000..dbda37e Binary files /dev/null and b/samples/99_genre_crafting/farming_game_starting_point/sprites/background.png differ diff --git a/samples/99_genre_dev_tools/animation_creator_starting_point/app/main.rb b/samples/99_genre_dev_tools/animation_creator_starting_point/app/main.rb index 14456e3..b80e4b8 100644 --- a/samples/99_genre_dev_tools/animation_creator_starting_point/app/main.rb +++ b/samples/99_genre_dev_tools/animation_creator_starting_point/app/main.rb @@ -72,24 +72,22 @@ class OneBitLowrezPaint end def render_instructions - instructions = <<-S -* Instructions: -- All data is stored in the ~canvas~ directory. -- Hold ~d~ to set the edit mode to erase. -- Release ~d~ to set the edit mode drawing. -- Press ~a~ to added a frame to the end. -- Press ~b~ to select the previous frame. -- Press ~f~ to select the next frame. -- Press ~c~ to copy a frame. -- Press ~v~ to paste a copied frame into the selected frame. -- Press ~x~ to delete the currently selected frame. -- Press ~w~ to save the canvas and export all sprites. -- Press ~l~ to load the canvas. -S - - instructions.strip.each_line.with_index do |l, i| + instructions = [ + "* Hotkeys:", + "- d: hold to erase, release to draw.", + "- a: add frame.", + "- c: copy frame.", + "- v: paste frame.", + "- x: delete frame.", + "- b: go to previous frame.", + "- f: go to next frame.", + "- w: save to ./canvas directory.", + "- l: load from ./canvas." + ] + + instructions.each.with_index do |l, i| outputs.labels << { x: 840, y: 500 - (i * 20), text: "#{l}", - r: 180, g: 180, b: 180, size_enum: -3 } + r: 180, g: 180, b: 180, size_enum: 0 } end end @@ -103,12 +101,12 @@ S label = { x: b.x + state.buttons_frame_selection.size.half, y: b.y, text: "#{i + 1}", r: 180, g: 180, b: 180, - size_enum: -4, alignment_enum: 1 }.label + size_enum: -4, alignment_enum: 1 }.label! - selection_border = b.merge(r: 40, g: 40, b: 40).border + selection_border = b.merge(r: 40, g: 40, b: 40).border! if i == state.animation_frames_selected_index - selection_border = b.merge(r: 40, g: 230, b: 200).border + selection_border = b.merge(r: 40, g: 230, b: 200).border! end [selection_border, label] diff --git a/samples/99_genre_dev_tools/tile_editor_starting_point/app/main.rb b/samples/99_genre_dev_tools/tile_editor_starting_point/app/main.rb index 4238fcd..95ccfdf 100644 --- a/samples/99_genre_dev_tools/tile_editor_starting_point/app/main.rb +++ b/samples/99_genre_dev_tools/tile_editor_starting_point/app/main.rb @@ -17,15 +17,19 @@ - args.outputs.labels: An array. The values generate a label. The parameters are [X, Y, TEXT, SIZE, ALIGNMENT, RED, GREEN, BLUE, ALPHA, FONT STYLE] + For more information about labels, go to mygame/documentation/02-labels.md. - args.outputs.sprites: An array. The values generate a sprite. The parameters are [X, Y, WIDTH, HEIGHT, IMAGE PATH] + For more information about sprites, go to mygame/documentation/05-sprites.md. - args.outputs.solids: An array. The values generate a solid. The parameters are [X, Y, WIDTH, HEIGHT, RED, GREEN, BLUE] + For more information about solids, go to mygame/documentation/03-solids-and-borders.md. - args.outputs.lines: An array. The values generate a line. The parameters are [X1, Y1, X2, Y2, RED, GREEN, BLUE] + For more information about lines, go to mygame/documentation/04-lines.md. - args.state.new_entity: Used when we want to create a new object, like a sprite or button. In this sample app, new_entity is used to create a new button that clears the grid. diff --git a/samples/99_genre_dungeon_crawl/classics_jam/app/main.rb b/samples/99_genre_dungeon_crawl/classics_jam/app/main.rb new file mode 100644 index 0000000..d14b50e --- /dev/null +++ b/samples/99_genre_dungeon_crawl/classics_jam/app/main.rb @@ -0,0 +1,213 @@ +class Game + attr_gtk + + def tick + defaults + render + input + calc + end + + def defaults + player.x ||= 640 + player.y ||= 360 + player.w ||= 16 + player.h ||= 16 + player.attacked_at ||= -1 + player.angle ||= 0 + player.future_player ||= future_player_position 0, 0 + player.projectiles ||= [] + player.damage ||= 0 + state.level ||= create_level level_one_template + end + + def render + outputs.sprites << level.walls.map do |w| + w.merge(path: 'sprites/square/gray.png') + end + + outputs.sprites << level.spawn_locations.map do |s| + s.merge(path: 'sprites/square/blue.png') + end + + outputs.sprites << player.projectiles.map do |p| + p.merge(path: 'sprites/square/blue.png') + end + + outputs.sprites << level.enemies.map do |e| + e.merge(path: 'sprites/square/red.png') + end + + outputs.sprites << player.merge(path: 'sprites/circle/green.png', angle: player.angle) + + outputs.labels << { x: 30, y: 30.from_top, text: "damage: #{player.damage || 0}" } + end + + def input + player.angle = inputs.directional_angle || player.angle + if inputs.controller_one.key_down.a || inputs.keyboard.key_down.space + player.attacked_at = state.tick_count + end + end + + def calc + calc_player + calc_projectiles + calc_enemies + calc_spawn_locations + end + + def calc_player + if player.attacked_at == state.tick_count + player.projectiles << { at: state.tick_count, + x: player.x, + y: player.y, + angle: player.angle, + w: 4, + h: 4 }.center_inside_rect(player) + end + + if player.attacked_at.elapsed_time > 5 + future_player = future_player_position inputs.left_right * 2, inputs.up_down * 2 + future_player_collision = future_collision player, future_player, level.walls + player.x = future_player_collision.x if !future_player_collision.dx_collision + player.y = future_player_collision.y if !future_player_collision.dy_collision + end + end + + def calc_projectile_collisions entities + entities.each do |e| + e.damage ||= 0 + player.projectiles.each do |p| + if !p.collided && (p.intersect_rect? e) + p.collided = true + e.damage += 1 + end + end + end + end + + def calc_projectiles + player.projectiles.map! do |p| + dx, dy = p.angle.vector 10 + p.merge(x: p.x + dx, y: p.y + dy) + end + + calc_projectile_collisions level.walls + level.enemies + level.spawn_locations + player.projectiles.reject! { |p| p.at.elapsed_time > 10000 } + player.projectiles.reject! { |p| p.collided } + level.enemies.reject! { |e| e.damage > e.hp } + level.spawn_locations.reject! { |s| s.damage > s.hp } + end + + def calc_enemies + level.enemies.map! do |e| + dx = 0 + dx = 1 if e.x < player.x + dx = -1 if e.x > player.x + dy = 0 + dy = 1 if e.y < player.y + dy = -1 if e.y > player.y + future_e = future_entity_position dx, dy, e + future_e_collision = future_collision e, future_e, level.enemies + level.walls + e.next_x = e.x + e.next_y = e.y + e.next_x = future_e_collision.x if !future_e_collision.dx_collision + e.next_y = future_e_collision.y if !future_e_collision.dy_collision + e + end + + level.enemies.map! do |e| + e.x = e.next_x + e.y = e.next_y + e + end + + level.enemies.each do |e| + player.damage += 1 if e.intersect_rect? player + end + end + + def calc_spawn_locations + level.spawn_locations.map! do |s| + s.merge(countdown: s.countdown - 1) + end + level.spawn_locations + .find_all { |s| s.countdown.neg? } + .each do |s| + s.countdown = s.rate + s.merge(countdown: s.rate) + new_enemy = create_enemy s + if !(level.enemies.find { |e| e.intersect_rect? new_enemy }) + level.enemies << new_enemy + end + end + end + + def create_enemy spawn_location + to_cell(spawn_location.ordinal_x, spawn_location.ordinal_y).merge hp: 2 + end + + def create_level level_template + { + walls: level_template.walls.map { |w| to_cell(w.ordinal_x, w.ordinal_y).merge(w) }, + enemies: [], + spawn_locations: level_template.spawn_locations.map { |s| to_cell(s.ordinal_x, s.ordinal_y).merge(s) } + } + end + + def level_one_template + { + walls: [{ ordinal_x: 25, ordinal_y: 20}, + { ordinal_x: 25, ordinal_y: 21}, + { ordinal_x: 25, ordinal_y: 22}, + { ordinal_x: 25, ordinal_y: 23}], + spawn_locations: [{ ordinal_x: 10, ordinal_y: 10, rate: 120, countdown: 0, hp: 5 }] + } + end + + def player + state.player ||= {} + end + + def level + state.level ||= {} + end + + def future_collision entity, future_entity, others + dx_collision = others.find { |o| o != entity && (o.intersect_rect? future_entity.dx) } + dy_collision = others.find { |o| o != entity && (o.intersect_rect? future_entity.dy) } + + { + dx_collision: dx_collision, + x: future_entity.dx.x, + dy_collision: dy_collision, + y: future_entity.dy.y + } + end + + def future_entity_position dx, dy, entity + { + dx: entity.merge(x: entity.x + dx), + dy: entity.merge(y: entity.y + dy), + both: entity.merge(x: entity.x + dx, y: entity.y + dy) + } + end + + def future_player_position dx, dy + future_entity_position dx, dy, player + end + + def to_cell ordinal_x, ordinal_y + { x: ordinal_x * 16, y: ordinal_y * 16, w: 16, h: 16 } + end +end + +def tick args + $game ||= Game.new + $game.args = args + $game.tick +end + +$gtk.reset +$game = nil diff --git a/samples/99_genre_dungeon_crawl/classics_jam/sprites/circle/green.png b/samples/99_genre_dungeon_crawl/classics_jam/sprites/circle/green.png new file mode 100644 index 0000000..43cf7ee Binary files /dev/null and b/samples/99_genre_dungeon_crawl/classics_jam/sprites/circle/green.png differ diff --git a/samples/99_genre_dungeon_crawl/classics_jam/sprites/square/blue.png b/samples/99_genre_dungeon_crawl/classics_jam/sprites/square/blue.png new file mode 100644 index 0000000..b840849 Binary files /dev/null and b/samples/99_genre_dungeon_crawl/classics_jam/sprites/square/blue.png differ diff --git a/samples/99_genre_dungeon_crawl/classics_jam/sprites/square/gray.png b/samples/99_genre_dungeon_crawl/classics_jam/sprites/square/gray.png new file mode 100644 index 0000000..2142b30 Binary files /dev/null and b/samples/99_genre_dungeon_crawl/classics_jam/sprites/square/gray.png differ diff --git a/samples/99_genre_dungeon_crawl/classics_jam/sprites/square/red.png b/samples/99_genre_dungeon_crawl/classics_jam/sprites/square/red.png new file mode 100644 index 0000000..3ed5f13 Binary files /dev/null and b/samples/99_genre_dungeon_crawl/classics_jam/sprites/square/red.png differ diff --git a/samples/99_genre_fighting/01_special_move_inputs/app/main.rb b/samples/99_genre_fighting/01_special_move_inputs/app/main.rb new file mode 100644 index 0000000..5db1951 --- /dev/null +++ b/samples/99_genre_fighting/01_special_move_inputs/app/main.rb @@ -0,0 +1,297 @@ +def tick args + #tick_instructions args, "Use LEFT and RIGHT arrow keys to move and SPACE to jump." + defaults args + render args + input args + calc args +end + +# sets default values and creates empty collections +# initialization only happens in the first frame +def defaults args + fiddle args + + args.state.tick_count = args.state.tick_count + args.state.bridge_top = 128 + args.state.player.x ||= 0 # initializes player's properties + args.state.player.y ||= args.state.bridge_top + args.state.player.w ||= 64 + args.state.player.h ||= 64 + args.state.player.dy ||= 0 + args.state.player.dx ||= 0 + args.state.player.r ||= 0 + args.state.game_over_at ||= 0 + args.state.animation_time ||=0 + + args.state.timeleft ||=0 + args.state.timeright ||=0 + args.state.lastpush ||=0 + + args.state.inputlist ||= ["j","k","l"] +end + +# sets enemy, player, hammer values +def fiddle args + args.state.gravity = -0.5 + args.state.player_jump_power = 10 # sets player values + args.state.player_jump_power_duration = 5 + args.state.player_max_run_speed = 20 + args.state.player_speed_slowdown_rate = 0.9 + args.state.player_acceleration = 0.9 +end + +# outputs objects onto the screen +def render args + if (args.state.player.dx < 0.01) && (args.state.player.dx > -0.01) + args.state.player.dx = 0 + end + + #move list + (args.layout.rect_group row: 0, col_from_right: 8, drow: 0.3, + merge: { vertical_alignment_enum: 0, size_enum: -2 }, + group: [ + { text: "move: WASD" }, + { text: "jump: Space" }, + { text: "attack forwards: J (while on ground" }, + { text: "attack upwards: K (while on groud)" }, + { text: "attack backwards: J (while on ground and holding A)" }, + { text: "attack downwards: K (while in air)" }, + { text: "dash attack: J, K in quick succession." }, + { text: "shield: hold J, K at the same time." }, + { text: "dash backwards: A, A in quick succession." }, + ]).into args.outputs.labels + + # registered moves + args.outputs.labels << { x: 0.to_layout_col, + y: 0.to_layout_row, + text: "input history", + size_enum: -2, + vertical_alignment_enum: 0 } + + (args.state.inputlist.take(5)).map do |s| + { text: s, size_enum: -2, vertical_alignment_enum: 0 } + end.yield_self do |group| + (args.layout.rect_group row: 0.3, col: 0, drow: 0.3, group: group).into args.outputs.labels + end + + + #sprites + player = [args.state.player.x, args.state.player.y, + args.state.player.w, args.state.player.h, + "sprites/square/white.png", + args.state.player.r] + + playershield = [args.state.player.x - 20, args.state.player.y - 10, + args.state.player.w + 20, args.state.player.h + 20, + "sprites/square/blue.png", + args.state.player.r, + 0] + + playerjab = [args.state.player.x + 32, args.state.player.y, + args.state.player.w, args.state.player.h, + "sprites/isometric/indigo.png", + args.state.player.r, + 0] + + playerupper = [args.state.player.x, args.state.player.y + 32, + args.state.player.w, args.state.player.h, + "sprites/isometric/indigo.png", + args.state.player.r+90, + 0] + + if ((args.state.tick_count - args.state.lastpush) <= 15) + if (args.state.inputlist[0] == "<<") + player = [args.state.player.x, args.state.player.y, + args.state.player.w, args.state.player.h, + "sprites/square/yellow.png", args.state.player.r] + end + + if (args.state.inputlist[0] == "shield") + player = [args.state.player.x, args.state.player.y, + args.state.player.w, args.state.player.h, + "sprites/square/indigo.png", args.state.player.r] + + playershield = [args.state.player.x - 10, args.state.player.y - 10, + args.state.player.w + 20, args.state.player.h + 20, + "sprites/square/blue.png", args.state.player.r, 50] + end + + if (args.state.inputlist[0] == "back-attack") + playerjab = [args.state.player.x - 20, args.state.player.y, + args.state.player.w - 10, args.state.player.h, + "sprites/isometric/indigo.png", args.state.player.r, 255] + end + + if (args.state.inputlist[0] == "forward-attack") + playerjab = [args.state.player.x + 32, args.state.player.y, + args.state.player.w, args.state.player.h, + "sprites/isometric/indigo.png", args.state.player.r, 255] + end + + if (args.state.inputlist[0] == "up-attack") + playerupper = [args.state.player.x, args.state.player.y + 32, + args.state.player.w, args.state.player.h, + "sprites/isometric/indigo.png", args.state.player.r + 90, 255] + end + + if (args.state.inputlist[0] == "dair") + playerupper = [args.state.player.x, args.state.player.y - 32, + args.state.player.w, args.state.player.h, + "sprites/isometric/indigo.png", args.state.player.r + 90, 255] + end + + if (args.state.inputlist[0] == "dash-attack") + playerupper = [args.state.player.x, args.state.player.y + 32, + args.state.player.w, args.state.player.h, + "sprites/isometric/violet.png", args.state.player.r + 90, 255] + + playerjab = [args.state.player.x + 32, args.state.player.y, + args.state.player.w, args.state.player.h, + "sprites/isometric/violet.png", args.state.player.r, 255] + end + end + + args.outputs.sprites << playerjab + args.outputs.sprites << playerupper + args.outputs.sprites << player + args.outputs.sprites << playershield + + args.outputs.solids << 20.map_with_index do |i| # uses 20 squares to form bridge + [i * 64, args.state.bridge_top - 64, 64, 64] + end +end + +# Performs calculations to move objects on the screen +def calc args + # Since velocity is the change in position, the change in x increases by dx. Same with y and dy. + args.state.player.x += args.state.player.dx + args.state.player.y += args.state.player.dy + + # Since acceleration is the change in velocity, the change in y (dy) increases every frame + args.state.player.dy += args.state.gravity + + # player's y position is either current y position or y position of top of + # bridge, whichever has a greater value + # ensures that the player never goes below the bridge + args.state.player.y = args.state.player.y.greater(args.state.bridge_top) + + # player's x position is either the current x position or 0, whichever has a greater value + # ensures that the player doesn't go too far left (out of the screen's scope) + args.state.player.x = args.state.player.x.greater(0) + + # player is not falling if it is located on the top of the bridge + args.state.player.falling = false if args.state.player.y == args.state.bridge_top + #args.state.player.rect = [args.state.player.x, args.state.player.y, args.state.player.h, args.state.player.w] # sets definition for player +end + +# Resets the player by changing its properties back to the values they had at initialization +def reset_player args + args.state.player.x = 0 + args.state.player.y = args.state.bridge_top + args.state.player.dy = 0 + args.state.player.dx = 0 + args.state.enemy.hammers.clear # empties hammer collection + args.state.enemy.hammer_queue.clear # empties hammer_queue + args.state.game_over_at = args.state.tick_count # game_over_at set to current frame (or passage of time) +end + +# Processes input from the user to move the player +def input args + if args.state.inputlist.length > 5 + args.state.inputlist.pop + end + + should_process_special_move = (args.inputs.keyboard.key_down.j) || + (args.inputs.keyboard.key_down.k) || + (args.inputs.keyboard.key_down.a) || + (args.inputs.keyboard.key_down.d) || + (args.inputs.controller_one.key_down.y) || + (args.inputs.controller_one.key_down.x) || + (args.inputs.controller_one.key_down.left) || + (args.inputs.controller_one.key_down.right) + + if (should_process_special_move) + if (args.inputs.keyboard.key_down.j && args.inputs.keyboard.key_down.k) || + (args.inputs.controller_one.key_down.x && args.inputs.controller_one.key_down.y) + args.state.inputlist.unshift("shield") + elsif (args.inputs.keyboard.key_down.k || args.inputs.controller_one.key_down.y) && + (args.state.inputlist[0] == "forward-attack") && ((args.state.tick_count - args.state.lastpush) <= 15) + args.state.inputlist.unshift("dash-attack") + args.state.player.dx = 20 + elsif (args.inputs.keyboard.key_down.j && args.inputs.keyboard.a) || + (args.inputs.controller_one.key_down.x && args.inputs.controller_one.key_down.left) + args.state.inputlist.unshift("back-attack") + elsif ( args.inputs.controller_one.key_down.x || args.inputs.keyboard.key_down.j) + args.state.inputlist.unshift("forward-attack") + elsif (args.inputs.keyboard.key_down.k || args.inputs.controller_one.key_down.y) && + (args.state.player.y > 128) + args.state.inputlist.unshift("dair") + elsif (args.inputs.keyboard.key_down.k || args.inputs.controller_one.key_down.y) + args.state.inputlist.unshift("up-attack") + elsif (args.inputs.controller_one.key_down.left || args.inputs.keyboard.key_down.a) && + (args.state.inputlist[0] == "<") && + ((args.state.tick_count - args.state.lastpush) <= 10) + args.state.inputlist.unshift("<<") + args.state.player.dx = -15 + elsif (args.inputs.controller_one.key_down.left || args.inputs.keyboard.key_down.a) + args.state.inputlist.unshift("<") + args.state.timeleft = args.state.tick_count + elsif (args.inputs.controller_one.key_down.right || args.inputs.keyboard.key_down.d) + args.state.inputlist.unshift(">") + end + + args.state.lastpush = args.state.tick_count + end + + if args.inputs.keyboard.space || args.inputs.controller_one.r2 # if the user presses the space bar + args.state.player.jumped_at ||= args.state.tick_count # jumped_at is set to current frame + + # if the time that has passed since the jump is less than the player's jump duration and + # the player is not falling + if args.state.player.jumped_at.elapsed_time < args.state.player_jump_power_duration && !args.state.player.falling + args.state.player.dy = args.state.player_jump_power # change in y is set to power of player's jump + end + end + + # if the space bar is in the "up" state (or not being pressed down) + if args.inputs.keyboard.key_up.space || args.inputs.controller_one.key_up.r2 + args.state.player.jumped_at = nil # jumped_at is empty + args.state.player.falling = true # the player is falling + end + + if args.inputs.left # if left key is pressed + if args.state.player.dx < -5 + args.state.player.dx = args.state.player.dx + else + args.state.player.dx = -5 + end + + elsif args.inputs.right # if right key is pressed + if args.state.player.dx > 5 + args.state.player.dx = args.state.player.dx + else + args.state.player.dx = 5 + end + else + args.state.player.dx *= args.state.player_speed_slowdown_rate # dx is scaled down + end + + if ((args.state.player.dx).abs > 5) #&& ((args.state.tick_count - args.state.lastpush) <= 10) + args.state.player.dx *= 0.95 + end +end + +def tick_instructions args, text, y = 715 + return if args.state.key_event_occurred + if args.inputs.mouse.click || + args.inputs.keyboard.directional_vector || + args.inputs.keyboard.key_down.enter || + args.inputs.keyboard.key_down.space || + args.inputs.keyboard.key_down.escape + args.state.key_event_occurred = true + end + + args.outputs.debug << [0, y - 50, 1280, 60].solid + args.outputs.debug << [640, y, text, 1, 1, 255, 255, 255].label + args.outputs.debug << [640, y - 25, "(click to dismiss instructions)" , -2, 1, 255, 255, 255].label +end diff --git a/samples/99_genre_fighting/01_special_move_inputs/sprites/isometric/indigo.png b/samples/99_genre_fighting/01_special_move_inputs/sprites/isometric/indigo.png new file mode 100644 index 0000000..e6be50c Binary files /dev/null and b/samples/99_genre_fighting/01_special_move_inputs/sprites/isometric/indigo.png differ diff --git a/samples/99_genre_fighting/01_special_move_inputs/sprites/isometric/violet.png b/samples/99_genre_fighting/01_special_move_inputs/sprites/isometric/violet.png new file mode 100644 index 0000000..f09bf21 Binary files /dev/null and b/samples/99_genre_fighting/01_special_move_inputs/sprites/isometric/violet.png differ diff --git a/samples/99_genre_fighting/01_special_move_inputs/sprites/square/blue.png b/samples/99_genre_fighting/01_special_move_inputs/sprites/square/blue.png new file mode 100644 index 0000000..b840849 Binary files /dev/null and b/samples/99_genre_fighting/01_special_move_inputs/sprites/square/blue.png differ diff --git a/samples/99_genre_fighting/01_special_move_inputs/sprites/square/indigo.png b/samples/99_genre_fighting/01_special_move_inputs/sprites/square/indigo.png new file mode 100644 index 0000000..2384108 Binary files /dev/null and b/samples/99_genre_fighting/01_special_move_inputs/sprites/square/indigo.png differ diff --git a/samples/99_genre_fighting/01_special_move_inputs/sprites/square/white.png b/samples/99_genre_fighting/01_special_move_inputs/sprites/square/white.png new file mode 100644 index 0000000..378c565 Binary files /dev/null and b/samples/99_genre_fighting/01_special_move_inputs/sprites/square/white.png differ diff --git a/samples/99_genre_fighting/01_special_move_inputs/sprites/square/yellow.png b/samples/99_genre_fighting/01_special_move_inputs/sprites/square/yellow.png new file mode 100644 index 0000000..0edeeec Binary files /dev/null and b/samples/99_genre_fighting/01_special_move_inputs/sprites/square/yellow.png differ diff --git a/samples/99_genre_lowrez/nokia_3310/app/main.rb b/samples/99_genre_lowrez/nokia_3310/app/main.rb index 683539e..7aa6ba5 100644 --- a/samples/99_genre_lowrez/nokia_3310/app/main.rb +++ b/samples/99_genre_lowrez/nokia_3310/app/main.rb @@ -67,7 +67,7 @@ def tick args # ======================================================================= - # ==== HOW TO ANIMATE A SPRITE (SEPARATE PNGS) ========================== + # ==== HOW TO ANIMATE A SPRITE (SEPERATE PNGS) ========================== # ======================================================================= # Remove the "#" at the beginning of the line below # how_to_animate_a_sprite args @@ -248,7 +248,7 @@ def how_to_render_sprites args end # ============================================================================= -# ==== HOW TO ANIMATE A SPRITE (SEPARATE PNGS) ========================== +# ==== HOW TO ANIMATE A SPRITE (SEPERATE PNGS) ========================== # ============================================================================= def how_to_animate_a_sprite args # STEP 1: Define when you want the animation to start. The animation in this case will start in 3 seconds @@ -472,7 +472,7 @@ def how_to_determine_collision args text: "Collision!", alignment_enum: 1) else - # if no collision occurred, render the words no collision. + # if collision occurred, render the words no collision. args.nokia.labels << args.nokia .default_label .merge(x: 42, @@ -605,7 +605,7 @@ def render_debug args text: text, size_enum: -1.5, r: 255, g: 255, b: 255 - }.label + }.label! end args.outputs.debug << { @@ -615,7 +615,7 @@ def render_debug args size_enum: -0.5, alignment_enum: 1, r: 255, g: 255, b: 255 - }.label + }.label! end def snake_demo args diff --git a/samples/99_genre_lowrez/nokia_3310/app/nokia.rb b/samples/99_genre_lowrez/nokia_3310/app/nokia.rb index 077e36f..7bcb5b1 100644 --- a/samples/99_genre_lowrez/nokia_3310/app/nokia.rb +++ b/samples/99_genre_lowrez/nokia_3310/app/nokia.rb @@ -236,7 +236,7 @@ module GTK g: 240, b: 216, a: 100 - }.line + }.line! end (NOKIA_WIDTH + 1).map_with_index do |i| @@ -249,7 +249,7 @@ module GTK g: 240, b: 216, a: 100 - }.line + }.line! end @args.state.overlay_rendered = true diff --git a/samples/99_genre_lowrez/resolution_64x64/app/main.rb b/samples/99_genre_lowrez/resolution_64x64/app/main.rb index 9208120..4b1614d 100644 --- a/samples/99_genre_lowrez/resolution_64x64/app/main.rb +++ b/samples/99_genre_lowrez/resolution_64x64/app/main.rb @@ -62,7 +62,7 @@ def tick args # ======================================================================= - # ==== HOW TO ANIMATE A SPRITE (SEPARATE PNGS) ========================== + # ==== HOW TO ANIMATE A SPRITE (SEPERATE PNGS) ========================== # Remove the "#" at the beginning of the line below # how_to_animate_a_sprite args # ======================================================================= @@ -242,7 +242,7 @@ def how_to_render_sprites args end ## # ============================================================================= -## # ==== HOW TO ANIMATE A SPRITE (SEPARATE PNGS) ========================== +## # ==== HOW TO ANIMATE A SPRITE (SEPERATE PNGS) ========================== ## # ============================================================================= def how_to_animate_a_sprite args # STEP 1: Define when you want the animation to start. The animation in this case will start in 3 seconds @@ -462,7 +462,7 @@ def how_to_determine_collision args text: "Collision!", alignment_enum: 1) else - # if no collision occurred, render the words no collision. + # if collision occurred, render the words no collision. args.lowrez.labels << args.lowrez .default_label .merge(x: 31, @@ -560,7 +560,7 @@ def render_debug args g: 128, b: 128, a: 80 - }.line + }.line! args.outputs.static_debug << { x: LOWREZ_X_OFFSET + (i * 10), @@ -571,7 +571,7 @@ def render_debug args g: 128, b: 128, a: 80 - }.line + }.line! end end @@ -598,7 +598,7 @@ def render_debug args y: 720 - (i * 20), text: text, size_enum: -1.5 - }.label + }.label! end args.outputs.debug << { @@ -607,7 +607,7 @@ def render_debug args text: "INFO: dev mode is currently enabled. Comment out the invocation of ~render_debug~ within the ~tick~ method to hide the debug layer.", size_enum: -0.5, alignment_enum: 1 - }.label + }.label! end $gtk.reset diff --git a/samples/99_genre_platformer/clepto_frog/app/main.rb b/samples/99_genre_platformer/clepto_frog/app/main.rb index e1ddffb..a4eb069 100644 --- a/samples/99_genre_platformer/clepto_frog/app/main.rb +++ b/samples/99_genre_platformer/clepto_frog/app/main.rb @@ -485,7 +485,7 @@ class CleptoFrog return if state.world_lookup.keys.length > 0 return unless state.world.length > 0 - # Searches through the world and finds the coordinates that exist + # Searches through the world and finds the cordinates that exist state.world_lookup = {} state.world.each do |x, y, w, h| state.world_lookup[[x, y, w || state.tile_size, h || state.tile_size]] = true diff --git a/samples/99_genre_platformer/gorillas_basic/app/repl.rb b/samples/99_genre_platformer/gorillas_basic/app/repl.rb deleted file mode 100644 index 4428c4b..0000000 --- a/samples/99_genre_platformer/gorillas_basic/app/repl.rb +++ /dev/null @@ -1,17 +0,0 @@ -begin - if $gtk.args.state.current_turn == :player_1_angle - $gtk.args.state.player_1_angle = "#{60 + 10.randomize(:ratio).to_i}" - $you_so_basic_gorillas.input_execute_turn - $gtk.args.state.player_1_velocity = "#{30 + 20.randomize(:ratio).to_i}" - $you_so_basic_gorillas.input_execute_turn - elsif $gtk.args.state.current_turn == :player_2_angle - $gtk.args.state.player_2_angle = "#{60 + 10.randomize(:ratio).to_i}" - $you_so_basic_gorillas.input_execute_turn - $gtk.args.state.player_2_velocity = "#{30 + 20.randomize(:ratio).to_i}" - $you_so_basic_gorillas.input_execute_turn - else - $you_so_basic_gorillas.input_execute_turn - end -rescue Exception => e - puts e -end diff --git a/samples/99_genre_platformer/the_little_probe/app/main.rb b/samples/99_genre_platformer/the_little_probe/app/main.rb index 5c0ce61..8fcf279 100644 --- a/samples/99_genre_platformer/the_little_probe/app/main.rb +++ b/samples/99_genre_platformer/the_little_probe/app/main.rb @@ -33,7 +33,7 @@ class FallingCircle { text: "mission control, this is sasha. landing on europa successful.", distance_gate: 0 }, { text: "operation \"find earth 2.0\", initiated at 8-29-2036 14:00.", distance_gate: 0 }, { text: "jupiter's sure is beautiful...", distance_gate: 4000 }, - { text: "hmm, it seems there's some kind of anomaly in the sky", distance_gate: 7000 }, + { text: "hmm, it seems there's some kind of anomoly in the sky", distance_gate: 7000 }, { text: "dancing lights, i'll call them whisps.", distance_gate: 8000 }, { text: "#todo... look i ran out of time -_-", distance_gate: 9000 }, { text: "there's never enough time", distance_gate: 9000 }, diff --git a/samples/99_genre_rpg_narrative/choose_your_own_adventure/app/decision.rb b/samples/99_genre_rpg_narrative/choose_your_own_adventure/app/decision.rb index 0d23668..2921076 100644 --- a/samples/99_genre_rpg_narrative/choose_your_own_adventure/app/decision.rb +++ b/samples/99_genre_rpg_narrative/choose_your_own_adventure/app/decision.rb @@ -1,5 +1,5 @@ # Hey there! Welcome to Four Decisions. Here is how you -# create your decision tree. Remove =begin and =end from the text to +# create your decision tree. Remove =being and =end from the text to # enable the game (just save the file). Change stuff and see what happens! def game diff --git a/samples/99_genre_rpg_narrative/choose_your_own_adventure/app/main.rb b/samples/99_genre_rpg_narrative/choose_your_own_adventure/app/main.rb index 953b121..22faad1 100644 --- a/samples/99_genre_rpg_narrative/choose_your_own_adventure/app/main.rb +++ b/samples/99_genre_rpg_narrative/choose_your_own_adventure/app/main.rb @@ -14,8 +14,10 @@ - args.outputs.labels: An array. The values generate a label. The parameters are [X, Y, TEXT, SIZE, ALIGNMENT, RED, GREEN, BLUE, ALPHA, FONT STYLE] - + For more information about labels, go to mygame/documentation/02-labels.md. + - args.keyboard.key_down.KEY: Determines if a key is in the down state or pressed down. + For more information about the keyboard, go to mygame/documentation/06-keyboard.md. - String interpolation: uses #{} syntax; everything between the #{ and the } is evaluated as Ruby code, and the placeholder is replaced with its corresponding value or result. @@ -53,7 +55,7 @@ def tick args end end -# Runs methods needed for the game to function properly +# Runs methods needed for game to function properly # Creates a rectangular border around the screen def tick_game args defaults args diff --git a/samples/99_genre_rpg_narrative/return_of_serenity/app/repl.rb b/samples/99_genre_rpg_narrative/return_of_serenity/app/repl.rb deleted file mode 100644 index a59baf5..0000000 --- a/samples/99_genre_rpg_narrative/return_of_serenity/app/repl.rb +++ /dev/null @@ -1 +0,0 @@ -puts $gtk.args.state.current_scene diff --git a/samples/99_genre_rpg_narrative/return_of_serenity/app/storyline_anka.rb b/samples/99_genre_rpg_narrative/return_of_serenity/app/storyline_anka.rb index 8fc10b2..bad7795 100644 --- a/samples/99_genre_rpg_narrative/return_of_serenity/app/storyline_anka.rb +++ b/samples/99_genre_rpg_narrative/return_of_serenity/app/storyline_anka.rb @@ -43,7 +43,7 @@ end def reply_to_anka args decision_graph anka_current_reply(args), - "Matthew's-- wife is doing-- well. What's-- even-- better-- is that he's-- a dad, and he didn't-- even-- know it. Should- I- leave- out the part about-- the crew- being-- in hibernation-- for 20-- years? They- should- enter-- stasis-- on a high- note... Right?", + "Matthew's-- wife is doing-- well. What's-- even-- better-- is that he's-- a dad, and he didn't-- even-- know it. Should- I- leave- out the part about-- the crew- being-- in hibernation-- for 20-- years? They- should- enter-- statis-- on a high- note... Right?", [:replied_with_whole_truth, "Whole-- Truth--", anka_reply_whole_truth], [:replied_with_half_truth, "Half-- Truth--", anka_reply_half_truth] end @@ -57,7 +57,7 @@ def anka_last_reply args end def anka_reply_whole_truth - "Matthew's wife is doing-- very-- well. In fact, she was pregnant. Matthew-- is a dad. He has a son. But, I need- all-- of-- you-- to brace-- yourselves. You've-- been in stasis-- for 20 years. A lot has changed. Most of Earth's-- population--- didn't-- survive. Tell- Matthew-- that I'm-- sorry he didn't-- get to see- his- son grow- up." + "Matthew's wife is doing-- very-- well. In fact, she was pregnant. Matthew-- is a dad. He has a son. But, I need- all-- of-- you-- to brace-- yourselves. You've-- been in statis-- for 20 years. A lot has changed. Most of Earth's-- population--- didn't-- survive. Tell- Matthew-- that I'm-- sorry he didn't-- get to see- his- son grow- up." end def anka_reply_half_truth @@ -92,9 +92,9 @@ end def anka_current_reply args if args.state.scene_history.include? :replied_to_serenity_alive_firmly - return "Hello. This is, Aanka. Sasha-- is still- trying-- to gather-- her wits about-- her, given- the gravity--- of your- last- reply. Thank- you- for being-- honest, and thank- you- for the help- with the ship- diagnostics. I was able-- to retrieve-- all of the navigation--- information---- after-- the battery--- swap. We- are ready-- to head back to Earth. Before-- we go- back- into-- stasis, Matthew--- wanted-- to know- how his- wife- is doing. Please- reply-- as soon- as you can. He's-- not going-- to get- into-- the stasis-- chamber-- until-- he knows- his wife is okay." + return "Hello. This is, Aanka. Sasha-- is still- trying-- to gather-- her wits about-- her, given- the gravity--- of your- last- reply. Thank- you- for being-- honest, and thank- you- for the help- with the ship- diagnostics. I was able-- to retrieve-- all of the navigation--- information---- after-- the battery--- swap. We- are ready-- to head back to Earth. Before-- we go- back- into-- statis, Matthew--- wanted-- to know- how his- wife- is doing. Please- reply-- as soon- as you can. He's-- not going-- to get- into-- the statis-- chamber-- until-- he knows- his wife is okay." else - return "Hello. This is, Aanka. Thank- you for the help- with the ship's-- diagnostics. I was able-- to retrieve-- all of the navigation--- information--- after-- the battery-- swap. I- know-- that- you didn't-- tell- the whole truth- about-- how far we are from- Earth. Don't-- worry. I understand-- why you did it. We- are ready-- to head back to Earth. Before-- we go- back- into-- stasis, Matthew--- wanted-- to know- how his- wife- is doing. Please- reply-- as soon- as you can. He's-- not going-- to get- into-- the stasis-- chamber-- until-- he knows- his wife is okay." + return "Hello. This is, Aanka. Thank- you for the help- with the ship's-- diagnostics. I was able-- to retrieve-- all of the navigation--- information--- after-- the battery-- swap. I- know-- that- you didn't-- tell- the whole truth- about-- how far we are from- Earth. Don't-- worry. I understand-- why you did it. We- are ready-- to head back to Earth. Before-- we go- back- into-- statis, Matthew--- wanted-- to know- how his- wife- is doing. Please- reply-- as soon- as you can. He's-- not going-- to get- into-- the statis-- chamber-- until-- he knows- his wife is okay." end end diff --git a/samples/99_genre_rpg_narrative/return_of_serenity/app/storyline_day_one.rb b/samples/99_genre_rpg_narrative/return_of_serenity/app/storyline_day_one.rb index fb11c97..24b2b45 100644 --- a/samples/99_genre_rpg_narrative/return_of_serenity/app/storyline_day_one.rb +++ b/samples/99_genre_rpg_narrative/return_of_serenity/app/storyline_day_one.rb @@ -21,7 +21,7 @@ def day_one_infront_of_home args [0, 4, 3, 20, :day_one_ceremony] ], storylines: [ - [40, 20, 4, 4, "It looks like everyone- is already- at the remembrance-- ceremony."], + [40, 20, 4, 4, "It looks like everyone- is already- at the rememberance-- ceremony."], ] } end diff --git a/samples/99_genre_rpg_narrative/return_of_serenity/app/storyline_serenity_bio.rb b/samples/99_genre_rpg_narrative/return_of_serenity/app/storyline_serenity_bio.rb index ad7653d..587f5f4 100644 --- a/samples/99_genre_rpg_narrative/return_of_serenity/app/storyline_serenity_bio.rb +++ b/samples/99_genre_rpg_narrative/return_of_serenity/app/storyline_serenity_bio.rb @@ -57,13 +57,13 @@ def serenity_bio_book args [ 4, 50, 56, 4, "The Title-- Reads: Never-- Forget-- Mission-- Serenity---"], [ 4, 38, 8, 8, "Name: Matthew--- R. Sex: Male--- Age-- at-- Departure: 36-----"], - [14, 38, 46, 8, "Tribute-- Text: Matthew graduated-- Magna-- Cum-- Laude-- from MIT--- with-- a- PHD---- in Aero-- Nautical--- Engineering. He was immensely--- competitive, and had an insatiable---- thirst- for aerial-- battle. From the age of twenty, he remained-- undefeated--- in the Israeli-- Air- Force- \"Blue Flag\" combat-- exercises. By the age of 29--- he had already-- risen through- the ranks, and became-- the Lieutenant--- General--- of Lufwaffe. Matthew-- volunteered-- to- pilot-- Mission-- Serenity. To- this day, his wife- and son- are pillars-- of strength- for us. Rest- in Peace- Matthew, we are sorry-- that- news of the pregnancy-- never-- reached- you. Please forgive us."], + [14, 38, 46, 8, "Tribute-- Text: Matthew graduated-- Magna-- Cum-- Laude-- from MIT--- with-- a- PHD---- in Aero-- Nautical--- Engineering. He was immensely--- competitive, and had an insatiable---- thirst- for aerial-- battle. From the age of twenty, he remained-- undefeated--- in the Israeli-- Air- Force- \"Blue Flag\" combat-- exercises. By the age of 29--- he had already-- risen through- the ranks, and became-- the Lieutenant--- General--- of Lufwaffe. Matthew-- volenteered-- to- pilot-- Mission-- Serenity. To- this day, his wife- and son- are pillars-- of strength- for us. Rest- in Peace- Matthew, we are sorry-- that- news of the pregancy-- never-- reached- you. Please forgive us."], [4, 26, 8, 8, "Name: Aanka--- P. Sex: Female--- Age-- at-- Departure: 9-----"], - [14, 26, 46, 8, "Tribute-- Text: Aanka--- graduated--- Magna-- Cum- Laude-- from MIT, at- the- age- of eight, with a- PHD---- in Astro-- Physics. Her-- IQ--- was over 390, the highest-- ever- recorded--- IQ-- in- human-- history. She changed- the landscape-- of Physics-- with her efforts- in- unravelling--- the mysteries--- of- Dark- Matter--. Anka discovered-- the threat- of Halley's-- Comet-- collision--- with Earth. She spear headed-- the global-- effort-- for Mission-- Serenity. Her- multilingual--- address-- to- the world-- brought- us all hope."], + [14, 26, 46, 8, "Tribute-- Text: Aanka--- gratuated--- Magna-- Cum- Laude-- from MIT, at- the- age- of eight, with a- PHD---- in Astro-- Physics. Her-- IQ--- was over 390, the highest-- ever- recorded--- IQ-- in- human-- history. She changed- the landscape-- of Physics-- with her efforts- in- unravelling--- the mysteries--- of- Dark- Matter--. Anka discovered-- the threat- of Halley's-- Comet-- collision--- with Earth. She spear headed-- the global-- effort-- for Misson-- Serenity. Her- multilingual--- address-- to- the world-- brought- us all hope."], [4, 14, 8, 8, "Name: Sasha--- N. Sex: Female--- Age-- at-- Departure: 29-----"], - [14, 14, 46, 8, "Tribute-- Text: Sasha graduated-- Magna-- Cum- Laude-- from MIT--- with-- a- PHD---- in Computer---- Science----. She-- was-- brilliant--, strong- willed--, and-- a-- stunningly--- beautiful--- woman---. Sasha---- is- the- creator--- of the world's--- first- Ruby--- Quantum-- Machine---. After-- much- critical--- acclaim--, the Quantum-- Computer-- was placed in MIT's---- Museum-- next- to- Richard--- G. and Thomas--- K.'s---- Lisp-- Machine---. Her- engineering--- skills-- were-- paramount--- for Mission--- Serenity's--- success. Humanity-- misses-- you-- dearly,-- Sasha--. Life-- shines-- a dimmer-- light-- now- that- your- angelic- voice-- can never- be heard- again."], + [14, 14, 46, 8, "Tribute-- Text: Sasha gratuated-- Magna-- Cum- Laude-- from MIT--- with-- a- PHD---- in Computer---- Science----. She-- was-- brilliant--, strong- willed--, and-- a-- stunningly--- beautiful--- woman---. Sasha---- is- the- creator--- of the world's--- first- Ruby--- Quantum-- Machine---. After-- much- critical--- acclaim--, the Quantum-- Computer-- was placed in MIT's---- Museam-- next- to- Richard--- G. and Thomas--- K.'s---- Lisp-- Machine---. Her- engineering--- skills-- were-- paramount--- for Mission--- Serenity's--- success. Humanity-- misses-- you-- dearly,-- Sasha--. Life-- shines-- a dimmer-- light-- now- that- your- angelic- voice-- can never- be heard- again."], ], scenes: [ [*hotspot_bottom, :serenity_bio_finally_to_bed] diff --git a/samples/99_genre_rpg_roguelike/01_roguelike_starting_point/app/main.rb b/samples/99_genre_rpg_roguelike/01_roguelike_starting_point/app/main.rb index 15a381b..bd5f521 100644 --- a/samples/99_genre_rpg_roguelike/01_roguelike_starting_point/app/main.rb +++ b/samples/99_genre_rpg_roguelike/01_roguelike_starting_point/app/main.rb @@ -14,7 +14,7 @@ def tick_game args # set up your game # initialize the game/game defaults. ||= means that you only initialize it if - # the value isn't already initialized + # the value isn't alread initialized args.state.player.x ||= 0 args.state.player.y ||= 0 diff --git a/samples/99_genre_rpg_roguelike/01_roguelike_starting_point/app/sprite_lookup.rb b/samples/99_genre_rpg_roguelike/01_roguelike_starting_point/app/sprite_lookup.rb index 579e133..f129e25 100644 --- a/samples/99_genre_rpg_roguelike/01_roguelike_starting_point/app/sprite_lookup.rb +++ b/samples/99_genre_rpg_roguelike/01_roguelike_starting_point/app/sprite_lookup.rb @@ -97,7 +97,7 @@ def tile_extended x, y, w, h, r, g, b, a, tile_row_column_or_key if !row member_name = member_name_as_code tile_row_column_or_key - raise "Unable to find a sprite for #{member_name}. Make sure the value exists in app/sprite_lookup.rb." + raise "Unabled to find a sprite for #{member_name}. Make sure the value exists in app/sprite_lookup.rb." end # Sprite provided by Rogue Yun diff --git a/samples/99_genre_rpg_roguelike/02_roguelike_line_of_sight/app/main.rb b/samples/99_genre_rpg_roguelike/02_roguelike_line_of_sight/app/main.rb index c2c364b..66ff027 100644 --- a/samples/99_genre_rpg_roguelike/02_roguelike_line_of_sight/app/main.rb +++ b/samples/99_genre_rpg_roguelike/02_roguelike_line_of_sight/app/main.rb @@ -339,7 +339,7 @@ class Game state.enemies.find { |e| e.x == x && e.y == y && !e.is_dead } end - # Moves the user based on their keyboard input and sets values for target cell + #M oves the user based on their keyboard input and sets values for target cell def input_target_cell if inputs.keyboard.key_down.up # if "up" key is in "down" state [state.x, state.y + 1, 0, 1] # user moves up diff --git a/samples/99_genre_rpg_roguelike/roguelike_line_of_sight/app/constants.rb b/samples/99_genre_rpg_roguelike/roguelike_line_of_sight/app/constants.rb deleted file mode 100644 index 37dd493..0000000 --- a/samples/99_genre_rpg_roguelike/roguelike_line_of_sight/app/constants.rb +++ /dev/null @@ -1,8 +0,0 @@ -SHOW_LEGEND = true -SOURCE_TILE_SIZE = 16 -DESTINATION_TILE_SIZE = 16 -TILE_SHEET_SIZE = 256 -TILE_R = 0 -TILE_G = 0 -TILE_B = 0 -TILE_A = 255 diff --git a/samples/99_genre_rpg_roguelike/roguelike_line_of_sight/app/legend.rb b/samples/99_genre_rpg_roguelike/roguelike_line_of_sight/app/legend.rb deleted file mode 100644 index 4d07b79..0000000 --- a/samples/99_genre_rpg_roguelike/roguelike_line_of_sight/app/legend.rb +++ /dev/null @@ -1,65 +0,0 @@ -def tick_legend args - return unless SHOW_LEGEND - - legend_padding = 16 - legend_x = 1280 - TILE_SHEET_SIZE - legend_padding - legend_y = 720 - TILE_SHEET_SIZE - legend_padding - tile_sheet_sprite = [legend_x, - legend_y, - TILE_SHEET_SIZE, - TILE_SHEET_SIZE, - 'sprites/simple-mood-16x16.png', 0, - TILE_A, - TILE_R, - TILE_G, - TILE_B] - - if args.inputs.mouse.point.inside_rect? tile_sheet_sprite - mouse_row = args.inputs.mouse.point.y.idiv(SOURCE_TILE_SIZE) - tile_row = 15 - (mouse_row - legend_y.idiv(SOURCE_TILE_SIZE)) - - mouse_col = args.inputs.mouse.point.x.idiv(SOURCE_TILE_SIZE) - tile_col = (mouse_col - legend_x.idiv(SOURCE_TILE_SIZE)) - - args.outputs.primitives << [legend_x - legend_padding * 2, - mouse_row * SOURCE_TILE_SIZE, 256 + legend_padding * 2, 16, 128, 128, 128, 64].solid - - args.outputs.primitives << [mouse_col * SOURCE_TILE_SIZE, - legend_y - legend_padding * 2, 16, 256 + legend_padding * 2, 128, 128, 128, 64].solid - - sprite_key = sprite_lookup.find { |k, v| v == [tile_row, tile_col] } - if sprite_key - member_name, _ = sprite_key - member_name = member_name_as_code member_name - args.outputs.labels << [660, 70, "# CODE SAMPLE (place in the tick_game method located in main.rb)", -1, 0] - args.outputs.labels << [660, 50, "# GRID_X, GRID_Y, TILE_KEY", -1, 0] - args.outputs.labels << [660, 30, "args.outputs.sprites << tile_in_game( 5, 6, #{member_name} )", -1, 0] - else - args.outputs.labels << [660, 50, "Tile [#{tile_row}, #{tile_col}] not found. Add a key and value to app/sprite_lookup.rb:", -1, 0] - args.outputs.labels << [660, 30, "{ \"some_string\" => [#{tile_row}, #{tile_col}] } OR { some_symbol: [#{tile_row}, #{tile_col}] }.", -1, 0] - end - - end - - # render the sprite in the top right with a padding to the top and right so it's - # not flush against the edge - args.outputs.sprites << tile_sheet_sprite - - # carefully place some ascii arrows to show the legend labels - args.outputs.labels << [895, 707, "ROW --->"] - args.outputs.labels << [943, 412, " ^"] - args.outputs.labels << [943, 412, " |"] - args.outputs.labels << [943, 394, "COL ---+"] - - # use the tile sheet to print out row and column numbers - args.outputs.sprites << 16.map_with_index do |i| - sprite_key = i % 10 - [ - tile(1280 - TILE_SHEET_SIZE - legend_padding * 2 - SOURCE_TILE_SIZE, - 720 - legend_padding * 2 - (SOURCE_TILE_SIZE * i), - sprite(sprite_key)), - tile(1280 - TILE_SHEET_SIZE - SOURCE_TILE_SIZE + (SOURCE_TILE_SIZE * i), - 720 - TILE_SHEET_SIZE - legend_padding * 3, sprite(sprite_key)) - ] - end -end diff --git a/samples/99_genre_rpg_roguelike/roguelike_line_of_sight/app/main.rb b/samples/99_genre_rpg_roguelike/roguelike_line_of_sight/app/main.rb deleted file mode 100644 index 15a381b..0000000 --- a/samples/99_genre_rpg_roguelike/roguelike_line_of_sight/app/main.rb +++ /dev/null @@ -1,97 +0,0 @@ -require 'app/constants.rb' -require 'app/sprite_lookup.rb' -require 'app/legend.rb' - -def tick args - tick_game args - tick_legend args -end - -def tick_game args - # setup the grid - args.state.grid.padding = 104 - args.state.grid.size = 512 - - # set up your game - # initialize the game/game defaults. ||= means that you only initialize it if - # the value isn't already initialized - args.state.player.x ||= 0 - args.state.player.y ||= 0 - - args.state.enemies ||= [ - { x: 10, y: 10, type: :goblin, tile_key: :G }, - { x: 15, y: 30, type: :rat, tile_key: :R } - ] - - args.state.info_message ||= "Use arrow keys to move around." - - # handle keyboard input - # keyboard input (arrow keys to move player) - new_player_x = args.state.player.x - new_player_y = args.state.player.y - player_direction = "" - player_moved = false - if args.inputs.keyboard.key_down.up - new_player_y += 1 - player_direction = "north" - player_moved = true - elsif args.inputs.keyboard.key_down.down - new_player_y -= 1 - player_direction = "south" - player_moved = true - elsif args.inputs.keyboard.key_down.right - new_player_x += 1 - player_direction = "east" - player_moved = true - elsif args.inputs.keyboard.key_down.left - new_player_x -= 1 - player_direction = "west" - player_moved = true - end - - #handle game logic - # determine if there is an enemy on that square, - # if so, don't let the player move there - if player_moved - found_enemy = args.state.enemies.find do |e| - e[:x] == new_player_x && e[:y] == new_player_y - end - - if !found_enemy - args.state.player.x = new_player_x - args.state.player.y = new_player_y - args.state.info_message = "You moved #{player_direction}." - else - args.state.info_message = "You cannot move into a square an enemy occupies." - end - end - - args.outputs.sprites << tile_in_game(args.state.player.x, - args.state.player.y, '@') - - # render game - # render enemies at locations - args.outputs.sprites << args.state.enemies.map do |e| - tile_in_game(e[:x], e[:y], e[:tile_key]) - end - - # render the border - border_x = args.state.grid.padding - DESTINATION_TILE_SIZE - border_y = args.state.grid.padding - DESTINATION_TILE_SIZE - border_size = args.state.grid.size + DESTINATION_TILE_SIZE * 2 - - args.outputs.borders << [border_x, - border_y, - border_size, - border_size] - - # render label stuff - args.outputs.labels << [border_x, border_y - 10, "Current player location is: #{args.state.player.x}, #{args.state.player.y}"] - args.outputs.labels << [border_x, border_y + 25 + border_size, args.state.info_message] -end - -def tile_in_game x, y, tile_key - tile($gtk.args.state.grid.padding + x * DESTINATION_TILE_SIZE, - $gtk.args.state.grid.padding + y * DESTINATION_TILE_SIZE, - tile_key) -end diff --git a/samples/99_genre_rpg_roguelike/roguelike_line_of_sight/app/sprite_lookup.rb b/samples/99_genre_rpg_roguelike/roguelike_line_of_sight/app/sprite_lookup.rb deleted file mode 100644 index 579e133..0000000 --- a/samples/99_genre_rpg_roguelike/roguelike_line_of_sight/app/sprite_lookup.rb +++ /dev/null @@ -1,124 +0,0 @@ -def sprite_lookup - { - 0 => [3, 0], - 1 => [3, 1], - 2 => [3, 2], - 3 => [3, 3], - 4 => [3, 4], - 5 => [3, 5], - 6 => [3, 6], - 7 => [3, 7], - 8 => [3, 8], - 9 => [3, 9], - '@' => [4, 0], - A: [ 4, 1], - B: [ 4, 2], - C: [ 4, 3], - D: [ 4, 4], - E: [ 4, 5], - F: [ 4, 6], - G: [ 4, 7], - H: [ 4, 8], - I: [ 4, 9], - J: [ 4, 10], - K: [ 4, 11], - L: [ 4, 12], - M: [ 4, 13], - N: [ 4, 14], - O: [ 4, 15], - P: [ 5, 0], - Q: [ 5, 1], - R: [ 5, 2], - S: [ 5, 3], - T: [ 5, 4], - U: [ 5, 5], - V: [ 5, 6], - W: [ 5, 7], - X: [ 5, 8], - Y: [ 5, 9], - Z: [ 5, 10], - a: [ 6, 1], - b: [ 6, 2], - c: [ 6, 3], - d: [ 6, 4], - e: [ 6, 5], - f: [ 6, 6], - g: [ 6, 7], - h: [ 6, 8], - i: [ 6, 9], - j: [ 6, 10], - k: [ 6, 11], - l: [ 6, 12], - m: [ 6, 13], - n: [ 6, 14], - o: [ 6, 15], - p: [ 7, 0], - q: [ 7, 1], - r: [ 7, 2], - s: [ 7, 3], - t: [ 7, 4], - u: [ 7, 5], - v: [ 7, 6], - w: [ 7, 7], - x: [ 7, 8], - y: [ 7, 9], - z: [ 7, 10], - '|' => [ 7, 12] - } -end - -def sprite key - $gtk.args.state.reserved.sprite_lookup[key] -end - -def member_name_as_code raw_member_name - if raw_member_name.is_a? Symbol - ":#{raw_member_name}" - elsif raw_member_name.is_a? String - "'#{raw_member_name}'" - elsif raw_member_name.is_a? Fixnum - "#{raw_member_name}" - else - "UNKNOWN: #{raw_member_name}" - end -end - -def tile x, y, tile_row_column_or_key - tile_extended x, y, DESTINATION_TILE_SIZE, DESTINATION_TILE_SIZE, TILE_R, TILE_G, TILE_B, TILE_A, tile_row_column_or_key -end - -def tile_extended x, y, w, h, r, g, b, a, tile_row_column_or_key - row_or_key, column = tile_row_column_or_key - if !column - row, column = sprite row_or_key - else - row, column = row_or_key, column - end - - if !row - member_name = member_name_as_code tile_row_column_or_key - raise "Unable to find a sprite for #{member_name}. Make sure the value exists in app/sprite_lookup.rb." - end - - # Sprite provided by Rogue Yun - # http://www.bay12forums.com/smf/index.php?topic=144897.0 - # License: Public Domain - - { - x: x, - y: y, - w: w, - h: h, - tile_x: column * 16, - tile_y: (row * 16), - tile_w: 16, - tile_h: 16, - r: r, - g: g, - b: b, - a: a, - path: 'sprites/simple-mood-16x16.png' - } -end - -$gtk.args.state.reserved.sprite_lookup = sprite_lookup diff --git a/samples/99_genre_rpg_roguelike/roguelike_line_of_sight/license-for-sample.txt b/samples/99_genre_rpg_roguelike/roguelike_line_of_sight/license-for-sample.txt deleted file mode 100644 index 100dcec..0000000 --- a/samples/99_genre_rpg_roguelike/roguelike_line_of_sight/license-for-sample.txt +++ /dev/null @@ -1,9 +0,0 @@ -Copyright 2019 DragonRuby LLC - -MIT License - -Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/samples/99_genre_rpg_roguelike/roguelike_line_of_sight/sprites/simple-mood-16x16.png b/samples/99_genre_rpg_roguelike/roguelike_line_of_sight/sprites/simple-mood-16x16.png deleted file mode 100644 index 0eca11e..0000000 Binary files a/samples/99_genre_rpg_roguelike/roguelike_line_of_sight/sprites/simple-mood-16x16.png and /dev/null differ diff --git a/samples/99_genre_rpg_roguelike/roguelike_starting_point/app/main.rb b/samples/99_genre_rpg_roguelike/roguelike_starting_point/app/main.rb deleted file mode 100644 index bc4d7fd..0000000 --- a/samples/99_genre_rpg_roguelike/roguelike_starting_point/app/main.rb +++ /dev/null @@ -1,438 +0,0 @@ -=begin - - APIs listing that haven't been encountered in previous sample apps: - - - lambda: A way to define a block and its parameters with special syntax. - For example, the syntax of lambda looks like this: - my_lambda = -> { puts "This is my lambda" } - - Reminders: - - args.outputs.labels: An array. The values generate a label. - The parameters are [X, Y, TEXT, SIZE, ALIGNMENT, RED, GREEN, BLUE, ALPHA, FONT STYLE] - - - ARRAY#inside_rect?: Returns whether or not the point is inside a rect. - - - product: Returns an array of all combinations of elements from all arrays. - - - find: Finds all elements of a collection that meet requirements. - - - abs: Returns the absolute value. - -=end - -# This sample app allows the player to move around in the dungeon, which becomes more or less visible -# depending on the player's location, and also has enemies. - -class Game - attr_accessor :args, :state, :inputs, :outputs, :grid - - # Calls all the methods needed for the game to run properly. - def tick - defaults - render_canvas - render_dungeon - render_player - render_enemies - print_cell_coordinates - calc_canvas - input_move - input_click_map - end - - # Sets default values and initializes variables - def defaults - outputs.background_color = [0, 0, 0] # black background - - # Initializes empty canvas, dungeon, and enemies collections. - state.canvas ||= [] - state.dungeon ||= [] - state.enemies ||= [] - - # If state.area doesn't have value, load_area_one and derive_dungeon_from_area methods are called - if !state.area - load_area_one - derive_dungeon_from_area - - # Changing these values will change the position of player - state.x = 7 - state.y = 5 - - # Creates new enemies, sets their values, and adds them to the enemies collection. - state.enemies << state.new_entity(:enemy) do |e| # declares each enemy as new entity - e.x = 13 # position - e.y = 5 - e.previous_hp = 3 - e.hp = 3 - e.max_hp = 3 - e.is_dead = false # the enemy is alive - end - - update_line_of_sight # updates line of sight by adding newly visible cells - end - end - - # Adds elements into the state.area collection - # The dungeon is derived using the coordinates of this collection - def load_area_one - state.area ||= [] - state.area << [8, 6] - state.area << [7, 6] - state.area << [7, 7] - state.area << [8, 9] - state.area << [7, 8] - state.area << [7, 9] - state.area << [6, 4] - state.area << [7, 3] - state.area << [7, 4] - state.area << [6, 5] - state.area << [7, 5] - state.area << [8, 5] - state.area << [8, 4] - state.area << [1, 1] - state.area << [0, 1] - state.area << [0, 2] - state.area << [1, 2] - state.area << [2, 2] - state.area << [2, 1] - state.area << [2, 3] - state.area << [1, 3] - state.area << [1, 4] - state.area << [2, 4] - state.area << [2, 5] - state.area << [1, 5] - state.area << [2, 6] - state.area << [3, 6] - state.area << [4, 6] - state.area << [4, 7] - state.area << [4, 8] - state.area << [5, 8] - state.area << [5, 9] - state.area << [6, 9] - state.area << [7, 10] - state.area << [7, 11] - state.area << [7, 12] - state.area << [7, 12] - state.area << [7, 13] - state.area << [8, 13] - state.area << [9, 13] - state.area << [10, 13] - state.area << [11, 13] - state.area << [12, 13] - state.area << [12, 12] - state.area << [8, 12] - state.area << [9, 12] - state.area << [10, 12] - state.area << [11, 12] - state.area << [12, 11] - state.area << [13, 11] - state.area << [13, 10] - state.area << [13, 9] - state.area << [13, 8] - state.area << [13, 7] - state.area << [13, 6] - state.area << [12, 6] - state.area << [14, 6] - state.area << [14, 5] - state.area << [13, 5] - state.area << [12, 5] - state.area << [12, 4] - state.area << [13, 4] - state.area << [14, 4] - state.area << [1, 6] - state.area << [6, 6] - end - - # Starts with an empty dungeon collection, and adds dungeon cells into it. - def derive_dungeon_from_area - state.dungeon = [] # starts as empty collection - - state.area.each do |a| # for each element of the area collection - state.dungeon << state.new_entity(:dungeon_cell) do |d| # declares each dungeon cell as new entity - d.x = a.x # dungeon cell position using coordinates from area - d.y = a.y - d.is_visible = false # cell is not visible - d.alpha = 0 # not transparent at all - d.border = [left_margin + a.x * grid_size, - bottom_margin + a.y * grid_size, - grid_size, - grid_size, - *blue, - 255] # sets border definition for dungeon cell - d # returns dungeon cell - end - end - end - - def left_margin - 40 # sets left margin - end - - def bottom_margin - 60 # sets bottom margin - end - - def grid_size - 40 # sets size of grid square - end - - # Updates the line of sight by calling the thick_line_of_sight method and - # adding dungeon cells to the newly_visible collection - def update_line_of_sight - variations = [-1, 0, 1] - # creates collection of newly visible dungeon cells - newly_visible = variations.product(variations).flat_map do |rise, run| # combo of all elements - thick_line_of_sight state.x, state.y, rise, run, 15, # calls thick_line_of_sight method - lambda { |x, y| dungeon_cell_exists? x, y } # checks whether or not cell exists - end.uniq# removes duplicates - - state.dungeon.each do |d| # perform action on each element of dungeons collection - d.is_visible = newly_visible.find { |v| v.x == d.x && v.y == d.y } # finds match inside newly_visible collection - end - end - - #Returns a boolean value - def dungeon_cell_exists? x, y - # Finds cell coordinates inside dungeon collection to determine if dungeon cell exists - state.dungeon.find { |d| d.x == x && d.y == y } - end - - # Calls line_of_sight method to add elements to result collection - def thick_line_of_sight start_x, start_y, rise, run, distance, cell_exists_lambda - result = [] - result += line_of_sight start_x, start_y, rise, run, distance, cell_exists_lambda - result += line_of_sight start_x - 1, start_y, rise, run, distance, cell_exists_lambda # one left - result += line_of_sight start_x + 1, start_y, rise, run, distance, cell_exists_lambda # one right - result - end - - # Adds points to the result collection to create the player's line of sight - def line_of_sight start_x, start_y, rise, run, distance, cell_exists_lambda - result = [] # starts as empty collection - points = points_on_line start_x, start_y, rise, run, distance # calls points_on_line method - points.each do |p| # for each point in collection - if cell_exists_lambda.call(p.x, p.y) # if the cell exists - result << p # add it to result collection - else # if cell does not exist - return result # return result collection as it is - end - end - - result # return result collection - end - - # Finds the coordinates of the points on the line by performing calculations - def points_on_line start_x, start_y, rise, run, distance - distance.times.map do |i| # perform an action - [start_x + run * i, start_y + rise * i] # definition of point - end - end - - def render_canvas - return - outputs.borders << state.canvas.map do |c| # on each element of canvas collection - c.border # outputs border - end - end - - # Outputs the dungeon cells. - def render_dungeon - outputs.solids << [0, 0, grid.w, grid.h] # outputs black background for grid - - # Sets the alpha value (opacity) for each dungeon cell and calls the cell_border method. - outputs.borders << state.dungeon.map do |d| # for each element in dungeon collection - d.alpha += if d.is_visible # if cell is visible - 255.fdiv(30) # increment opacity (transparency) - else # if cell is not visible - 255.fdiv(600) * -1 # decrease opacity - end - d.alpha = d.alpha.cap_min_max(0, 255) - cell_border d.x, d.y, [*blue, d.alpha] # sets blue border using alpha value - end.reject_nil - end - - # Sets definition of a cell border using the parameters - def cell_border x, y, color = nil - [left_margin + x * grid_size, - bottom_margin + y * grid_size, - grid_size, - grid_size, - *color] - end - - # Sets the values for the player and outputs it as a label - def render_player - outputs.labels << [grid_x(state.x) + 20, # positions "@" text in center of grid square - grid_y(state.y) + 35, - "@", # player is represented by a white "@" character - 1, 1, *white] - end - - def grid_x x - left_margin + x * grid_size # positions horizontally on grid - end - - def grid_y y - bottom_margin + y * grid_size # positions vertically on grid - end - - # Outputs enemies onto the screen. - def render_enemies - state.enemies.map do |e| # for each enemy in the collection - alpha = 255 # set opacity (full transparency) - - # Outputs an enemy using a label. - outputs.labels << [ - left_margin + 20 + e.x * grid_size, # positions enemy's "r" text in center of grid square - bottom_margin + 35 + e.y * grid_size, - "r", # enemy's text - 1, 1, *white, alpha] - - # Creates a red border around an enemy. - outputs.borders << [grid_x(e.x), grid_y(e.y), grid_size, grid_size, *red] - end - end - - #White labels are output for the cell coordinates of each element in the dungeon collection. - def print_cell_coordinates - return unless state.debug - state.dungeon.each do |d| - outputs.labels << [grid_x(d.x) + 2, - grid_y(d.y) - 2, - "#{d.x},#{d.y}", - -2, 0, *white] - end - end - - # Adds new elements into the canvas collection and sets their values. - def calc_canvas - return if state.canvas.length > 0 # return if canvas collection has at least one element - 15.times do |x| # 15 times perform an action - 15.times do |y| - state.canvas << state.new_entity(:canvas) do |c| # declare canvas element as new entity - c.x = x # set position - c.y = y - c.border = [left_margin + x * grid_size, - bottom_margin + y * grid_size, - grid_size, - grid_size, - *white, 30] # sets border definition - end - end - end - end - - # Updates x and y values of the player, and updates player's line of sight - def input_move - x, y, x_diff, y_diff = input_target_cell - - return unless dungeon_cell_exists? x, y # player can't move there if a dungeon cell doesn't exist in that location - return if enemy_at x, y # player can't move there if there is an enemy in that location - - state.x += x_diff # increments x by x_diff (so player moves left or right) - state.y += y_diff # same with y and y_diff ( so player moves up or down) - update_line_of_sight # updates visible cells - end - - def enemy_at x, y - # Finds if coordinates exist in enemies collection and enemy is not dead - state.enemies.find { |e| e.x == x && e.y == y && !e.is_dead } - end - - # Moves the user based on their keyboard input and sets values for target cell - def input_target_cell - if inputs.keyboard.key_down.up # if "up" key is in "down" state - [state.x, state.y + 1, 0, 1] # user moves up - elsif inputs.keyboard.key_down.down # if "down" key is pressed - [state.x, state.y - 1, 0, -1] # user moves down - elsif inputs.keyboard.key_down.left # if "left" key is pressed - [state.x - 1, state.y, -1, 0] # user moves left - elsif inputs.keyboard.key_down.right # if "right" key is pressed - [state.x + 1, state.y, 1, 0] # user moves right - else - nil # otherwise, empty - end - end - - # Goes through the canvas collection to find if the mouse was clicked inside of the borders of an element. - def input_click_map - return unless inputs.mouse.click # return unless the mouse is clicked - canvas_entry = state.canvas.find do |c| # find element from canvas collection that meets requirements - inputs.mouse.click.inside_rect? c.border # find border that mouse was clicked inside of - end - puts canvas_entry # prints canvas_entry value - end - - # Sets the definition of a label using the parameters. - def label text, x, y, color = nil - color ||= white # color is initialized to white - [x, y, text, 1, 1, *color] # sets label definition - end - - def green - [60, 200, 100] # sets color saturation to shade of green - end - - def blue - [50, 50, 210] # sets color saturation to shade of blue - end - - def white - [255, 255, 255] # sets color saturation to white - end - - def red - [230, 80, 80] # sets color saturation to shade of red - end - - def orange - [255, 80, 60] # sets color saturation to shade of orange - end - - def pink - [255, 0, 200] # sets color saturation to shade of pink - end - - def gray - [75, 75, 75] # sets color saturation to shade of gray - end - - # Recolors the border using the parameters. - def recolor_border border, r, g, b - border[4] = r - border[5] = g - border[6] = b - border - end - - # Returns a boolean value. - def visible? cell - # finds cell's coordinates inside visible_cells collections to determine if cell is visible - state.visible_cells.find { |c| c.x == cell.x && c.y == cell.y} - end - - # Exports dungeon by printing dungeon cell coordinates - def export_dungeon - state.dungeon.each do |d| # on each element of dungeon collection - puts "state.dungeon << [#{d.x}, #{d.y}]" # prints cell coordinates - end - end - - def distance_to_cell cell - distance_to state.x, cell.x, state.y, cell.y # calls distance_to method - end - - def distance_to from_x, x, from_y, y - (from_x - x).abs + (from_y - y).abs # finds distance between two cells using coordinates - end -end - -$game = Game.new - -def tick args - $game.args = args - $game.state = args.state - $game.inputs = args.inputs - $game.outputs = args.outputs - $game.grid = args.grid - $game.tick -end diff --git a/samples/99_genre_rpg_roguelike/roguelike_starting_point/license-for-sample.txt b/samples/99_genre_rpg_roguelike/roguelike_starting_point/license-for-sample.txt deleted file mode 100644 index 100dcec..0000000 --- a/samples/99_genre_rpg_roguelike/roguelike_starting_point/license-for-sample.txt +++ /dev/null @@ -1,9 +0,0 @@ -Copyright 2019 DragonRuby LLC - -MIT License - -Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/samples/99_genre_rpg_roguelike/roguelike_starting_point/replay.txt b/samples/99_genre_rpg_roguelike/roguelike_starting_point/replay.txt deleted file mode 100644 index a2b4c52..0000000 --- a/samples/99_genre_rpg_roguelike/roguelike_starting_point/replay.txt +++ /dev/null @@ -1,555 +0,0 @@ -replay_version 2.0 -stopped_at 1731 -seed 100 -recorded_at Sun Sep 29 22:38:52 2019 -[:mouse_move, 785, 468, 2, 1, 114] -[:mouse_move, 756, 468, 2, 2, 115] -[:mouse_move, 745, 468, 2, 3, 117] -[:mouse_move, 718, 470, 2, 4, 118] -[:mouse_move, 705, 472, 2, 5, 119] -[:mouse_move, 680, 476, 2, 6, 120] -[:mouse_move, 668, 478, 2, 7, 121] -[:mouse_move, 606, 492, 2, 8, 122] -[:mouse_move, 581, 499, 2, 9, 123] -[:mouse_move, 523, 511, 2, 10, 124] -[:mouse_move, 417, 527, 2, 11, 125] -[:mouse_move, 387, 528, 2, 12, 126] -[:mouse_move, 344, 528, 2, 13, 127] -[:mouse_move, 324, 526, 2, 14, 128] -[:mouse_move, 295, 520, 2, 15, 129] -[:mouse_move, 285, 518, 2, 16, 130] -[:mouse_move, 276, 515, 2, 17, 131] -[:mouse_move, 255, 512, 2, 18, 132] -[:mouse_move, 244, 511, 2, 19, 133] -[:mouse_move, 228, 511, 2, 20, 134] -[:mouse_move, 213, 513, 2, 21, 135] -[:mouse_move, 194, 523, 2, 22, 136] -[:mouse_move, 190, 526, 2, 23, 137] -[:mouse_move, 183, 532, 2, 24, 138] -[:mouse_move, 180, 533, 2, 25, 139] -[:mouse_move, 177, 536, 2, 26, 140] -[:mouse_move, 177, 537, 2, 27, 141] -[:mouse_move, 193, 537, 2, 28, 142] -[:mouse_move, 208, 536, 2, 29, 143] -[:mouse_move, 222, 536, 2, 30, 144] -[:mouse_move, 232, 535, 2, 31, 145] -[:mouse_move, 241, 535, 2, 32, 146] -[:mouse_move, 245, 535, 2, 33, 147] -[:mouse_move, 249, 535, 2, 34, 148] -[:mouse_move, 250, 535, 2, 35, 149] -[:mouse_move, 251, 535, 2, 36, 150] -[:mouse_move, 252, 534, 2, 37, 151] -[:mouse_move, 256, 531, 2, 38, 152] -[:mouse_move, 259, 527, 2, 39, 153] -[:mouse_move, 265, 520, 2, 40, 154] -[:mouse_move, 270, 515, 2, 41, 155] -[:mouse_move, 274, 511, 2, 42, 156] -[:mouse_move, 282, 501, 2, 43, 157] -[:mouse_move, 293, 490, 2, 44, 159] -[:mouse_move, 295, 489, 2, 45, 160] -[:mouse_move, 299, 487, 2, 46, 161] -[:mouse_move, 301, 485, 2, 47, 162] -[:mouse_move, 303, 484, 2, 48, 163] -[:mouse_move, 304, 484, 2, 49, 164] -[:mouse_move, 306, 484, 2, 50, 165] -[:mouse_move, 307, 484, 2, 51, 166] -[:mouse_move, 308, 484, 2, 52, 167] -[:mouse_move, 310, 484, 2, 53, 168] -[:mouse_move, 314, 484, 2, 54, 169] -[:mouse_move, 316, 484, 2, 55, 170] -[:mouse_move, 317, 484, 2, 56, 171] -[:mouse_move, 318, 484, 2, 57, 172] -[:mouse_move, 319, 484, 2, 58, 173] -[:key_down_raw, 1073741906, 0, 2, 59, 232] -[:key_up_raw, 1073741906, 0, 2, 60, 237] -[:key_down_raw, 1073741906, 0, 2, 61, 243] -[:key_up_raw, 1073741906, 0, 2, 62, 247] -[:key_down_raw, 1073741906, 0, 2, 63, 254] -[:key_up_raw, 1073741906, 0, 2, 64, 257] -[:key_down_raw, 1073741906, 0, 2, 65, 266] -[:key_up_raw, 1073741906, 0, 2, 66, 272] -[:key_down_raw, 1073741906, 0, 2, 67, 279] -[:key_up_raw, 1073741906, 0, 2, 68, 284] -[:key_down_raw, 1073741905, 0, 2, 69, 326] -[:key_up_raw, 1073741905, 0, 2, 70, 334] -[:key_down_raw, 1073741904, 0, 2, 71, 421] -[:key_up_raw, 1073741904, 0, 2, 72, 428] -[:key_down_raw, 1073741904, 0, 2, 73, 438] -[:key_up_raw, 1073741904, 0, 2, 74, 445] -[:key_down_raw, 1073741905, 0, 2, 75, 459] -[:key_up_raw, 1073741905, 0, 2, 76, 466] -[:key_down_raw, 1073741904, 0, 2, 77, 480] -[:key_up_raw, 1073741904, 0, 2, 78, 488] -[:key_down_raw, 1073741905, 0, 2, 79, 499] -[:key_up_raw, 1073741905, 0, 2, 80, 507] -[:mouse_move, 289, 484, 2, 81, 545] -[:mouse_move, 274, 484, 2, 82, 546] -[:mouse_move, 244, 484, 2, 83, 547] -[:mouse_move, 231, 485, 2, 84, 548] -[:mouse_move, 208, 485, 2, 85, 549] -[:mouse_move, 199, 485, 2, 86, 550] -[:mouse_move, 178, 485, 2, 87, 551] -[:mouse_move, 174, 485, 2, 88, 552] -[:mouse_move, 162, 483, 2, 89, 553] -[:mouse_move, 159, 482, 2, 90, 554] -[:mouse_move, 157, 477, 2, 91, 555] -[:mouse_move, 157, 473, 2, 92, 556] -[:mouse_move, 161, 465, 2, 93, 557] -[:mouse_move, 165, 459, 2, 94, 558] -[:mouse_move, 174, 449, 2, 95, 559] -[:mouse_move, 179, 443, 2, 96, 560] -[:mouse_move, 191, 431, 2, 97, 561] -[:mouse_move, 196, 425, 2, 98, 562] -[:mouse_move, 205, 413, 2, 99, 563] -[:mouse_move, 210, 408, 2, 100, 564] -[:mouse_move, 212, 406, 2, 101, 565] -[:mouse_move, 219, 397, 2, 102, 566] -[:mouse_move, 223, 395, 2, 103, 567] -[:mouse_move, 228, 390, 2, 104, 568] -[:mouse_move, 230, 388, 2, 105, 569] -[:mouse_move, 233, 386, 2, 106, 570] -[:mouse_move, 234, 385, 2, 107, 571] -[:mouse_move, 235, 384, 2, 108, 573] -[:mouse_move, 234, 384, 2, 109, 580] -[:mouse_move, 234, 382, 2, 110, 622] -[:mouse_move, 234, 379, 2, 111, 623] -[:mouse_move, 236, 374, 2, 112, 624] -[:mouse_move, 237, 371, 2, 113, 625] -[:mouse_move, 240, 366, 2, 114, 626] -[:mouse_move, 241, 364, 2, 115, 627] -[:mouse_move, 243, 362, 2, 116, 628] -[:mouse_move, 243, 361, 2, 117, 629] -[:mouse_move, 242, 361, 2, 118, 632] -[:mouse_move, 239, 361, 2, 119, 633] -[:mouse_move, 229, 367, 2, 120, 634] -[:mouse_move, 223, 372, 2, 121, 635] -[:mouse_move, 208, 385, 2, 122, 636] -[:mouse_move, 198, 393, 2, 123, 637] -[:mouse_move, 179, 410, 2, 124, 638] -[:mouse_move, 169, 421, 2, 125, 639] -[:mouse_move, 149, 440, 2, 126, 640] -[:mouse_move, 139, 451, 2, 127, 641] -[:mouse_move, 127, 465, 2, 128, 642] -[:mouse_move, 119, 473, 2, 129, 643] -[:mouse_move, 108, 486, 2, 130, 644] -[:mouse_move, 103, 491, 2, 131, 645] -[:mouse_move, 98, 496, 2, 132, 646] -[:mouse_move, 96, 498, 2, 133, 647] -[:mouse_move, 94, 500, 2, 134, 648] -[:mouse_move, 92, 501, 2, 135, 649] -[:mouse_move, 91, 502, 2, 136, 650] -[:mouse_move, 92, 500, 2, 137, 653] -[:mouse_move, 95, 498, 2, 138, 654] -[:mouse_move, 105, 488, 2, 139, 655] -[:mouse_move, 112, 482, 2, 140, 656] -[:mouse_move, 128, 463, 2, 141, 657] -[:mouse_move, 138, 450, 2, 142, 658] -[:mouse_move, 159, 419, 2, 143, 659] -[:mouse_move, 168, 403, 2, 144, 660] -[:mouse_move, 182, 382, 2, 145, 661] -[:mouse_move, 188, 370, 2, 146, 662] -[:mouse_move, 200, 354, 2, 147, 663] -[:mouse_move, 205, 348, 2, 148, 664] -[:mouse_move, 214, 338, 2, 149, 665] -[:mouse_move, 218, 335, 2, 150, 666] -[:mouse_move, 222, 331, 2, 151, 667] -[:mouse_move, 224, 330, 2, 152, 668] -[:mouse_move, 226, 328, 2, 153, 669] -[:mouse_move, 227, 328, 2, 154, 670] -[:mouse_move, 222, 329, 2, 155, 674] -[:mouse_move, 219, 332, 2, 156, 675] -[:mouse_move, 207, 342, 2, 157, 676] -[:mouse_move, 201, 350, 2, 158, 677] -[:mouse_move, 184, 370, 2, 159, 678] -[:mouse_move, 173, 384, 2, 160, 679] -[:mouse_move, 151, 415, 2, 161, 680] -[:mouse_move, 140, 431, 2, 162, 681] -[:mouse_move, 119, 458, 2, 163, 682] -[:mouse_move, 114, 463, 2, 164, 683] -[:mouse_move, 99, 478, 2, 165, 684] -[:mouse_move, 97, 480, 2, 166, 685] -[:mouse_move, 88, 490, 2, 167, 686] -[:mouse_move, 85, 493, 2, 168, 687] -[:mouse_move, 82, 496, 2, 169, 688] -[:mouse_move, 81, 497, 2, 170, 689] -[:mouse_move, 82, 497, 2, 171, 692] -[:mouse_move, 84, 496, 2, 172, 693] -[:mouse_move, 94, 489, 2, 173, 694] -[:mouse_move, 101, 482, 2, 174, 695] -[:mouse_move, 119, 463, 2, 175, 696] -[:mouse_move, 129, 451, 2, 176, 697] -[:mouse_move, 151, 426, 2, 177, 698] -[:mouse_move, 155, 420, 2, 178, 699] -[:mouse_move, 172, 401, 2, 179, 700] -[:mouse_move, 178, 393, 2, 180, 701] -[:mouse_move, 185, 387, 2, 181, 702] -[:mouse_move, 197, 376, 2, 182, 703] -[:mouse_move, 202, 371, 2, 183, 704] -[:mouse_move, 209, 365, 2, 184, 705] -[:mouse_move, 215, 360, 2, 185, 706] -[:mouse_move, 218, 357, 2, 186, 707] -[:mouse_move, 222, 353, 2, 187, 708] -[:mouse_move, 225, 351, 2, 188, 709] -[:mouse_move, 226, 350, 2, 189, 710] -[:mouse_move, 227, 348, 2, 190, 711] -[:mouse_move, 228, 348, 2, 191, 712] -[:mouse_move, 229, 347, 2, 192, 713] -[:mouse_move, 229, 346, 2, 193, 715] -[:mouse_move, 225, 352, 2, 194, 721] -[:mouse_move, 219, 361, 2, 195, 722] -[:mouse_move, 201, 385, 2, 196, 723] -[:mouse_move, 193, 393, 2, 197, 724] -[:mouse_move, 165, 424, 2, 198, 725] -[:mouse_move, 151, 439, 2, 199, 726] -[:mouse_move, 127, 468, 2, 200, 727] -[:mouse_move, 116, 480, 2, 201, 728] -[:mouse_move, 106, 490, 2, 202, 729] -[:mouse_move, 92, 504, 2, 203, 730] -[:mouse_move, 84, 512, 2, 204, 731] -[:mouse_move, 77, 519, 2, 205, 732] -[:mouse_move, 73, 523, 2, 206, 733] -[:mouse_move, 69, 527, 2, 207, 734] -[:mouse_move, 68, 527, 2, 208, 735] -[:mouse_move, 68, 528, 2, 209, 736] -[:mouse_move, 70, 525, 2, 210, 738] -[:mouse_move, 73, 522, 2, 211, 739] -[:mouse_move, 86, 511, 2, 212, 740] -[:mouse_move, 93, 503, 2, 213, 741] -[:mouse_move, 117, 477, 2, 214, 742] -[:mouse_move, 123, 469, 2, 215, 743] -[:mouse_move, 156, 427, 2, 216, 744] -[:mouse_move, 169, 407, 2, 217, 745] -[:mouse_move, 187, 376, 2, 218, 746] -[:mouse_move, 199, 356, 2, 219, 747] -[:mouse_move, 221, 318, 2, 220, 748] -[:mouse_move, 231, 302, 2, 221, 749] -[:mouse_move, 250, 276, 2, 222, 750] -[:mouse_move, 260, 266, 2, 223, 751] -[:mouse_move, 267, 259, 2, 224, 752] -[:mouse_move, 272, 254, 2, 225, 753] -[:mouse_move, 279, 247, 2, 226, 754] -[:mouse_move, 281, 245, 2, 227, 755] -[:mouse_move, 282, 245, 2, 228, 756] -[:mouse_move, 283, 244, 2, 229, 757] -[:key_down_raw, 1073741906, 0, 2, 230, 813] -[:key_up_raw, 1073741906, 0, 2, 231, 820] -[:key_down_raw, 1073741903, 0, 2, 232, 833] -[:key_up_raw, 1073741903, 0, 2, 233, 840] -[:key_down_raw, 1073741903, 0, 2, 234, 848] -[:key_up_raw, 1073741903, 0, 2, 235, 855] -[:key_down_raw, 1073741906, 0, 2, 236, 862] -[:key_up_raw, 1073741906, 0, 2, 237, 870] -[:key_down_raw, 1073741903, 0, 2, 238, 880] -[:key_up_raw, 1073741903, 0, 2, 239, 901] -[:key_down_raw, 1073741903, 0, 2, 240, 917] -[:key_up_raw, 1073741903, 0, 2, 241, 924] -[:key_down_raw, 1073741905, 0, 2, 242, 943] -[:key_up_raw, 1073741905, 0, 2, 243, 948] -[:key_down_raw, 1073741905, 0, 2, 244, 952] -[:key_up_raw, 1073741905, 0, 2, 245, 956] -[:key_down_raw, 1073741905, 0, 2, 246, 960] -[:key_up_raw, 1073741905, 0, 2, 247, 963] -[:key_down_raw, 1073741905, 0, 2, 248, 967] -[:key_up_raw, 1073741905, 0, 2, 249, 972] -[:mouse_move, 244, 247, 2, 250, 997] -[:mouse_move, 229, 253, 2, 251, 998] -[:mouse_move, 174, 283, 2, 252, 999] -[:mouse_move, 152, 299, 2, 253, 1000] -[:mouse_move, 133, 313, 2, 254, 1001] -[:mouse_move, 63, 372, 2, 255, 1002] -[:mouse_move, 53, 384, 2, 256, 1003] -[:mouse_move, 40, 399, 2, 257, 1004] -[:mouse_move, 20, 424, 2, 258, 1005] -[:mouse_move, 13, 440, 2, 259, 1006] -[:mouse_move, 12, 445, 2, 260, 1007] -[:mouse_move, 12, 450, 2, 261, 1008] -[:mouse_move, 12, 451, 2, 262, 1009] -[:mouse_move, 13, 454, 2, 263, 1010] -[:mouse_move, 14, 454, 2, 264, 1011] -[:mouse_move, 15, 455, 2, 265, 1012] -[:mouse_move, 15, 454, 2, 266, 1014] -[:mouse_move, 15, 452, 2, 267, 1015] -[:mouse_move, 15, 447, 2, 268, 1016] -[:mouse_move, 15, 443, 2, 269, 1017] -[:mouse_move, 16, 438, 2, 270, 1018] -[:mouse_move, 17, 435, 2, 271, 1019] -[:mouse_move, 19, 431, 2, 272, 1020] -[:mouse_move, 20, 430, 2, 273, 1021] -[:mouse_move, 22, 428, 2, 274, 1022] -[:mouse_move, 23, 427, 2, 275, 1023] -[:mouse_move, 25, 426, 2, 276, 1024] -[:mouse_move, 26, 426, 2, 277, 1025] -[:mouse_move, 29, 426, 2, 278, 1026] -[:mouse_move, 30, 426, 2, 279, 1028] -[:mouse_move, 31, 427, 2, 280, 1029] -[:mouse_move, 32, 428, 2, 281, 1030] -[:mouse_move, 33, 431, 2, 282, 1031] -[:mouse_move, 34, 432, 2, 283, 1032] -[:mouse_move, 35, 437, 2, 284, 1033] -[:mouse_move, 36, 439, 2, 285, 1034] -[:mouse_move, 37, 444, 2, 286, 1035] -[:mouse_move, 39, 449, 2, 287, 1036] -[:mouse_move, 44, 460, 2, 288, 1037] -[:mouse_move, 45, 464, 2, 289, 1038] -[:mouse_move, 52, 475, 2, 290, 1039] -[:mouse_move, 55, 479, 2, 291, 1040] -[:mouse_move, 62, 485, 2, 292, 1041] -[:mouse_move, 66, 487, 2, 293, 1042] -[:mouse_move, 74, 488, 2, 294, 1043] -[:mouse_move, 79, 488, 2, 295, 1044] -[:mouse_move, 89, 484, 2, 296, 1045] -[:mouse_move, 95, 480, 2, 297, 1046] -[:mouse_move, 111, 468, 2, 298, 1047] -[:mouse_move, 115, 466, 2, 299, 1048] -[:mouse_move, 134, 453, 2, 300, 1049] -[:mouse_move, 142, 447, 2, 301, 1050] -[:mouse_move, 160, 437, 2, 302, 1051] -[:mouse_move, 170, 431, 2, 303, 1052] -[:mouse_move, 179, 425, 2, 304, 1053] -[:mouse_move, 192, 417, 2, 305, 1054] -[:mouse_move, 200, 411, 2, 306, 1055] -[:mouse_move, 213, 401, 2, 307, 1056] -[:mouse_move, 219, 396, 2, 308, 1057] -[:mouse_move, 230, 386, 2, 309, 1058] -[:mouse_move, 238, 375, 2, 310, 1059] -[:mouse_move, 244, 363, 2, 311, 1060] -[:mouse_move, 247, 355, 2, 312, 1061] -[:mouse_move, 253, 341, 2, 313, 1062] -[:mouse_move, 255, 335, 2, 314, 1063] -[:mouse_move, 257, 321, 2, 315, 1064] -[:mouse_move, 258, 309, 2, 316, 1065] -[:mouse_move, 257, 298, 2, 317, 1066] -[:mouse_move, 255, 291, 2, 318, 1067] -[:mouse_move, 249, 281, 2, 319, 1068] -[:mouse_move, 242, 271, 2, 320, 1069] -[:mouse_move, 233, 264, 2, 321, 1070] -[:mouse_move, 226, 260, 2, 322, 1071] -[:mouse_move, 207, 252, 2, 323, 1072] -[:mouse_move, 203, 251, 2, 324, 1073] -[:mouse_move, 185, 249, 2, 325, 1074] -[:mouse_move, 178, 249, 2, 326, 1075] -[:mouse_move, 161, 249, 2, 327, 1076] -[:mouse_move, 153, 250, 2, 328, 1077] -[:mouse_move, 139, 256, 2, 329, 1078] -[:mouse_move, 132, 259, 2, 330, 1079] -[:mouse_move, 120, 269, 2, 331, 1080] -[:mouse_move, 110, 279, 2, 332, 1081] -[:mouse_move, 104, 287, 2, 333, 1082] -[:mouse_move, 93, 304, 2, 334, 1083] -[:mouse_move, 87, 313, 2, 335, 1084] -[:mouse_move, 80, 326, 2, 336, 1085] -[:mouse_move, 75, 335, 2, 337, 1086] -[:mouse_move, 69, 351, 2, 338, 1087] -[:mouse_move, 67, 359, 2, 339, 1088] -[:mouse_move, 64, 376, 2, 340, 1089] -[:mouse_move, 64, 383, 2, 341, 1090] -[:mouse_move, 62, 399, 2, 342, 1091] -[:mouse_move, 62, 406, 2, 343, 1092] -[:mouse_move, 62, 418, 2, 344, 1093] -[:mouse_move, 62, 423, 2, 345, 1094] -[:mouse_move, 66, 433, 2, 346, 1095] -[:mouse_move, 69, 437, 2, 347, 1096] -[:mouse_move, 78, 444, 2, 348, 1097] -[:mouse_move, 86, 450, 2, 349, 1098] -[:mouse_move, 102, 457, 2, 350, 1099] -[:mouse_move, 112, 458, 2, 351, 1100] -[:mouse_move, 136, 461, 2, 352, 1101] -[:mouse_move, 142, 461, 2, 353, 1102] -[:mouse_move, 162, 460, 2, 354, 1103] -[:mouse_move, 172, 459, 2, 355, 1104] -[:mouse_move, 188, 454, 2, 356, 1105] -[:mouse_move, 195, 451, 2, 357, 1106] -[:mouse_move, 211, 443, 2, 358, 1107] -[:mouse_move, 214, 440, 2, 359, 1108] -[:mouse_move, 222, 432, 2, 360, 1109] -[:mouse_move, 233, 412, 2, 361, 1110] -[:mouse_move, 238, 400, 2, 362, 1111] -[:mouse_move, 248, 375, 2, 363, 1112] -[:mouse_move, 250, 370, 2, 364, 1113] -[:mouse_move, 258, 351, 2, 365, 1114] -[:mouse_move, 261, 343, 2, 366, 1115] -[:mouse_move, 264, 328, 2, 367, 1116] -[:mouse_move, 264, 321, 2, 368, 1117] -[:mouse_move, 265, 307, 2, 369, 1118] -[:mouse_move, 265, 305, 2, 370, 1119] -[:mouse_move, 264, 296, 2, 371, 1120] -[:mouse_move, 262, 289, 2, 372, 1121] -[:mouse_move, 257, 282, 2, 373, 1122] -[:mouse_move, 252, 277, 2, 374, 1123] -[:mouse_move, 237, 271, 2, 375, 1124] -[:mouse_move, 227, 269, 2, 376, 1125] -[:mouse_move, 211, 268, 2, 377, 1126] -[:mouse_move, 201, 268, 2, 378, 1127] -[:mouse_move, 177, 268, 2, 379, 1128] -[:mouse_move, 168, 269, 2, 380, 1129] -[:mouse_move, 149, 274, 2, 381, 1130] -[:mouse_move, 137, 279, 2, 382, 1131] -[:mouse_move, 124, 288, 2, 383, 1132] -[:mouse_move, 116, 294, 2, 384, 1133] -[:mouse_move, 102, 307, 2, 385, 1134] -[:mouse_move, 91, 319, 2, 386, 1135] -[:mouse_move, 88, 323, 2, 387, 1136] -[:mouse_move, 73, 344, 2, 388, 1137] -[:mouse_move, 68, 353, 2, 389, 1138] -[:mouse_move, 57, 374, 2, 390, 1139] -[:mouse_move, 52, 386, 2, 391, 1140] -[:mouse_move, 44, 412, 2, 392, 1141] -[:mouse_move, 42, 418, 2, 393, 1142] -[:mouse_move, 36, 437, 2, 394, 1143] -[:mouse_move, 34, 445, 2, 395, 1144] -[:mouse_move, 33, 453, 2, 396, 1145] -[:mouse_move, 32, 457, 2, 397, 1146] -[:mouse_move, 32, 466, 2, 398, 1147] -[:mouse_move, 33, 468, 2, 399, 1148] -[:mouse_move, 38, 475, 2, 400, 1149] -[:mouse_move, 44, 482, 2, 401, 1150] -[:mouse_move, 56, 492, 2, 402, 1151] -[:mouse_move, 64, 496, 2, 403, 1152] -[:mouse_move, 81, 503, 2, 404, 1153] -[:mouse_move, 92, 503, 2, 405, 1154] -[:mouse_move, 106, 503, 2, 406, 1155] -[:mouse_move, 115, 501, 2, 407, 1156] -[:mouse_move, 134, 492, 2, 408, 1157] -[:mouse_move, 147, 485, 2, 409, 1158] -[:mouse_move, 163, 471, 2, 410, 1159] -[:mouse_move, 171, 463, 2, 411, 1160] -[:mouse_move, 183, 451, 2, 412, 1161] -[:mouse_move, 202, 425, 2, 413, 1163] -[:mouse_move, 215, 401, 2, 414, 1164] -[:mouse_move, 217, 395, 2, 415, 1165] -[:mouse_move, 226, 373, 2, 416, 1166] -[:mouse_move, 234, 357, 2, 417, 1167] -[:mouse_move, 238, 343, 2, 418, 1168] -[:mouse_move, 240, 334, 2, 419, 1169] -[:mouse_move, 247, 310, 2, 420, 1170] -[:mouse_move, 249, 299, 2, 421, 1171] -[:mouse_move, 250, 290, 2, 422, 1172] -[:mouse_move, 251, 283, 2, 423, 1173] -[:mouse_move, 251, 269, 2, 424, 1174] -[:mouse_move, 248, 263, 2, 425, 1175] -[:mouse_move, 237, 256, 2, 426, 1176] -[:mouse_move, 229, 254, 2, 427, 1177] -[:mouse_move, 210, 250, 2, 428, 1178] -[:mouse_move, 199, 249, 2, 429, 1179] -[:mouse_move, 184, 248, 2, 430, 1180] -[:mouse_move, 173, 248, 2, 431, 1181] -[:mouse_move, 153, 248, 2, 432, 1182] -[:mouse_move, 145, 249, 2, 433, 1183] -[:mouse_move, 138, 251, 2, 434, 1184] -[:mouse_move, 125, 257, 2, 435, 1185] -[:mouse_move, 121, 260, 2, 436, 1186] -[:mouse_move, 112, 267, 2, 437, 1187] -[:mouse_move, 101, 280, 2, 438, 1188] -[:mouse_move, 97, 287, 2, 439, 1189] -[:mouse_move, 86, 306, 2, 440, 1190] -[:mouse_move, 81, 316, 2, 441, 1191] -[:mouse_move, 79, 322, 2, 442, 1192] -[:mouse_move, 70, 345, 2, 443, 1193] -[:mouse_move, 63, 365, 2, 444, 1194] -[:mouse_move, 59, 389, 2, 445, 1195] -[:mouse_move, 59, 401, 2, 446, 1196] -[:mouse_move, 59, 416, 2, 447, 1197] -[:mouse_move, 59, 425, 2, 448, 1198] -[:mouse_move, 60, 439, 2, 449, 1199] -[:mouse_move, 60, 442, 2, 450, 1200] -[:mouse_move, 64, 454, 2, 451, 1201] -[:mouse_move, 66, 457, 2, 452, 1202] -[:mouse_move, 70, 462, 2, 453, 1203] -[:mouse_move, 74, 464, 2, 454, 1204] -[:mouse_move, 81, 467, 2, 455, 1205] -[:mouse_move, 85, 468, 2, 456, 1206] -[:mouse_move, 97, 469, 2, 457, 1207] -[:mouse_move, 107, 469, 2, 458, 1208] -[:mouse_move, 124, 471, 2, 459, 1209] -[:mouse_move, 134, 471, 2, 460, 1210] -[:mouse_move, 148, 471, 2, 461, 1211] -[:mouse_move, 161, 468, 2, 462, 1212] -[:mouse_move, 178, 457, 2, 463, 1213] -[:mouse_move, 186, 451, 2, 464, 1214] -[:mouse_move, 202, 434, 2, 465, 1215] -[:mouse_move, 210, 424, 2, 466, 1216] -[:mouse_move, 227, 400, 2, 467, 1217] -[:mouse_move, 234, 388, 2, 468, 1218] -[:mouse_move, 237, 383, 2, 469, 1219] -[:mouse_move, 250, 360, 2, 470, 1220] -[:mouse_move, 254, 351, 2, 471, 1221] -[:mouse_move, 261, 334, 2, 472, 1222] -[:mouse_move, 262, 326, 2, 473, 1223] -[:mouse_move, 264, 312, 2, 474, 1224] -[:mouse_move, 265, 305, 2, 475, 1225] -[:mouse_move, 265, 293, 2, 476, 1226] -[:mouse_move, 265, 287, 2, 477, 1227] -[:mouse_move, 259, 272, 2, 478, 1228] -[:mouse_move, 255, 267, 2, 479, 1229] -[:mouse_move, 246, 260, 2, 480, 1230] -[:mouse_move, 239, 257, 2, 481, 1231] -[:mouse_move, 226, 253, 2, 482, 1232] -[:mouse_move, 213, 251, 2, 483, 1233] -[:mouse_move, 194, 251, 2, 484, 1234] -[:mouse_move, 184, 252, 2, 485, 1235] -[:mouse_move, 163, 259, 2, 486, 1236] -[:mouse_move, 153, 263, 2, 487, 1237] -[:mouse_move, 133, 274, 2, 488, 1238] -[:mouse_move, 128, 278, 2, 489, 1239] -[:mouse_move, 107, 297, 2, 490, 1240] -[:mouse_move, 100, 305, 2, 491, 1241] -[:mouse_move, 86, 324, 2, 492, 1242] -[:mouse_move, 79, 335, 2, 493, 1243] -[:mouse_move, 74, 348, 2, 494, 1244] -[:mouse_move, 66, 388, 2, 495, 1245] -[:mouse_move, 66, 399, 2, 496, 1246] -[:mouse_move, 68, 429, 2, 497, 1247] -[:mouse_move, 73, 441, 2, 498, 1248] -[:mouse_move, 83, 452, 2, 499, 1249] -[:mouse_move, 89, 457, 2, 500, 1250] -[:mouse_move, 97, 462, 2, 501, 1251] -[:key_down_raw, 1073741906, 0, 2, 502, 1292] -[:key_up_raw, 1073741906, 0, 2, 503, 1296] -[:key_down_raw, 1073741906, 0, 2, 504, 1309] -[:key_up_raw, 1073741906, 0, 2, 505, 1314] -[:key_down_raw, 1073741906, 0, 2, 506, 1319] -[:key_up_raw, 1073741906, 0, 2, 507, 1322] -[:key_down_raw, 1073741906, 0, 2, 508, 1327] -[:key_up_raw, 1073741906, 0, 2, 509, 1331] -[:key_down_raw, 1073741906, 0, 2, 510, 1336] -[:key_up_raw, 1073741906, 0, 2, 511, 1339] -[:key_down_raw, 1073741906, 0, 2, 512, 1345] -[:key_up_raw, 1073741906, 0, 2, 513, 1348] -[:key_down_raw, 1073741906, 0, 2, 514, 1354] -[:key_up_raw, 1073741906, 0, 2, 515, 1358] -[:key_down_raw, 1073741906, 0, 2, 516, 1362] -[:key_up_raw, 1073741906, 0, 2, 517, 1370] -[:key_down_raw, 1073741903, 0, 2, 518, 1386] -[:key_up_raw, 1073741903, 0, 2, 519, 1392] -[:key_down_raw, 1073741903, 0, 2, 520, 1397] -[:key_up_raw, 1073741903, 0, 2, 521, 1401] -[:key_down_raw, 1073741903, 0, 2, 522, 1407] -[:key_up_raw, 1073741903, 0, 2, 523, 1412] -[:key_down_raw, 1073741903, 0, 2, 524, 1415] -[:key_up_raw, 1073741903, 0, 2, 525, 1421] -[:key_down_raw, 1073741903, 0, 2, 526, 1428] -[:key_up_raw, 1073741903, 0, 2, 527, 1436] -[:key_down_raw, 1073741905, 0, 2, 528, 1446] -[:key_up_raw, 1073741905, 0, 2, 529, 1458] -[:key_down_raw, 1073741905, 0, 2, 530, 1466] -[:key_up_raw, 1073741905, 0, 2, 531, 1472] -[:key_down_raw, 1073741903, 0, 2, 532, 1479] -[:key_up_raw, 1073741903, 0, 2, 533, 1489] -[:key_down_raw, 1073741905, 0, 2, 534, 1513] -[:key_up_raw, 1073741905, 0, 2, 535, 1517] -[:key_down_raw, 1073741905, 0, 2, 536, 1522] -[:key_up_raw, 1073741905, 0, 2, 537, 1526] -[:key_down_raw, 1073741905, 0, 2, 538, 1531] -[:key_up_raw, 1073741905, 0, 2, 539, 1535] -[:key_down_raw, 1073741905, 0, 2, 540, 1540] -[:key_up_raw, 1073741905, 0, 2, 541, 1544] -[:key_down_raw, 1073741905, 0, 2, 542, 1549] -[:key_up_raw, 1073741905, 0, 2, 543, 1554] -[:key_down_raw, 1073741905, 0, 2, 544, 1558] -[:key_up_raw, 1073741905, 0, 2, 545, 1564] -[:key_down_raw, 1073742051, 1024, 2, 546, 1663] -[:key_down_raw, 114, 1024, 2, 547, 1664] -[:key_up_raw, 114, 1024, 2, 548, 1669] -[:key_up_raw, 1073742051, 0, 2, 549, 1677] -[:key_down_raw, 1073742051, 1024, 2, 550, 1729] -[:key_down_raw, 113, 1024, 2, 551, 1730] diff --git a/samples/99_genre_rpg_tactical/gameboard_movement/app/main.rb b/samples/99_genre_rpg_tactical/gameboard_movement/app/main.rb deleted file mode 100644 index 8eb935e..0000000 --- a/samples/99_genre_rpg_tactical/gameboard_movement/app/main.rb +++ /dev/null @@ -1,529 +0,0 @@ -# Size of board is always 1280x720 - -def tick args - size = 64 - - # Draw a checkerboard as a placeholder game board - i = 0 - j = 0 - while i < 12 do - while j < 21 do - args.outputs.solids << [(j*size), (i*size), size, size, 255, 100, 0, ((i+j) % 2 == 0) ? 255 : 0] - j += 1 - end - j = 0 - i += 1 - end - k = 0 - ary = Array.new(220) - while k < 220 - ary[k] = 1 - if k > 20 and k < 36 - ary[k] = 0 - end - if k > 40 and k < 56 - ary[k] = 0 - end - if k > 60 and k < 76 - ary[k] = 0 - end - if k > 80 and k < 96 - ary[k] = 0 - end - if k > 100 and k < 116 - ary[k] = 0 - end - if k > 120 and k < 136 - ary[k] = 0 - end - if k == 161 and args.state.bot3.hp >= 1 - ary[k] = 0 - end - if k == 147 and args.state.bot1.hp >= 1 - ary[k] = 0 - end - if k == 215 and args.state.bot2.hp >= 1 - ary[k] = 0 - end - k += 1 - end - ary2 = ary; - htarget = 161 - target = 160 - targetb = 181 - targetc = 141 - targetd = 162 - target2 = 146 - target2b = 167 - target2c = 148 - htarget2 = 147 - target3 = 214 - target3c = 216 - target3b = 195 - htarget3 = 215 - # player attributes - args.state.player.x ||= 0 - args.state.player.y ||= 0 - args.state.player.w ||= 64 - args.state.player.h ||= 64 - args.state.player.direction ||= 1 - args.state.player.hp ||= 100 - args.state.player.strength ||= 100 - args.state.player.pos ||= 0 - - # bot1 attributes - args.state.bot1.x ||= 448 - args.state.bot1.y ||= 448 - args.state.bot1.w ||= 64 - args.state.bot1.h ||= 64 - args.state.bot1.direction ||= 1 - args.state.bot1.hp ||= 100 - args.state.bot1.strength ||= 5 - - # bot2 attributes - args.state.bot2.x ||= 960 - args.state.bot2.y ||= 640 - args.state.bot2.w ||= 64 - args.state.bot2.h ||= 64 - args.state.bot2.direction ||= 1 - args.state.bot2.hp ||= 100 - args.state.bot2.strength ||= 8 - - # bot3 attributes - args.state.bot3.x ||= 64 - args.state.bot3.y ||= 512 - args.state.bot3.w ||= 64 - args.state.bot3.h ||= 64 - args.state.bot3.direction ||= 1 - args.state.bot3.hp ||= 100 - args.state.bot3.strength ||= 8 - - # obstacle attributes - args.state.obs1.x ||= 64 - args.state.obs1.y ||= 64 - args.state.obs1.w ||= 960 - args.state.obs1.h ||= 384 - args.state.obs1.direction ||= 1 - - - @menu_shown ||= :hidden - - # display menu - if @menu_shown == :hidden - args.state.menu_button ||= new_button :menu, 1081, 650, "Menu" - args.outputs.primitives << args.state.menu_button[:primitives] - - if button_clicked? args, args.state.menu_button - @menu_shown = :visible - end - - else - args.state.menu_overlay = [1080, 0, 200, 720, 100, 0, 0, 250] - - # first overlay - if args.state.menu_overlay - args.outputs.solids << args.state.menu_overlay - - # move button - args.state.move_button ||= new_button :move, 1081, 650, "Move" - args.outputs.primitives << args.state.move_button[:primitives] - - if button_clicked? args, args.state.move_button - args.gtk.notify! "Move button was clicked!" - end - - # attack button - args.state.attack_button ||= new_button :attack, 1081, 600, "Attack" - args.outputs.primitives << args.state.attack_button[:primitives] - - if button_clicked? args, args.state.attack_button - - if args.state.player.pos+1 == htarget or args.state.player.pos-1 == htarget or args.state.player.pos+20 == htarget or args.state.player.pos-20 == htarget - damage = rand(100) - dealt = "#{damage} Damage Dealt!" - args.gtk.notify! dealt - args.state.bot3.hp -= damage - - end - if args.state.player.pos+1 == htarget2 or args.state.player.pos-1 == htarget2 or args.state.player.pos+20 == htarget2 or args.state.player.pos-20 == htarget2 - damage = rand(100) - dealt = "#{damage} Damage Dealt!" - args.gtk.notify! dealt - - args.state.bot1.hp -= damage - - end - if args.state.player.pos+1 == htarget3 or args.state.player.pos-1 == htarget3 or args.state.player.pos+20 == htarget3 or args.state.player.pos-20 == htarget3 - damage = rand(100) - dealt = "#{damage} Damage Dealt!" - args.gtk.notify! dealt - args.state.bot2.hp -= damage - - end - end - - # items button - args.state.items_button ||= new_button :items, 1081, 550, "Items" - args.outputs.primitives << args.state.items_button[:primitives] - - if button_clicked? args, args.state.items_button - args.state.itemMenu_overlay = [880, 0, 200, 720, 150, 0, 0, 250] - args.gtk.notify! "Items button was clicked!" - end - - # second overlay - if args.state.itemMenu_overlay - args.outputs.solids << args.state.itemMenu_overlay - args.outputs.labels << [960, 700, "Items"] - - # create items - args.state.potion_button ||= new_button :potion, 881, 600, "Potion" - args.outputs.primitives << args.state.potion_button[:primitives] - - if button_clicked? args, args.state.potion_button - args.gtk.notify! "Potion Used!" - end - - args.state.elixer_button ||= new_button :potion, 881, 550, "Elixer" - args.outputs.primitives << args.state.elixer_button[:primitives] - - if button_clicked? args, args.state.elixer_button - args.gtk.notify! "Elixer Used!" - end - - end - - # wait button - args.state.wait_button ||= new_button :wait, 1081, 500, "Wait" - args.outputs.primitives << args.state.wait_button[:primitives] - - if button_clicked? args, args.state.wait_button - args.gtk.notify! "Wait button was clicked!" - end - - # close button - args.state.close_button ||= new_button :close, 1081, 450, "Close" - args.outputs.primitives << args.state.close_button[:primitives] - - # hide menu - if button_clicked? args, args.state.close_button - @menu_shown = :hidden - end - - end - end - - # left and right movement - if args.inputs.keyboard.key_down.right and ary[args.state.player.pos+1] == 1 and args.state.player.pos%20 < 19 - args.state.player.direction = 1 - args.state.player.started_running_at = args.state.tick_count - args.state.player.x += size - args.state.player.pos += 1 - elsif args.inputs.keyboard.key_down.left and ary[args.state.player.pos-1] == 1 and args.state.player.pos%20 > 0 - args.state.player.direction = -1 - args.state.player.started_running_at = args.state.tick_count - args.state.player.x -= size - args.state.player.pos -= 1 - end - - - - - # up and down movement - if args.inputs.keyboard.key_down.up and ary[args.state.player.pos+20] == 1 and args.state.player.pos < 200 - args.state.player.direction = 1 - args.state.player.started_running_at = args.state.tick_count - args.state.player.y += size - args.state.player.pos += 20 - elsif args.inputs.keyboard.key_down.down and ary[args.state.player.pos-20] == 1 and args.state.player.pos >= 20 - args.state.player.direction = -1 - args.state.player.started_running_at = args.state.tick_count - args.state.player.y -= size - args.state.player.pos -= 20 - end - - pigga = args.state.player.intersect_rect? args.state.obs1 - if pigga - args.gtk.notify! "sprites collide!" - args.state.player.y -= size - end - looping = true - cangoup = false - cangoright = false - cangodown = false - cangoleft = false - ftarget = 10000 - hold = 9 - testtarget = args.state.player.pos - if args.state.bot3.hp > 0 - ftarget = (target-testtarget).abs - hold = target - end - if(ftarget > (targetb-testtarget).abs and args.state.bot3.hp > 0) - ftarget = (targetb-testtarget).abs - hold = targetb - end - if(ftarget > (targetc-testtarget).abs and args.state.bot3.hp > 0) - ftarget = (targetc-testtarget).abs - hold = targetc - end - if(ftarget > (targetd-testtarget).abs and args.state.bot3.hp > 0) - ftarget = (targetd-testtarget).abs - hold = targetd - end - if(ftarget > (target2-testtarget).abs and args.state.bot1.hp > 0) - ftarget = (target2-testtarget).abs - hold = target2 - end - if(ftarget > (target2b-testtarget).abs and args.state.bot1.hp > 0) - ftarget = (target2b-testtarget).abs - hold = target2b - end - if(ftarget > (target2c-testtarget).abs and args.state.bot1.hp > 0) - ftarget = (target2c-testtarget).abs - hold = target2c - end - if(ftarget > (target3-testtarget).abs and args.state.bot2.hp > 0) - ftarget = (target3-testtarget).abs - hold = target3 - end - if(ftarget > (target3b-testtarget).abs and args.state.bot2.hp > 0) - ftarget = (target3b-testtarget).abs - hold = target3b - end - if(ftarget > (target3c-testtarget).abs and args.state.bot2.hp > 0) - ftarget = (target3c-testtarget).abs - hold = target3c - end - if ftarget == 10000 - looping = false - end - if args.inputs.keyboard.key_down.f - while looping and target != testtarget and targetb != testtarget and targetc != testtarget and targetd != testtarget and target2 != testtarget and target2b != testtarget and target2c != testtarget and target3 != testtarget and target3b != testtarget and target3c != testtarget - cangoup = false - cangoright = false - cangodown = false - cangoleft = false - - if hold-testtarget >= 20 and ary2[args.state.player.pos+20] == 1 and args.state.player.pos < 200 - cangoup = true - elsif testtarget-hold >= 20 and ary2[args.state.player.pos-20] == 1 and args.state.player.pos > 20 - cangodown = true - cangoup = false - elsif hold%20-testtarget%20 > 0 and ary2[args.state.player.pos+1] == 1 and args.state.player.pos%20 < 19 - cangodown = false - cangoup = false - cangoright = true - elsif testtarget%20-hold%20 > 0 and ary2[args.state.player.pos-1] == 1 and args.state.player.pos%20 > 0 - cangodown = false - cangoup = false - cangoright = false - cangoleft = true - end - if cangodown == false and cangoup == false and cangoleft == false and cangoright == false - if ary2[args.state.player.pos+20] == 1 and args.state.player.pos < 200 - cangoup = true - elsif ary2[args.state.player.pos-20] == 1 and args.state.player.pos > 20 - cangodown = true - cangoup = false - elsif ary2[args.state.player.pos+1] == 1 and args.state.player.pos%20 < 19 - cangodown = false - cangoup = false - cangoright = true - elsif ary2[args.state.player.pos-1] == 1 and args.state.player.pos%20 > 0 - cangodown = false - cangoup = false - cangoright = false - cangoleft = true - end - end - if cangodown == true - args.state.player.direction = -1 - args.state.player.started_running_at = args.state.tick_count - args.state.player.y -= size - ary2[args.state.player.pos] = 0 - args.state.player.pos -= 20 - testtarget -= 20 - - elsif cangoup == true - args.state.player.direction = 1 - args.state.player.started_running_at = args.state.tick_count - args.state.player.y += size - ary2[args.state.player.pos] = 0 - args.state.player.pos += 20 - testtarget+=20 - - elsif cangoright == true - args.state.player.direction = 1 - args.state.player.started_running_at = args.state.tick_count - args.state.player.x += size - ary2[args.state.player.pos] = 0 - args.state.player.pos += 1 - testtarget += 1 - - elsif cangoleft == true - args.state.player.direction = -1 - args.state.player.started_running_at = args.state.tick_count - args.state.player.x -= size - ary2[args.state.player.pos] = 0 - args.state.player.pos -= 1 - testtarget -= 1 - end - - end - end - - - #Wrap player around the stage - if args.state.player.x > 1280 - args.state.player.x = -64 - args.state.player.started_running_at ||= args.state.tick_count - elsif args.state.player.x < -64 - args.state.player.x = 1280 - args.state.player.started_running_at ||= args.state.tick_count - end - - if args.state.player.y > 720 - args.state.player.y = -64 - args.state.player.started_running_at ||= args.state.tick_count - elsif args.state.player.y < -64 - args.state.player.y = 720 - args.state.player.started_running_at ||= args.state.tick_count - end - - # Display obstacles - args.outputs.sprites << display_obs1(args) - - #Display the flying dragon and bots - args.outputs.sprites << display_dragon(args) - if args.state.bot1.hp >= 1 - args.outputs.sprites << display_bot1(args) - end - if args.state.bot2.hp >= 1 - args.outputs.sprites << display_bot2(args) - end - if args.state.bot3.hp >= 1 - args.outputs.sprites << display_bot3(args) - end - if args.state.bot1.hp <= 0 and args.state.bot3.hp <= 0 and args.state.bot2.hp <= 0 - args.gtk.notify! "You Win!" - end -end - -# helper method to create a button -def new_button id, x, y, text - # create a hash ("entity") that has some metadata - # about what it represents - entity = - { - id: id, - rect: { x: x, y: y, w: 200, h: 50 } - } - - # for that entity, define the primitives - # that form it - entity[:primitives] = - [ - { x: x, y: y, w: 200, h: 50 }.border, - { x: x + 75, y: y + 30, text: text }.label - ] - - entity -end - -# helper method for determining if a button was clicked -def button_clicked? args, button - return false unless args.inputs.mouse.click - return args.inputs.mouse.point.inside_rect? button[:rect] -end - -def display_dragon args - start_looping_at = 0 - number_of_sprites = 2 - number_of_frames_to_show_each_sprite = 8 - does_sprite_loop = true - sprite_index = start_looping_at.frame_index number_of_sprites, - number_of_frames_to_show_each_sprite, - does_sprite_loop - { - pos: args.state.player.pos, - x: args.state.player.x, - y: args.state.player.y, - w: args.state.player.w, - h: args.state.player.h, - path: "sprites/roy-#{sprite_index}.png", - flip_horizontally: args.state.player.direction < 0 - } -end - -def display_bot1 args - start_looping_at = 0 - number_of_sprites = 6 - number_of_frames_to_show_each_sprite = 4 - does_sprite_loop = true - sprite_index = start_looping_at.frame_index number_of_sprites, - number_of_frames_to_show_each_sprite, - does_sprite_loop - { - x: args.state.bot1.x, - y: args.state.bot1.y, - w: args.state.bot1.w, - h: args.state.bot1.h, - path: "sprites/dragon-#{sprite_index}.png", - flip_horizontally: args.state.bot1.direction < 0 - } -end - -def display_bot2 args - start_looping_at = 0 - number_of_sprites = 6 - number_of_frames_to_show_each_sprite = 4 - does_sprite_loop = true - sprite_index = start_looping_at.frame_index number_of_sprites, - number_of_frames_to_show_each_sprite, - does_sprite_loop - { - x: args.state.bot2.x, - y: args.state.bot2.y, - w: args.state.bot2.w, - h: args.state.bot2.h, - path: "sprites/dragon-#{sprite_index}.png", - flip_horizontally: args.state.bot2.direction < 0 - } -end - -def display_bot3 args - start_looping_at = 0 - number_of_sprites = 6 - number_of_frames_to_show_each_sprite = 4 - does_sprite_loop = true - sprite_index = start_looping_at.frame_index number_of_sprites, - number_of_frames_to_show_each_sprite, - does_sprite_loop - { - x: args.state.bot3.x, - y: args.state.bot3.y, - w: args.state.bot3.w, - h: args.state.bot3.h, - path: "sprites/dragon-#{sprite_index}.png", - flip_horizontally: args.state.bot3.direction < 0 - } -end - -def display_obs1 args - start_looping_at = 0 - number_of_sprites = 1 - number_of_frames_to_show_each_sprite = 8 - does_sprite_loop = true - sprite_index = start_looping_at.frame_index number_of_sprites, - number_of_frames_to_show_each_sprite, - does_sprite_loop - { - x: args.state.obs1.x, - y: args.state.obs1.y, - w: args.state.obs1.w, - h: args.state.obs1.h, - path: "sprites/water-1.png", - flip_horizontally: args.state.obs1.direction < 0 - } -end diff --git a/samples/99_genre_rpg_tactical/gameboard_movement/sprites/border-black.png b/samples/99_genre_rpg_tactical/gameboard_movement/sprites/border-black.png deleted file mode 100644 index c9d0bad..0000000 Binary files a/samples/99_genre_rpg_tactical/gameboard_movement/sprites/border-black.png and /dev/null differ diff --git a/samples/99_genre_rpg_tactical/gameboard_movement/sprites/circle-black.png b/samples/99_genre_rpg_tactical/gameboard_movement/sprites/circle-black.png deleted file mode 100644 index c98e23d..0000000 Binary files a/samples/99_genre_rpg_tactical/gameboard_movement/sprites/circle-black.png and /dev/null differ diff --git a/samples/99_genre_rpg_tactical/gameboard_movement/sprites/circle-blue.png b/samples/99_genre_rpg_tactical/gameboard_movement/sprites/circle-blue.png deleted file mode 100644 index 1726d2a..0000000 Binary files a/samples/99_genre_rpg_tactical/gameboard_movement/sprites/circle-blue.png and /dev/null differ diff --git a/samples/99_genre_rpg_tactical/gameboard_movement/sprites/circle-gray.png b/samples/99_genre_rpg_tactical/gameboard_movement/sprites/circle-gray.png deleted file mode 100644 index 960f191..0000000 Binary files a/samples/99_genre_rpg_tactical/gameboard_movement/sprites/circle-gray.png and /dev/null differ diff --git a/samples/99_genre_rpg_tactical/gameboard_movement/sprites/circle-green.png b/samples/99_genre_rpg_tactical/gameboard_movement/sprites/circle-green.png deleted file mode 100644 index 43cf7ee..0000000 Binary files a/samples/99_genre_rpg_tactical/gameboard_movement/sprites/circle-green.png and /dev/null differ diff --git a/samples/99_genre_rpg_tactical/gameboard_movement/sprites/circle-indigo.png b/samples/99_genre_rpg_tactical/gameboard_movement/sprites/circle-indigo.png deleted file mode 100644 index 598e240..0000000 Binary files a/samples/99_genre_rpg_tactical/gameboard_movement/sprites/circle-indigo.png and /dev/null differ diff --git a/samples/99_genre_rpg_tactical/gameboard_movement/sprites/circle-orange.png b/samples/99_genre_rpg_tactical/gameboard_movement/sprites/circle-orange.png deleted file mode 100644 index 5604a42..0000000 Binary files a/samples/99_genre_rpg_tactical/gameboard_movement/sprites/circle-orange.png and /dev/null differ diff --git a/samples/99_genre_rpg_tactical/gameboard_movement/sprites/circle-red.png b/samples/99_genre_rpg_tactical/gameboard_movement/sprites/circle-red.png deleted file mode 100644 index 7f17ca6..0000000 Binary files a/samples/99_genre_rpg_tactical/gameboard_movement/sprites/circle-red.png and /dev/null differ diff --git a/samples/99_genre_rpg_tactical/gameboard_movement/sprites/circle-violet.png b/samples/99_genre_rpg_tactical/gameboard_movement/sprites/circle-violet.png deleted file mode 100644 index 681d210..0000000 Binary files a/samples/99_genre_rpg_tactical/gameboard_movement/sprites/circle-violet.png and /dev/null differ diff --git a/samples/99_genre_rpg_tactical/gameboard_movement/sprites/circle-white.png b/samples/99_genre_rpg_tactical/gameboard_movement/sprites/circle-white.png deleted file mode 100644 index bd32155..0000000 Binary files a/samples/99_genre_rpg_tactical/gameboard_movement/sprites/circle-white.png and /dev/null differ diff --git a/samples/99_genre_rpg_tactical/gameboard_movement/sprites/circle-yellow.png b/samples/99_genre_rpg_tactical/gameboard_movement/sprites/circle-yellow.png deleted file mode 100644 index 94992eb..0000000 Binary files a/samples/99_genre_rpg_tactical/gameboard_movement/sprites/circle-yellow.png and /dev/null differ diff --git a/samples/99_genre_rpg_tactical/gameboard_movement/sprites/dragon-0.png b/samples/99_genre_rpg_tactical/gameboard_movement/sprites/dragon-0.png deleted file mode 100644 index fb179af..0000000 Binary files a/samples/99_genre_rpg_tactical/gameboard_movement/sprites/dragon-0.png and /dev/null differ diff --git a/samples/99_genre_rpg_tactical/gameboard_movement/sprites/dragon-1.png b/samples/99_genre_rpg_tactical/gameboard_movement/sprites/dragon-1.png deleted file mode 100644 index 8cfe531..0000000 Binary files a/samples/99_genre_rpg_tactical/gameboard_movement/sprites/dragon-1.png and /dev/null differ diff --git a/samples/99_genre_rpg_tactical/gameboard_movement/sprites/dragon-2.png b/samples/99_genre_rpg_tactical/gameboard_movement/sprites/dragon-2.png deleted file mode 100644 index cb462e1..0000000 Binary files a/samples/99_genre_rpg_tactical/gameboard_movement/sprites/dragon-2.png and /dev/null differ diff --git a/samples/99_genre_rpg_tactical/gameboard_movement/sprites/dragon-3.png b/samples/99_genre_rpg_tactical/gameboard_movement/sprites/dragon-3.png deleted file mode 100644 index 04c4977..0000000 Binary files a/samples/99_genre_rpg_tactical/gameboard_movement/sprites/dragon-3.png and /dev/null differ diff --git a/samples/99_genre_rpg_tactical/gameboard_movement/sprites/dragon-4.png b/samples/99_genre_rpg_tactical/gameboard_movement/sprites/dragon-4.png deleted file mode 100644 index b29fa3d..0000000 Binary files a/samples/99_genre_rpg_tactical/gameboard_movement/sprites/dragon-4.png and /dev/null differ diff --git a/samples/99_genre_rpg_tactical/gameboard_movement/sprites/dragon-5.png b/samples/99_genre_rpg_tactical/gameboard_movement/sprites/dragon-5.png deleted file mode 100644 index 99f4e74..0000000 Binary files a/samples/99_genre_rpg_tactical/gameboard_movement/sprites/dragon-5.png and /dev/null differ diff --git a/samples/99_genre_rpg_tactical/gameboard_movement/sprites/explosion-0.png b/samples/99_genre_rpg_tactical/gameboard_movement/sprites/explosion-0.png deleted file mode 100644 index f48636f..0000000 Binary files a/samples/99_genre_rpg_tactical/gameboard_movement/sprites/explosion-0.png and /dev/null differ diff --git a/samples/99_genre_rpg_tactical/gameboard_movement/sprites/explosion-1.png b/samples/99_genre_rpg_tactical/gameboard_movement/sprites/explosion-1.png deleted file mode 100644 index b4018d9..0000000 Binary files a/samples/99_genre_rpg_tactical/gameboard_movement/sprites/explosion-1.png and /dev/null differ diff --git a/samples/99_genre_rpg_tactical/gameboard_movement/sprites/explosion-2.png b/samples/99_genre_rpg_tactical/gameboard_movement/sprites/explosion-2.png deleted file mode 100644 index 3abaedd..0000000 Binary files a/samples/99_genre_rpg_tactical/gameboard_movement/sprites/explosion-2.png and /dev/null differ diff --git a/samples/99_genre_rpg_tactical/gameboard_movement/sprites/explosion-3.png b/samples/99_genre_rpg_tactical/gameboard_movement/sprites/explosion-3.png deleted file mode 100644 index fe94a5a..0000000 Binary files a/samples/99_genre_rpg_tactical/gameboard_movement/sprites/explosion-3.png and /dev/null differ diff --git a/samples/99_genre_rpg_tactical/gameboard_movement/sprites/explosion-4.png b/samples/99_genre_rpg_tactical/gameboard_movement/sprites/explosion-4.png deleted file mode 100644 index ed04237..0000000 Binary files a/samples/99_genre_rpg_tactical/gameboard_movement/sprites/explosion-4.png and /dev/null differ diff --git a/samples/99_genre_rpg_tactical/gameboard_movement/sprites/explosion-5.png b/samples/99_genre_rpg_tactical/gameboard_movement/sprites/explosion-5.png deleted file mode 100644 index 2cd8f06..0000000 Binary files a/samples/99_genre_rpg_tactical/gameboard_movement/sprites/explosion-5.png and /dev/null differ diff --git a/samples/99_genre_rpg_tactical/gameboard_movement/sprites/explosion-6.png b/samples/99_genre_rpg_tactical/gameboard_movement/sprites/explosion-6.png deleted file mode 100644 index e55909c..0000000 Binary files a/samples/99_genre_rpg_tactical/gameboard_movement/sprites/explosion-6.png and /dev/null differ diff --git a/samples/99_genre_rpg_tactical/gameboard_movement/sprites/explosion-sheet.png b/samples/99_genre_rpg_tactical/gameboard_movement/sprites/explosion-sheet.png deleted file mode 100644 index 8559a5c..0000000 Binary files a/samples/99_genre_rpg_tactical/gameboard_movement/sprites/explosion-sheet.png and /dev/null differ diff --git a/samples/99_genre_rpg_tactical/gameboard_movement/sprites/hexagon-black.png b/samples/99_genre_rpg_tactical/gameboard_movement/sprites/hexagon-black.png deleted file mode 100644 index f50c872..0000000 Binary files a/samples/99_genre_rpg_tactical/gameboard_movement/sprites/hexagon-black.png and /dev/null differ diff --git a/samples/99_genre_rpg_tactical/gameboard_movement/sprites/hexagon-blue.png b/samples/99_genre_rpg_tactical/gameboard_movement/sprites/hexagon-blue.png deleted file mode 100644 index 1696bae..0000000 Binary files a/samples/99_genre_rpg_tactical/gameboard_movement/sprites/hexagon-blue.png and /dev/null differ diff --git a/samples/99_genre_rpg_tactical/gameboard_movement/sprites/hexagon-gray.png b/samples/99_genre_rpg_tactical/gameboard_movement/sprites/hexagon-gray.png deleted file mode 100644 index e8c4c5a..0000000 Binary files a/samples/99_genre_rpg_tactical/gameboard_movement/sprites/hexagon-gray.png and /dev/null differ diff --git a/samples/99_genre_rpg_tactical/gameboard_movement/sprites/hexagon-green.png b/samples/99_genre_rpg_tactical/gameboard_movement/sprites/hexagon-green.png deleted file mode 100644 index a700602..0000000 Binary files a/samples/99_genre_rpg_tactical/gameboard_movement/sprites/hexagon-green.png and /dev/null differ diff --git a/samples/99_genre_rpg_tactical/gameboard_movement/sprites/hexagon-indigo.png b/samples/99_genre_rpg_tactical/gameboard_movement/sprites/hexagon-indigo.png deleted file mode 100644 index 15f6f4f..0000000 Binary files a/samples/99_genre_rpg_tactical/gameboard_movement/sprites/hexagon-indigo.png and /dev/null differ diff --git a/samples/99_genre_rpg_tactical/gameboard_movement/sprites/hexagon-orange.png b/samples/99_genre_rpg_tactical/gameboard_movement/sprites/hexagon-orange.png deleted file mode 100644 index 1587173..0000000 Binary files a/samples/99_genre_rpg_tactical/gameboard_movement/sprites/hexagon-orange.png and /dev/null differ diff --git a/samples/99_genre_rpg_tactical/gameboard_movement/sprites/hexagon-red.png b/samples/99_genre_rpg_tactical/gameboard_movement/sprites/hexagon-red.png deleted file mode 100644 index d442f39..0000000 Binary files a/samples/99_genre_rpg_tactical/gameboard_movement/sprites/hexagon-red.png and /dev/null differ diff --git a/samples/99_genre_rpg_tactical/gameboard_movement/sprites/hexagon-violet.png b/samples/99_genre_rpg_tactical/gameboard_movement/sprites/hexagon-violet.png deleted file mode 100644 index 3be5731..0000000 Binary files a/samples/99_genre_rpg_tactical/gameboard_movement/sprites/hexagon-violet.png and /dev/null differ diff --git a/samples/99_genre_rpg_tactical/gameboard_movement/sprites/hexagon-white.png b/samples/99_genre_rpg_tactical/gameboard_movement/sprites/hexagon-white.png deleted file mode 100644 index c1ad970..0000000 Binary files a/samples/99_genre_rpg_tactical/gameboard_movement/sprites/hexagon-white.png and /dev/null differ diff --git a/samples/99_genre_rpg_tactical/gameboard_movement/sprites/hexagon-yellow.png b/samples/99_genre_rpg_tactical/gameboard_movement/sprites/hexagon-yellow.png deleted file mode 100644 index 63f5f34..0000000 Binary files a/samples/99_genre_rpg_tactical/gameboard_movement/sprites/hexagon-yellow.png and /dev/null differ diff --git a/samples/99_genre_rpg_tactical/gameboard_movement/sprites/isometric-black.png b/samples/99_genre_rpg_tactical/gameboard_movement/sprites/isometric-black.png deleted file mode 100644 index fa9e463..0000000 Binary files a/samples/99_genre_rpg_tactical/gameboard_movement/sprites/isometric-black.png and /dev/null differ diff --git a/samples/99_genre_rpg_tactical/gameboard_movement/sprites/isometric-blue.png b/samples/99_genre_rpg_tactical/gameboard_movement/sprites/isometric-blue.png deleted file mode 100644 index a3d8524..0000000 Binary files a/samples/99_genre_rpg_tactical/gameboard_movement/sprites/isometric-blue.png and /dev/null differ diff --git a/samples/99_genre_rpg_tactical/gameboard_movement/sprites/isometric-gray.png b/samples/99_genre_rpg_tactical/gameboard_movement/sprites/isometric-gray.png deleted file mode 100644 index 85dcc1d..0000000 Binary files a/samples/99_genre_rpg_tactical/gameboard_movement/sprites/isometric-gray.png and /dev/null differ diff --git a/samples/99_genre_rpg_tactical/gameboard_movement/sprites/isometric-green.png b/samples/99_genre_rpg_tactical/gameboard_movement/sprites/isometric-green.png deleted file mode 100644 index ec2773e..0000000 Binary files a/samples/99_genre_rpg_tactical/gameboard_movement/sprites/isometric-green.png and /dev/null differ diff --git a/samples/99_genre_rpg_tactical/gameboard_movement/sprites/isometric-indigo.png b/samples/99_genre_rpg_tactical/gameboard_movement/sprites/isometric-indigo.png deleted file mode 100644 index e6be50c..0000000 Binary files a/samples/99_genre_rpg_tactical/gameboard_movement/sprites/isometric-indigo.png and /dev/null differ diff --git a/samples/99_genre_rpg_tactical/gameboard_movement/sprites/isometric-orange.png b/samples/99_genre_rpg_tactical/gameboard_movement/sprites/isometric-orange.png deleted file mode 100644 index 154d81c..0000000 Binary files a/samples/99_genre_rpg_tactical/gameboard_movement/sprites/isometric-orange.png and /dev/null differ diff --git a/samples/99_genre_rpg_tactical/gameboard_movement/sprites/isometric-red.png b/samples/99_genre_rpg_tactical/gameboard_movement/sprites/isometric-red.png deleted file mode 100644 index 3448c4d..0000000 Binary files a/samples/99_genre_rpg_tactical/gameboard_movement/sprites/isometric-red.png and /dev/null differ diff --git a/samples/99_genre_rpg_tactical/gameboard_movement/sprites/isometric-violet.png b/samples/99_genre_rpg_tactical/gameboard_movement/sprites/isometric-violet.png deleted file mode 100644 index f09bf21..0000000 Binary files a/samples/99_genre_rpg_tactical/gameboard_movement/sprites/isometric-violet.png and /dev/null differ diff --git a/samples/99_genre_rpg_tactical/gameboard_movement/sprites/isometric-white.png b/samples/99_genre_rpg_tactical/gameboard_movement/sprites/isometric-white.png deleted file mode 100644 index a45793d..0000000 Binary files a/samples/99_genre_rpg_tactical/gameboard_movement/sprites/isometric-white.png and /dev/null differ diff --git a/samples/99_genre_rpg_tactical/gameboard_movement/sprites/isometric-yellow.png b/samples/99_genre_rpg_tactical/gameboard_movement/sprites/isometric-yellow.png deleted file mode 100644 index 9be20c7..0000000 Binary files a/samples/99_genre_rpg_tactical/gameboard_movement/sprites/isometric-yellow.png and /dev/null differ diff --git a/samples/99_genre_rpg_tactical/gameboard_movement/sprites/roy-0.png b/samples/99_genre_rpg_tactical/gameboard_movement/sprites/roy-0.png deleted file mode 100644 index dd122e1..0000000 Binary files a/samples/99_genre_rpg_tactical/gameboard_movement/sprites/roy-0.png and /dev/null differ diff --git a/samples/99_genre_rpg_tactical/gameboard_movement/sprites/roy-1.png b/samples/99_genre_rpg_tactical/gameboard_movement/sprites/roy-1.png deleted file mode 100644 index d3ac548..0000000 Binary files a/samples/99_genre_rpg_tactical/gameboard_movement/sprites/roy-1.png and /dev/null differ diff --git a/samples/99_genre_rpg_tactical/gameboard_movement/sprites/square-black.png b/samples/99_genre_rpg_tactical/gameboard_movement/sprites/square-black.png deleted file mode 100644 index cea7bd7..0000000 Binary files a/samples/99_genre_rpg_tactical/gameboard_movement/sprites/square-black.png and /dev/null differ diff --git a/samples/99_genre_rpg_tactical/gameboard_movement/sprites/square-blue.png b/samples/99_genre_rpg_tactical/gameboard_movement/sprites/square-blue.png deleted file mode 100644 index b840849..0000000 Binary files a/samples/99_genre_rpg_tactical/gameboard_movement/sprites/square-blue.png and /dev/null differ diff --git a/samples/99_genre_rpg_tactical/gameboard_movement/sprites/square-gray.png b/samples/99_genre_rpg_tactical/gameboard_movement/sprites/square-gray.png deleted file mode 100644 index 2142b30..0000000 Binary files a/samples/99_genre_rpg_tactical/gameboard_movement/sprites/square-gray.png and /dev/null differ diff --git a/samples/99_genre_rpg_tactical/gameboard_movement/sprites/square-green.png b/samples/99_genre_rpg_tactical/gameboard_movement/sprites/square-green.png deleted file mode 100644 index 5ef7f75..0000000 Binary files a/samples/99_genre_rpg_tactical/gameboard_movement/sprites/square-green.png and /dev/null differ diff --git a/samples/99_genre_rpg_tactical/gameboard_movement/sprites/square-indigo.png b/samples/99_genre_rpg_tactical/gameboard_movement/sprites/square-indigo.png deleted file mode 100644 index 2384108..0000000 Binary files a/samples/99_genre_rpg_tactical/gameboard_movement/sprites/square-indigo.png and /dev/null differ diff --git a/samples/99_genre_rpg_tactical/gameboard_movement/sprites/square-orange.png b/samples/99_genre_rpg_tactical/gameboard_movement/sprites/square-orange.png deleted file mode 100644 index bb1eee7..0000000 Binary files a/samples/99_genre_rpg_tactical/gameboard_movement/sprites/square-orange.png and /dev/null differ diff --git a/samples/99_genre_rpg_tactical/gameboard_movement/sprites/square-red.png b/samples/99_genre_rpg_tactical/gameboard_movement/sprites/square-red.png deleted file mode 100644 index 3ed5f13..0000000 Binary files a/samples/99_genre_rpg_tactical/gameboard_movement/sprites/square-red.png and /dev/null differ diff --git a/samples/99_genre_rpg_tactical/gameboard_movement/sprites/square-violet.png b/samples/99_genre_rpg_tactical/gameboard_movement/sprites/square-violet.png deleted file mode 100644 index 333540c..0000000 Binary files a/samples/99_genre_rpg_tactical/gameboard_movement/sprites/square-violet.png and /dev/null differ diff --git a/samples/99_genre_rpg_tactical/gameboard_movement/sprites/square-white.png b/samples/99_genre_rpg_tactical/gameboard_movement/sprites/square-white.png deleted file mode 100644 index 378c565..0000000 Binary files a/samples/99_genre_rpg_tactical/gameboard_movement/sprites/square-white.png and /dev/null differ diff --git a/samples/99_genre_rpg_tactical/gameboard_movement/sprites/square-yellow.png b/samples/99_genre_rpg_tactical/gameboard_movement/sprites/square-yellow.png deleted file mode 100644 index 0edeeec..0000000 Binary files a/samples/99_genre_rpg_tactical/gameboard_movement/sprites/square-yellow.png and /dev/null differ diff --git a/samples/99_genre_rpg_tactical/gameboard_movement/sprites/star.png b/samples/99_genre_rpg_tactical/gameboard_movement/sprites/star.png deleted file mode 100644 index e0ee0f9..0000000 Binary files a/samples/99_genre_rpg_tactical/gameboard_movement/sprites/star.png and /dev/null differ diff --git a/samples/99_genre_rpg_tactical/gameboard_movement/sprites/water-1.png b/samples/99_genre_rpg_tactical/gameboard_movement/sprites/water-1.png deleted file mode 100644 index 527385a..0000000 Binary files a/samples/99_genre_rpg_tactical/gameboard_movement/sprites/water-1.png and /dev/null differ diff --git a/samples/99_genre_rpg_tactical/gameboard_movement/sprites/water-2.png b/samples/99_genre_rpg_tactical/gameboard_movement/sprites/water-2.png deleted file mode 100644 index 7f73b1b..0000000 Binary files a/samples/99_genre_rpg_tactical/gameboard_movement/sprites/water-2.png and /dev/null differ diff --git a/samples/99_genre_rpg_tactical/isometric_grid/app/main.rb b/samples/99_genre_rpg_tactical/isometric_grid/app/main.rb index 6c8368d..28bea32 100644 --- a/samples/99_genre_rpg_tactical/isometric_grid/app/main.rb +++ b/samples/99_genre_rpg_tactical/isometric_grid/app/main.rb @@ -10,10 +10,10 @@ class Isometric def defaults state.quantity ||= 6 #Size of grid - state.tileSize ||= [262 / 2, 194 / 2] #width and height of orange tiles + state.tileSize ||= [262 / 2, 194 / 2] #width and heigth of orange tiles state.tileGrid ||= [] #Holds ordering of tiles state.currentSpriteLocation ||= -1 #Current Sprite hovering location - state.tileCords ||= [] #Physical, rendering coordinates + state.tileCords ||= [] #Physical, rendering cordinates state.initCords ||= [640 - (state.quantity / 2 * state.tileSize[0]), 330] #Location of tile (0, 0) state.sideSize ||= [state.tileSize[0] / 2, 242 / 2] #Purple & green cube face size state.mode ||= :delete #Switches between :delete and :insert @@ -50,7 +50,7 @@ class Isometric end end - #Calculates physical coordinates for tiles + #Calculates physical cordinates for tiles if state.tileCords == [] state.tileCords = state.tileGrid.map do |val| @@ -101,7 +101,7 @@ class Isometric #Shows the tile itself. Important that it's rendered after the two above! outputs.sprites << state.tileCords.map do |val| - if val[2] == true #Checks if tile needs to be rendered + if val[2] == true #Chcekcs if tile needs to be rendered if val[5] == state.currentSpriteLocation [val[0], val[1], state.tileSize[0], state.tileSize[1], 'sprites/selectedTile.png'] else diff --git a/samples/99_genre_rpg_tactical/taking_turns/app/main.rb b/samples/99_genre_rpg_tactical/taking_turns/app/main.rb deleted file mode 100644 index aac6de7..0000000 --- a/samples/99_genre_rpg_tactical/taking_turns/app/main.rb +++ /dev/null @@ -1,189 +0,0 @@ -def tick args - args.state.base_columns ||= 10.times.map { |n| 50 * n + 1280 / 2 - 5 * 50 + 5 } - args.state.base_rows ||= 5.times.map { |n| 50 * n + 720 - 5 * 50 } - args.state.offset_columns = 10.times.map { |n| (n - 4.5) * Math.sin(Kernel.tick_count.to_radians) * 12 } - args.state.offset_rows = 5.map { 0 } - args.state.columns = 10.times.map { |i| args.state.base_columns[i] + args.state.offset_columns[i] } - args.state.rows = 5.times.map { |i| args.state.base_rows[i] + args.state.offset_rows[i] } - args.state.explosions ||= [] - args.state.enemies ||= [] - args.state.score ||= 0 - args.state.wave ||= 0 - if args.state.enemies.empty? - args.state.wave += 1 - args.state.wave_root = Math.sqrt(args.state.wave) - args.state.enemies = make_enemies - end - args.state.player ||= {x: 620, y: 80, w: 40, h: 40, path: 'sprites/circle-gray.png', angle: 90, cooldown: 0, alive: true} - args.state.enemy_bullets ||= [] - args.state.player_bullets ||= [] - args.state.lives ||= 3 - args.state.missed_shots ||= 0 - args.state.fired_shots ||= 0 - - update_explosions args - update_enemy_positions args - - if args.inputs.left && args.state.player[:x] > (300 + 5) - args.state.player[:x] -= 5 - end - if args.inputs.right && args.state.player[:x] < (1280 - args.state.player[:w] - 300 - 5) - args.state.player[:x] += 5 - end - - args.state.enemy_bullets.each do |bullet| - bullet[:x] += bullet[:dx] - bullet[:y] += bullet[:dy] - end - args.state.player_bullets.each do |bullet| - bullet[:x] += bullet[:dx] - bullet[:y] += bullet[:dy] - end - - args.state.enemy_bullets = args.state.enemy_bullets.find_all { |bullet| bullet[:y].between?(-16, 736) } - args.state.player_bullets = args.state.player_bullets.find_all do |bullet| - if bullet[:y].between?(-16, 736) - true - else - args.state.missed_shots += 1 - false - end - end - - args.state.enemies = args.state.enemies.reject do |enemy| - if args.state.player[:alive] && 1500 > (args.state.player[:x] - enemy[:x]) ** 2 + (args.state.player[:y] - enemy[:y]) ** 2 - args.state.explosions << {x: enemy[:x] + 4, y: enemy[:y] + 4, w: 32, h: 32, path: 'sprites/explosion-0.png', age: 0} - args.state.explosions << {x: args.state.player[:x] + 4, y: args.state.player[:y] + 4, w: 32, h: 32, path: 'sprites/explosion-0.png', age: 0} - args.state.player[:alive] = false - true - else - false - end - end - args.state.enemy_bullets.each do |bullet| - if args.state.player[:alive] && 400 > (args.state.player[:x] - bullet[:x] + 12) ** 2 + (args.state.player[:y] - bullet[:y] + 12) ** 2 - args.state.explosions << {x: args.state.player[:x] + 4, y: args.state.player[:y] + 4, w: 32, h: 32, path: 'sprites/explosion-0.png', age: 0} - args.state.player[:alive] = false - bullet[:despawn] = true - end - end - args.state.enemies = args.state.enemies.reject do |enemy| - args.state.player_bullets.any? do |bullet| - if 400 > (enemy[:x] - bullet[:x] + 12) ** 2 + (enemy[:y] - bullet[:y] + 12) ** 2 - args.state.explosions << {x: enemy[:x] + 4, y: enemy[:y] + 4, w: 32, h: 32, path: 'sprites/explosion-0.png', age: 0} - bullet[:despawn] = true - args.state.score += 1000 * args.state.wave - true - else - false - end - end - end - - args.state.player_bullets = args.state.player_bullets.reject { |bullet| bullet[:despawn] } - args.state.enemy_bullets = args.state.enemy_bullets.reject { |bullet| bullet[:despawn] } - - args.state.player[:cooldown] -= 1 - if args.inputs.keyboard.key_held.space && args.state.player[:cooldown] <= 0 && args.state.player[:alive] - args.state.player_bullets << {x: args.state.player[:x] + 12, y: args.state.player[:y] + 28, w: 16, h: 16, path: 'sprites/star.png', dx: 0, dy: 8}.sprite - args.state.fired_shots += 1 - args.state.player[:cooldown] = 10 + 20 / args.state.wave - end - args.state.enemies.each do |enemy| - if Math.rand < 0.0005 + 0.0005 * args.state.wave && args.state.player[:alive] && enemy[:move_state] == :normal - args.state.enemy_bullets << {x: enemy[:x] + 12, y: enemy[:y] - 8, w: 16, h: 16, path: 'sprites/star.png', dx: 0, dy: -3 - args.state.wave_root}.sprite - end - end - - args.outputs.background_color = [0, 0, 0] - args.outputs.primitives << args.state.enemies.map do |enemy| - [enemy[:x], enemy[:y], 40, 40, enemy[:path], -90].sprite - end - args.outputs.primitives << args.state.player if args.state.player[:alive] - args.outputs.primitives << args.state.explosions - args.outputs.primitives << args.state.player_bullets - args.outputs.primitives << args.state.enemy_bullets - accuracy = args.state.fired_shots.zero? ? 1 : (args.state.fired_shots - args.state.missed_shots) / args.state.fired_shots - args.outputs.primitives << [ - [0, 0, 300, 720, 96, 0, 0].solid, - [1280 - 300, 0, 300, 720, 96, 0, 0].solid, - [1280 - 290, 60, "Wave #{args.state.wave}", 255, 255, 255].label, - [1280 - 290, 40, "Accuracy #{(accuracy * 100).floor}%", 255, 255, 255].label, - [1280 - 290, 20, "Score #{(args.state.score * accuracy).floor}", 255, 255, 255].label, - ] - args.outputs.primitives << args.state.lives.times.map do |n| - [1280 - 290 + 50 * n, 80, 40, 40, 'sprites/circle-gray.png', 90].sprite - end - #args.outputs.debug << args.gtk.framerate_diagnostics_primitives - - if (!args.state.player[:alive]) && args.state.enemy_bullets.empty? && args.state.explosions.empty? && args.state.enemies.all? { |enemy| enemy[:move_state] == :normal } - args.state.player[:alive] = true - args.state.player[:x] = 624 - args.state.player[:y] = 80 - args.state.lives -= 1 - if args.state.lives == -1 - args.state.clear! - end - end -end - -def make_enemies - enemies = [] - enemies += 10.times.map { |n| {x: Math.rand * 1280 * 2 - 640, y: Math.rand * 720 * 2 + 720, row: 0, col: n, path: 'sprites/circle-orange.png', move_state: :retreat} } - enemies += 10.times.map { |n| {x: Math.rand * 1280 * 2 - 640, y: Math.rand * 720 * 2 + 720, row: 1, col: n, path: 'sprites/circle-orange.png', move_state: :retreat} } - enemies += 8.times.map { |n| {x: Math.rand * 1280 * 2 - 640, y: Math.rand * 720 * 2 + 720, row: 2, col: n + 1, path: 'sprites/circle-blue.png', move_state: :retreat} } - enemies += 8.times.map { |n| {x: Math.rand * 1280 * 2 - 640, y: Math.rand * 720 * 2 + 720, row: 3, col: n + 1, path: 'sprites/circle-blue.png', move_state: :retreat} } - enemies += 4.times.map { |n| {x: Math.rand * 1280 * 2 - 640, y: Math.rand * 720 * 2 + 720, row: 4, col: n + 3, path: 'sprites/circle-green.png', move_state: :retreat} } - enemies -end - -def update_explosions args - args.state.explosions.each do |explosion| - explosion[:age] += 0.5 - explosion[:path] = "sprites/explosion-#{explosion[:age].floor}.png" - end - args.state.explosions = args.state.explosions.reject { |explosion| explosion[:age] >= 7 } -end - -def update_enemy_positions args - args.state.enemies.each do |enemy| - if enemy[:move_state] == :normal - enemy[:x] = args.state.columns[enemy[:col]] - enemy[:y] = args.state.rows[enemy[:row]] - enemy[:move_state] = :dive if Math.rand < 0.0002 + 0.00005 * args.state.wave && args.state.player[:alive] - elsif enemy[:move_state] == :dive - enemy[:target_x] ||= args.state.player[:x] - enemy[:target_y] ||= args.state.player[:y] - dx = enemy[:target_x] - enemy[:x] - dy = enemy[:target_y] - enemy[:y] - vel = Math.sqrt(dx * dx + dy * dy) - speed_limit = 2 + args.state.wave_root - if vel > speed_limit - dx /= vel / speed_limit - dy /= vel / speed_limit - end - if vel < 1 || !args.state.player[:alive] - enemy[:move_state] = :retreat - end - enemy[:x] += dx - enemy[:y] += dy - elsif enemy[:move_state] == :retreat - enemy[:target_x] = args.state.columns[enemy[:col]] - enemy[:target_y] = args.state.rows[enemy[:row]] - dx = enemy[:target_x] - enemy[:x] - dy = enemy[:target_y] - enemy[:y] - vel = Math.sqrt(dx * dx + dy * dy) - speed_limit = 2 + args.state.wave_root - if vel > speed_limit - dx /= vel / speed_limit - dy /= vel / speed_limit - elsif vel < 1 - enemy[:move_state] = :normal - enemy[:target_x] = nil - enemy[:target_y] = nil - end - enemy[:x] += dx - enemy[:y] += dy - end - end -end diff --git a/samples/99_genre_rpg_tactical/taking_turns/run.bat b/samples/99_genre_rpg_tactical/taking_turns/run.bat deleted file mode 100644 index 36335e3..0000000 --- a/samples/99_genre_rpg_tactical/taking_turns/run.bat +++ /dev/null @@ -1,6 +0,0 @@ -cd /d %~dp0 - -cd .. -cd .. -cd .. -dragonruby samples/99_genre_arcade/dragalaga diff --git a/samples/99_genre_rpg_tactical/taking_turns/sprites/circle-blue.png b/samples/99_genre_rpg_tactical/taking_turns/sprites/circle-blue.png deleted file mode 100644 index 1726d2a..0000000 Binary files a/samples/99_genre_rpg_tactical/taking_turns/sprites/circle-blue.png and /dev/null differ diff --git a/samples/99_genre_rpg_tactical/taking_turns/sprites/circle-gray.png b/samples/99_genre_rpg_tactical/taking_turns/sprites/circle-gray.png deleted file mode 100644 index 960f191..0000000 Binary files a/samples/99_genre_rpg_tactical/taking_turns/sprites/circle-gray.png and /dev/null differ diff --git a/samples/99_genre_rpg_tactical/taking_turns/sprites/circle-green.png b/samples/99_genre_rpg_tactical/taking_turns/sprites/circle-green.png deleted file mode 100644 index 43cf7ee..0000000 Binary files a/samples/99_genre_rpg_tactical/taking_turns/sprites/circle-green.png and /dev/null differ diff --git a/samples/99_genre_rpg_tactical/taking_turns/sprites/circle-orange.png b/samples/99_genre_rpg_tactical/taking_turns/sprites/circle-orange.png deleted file mode 100644 index 5604a42..0000000 Binary files a/samples/99_genre_rpg_tactical/taking_turns/sprites/circle-orange.png and /dev/null differ diff --git a/samples/99_genre_rpg_tactical/taking_turns/sprites/explosion-0.png b/samples/99_genre_rpg_tactical/taking_turns/sprites/explosion-0.png deleted file mode 100644 index f48636f..0000000 Binary files a/samples/99_genre_rpg_tactical/taking_turns/sprites/explosion-0.png and /dev/null differ diff --git a/samples/99_genre_rpg_tactical/taking_turns/sprites/explosion-1.png b/samples/99_genre_rpg_tactical/taking_turns/sprites/explosion-1.png deleted file mode 100644 index b4018d9..0000000 Binary files a/samples/99_genre_rpg_tactical/taking_turns/sprites/explosion-1.png and /dev/null differ diff --git a/samples/99_genre_rpg_tactical/taking_turns/sprites/explosion-2.png b/samples/99_genre_rpg_tactical/taking_turns/sprites/explosion-2.png deleted file mode 100644 index 3abaedd..0000000 Binary files a/samples/99_genre_rpg_tactical/taking_turns/sprites/explosion-2.png and /dev/null differ diff --git a/samples/99_genre_rpg_tactical/taking_turns/sprites/explosion-3.png b/samples/99_genre_rpg_tactical/taking_turns/sprites/explosion-3.png deleted file mode 100644 index fe94a5a..0000000 Binary files a/samples/99_genre_rpg_tactical/taking_turns/sprites/explosion-3.png and /dev/null differ diff --git a/samples/99_genre_rpg_tactical/taking_turns/sprites/explosion-4.png b/samples/99_genre_rpg_tactical/taking_turns/sprites/explosion-4.png deleted file mode 100644 index ed04237..0000000 Binary files a/samples/99_genre_rpg_tactical/taking_turns/sprites/explosion-4.png and /dev/null differ diff --git a/samples/99_genre_rpg_tactical/taking_turns/sprites/explosion-5.png b/samples/99_genre_rpg_tactical/taking_turns/sprites/explosion-5.png deleted file mode 100644 index 2cd8f06..0000000 Binary files a/samples/99_genre_rpg_tactical/taking_turns/sprites/explosion-5.png and /dev/null differ diff --git a/samples/99_genre_rpg_tactical/taking_turns/sprites/explosion-6.png b/samples/99_genre_rpg_tactical/taking_turns/sprites/explosion-6.png deleted file mode 100644 index e55909c..0000000 Binary files a/samples/99_genre_rpg_tactical/taking_turns/sprites/explosion-6.png and /dev/null differ diff --git a/samples/99_genre_rpg_tactical/taking_turns/sprites/star.png b/samples/99_genre_rpg_tactical/taking_turns/sprites/star.png deleted file mode 100644 index e0ee0f9..0000000 Binary files a/samples/99_genre_rpg_tactical/taking_turns/sprites/star.png and /dev/null differ diff --git a/samples/99_genre_rpg_topdown/topdown_starting_point/app/main.rb b/samples/99_genre_rpg_topdown/topdown_starting_point/app/main.rb index 33228a6..c447940 100644 --- a/samples/99_genre_rpg_topdown/topdown_starting_point/app/main.rb +++ b/samples/99_genre_rpg_topdown/topdown_starting_point/app/main.rb @@ -15,6 +15,7 @@ - args.outputs.labels: An array. The values generate a label. The parameters are [X, Y, TEXT, SIZE, ALIGNMENT, RED, GREEN, BLUE, ALPHA, FONT STYLE] + For more information about labels, go to mygame/documentation/02-labels.md. =end -- cgit v1.2.3