Make a real game in Python on microStudio, a free game engine in the browser: a game loop, keys, stars as objects, catching and scoring, then sprites, sound and sharing.
Each lesson works two ways. Students can work through the online tutorial at their own pace (it checks their answers and saves their progress in their browser), or you can teach it to the whole class from the slides, then send students into the tutorial for the Modify and Make steps.
Every lesson guide has plain-language notes, the answers to every check, a solution for every task, and slides and a worksheet for Waypoints Prepare. These guide pages are not linked from student pages, but they are not secret either: keep printed Teacher editions for answers you do not want students to find.
Whole-course cheat sheet: Open to print (every command, grouped by unit: a handout for the final challenge)
init, update and draw: how every game engine runs, and moving with the keys.
A game engine runs your game for you. You write three functions and the engine calls them: init() once at the start, then update() and draw() about 60 times a second for as long as the game runs. update() changes things (positions, the score); draw() clears the screen and draws everything where it is now. Each pass is a frame. Movement is a small change every frame: x += 1 sixty times a second is a smooth slide.
Keys are read the same way: every frame, update() asks whether a key is down (pressed("LEFT")) and moves a little if so. This is polling; the turtle course's onkey was an event (a function called once per press).
The students' games live on microstudio.dev, a free, open-source game engine in the browser (MIT licence). Our lessons show each game playing on the page, and students copy the code into their own microStudio project. microStudio's Python is ordinary Python (Brython), with screen, keyboard and audio ready to use. The screen is 200 tall, with (0, 0) in the middle and y going up.
A flip book: each page is a frame, drawn a tiny bit different from the last; flicked fast, it moves. It breaks because a flip book is drawn in advance, while a game draws each page just before showing it, from what the player is doing now.
main and press Run.x += 1 to x += 3. Then to x -= 1.screen.clear(...) and run it: why the smear?global again? update() changes a variable made outside it, exactly as in the turtle events lesson.pressed()? A two-line helper students copy: microStudio's keyboard.LEFT does not exist until the first key press, so the helper checks first.The turtle course's events (ontimer moving a target) were a slow game loop. Objects with turtles' falling stars come back in the next unit as objects that move and draw themselves.
Cheat sheet: Open to print (A4, with a picture of what each command draws) · Markdown
Stars as objects, catching them for points, then sprites, sound and sharing what you made.
A game is a loop, things that move, and questions asked every frame. Each star is an object of a Star class (as in Objects with turtles) that keeps its own x, y and speed, and has move() and draw() methods; the loop asks every star to move, then to draw. Collision is a question: is this star close enough to the paddle, across and up and down (abs(self.x - x) < 12 and abs(self.y - y) < 8)? A caught star adds to the score and restarts at the top. Lives count misses, and at 0 the game stops; calling init() again starts over.
Then the game becomes the student's own: sprites drawn in microStudio's Sprites tab (screen.drawSprite("star", x, y, w, h)), sounds from audio.beep("C E G"), and a playtest with a friend.
update().A referee watching a game: every moment, they check each player against the rules (offside? out of bounds?). It breaks because a referee can miss things; the game loop checks every star, every frame, without fail.
< 12 in touches() to < 30: what happens to the game?star in the Sprites tab and use screen.drawSprite in the star's draw().update(), where the thing happens, never in draw() (which runs every frame).This is the turtle course's Catch the turtle and Objects with turtles' falling stars, in a real engine. Next steps beyond the course: microStudio's maps, music and multiplayer (its Help tab), or Godot, whose GDScript reads much like Python.
Cheat sheet: Open to print (A4, with a picture of what each command draws) · Markdown