diff --git a/ropy-30.blend b/ropy-30.blend
index b27ac55..5ff2787 100644
Binary files a/ropy-30.blend and b/ropy-30.blend differ
diff --git a/ropy-30.blend1 b/ropy-30.blend1
new file mode 100644
index 0000000..b27ac55
Binary files /dev/null and b/ropy-30.blend1 differ
diff --git a/ropy-31.blend b/ropy-31.blend
new file mode 100644
index 0000000..300f858
Binary files /dev/null and b/ropy-31.blend differ
diff --git a/rp.py b/rp.py
index d9cb09c..35f47ea 100644
--- a/rp.py
+++ b/rp.py
@@ -133,7 +133,9 @@ def points_maj (cont):
# Initialisation lors du chargement du terrain
##
-def terrain_init ():
+def terrain_init (cont):
+ if cont.sensors['Init'].positive == False:
+ return False
# Ajout du Hud
scene.active_camera = scene.objects["Camera"]
@@ -391,7 +393,9 @@ color_cmd_hl = (0.8, 0.619, 0.021, 1) # Jaune
# Init
##
-def cmd_init():
+def cmd_init(cont):
+ if cont.sensors['Init'].positive == False:
+ return False
# Taille de la fenêtre
# Read config (screen size : data/config/screen/width-> [0][3][0].text)
diff --git a/rp_config.xml b/rp_config.xml
index 3225c93..aae8bf8 100644
--- a/rp_config.xml
+++ b/rp_config.xml
@@ -3,9 +3,9 @@
1.0
False
- -1.8592177629470825
- -33.43065643310547
- 27.0482177734375
+ 0.0057830810546875
+ -26.440298080444336
+ 20.22315788269043
1280
diff --git a/rp_doc.py b/rp_doc.py
index ecd4b5e..3bbbc7c 100644
--- a/rp_doc.py
+++ b/rp_doc.py
@@ -1,6 +1,7 @@
import bge # Bibliothèque Blender Game Engine (UPBGE)
import rp_map1 # Map definition
import webbrowser
+import time
###############################################################################
# rp_doc.py
@@ -256,6 +257,10 @@ def init():
scene.objects["mission_"+str(scene.objects['Points']['mission'])+"-card-icon"].color = color_doc_mission
scene.objects["mission_"+str(scene.objects['Points']['mission'])+"-card-text"].color = color_doc_mission
+ # Chargement du texte
+ text_load()
+ text_load2()
+
# Mémorisation de la position des pages
chap=("general", "missions", "rover", "python")
for page in chap:
@@ -277,10 +282,6 @@ def open():
scene.objects['Doc'].worldPosition = [0, -21, 15.8]
scene.objects['Doc_close'].color = color_doc_chap
scene.objects['Doc'].setVisible(True,True)
- scene.objects['Doc_title']['Text'] = " "
- text_clear()
- scene.objects['Doc_title'].setVisible(False,True)
- text_hide()
# Placer le nouveau chapitre
name_chap = scene.objects['Doc']['page_chap']
@@ -289,6 +290,9 @@ def open():
scene.objects['Doc_chap-'+name_chap].worldPosition = scene.objects['Doc'].worldPosition
scene.objects['Doc_chap-'+name_chap].setVisible(True,True)
+ # scene.objects['Doc_text-l1-forward-card'].setVisible(True, False)
+ # scene.objects['Doc_text-l1-ref'].setVisible(True, False)
+
# Affichage ou pas du bouton de selection de la mission
if name_chap == "missions":
name_fct = scene.objects['Doc_chap-missions']['page_fct']
@@ -325,22 +329,62 @@ def open():
scene.objects['Book_python_url'+str(i)].setVisible(True,True)
# Afficher le texte de la carte active
- if name_chap != "general":
- if scene.objects['Doc_chap-'+name_chap]['page_fct'] !="":
- name_fct = scene.objects['Doc_chap-'+name_chap]['page_fct']
- scene.objects['Doc_title']['Text'] = card_description[name_fct][0]
- scene.objects['Doc_title'].setVisible(True, False)
- text_update(card_description[name_fct][1])
- else:
- scene.objects['Doc_title'].setVisible(False,True)
- text_hide()
+ if name_chap != "general" and scene.objects['Doc_chap-'+name_chap]['page_fct'] !="":
+ name_fct = scene.objects['Doc_chap-'+name_chap]['page_fct']
+ scene.objects['Doc_title']['Text'] = card_description[name_fct][0]
+ scene.objects['Doc_title'].setVisible(True, False)
+ text_show(name_fct)
else:
- if name_chap != "missions":
- scene.objects['Doc_title'].setVisible(False,True)
- text_hide()
- else:
- scene.objects['Doc_title'].setVisible(False,True)
- text_hide()
+ scene.objects['Doc_title']['Text'] = " "
+ scene.objects['Doc_title'].setVisible(False,True)
+ text_hide()
+
+ scene.objects['Doc_text-l1-ref'].setVisible(True, False)
+ print (scene.objects['Doc_text-l1-forward-card']['Text'])
+ scene.objects['Doc_text-l1-forward-card'].setVisible(True, False)
+ scene.objects['Doc_text-l1-forward-card'].worldPosition.x = scene.objects['Doc_text-l1-ref'].worldPosition.x
+ scene.objects['Doc_text-l1-forward-card'].worldPosition.y = scene.objects['Doc_text-l1-ref'].worldPosition.y
+ scene.objects['Doc_text-l1-forward-card'].worldPosition.z = scene.objects['Doc_text-l1-ref'].worldPosition.z
+
+ # text_load2()
+ # scene.objects['Doc_text-l1-forward-card']['text_def']= scene.objects['Doc_text-l1-forward-card']['Text']
+ # scene.objects['Doc_text-l1-forward-card']['redraw']=True
+
+ # print (scene.objects['Doc_text-l1-forward-card']['Text'])
+ # old_text=scene.objects['Doc_text-l1-forward-card']['Text']
+ # print (old_text)
+ # scene.objects['Doc_text-l1-forward-card']['Text']="eeee"
+ # scene.objects['Doc_text-l1-forward-card']['Text']=old_text
+ # scene.objects['Doc_text-l1-forward-card']['Text']=" rp_avancer()"
+ # scene.objects['Doc_text-l1-forward-card']['Text']=old_text
+
+ # doc_tempo (0.1)
+ # scene.objects['Doc_text-l1-forward-card'].setVisible(False, False)
+ # rp_tempo(0.1)
+ # scene.objects['Doc_text-l1-forward-card'].setVisible(False, False)
+ # scene.objects['Doc_text-l1-forward-card']['Text']="eeee"
+
+def text_redraw(cont):
+ print ("text_redraw")
+ obj = cont.owner
+ print (obj['text_def'] +":" + obj['Text'])
+ obj['Text']= obj['text_def']
+ obj.setVisible(True, False)
+ print (obj['Text'])
+ scene.objects['Doc_text-l1-forward-card']['redraw']=False
+ scene.objects['Doc_text-l1-sleep-card']['Text']="rr"
+
+ # scene.objects['Doc_text-l1-forward-card']['Text']="eeee"
+ # if card is None:
+ # for card in card_description:
+ # print ("hide:", card)
+ # for i in range (13):
+ # scene.objects['Doc_text-l'+str(i+1)+'-'+str(card)].setVisible(False, False)
+ # else:
+ # print ("hide:", card)
+ # for i in range (13):
+ # scene.objects['Doc_text-l'+str(i+1)+'-'+card].setVisible(False, False)
+
##
# Fermeture du livre
@@ -439,7 +483,6 @@ def chapter(cont):
# sound_play (sndbuff_book_flip)
obj = cont.owner
scene.objects['Doc_title']['Text'] = " "
- text_clear()
# Enlever l'ancien chapitre
scene.objects['Doc-'+scene.objects['Doc']['page_chap']].color = color_doc_chap
@@ -492,16 +535,13 @@ def chapter(cont):
scene.objects['Book_python_url'+str(i)].setVisible(True,True)
# Afficher le texte de la carte active
- if name_chap != "general":
- if scene.objects['Doc_chap-'+name_chap]['page_fct'] !="":
- name_fct = scene.objects['Doc_chap-'+name_chap]['page_fct']
- scene.objects['Doc_title']['Text'] = card_description[name_fct][0]
- scene.objects['Doc_title'].setVisible(True, False)
- text_update(card_description[name_fct][1])
- else:
- scene.objects['Doc_title'].setVisible(False,True)
- text_hide()
+ if name_chap != "general" and scene.objects['Doc_chap-'+name_chap]['page_fct'] !="":
+ name_fct = scene.objects['Doc_chap-'+name_chap]['page_fct']
+ scene.objects['Doc_title']['Text'] = card_description[name_fct][0]
+ scene.objects['Doc_title'].setVisible(True, False)
+ text_show(name_fct)
else:
+ scene.objects['Doc_title']['Text'] = " "
scene.objects['Doc_title'].setVisible(False,True)
text_hide()
@@ -509,35 +549,85 @@ def chapter(cont):
# Cacher le texte
##
-def text_hide():
- for i in range (13):
- scene.objects['Doc_text-l'+str(i+1)].setVisible(False, False)
-
-##
-# Effacer le texte
-##
-
-def text_clear():
- for i in range (13):
- scene.objects['Doc_text-l'+str(i+1)]['Text'] = ""
+def text_hide(card=None):
+ if card is None:
+ for card in card_description:
+ print ("hide:", card)
+ for i in range (13):
+ scene.objects['Doc_text-l'+str(i+1)+'-'+str(card)].setVisible(False, False)
+ else:
+ print ("hide:", card)
+ for i in range (13):
+ scene.objects['Doc_text-l'+str(i+1)+'-'+card].setVisible(False, False)
##
# Afficher le texte
##
-def text_update(text):
- lines = text.split("\n")
- for i in range (13):
- if i >= len(lines):
- scene.objects['Doc_text-l'+str(i+1)]['Text'] = ""
- scene.objects['Doc_text-l'+str(i+1)].setVisible(False, False)
- else:
- if len(lines[i]) ==0:
- scene.objects['Doc_text-l'+str(i+1)]['Text'] = ""
- scene.objects['Doc_text-l'+str(i+1)].setVisible(False, False)
+def text_show(card=None):
+ if card is None:
+ for card in card_description:
+ # print ("show:", card)
+ for i in range (13):
+ scene.objects['Doc_text-l'+str(i+1)+'-'+str(card)].setVisible(True, False)
+ else:
+ # print ("show:", card)
+ lines = card_description[card][1].split("\n")
+ for i in range (13):
+ # print ("show avant:", scene.objects['Doc_text-l'+str(i+1)+'-'+card].name, scene.objects['Doc_text-l'+str(i+1)+'-'+card]['Text'])
+ if i >= len(lines):
+ text=""
else:
- scene.objects['Doc_text-l'+str(i+1)]['Text'] = lines[i]
- scene.objects['Doc_text-l'+str(i+1)].setVisible(True, False)
+ if len(lines[i]) ==0:
+ text=""
+ else:
+ text=lines[i]
+ # if scene.objects['Doc_text-l'+str(i+1)+'-'+card]['Text'] != text:
+ # scene.objects['Doc_text-l'+str(i+1)+'-'+card]['Text'] = text
+ print ("text", text)
+ # text="hh"
+ idcard="Doc_text-l"+str(i+1)+"-"+card
+ scene.objects[idcard]['Text'] = str(text)
+ scene.objects[idcard].setVisible(True, False)
+ # print ("show après:", scene.objects['Doc_text-l'+str(i+1)+'-'+card].name, scene.objects['Doc_text-l'+str(i+1)+'-'+card]['Text'])
+
+##
+# Préchargement des textes
+##
+
+def text_load():
+ # for i in range (13):
+ # scene.objects['Doc_text-l'+str(i+1)+'-ref']['Text'] = ""
+
+ # Création des objets 3D
+ for card in card_description:
+ print ("create:", card)
+ for i in range (13):
+ doc_text= scene.addObject('Doc_text-l'+str(i+1), None, 0.00, True)
+ # doc_text= scene.addObject('Doc_text-l'+str(i+1), scene.objects['Terrain'])
+ # doc_text= scene.addObject('Doc_text-l'+str(i+1), scene.objects['Doc'] )
+ doc_text.setParent(scene.objects['Doc'])
+ doc_text.name = 'Doc_text-l'+str(i+1)+'-'+str(card)
+ doc_text.worldPosition.x = scene.objects['Doc_text-l'+str(i+1)+'-ref'].worldPosition.x
+ doc_text.worldPosition.y = scene.objects['Doc_text-l'+str(i+1)+'-ref'].worldPosition.y
+ doc_text.worldPosition.z = scene.objects['Doc_text-l'+str(i+1)+'-ref'].worldPosition.z
+ doc_text.setVisible(False, False)
+ print ("create:", doc_text.name)
+
+def text_load2():
+ for card in card_description:
+ lines = card_description[card][1].split("\n")
+ print ("load:", lines)
+ for i in range (13):
+ if i >= len(lines):
+ scene.objects['Doc_text-l'+str(i+1)+'-'+str(card)]['Text']=""
+ else:
+ if len(lines[i]) ==0:
+ scene.objects['Doc_text-l'+str(i+1)+'-'+str(card)]['Text']=""
+ else:
+ scene.objects['Doc_text-l'+str(i+1)+'-'+str(card)]['Text']=lines[i]
+ # scene.objects['Doc_text-l'+str(i+1)+'-'+str(card)]['Text']=str(card)
+ print ("load:", scene.objects['Doc_text-l'+str(i+1)+'-'+str(card)].name, scene.objects['Doc_text-l'+str(i+1)+'-'+str(card)]['Text'])
##
# Afficher les details de la fonction à partir d'une carte
@@ -550,7 +640,6 @@ def card (cont):
name_chap = scene.objects['Doc']['page_chap']
name_fct= obj.name[:-7]
scene.objects['Doc_title']['Text'] = " "
- text_clear()
# Enlever l'ancienne carte
if scene.objects['Doc_chap-'+name_chap]['page_fct'] !="":
@@ -572,7 +661,7 @@ def card (cont):
scene.objects[name_fct+'-text'].color = color_doc_activate
scene.objects['Doc_title']['Text'] = card_description[name_fct][0]
scene.objects['Doc_title'].setVisible(True, False)
- text_update(card_description[name_fct][1])
+ text_show(name_fct)
# URL Python
if name_chap == "python":
@@ -643,9 +732,26 @@ def upgrade_talk (card):
else:
return ""
-##
+
+###############################################################################
+# Temporisation
+###############################################################################
+
+# Temporisation basée sur l'horloge de l'OS
+def doc_sleep (duration):
+ time.sleep(duration)
+
+# Temporisation basée par l'horloge de UPBGE
+def doc_tempo (duration):
+ # time.sleep(duration*(1/scene.objects['Commands']['speed']))
+ scene.objects['Commands']['time']=0
+ while scene.objects['Commands']['time']