def main_loop(level): _grille = Grille(level) _grille.drawMap(screen) _player = Player(_grille) _player.drawPlayer(screen) pygame.display.update() background = pygame.image.load("img/back.png") while not _grille.is_fini(): for event in pygame.event.get(): if event.type == QUIT: sys.exit() if event.type == KEYDOWN: _player.move(event.key) if event.key == K_r: _grille.genMap(level) _grille.drawMap(screen) _player = Player(_grille) _player.drawPlayer(screen) if event.key == K_q: sys.exit() l = 0 if event.key == K_p: for level in lvl: main_loop(lvl[l]) l += 1 screen.blit(background, (150, 100)) _grille.drawMap(screen) _player.drawPlayer(screen) pygame.display.update()
from pygame.locals import * from grille import Grille from player import Player from config import * pygame.init() screen = pygame.display.set_mode((LARGEUR, HAUTEUR)) pygame.display.set_caption(TITRE) background = pygame.image.load("img/back.png") screen.blit(background, (0, 0)) _grille = Grille("lvl/lv1") _grille.drawMap(screen) _player = Player(_grille) _player.drawPlayer(screen) pygame.display.flip() continuer = True while not _grille.is_fini(): for event in pygame.event.get(): if event.type == QUIT: sys.exit() if event.type == KEYDOWN: _player.move(event.key) if event.key == K_r: _grille.genMap("lvl/lv1")
from pygame.locals import * from grille import Grille from player import Player from config import * pygame.init() screen = pygame.display.set_mode((LARGEUR, HAUTEUR)) pygame.display.set_caption(TITRE) background = pygame.image.load("img/back.png") screen.blit(background, (0,0)) _grille = Grille("lvl/lv1") _grille.drawMap(screen) _player = Player(_grille) _player.drawPlayer(screen) pygame.display.flip() continuer = True while not _grille.is_fini(): for event in pygame.event.get(): if event.type == QUIT: sys.exit() if event.type == KEYDOWN: _player.move(event.key) if event.key == K_r: _grille.genMap("lvl/lv1")