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 |
|
| Toggle debug info | F3 |
|
||||||
| Print current position to the terminal | F4 |
|
| Print current position to the terminal | F4 |
|
||||||
| Save level to `./levels` folder | F5 |
|
| Save level to `./levels` folder | F5 |
|
||||||
|
| Snap to the closest point | F6 |
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import pygame
|
import pygame
|
||||||
from engineevents import EngineEvent
|
from engineevents import EngineEvent
|
||||||
from constants import ROT, IROT, OFFSET, I
|
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 levels import open_level, save_level, make_wall
|
||||||
from alert import Alert
|
from alert import Alert
|
||||||
|
|
||||||
@ -13,8 +13,6 @@ def defaultcontrols():
|
|||||||
if event.type == pygame.KEYDOWN:
|
if event.type == pygame.KEYDOWN:
|
||||||
if event.key == pygame.K_r:
|
if event.key == pygame.K_r:
|
||||||
aoEngineEvents.append(EngineEvent(None, lambda args: args[0].rotate(-1), tsArguments=("gPlayer",)))
|
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:
|
if event.key == pygame.K_F1:
|
||||||
aoEngineEvents.append(EngineEvent("bCap", lambda args: not args[0]))
|
aoEngineEvents.append(EngineEvent("bCap", lambda args: not args[0]))
|
||||||
if event.key == pygame.K_F2:
|
if event.key == pygame.K_F2:
|
||||||
@ -29,6 +27,10 @@ def defaultcontrols():
|
|||||||
else:
|
else:
|
||||||
args[0].append(args[1].cPos)
|
args[0].append(args[1].cPos)
|
||||||
aoEngineEvents.append(EngineEvent(None, fX, tsArguments=("wall_buffer", "gPlayer", "level") ))
|
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:
|
if event.key == pygame.K_F5:
|
||||||
#0: level
|
#0: level
|
||||||
#1: alert_append
|
#1: alert_append
|
||||||
@ -39,8 +41,24 @@ def defaultcontrols():
|
|||||||
|
|
||||||
args[1](alert, 5)
|
args[1](alert, 5)
|
||||||
aoEngineEvents.append(EngineEvent(None, fX, tsArguments=("level", "alert_append", "display") ))
|
aoEngineEvents.append(EngineEvent(None, fX, tsArguments=("level", "alert_append", "display") ))
|
||||||
if event.key == pygame.K_F4:
|
if event.key == pygame.K_F6:
|
||||||
aoEngineEvents.append(EngineEvent(None, lambda args: print(args[0].cPos), tsArguments=("gPlayer",)))
|
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()
|
keys = pygame.key.get_pressed()
|
||||||
if keys[pygame.K_d]:
|
if keys[pygame.K_d]:
|
||||||
aoEngineEvents.append(EngineEvent(None, lambda args: args[0].rotate( ROT), tsArguments=("gPlayer",)))
|
aoEngineEvents.append(EngineEvent(None, lambda args: args[0].rotate( ROT), tsArguments=("gPlayer",)))
|
||||||
|
Loading…
Reference in New Issue
Block a user