|
@@ -13,7 +13,6 @@ def main():
|
|
|
pygame.init() # La fonction secrète, on sait pas ce qu'elle fait mais elle doit être là
|
|
pygame.init() # La fonction secrète, on sait pas ce qu'elle fait mais elle doit être là
|
|
|
|
|
|
|
|
display = pygame.display.set_mode((WINDOW_WIDTH, WINDOW_HEIGHT)) # Taille de la fenêtre
|
|
display = pygame.display.set_mode((WINDOW_WIDTH, WINDOW_HEIGHT)) # Taille de la fenêtre
|
|
|
- display.fill(BACKGROUND_COLOR)
|
|
|
|
|
|
|
|
|
|
pygame.display.set_caption("VISI301") # Nom de la fenêtre, à changer à la fin TODO
|
|
pygame.display.set_caption("VISI301") # Nom de la fenêtre, à changer à la fin TODO
|
|
|
|
|
|
|
@@ -23,27 +22,35 @@ def main():
|
|
|
# Création du monde
|
|
# Création du monde
|
|
|
world = World(display, NB_COL, NB_ROW, GAP)
|
|
world = World(display, NB_COL, NB_ROW, GAP)
|
|
|
|
|
|
|
|
- player = Player(0, 0, world, display)
|
|
|
|
|
|
|
+ player = Player(world.pos_list[1]["x"], world.pos_list[1]["y"], world, display) # On initialise le joueur sur la première tuile en dessous du nid
|
|
|
|
|
|
|
|
nest = Nest(0, display)
|
|
nest = Nest(0, display)
|
|
|
|
|
|
|
|
### Boucle principale ###
|
|
### Boucle principale ###
|
|
|
while True:
|
|
while True:
|
|
|
-
|
|
|
|
|
- # À chaque tick on fait ce qu'il y a là
|
|
|
|
|
- world.draw()
|
|
|
|
|
- player.draw(world.pos_list[1]) # On commence sur la tuile en dessous du nid
|
|
|
|
|
- nest.draw(world.pos_list[0], 0)
|
|
|
|
|
|
|
|
|
|
|
|
+ # On gère les évènements
|
|
|
for event in pygame.event.get():
|
|
for event in pygame.event.get():
|
|
|
|
|
|
|
|
- # On fait des trucs
|
|
|
|
|
|
|
+ # On gère les touches
|
|
|
|
|
+ if event.type == pygame.KEYDOWN:
|
|
|
|
|
+ if event.key == pygame.K_z:
|
|
|
|
|
+ player.move("up")
|
|
|
|
|
+
|
|
|
|
|
+ elif event.key == pygame.K_s:
|
|
|
|
|
+ player.move("down")
|
|
|
|
|
|
|
|
# Fermeture du jeu
|
|
# Fermeture du jeu
|
|
|
if event.type == QUIT:
|
|
if event.type == QUIT:
|
|
|
pygame.quit()
|
|
pygame.quit()
|
|
|
sys.exit()
|
|
sys.exit()
|
|
|
|
|
|
|
|
|
|
+ # À chaque tick on fait ce qu'il y a là
|
|
|
|
|
+ display.fill(BACKGROUND_COLOR)
|
|
|
|
|
+ world.draw()
|
|
|
|
|
+ player.draw()
|
|
|
|
|
+ nest.draw(world.pos_list[0], 0)
|
|
|
|
|
+
|
|
|
pygame.display.update()
|
|
pygame.display.update()
|
|
|
clock.tick(FPS)
|
|
clock.tick(FPS)
|
|
|
|
|
|