2020-03-28 03:43:12 +01:00
|
|
|
# -*- coding: UTF-8 -*-
|
|
|
|
|
|
|
|
### Tangled Mind
|
|
|
|
### Author: Arthur 'Grizzly' Grisel-Davy
|
|
|
|
|
|
|
|
import pygame
|
2020-05-07 01:41:34 +02:00
|
|
|
import yaml
|
2020-03-28 20:56:52 +01:00
|
|
|
|
2020-05-02 05:34:46 +02:00
|
|
|
from models import Game, Player, Carte, Camera, Enemy, Hud
|
2020-05-09 07:27:42 +02:00
|
|
|
from utils import enemy_placement
|
2020-04-11 06:17:49 +02:00
|
|
|
|
2020-03-28 03:43:12 +01:00
|
|
|
pygame.init()
|
|
|
|
|
|
|
|
|
2020-03-28 20:56:52 +01:00
|
|
|
screen_width = 1200
|
2020-03-28 03:43:12 +01:00
|
|
|
screen_height = 800
|
2020-04-15 01:07:57 +02:00
|
|
|
center_screen = (int(screen_width/2),int(screen_height/2))
|
2020-03-28 03:43:12 +01:00
|
|
|
screen = pygame.display.set_mode((screen_width, screen_height))
|
|
|
|
|
|
|
|
|
2020-04-04 06:11:34 +02:00
|
|
|
BACKGROUND=(200,200,200)
|
2020-03-28 03:43:12 +01:00
|
|
|
WHITE=(255,255,255)
|
|
|
|
BLUE=(0,0,255)
|
2020-03-28 20:56:52 +01:00
|
|
|
RED=(255,0,0)
|
2020-03-28 03:43:12 +01:00
|
|
|
|
2020-05-07 01:41:34 +02:00
|
|
|
|
2020-05-09 07:27:42 +02:00
|
|
|
with open(r'./config.yaml') as file:
|
|
|
|
data = yaml.load(file,Loader=yaml.FullLoader)
|
|
|
|
path_player = data['path_player']
|
|
|
|
path_canon = data['path_canon']
|
|
|
|
path_enemy = data['path_enemy']
|
|
|
|
path_projectile = data['path_projectile']
|
2020-05-07 03:52:10 +02:00
|
|
|
|
2020-05-07 01:41:34 +02:00
|
|
|
|
|
|
|
|
2020-05-04 04:27:44 +02:00
|
|
|
carte = Carte(n=5)
|
2020-05-09 07:27:42 +02:00
|
|
|
|
|
|
|
enemies = []
|
|
|
|
for positions in enemy_placement(carte.carte):
|
|
|
|
for position in positions:
|
|
|
|
enemies.append(Enemy('Plop',position,path_enemy))
|
|
|
|
|
2020-05-04 04:08:10 +02:00
|
|
|
start_pos = carte.player_start_pos
|
2020-05-09 07:27:42 +02:00
|
|
|
player = Player('Alice',start_pos,center_screen,pygame.K_z,pygame.K_s,pygame.K_q,pygame.K_d,323,path_player,path_canon,path_projectile)
|
2020-05-04 04:08:10 +02:00
|
|
|
camera = Camera(start_pos,screen_width,screen_height,0.3)
|
|
|
|
#enemies = [Enemy('Plop',(300,300),'perso.png')]
|
2020-05-02 05:34:46 +02:00
|
|
|
hud = Hud(player)
|
2020-05-09 07:27:42 +02:00
|
|
|
game = Game(carte,player,camera,enemies,hud)
|
2020-03-28 03:43:12 +01:00
|
|
|
|
2020-04-11 06:17:49 +02:00
|
|
|
clock = pygame.time.Clock()
|
2020-03-28 03:43:12 +01:00
|
|
|
|
2020-05-07 01:41:34 +02:00
|
|
|
done = False
|
2020-03-28 03:43:12 +01:00
|
|
|
while not done:
|
2020-05-07 01:41:34 +02:00
|
|
|
for event in pygame.event.get():
|
|
|
|
if event.type == pygame.QUIT:
|
|
|
|
done = True
|
2020-05-07 03:52:10 +02:00
|
|
|
if event.type == pygame.KEYDOWN:
|
|
|
|
if event.key == pygame.K_ESCAPE:
|
|
|
|
game.pause = not game.pause
|
2020-03-28 03:43:12 +01:00
|
|
|
|
2020-04-11 06:17:49 +02:00
|
|
|
|
2020-05-07 01:41:34 +02:00
|
|
|
keystate = pygame.key.get_pressed() + pygame.mouse.get_pressed()
|
2020-04-14 02:43:09 +02:00
|
|
|
|
2020-05-07 01:41:34 +02:00
|
|
|
if not game.pause:
|
2020-05-02 05:34:46 +02:00
|
|
|
player.check_keys(keystate,screen_width,screen_height,carte,camera)
|
2020-03-28 20:56:52 +01:00
|
|
|
|
2020-05-07 01:41:34 +02:00
|
|
|
|
|
|
|
screen.fill(BACKGROUND)
|
|
|
|
game.draw(screen)
|
|
|
|
|
|
|
|
if game.pause:
|
2020-05-07 03:52:10 +02:00
|
|
|
game.draw_pause(screen)
|
2020-03-28 03:43:12 +01:00
|
|
|
|
2020-05-07 01:41:34 +02:00
|
|
|
pygame.display.flip()
|
2020-04-11 06:17:49 +02:00
|
|
|
|
|
|
|
|
2020-05-07 01:41:34 +02:00
|
|
|
clock.tick(60)
|
2020-04-11 06:17:49 +02:00
|
|
|
|