diff --git a/ropy-22.blend b/ropy-22.blend
new file mode 100644
index 0000000..33b1748
Binary files /dev/null and b/ropy-22.blend differ
diff --git a/rp.py b/rp.py
index 7e98a4b..b76d5ae 100644
--- a/rp.py
+++ b/rp.py
@@ -76,6 +76,11 @@ ACTIVATE = bge.logic.KX_INPUT_ACTIVE
# User interface : texte info et compteurs
###############################################################################
+color_text = (0, 0, 0, 1) # Noir
+color_text_red = (0.799, 0.031, 0.038, 1)
+color_text_orange = (0.799, 0.176, 0.054, 1)
+color_text_yellow = (0.799, 0.617, 0.021, 1)
+
##
# Mise à jour de l'affichage des compteurs
##
@@ -85,6 +90,19 @@ def points_maj (cont):
# Step
if scene.objects['Points-Step-text']['Text']!= str(scene.objects['Points']['step']):
scene.objects['Points-Step-text']['Text']=str(scene.objects['Points']['step'])
+ if scene.objects['Points']['upgrade_battery']:
+ scene.objects['Points']['battery'] = round(100*(1 - (scene.objects['Points']['step']/200)))
+ else:
+ scene.objects['Points']['battery'] = round(100*(1 - (scene.objects['Points']['step']/20)))
+ if scene.objects['Points']['battery'] <=10:
+ scene.objects['Points-Battery'].color = color_text_red
+ scene.objects['Points-Battery-text'].color = color_text_red
+ if scene.objects['Points']['battery'] <=0:
+ scene.objects['Points-Battery-text']['Text']="0%"
+ print ("Plus de batterie !")
+ scene.objects['Rover']['stop'] = True
+ else:
+ scene.objects['Points-Battery-text']['Text']=str(scene.objects['Points']['battery'])+"%"
# Level
if scene.objects['Points-Level-text']['Text']!=str(scene.objects['Points']['level']):
@@ -103,7 +121,7 @@ def points_maj (cont):
# Position du Rover
obj=scene.objects['Rover']
- obj['position']=str(obj.worldPosition.x)+","+str(obj.worldPosition.y)+","+str(obj.worldPosition.z)
+ obj['position']=str(round(obj.worldPosition.x,3))+","+str(round(obj.worldPosition.y,3))+","+str(round(obj.worldPosition.z,3))
###############################################################################
# Terrain
@@ -180,7 +198,7 @@ def terrain_run ():
scene.objects['Pause'].setVisible(False,False)
scene.objects['Pause'].suspendPhysics()
scene.objects['Pause-Hl'].setVisible(False,False)
- scene.objects['Run']. restorePhysics()
+ scene.objects['Run'].restorePhysics()
scene.objects['Run-Hl'].setVisible(True,False)
# Run
@@ -234,7 +252,7 @@ def terrain_end (cont):
scene.objects['Pause'].suspendPhysics()
scene.objects['Pause-Hl'].setVisible(False,False)
scene.objects['Run'].setVisible(True,False)
- scene.objects['Run']. restorePhysics()
+ scene.objects['Run'].restorePhysics()
##
# Vitesse du jeu
@@ -305,7 +323,7 @@ def sound_set ():
scene.objects['NoSound-cmd'].suspendPhysics()
scene.objects['NoSound-cmd'].setVisible(False,False)
scene.objects['NoSound-cmd-Hl'].setVisible(False,False)
- scene.objects['Sound-cmd']. restorePhysics()
+ scene.objects['Sound-cmd'].restorePhysics()
scene.objects['Sound-cmd-Hl'].setVisible(True,False)
scene.objects['Commands']['sound']=True
# scene.objects['Cmd-text']['Text']= "Mute"
@@ -322,7 +340,7 @@ def sound_unset ():
scene.objects['Sound-cmd'].suspendPhysics()
scene.objects['Sound-cmd'].setVisible(False,False)
scene.objects['Sound-cmd-Hl'].setVisible(False,False)
- scene.objects['NoSound-cmd']. restorePhysics()
+ scene.objects['NoSound-cmd'].restorePhysics()
scene.objects['NoSound-cmd-Hl'].setVisible(True,False)
scene.objects['Commands']['sound']=False
# scene.objects['Cmd-text']['Text']= "Unmute"
@@ -348,7 +366,7 @@ color_cmd_hl = (0.8, 0.619, 0.021, 1) # Jaune
def cmd_init():
- # UI : Commands
+ # UI : Commands
scene.objects['Run-Hl'].setVisible(False,False)
scene.objects['Pause'].setVisible(False,False)
scene.objects['Pause'].suspendPhysics()
@@ -356,6 +374,10 @@ def cmd_init():
scene.objects['Stop-Hl'].setVisible(False,False)
scene.objects['Aim-cmd-Hl'].setVisible(False,False)
scene.objects['Doc-cmd-Hl'].setVisible(False,False)
+ scene.objects['Task-cmd-Hl'].setVisible(False,False)
+ scene.objects['Task_close-cmd'].setVisible(False,False)
+ scene.objects['Task_close-cmd'].suspendPhysics()
+ scene.objects['Task_close-cmd-Hl'].setVisible(False,False)
scene.objects['Store-cmd-Hl'].setVisible(False,False)
scene.objects['ResetView-Hl'].setVisible(False,False)
scene.objects['About-cmd-Hl'].setVisible(False,False)
@@ -420,11 +442,12 @@ def cmd_init():
upgrade_maj()
# Windows
- windows=("Doc", "Doc_chap-general", "Doc_chap-missions", "Doc_chap-rover", "Doc_chap-python", "About")
+ windows=("Doc", "Doc_chap-general", "Doc_chap-missions", "Doc_chap-rover", "Doc_chap-python", "About", "Task")
for window in windows:
scene.objects[window].setVisible(False,True)
rp_doc.init()
rp_store.init()
+ scene.objects['Task'].worldPosition = [42.6047, -2.09252, 2.99685] # Panel task
##
# Highlight des commandes
@@ -461,6 +484,8 @@ def cmd_hl(cont):
"Aim-cmd":"Afficher/cacher l'objectif",
"Doc-cmd":"Documentation",
"Store-cmd":"Magasin",
+ "Task-cmd":"Liste des tâches",
+ "Task_close-cmd":"Fermer la liste des tâches",
"ResetView": "Reset de la vue (Touche Début)",
"About-cmd": "A propos",
"Speed_down": "Moins vite (-)",
@@ -485,7 +510,7 @@ def cmd_hl(cont):
if cont.sensors['MO'].status == JUST_RELEASED and (scene.objects['Terrain']['manip_mode']==0 or scene.objects['Terrain']['manip_mode']==9):
scene.objects['Cmd-text']['Text']= ""
scene.objects['Cmd-text'].setVisible(False,False)
- if obj.name!="Run" and obj.name!="Pause" and obj.name!="Stop" and obj.name!="Sound-cmd" and obj.name!="NoSound-cmd" :
+ if obj.name!="Run" and obj.name!="Pause" and obj.name!="Stop" and obj.name!="Sound-cmd" and obj.name!="NoSound-cmd" and obj.name!="Task-cmd" and obj.name!="Task_close-cmd" :
scene.objects[obj.name+'-Hl'].setVisible(False,True)
obj.setVisible(True,True)
@@ -512,6 +537,20 @@ def cmd_hl(cont):
scene.objects['Sound-cmd-Hl'].setVisible(False,False)
scene.objects['Sound-cmd'].setVisible(True,False)
+ # Task panel
+ if obj.name=="Task-cmd":
+ scene.objects['Task-cmd-Hl'].setVisible(False,True)
+ if scene.objects['Commands']['task']:
+ scene.objects['Task-cmd'].setVisible(False,True)
+ else:
+ scene.objects['Task-cmd'].setVisible(True,False)
+ if obj.name=="Task_close-cmd":
+ scene.objects['Task_close-cmd-Hl'].setVisible(False,True)
+ if scene.objects['Commands']['task']==False:
+ scene.objects['Task_close-cmd'].setVisible(False,True)
+ else:
+ scene.objects['Task_close-cmd'].setVisible(True,False)
+
##
# Click sur les commandes
##
@@ -554,7 +593,11 @@ def cmd_click (cont):
if obj.name=="Store-cmd":
sound_play (snd_open)
store_open ()
-
+ if obj.name=="Task-cmd":
+ sound_play (snd_open)
+ task_open ()
+ if obj.name=="Task_close-cmd":
+ task_close ()
###############################################################################
# Gestion du clavier
@@ -576,11 +619,19 @@ def mode(cont):
# Touche ESC
if JUST_ACTIVATED in keyboard.inputs[bge.events.ESCKEY].queue:
+
# Fenêtres modales
- if scene.objects['Terrain']['manip_mode']==9:
+ if scene.objects['Terrain']['manip_mode']==9: # About
if scene.objects['About'].visible:
about_close()
- return
+ return
+ elif scene.objects['Terrain']['manip_mode']==8: # Doc et store
+ if scene.objects['Doc'].visible:
+ tablet_close()
+ return
+ if scene.objects['Store'].visible:
+ store_close()
+ return
else: # Sortir du jeu
terrain_stop ()
@@ -944,6 +995,22 @@ def tablet_close ():
scene.objects['Speed_down-Hl'].setVisible(False,False)
scene.objects['Cmd-text'].setVisible(False,False)
+ # Task panel
+ if scene.objects['Commands']['task']:
+ scene.objects['Task-cmd'].setVisible(False,True)
+ scene.objects['Task-cmd'].suspendPhysics()
+ scene.objects['Task-cmd-Hl'].setVisible(False,True)
+ scene.objects['Task_close-cmd'].setVisible(True,True)
+ scene.objects['Task_close-cmd'].restorePhysics()
+ scene.objects['Task_close-cmd-Hl'].setVisible(False,True)
+ else:
+ scene.objects['Task_close-cmd'].setVisible(False,True)
+ scene.objects['Task_close-cmd'].suspendPhysics()
+ scene.objects['Task_close-cmd-Hl'].setVisible(False,True)
+ scene.objects['Task-cmd'].setVisible(True,True)
+ scene.objects['Task-cmd'].restorePhysics()
+ scene.objects['Task-cmd-Hl'].setVisible(False,True)
+
# Camera
scene.objects['Camera'].worldPosition.x = scene.objects['Camera']['current_lx']
scene.objects['Camera'].worldPosition.y = scene.objects['Camera']['current_ly']
@@ -952,6 +1019,7 @@ def tablet_close ():
# Reset si changement de mission
if scene.objects['Points']['mission_init']!= scene.objects['Points']['mission']:
terrain_stop ()
+ rp_map.task()
if scene.objects['Grid-u'].visible:
rp_map.aim_show()
scene.objects['Points']['mission_init'] = scene.objects['Points']['mission']
@@ -965,6 +1033,96 @@ def tablet_close_click(cont):
sound_play (snd_close)
tablet_close()
+###############################################################################
+# Liste des tâches
+###############################################################################
+
+##
+# Allumer la tablette des tâches
+##
+
+def task_open ():
+ scene.objects['Commands']['task']=True
+ scene.objects['Task-cmd'].setVisible(False,True)
+ scene.objects['Task-cmd'].suspendPhysics()
+ scene.objects['Task-cmd-Hl'].setVisible(False,True)
+ scene.objects['Task'].setVisible(True,True)
+ scene.objects['Task']['timer'] = 0
+ scene.objects['Task']['anim_open'] = True
+ rp_map.task()
+
+def task_open_anim():
+ x0_cam=0.005783
+ y0_cam=-26.4403
+ z0_cam=20.2232
+ x_cam=scene.objects['Camera'].worldPosition.x
+ y_cam=scene.objects['Camera'].worldPosition.y
+ z_cam=scene.objects['Camera'].worldPosition.z
+ resol=50
+ x0=0.291678-x0_cam+x_cam
+ y0 =-25.9416-y0_cam+y_cam
+ z0 = 19.793-z0_cam+z_cam
+ x1 = 0.201271-x0_cam+x_cam
+ y1 =-25.9416-y0_cam+y_cam
+ z1 = 19.793-z0_cam+z_cam
+ xi = x0+((x1-x0)/resol)*scene.objects['Task']['timer']
+ yi = y0+((y1-y0)/resol)*scene.objects['Task']['timer']
+ zi = z0+((z1-z0)/resol)*scene.objects['Task']['timer']
+ scene.objects['Task'].worldPosition = [xi, yi, zi]
+ scene.objects['Task']['timer']+=1
+ if scene.objects['Task']['timer']== resol:
+ scene.objects['Task']['anim_open'] = False
+ scene.objects['Task_close-cmd'].setVisible(True,True)
+ scene.objects['Task_close-cmd-Hl'].setVisible(False,True)
+ scene.objects['Task_close-cmd'].restorePhysics()
+
+##
+# Allumer la tablette des tâches
+##
+
+def task_close ():
+ scene.objects['Commands']['task']=False
+ scene.objects['Task_close-cmd'].setVisible(False,True)
+ scene.objects['Task_close-cmd'].suspendPhysics()
+ scene.objects['Task_close-cmd-Hl'].setVisible(False,True)
+ scene.objects['Task']['timer'] = 0
+ scene.objects['Task']['anim_close'] = True
+
+def task_close_anim():
+ x0_cam=0.005783
+ y0_cam=-26.4403
+ z0_cam=20.2232
+ x_cam=scene.objects['Camera'].worldPosition.x
+ y_cam=scene.objects['Camera'].worldPosition.y
+ z_cam=scene.objects['Camera'].worldPosition.z
+ resol=50
+ x0 = 0.201271-x0_cam+x_cam
+ y0 =-25.9416-y0_cam+y_cam
+ z0 = 19.793-z0_cam+z_cam
+ x1=0.291678-x0_cam+x_cam
+ y1 =-25.9416-y0_cam+y_cam
+ z1 = 19.793-z0_cam+z_cam
+ xi = x0+((x1-x0)/resol)*scene.objects['Task']['timer']
+ yi = y0+((y1-y0)/resol)*scene.objects['Task']['timer']
+ zi = z0+((z1-z0)/resol)*scene.objects['Task']['timer']
+ scene.objects['Task'].worldPosition = [xi, yi, zi]
+ scene.objects['Task']['timer']+=1
+ if scene.objects['Task']['timer']== resol:
+ scene.objects['Task']['anim_close'] = False
+ scene.objects['Task'].setVisible(False,True)
+ scene.objects['Task-cmd'].setVisible(True,True)
+ scene.objects['Task-cmd-Hl'].setVisible(False,True)
+ scene.objects['Task-cmd'].restorePhysics()
+
+##
+# Clic pour fermer la tablette des tâches
+##
+
+def task_close_click(cont):
+ if cont.sensors['Click'].status == JUST_ACTIVATED and cont.sensors['MO'].positive :
+ sound_play (snd_close)
+ task_close()
+
###############################################################################
# Store
###############################################################################
@@ -1028,8 +1186,6 @@ def store_open ():
terrain_grid()
else:
scene.objects['Store']['Grid_visible'] = False
-
-
rp_store.open()
##
@@ -1074,6 +1230,23 @@ def store_close():
scene.objects['Speed_down-Hl'].setVisible(False,False)
scene.objects['Cmd-text'].setVisible(False,False)
+ # Task panel
+ if scene.objects['Commands']['task']:
+ scene.objects['Task-cmd'].setVisible(False,True)
+ scene.objects['Task-cmd'].suspendPhysics()
+ scene.objects['Task-cmd-Hl'].setVisible(False,True)
+ scene.objects['Task_close-cmd'].setVisible(True,True)
+ scene.objects['Task_close-cmd'].restorePhysics()
+ scene.objects['Task_close-cmd-Hl'].setVisible(False,True)
+ else:
+ scene.objects['Task_close-cmd'].setVisible(False,True)
+ scene.objects['Task_close-cmd'].suspendPhysics()
+ scene.objects['Task_close-cmd-Hl'].setVisible(False,True)
+ scene.objects['Task-cmd'].setVisible(True,True)
+ scene.objects['Task-cmd'].restorePhysics()
+ scene.objects['Task-cmd-Hl'].setVisible(False,True)
+
+
# Maj de l'interface
upgrade_maj()
diff --git a/rp_cmd.py b/rp_cmd.py
index 2d43c83..c48d997 100644
--- a/rp_cmd.py
+++ b/rp_cmd.py
@@ -25,6 +25,8 @@ def mrp_avancer():
if rp_detect()==False:
rp_avancer()
rp_marquer()
+ print ("Nb de balises posées : ", str(rp_balise()))
+ print ("Niveau batterie : ", str(rp_batterie()))
def mrp_avancer_nbpas(pas):
for i in range (pas):
@@ -45,12 +47,10 @@ def commandes():
# mrp_avancer_mur()
# rp_gauche()
- # mrp_avancer()
- # rp_gauche()
- # mrp_avancer()
-
+ # rp_vitesse (8)
mrp_avancer_mur()
rp_gauche()
+ # rp_vitesse (1)
mrp_avancer_mur()
rp_fin()
diff --git a/rp_config.xml b/rp_config.xml
index 7f21185..67202c9 100644
--- a/rp_config.xml
+++ b/rp_config.xml
@@ -3,9 +3,9 @@
4.0
False
- -1.3732191324234009
- -44.52867889404297
- 36.26533126831055
+ 0.0057830810546875
+ -26.440298080444336
+ 20.22315788269043
@@ -15,7 +15,7 @@
True
True
- False
+ True
True
\ No newline at end of file
diff --git a/rp_doc.py b/rp_doc.py
index 619fecf..269064f 100644
--- a/rp_doc.py
+++ b/rp_doc.py
@@ -43,7 +43,7 @@ missions_card=rp_map1.get_missions_card()
################################################################################
rover_card=["avancer-card", "tourner-card", "baliser-card", "detecter-card", "radar-card"]
-rover_card=rover_card+["vitesse-card", "peinture-card", "batterie-card", "balise-card"]
+rover_card=rover_card+["speed-card", "paint-card", "battery-card", "beacon-card"]
# Avancer
rp_avancer_title="Avancer"
@@ -76,29 +76,29 @@ rp_radar_text="FIXME"
rp_radar_type="standard"
card_description.update({"radar-card" : [rp_radar_title, rp_radar_text, rp_radar_type]})
-# Vitesse
-rp_vitesse_title="Vitesse"
-rp_vitesse_text="FIXME"
-rp_vitesse_type="upgrade"
-card_description.update({"vitesse-card" : [rp_vitesse_title, rp_vitesse_text, rp_vitesse_type]})
+# Speed - Vitesse
+rp_speed_title="Vitesse"
+rp_speed_text="FIXME"
+rp_speed_type="upgrade"
+card_description.update({"speed-card" : [rp_speed_title, rp_speed_text, rp_speed_type]})
-# Peinture
-rp_peinture_title="Peinture"
-rp_peinture_text="FIXME"
-rp_peinture_type="upgrade"
-card_description.update({"peinture-card" : [rp_peinture_title, rp_peinture_text, rp_peinture_type]})
+# Paint - Peinture
+rp_paint_title="Peinture"
+rp_paint_text="FIXME"
+rp_paint_type="upgrade"
+card_description.update({"paint-card" : [rp_paint_title, rp_paint_text, rp_paint_type]})
-# Batterie +
-rp_batterie_title="Batterie +"
-rp_batterie_text="FIXME"
-rp_batterie_type="upgrade"
-card_description.update({"batterie-card" : [rp_batterie_title, rp_batterie_text, rp_batterie_type]})
+# Battery + - Batterie +
+rp_battery_title="Batterie +"
+rp_battery_text="FIXME"
+rp_battery_type="upgrade"
+card_description.update({"battery-card" : [rp_battery_title, rp_battery_text, rp_battery_type]})
-# Balise +
-rp_balise_title="Balise +"
-rp_balise_text="FIXME"
-rp_balise_type="upgrade"
-card_description.update({"balise-card" : [rp_balise_title, rp_balise_text, rp_balise_type]})
+# Beacon + - Balise +
+rp_beacon_title="Balise +"
+rp_beacon_text="FIXME"
+rp_beacon_type="upgrade"
+card_description.update({"beacon-card" : [rp_beacon_title, rp_beacon_text, rp_beacon_type]})
###############################################################################
# Documentation Python
@@ -111,7 +111,7 @@ python_card=["fonction-card", "alternative-card", "boucle-card"]
rp_fonction_title="Fonction"
rp_fonction_text=" La définition d'une fonction se fait \n avec \"def\". La fonction peut \n renvoyer une valeur avec \"return\". \n \n"
rp_fonction_text=rp_fonction_text + " def fonction_1 (arguments) : \n instruction_1 \n instruction_2 \n ....\n return valeurs_renvoyées \n\n"
-rp_fonction_text=rp_fonction_text + " Les arguments sont des données \n transmisent à la fonction."
+rp_fonction_text=rp_fonction_text + " Les arguments sont des données \n transmises à la fonction."
card_description.update({"fonction-card" : [rp_fonction_title, rp_fonction_text]})
# Alternative
@@ -223,6 +223,17 @@ def open():
else:
scene.objects['Book_level_button'].setVisible(False,True)
+ # Upgrade
+ if name_chap == "rover":
+ upgrade_card=("battery", "beacon", "paint", "speed")
+ for i in range(len(upgrade_card)):
+ if scene.objects['Points']['upgrade_'+upgrade_card[i]]==True:
+ scene.objects[upgrade_card[i]+'-card'].setVisible(True,True)
+ scene.objects[upgrade_card[i]+'-card_colbox'].restorePhysics()
+ else:
+ scene.objects[upgrade_card[i]+'-card'].setVisible(False,True)
+ scene.objects[upgrade_card[i]+'-card_colbox'].suspendPhysics()
+
# Afficher le texte de la carte active
if name_chap != "general":
if scene.objects['Doc_chap-'+name_chap]['page_fct'] !="":
@@ -361,6 +372,17 @@ def chapter(cont):
else:
scene.objects['Book_level_button'].setVisible(False,True)
+ # Upgrade
+ if name_chap == "rover":
+ upgrade_card=("battery", "beacon", "paint", "speed")
+ for i in range(len(upgrade_card)):
+ if scene.objects['Points']['upgrade_'+upgrade_card[i]]==True:
+ scene.objects[upgrade_card[i]+'-card'].setVisible(True,True)
+ scene.objects[upgrade_card[i]+'-card-colbox'].restorePhysics()
+ else:
+ scene.objects[upgrade_card[i]+'-card'].setVisible(False,True)
+ scene.objects[upgrade_card[i]+'-card-colbox'].suspendPhysics()
+
# Afficher le texte de la carte active
if name_chap != "general":
if scene.objects['Doc_chap-'+name_chap]['page_fct'] !="":
@@ -435,7 +457,6 @@ def level_button (cont):
scene.objects["mission_"+str(scene.objects['Points']['mission'])+"-card"].color = color_doc_fct
scene.objects["mission_"+str(scene.objects['Points']['mission'])+"-card-icon"].color = color_doc_fct
scene.objects["mission_"+str(scene.objects['Points']['mission'])+"-card-text"].color = color_doc_fct
- print ("Sélectionner le niveau :", str(mission_select))
scene.objects['Points']['mission'] = mission_select
scene.objects['Points-Map-text']['Text']="Mission "+str(scene.objects['Points']['mission'])
scene.objects['Book_mission']['Text'] = "Mission en cours : "+str(scene.objects['Points']['mission'])
diff --git a/rp_lib.py b/rp_lib.py
index 5e3e8cd..7e2df35 100644
--- a/rp_lib.py
+++ b/rp_lib.py
@@ -202,7 +202,7 @@ def rp_avancer ():
scene.objects['Points']['step'] +=1
# Animation rapide
- if scene.objects['Commands']['speed'] == 10 and scene.objects['Points']['step']> 2: # A tendance à planter sur les premiers mouvements en rapide + balisage
+ if scene.objects['Commands']['speed'] >= 10 and scene.objects['Points']['step']> 2: # A tendance à planter sur les premiers mouvements en rapide + balisage
x0 = obj.worldPosition.x
y0 = obj.worldPosition.y
z0 = obj.worldPosition.z
@@ -234,7 +234,7 @@ def rp_avancer ():
# rp_tempo (0.1*step)
# Animation
- if scene.objects['Commands']['speed'] != 10:
+ if scene.objects['Commands']['speed'] < 10:
start = 1
end = 100
layer = 0
@@ -290,7 +290,7 @@ def rp_gauche ():
step=math.pi/2 # Pas angulaire
# Animation rapide
- if scene.objects['Commands']['speed'] == 10:
+ if scene.objects['Commands']['speed'] >= 10:
obj.applyRotation((0, 0, step), True)
rp_tempo (0.1)
return True
@@ -336,7 +336,7 @@ def rp_droite ():
step=math.pi/2 # Pas angulaire
# Rapide
- if scene.objects['Commands']['speed'] == 10:
+ if scene.objects['Commands']['speed'] >= 10:
obj.applyRotation((0, 0, -step), True)
rp_tempo (0.1)
return True
@@ -491,6 +491,56 @@ def rp_radar ():
print ("rp_radar")
# FIXME
+###############################################################################
+# Rover fonction avancées (upgrade) élèves
+###############################################################################
+
+##
+# Peindre : station, rover, balise
+##
+
+# FIXME tout à définir
+def rp_couleur (element, new_color):
+ if scene.objects['Points']['upgrade_paint']:
+ if (debug_mvt):
+ print ("Nouvelle couleur :", str(new_color),"->", element)
+ print ("Nouvelle couleur :", str(new_color),"->", element)
+
+##
+# Changer la vitesse
+##
+
+def rp_vitesse (new_speed):
+ if scene.objects['Points']['upgrade_speed']:
+ if new_speed is not None:
+ if (debug_mvt):
+ print ("Nouvelle vitesse :", new_speed)
+ scene.objects['Text_speed']['Text']=str(new_speed)
+ scene.objects['Commands']['speed']=new_speed
+ return scene.objects['Commands']['speed']
+
+##
+# Connaitre le nombre de balise posées
+##
+
+def rp_balise ():
+ if scene.objects['Points']['upgrade_beacon']:
+ for i in range (200):
+ if scene.objects["Beacon-"+str(i)]['activated']==False:
+ break
+ if (debug_mvt):
+ print ("Nombre de balises posées :", i)
+ return i
+
+##
+# Connaitre la charge de la batterie
+##
+
+def rp_batterie ():
+ if scene.objects['Points']['upgrade_battery']:
+ if (debug_mvt):
+ print ("Charge de la batterie :", scene.objects['Points']['battery'])
+ return scene.objects['Points']['battery']
###############################################################################
# Colision
diff --git a/rp_map1.py b/rp_map1.py
index 5590163..abc0e05 100644
--- a/rp_map1.py
+++ b/rp_map1.py
@@ -17,12 +17,19 @@ import os
scene = bge.logic.getCurrentScene()
+color_text = (0, 0, 0, 1) # Noir
+color_text_red = (0.799, 0.031, 0.038, 1)
+color_text_orange = (0.799, 0.176, 0.054, 1)
+color_text_yellow = (0.799, 0.617, 0.021, 1)
+color_text_white = (1, 1, 1, 1)
+
###############################################################################
# Missions
###############################################################################
missions_card_description ={}
missions_conf ={}
+missions_task ={}
###############################################################################
# Initialisation du niveau :
@@ -44,37 +51,46 @@ mission_1_text= mission_1_text +" -> Voir onglet Rover, page \"Avancer\" \n"
mission_1_text= mission_1_text +" -> Voir onglet Rover, page \"Tourner \" \n\n"
mission_1_text= mission_1_text +"Afin de visualiser le trajet, il faudra \n marquer les cases. \n"
mission_1_text= mission_1_text +" -> Voir onglet Rover, page \"Baliser\" \n"
+mission_1_task = "- Atteindre l'objectif \n\n- Poser 6 balises \n minimum"
mission_1_init=[-11.0,3.0, "e"] # Rover init position (x,y), orientation ("n|s|e|w")
mission_1_aim=[-7.0,2.0] # Aim position (x,y)
missions_card_description.update({"mission_1-card" : [mission_1_title, mission_1_text]})
missions_conf.update({"1" : [mission_1_init, mission_1_aim]})
+missions_task.update({"1" : [mission_1_task]})
# Mission 2
mission_2_title="Mission 2\n Ma première fonction"
mission_2_text="\n \n La case à atteindre est toujours la \n même (à l'est de la station). \n \n"
mission_2_text= mission_2_text + " Pour faciliter le codage, vous devez \n créer et utiliser la fonction \n \"mrp_avancer()\" regroupant avancer \n et marquer. \n -> Voir onglet Python, page \"Fonction\". \n\n\n\n\n"
+mission_2_task = "- Atteindre l'objectif \n\n- Poser 6 balises \n minimum\n\n- 40 lignes de code \n maximum\n\n- Définition de la \n fonction \n \"mrp_avancer()\""
mission_2_init=[-11.0,3.0, "e"]
mission_2_aim=[-7.0,2.0]
missions_card_description.update({"mission_2-card" : [mission_2_title, mission_2_text]})
missions_conf.update({"2" : [mission_2_init, mission_2_aim]})
+missions_task.update({"2" : [mission_2_task]})
# Mission 3
mission_3_title="Mission 3\n Apprendre le danger"
mission_3_text="\n \n Tout d'abords, il faut provoquer une \n collision avec un obstacle (pente \n ou station) et observer ce qui se \n passe.\n \n"
mission_3_text= mission_3_text + " Il faut donc sécuriser Ropy en \n utilisant une structure alternative. \n -> Voir onglet Python, page \"Si alors\" \n -> Voir onglet Rover, page \"Détecter\" \n \n"
+mission_3_task = "- Utilisation de \n \"rp_detect()\" dans \n une structure \n alternative \"if\"."
mission_3_init=[-11.0,3.0, "e"] # Rover init position (x,y), orientation ("n|s|e|w")
mission_3_aim=[100.0,100.0] # Aim caché -> pas de de position objectif
missions_card_description.update({"mission_3-card" : [mission_3_title, mission_3_text]})
missions_conf.update({"3" : [mission_3_init, mission_3_aim]})
+missions_task.update({"3" : [mission_3_task]})
# Mission 4
mission_4_title="Mission 4\n Partir au bout du monde"
mission_4_text="\n \n Ropy est maintenant prêt pour \n l'aventure soit atteindre la case \n du nouvel objectif (loin, très loin ...). \n \n Pour un tel voyage, l'utilisation \n d'une boucle du type \"for\" s'impose. \n"
-mission_4_text= mission_4_text +" -> Voir onglet Python, page \"Boucle\" \n \n \n \n \n"
+mission_4_text= mission_4_text +" -> Voir onglet Python, page \"Boucle\" \n \n"
+mission_4_text= mission_4_text + " Dans un deuxième temps, il faut créer \n la fonction \"mrp_avancer_nbpas(pas)\"\n afin d'avancer d'un nombre de pas."
+mission_4_task = "- Atteindre l'objectif \n\n- 40 lignes de code \n maximum\n\n- Utilisation de \n boucle \"for\" \n\n- En bonus : création \n de la fonction \"mrp_\n avancer_nbpas(pas)\""
mission_4_init=[-7.0,4.0, "e"]
mission_4_aim=[12.0,9.0]
missions_card_description.update({"mission_4-card" : [mission_4_title, mission_4_text]})
missions_conf.update({"4" : [mission_4_init, mission_4_aim]})
+missions_task.update({"4" : [mission_4_task]})
# Mission 5
mission_5_title="Mission 5\n Faire face à l'inconnu"
@@ -82,30 +98,38 @@ mission_5_text="\n \n La case à atteindre est toujours la \n même, mais le lie
mission_5_text= mission_5_text +" Pour pallier à l\'aléatoire, vous \n utiliserez les pentes comme obstacle. \n"
mission_5_text= mission_5_text +" Il faut alors créer une fonction \n avec une boucle \"while\" (tant que) \n qui permet d'avancer jusqu'à un \n obstacle :"
mission_5_text= mission_5_text +" \"mrp_avancer_mur()\". \n \n \n"
+mission_5_task = "- Atteindre l'objectif \n\n- 40 lignes de code \n maximum\n\n- Utilisation de \n boucle \"while\" \n\n- En bonus : création \n de la fonction \"mrp_\n avancer_mur()\""
mission_5_init=[0.0,0.0, "e"] # Position aléatoire tourné vers l'est -> défini dans le reset
mission_5_aim=[12.0,9.0]
missions_card_description.update({"mission_5-card" : [mission_5_title, mission_5_text]})
missions_conf.update({"5" : [mission_5_init, mission_5_aim]})
+missions_task.update({"5" : [mission_5_task]})
# Mission 6
mission_6_title="Mission 6\n Se rendre utile"
-mission_6_text="\n \n Une zone précise du terrain présente \n des pierres à analyser. \n \n Elles apparaissent de manière \n aléatoire (encore !), pour les \n ramasser, Ropy doit passer sur \n toutes les cases de la zone. \n \n \n \n \n \n \n"
+mission_6_text="\n \n Une zone précise du terrain présente \n des carottages afin d'analyser la \n roche. \n \n Les lieux de forage sont définis de \n manière aléatoire (encore !), pour les \n réaliser, Ropy doit donc passer sur \n toutes les cases de la zone. \n \n \n \n \n \n \n"
+mission_6_task = "- Passer sur les 10 \n lieux de forage"
mission_6_init=[0.0,0.0, "e"] # Position aléatoire tourné vers l'est -> défini dans le reset
mission_6_aim=[100.0,100.0] # Aim caché -> rammassage de pierre
missions_card_description.update({"mission_6-card" : [mission_6_title, mission_6_text]})
missions_conf.update({"6" : [mission_6_init, mission_6_aim]})
+missions_task.update({"6" : [mission_6_task]})
# Mission 7
# mission_7_title="Mission 7\n FIXME"
# mission_7_text="\n \n FIXME"
+# mission_7_task = "FIXME"
# missions_card_description.update({"mission_7-card" : [mission_7_title, mission_7_text]})
# missions_conf.update({"7" : [mission_7_init, mission_7_aim]})
+# missions_task.update({"7" : [mission_7_task]})
# Mission 8
# mission_8_title="Mission 8\n FIXME"
# mission_8_text="\n \n FIXME"
+# mission_8_task = "FIXME"
# missions_card_description.update({"mission_8-card" : [mission_8_title, mission_8_text]})
# missions_conf.update({"8" : [mission_8_init, mission_8_aim]})
+# missions_task.update({"8" : [mission_8_task]})
# Description des cartes missions
@@ -160,6 +184,9 @@ def map_init():
def map_reset():
scene.objects['Points']['step']=0
scene.objects['Points']['nbligne']=0
+ scene.objects['Points']['battery']=100
+ scene.objects['Points-Battery'].color = color_text_white
+ scene.objects['Points-Battery-text'].color = color_text
mission_init = missions_conf[str(scene.objects['Points']['mission'])][0]
mission_aim = missions_conf[str(scene.objects['Points']['mission'])][1]
@@ -245,10 +272,17 @@ def aim_hide():
scene.objects['Aimzone-mission-6'].setVisible(False,True)
scene.objects['Initzone-mission-5'].setVisible(False,True)
+##
+# Affichage des tâches
+##
+
+def task():
+ scene.objects['Task_text']['Text']=missions_task[str(scene.objects['Points']['mission'])][0]
+
##
# Validation de l'objectif atteint
##
-
+
def objectif_control(x,y):
# Mission 1
@@ -281,8 +315,12 @@ def objectif_control(x,y):
else:
txt=["def mrp_avancer_nbpas"] # Présence de "def mrp_avancer_nbpas"
if rp_cmd_txtcount(txt, 1):
- return True
-
+ txt=["for" ] # Présence de "for i in range" 1x
+ if rp_cmd_txtcount(txt, 1):
+ txt=["in range" ]
+ if rp_cmd_txtcount(txt, 1):
+ return True
+
# Mission 5 (boucle en while)
if scene.objects['Points']['mission']==5:
if [x,y] in scene.objects['Terrain']['map_aim']: # Aim
@@ -293,7 +331,9 @@ def objectif_control(x,y):
else:
txt=["def mrp_avancer_mur():", "def mrp_avancer_mur() :", "def mrp_avancer_mur ():", "def mrp_avancer_mur () :"] # Présence de "def mrp_avancer_mur():"
if rp_cmd_txtcount(txt, 1):
- return True
+ txt=["while" ] # Présence de "while" 1x
+ if rp_cmd_txtcount(txt, 1):
+ return True
# Mission 6 (passer sur tout le terrain)
if scene.objects['Points']['mission']==6:
diff --git a/rp_store.py b/rp_store.py
index 8802014..5939ae5 100644
--- a/rp_store.py
+++ b/rp_store.py
@@ -96,6 +96,10 @@ def open2 (cont):
thread_gostore_stop()
obj['store-anim_end']=False
+ # Pas arrivé au store, dommage !
+ if obj['stop']:
+ return False
+
# Affinage de la position
obj.worldPosition.x = -9.75
obj.worldPosition.y = -4
@@ -153,7 +157,6 @@ def open2 (cont):
scene.objects['Store_upgrade-colbox'].suspendPhysics (True)
scene.objects['Store_text'].setVisible(False,True)
-
##
# Animation du store
##
@@ -385,7 +388,6 @@ def rover_go_store():
# Position de départ pour le debug
# obj.worldPosition.x=12
# obj.worldPosition.y=9
-
x0 = obj.worldPosition.x
y0 = obj.worldPosition.y
z0 = obj.worldPosition.z