mirror of
https://forge.apps.education.fr/blender-edutech/ropy.git
synced 2024-01-27 08:23:20 +01:00
Bugfix : Séparation claire entre la fin de cycle provoquée (kill) et la fin de cycle naturelle (closed), passage de la fin de cycle par bge
This commit is contained in:
parent
a30cd1d029
commit
25b3fa3d61
BIN
ropy-07.blend
BIN
ropy-07.blend
Binary file not shown.
63
rp.py
63
rp.py
@ -176,19 +176,12 @@ def terrain_run ():
|
||||
scene.objects['Run'].suspendPhysics()
|
||||
scene.objects['Run-Hl'].setVisible(False,False)
|
||||
scene.objects['Pause']. restorePhysics()
|
||||
scene.objects['Pause-Hl'].setVisible(True,False)
|
||||
scene.objects['Pause'].setVisible(True,False)
|
||||
|
||||
# Démarrage de la map
|
||||
if scene.objects['Terrain']['thread_run']==False:
|
||||
scene.objects['Stop'].setVisible(True,False)
|
||||
scene.objects['Stop']. restorePhysics()
|
||||
runpy.run_module('rp_cmd', run_name='stop') # Stop du script utilisateur
|
||||
|
||||
# Mise à zéro des compteurs
|
||||
rp_map.map_reset()
|
||||
|
||||
# Scripts utilisateur et vagues
|
||||
scene.objects['Terrain']['thread_run']=True
|
||||
if scene.objects['Terrain']['thread_cmd']==False:
|
||||
scene.objects['Terrain']['thread_cmd']=True
|
||||
rp_map.map_reset() # Mise à zéro des compteurs
|
||||
runpy.run_module('rp_cmd', run_name='start') # Execution du script utilisateur
|
||||
|
||||
# Arrêt de la pause
|
||||
@ -197,15 +190,20 @@ def terrain_run ():
|
||||
pass
|
||||
|
||||
##
|
||||
# Arrêt et réinitialisation du cycle
|
||||
# Arrêt et réinitialisation du cycle (forçage)
|
||||
##
|
||||
|
||||
def terrain_stop ():
|
||||
scene.objects['Terrain']['thread_cmd']=False
|
||||
|
||||
# Arrêt des threads utilisateurs
|
||||
##
|
||||
# Fin naturelle du cycle
|
||||
##
|
||||
|
||||
def terrain_end (cont):
|
||||
if cont.sensors['End cycle'].positive:
|
||||
scene.objects['Terrain']['run']=False
|
||||
scene.objects['Terrain']['thread_run']=False
|
||||
runpy.run_module('rp_cmd', run_name='stop') # Stop du script utilisateur
|
||||
runpy.run_module('rp_cmd', run_name='stop') # Fin du script utilisateur
|
||||
|
||||
# Commandes
|
||||
scene.objects['Pause'].setVisible(False,False)
|
||||
@ -213,25 +211,6 @@ def terrain_stop ():
|
||||
scene.objects['Pause-Hl'].setVisible(False,False)
|
||||
scene.objects['Run'].setVisible(True,False)
|
||||
scene.objects['Run']. restorePhysics()
|
||||
scene.objects['Stop'].setVisible(False,False)
|
||||
scene.objects['Stop'].suspendPhysics()
|
||||
scene.objects['Stop-Hl'].setVisible(False,False)
|
||||
scene.objects['Cmd-text'].setVisible(False,False)
|
||||
|
||||
##
|
||||
# Fin de la map
|
||||
##
|
||||
|
||||
def terrain_end ():
|
||||
scene.objects['Terrain']['run']=False
|
||||
scene.objects['Terrain']['thread_run']=False
|
||||
|
||||
# Commandes
|
||||
scene.objects['Pause'].setVisible(False,False)
|
||||
scene.objects['Pause-Hl'].setVisible(False,False)
|
||||
scene.objects['Run'].setVisible(True,False)
|
||||
scene.objects['Stop'].setVisible(False,False)
|
||||
scene.objects['Stop-Hl'].setVisible(False,False)
|
||||
|
||||
##
|
||||
# Vitesse du jeu
|
||||
@ -340,8 +319,6 @@ def cmd_init():
|
||||
scene.objects['Pause'].setVisible(False,False)
|
||||
scene.objects['Pause'].suspendPhysics()
|
||||
scene.objects['Pause-Hl'].setVisible(False,False)
|
||||
scene.objects['Stop'].setVisible(False,False)
|
||||
scene.objects['Stop'].suspendPhysics()
|
||||
scene.objects['Stop-Hl'].setVisible(False,False)
|
||||
scene.objects['Objective-Hl'].setVisible(False,False)
|
||||
scene.objects['Doc-cmd-Hl'].setVisible(False,False)
|
||||
@ -426,7 +403,6 @@ def cmd_hl(cont):
|
||||
|
||||
# Stop
|
||||
if obj.name=="Stop":
|
||||
if scene.objects['Terrain']['thread_run']==True:
|
||||
scene.objects['Stop'].setVisible(False,False)
|
||||
scene.objects['Stop-Hl'].setVisible(True,False)
|
||||
|
||||
@ -475,7 +451,6 @@ def cmd_hl(cont):
|
||||
|
||||
# Stop
|
||||
if obj.name=="Stop":
|
||||
if scene.objects['Terrain']['thread_run']==True:
|
||||
scene.objects['Stop-Hl'].setVisible(False,False)
|
||||
scene.objects['Stop'].setVisible(True,False)
|
||||
|
||||
@ -506,9 +481,11 @@ def cmd_click (cont):
|
||||
if obj.name=="Objective":
|
||||
sound_play (snd_grid)
|
||||
terrain_grid ()
|
||||
|
||||
if obj.name=="Speed_up" or obj.name=="Speed_down":
|
||||
sound_play (snd_click)
|
||||
terrain_speed (obj)
|
||||
|
||||
if obj.name=="ResetView":
|
||||
sound_play (snd_click)
|
||||
manip_reset()
|
||||
@ -517,6 +494,7 @@ def cmd_click (cont):
|
||||
if obj.name=="NoSound-cmd":
|
||||
sound_set ()
|
||||
sound_play (snd_click)
|
||||
|
||||
if obj.name=="Doc-cmd":
|
||||
sound_play (snd_open)
|
||||
tablet_open ()
|
||||
@ -604,8 +582,9 @@ def mode(cont):
|
||||
|
||||
# Touche F6 -> Stop / Init
|
||||
if JUST_ACTIVATED in keyboard.inputs[bge.events.F6KEY].queue:
|
||||
if scene.objects['Terrain']['thread_run']==True:
|
||||
terrain_stop ()
|
||||
# if scene.objects['Terrain']['thread_cmd']==True: # FIXME : bien utile ?
|
||||
# terrain_stop ()
|
||||
|
||||
# Touche +/- du pad -> Vitesse + ou /
|
||||
if JUST_ACTIVATED in keyboard.inputs[bge.events.PADPLUSKEY].queue:
|
||||
@ -711,7 +690,6 @@ def manip(cont):
|
||||
# distance_cam_past= math.sqrt(scene.objects['Camera']['past_ly']**2+scene.objects['Camera']['past_lz']**2)
|
||||
# distance_cam = math.sqrt((scene.objects['Camera'].worldPosition.y**2+scene.objects['Camera'].worldPosition.z**2))
|
||||
# size_scale = (distance_cam/distance_cam_past) * 0.23
|
||||
print ("scene.objects['Camera']", scene.objects['Camera'].worldPosition.x, scene.objects['Camera'].worldPosition.y, scene.objects['Camera'].worldPosition.z)
|
||||
if scene.objects['Camera'].worldPosition.z >0.5 and scene.objects['Camera'].worldPosition.z <57:
|
||||
scene.objects['Camera'].applyMovement((0, 0, (delta_x+delta_y)*sensibilite_zoom), True)
|
||||
if scene.objects['Camera'].worldPosition.z <=0.5 or scene.objects['Camera'].worldPosition.z >=57 :
|
||||
@ -740,7 +718,6 @@ def manip_wheel(cont):
|
||||
# # size_scale = (distance_cam/distance_cam_past) * 0.23
|
||||
# size_scale = 0.2
|
||||
# # size_scale = 0.23
|
||||
print ("scene.objects['Camera']", scene.objects['Camera'].worldPosition.x, scene.objects['Camera'].worldPosition.y, scene.objects['Camera'].worldPosition.z)
|
||||
if cont.sensors['WheelUp'].positive :
|
||||
scene.objects['Camera'].applyMovement((0, 0, -sensibilite_wheel), True)
|
||||
# if scene.objects['Mouse_main']['mouse_graphic']:
|
||||
@ -880,8 +857,8 @@ def tablet_close ():
|
||||
scene.objects['Pause'].setVisible(False,False)
|
||||
scene.objects['Pause'].suspendPhysics()
|
||||
scene.objects['Pause-Hl'].setVisible(False,False)
|
||||
scene.objects['Stop'].setVisible(False,False)
|
||||
scene.objects['Stop'].suspendPhysics()
|
||||
# scene.objects['Stop'].setVisible(False,False)
|
||||
# scene.objects['Stop'].suspendPhysics()
|
||||
scene.objects['Stop-Hl'].setVisible(False,False)
|
||||
scene.objects['Objective-Hl'].setVisible(False,False)
|
||||
scene.objects['Doc-cmd-Hl'].setVisible(False,False)
|
||||
|
28
rp_cmd.py
28
rp_cmd.py
@ -7,25 +7,6 @@ from rp_lib import * # Bibliothèque Ropy
|
||||
# @project: Ropy (Blender-EduTech)
|
||||
###############################################################################
|
||||
|
||||
###############################################################################
|
||||
# En: Threads management << DONT CHANGE THIS SECTION >>
|
||||
# Fr: Gestion des tâches (threads) << NE PAS MODIFIER CETTE SECTION >>
|
||||
###############################################################################
|
||||
|
||||
scene = bge.logic.getCurrentScene()
|
||||
|
||||
def start():
|
||||
scene.objects['Terrain']['thread_cmd']=True
|
||||
thread_cmd_start(commands)
|
||||
|
||||
def stop():
|
||||
thread_cmd_stop()
|
||||
|
||||
def end():
|
||||
rp_sleep (2)
|
||||
print ("Thread commands is arrived.")
|
||||
scene.objects['Terrain']['thread_cmd']=False
|
||||
|
||||
###############################################################################
|
||||
# Fonctions
|
||||
###############################################################################
|
||||
@ -38,10 +19,13 @@ def end():
|
||||
def commands():
|
||||
|
||||
print("Go !!")
|
||||
rp_sleep (0.5)
|
||||
rp_gauche()
|
||||
rp_sleep (0.5)
|
||||
rp_avancer()
|
||||
|
||||
end()
|
||||
rp_sleep (2)
|
||||
rp_fin()
|
||||
|
||||
###############################################################################
|
||||
# En: Externals calls << DONT CHANGE THIS SECTION >>
|
||||
@ -49,7 +33,7 @@ def commands():
|
||||
###############################################################################
|
||||
|
||||
if __name__=='start':
|
||||
start()
|
||||
thread_cmd_start(commands)
|
||||
if __name__=='stop':
|
||||
stop()
|
||||
thread_cmd_stop()
|
||||
|
||||
|
@ -1,11 +1,11 @@
|
||||
<data>
|
||||
<config>
|
||||
<speed>10.0</speed>
|
||||
<speed>0.25</speed>
|
||||
<sound>True</sound>
|
||||
<cam>
|
||||
<worldPosition.x>-4.190211772918701</worldPosition.x>
|
||||
<worldPosition.y>-12.807374954223633</worldPosition.y>
|
||||
<worldPosition.z>12.73536491394043</worldPosition.z>
|
||||
<worldPosition.x>0.0057830810546875</worldPosition.x>
|
||||
<worldPosition.y>-26.440298080444336</worldPosition.y>
|
||||
<worldPosition.z>20.22315788269043</worldPosition.z>
|
||||
</cam>
|
||||
</config>
|
||||
<mission>
|
||||
|
14
rp_lib.py
14
rp_lib.py
@ -1,4 +1,4 @@
|
||||
import bge # Blender Game Engine (UPBGE)
|
||||
+import bge # Blender Game Engine (UPBGE)
|
||||
import aud # Sounds
|
||||
import threading # Multithreading
|
||||
import trace
|
||||
@ -129,6 +129,7 @@ def thread_stop(threads, type_txt):
|
||||
i +=1
|
||||
if zombie_flag==False:
|
||||
print ("All threads",type_txt, "are closed.")
|
||||
scene.objects['Terrain']['thread_cmd']=False
|
||||
return True
|
||||
else:
|
||||
print ("There are zombies threads",type_txt, ".")
|
||||
@ -140,6 +141,17 @@ def thread_cmd_start(fct):
|
||||
def thread_cmd_stop():
|
||||
thread_stop(threads_cmd, "commands")
|
||||
|
||||
def rp_end():
|
||||
rp_sleep (0.5)
|
||||
print ("Thread commands is arrived.")
|
||||
scene.objects['Terrain']['thread_cmd']=False
|
||||
|
||||
def rp_fin():
|
||||
rp_end()
|
||||
|
||||
def rp_quit():
|
||||
rp_end()
|
||||
|
||||
###############################################################################
|
||||
# Sounds
|
||||
###############################################################################
|
||||
|
Loading…
x
Reference in New Issue
Block a user