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 *
|
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
|
||||||
@ -25,8 +25,11 @@ def draw(level,gPlayer,fov,res):
|
|||||||
rDist = MobiusDist(cInt,gPlayer.cPos)*1.1
|
rDist = MobiusDist(cInt,gPlayer.cPos)*1.1
|
||||||
if j.isFinite and not 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
|
||||||
|
|
||||||
|
2
main.py
2
main.py
@ -90,7 +90,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((cap(i.dist)) * 360),8,int(cap(1 - i.dist) * 1280)))
|
||||||
n += 4
|
n += 4
|
||||||
gPlayer.normalize()
|
gPlayer.normalize()
|
||||||
if debugInfo:
|
if debugInfo:
|
||||||
|
Loading…
Reference in New Issue
Block a user