Ajout des ressorts

This commit is contained in:
Philippe Roy 2023-07-20 22:44:24 +02:00
parent 24310fda4c
commit ec9c006599
3 changed files with 28 additions and 4 deletions

Binary file not shown.

BIN
fop-05.blend Normal file

Binary file not shown.

32
fop.py
View File

@ -99,17 +99,18 @@ def clavier(cont):
# Saut sur les téléporte (mode debug) : avancer
if JUST_ACTIVATED in keyboard.inputs[bge.events.ZKEY].queue and obj['spawn']<8:
obj['spawn'] +=1
print ("Saut sur les téléporte :", obj['spawn'])
obj_spawn = scene.objects['Spawn '+str(obj['spawn'])]
print (obj_spawn['sens'])
obj.worldPosition = obj_spawn.worldPosition
obj.applyRotation((0, 0, -obj.worldOrientation.to_euler().z+math.pi), False)
obj.applyRotation((0, 0, -obj.worldOrientation.to_euler().z+obj_spawn['sens']), False)
# Saut sur les téléporte (mode debug) : reculer
# Saut sur les téléportes(mode debug) : reculer
if JUST_ACTIVATED in keyboard.inputs[bge.events.AKEY].queue and obj['spawn']>0:
obj['spawn'] -=1
print ("Saut sur les téléporte :", obj['spawn'])
obj_spawn = scene.objects['Spawn '+str(obj['spawn'])]
print (obj_spawn['sens'])
obj.worldPosition = obj_spawn.worldPosition
obj.applyRotation((0, 0, -obj.worldOrientation.to_euler().z+obj_spawn['sens']), False)
###
# Suivi par la caméra
@ -144,6 +145,13 @@ def init(cont):
for i in range (1, 7):
scene.objects['Pancarte '+str(i)].setVisible(False,True)
# Animation plateforme
start = 1
end = 200
mode = bge.logic.KX_ACTION_MODE_LOOP
speed = 0.5
scene.objects['Platforme'].playAction('Platforme-action', start, end, 0, 1, 1.0, mode, 0.0, 0, speed)
# Chute
def chute(cont):
obj = cont.owner
@ -161,6 +169,22 @@ def checkpoint(cont):
obj_frankie['spawn']=obj_i
scene.objects['Pancarte '+str(obj_i)].setVisible(True,True)
# Ressort
def ressort(cont):
obj = cont.owner
sensor = obj.sensors['Collision']
force_saut = 1000
obj_ressort=scene.objects[obj.name[:-7]]
obj_frankie = scene.objects['Frankie']
if sensor.positive:
start = 1,
end = 16,
mode = bge.logic.KX_ACTION_MODE_PLAY,
speed = 0.5
obj_ressort.playAction(obj_ressort.name+'-action', start, end, 0, 1, 1.0, mode, 0.0, 0, speed)
obj_frankie.applyForce((0, 0,force_saut), True)
###############################################################################
# Gestion du Joystick (Joystick USB)
###############################################################################