p5bg:bullet_game
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
p5bg:bullet_game [2024/09/04 08:50] – appledog | p5bg:bullet_game [2024/09/11 06:42] (current) – removed appledog | ||
---|---|---|---|
Line 1: | Line 1: | ||
- | = Bullet Game | ||
- | Bullet Game is our near-end stage pygame 2d game framework example. We've already done at least 6 or 7 other games using pygame. So this will document the patterns we have learned. | ||
- | |||
- | We began by "just writing" | ||
- | |||
- | * Refactoring | ||
- | ** Encapsulation | ||
- | ** Light Commentary (code commentary) ex. IN and OUT for functions. | ||
- | |||
- | The primary goal is encapsulation. So, we're going to break up the old main into several new classes. | ||
- | |||
- | == PyGame Framework | ||
- | The first part of this is the use of [[pygame framework]]. We'll describe the additions here. | ||
- | |||
- | == Bullet Game | ||
- | Here is the code we added, starting with main.py: | ||
- | |||
- | === main.py | ||
- | < | ||
- | from Window import * | ||
- | from Game import * | ||
- | |||
- | def main(): | ||
- | window = Window() | ||
- | window.setCaption(" | ||
- | window.setSize(Screen.WIDTH, | ||
- | window.setFont(" | ||
- | |||
- | game = Game(window) | ||
- | game.start() | ||
- | |||
- | if __name__ == " | ||
- | main() | ||
- | </ | ||
p5bg/bullet_game.1725439849.txt.gz · Last modified: 2024/09/04 08:50 by appledog