Make speed changable via engine events.
This commit is contained in:
parent
28868e5451
commit
457f0b9fa0
@ -3,6 +3,5 @@ from cmath import exp
|
||||
I = complex(0,1)
|
||||
WHITE = (255,255,255)
|
||||
BLACK = (0,0,0)
|
||||
OFFSET = 0.0078125
|
||||
ROT = cNorm(exp(deg2rad(2)*I))
|
||||
IROT = 1/ROT
|
||||
|
@ -1,6 +1,6 @@
|
||||
import pygame
|
||||
from engineevents import EngineEvent
|
||||
from constants import ROT, IROT, OFFSET, I
|
||||
from constants import ROT, IROT, I
|
||||
from gyro import GyroVector, MobiusDist
|
||||
from levels import open_level, save_level, make_wall
|
||||
from alert import Alert
|
||||
@ -69,11 +69,11 @@ def defaultcontrols():
|
||||
if keys[pygame.K_a]:
|
||||
aoEngineEvents.append(EngineEvent(None, lambda args: args[0].rotate(IROT), tsArguments=("gPlayer",)))
|
||||
if keys[pygame.K_q]:
|
||||
aoEngineEvents.append(EngineEvent(None, lambda args: args[0].__iadd__(GyroVector(OFFSET * args[0].cRot*I, 1)), tsArguments=("gPlayer",)))
|
||||
aoEngineEvents.append(EngineEvent(None, lambda args: args[0].__iadd__(GyroVector(args[1] * args[0].cRot*I, 1)), tsArguments=("gPlayer",'offset')))
|
||||
if keys[pygame.K_e]:
|
||||
aoEngineEvents.append(EngineEvent(None, lambda args: args[0].__isub__(GyroVector(OFFSET * args[0].cRot*I, 1)), tsArguments=("gPlayer",)))
|
||||
aoEngineEvents.append(EngineEvent(None, lambda args: args[0].__isub__(GyroVector(args[1] * args[0].cRot*I, 1)), tsArguments=("gPlayer",'offset')))
|
||||
if keys[pygame.K_w]:
|
||||
aoEngineEvents.append(EngineEvent(None, lambda args: args[0].__isub__(GyroVector(OFFSET * args[0].cRot , 1)), tsArguments=("gPlayer",)))
|
||||
aoEngineEvents.append(EngineEvent(None, lambda args: args[0].__isub__(GyroVector(args[1] * args[0].cRot , 1)), tsArguments=("gPlayer",'offset')))
|
||||
if keys[pygame.K_s]:
|
||||
aoEngineEvents.append(EngineEvent(None, lambda args: args[0].__iadd__(GyroVector(OFFSET * args[0].cRot , 1)), tsArguments=("gPlayer",)))
|
||||
aoEngineEvents.append(EngineEvent(None, lambda args: args[0].__iadd__(GyroVector(args[1] * args[0].cRot , 1)), tsArguments=("gPlayer",'offset')))
|
||||
return aoEngineEvents
|
||||
|
9
main.py
9
main.py
@ -9,7 +9,7 @@ import pygame
|
||||
import pygame.freetype
|
||||
|
||||
from gyro import GyroVector, Poincare2Klein
|
||||
from constants import I, WHITE, BLACK, IROT, ROT, OFFSET
|
||||
from constants import I, WHITE, BLACK, IROT, ROT
|
||||
from draw import draw, DrawnSegment
|
||||
from alert import Alert
|
||||
from engineevents import EngineEvent, EngineEventProcessingError
|
||||
@ -36,6 +36,7 @@ def nonzerocap(n):
|
||||
|
||||
|
||||
def mainLoop():
|
||||
offset = 0.0078125
|
||||
sky = (127,127,255)
|
||||
ground = (102, 51, 0)
|
||||
bCap = True
|
||||
@ -74,6 +75,7 @@ def mainLoop():
|
||||
nonlocal sky
|
||||
nonlocal ground
|
||||
nonlocal iDistScale
|
||||
nonlocal offset
|
||||
state = {
|
||||
'bCap': bCap,
|
||||
'bCont': bCont,
|
||||
@ -88,7 +90,8 @@ def mainLoop():
|
||||
'level': level,
|
||||
'sky': sky,
|
||||
'ground': ground,
|
||||
'iDistScale': iDistScale
|
||||
'iDistScale': iDistScale,
|
||||
'offset': offset
|
||||
}
|
||||
for i in aoEngineEvents:
|
||||
if i.sVariableToModify == "bCap":
|
||||
@ -113,6 +116,8 @@ def mainLoop():
|
||||
level = i.fLambda(list(map(lambda oX: state[oX], i.tsArguments)))
|
||||
elif i.sVariableToModify == "iDistScale":
|
||||
iDistScale = i.fLambda(list(map(lambda oX: state[oX], i.tsArguments)))
|
||||
elif i.sVariableToModify == "offset":
|
||||
offset = i.fLambda(list(map(lambda oX: state[oX], i.tsArguments)))
|
||||
elif i.sVariableToModify is None:
|
||||
i.fLambda(list(map(lambda oX: state[oX], i.tsArguments)))
|
||||
else:
|
||||
|
Loading…
Reference in New Issue
Block a user