Skip to content

Commit e54ba95

Browse files
committed
wrote the labrinth scenario...unfortunately the engine doesn't support the whole scenario
1 parent a194847 commit e54ba95

4 files changed

Lines changed: 37 additions & 6 deletions

File tree

scenarios/cannon_practice.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ In your `// setup goes here` section of `main()`...
3535

3636
## Gameplay Logic
3737

38-
In your `game_logic(...)` function...
38+
In your [`game_logic(...)` function](https://cleancut.github.io/rusty_engine/25-game-logic-function.html)...
3939

4040
1. Decide which keyboard/mouse input will control the rotation of the cannon, and implement rotating the cannon.
4141
- Constrain the min/max angle of rotation to angles in the first quadrant (from straight up to straight right) with [the `.clamp` method](https://doc.rust-lang.org/std/primitive.f32.html#method.clamp) and the [`UP` and `RIGHT` constants](https://docs.rs/rusty_engine/latest/rusty_engine/#constants).

scenarios/extreme_drivers_ed.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,6 @@ In your `// game setup goes here` section of `main`...
3434

3535
## Game Logic
3636

37-
In your `game_logic(...)` function...
37+
In your [`game_logic(...)` function](https://cleancut.github.io/rusty_engine/25-game-logic-function.html)...
3838

3939
1.

scenarios/labrinth.md

Lines changed: 34 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
Guide the marble from the beginning to the end of the labrinth...but don't fall in any holes!
44

5+
NOTE: This scenario is not fully supported by the capabilities of the engine. You will need to supplement the engine with your own physics logic and/or make changes to the engine itself to accomplish this complete scenario. This is included here because we _might_ add enough features to support this scenario in the future. You're certainly welcome to help!
6+
57
This game consists of a [Labrinth](https://en.wikipedia.org/wiki/Labyrinth) or maze with a beginning and an end. The marble starts at the beginning of the labrynth (naturally) and must proceed to the end. Sounds easy...until you realize that there are holes all along the maze, and you don't have perfect control of the marble! If you fall in one of the holes, start over from the beginning.
68

79
## Common Setup
@@ -11,8 +13,13 @@ This game consists of a [Labrinth](https://en.wikipedia.org/wiki/Labyrinth) or m
1113
## Game State
1214

1315
1. Define a game state struct with fields for:
16+
- Current tilt of the labrinth (a `Vec2`)
1417
- Current velocity of the marble (a `Vec2`)
15-
- Lives left (a u8)
18+
- Lives left (a `u8`)
19+
1. Define constants for:
20+
- Marble movement speed (an `f32`)
21+
- Maximum tilt magnitude (an `f32`)
22+
- Maximum marble speed (an `f32`)
1623
1. Choose a sprite to represent the player's marble
1724
1. Choose a sprite to represent the starting area or spot
1825
1. Choose a sprite to represent holes in the labrinth
@@ -33,6 +40,30 @@ In your `// setup goes here` section of `main()`...
3340

3441
## Gameplay Logic
3542

36-
In your `game_logic(...)` function...
43+
In your [`game_logic(...)` function](https://cleancut.github.io/rusty_engine/25-game-logic-function.html)...
44+
45+
1. We will move the marble by virtually tilting the whole labrinth (even though it won't look like we're tilting it). The relative movement of the mouse will do the tilting. The more tilted the labrinth is, the faster the marble will accelerate in that direction.
46+
- Collect [mouse movement events](https://cleancut.github.io/rusty_engine/120-mouse-events.html#mouse-motion-events) (not location events!) and add them to the current tilt of the labrinth
47+
- Clamp the maximum length of the tilt `Vec2` to the maximum tilt magnitude constant with [the `.clamp_length_max` method](https://docs.rs/glam/latest/glam/f32/struct.Vec2.html#method.clamp_length_max).
48+
1. Accelerate the marble.
49+
- Each frame, multiply the tilt `Vec2` in the game state by the movement speed constant AND `engine_state.delta_f32`, and then add that resulting `Vec2` to the marble velocity in the game state. Clamp the maximum length of the marble velocity using the maximum marble velocity constant with [the `.clamp_length_max` method](https://docs.rs/glam/latest/glam/f32/struct.Vec2.html#method.clamp_length_max).
50+
- Each frame, increment the marble sprite's translation by the velocity in the game state.
51+
- At this point, you should be able to get the marble to move around the screen (though it ignores all the other sprites). Play with all the constant values until you get something that feels reasonable. For the game to be playable, you'll need a decently large max tilt magnitude paired with a relatively small movement speed and small max movement speed to give you enough control over the marble. But you don't want _too_ much control...it should feel like rolling a marble on a flat surface by tilting it.
52+
53+
## The sort of unfinished part
54+
55+
This section isn't well-supported by the underlying engine. 😬 Sorry.
56+
57+
1. Make it so that you can't go through your barriers.
58+
- Missing engine feature: Collision contact normals.
59+
1. Make it so that if the center of the marble overlaps a hole, you lose.
60+
- Missing engine feature: Testing if an arbitrary `Vec2` is within a sprite's collider.
61+
62+
## The rest
63+
64+
1. When you touch the goal, you win!
65+
66+
67+
## Challenges
3768

38-
1. We will move the marble by virtually tilting the whole labrinth. The relative movement of the mouse will do the tilting. The more tilted the labrinth is, the faster the marble will accelerate in that direction.
69+
- When you fall down a hole, reset the game nicely and keep playing, keeping track of number of tries.

scenarios/space_invaders.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,6 @@ In your `// setup goes here` section of `main()`...
1616

1717
## Gameplay Logic
1818

19-
In your `game_logic(...)` function...
19+
In your [`game_logic(...)` function](https://cleancut.github.io/rusty_engine/25-game-logic-function.html)...
2020

2121
1.

0 commit comments

Comments
 (0)