player.py 797 B

123456789101112131415161718192021
  1. import pygame
  2. from tiles import *
  3. from variables import *
  4. from world import World
  5. class Player:
  6. def __init__(self, x: int, y: int, world: World, display: pygame.display):
  7. """Un joueur, avec ses coordonnées (x, y)"""
  8. self.display = display
  9. self.x: int = x
  10. self.y: int = y
  11. self.picture: str = "player"
  12. self.world: World = world
  13. def draw(self, tile: dict):
  14. """Affiche le joueur"""
  15. image = pygame.transform.scale(PLAYER, (self.world.tile_width, self.world.tile_height))
  16. self.display.blit(image, (tile['x'] - self.world.tile_width // 2, tile['y'] - self.world.tile_height // 2)) #la valeur ici est arbitraire mais marche. elle est la pour centrer l'affichage du joueur sur une tuile, a changer dans le futur