main.py 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. import pygame, sys
  2. from pygame.locals import * # Import des constantes de pygame
  3. from world import World
  4. from variables import *
  5. from player import *
  6. from nest import *
  7. def main():
  8. """La fonction pricipale"""
  9. ### Initialmisation ###
  10. pygame.init() # La fonction secrète, on sait pas ce qu'elle fait mais elle doit être là
  11. display = pygame.display.set_mode((WINDOW_WIDTH, WINDOW_HEIGHT)) # Taille de la fenêtre
  12. display.fill(BACKGROUND_COLOR)
  13. pygame.display.set_caption("VISI301") # Nom de la fenêtre, à changer à la fin TODO
  14. # Horloge du jeu
  15. clock = pygame.time.Clock()
  16. # Création du monde
  17. world = World(display, NB_COL, NB_ROW, GAP)
  18. player = Player(0, 0, world, display)
  19. nest = Nest(0, display)
  20. ### Boucle principale ###
  21. while True:
  22. # À chaque tick on fait ce qu'il y a là
  23. world.draw()
  24. player.draw(world.pos_list[1]) # On commence sur la tuile en dessous du nid
  25. nest.draw(world.pos_list[0], 0)
  26. for event in pygame.event.get():
  27. # On fait des trucs
  28. # Fermeture du jeu
  29. if event.type == QUIT:
  30. pygame.quit()
  31. sys.exit()
  32. pygame.display.update()
  33. clock.tick(FPS)
  34. # On quitte pygame
  35. pygame.quit()
  36. # On lance la fonction principale
  37. main()