Merge conflict fix.
This commit is contained in:
commit
43b2d31980
@ -3,6 +3,6 @@ from cmath import exp
|
|||||||
I = complex(0,1)
|
I = complex(0,1)
|
||||||
WHITE = (255,255,255)
|
WHITE = (255,255,255)
|
||||||
BLACK = (0,0,0)
|
BLACK = (0,0,0)
|
||||||
OFFSET = 0.015625
|
OFFSET = 0.0078125
|
||||||
ROT = cNorm(exp(deg2rad(2)*I))
|
ROT = cNorm(exp(deg2rad(2)*I))
|
||||||
IROT = 1/ROT
|
IROT = 1/ROT
|
||||||
|
17
draw.py
17
draw.py
@ -4,8 +4,8 @@ from gyro import *
|
|||||||
from lines import *
|
from lines import *
|
||||||
|
|
||||||
class DrawnSegment:
|
class DrawnSegment:
|
||||||
def __init__(self,height,color):
|
def __init__(self,dist,color):
|
||||||
self.height = height
|
self.dist = dist
|
||||||
self.color = color
|
self.color = color
|
||||||
|
|
||||||
def draw(level,gPlayer,fov,res):
|
def draw(level,gPlayer,fov,res):
|
||||||
@ -13,7 +13,7 @@ def draw(level,gPlayer,fov,res):
|
|||||||
irot = exp(fov/res*I)
|
irot = exp(fov/res*I)
|
||||||
iprot = gPlayer.cRot
|
iprot = gPlayer.cRot
|
||||||
for i in range(res):
|
for i in range(res):
|
||||||
m = DrawnSegment(0,BLACK)
|
m = None
|
||||||
rot = irot**(i-(res/2)) * iprot
|
rot = irot**(i-(res/2)) * iprot
|
||||||
for j in level:
|
for j in level:
|
||||||
try: # Function "LineIntersection" faults from time to time
|
try: # Function "LineIntersection" faults from time to time
|
||||||
@ -23,10 +23,13 @@ def draw(level,gPlayer,fov,res):
|
|||||||
if cDot(rot,MobiusAdd(cInt,-gPlayer.cPos)) > 0:
|
if cDot(rot,MobiusAdd(cInt,-gPlayer.cPos)) > 0:
|
||||||
continue
|
continue
|
||||||
rDist = MobiusDist(cInt,gPlayer.cPos)*1.1
|
rDist = MobiusDist(cInt,gPlayer.cPos)*1.1
|
||||||
if not (j.isFinite and cBetween(j.pointA,j.pointB,cInt)):
|
if j.isFinite and not cBetween(j.pointA,j.pointB,cInt):
|
||||||
continue
|
continue
|
||||||
if (1 - m.height) > rDist:
|
if m is None:
|
||||||
m = DrawnSegment(1-rDist,j.color)
|
m = DrawnSegment(rDist,j.color)
|
||||||
drawn.append(m)
|
continue
|
||||||
|
if m.dist > rDist:
|
||||||
|
m = DrawnSegment(rDist,j.color)
|
||||||
|
drawn.append(m if m is not None else DrawnSegment(0, BLACK))
|
||||||
return drawn
|
return drawn
|
||||||
|
|
||||||
|
@ -18,8 +18,8 @@ def parse_level_from_string(string):
|
|||||||
|
|
||||||
level.append(
|
level.append(
|
||||||
Segment(
|
Segment(
|
||||||
bool(raw_segment[0]),
|
raw_segment[0] == "True",
|
||||||
float(raw_segment[1]),
|
complex(raw_segment[1]),
|
||||||
complex(raw_segment[2]),
|
complex(raw_segment[2]),
|
||||||
tuple(map(int, raw_segment[3][1:len(raw_segment[3])-1].split(', ')))
|
tuple(map(int, raw_segment[3][1:len(raw_segment[3])-1].split(', ')))
|
||||||
)
|
)
|
||||||
|
2
lines.py
2
lines.py
@ -13,7 +13,7 @@ def cLineIntersection(cA0, cA1, cB0, cB1):
|
|||||||
|
|
||||||
@jit
|
@jit
|
||||||
def Between(rA,rB,rN):
|
def Between(rA,rB,rN):
|
||||||
return (rA < rN and rN < rB) or (rB < rN and rN < rA)
|
return (rA <= rN and rN <= rB) or (rB <= rN and rN <= rA)
|
||||||
|
|
||||||
@jit
|
@jit
|
||||||
def cBetween(cA,cB,cN):
|
def cBetween(cA,cB,cN):
|
||||||
|
29
main.py
29
main.py
@ -2,11 +2,13 @@
|
|||||||
from numba import jit
|
from numba import jit
|
||||||
|
|
||||||
from math import copysign, pi, acos
|
from math import copysign, pi, acos
|
||||||
|
from time import time
|
||||||
|
import sys
|
||||||
|
|
||||||
import pygame
|
import pygame
|
||||||
import pygame.freetype
|
import pygame.freetype
|
||||||
|
|
||||||
from levels import Segment
|
from levels import Segment, open_level, parse_level_from_string
|
||||||
from gyro import *
|
from gyro import *
|
||||||
from levels import *
|
from levels import *
|
||||||
from constants import *
|
from constants import *
|
||||||
@ -20,14 +22,6 @@ gOrigin = GyroVector(0,1)
|
|||||||
SKY = (127,127,255)
|
SKY = (127,127,255)
|
||||||
GROUND = (102, 51, 0)
|
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):
|
def renderDebugInfo(gPlayer, clock, fontSize = 18):
|
||||||
font = pygame.freetype.Font(None, fontSize)
|
font = pygame.freetype.Font(None, fontSize)
|
||||||
font_fg = (255, 255, 255)
|
font_fg = (255, 255, 255)
|
||||||
@ -39,6 +33,10 @@ def renderDebugInfo(gPlayer, clock, fontSize = 18):
|
|||||||
|
|
||||||
return fps_surf, cPos_surf, cRot_surf
|
return fps_surf, cPos_surf, cRot_surf
|
||||||
|
|
||||||
|
def nonzerocap(n):
|
||||||
|
if n <= 0: return 1
|
||||||
|
return n
|
||||||
|
|
||||||
def mainLoop():
|
def mainLoop():
|
||||||
gPlayer = GyroVector(0,1)
|
gPlayer = GyroVector(0,1)
|
||||||
display = pygame.display.set_mode((1280,720))
|
display = pygame.display.set_mode((1280,720))
|
||||||
@ -55,6 +53,12 @@ def mainLoop():
|
|||||||
alerts.append(alert)
|
alerts.append(alert)
|
||||||
alert.start_hide_thread(alerts, delay)
|
alert.start_hide_thread(alerts, delay)
|
||||||
|
|
||||||
|
try:
|
||||||
|
leveltoparse = open_level(sys.argv[1])
|
||||||
|
except IndexError:
|
||||||
|
leveltoparse = open_level("maps/squareroom.p3hel")
|
||||||
|
level = parse_level_from_string(leveltoparse)
|
||||||
|
|
||||||
while True:
|
while True:
|
||||||
for event in pygame.event.get():
|
for event in pygame.event.get():
|
||||||
if event.type == pygame.QUIT:
|
if event.type == pygame.QUIT:
|
||||||
@ -80,11 +84,6 @@ def mainLoop():
|
|||||||
|
|
||||||
alert_append(alert, 5)
|
alert_append(alert, 5)
|
||||||
|
|
||||||
if event.key == pygame.K_F9:
|
|
||||||
# TODO: @bedohswe make open file dialog
|
|
||||||
# open_level(path)
|
|
||||||
pass
|
|
||||||
|
|
||||||
keys = pygame.key.get_pressed()
|
keys = pygame.key.get_pressed()
|
||||||
if keys[pygame.K_d]:
|
if keys[pygame.K_d]:
|
||||||
gPlayer.rotate(ROT)
|
gPlayer.rotate(ROT)
|
||||||
@ -105,7 +104,7 @@ def mainLoop():
|
|||||||
pygame.draw.rect(display,GROUND, (0,360,1280,360))
|
pygame.draw.rect(display,GROUND, (0,360,1280,360))
|
||||||
n = 0
|
n = 0
|
||||||
for i in drawn:
|
for i in drawn:
|
||||||
pygame.draw.rect(display,i.color, (n,int((1 - cap(i.height)) * 360),8,int(cap(i.height) * 1280)))
|
pygame.draw.rect(display,i.color, (n,int((nonzerocap(i.dist)) * 360),8,int((1 -nonzerocap(i.dist)) * 1280)))
|
||||||
n += 4
|
n += 4
|
||||||
gPlayer.normalize()
|
gPlayer.normalize()
|
||||||
if debugInfo:
|
if debugInfo:
|
||||||
|
1
maps/cross.p3hel
Normal file
1
maps/cross.p3hel
Normal file
@ -0,0 +1 @@
|
|||||||
|
False/1/0/(255, 0, 0 |False/1j/0/(0, 255, 0
|
1
maps/empty.p3hel
Normal file
1
maps/empty.p3hel
Normal file
@ -0,0 +1 @@
|
|||||||
|
True/0/0/(0, 0, 0
|
1
maps/squareroom.p3hel
Normal file
1
maps/squareroom.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