pymunk_demo_platformer_02.py Full Listing

pymunk_demo_platformer_02.py
 1"""
 2Example of Pymunk Physics Engine Platformer
 3"""
 4import arcade
 5
 6SCREEN_TITLE = "PyMunk Platformer"
 7
 8# How big are our image tiles?
 9SPRITE_IMAGE_SIZE = 128
10
11# Scale sprites up or down
12SPRITE_SCALING_PLAYER = 0.5
13SPRITE_SCALING_TILES = 0.5
14
15# Scaled sprite size for tiles
16SPRITE_SIZE = int(SPRITE_IMAGE_SIZE * SPRITE_SCALING_PLAYER)
17
18# Size of grid to show on screen, in number of tiles
19SCREEN_GRID_WIDTH = 25
20SCREEN_GRID_HEIGHT = 15
21
22# Size of screen to show, in pixels
23SCREEN_WIDTH = SPRITE_SIZE * SCREEN_GRID_WIDTH
24SCREEN_HEIGHT = SPRITE_SIZE * SCREEN_GRID_HEIGHT
25
26
27class GameWindow(arcade.Window):
28    """ Main Window """
29
30    def __init__(self, width, height, title):
31        """ Create the variables """
32
33        # Init the parent class
34        super().__init__(width, height, title)
35
36    def setup(self):
37        """ Set up everything with the game """
38        pass
39
40    def on_key_press(self, key, modifiers):
41        """Called whenever a key is pressed. """
42        pass
43
44    def on_key_release(self, key, modifiers):
45        """Called when the user releases a key. """
46        pass
47
48    def on_update(self, delta_time):
49        """ Movement and game logic """
50        pass
51
52    def on_draw(self):
53        """ Draw everything """
54        self.clear()
55
56
57def main():
58    """ Main function """
59    window = GameWindow(SCREEN_WIDTH, SCREEN_HEIGHT, SCREEN_TITLE)
60    window.setup()
61    arcade.run()
62
63
64if __name__ == "__main__":
65    main()