def __init__(self,x , y): GameObject.__init__(self, x, y) self.renderer = ImageRenderer('Scene4/images/trap/single_thorn_1.png') # self.image = pygame.image.load('../images/trap/medium_thorn.png') self.collider = BoxCollider(20, 60) self.limit = 448 self.Active = False
def update(self): GameObject.update(self) if self.x <= 138: self.Active = True if self.Active: self.run() if self.count >= self.limit: self.isActive = True
def __init__(self, x, y, frame_delay=1): self.frame_counter = FrameCounter(frame_delay) GameObject.__init__(self, x, y) self.renderer = Animation([ "Scene4/images/player/player_stand.png", "Scene4/images/player/playerDeath1.png", "Scene4/images/player/playerDeath2.png", "Scene4/images/player/playerDeath3.png" ])
def __init__(self, x, y): GameObject.__init__(self, x, y) self.renderer = ImageRenderer('Scene4/images/map/grass1.png') # self.image = pygame.image.load('../images/map/grass1.png') self.collider = BoxCollider(32, 32) self.isActive = False self.Active = False self.count = 176 self.limit = 416
def __init__(self, x, y, input_manager): GameObject.__init__(self, x, y) self.image = pygame.image.load('Scene4/images/player/player_stand.png') self.image = pygame.transform.scale(self.image, (32, 64)) self.width = self.image.get_width() self.heigth = self.image.get_height() self.win = False self.isJump = False self.speed = 4 self.jumpHight = 16 self.input_manager = input_manager self.counter = FrameCounter(24) self.pressJump = False self.collider = BoxCollider(self.width, self.heigth) self.resetLock() self.Alive = True self.renderer = PlayerAnimation() self.dx = 0 self.dy = 0
def update(self): GameObject.update(self) if self.x <= 138: self.Active = True if self.Active: self.run()
def __init__(self,x , y): GameObject.__init__(self, x, y) self.renderer = ImageRenderer('Scene4/images/map/platform.png') # self.image = pygame.image.load('../images/map/platform.png') self.collider = BoxCollider(32, 32)
def __init__(self, x, y): GameObject.__init__(self, x, y) self.renderer = ImageRenderer('Scene4/images/trap/hidden_thorn.png') # self.image = pygame.image.load('../images/trap/hidden_thorn.png') self.collider = BoxCollider(30, 32) self.isActive = False
def __init__(self, width, height): GameObject.__init__(self, 0 , 0) self.width = width self.height = height
def __init__(self, x, y): GameObject.__init__(self, x, y) self.renderer = ImageRenderer('Scene4/images/trap/thorn.png') # self.image = pygame.image.load('../images/trap/thorn.png') self.collider = BoxCollider(24, 30)
def __init__(self, x, y): GameObject.__init__(self, x, y) self.renderer = ImageRenderer('Scene4/images/map/laser.png')
def update(self, canvas): ffont = pygame.font.Font(None, 100) # import BackGround frame_counter = FrameCounter(40) # Clock clock = pygame.time.Clock() map_generator.generate_map("Scene4/Part1/map/map4.json") input_manager = InputManager() player = Player(124, 416, input_manager) # self.elevator.player = player loop = True pressReset = False shut_down = False pygame.mixer.music.load('Scene4/sound/Scene4.mp3') pygame.mixer.music.play(-1) CorrectPass = "******" PlayerPass = "" dead = pygame.mixer.Sound('Scene4/sound/dead.mp3') played_sound = False while loop: # if self.elevator.pressClose: # loop = False # shut_down = True # self.pressClose = True # if pressReset: cnt = 0 # pygame.mixer.music.load('Scene4/sound/Scene4.mp3') pygame.mixer.music.play(-1) while len(game_object4_1.game_objects) > 0: for game_object in game_object4_1.game_objects: # print(game_object.x) game_object4_1.game_objects.remove(game_object) map_generator.generate_map("Scene4/Part1/map/map4.json") player = Player(124, 416, input_manager) game_object4_1.start_point = GameObject(0, 0) game_object4_1.finish_point = GameObject(3056, 0) pressReset = False played_sound = False # --------------------------------------------------------------------------------------------------------- events = pygame.event.get() for even in events: if (even.type == pygame.QUIT) or (even.type == KEYDOWN and even.key == K_ESCAPE): loop = False shut_down = True self.pressClose = True else: input_manager.update(even) # ------------------------------------------------------------------------------------------------------- canvas.blit(pygame.image.load('Scene4/images/BackGround4.jpg'), (0, 0)) player.update() game_object4_1.update() game_object4_1.render(canvas) # draw if player.Alive: player.renderer.render(canvas, player.x, player.y) # canvas.blit(player.image, (player.x - player.width//2, player.y - player.heigth//2)) # canvas.fill((100 , 150, 200)) # ------------------------------------------------------------------------------------------------------------------ if player.win: loop = False # ------------------------------------------------------------------------------------------------------------------ if not player.Alive: pygame.mixer.music.stop() if not played_sound: dead.play() played_sound = True frame_counter.run() if frame_counter.expired: frame_counter.reset() pressReset = True pygame.display.flip() clock.tick(60) canvas.blit(pygame.image.load('Scene4/images/PasswordScene.png'), (0, 0)) if not shut_down: loop = True while loop: events = pygame.event.get() for even in events: if (even.type == pygame.QUIT) or (even.type == KEYDOWN and even.key == K_ESCAPE): loop = False self.pressClose = True elif even.type == KEYDOWN: if even.key == pygame.K_RETURN: if PlayerPass == CorrectPass: loop = False self.end = True else: PlayerPass = "" canvas.blit( pygame.image.load( 'Scene4/images/PasswordScene.png'), (0, 0)) elif even.key is not pygame.K_BACKSPACE: PlayerPass += even.unicode else: PlayerPass = PlayerPass[:-1] canvas.blit( pygame.image.load( 'Scene4/images/PasswordScene.png'), (0, 0)) chu = ffont.render(PlayerPass, True, (255, 0, 0)) canvas.blit(chu, (300, 300)) pygame.display.flip() clock.tick(60) self.end = True
def __init__(self, x, y): GameObject.__init__(self, x, y) self.renderer = ImageRenderer('Scene4/images/map/locked_door.png') # self.image = pygame.image.load('../images/map/grass1.png') self.collider = BoxCollider(32, 544)