forked from bedohswe/p3he
Change rendering a bit.
This commit is contained in:
parent
53ecde3e0c
commit
d54377e3d6
15
draw.py
15
draw.py
@ -4,8 +4,8 @@ from gyro import *
|
||||
from lines import *
|
||||
|
||||
class DrawnSegment:
|
||||
def __init__(self,height,color):
|
||||
self.height = height
|
||||
def __init__(self,dist,color):
|
||||
self.dist = dist
|
||||
self.color = color
|
||||
|
||||
def draw(level,gPlayer,fov,res):
|
||||
@ -13,7 +13,7 @@ def draw(level,gPlayer,fov,res):
|
||||
irot = exp(fov/res*I)
|
||||
iprot = gPlayer.cRot
|
||||
for i in range(res):
|
||||
m = DrawnSegment(0,BLACK)
|
||||
m = None
|
||||
rot = irot**(i-(res/2)) * iprot
|
||||
for j in level:
|
||||
try: # Function "LineIntersection" faults from time to time
|
||||
@ -25,8 +25,11 @@ def draw(level,gPlayer,fov,res):
|
||||
rDist = MobiusDist(cInt,gPlayer.cPos)*1.1
|
||||
if j.isFinite and not cBetween(j.pointA,j.pointB,cInt):
|
||||
continue
|
||||
if (1 - m.height) > rDist:
|
||||
m = DrawnSegment(1-rDist,j.color)
|
||||
drawn.append(m)
|
||||
if m is None:
|
||||
m = DrawnSegment(rDist,j.color)
|
||||
continue
|
||||
if m.dist > rDist:
|
||||
m = DrawnSegment(rDist,j.color)
|
||||
drawn.append(m if m is not None else DrawnSegment(0, BLACK))
|
||||
return drawn
|
||||
|
||||
|
2
main.py
2
main.py
@ -90,7 +90,7 @@ def mainLoop():
|
||||
pygame.draw.rect(display,GROUND, (0,360,1280,360))
|
||||
n = 0
|
||||
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((cap(i.dist)) * 360),8,int(cap(1 - i.dist) * 1280)))
|
||||
n += 4
|
||||
gPlayer.normalize()
|
||||
if debugInfo:
|
||||
|
Loading…
Reference in New Issue
Block a user