Project 4 of 9, for Caitlin
Arcade Catch Game
Mackerel Night, a Pygame game for a new cabinet in the Arcade: rules you can test without a window, drawing kept apart, played by real people and handed to Caitlin.
Sign up free to open itLog in
Act 9 needs a free account, so your work is saved as you go. Act 1 is open to everyone.
The brief
- CaitlinI've got a new cabinet for the Arcade, with a proper joystick and a coin slot I've taped over.
- CaitlinMackerel fall off a pier, you catch them in a bucket, and boots cost you a life.
- YahyaYou should make the mackerel faster every level, like twice as fast.
- CaitlinLet's make them land first, then we'll talk about twice as fast.
- PaulPut the rules in one file and the drawing in another, and then the rules can be tested.
Caitlin's rules, written down at last:
- Mackerel and old boots fall from the top of the screen. The player slides a bucket along the pier at the bottom.
- A mackerel in the bucket scores 1. A boot in the bucket costs a life. Anything missed falls in the sea and costs nothing.
- Three lives. When they're gone, the game is over.
- Every ten mackerel is a level, up to level 9; each level, things fall faster and more often.
- The best five scores, three initials each, stay on the cabinet overnight.
The project, on your own computer, has three parts:
pier.py: the rules, with no pygame anywhere in it.Game(seed=None, spawn=True), withmove(direction),drop(kind, x),update()for one frame,fall_speed(), andstate(), a dictionary of everything there is to draw:bucket_x,items(each{"kind", "x", "y"}),score,lives,levelandover. The sizes and speeds are constants at the top of the file, and the details are in its docstring.scores.py:add_score(path, initials, score)andtop_scores(path, count=5), kept in a JSON file.main.py: the pygame loop. It reads the keys, callsupdate()once a frame, and draws fromstate()and nothing else.python main.py --frames 30plays thirty frames and stops.
The tests in tests/ check the rules and the high scores without opening a window.
>>> game = Game(spawn=False)
>>> game.drop("mackerel", game.state()["bucket_x"])
>>> for frame in range(150):
... game.update()
...
>>> game.state()
{'bucket_x': 208, 'items': [], 'score': 1, 'lives': 3, 'level': 1, 'over': False}What you learn
What's in it
- Sixty times a second
- Make it in text
- Caitlin's cabinet
- Milestone 1: the plan and the rules of the game
- Milestone 2: the logic, tested
- Drawing a frame in pygame
- Milestone 3: the game on screen
- Milestone 4: playtested in the Arcade and handed to Caitlin
- Ship it