forked from bedohswe/p3he
Compare commits
No commits in common. "54c276bd8beefab40ddaf450625af3009a902eba" and "a0a33254e36f4e61b7b736cb6884e7951e70e35a" have entirely different histories.
54c276bd8b
...
a0a33254e3
21
main.py
21
main.py
@ -8,6 +8,7 @@ import pygame.freetype
|
|||||||
from gyro import *
|
from gyro import *
|
||||||
from lines import *
|
from lines import *
|
||||||
|
|
||||||
|
|
||||||
def deg2rad(rA): return rA/180*PI
|
def deg2rad(rA): return rA/180*PI
|
||||||
|
|
||||||
I = complex256(complex(0,1))
|
I = complex256(complex(0,1))
|
||||||
@ -56,7 +57,7 @@ def draw(level,gPlayer,fov,res):
|
|||||||
cInt = cLineIntersection(tA,tB,complex256(0),rot)
|
cInt = cLineIntersection(tA,tB,complex256(0),rot)
|
||||||
except ZeroDivisionError:
|
except ZeroDivisionError:
|
||||||
continue
|
continue
|
||||||
rDist = cDist(0,cInt)
|
rDist = cDist(0,cInt)
|
||||||
if not (j.isFinite and cBetween(tA,tB,cInt)):
|
if not (j.isFinite and cBetween(tA,tB,cInt)):
|
||||||
continue
|
continue
|
||||||
if cDot(cInt,rot) > 0:
|
if cDot(cInt,rot) > 0:
|
||||||
@ -65,7 +66,7 @@ def draw(level,gPlayer,fov,res):
|
|||||||
m = DrawnSegment(1-rDist,j.color)
|
m = DrawnSegment(1-rDist,j.color)
|
||||||
drawn.append(m)
|
drawn.append(m)
|
||||||
return drawn
|
return drawn
|
||||||
|
|
||||||
def cap(rN):
|
def cap(rN):
|
||||||
if rN < 0:
|
if rN < 0:
|
||||||
return 0
|
return 0
|
||||||
@ -74,7 +75,7 @@ def cap(rN):
|
|||||||
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))
|
||||||
font = pygame.freetype.Font(None,18)
|
font = pygame.freetype.Font(None,24)
|
||||||
while True:
|
while True:
|
||||||
framestart = time_ns()
|
framestart = time_ns()
|
||||||
|
|
||||||
@ -83,7 +84,7 @@ def mainLoop():
|
|||||||
return True
|
return True
|
||||||
if event.type == pygame.KEYDOWN:
|
if event.type == pygame.KEYDOWN:
|
||||||
if event.key == pygame.K_q:
|
if event.key == pygame.K_q:
|
||||||
gPlayer.cRot *= -1
|
gPlayer.cRot *= -1
|
||||||
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)
|
||||||
@ -102,19 +103,17 @@ def mainLoop():
|
|||||||
for i in drawn:
|
for i in drawn:
|
||||||
pygame.draw.rect(display,i.color, (n,360 - (cap(i.height) * 360),10,cap(i.height) * 1000))
|
pygame.draw.rect(display,i.color, (n,360 - (cap(i.height) * 360),10,cap(i.height) * 1000))
|
||||||
n += 8
|
n += 8
|
||||||
|
font.render_to(display, (20, 150), str(gPlayer.cPos), (0, 0, 0))
|
||||||
font.render_to(display, (8, 8), "cPos: " + str(gPlayer.cPos), (255, 255, 255), (0, 0, 0))
|
font.render_to(display, (20, 250), str(gPlayer.cRot), (0, 0, 0))
|
||||||
font.render_to(display, (8, 26), "cRot: " + str(gPlayer.cRot), (255, 255, 255), (0, 0, 0))
|
|
||||||
|
|
||||||
pygame.display.update()
|
pygame.display.update()
|
||||||
|
|
||||||
frameend = time_ns()
|
frameend = time_ns()
|
||||||
sleep((frameend-framestart) / F_)
|
sleep((frameend-framestart) / F_)
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
pygame.init()
|
pygame.init()
|
||||||
pygame.display.set_caption('P3HE')
|
pygame.display.set_caption('P3HE')
|
||||||
if not pygame.get_init():
|
if not pygame.get_init():
|
||||||
return False
|
return False
|
||||||
retstatus = mainLoop()
|
retstatus = mainLoop()
|
||||||
|
Loading…
Reference in New Issue
Block a user