diff options
| author | _Tradam <[email protected]> | 2021-12-16 19:22:26 -0500 |
|---|---|---|
| committer | GitHub <[email protected]> | 2021-12-16 19:22:26 -0500 |
| commit | 5954b9beb4d4a3b4f248d72d1851195f030558a8 (patch) | |
| tree | fecd8aa840a25afdb502915b0fdb4d03b7ed339a /samples/04_physics_and_collisions/07_jump_physics/app | |
| parent | 2f845281f133849256b57bb08fd3e9ae57600784 (diff) | |
| parent | eaa29e72939f5edf61735ccbb73c36ee89369f65 (diff) | |
| download | dragonruby-game-toolkit-contrib-master.tar.gz dragonruby-game-toolkit-contrib-master.zip | |
Diffstat (limited to 'samples/04_physics_and_collisions/07_jump_physics/app')
| -rw-r--r-- | samples/04_physics_and_collisions/07_jump_physics/app/main.rb | 11 |
1 files changed, 9 insertions, 2 deletions
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 da01e91..8db98be 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. @@ -44,8 +45,7 @@ class VerticalPlatformer input end - # Sets default values - def defaults + def init_game 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 @@ -68,6 +68,11 @@ class VerticalPlatformer s.camera ||= { y: -100 } # shows view on screen (as the player moves upward, the camera does too) end + # Sets default values + def defaults + init_game + end + # Outputs objects onto the screen def render outputs.solids << s.platforms.map do |p| # outputs platforms onto screen @@ -155,7 +160,9 @@ class VerticalPlatformer rect: nil) end else + # game over s.as_hash.clear # otherwise clear the hash (no new platform is necessary) + init_game end end |
