forked from bedohswe/p3he
Implement level loading.
This commit is contained in:
parent
371491a607
commit
3b2522b12b
@ -19,7 +19,7 @@ def parse_level_from_string(string):
|
||||
level.append(
|
||||
Segment(
|
||||
bool(raw_segment[0]),
|
||||
float(raw_segment[1]),
|
||||
complex(raw_segment[1]),
|
||||
complex(raw_segment[2]),
|
||||
tuple(map(int, raw_segment[3][1:len(raw_segment[3])-1].split(', ')))
|
||||
)
|
||||
|
16
main.py
16
main.py
@ -3,11 +3,12 @@ from numba import jit
|
||||
|
||||
from math import copysign, pi, acos
|
||||
from time import time
|
||||
import sys
|
||||
|
||||
import pygame
|
||||
import pygame.freetype
|
||||
|
||||
from levels import Segment
|
||||
from levels import Segment, open_level, parse_level_from_string
|
||||
from gyro import *
|
||||
from levels import *
|
||||
from constants import *
|
||||
@ -20,14 +21,6 @@ gOrigin = GyroVector(0,1)
|
||||
SKY = (127,127,255)
|
||||
GROUND = (102, 51, 0)
|
||||
|
||||
level = [
|
||||
Segment(True,.6,I*.6,(255,0,0)),
|
||||
Segment(True,.6,-I*.6,(0,255,0)),
|
||||
Segment(True,-.6,-I*.6,(0,0,255)),
|
||||
Segment(True,-.6,I*.6,(255,255,0))
|
||||
]
|
||||
|
||||
|
||||
def renderDebugInfo(gPlayer, clock, fontSize = 18):
|
||||
font = pygame.freetype.Font(None, fontSize)
|
||||
font_fg = (255, 255, 255)
|
||||
@ -49,6 +42,11 @@ def mainLoop():
|
||||
debugInfo = True
|
||||
wall_buffer = []
|
||||
|
||||
try:
|
||||
level = parse_level_from_string(open_level(sys.argv[1]))
|
||||
except IndexError:
|
||||
level = parse_level_from_string(open_level("maps/cuberoom.p3hel"))
|
||||
|
||||
while True:
|
||||
for event in pygame.event.get():
|
||||
if event.type == pygame.QUIT:
|
||||
|
1
maps/cuberoom.p3hel
Normal file
1
maps/cuberoom.p3hel
Normal file
@ -0,0 +1 @@
|
||||
True/0.6/0.6j/(255, 0, 0)|True/0.6/-0.6j/(0, 255, 0)|True/-0.6/-0.6j/(0, 0, 255)|True/-0.6/0.6j/(255, 255, 0)
|
Loading…
Reference in New Issue
Block a user