|
| 1 | +class Pinball: |
| 2 | + """ |
| 3 | + This is a boilerplate class for creating new demos/games for the SSS platform. It needs to include definitions for the following functions: init, run, stop. |
| 4 | + The init function needs to at least have the things shown below. Frame rate is in frames per second and demo time is in seconds. Demo time should be None if it is a game. |
| 5 | + The run function yields a generator. This generator will be called a specified frame rate, this controls what is being pushed to the screen. |
| 6 | + The stop function is called when the demo/game is being exited by the upper SSS software. It should reset the state for the game |
| 7 | + """ |
| 8 | + |
| 9 | + demo_time = None # Number of seconds or None if its game |
| 10 | + |
| 11 | + # User input is passed through input_queue |
| 12 | + # Game output is passed through output_queue |
| 13 | + # Screen updates are done through the screen object |
| 14 | + def __init__(self, input_queue, output_queue, screen): |
| 15 | + """ |
| 16 | + Constructor |
| 17 | +
|
| 18 | + Args: |
| 19 | + input_queue (Queue): Queue for user input |
| 20 | + output_queue (Queue): Queue for game output |
| 21 | + screen (Screen): Screen object |
| 22 | + """ |
| 23 | + # Provide the framerate in frames/seconds and the amount of time of the demo in seconds |
| 24 | + self.frame_rate = 10 |
| 25 | + |
| 26 | + self.input_queue = input_queue |
| 27 | + self.output_queue = output_queue |
| 28 | + self.screen = screen |
| 29 | + # init demo/game specific variables here |
| 30 | + |
| 31 | + def run(self): |
| 32 | + """Main loop for the demo""" |
| 33 | + # Create generator here |
| 34 | + while True: |
| 35 | + self.screen.draw_text( |
| 36 | + self.screen.x_width // 2 - 5, |
| 37 | + self.screen.y_height // 2 - 4, |
| 38 | + "HELLO THERE", |
| 39 | + push=True, |
| 40 | + ) |
| 41 | + yield |
| 42 | + |
| 43 | + def stop(self): |
| 44 | + """Reset the state of the demo if needed, else leave blank""" |
| 45 | + pass |
0 commit comments