74 lines
No EOL
1.8 KiB
Python
74 lines
No EOL
1.8 KiB
Python
# -*- coding: UTF-8 -*-
|
|
|
|
### Tangled Mind
|
|
### Author: Arthur 'Grizzly' Grisel-Davy
|
|
|
|
import pygame
|
|
import yaml
|
|
|
|
from models import Game, Player, Carte, Camera, Enemy, Hud
|
|
|
|
pygame.init()
|
|
|
|
|
|
screen_width = 1200
|
|
screen_height = 800
|
|
center_screen = (int(screen_width/2),int(screen_height/2))
|
|
screen = pygame.display.set_mode((screen_width, screen_height))
|
|
|
|
|
|
BACKGROUND=(200,200,200)
|
|
WHITE=(255,255,255)
|
|
BLUE=(0,0,255)
|
|
RED=(255,0,0)
|
|
|
|
# with open(r'./config.yaml') as file:
|
|
# data = yaml.load(file,Loader=yaml.FullLoader)
|
|
# up = pygame.key.key_code(data['up'])
|
|
# right = pygame.key.key_code(data['right'])
|
|
# down = pygame.key.key_code(data['down'])
|
|
# left = pygame.key.key_code(data['left'])
|
|
# pause = pygame.key.key_code(data['pause'])
|
|
# print(up,right,down,left,pause)
|
|
|
|
|
|
|
|
|
|
|
|
carte = Carte(n=5)
|
|
start_pos = carte.player_start_pos
|
|
player = Player('Alice',start_pos,center_screen,pygame.K_z,pygame.K_s,pygame.K_q,pygame.K_d,323,'perso.png','canon.png','projectile1_right.png')
|
|
camera = Camera(start_pos,screen_width,screen_height,0.3)
|
|
#enemies = [Enemy('Plop',(300,300),'perso.png')]
|
|
hud = Hud(player)
|
|
game = Game(carte,player,camera,[],hud)
|
|
|
|
clock = pygame.time.Clock()
|
|
|
|
done = False
|
|
while not done:
|
|
for event in pygame.event.get():
|
|
if event.type == pygame.QUIT:
|
|
done = True
|
|
if event.type == pygame.KEYDOWN:
|
|
if event.key == pygame.K_ESCAPE:
|
|
game.pause = not game.pause
|
|
|
|
|
|
keystate = pygame.key.get_pressed() + pygame.mouse.get_pressed()
|
|
|
|
if not game.pause:
|
|
player.check_keys(keystate,screen_width,screen_height,carte,camera)
|
|
|
|
|
|
screen.fill(BACKGROUND)
|
|
game.draw(screen)
|
|
|
|
if game.pause:
|
|
game.draw_pause(screen)
|
|
|
|
pygame.display.flip()
|
|
|
|
|
|
clock.tick(60)
|
|
|