animTile.sprite = sprite2.loadSpriteAnimation("player_idle") animTile.play("player_idle") _player = objects.getObjectsOfType(player.Player)[0] _player.sprite = sprite2.loadSpriteAnimation("eggy") _player.play("eggy") ##### camera = Camera(15) camera.setTarget(player.getPlayer()) fps_delay = 60 #Show fps every second fps_delta = 0 while True: inputcontrol.evaluate(pygame.event.get()) physics.solve(objects.getObjectsOfType(Entity)) camera.render(gameScreen) ui.render(gameScreen) scaled_display = pygame.transform.scale(gameScreen, (SCREENWIDTH * SCALEFACTOR, SCREENHEIGHT * SCALEFACTOR)) display.blit(scaled_display, (0, 0)) pygame.display.update() clock.tick(60) #Show FPS if fps_delta >= fps_delay and DEBUGGING: fps_delta = 0 print("%0.2f" % clock.get_fps() + " FPS") fps_delta += 1
background = GameObject(position=Vector2(0, 0), scale=Vector2(SCREENWIDTH, SCREENHEIGHT)) background.colorize(pygame.Color(255, 255, 255)) ball = GameObject(position=Vector2(40, 40)) ball.colorize(pygame.Color(255, 0, 0)) while True: #TODO: Move inputs into a custom class and handle with single function call for event in pygame.event.get(): if event.type == QUIT: print("Closing game...") pygame.quit() sys.exit(0) elif event.type == KEYDOWN: print("Key Down: ", event.key) elif event.type == KEYUP: print("Key Up: ", event.key) camera.render(display) pygame.display.update() clock.tick(60) if fps_delta >= fps_delay and DEBUGGING: fps_delta = 0 print("%0.2f" % clock.get_fps() + " FPS") fps_delta += 1