def __init__(self, WindowSize): title = "Stage 2" subtitle = "Game Object Containers" slides = [ [ Text( 50, flip_y(WindowSize, 50), """- New instances of game objects are added to a container. This makes it easier to manage all the game objects in a game - Every frame, we call the update and draw functions of all the game objects inside a container""", {"font_size": 18}), Text( 250, flip_y(WindowSize, 230), """monsters = [] for monster in monsters: monster.update() for monster in monsters: monster.draw() """) ], ] super().__init__(WindowSize, title, subtitle, slides)
def __init__(self, WindowSize): title = "Stage 6" subtitle = "Python game programming libraries" slides = [[ Text( 50, flip_y(WindowSize, 70), """Game programming libraries - Pygame - Arcade - Ren'py - pyglet - many more Game programming frameworks/engines with Python - Godot Engine - Cocos2d - Panda3d """), Text(600, flip_y(WindowSize, 70), """Platforms - PC - Mac - iOS - Android""") ], [ Text( 50, flip_y(WindowSize, 70), """Libraries that can also be used for games - Kivy - Django / Flask - Curses - many more""") ]] super().__init__(WindowSize, title, subtitle, slides)
def __init__(self, WindowSize): title = "Stage 2" subtitle = "Game Objects" slides = [ [ Text( 50, flip_y(WindowSize, 70), """- It is useful to use OOP for Game objects - Game objects have functions for updating and drawing - Every frame, the game will update and draw game objects."""), Text( 150, flip_y(WindowSize, 200), """@dataclass class GameObject: x: int y: int image: Image """), Text( 500, flip_y(WindowSize, 200), """class Monster(GameObject): def update(self): pass def draw(self): pass""") ], ] super().__init__(WindowSize, title, subtitle, slides)
def __init__(self, WindowSize): title = "Stage 2" subtitle = "What you need to know to program game" slides = [ [], [ Text(50, flip_y(WindowSize, 70), "1. Game Library"), ], [ Text( 50, flip_y(WindowSize, 70), """1. Game Library 2, Game Programming Design Patterns: Game loop""") ], [ Text( 50, flip_y(WindowSize, 70), """1. Game Library 2. Game Programming Design Patterns: Game loop 3. Object Oriented Programming: Game objects""") ], [ Text( 50, flip_y(WindowSize, 70), """1. Game Library 2. Game Programming Design Patterns: Game loop 3. Object Oriented Programming: Game objects 4. Maths""") ], ] super().__init__(WindowSize, title, subtitle, slides)
def __init__(self, WindowSize): self.texts = [ Text(WindowSize[0] / 2, flip_y(WindowSize, 110), "MrValdez", {"font_size": 60, "font_name": "Armalite Rifle"}), Text(WindowSize[0] / 2, flip_y(WindowSize, 190), "Game Programming with Python", {"font_size": 30}), Text(WindowSize[0] / 2, flip_y(WindowSize, 500), "Difficulty: Intermediate", {"italic": True}), ] self.start_text = Text(WindowSize[0] / 2, flip_y(WindowSize, 400), "Press any key") self.blink_time = 0.75 self.blink = self.blink_time
def draw(self): self.walls.draw() self.sprites.draw() self.floor.draw() arcade.draw_lrtb_rectangle_filled(0, self.WindowSize[0], flip_y(self.WindowSize, 0), flip_y(self.WindowSize, 100), arcade.color.BLACK) for text in self.texts: text.draw()
def __init__(self, WindowSize): title = "Stage 1" subtitle = "Game Loop" slides = [ [ Text( 50, flip_y(WindowSize, 70), """- The basic code for all games - Infinite loop - Runs after game world setup - Each iteration is called a "frame" """), Image(500, flip_y(WindowSize, 70), "game_loop.png", scale=1.2) ], ] super().__init__(WindowSize, title, subtitle, slides)
def __init__(self, WindowSize): title = "Stage 1" subtitle = "Who is MrValdez" slides = [[ Text( 50, flip_y(WindowSize, 40), """- I'm a video game programming hobbyist - Active board member at Python Philippines - Use game programming to teach programming - https://mrvaldez.ph - https://github.com/mrvaldez - @MrValdez """), Image(650, flip_y(WindowSize, 30), "mrvaldez.png", scale=0.6), ]] super().__init__(WindowSize, title, subtitle, slides)
def __init__(self, WindowSize): self.texts = [ Text( WindowSize[0] / 2, flip_y(WindowSize, 110), "The source code for this presentation can be found at\nhttps://github.com/MrValdez/PyCon-APAC-2018" ), Text( WindowSize[0] / 2, 0, """Anyone can make a game... It just take a lot of effort. In this talk, MrValdez will be introducing the basics of Game Programming. By the end, we would have enough to make a simple game. But he can't do it alone. He'll need your help. 3 volunteers from the audience to help: One artist. One player. This is the one hour story of how PyCon APAC 2018 made a game. """), ] self.WindowSize = WindowSize artist = arcade.Sprite("artist.png", scale=0.31) artist.center_x = 420 artist.center_y = -680 tester = arcade.Sprite("gamer.png", scale=0.7) tester.center_x = 600 tester.center_y = -680 self.sprites = arcade.SpriteList() self.sprites.append(artist) self.sprites.append(tester)
def __init__(self, WindowSize): title = "Stage 1" subtitle = "" slides = [ [Text(50, flip_y(WindowSize, 40), "Who here play video games?")], [Text(50, flip_y(WindowSize, 40), "Who here play video games?") ], # hack: run twice because of keypress from previous stage [ Text(50, flip_y(WindowSize, 40), "Who here play video games?"), Image(100, flip_y(WindowSize, 100), "video_game1.png", scale=1.4, transition="left") ], [ Text(50, flip_y(WindowSize, 40), "Who here play video games?"), Image(100, flip_y(WindowSize, 100), "video_game1.png", scale=1.4), Image(360, flip_y(WindowSize, 70), "video_game2.png", scale=0.5, transition="right") ], [ Text(50, flip_y(WindowSize, 40), "Who here play video games?"), Image(100, flip_y(WindowSize, 100), "video_game1.png", scale=1.4), Image(360, flip_y(WindowSize, 70), "video_game2.png", scale=0.5), Image(250, flip_y(WindowSize, 80), "video_game3.png", scale=0.75, transition="bottom") ], ] super().__init__(WindowSize, title, subtitle, slides)
def __init__(self, WindowSize): self.texts = [ Text( 10, flip_y(WindowSize, 20), "Stage 1", { "font_name": "Georgia", "font_size": 40, "bold": True, "anchor_x": "left", "align": "left" }), ] self.WindowSize = WindowSize self.avatar = Avatar("avatar.png") self.avatar.center_x = 860 self.avatar.center_y = 120 joysticks = arcade.get_joysticks() if joysticks: self.joystick = joysticks[0] self.joystick.open() self.joystick.on_joyhat_motion = self.on_joyhat_motion self.sprites = arcade.SpriteList() self.sprites.append(self.avatar) self.walls = arcade.SpriteList() top_row = list(zip(range(20, 1024, 90), [500] * 15)) for i in range(len(top_row)): left = top_row[i][0] top = top_row[i][1] + random.randint(-10, 10) top_row[i] = (left, top) for pos in top_row: wall = arcade.Sprite("LPC_cliffs_grass.png", image_x=15, image_y=288 - 175 - 100, image_width=65, image_height=120, scale=1.6) wall.left = pos[0] wall.top = pos[1] self.walls.append(wall) right_row = [ [903, 410], #[920, 410 - 240 + 20] ] for pos in right_row: wall = arcade.Sprite("LPC_cliffs_grass.png", image_x=95, image_y=288 - 130 - 150, image_width=75, image_height=120, scale=2.2) wall.left = pos[0] wall.top = pos[1] self.walls.append(wall) bottom_row = list(zip(range(20, 1024, 90), [50] * 15)) left_row = list(zip([10] * 15, range(50, 500, 200))) left_row.reverse() for pos in left_row + bottom_row: wall = arcade.Sprite("LPC_cliffs_grass.png", image_x=174, image_y=288 - 175 - 100, image_width=80, image_height=140, scale=2) wall.left = pos[0] wall.top = pos[1] self.walls.append(wall) self.physics = arcade.PhysicsEngineSimple(self.avatar, self.walls) self.floor = arcade.SpriteList() cave = arcade.Sprite("LPC_cliffs_grass.png", image_x=1, image_y=288 - 140, image_width=30, image_height=45, scale=2.4) target_cliff = top_row[3] cave.left = target_cliff[0] + 14 cave.top = target_cliff[1] - 85 self.floor.append(cave) self.cave = cave