KIZILANDO

Untitled

May 9th, 2021
414
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import pygame
  2. import pytmx
  3. import pyscroll
  4.  
  5. from player import Player
  6.  
  7.  
  8. class Game:
  9.     def __init__(self):
  10.         # creer la fenetre du jeu
  11.         self.screen = pygame.display.set_mode((1366, 768))
  12.         pygame.display.set_caption("Parcours")
  13.  
  14.         #charger la carte (tmx)
  15.         tmx_data = pytmx.util_pygame.load_pygame('map5.tmx')
  16.         map_data = pyscroll.data.TiledMapData(tmx_data)
  17.         map_layer = pyscroll.orthographic.BufferedRenderer(map_data, self.screen.get_size())
  18.         map_layer.zoom = 2
  19.  
  20.         player_position = tmx_data.get_object_by_name("spawn")
  21.         self.player = Player(player_position.x, player_position.y)
  22.  
  23.         # generer un joueur
  24.  
  25.         #dessiner le groupe calques
  26.         self.group = pyscroll.PyscrollGroup(map_layer=map_layer, default_layer=10)
  27.         self.group.add(self.player)
  28.  
  29.     def run(self):
  30.         #boucle du jeu
  31.         running = True
  32.  
  33.         while running:
  34.  
  35.             self.group.draw(self.screen)
  36.             pygame.display.flip()
  37.  
  38.             for event in pygame.event.get():
  39.                 if event.type == pygame.QUIT:
  40.                     running = False
  41.  
  42.         pygame.quit()
RAW Paste Data