Finalisation des cartes de fonction

This commit is contained in:
Philippe Roy 2022-08-21 02:22:56 +02:00
parent 141e170e83
commit b34e4ab067
3 changed files with 223 additions and 112 deletions

BIN
ropy-07.blend Normal file

Binary file not shown.

5
rp.py
View File

@ -345,6 +345,11 @@ def cmd_init():
i=speed_mode.index(scene.objects['Terrain']['speed'])
scene.objects['Text_speed']['Text']=speed_mode_txt[i]
# Windows
windows=("Doc", "Doc_chap-general", "Doc_chap-missions", "Doc_chap-rover", "Doc_chap-python", "About")
for window in windows:
scene.objects[window].setVisible(False,True)
##
# Highlight des commandes
##

330
rp_doc.py
View File

@ -28,8 +28,10 @@ scene = bge.logic.getCurrentScene()
color_doc_chap = (0, 1, 0.857,1) # Turquoise
color_doc_fct = (0, 1, 0.857,1) # Turquoise
color_doc_hl = (0.799, 0.617, 0.021, 1) # Jaune
# color_doc_activate = (0.936, 0.033, 1, 1) # Rose
color_doc_activate = (0.837, 0.901, 1, 1) # Rose
color_doc_activate = (0.936, 0.033, 1, 1) # Rose
# color_doc_activate = (1, 0.099, 0.981, 1) # Rose
# scene.objects['Doc_icon_'+name_chap+'-text'].color = color_doc_activate
# Sounds
# audiodev = aud.Device()
@ -55,33 +57,124 @@ card_description ={}
missions_card=["mission_1-card", "mission_2-card", "mission_3-card", "mission_4-card", "mission_5-card", "mission_6-card", "mission_7-card", "mission_8-card"]
# ct_build (x, y, category, name, color, style)
rp_mission_1_title="Build a tower"
rp_mission_1_text="ct_build (x,y, category, name, color, style)\n \v- x position (integer)\n \v- y position (integer)\n"
# Mission 1
rp_mission_1_title="Mission 1\n Premiers pas"
rp_mission_1_text="\n \n aa"
card_description.update({"mission_1-card" : [rp_mission_1_title, rp_mission_1_text]})
# ct_build_text = ct_build_text +" \v- category (string) : \n \v \v- \"Archer tower\" (default value)\n \v \v- \"Mage tower\"\n"
# ct_build_text = ct_build_text +" \v- name (string)\n \v- color (RGB tuple, default=purple)\n"
# ct_build_text = ct_build_text +" \v- style (string) : \n \v \v- \"square\" (default value) or \"round\"\n \v \v- version : A (default value), B or C\n \v \v- exemple : 'round-B' \n"
# ct_build_text = ct_build_text +" \v- Return boolean flag (builded -> True)\n\n"
# ct_build_text = ct_build_text +"Predefined colors : blue, green, magenta,\n orange, purple, red, turquoise, yellow.\n\n"
# ct_build_text = ct_build_text +"Exemple : ct_build (1, 1, \"Archer tower\", \n \"Tower #1\", yellow, \"round-A\")\n"
card_description.update({"mission_1-card" : [rp_mission_1_title, rp_mission_1_text]})
# # ct_remove (x, y)
# ct_remove_title="Remove a tower"
# ct_remove_text=" ct_remove (x, y) \n \v - x position (integer)\n \v - y position (integer)\n"
# fct_description.update({"Remove-card" : [ct_remove_title, ct_remove_text]})
# Mission 2
rp_mission_2_title="Mission 2\n FIXME"
rp_mission_2_text="\n \n FIXME"
card_description.update({"mission_2-card" : [rp_mission_2_title, rp_mission_2_text]})
# Mission 3
rp_mission_3_title="Mission 3\n FIXME"
rp_mission_3_text="\n \n FIXME"
card_description.update({"mission_3-card" : [rp_mission_3_title, rp_mission_3_text]})
# Mission 4
rp_mission_4_title="Mission 4\n FIXME"
rp_mission_4_text="\n \n FIXME"
card_description.update({"mission_4-card" : [rp_mission_4_title, rp_mission_4_text]})
# Mission 5
rp_mission_5_title="Mission 5\n FIXME"
rp_mission_5_text="\n \n FIXME"
card_description.update({"mission_5-card" : [rp_mission_5_title, rp_mission_5_text]})
# Mission 6
rp_mission_6_title="Mission 6\n FIXME"
rp_mission_6_text="\n \n FIXME"
card_description.update({"mission_6-card" : [rp_mission_6_title, rp_mission_6_text]})
# Mission 7
rp_mission_7_title="Mission 7\n FIXME"
rp_mission_7_text="\n \n FIXME"
card_description.update({"mission_7-card" : [rp_mission_7_title, rp_mission_7_text]})
# Mission 8
rp_mission_8_title="Mission 8\n FIXME"
rp_mission_8_text="\n \n FIXME"
card_description.update({"mission_8-card" : [rp_mission_8_title, rp_mission_8_text]})
###############################################################################
# Rover
###############################################################################
rover_card=["avancer-card", "tourner-card", "baliser-card", "prendre-card", "baliser-card"]
rover_card=["avancer-card", "tourner-card", "baliser-card", "prendre-card", "detecter-card", "radar-card"]
# Avancer
rp_avancer_title="Avancer"
rp_avancer_text="FIXME"
card_description.update({"avancer-card" : [rp_avancer_title, rp_avancer_text]})
# Tourner
rp_tourner_title="Tourner"
rp_tourner_text="FIXME"
card_description.update({"tourner-card" : [rp_tourner_title, rp_tourner_text]})
# Baliser
rp_baliser_title="Baliser"
rp_baliser_text="FIXME"
card_description.update({"baliser-card" : [rp_baliser_title, rp_baliser_text]})
# Prendre
rp_prendre_title="Prendre"
rp_prendre_text="FIXME"
card_description.update({"prendre-card" : [rp_prendre_title, rp_prendre_text]})
# Détecter
rp_detecter_title="Détecter"
rp_detecter_text="FIXME"
card_description.update({"detecter-card" : [rp_detecter_title, rp_detecter_text]})
# Radar
rp_radar_title="Radar"
rp_radar_text="FIXME"
card_description.update({"radar-card" : [rp_radar_title, rp_radar_text]})
###############################################################################
# Python
###############################################################################
python_card=["fonction-card", "alternative-card", "boucle-card", "liste-card", "dictionnaire-card", "poo-card"]
python_card=["fonction-card", "alternative-card", "boucle-card", "liste-card", "dict-card", "poo-card"]
# Fonction
rp_fonction_title="Fonction"
rp_fonction_text="FIXME"
card_description.update({"fonction-card" : [rp_fonction_title, rp_fonction_text]})
# Alternative
rp_alternative_title="Alternative"
rp_alternative_text="FIXME"
card_description.update({"alternative-card" : [rp_alternative_title, rp_alternative_text]})
# Boucle
rp_boucle_title="Boucle"
rp_boucle_text="FIXME"
card_description.update({"boucle-card" : [rp_boucle_title, rp_boucle_text]})
# Liste
rp_liste_title="Liste"
rp_liste_text="FIXME"
card_description.update({"liste-card" : [rp_liste_title, rp_liste_text]})
# Dictionnaire
rp_dict_title="Dictionnaire"
rp_dict_text="FIXME"
card_description.update({"dict-card" : [rp_dict_title, rp_dict_text]})
# Objet (POO)
rp_poo_title="Programmation\norientée objet (POO)"
rp_poo_text="\nFIXME"
card_description.update({"poo-card" : [rp_poo_title, rp_poo_text]})
###############################################################################
# Interface
@ -93,54 +186,61 @@ python_card=["fonction-card", "alternative-card", "boucle-card", "liste-card", "
def init():
# Mettre les pages avec la couleurs par defaut
# Mettre les couleurs par défaut sur les icones (chapitres et cartes)
chap=("general", "missions", "rover", "python")
for page in chap:
scene.objects["Doc-"+page].color = color_doc_chap
scene.objects["Doc-"+page+"-text"].color = color_doc_chap
for i in range(len(missions_card)):
scene.objects[missions_card[i]].color = color_doc_fct
scene.objects[missions_card[i]+"-icon"].color = color_doc_fct
scene.objects[missions_card[i]+"-text"].color = color_doc_fct
for i in range(len(rover_card)):
scene.objects[rover_card[i]].color = color_doc_fct
scene.objects[rover_card[i]+"-icon"].color = color_doc_fct
scene.objects[rover_card[i]+"-text"].color = color_doc_fct
for i in range(len(python_card)):
scene.objects[python_card[i]].color = color_doc_fct
scene.objects[python_card[i]+"-icon"].color = color_doc_fct
scene.objects[python_card[i]+"-text"].color = color_doc_fct
# Mémorisation de la position des pages
chap=("general", "missions", "rover", "python")
for page in chap:
scene.objects["Doc_chap-"+page]['init_lx']=scene.objects["Doc_chap-"+page].worldPosition.x
scene.objects["Doc_chap-"+page]['init_ly']=scene.objects["Doc_chap-"+page].worldPosition.y
scene.objects["Doc_chap-"+page]['init_lz']=scene.objects["Doc_chap-"+page].worldPosition.z
# Placer la tablette
# scene.objects['Doc'].worldPosition = [0, -21, 15.75]
scene.objects['Doc'].worldPosition = [0, -21, 15.8]
scene.objects['Doc_close'].color = color_doc_chap
for page in ("general", "missions", "rover", "python"):
scene.objects["Doc_icon_"+page].color = color_doc_chap
scene.objects["Doc_icon_"+page+"-text"].color = color_doc_chap
scene.objects['Doc'].setVisible(True,True)
scene.objects['Doc_title'].setVisible(False,True)
scene.objects['Doc_text'].setVisible(False,True)
# sound_play (sndbuff_book_open)
# Activer la page screen (page par defaut)
# Placer la page Généralité (page par défaut)
scene.objects['Doc_chap-general'].worldPosition = scene.objects['Doc'].worldPosition
scene.objects['Doc_chap-general'].setVisible(True,True)
scene.objects['Doc']['page_chap'] = "general"
# scene.objects['Book_chap-screen'].color = color_doc_activate
# scene.objects['Book_page_screen'].worldPosition = scene.objects['Book'].worldPosition
# scene.objects['Book_page_screen'].setVisible(True,True)
# Mettre les cartes avec la couleur par defaut
for i in range(len(missions_card)):
scene.objects[missions_card[i]].color = color_doc_fct
for i in range(len(rover_card)):
scene.objects[rover_card[i]].color = color_doc_fct
for i in range(len(python_card)):
scene.objects[python_card[i]].color = color_doc_fct
scene.objects['Doc']['page_fct'] = ""
scene.objects['Doc-general'].color = color_doc_activate
scene.objects['Doc-general-text'].color = color_doc_activate
##
# Fermeture du livre
##
def close():
# sound_play (sndbuff_book_close)
# Effacer les fonctions cartes
scene.objects['Doc'].setVisible(False,True)
scene.objects['Doc'].worldPosition = [35, -2, 2]
scene.objects['Doc_chap-general'].setVisible(False,True)
scene.objects['Doc_chap-general'].worldPosition = [35, -5, 0]
scene.objects['Doc_chap-missions'].setVisible(False,True)
scene.objects['Doc_chap-missions'].worldPosition = [35, -7, -2]
scene.objects['Doc_chap-rover'].setVisible(False,True)
scene.objects['Doc_chap-rover'].worldPosition = [35, -9, -4]
scene.objects['Doc_chap-python'].setVisible(False,True)
scene.objects['Doc_chap-python'].worldPosition = [35, -11, -6]
chap=("general", "missions", "rover", "python")
for page in chap:
scene.objects["Doc_chap-"+page].setVisible(False,True)
scene.objects["Doc_chap-"+page].worldPosition.x = scene.objects["Doc_chap-"+page]['init_lx']
scene.objects["Doc_chap-"+page].worldPosition.y = scene.objects["Doc_chap-"+page]['init_ly']
scene.objects["Doc_chap-"+page].worldPosition.z = scene.objects["Doc_chap-"+page]['init_lz']
scene.objects['Doc'].setVisible(False,True)
scene.objects['Doc'].worldPosition = [35, -2, 2]
@ -149,49 +249,62 @@ def close():
##
def hl (cont):
# Activation
if cont.sensors['MO'].status == JUST_ACTIVATED :
obj = cont.owner
name=obj.name[:-7]
name_text=obj.name[:-7]+"-text"
name_icon=obj.name[:-7]+"-icon"
if name == scene.objects['Doc']['page_chap'] or name == scene.objects['Doc']['page_fct'] :
scene.objects[name].color = color_doc_activate
if name_text in scene.objects:
scene.objects[name_text].color = color_doc_activate
if name_icon in scene.objects:
scene.objects[name_icon].color = color_doc_activate
else:
name_text=name+"-text"
name_icon=name+"-icon"
# Close
if name == "Doc_close" :
scene.objects[name].color = color_doc_hl
if name_text in scene.objects:
scene.objects[name_text].color = color_doc_hl
if name_icon in scene.objects:
scene.objects[name_icon].color = color_doc_hl
else:
if "Doc-" in name : # Chapitre
if name[4:] == scene.objects['Doc']['page_chap']:
scene.objects[name].color = color_doc_activate
scene.objects[name_text].color = color_doc_activate
else:
scene.objects[name].color = color_doc_hl
scene.objects[name_text].color = color_doc_hl
else: # Carte
if name == scene.objects['Doc']['page_fct'] :
scene.objects[name].color = color_doc_activate
scene.objects[name_text].color = color_doc_activate
scene.objects[name_icon].color = color_doc_activate
else:
scene.objects[name].color = color_doc_hl
scene.objects[name_text].color = color_doc_hl
scene.objects[name_icon].color = color_doc_hl
# Désactivation
if cont.sensors['MO'].status == JUST_RELEASED :
obj = cont.owner
name=obj.name[:-7]
name_text=obj.name[:-7]+"-text"
name_icon=obj.name[:-7]+"-icon"
if name == scene.objects['Doc']['page_chap'] or name == scene.objects['Doc']['page_fct'] :
scene.objects[name].color = color_doc_activate
if name_text in scene.objects:
scene.objects[name_text].color = color_doc_activate
if name_icon in scene.objects:
scene.objects[name_icon].color = color_doc_activate
else:
scene.objects[name].color = color_doc_fct
if name_text in scene.objects:
scene.objects[name_text].color = color_doc_fct
if name_icon in scene.objects:
scene.objects[name_icon].color = color_doc_fct
# if name == scene.objects['Book']['page_chap'] or name == scene.objects['Book']['page_fct'] :
# scene.objects[name].color = color_doc_activate
# else:
# if name[5]=="c":
# scene.objects[name].color = color_doc_chap
# else:
# scene.objects[name].color = color_doc_fct
# Close
if name == "Doc_close" :
scene.objects[name].color = color_doc_fct
else:
if "Doc-" in name : # Chapitre
if name[4:] == scene.objects['Doc']['page_chap']:
scene.objects[name].color = color_doc_activate
scene.objects[name_text].color = color_doc_activate
else:
scene.objects[name].color = color_doc_fct
scene.objects[name_text].color = color_doc_fct
else: # Carte
if name == scene.objects['Doc']['page_fct'] :
scene.objects[name].color = color_doc_activate
scene.objects[name_text].color = color_doc_activate
scene.objects[name_icon].color = color_doc_activate
else:
scene.objects[name].color = color_doc_fct
scene.objects[name_text].color = color_doc_fct
scene.objects[name_icon].color = color_doc_fct
##
# Afficher le chapitre
@ -201,31 +314,24 @@ def chapter(cont):
if cont.sensors['Click'].status == JUST_ACTIVATED and cont.sensors['MO'].positive and cont.sensors['Click'].positive:
# sound_play (sndbuff_book_flip)
obj = cont.owner
last_name_chap= scene.objects['Doc']['page_chap']
name_chap= obj.name[9:-7]
scene.objects['Doc_icon_'+last_name_chap].color = color_doc_chap
scene.objects['Doc_icon_'+last_name_chap+'-text'].color = color_doc_chap
scene.objects['Doc_icon_'+name_chap].color = color_doc_activate
scene.objects['Doc_icon_'+name_chap+'-text'].color = color_doc_activate
# Enlever l'ancien chapitre
scene.objects['Doc-'+scene.objects['Doc']['page_chap']].color = color_doc_chap
scene.objects['Doc-'+scene.objects['Doc']['page_chap']+'-text'].color = color_doc_chap
scene.objects["Doc_chap-"+scene.objects['Doc']['page_chap']].worldPosition.x = scene.objects["Doc_chap-"+scene.objects['Doc']['page_chap']]['init_lx']
scene.objects["Doc_chap-"+scene.objects['Doc']['page_chap']].worldPosition.y = scene.objects["Doc_chap-"+scene.objects['Doc']['page_chap']]['init_ly']
scene.objects["Doc_chap-"+scene.objects['Doc']['page_chap']].worldPosition.z = scene.objects["Doc_chap-"+scene.objects['Doc']['page_chap']]['init_lz']
# Placer le nouveau chapitre
name_chap= obj.name[4:-7]
scene.objects['Doc-'+name_chap].color = color_doc_activate
scene.objects['Doc-'+name_chap+'-text'].color = color_doc_activate
scene.objects['Doc']['page_chap'] = name_chap
# last_name_fct= scene.objects['Doc']['page_fct']
# if last_name_fct != "":
# scene.objects[last_name_fct].color = color_doc_fct
# scene.objects['Book']['page_fct'] = ""
# Effacer les fonctions cartes
scene.objects['Doc_chap-general'].setVisible(False,True)
scene.objects['Doc_chap-missions'].setVisible(False,True)
scene.objects['Doc_chap-rover'].setVisible(False,True)
scene.objects['Doc_chap-python'].setVisible(False,True)
scene.objects['Doc_title'].setVisible(False,True)
scene.objects['Doc_text'].setVisible(False,True)
# Afficher la page
scene.objects['Doc_chap-'+name_chap].worldPosition = scene.objects['Doc'].worldPosition
scene.objects['Doc_chap-'+name_chap].setVisible(True,True)
scene.objects['Doc_title'].setVisible(False,True)
scene.objects['Doc_text'].setVisible(False,True)
##
# Afficher les details de la fonction à partir d'une carte
##
@ -234,23 +340,23 @@ def card (cont):
if cont.sensors['Click'].status == JUST_ACTIVATED and cont.sensors['MO'].positive :
# sound_play (sndbuff_book_flip)
obj = cont.owner
pass
name_fct= obj.name[:-7]
# # Highlight des cartes
# last_name_fct= scene.objects['Book']['page_fct']
# name_fct= obj.name[:-7]
# if last_name_fct != "":
# scene.objects[last_name_fct].color = color_doc_fct
# scene.objects['Book']['page_fct'] = name_fct
# scene.objects[name_fct].color = color_doc_activate
# Enlever l'ancienne carte
if scene.objects['Doc']['page_fct'] != "":
scene.objects[scene.objects['Doc']['page_fct']].color = color_doc_fct
scene.objects[scene.objects['Doc']['page_fct']+'-text'].color = color_doc_fct
scene.objects[scene.objects['Doc']['page_fct']+'-icon'].color = color_doc_fct
# # Afficher le texte de la fonction
# print ("name_fct : ", name_fct)
# print ("fct_description : ", fct_description)
# scene.objects['Book_text_title']['Text'] = fct_description[name_fct][0]
# scene.objects['Book_text']['Text'] = fct_description[name_fct][1]
# scene.objects['Book_text_title'].setVisible(True, False)
# scene.objects['Book_text'].setVisible(True, False)
# Afficher le texte de la carte
scene.objects['Doc']['page_fct']= name_fct
scene.objects[name_fct].color = color_doc_activate
scene.objects[name_fct+'-icon'].color = color_doc_activate
scene.objects[name_fct+'-text'].color = color_doc_activate
scene.objects['Doc_title']['Text'] = card_description[name_fct][0]
scene.objects['Doc_text']['Text'] = card_description[name_fct][1]
scene.objects['Doc_title'].setVisible(True, False)
scene.objects['Doc_text'].setVisible(True, False)
##
# Sounds