Skip to content

Commit

Permalink
More updates
Browse files Browse the repository at this point in the history
  • Loading branch information
lawsie committed Nov 14, 2024
1 parent ae32478 commit 19c175e
Show file tree
Hide file tree
Showing 6 changed files with 98 additions and 355 deletions.
2 changes: 1 addition & 1 deletion en/meta.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ last_tested: "2021-10-06"
steps:
- title: What you will make
- title: Set the scene
- title: Create obstacles
- title: Create an obstacle
completion:
- engaged
- title: Random obstacles
Expand Down
4 changes: 2 additions & 2 deletions en/step_3.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
## Create obstacles
## Create an obstacle

<div style="display: flex; flex-wrap: wrap">
<div style="flex-basis: 200px; flex-grow: 1; margin-right: 15px;">
Expand Down Expand Up @@ -74,7 +74,7 @@ def draw_obstacles():
text('🌵', obstacle_x, obstacle_y)

--- /code ---
</div>

--- /task ---

--- task ---
Expand Down
3 changes: 2 additions & 1 deletion en/step_4.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
## Random obstacles

--- task ---

Currently, the obstacle disappears off the bottom of the screen, because its `obstacle_y` position becomes larger than the screen size.

--- task ---

Use the modulo (%) operator to divide the y position by the screen size and give you the **remainder**. This makes the obstacle reappear at the top!

--- code ---
Expand Down
33 changes: 32 additions & 1 deletion en/step_5.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,38 @@
## Lots of obstacles

Now you will add code to make lots of obstacles to avoid.

--- task ---

Add a loop and indent the code to draw an obstacle. The loop will run this code multiple times.

--- code ---
---
language: python
line_numbers: true
line_number_start: 13
line_highlights: 15-19
---

def draw_obstacles():
seed(1234)
for i in range(8):
obstacle_x = randint(0, screen_size)
obstacle_y = randint(0, screen_size) + frame_count
obstacle_y = obstacle_y % screen_size
text('🌵', obstacle_x, obstacle_y)

--- /code ---

Make sure that the code for the seed is before the loop, otherwise all of your obstacles will be generated on top of each other!

--- /task ---

--- task ---
Change the number inside `range()` to control how many obstacles are created.

some task
--- /task ---

--- task ---
**Test:** Run your code and you should see several obstacles.
--- /task ---
Loading

0 comments on commit 19c175e

Please sign in to comment.