def __init__(self, x, y, frame_delay=1): self.frame_counter = FrameCounter(frame_delay) GameObject.__init__(self, x, y) self.renderer = Animation(["image/player/player1.png", "image/player/playerDeath1.png", "image/player/playerDeath2.png", "image/player/playerDeath3.png"])
def __init__(self, x, y, input_manager): GameObject.__init__(self, x, y) self.image = pygame.image.load("Scene2/image/player/player1.png") self.image = pygame.transform.scale(self.image, (32, 64)) self.width = self.image.get_width() self.height = self.image.get_height() self.isJump = False self.speed = 4 self.jumpHight = 16 self.input_manager = input_manager self.counter = FrameCounter(24) self.pressJump = False self.box_collider = BoxCollider(self.width, self.height) self.resetLock() self.Alive = True self.dx = 0 self.dy = 0 self.renderer = PlayerAnimation() self.win = False
def __init__(self, x, y): GameObject.__init__(self, x, y) self.renderer = ImageRenderer( "Scene2/assets/images/sprite/hiddenspike0000.png") self.box_collider = BoxCollider(28, 28)
def __init__(self, width, height): GameObject.__init__(self, 0, 0) self.width = width self.height = height
def update(self, canvas): # set screen BG = (50, 50, 50) # Clock clock = pygame.time.Clock() input_manager = InputManager() player = Player(132, 160, global_input_manager) generate_map("Scene2/assets/maps/tut_lvl.json") frame_delay = FrameCounter(60) dead = pygame.mixer.Sound('Scene4/sound/dead.mp3') pygame.mixer.music.load('Scene2/sound/brackground2.mp3') pygame.mixer.music.play(-1) loop = True pressReset = False played_music = False while loop: if pressReset: pygame.mixer.music.play(-1) cnt = 0 while len(game_objectS2.game_objects) > 0: for game_object in game_objectS2.game_objects: # print(game_object.x) game_objectS2.game_objects.remove(game_object) generate_map("Scene2/assets/maps/tut_lvl.json") player = Player(124, 416, global_input_manager) game_objectS2.start_point = GameObject(0, 0) game_objectS2.finish_point = GameObject(1616, 0) pressReset = False played_music = False # Event processing events = pygame.event.get() for event in events: if (event.type == pygame.QUIT) or (event.type == KEYDOWN and event.key == K_ESCAPE): loop = False self.pressClose = True else: global_input_manager.update(event) canvas.fill(BG) player.update() if player.win: loop = False canvas.blit(pygame.image.load('Scene4/images/BackGround4.jpg'), (0, 0)) # canvas.blit(player.image, (player.x - player.width // 2, player.y - player.height // 2)) if player.Alive: player.renderer.render(canvas, player.x, player.y) # player.box_collider.render(canvas) game_objectS2.update() game_objectS2.render(canvas) # print(player.Alive) pygame.display.flip() if not player.Alive: if not played_music: pygame.mixer.music.stop() dead.play() played_music = True frame_delay.run() if frame_delay.expired: frame_delay.reset() pressReset = True clock.tick(60) pygame.mixer.music.stop() self.end = True
def __init__(self, x, y): GameObject.__init__(self, x, y) self.renderer = ImageRenderer( "Scene2/assets/images/sprite/platform0000.png") self.box_collider = BoxCollider(32, 32)