mirror of
https://forge.apps.education.fr/phroy/frankie-on-platform.git
synced 2024-01-27 11:32:04 +01:00
Déplacement de Frankie : clavier et spawn
This commit is contained in:
parent
8ee3c0592a
commit
ae67cbbfea
BIN
fop-04.blend
BIN
fop-04.blend
Binary file not shown.
133
fop.py
133
fop.py
@ -1,5 +1,6 @@
|
||||
import bge # Bibliothèque Blender Game Engine (UPBGE)
|
||||
import bpy # Blender
|
||||
import math
|
||||
|
||||
###############################################################################
|
||||
# fop.py
|
||||
@ -58,7 +59,7 @@ def clavier(cont):
|
||||
# Tourner gauche : Flèche gauche - Left arrow
|
||||
if keyboard.inputs[bge.events.LEFTARROWKEY].status[0] == ACTIVATE:
|
||||
if obj_cam['fps']:
|
||||
obj.applyRotation((0, 0,pas_angulaire_pfs), True)
|
||||
obj.applyRotation((0, 0,pas_angulaire_fps), True)
|
||||
else:
|
||||
obj.applyRotation((0, 0,pas_angulaire), True)
|
||||
|
||||
@ -78,6 +79,15 @@ def clavier(cont):
|
||||
obj.applyForce((0, 0,force_saut), True)
|
||||
break
|
||||
|
||||
# Caméra FPS
|
||||
if JUST_ACTIVATED in keyboard.inputs[bge.events.FKEY].queue:
|
||||
if obj_cam['fps']==False:
|
||||
scene.active_camera = scene.objects["Camera_fps"]
|
||||
obj_cam['fps'] = True
|
||||
else:
|
||||
scene.active_camera = scene.objects["Camera"]
|
||||
obj_cam['fps'] = False
|
||||
|
||||
# Recul caméra
|
||||
if keyboard.inputs[bge.events.EKEY].status[0] == ACTIVATE and obj_cam['macro']==False:
|
||||
obj_cam.applyMovement((0,0,recul_camera), True)
|
||||
@ -86,28 +96,27 @@ def clavier(cont):
|
||||
obj_cam.applyMovement((0,0,-recul_camera), True)
|
||||
obj_cam['macro'] = False
|
||||
|
||||
# Caméra FPS
|
||||
if keyboard.inputs[bge.events.FKEY].status[0] == ACTIVATE and obj_cam['fps']==False and obj_cam['relache']==True:
|
||||
scene.active_camera = scene.objects["Camera_fps"]
|
||||
obj_cam['fps'] = True
|
||||
obj_cam['relache'] = False
|
||||
if keyboard.inputs[bge.events.FKEY].status[0] == ACTIVATE and obj_cam['fps']==True and obj_cam['relache']==True:
|
||||
scene.active_camera = scene.objects["Camera"]
|
||||
obj_cam['fps'] = False
|
||||
obj_cam['relache'] = False
|
||||
if keyboard.inputs[bge.events.FKEY].status[0] != ACTIVATE and obj_cam['relache']==False:
|
||||
obj_cam['relache'] = True
|
||||
# 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'])]
|
||||
obj.worldPosition = obj_spawn.worldPosition
|
||||
obj.applyRotation((0, 0, -obj.worldOrientation.to_euler().z+math.pi), False)
|
||||
|
||||
# Saut sur les téléporte (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'])]
|
||||
obj.worldPosition = obj_spawn.worldPosition
|
||||
|
||||
###
|
||||
# Suivi par la caméra
|
||||
###
|
||||
|
||||
def camera_track (cont):
|
||||
obj = cont.owner
|
||||
obj_frankie = scene.objects['Frankie']
|
||||
obj.worldPosition.x=obj_frankie.worldPosition.x
|
||||
obj.worldPosition.y=obj_frankie.worldPosition.y
|
||||
obj.worldPosition.z=obj_frankie.worldPosition.z
|
||||
cont.owner.worldPosition = scene.objects['Frankie'].worldPosition
|
||||
|
||||
###############################################################################
|
||||
# Cycle
|
||||
@ -131,7 +140,7 @@ def init(cont):
|
||||
eevee.shadow_cube_size='512'
|
||||
|
||||
# Pancartes
|
||||
scene.objects['Frankie']['spawn']="0"
|
||||
scene.objects['Frankie']['spawn']=0
|
||||
for i in range (1, 7):
|
||||
scene.objects['Pancarte '+str(i)].setVisible(False,True)
|
||||
|
||||
@ -140,93 +149,17 @@ def chute(cont):
|
||||
obj = cont.owner
|
||||
if obj.worldPosition.z<=-9 :
|
||||
obj_spawn = scene.objects['Spawn '+str(obj['spawn'])]
|
||||
obj_frankie.worldPosition.x = obj_spawn.worldPosition.x
|
||||
obj_frankie.worldPosition.y = obj_spawn.worldPosition.y
|
||||
obj_frankie.worldPosition.z = obj_spawn.worldPosition.z
|
||||
obj.worldPosition = obj_spawn.worldPosition
|
||||
obj.applyRotation((0, 0, -obj.worldOrientation.to_euler().z+math.pi), False)
|
||||
|
||||
# Checkpoint
|
||||
def checkpoint(cont):
|
||||
obj = cont.owner
|
||||
print (obj.name)
|
||||
obj_i=int(obj[len(obj.name)-1:])
|
||||
obj_i=int(obj.name[6:-7])
|
||||
obj_frankie = scene.objects['Frankie']
|
||||
scene.objects['Pancarte '+str(obj_i)].setVisible(True,True)
|
||||
obj_frankie['spawn']=obj_i
|
||||
|
||||
# # Mémorisation de la position de départ de la bille
|
||||
# obj['init_x']=obj.worldPosition.x
|
||||
# obj['init_y']=obj.worldPosition.y
|
||||
# obj['init_z']=obj.worldPosition.z
|
||||
|
||||
# # Cacher le panneau de la victoire et suspendre la physique du panneau cliquable
|
||||
# scene.objects['Panneau victoire'].setVisible(False,True)
|
||||
# scene.objects['Panneau victoire - plan'].suspendPhysics (True)
|
||||
# scene.objects['Bouton fermer'].color = (0, 0, 0, 1) # Noir
|
||||
|
||||
# Cycle (boucle de contrôle de la bille)
|
||||
# def cycle(cont):
|
||||
# obj = cont.owner # obj est l'objet associé au contrôleur donc 'Bille'
|
||||
# obj['z']=obj.worldPosition.z # la propriété z est mis à jour avec la position globale en z de la bille
|
||||
|
||||
# # Si l'altitude de bille < -10 et pas de victoire -> chute
|
||||
# if obj['z'] < -10 and obj['victoire'] == False:
|
||||
# print ("Chuuuu.....te")
|
||||
# depart() # Replacer la bille au départ
|
||||
|
||||
# Départ de la bille
|
||||
# def depart():
|
||||
# obj_bille = scene.objects['Bille']
|
||||
# obj_plateau = scene.objects['Plateau']
|
||||
|
||||
# # Replacement du plateau (tous les angles à 0 en plusieurs fois)
|
||||
# while obj_plateau.worldOrientation.to_euler().x != 0 and obj_plateau.worldOrientation.to_euler().y !=0 and obj_plateau.worldOrientation.to_euler().z !=0 :
|
||||
# obj_plateau.applyRotation((-obj_plateau.worldOrientation.to_euler().x, -obj_plateau.worldOrientation.to_euler().y, -obj_plateau.worldOrientation.to_euler().z), False)
|
||||
|
||||
# # Mettre la bille à la position de départ avec une vitesse nulle
|
||||
# obj_bille = scene.objects['Bille']
|
||||
# obj_bille.worldLinearVelocity=(0, 0, 0)
|
||||
# obj_bille.worldAngularVelocity=(0, 0, 0)
|
||||
# obj_bille.worldPosition.x = obj_bille['init_x']
|
||||
# obj_bille.worldPosition.y = obj_bille['init_y']
|
||||
# obj_bille.worldPosition.z = obj_bille['init_z']+0.5 # On repose la bille
|
||||
# obj_bille['victoire']=False
|
||||
# obj_bille['chute'] = False
|
||||
|
||||
# Victoire (collision de la bille avec l'arrivée)
|
||||
def victoire(cont):
|
||||
obj = cont.owner
|
||||
# scene.objects['Bille']['victoire']=True
|
||||
# scene.objects['Panneau victoire'].setVisible(True,True) # Afficher le panneau de la victoire
|
||||
# scene.objects['Panneau victoire - plan'].restorePhysics() # Restaurer la physique du panneau cliquable
|
||||
# start = 1
|
||||
# end = 100
|
||||
# layer = 0
|
||||
# priority = 1
|
||||
# blendin = 1.0
|
||||
# mode = bge.logic.KX_ACTION_MODE_PLAY
|
||||
# layerWeight = 0.0
|
||||
# ipoFlags = 0
|
||||
# speed = 1
|
||||
# scene.objects['Panneau victoire'].playAction('Panneau victoireAction', start, end, layer, priority, blendin, mode, layerWeight, ipoFlags, speed)
|
||||
|
||||
# Highlight du bouton Fermer
|
||||
# def victoire_fermer_hl(cont):
|
||||
# obj = cont.owner
|
||||
|
||||
# # Activation
|
||||
# if cont.sensors['MO'].status == JUST_ACTIVATED:
|
||||
# obj.color = (1, 1, 1, 1) # Blanc
|
||||
|
||||
# # Désactivation
|
||||
# if cont.sensors['MO'].status == JUST_RELEASED:
|
||||
# obj.color = (0, 0, 0, 1) # Noir
|
||||
|
||||
# # Fermer le panneau de la victoire (clic)
|
||||
# def victoire_fermer(cont):
|
||||
# if cont.sensors['Click'].status == JUST_ACTIVATED and cont.sensors['MO'].positive:
|
||||
# scene.objects['Panneau victoire'].setVisible(False,True) # Cacher le panneau de la victoire
|
||||
# scene.objects['Panneau victoire - plan'].suspendPhysics (True) # Suspendre la physique du panneau cliquable
|
||||
# depart() # Replacer la bille au départ
|
||||
if obj_i > obj_frankie['spawn']:
|
||||
obj_frankie['spawn']=obj_i
|
||||
scene.objects['Pancarte '+str(obj_i)].setVisible(True,True)
|
||||
|
||||
###############################################################################
|
||||
# Gestion du Joystick (Joystick USB)
|
||||
|
Loading…
Reference in New Issue
Block a user