feat(walls): player can create walls by pressing F3
This commit is contained in:
parent
f7ee5715c7
commit
e1010930b5
20
main.py
20
main.py
@ -88,12 +88,22 @@ def renderDebugInfo(gPlayer, clock, fontSize = 18):
|
|||||||
|
|
||||||
return fps_surf, cPos_surf, cRot_surf
|
return fps_surf, cPos_surf, cRot_surf
|
||||||
|
|
||||||
|
def make_wall(wall_buffer):
|
||||||
|
if (len(wall_buffer) != 2):
|
||||||
|
print('Warning: wall buffer not contains 2 points.')
|
||||||
|
return
|
||||||
|
|
||||||
|
level.append(
|
||||||
|
Segment(True, wall_buffer[0], wall_buffer[1], (23,74,183))
|
||||||
|
)
|
||||||
|
|
||||||
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))
|
||||||
clock = pygame.time.Clock()
|
clock = pygame.time.Clock()
|
||||||
fontSize = 18
|
fontSize = 18
|
||||||
debugInfo = True
|
debugInfo = True
|
||||||
|
wall_buffer = []
|
||||||
|
|
||||||
while True:
|
while True:
|
||||||
#framestart = time_ns()
|
#framestart = time_ns()
|
||||||
@ -106,6 +116,14 @@ def mainLoop():
|
|||||||
gPlayer.cRot *= -1
|
gPlayer.cRot *= -1
|
||||||
if event.key == pygame.K_F3:
|
if event.key == pygame.K_F3:
|
||||||
debugInfo = not debugInfo
|
debugInfo = not debugInfo
|
||||||
|
if event.key == pygame.K_F2:
|
||||||
|
if (len(wall_buffer) == 1):
|
||||||
|
wall_buffer.append(gPlayer.cPos)
|
||||||
|
make_wall(wall_buffer)
|
||||||
|
wall_buffer.clear()
|
||||||
|
else:
|
||||||
|
wall_buffer.append(gPlayer.cPos)
|
||||||
|
|
||||||
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)
|
||||||
@ -118,7 +136,7 @@ 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/4,320)
|
drawn = draw(level,gPlayer,PI/2,320)
|
||||||
pygame.draw.rect(display,SKY, (0,0,1280,360))
|
pygame.draw.rect(display,SKY, (0,0,1280,360))
|
||||||
pygame.draw.rect(display,GROUND, (0,360,1280,360))
|
pygame.draw.rect(display,GROUND, (0,360,1280,360))
|
||||||
n = 0
|
n = 0
|
||||||
|
Loading…
Reference in New Issue
Block a user