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)
|
I = complex(0,1)
|
||||||
WHITE = (255,255,255)
|
WHITE = (255,255,255)
|
||||||
BLACK = (0,0,0)
|
BLACK = (0,0,0)
|
||||||
OFFSET = 0.0078125
|
|
||||||
ROT = cNorm(exp(deg2rad(2)*I))
|
ROT = cNorm(exp(deg2rad(2)*I))
|
||||||
IROT = 1/ROT
|
IROT = 1/ROT
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import pygame
|
import pygame
|
||||||
from engineevents import EngineEvent
|
from engineevents import EngineEvent
|
||||||
from constants import ROT, IROT, OFFSET, I
|
from constants import ROT, IROT, I
|
||||||
from gyro import GyroVector, MobiusDist
|
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
|
||||||
@ -69,11 +69,11 @@ def defaultcontrols():
|
|||||||
if keys[pygame.K_a]:
|
if keys[pygame.K_a]:
|
||||||
aoEngineEvents.append(EngineEvent(None, lambda args: args[0].rotate(IROT), tsArguments=("gPlayer",)))
|
aoEngineEvents.append(EngineEvent(None, lambda args: args[0].rotate(IROT), tsArguments=("gPlayer",)))
|
||||||
if keys[pygame.K_q]:
|
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]:
|
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]:
|
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]:
|
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
|
return aoEngineEvents
|
||||||
|
9
main.py
9
main.py
@ -9,7 +9,7 @@ import pygame
|
|||||||
import pygame.freetype
|
import pygame.freetype
|
||||||
|
|
||||||
from gyro import GyroVector, Poincare2Klein
|
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 draw import draw, DrawnSegment
|
||||||
from alert import Alert
|
from alert import Alert
|
||||||
from engineevents import EngineEvent, EngineEventProcessingError
|
from engineevents import EngineEvent, EngineEventProcessingError
|
||||||
@ -36,6 +36,7 @@ def nonzerocap(n):
|
|||||||
|
|
||||||
|
|
||||||
def mainLoop():
|
def mainLoop():
|
||||||
|
offset = 0.0078125
|
||||||
sky = (127,127,255)
|
sky = (127,127,255)
|
||||||
ground = (102, 51, 0)
|
ground = (102, 51, 0)
|
||||||
bCap = True
|
bCap = True
|
||||||
@ -74,6 +75,7 @@ def mainLoop():
|
|||||||
nonlocal sky
|
nonlocal sky
|
||||||
nonlocal ground
|
nonlocal ground
|
||||||
nonlocal iDistScale
|
nonlocal iDistScale
|
||||||
|
nonlocal offset
|
||||||
state = {
|
state = {
|
||||||
'bCap': bCap,
|
'bCap': bCap,
|
||||||
'bCont': bCont,
|
'bCont': bCont,
|
||||||
@ -88,7 +90,8 @@ def mainLoop():
|
|||||||
'level': level,
|
'level': level,
|
||||||
'sky': sky,
|
'sky': sky,
|
||||||
'ground': ground,
|
'ground': ground,
|
||||||
'iDistScale': iDistScale
|
'iDistScale': iDistScale,
|
||||||
|
'offset': offset
|
||||||
}
|
}
|
||||||
for i in aoEngineEvents:
|
for i in aoEngineEvents:
|
||||||
if i.sVariableToModify == "bCap":
|
if i.sVariableToModify == "bCap":
|
||||||
@ -113,6 +116,8 @@ def mainLoop():
|
|||||||
level = i.fLambda(list(map(lambda oX: state[oX], i.tsArguments)))
|
level = i.fLambda(list(map(lambda oX: state[oX], i.tsArguments)))
|
||||||
elif i.sVariableToModify == "iDistScale":
|
elif i.sVariableToModify == "iDistScale":
|
||||||
iDistScale = i.fLambda(list(map(lambda oX: state[oX], i.tsArguments)))
|
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:
|
elif i.sVariableToModify is None:
|
||||||
i.fLambda(list(map(lambda oX: state[oX], i.tsArguments)))
|
i.fLambda(list(map(lambda oX: state[oX], i.tsArguments)))
|
||||||
else:
|
else:
|
||||||
|
Loading…
Reference in New Issue
Block a user