Add a button to snap the player coordinates to the closest point.
This commit is contained in:
parent
e0e9b33098
commit
9ceaba94d7
@ -28,3 +28,4 @@ If no game is specified then "squareroom" will be loaded.
|
||||
| Toggle debug info | F3 |
|
||||
| Print current position to the terminal | F4 |
|
||||
| Save level to `./levels` folder | F5 |
|
||||
| Snap to the closest point | F6 |
|
||||
|
@ -1,7 +1,7 @@
|
||||
import pygame
|
||||
from engineevents import EngineEvent
|
||||
from constants import ROT, IROT, OFFSET, I
|
||||
from gyro import GyroVector
|
||||
from gyro import GyroVector, MobiusDist
|
||||
from levels import open_level, save_level, make_wall
|
||||
from alert import Alert
|
||||
|
||||
@ -13,8 +13,6 @@ def defaultcontrols():
|
||||
if event.type == pygame.KEYDOWN:
|
||||
if event.key == pygame.K_r:
|
||||
aoEngineEvents.append(EngineEvent(None, lambda args: args[0].rotate(-1), tsArguments=("gPlayer",)))
|
||||
if event.key == pygame.K_F3:
|
||||
aoEngineEvents.append(EngineEvent("debugInfo", lambda args: not args[0]))
|
||||
if event.key == pygame.K_F1:
|
||||
aoEngineEvents.append(EngineEvent("bCap", lambda args: not args[0]))
|
||||
if event.key == pygame.K_F2:
|
||||
@ -29,6 +27,10 @@ def defaultcontrols():
|
||||
else:
|
||||
args[0].append(args[1].cPos)
|
||||
aoEngineEvents.append(EngineEvent(None, fX, tsArguments=("wall_buffer", "gPlayer", "level") ))
|
||||
if event.key == pygame.K_F3:
|
||||
aoEngineEvents.append(EngineEvent("debugInfo", lambda args: not args[0]))
|
||||
if event.key == pygame.K_F4:
|
||||
aoEngineEvents.append(EngineEvent(None, lambda args: print(args[0].cPos), tsArguments=("gPlayer",)))
|
||||
if event.key == pygame.K_F5:
|
||||
#0: level
|
||||
#1: alert_append
|
||||
@ -39,8 +41,24 @@ def defaultcontrols():
|
||||
|
||||
args[1](alert, 5)
|
||||
aoEngineEvents.append(EngineEvent(None, fX, tsArguments=("level", "alert_append", "display") ))
|
||||
if event.key == pygame.K_F4:
|
||||
aoEngineEvents.append(EngineEvent(None, lambda args: print(args[0].cPos), tsArguments=("gPlayer",)))
|
||||
if event.key == pygame.K_F6:
|
||||
def fX(aArgs):
|
||||
aLevel = aArgs[0]
|
||||
gPlayer = aArgs[1]
|
||||
fMin = 2
|
||||
cMin = gPlayer.cPos
|
||||
for i in aLevel:
|
||||
fD = MobiusDist(gPlayer.cPos, i.pointA)
|
||||
if fD < fMin:
|
||||
fMin = fD
|
||||
cMin = i.pointA
|
||||
fD = MobiusDist(gPlayer.cPos, i.pointB)
|
||||
if fD < fMin:
|
||||
fMin = fD
|
||||
cMin = i.pointB
|
||||
return GyroVector(cMin,gPlayer.cRot)
|
||||
aoEngineEvents.append(EngineEvent('gPlayer', fX, tsArguments=('level','gPlayer')))
|
||||
|
||||
keys = pygame.key.get_pressed()
|
||||
if keys[pygame.K_d]:
|
||||
aoEngineEvents.append(EngineEvent(None, lambda args: args[0].rotate( ROT), tsArguments=("gPlayer",)))
|
||||
|
Loading…
Reference in New Issue
Block a user