A commit.

This commit is contained in:
bʰedoh₂ swé 2024-04-03 17:47:27 +05:00
parent 64402f86b6
commit d4b559555b

16
main.py
View File

@ -20,6 +20,8 @@ IROT = 1/ROT
F = 5 * 10**7 F = 5 * 10**7
F_ = 10**9 F_ = 10**9
SKY = (127,127,255)
GROUND = (102, 51, 0)
class Segment: class Segment:
def __init__(self,bA,cA,cB,trColor): def __init__(self,bA,cA,cB,trColor):
@ -34,10 +36,10 @@ class DrawnSegment:
self.color = color self.color = color
level = [ level = [
Segment(False,.5,I*.5,(255,0,0)), Segment(False,.7,I*.7,(255,0,0)),
Segment(False,.5,-I*.5,(0,255,0)), Segment(False,.7,-I*.7,(0,255,0)),
Segment(False,-.5,-I*.5,(0,0,255)), Segment(False,-.7,-I*.7,(0,0,255)),
Segment(False,-.5,I*.5,(255,255,0)) Segment(False,-.7,I*.7,(255,255,0))
] ]
def draw(level,gPlayer,fov,res): def draw(level,gPlayer,fov,res):
@ -54,7 +56,7 @@ def draw(level,gPlayer,fov,res):
cInt = cLineIntersection(tA,tB,complex(0),rot) cInt = cLineIntersection(tA,tB,complex(0),rot)
except ZeroDivisionError: except ZeroDivisionError:
continue continue
rDist = cDist(0,cInt) rDist = cDist(0,cInt) * irot.real
if cDot(cInt,rot) > 0: if cDot(cInt,rot) > 0:
continue continue
if (1 - m.height) > rDist: if (1 - m.height) > rDist:
@ -92,9 +94,11 @@ def mainLoop():
display.fill(WHITE) display.fill(WHITE)
#pygame.draw.rect(display,BLACK, c_tr(Poincare2Klein(gPlayer.cPos) * -100) + (100,100),0) #pygame.draw.rect(display,BLACK, c_tr(Poincare2Klein(gPlayer.cPos) * -100) + (100,100),0)
drawn = draw(level,gPlayer,PI/2,640) drawn = draw(level,gPlayer,PI/2,640)
pygame.draw.rect(display,SKY, (0,0,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,360 - (cap(i.height) * 500),10,cap(i.height) * 1000)) pygame.draw.rect(display,i.color, (n,360 - (cap(i.height) * 360),10,cap(i.height) * 1000))
n += 2 n += 2
font.render_to(display, (20, 150), str(gPlayer.cPos), (0, 0, 0)) font.render_to(display, (20, 150), str(gPlayer.cPos), (0, 0, 0))
font.render_to(display, (20, 250), str(gPlayer.cRot), (0, 0, 0)) font.render_to(display, (20, 250), str(gPlayer.cRot), (0, 0, 0))