Remove hardcoded data and create config file

master
grisel-davy 4 years ago
parent 9795abe51d
commit 9c71bd0312

@ -0,0 +1,15 @@
### Tangled Mind
### Author: Arthur 'Grizzly' Grisel-Davy
# Map
room_side : 1000
# Player
cap_speed : 10
acceleration : 2
deceleration : 1.1
# Projectile
max_fire_rate : 10

@ -26,7 +26,6 @@ carte = Carte(n=5)
# possible positions: 300,300: 1400,1000: 2700,400, 2800,1600
# click = 323
start_pos = carte.player_start_pos
print(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')]

@ -11,11 +11,14 @@ from utils import *
img_path = 'asset/'
max_fire_rate = 10 # in fires per seconds
cap_speed = 10
acceleration = 2
deceleration = 1.1
with open(r'./config.yaml') as file:
data = yaml.load(file,Loader=yaml.FullLoader)
max_fire_rate = data['max_fire_rate'] # in fires per seconds
cap_speed = data['cap_speed']
acceleration = data['acceleration']
deceleration = data['deceleration']

@ -6,6 +6,7 @@
from glob import glob
import random
import pygame
import yaml
def fetch_rooms(path):
"""Fetch all the basic tiles asset from the path.
@ -53,7 +54,10 @@ def map_generator(n):
"""Map generator generate a map with a main path of n rooms
"""
room_side = 1000
with open(r'./config.yaml') as file:
data = yaml.load(file,Loader=yaml.FullLoader)
room_side = data['room_side']
change_side = {'T':'D','R':'L','D':'T','L':'R'}
deplacements = {'T':[0,-1],'R':[1,0],'D':[0,1],'L':[-1,0]}
@ -136,9 +140,6 @@ def map_generator(n):
background = pygame.image.load(back_path).convert()
print("Open paths:")
print(open_paths)
if not check_map(carte):
raise ValueError("Invalid Map after closing paths.")

Loading…
Cancel
Save