2022-08-19 15:43:20 +02:00
import bge # Bibliothèque Blender Game Engine (UPBGE)
2022-09-20 06:40:11 +02:00
import rp_map1 # Map definition
2022-08-19 15:43:20 +02:00
###############################################################################
# rp_doc.py
2022-08-26 12:41:18 +02:00
# @title: Documentation du Rover Ropy
2022-08-19 15:43:20 +02:00
# @project: Ropy (Blender-EduTech)
# @lang: fr
# @authors: Philippe Roy <philippe.roy@ac-grenoble.fr>
# @copyright: Copyright (C) 2020-2022 Philippe Roy
# @license: GNU GPL
#
# Ropy est destiné à la découverte de la programmation procédurale et du language Python.
# A travers plusieurs challenges, donc de manière graduée, les élèves vont apprendre à manipuler les structures algorithmiques de base et à les coder en Python.
#
#
###############################################################################
scene = bge . logic . getCurrentScene ( )
# Colors
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
2022-08-21 02:22:56 +02:00
color_doc_activate = ( 0.936 , 0.033 , 1 , 1 ) # Rose
2022-08-22 04:41:22 +02:00
color_doc_mission = ( 1 , 0.192 , 0.03 , 1 ) # Orange
2022-08-19 15:43:20 +02:00
# UPBGE constants
JUST_ACTIVATED = bge . logic . KX_INPUT_JUST_ACTIVATED
JUST_RELEASED = bge . logic . KX_INPUT_JUST_RELEASED
ACTIVATE = bge . logic . KX_INPUT_ACTIVE
# JUST_DEACTIVATED = bge.logic.KX_SENSOR_JUST_DEACTIVATED
2022-08-20 22:44:17 +02:00
# Cards description
card_description = { }
2022-08-19 15:43:20 +02:00
2022-08-20 22:44:17 +02:00
# Missions
2022-08-24 14:12:23 +02:00
card_description . update ( rp_map1 . get_card_description ( ) )
missions_card = rp_map1 . get_missions_card ( )
2022-08-19 15:43:20 +02:00
2022-09-26 00:34:39 +02:00
################################################################################
# Documentation Rover
################################################################################
2022-08-19 15:43:20 +02:00
2022-09-26 00:34:39 +02:00
rover_card = [ " avancer-card " , " tourner-card " , " baliser-card " , " detecter-card " , " radar-card " ]
2022-10-02 01:36:40 +02:00
rover_card = rover_card + [ " speed-card " , " paint-card " , " battery-card " , " beacon-card " ]
2022-08-21 02:22:56 +02:00
# Avancer
rp_avancer_title = " Avancer "
2022-09-14 21:58:33 +02:00
rp_avancer_text = " rp_avancer() \n -> Avance d ' un pas en avant. "
2022-09-26 00:34:39 +02:00
rp_avancer_type = " standard "
card_description . update ( { " avancer-card " : [ rp_avancer_title , rp_avancer_text , rp_avancer_type ] } )
2022-08-21 02:22:56 +02:00
# Tourner
rp_tourner_title = " Tourner "
2022-09-14 21:58:33 +02:00
rp_tourner_text = " rp_gauche() \n -> Tourne à gauche (90°). \n \n "
rp_tourner_text = rp_tourner_text + " rp_droite() \n -> Tourne à droite (90°). "
2022-09-26 00:34:39 +02:00
rp_tourner_type = " standard "
card_description . update ( { " tourner-card " : [ rp_tourner_title , rp_tourner_text , rp_tourner_type ] } )
2022-08-21 02:22:56 +02:00
# Baliser
rp_baliser_title = " Baliser "
2022-09-26 00:34:39 +02:00
rp_baliser_text = " rp_marquer() \n -> Place une balise sur la case. \n \n Ropy possède que 40 balises, \n il ne peut pas en poser plus. "
rp_baliser_type = " standard "
card_description . update ( { " baliser-card " : [ rp_baliser_title , rp_baliser_text , rp_baliser_type ] } )
2022-08-21 02:22:56 +02:00
# Détecter
rp_detecter_title = " Détecter "
2022-09-14 21:58:33 +02:00
rp_detecter_text = " rp_detect() \n -> Détecte un obstacle. \n \n La fonction retourne : \n - \" True \" si il a un obstacle, \n - \" False \" si il n ' y a pas d ' obstacle. "
2022-09-26 00:34:39 +02:00
rp_detecter_type = " standard "
card_description . update ( { " detecter-card " : [ rp_detecter_title , rp_detecter_text , rp_detecter_type ] } )
2022-08-21 02:22:56 +02:00
# Radar
rp_radar_title = " Radar "
rp_radar_text = " FIXME "
2022-09-26 00:34:39 +02:00
rp_radar_type = " standard "
card_description . update ( { " radar-card " : [ rp_radar_title , rp_radar_text , rp_radar_type ] } )
2022-10-02 01:36:40 +02:00
# 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 ] } )
# 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 ] } )
# 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 ] } )
# 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 ] } )
2022-08-19 15:43:20 +02:00
###############################################################################
2022-09-26 00:34:39 +02:00
# Documentation Python
2022-08-19 15:43:20 +02:00
###############################################################################
2022-09-14 21:58:33 +02:00
python_card = [ " fonction-card " , " alternative-card " , " boucle-card " ]
# python_card=["fonction-card", "alternative-card", "boucle-card", "liste-card", "dict-card", "poo-card"]
2022-08-21 02:22:56 +02:00
# Fonction
rp_fonction_title = " Fonction "
2022-09-14 21:58:33 +02:00
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 "
2022-10-02 01:36:40 +02:00
rp_fonction_text = rp_fonction_text + " Les arguments sont des données \n transmises à la fonction. "
2022-08-21 02:22:56 +02:00
card_description . update ( { " fonction-card " : [ rp_fonction_title , rp_fonction_text ] } )
# Alternative
rp_alternative_title = " Alternative "
2022-09-14 21:58:33 +02:00
rp_alternative_text = " L ' alternative permet d ' éxécuter des \n instructions en fonction d ' un test. \n "
rp_alternative_text = rp_alternative_text + " Elle se programme en suivant la \n suite : si ... alors ... sinon ... où \n "
rp_alternative_text = rp_alternative_text + " \" si \" est \" if \" et \" sinon \" est \" else \" . \n \n "
rp_alternative_text = rp_alternative_text + " if condition : \n "
rp_alternative_text = rp_alternative_text + " instruction_1 \n "
rp_alternative_text = rp_alternative_text + " else : \n "
rp_alternative_text = rp_alternative_text + " instruction_2 \n \n "
rp_alternative_text = rp_alternative_text + " Le sinon ( \" else \" ) est facultatif. \n \n "
2022-08-21 02:22:56 +02:00
card_description . update ( { " alternative-card " : [ rp_alternative_title , rp_alternative_text ] } )
2022-09-21 07:00:44 +02:00
# Boucles
2022-09-14 21:58:33 +02:00
rp_boucle_title = " Boucles "
rp_boucle_text = " Il y a deux types de boucle : \n - avec \" for \" pour définir un nombre \n de répétition (ici N), \n - avec \" while \" (tant que) pour \n prendre en compte une condition. \n \n "
rp_boucle_text = rp_boucle_text + " for i in range (n) : \n instruction \n \n "
rp_boucle_text = rp_boucle_text + " while condition : \n instruction \n \n "
2022-08-21 02:22:56 +02:00
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 \n orientée objet (POO) "
rp_poo_text = " \n FIXME "
card_description . update ( { " poo-card " : [ rp_poo_title , rp_poo_text ] } )
2022-08-19 15:43:20 +02:00
###############################################################################
# Interface
###############################################################################
##
# Initialisation de la tablette
##
def init ( ) :
2022-09-20 06:40:11 +02:00
# Mettre les couleurs sur les icones (chapitres et cartes)
2022-08-21 02:22:56 +02:00
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
2022-09-20 06:40:11 +02:00
scene . objects [ ' Book_level_button ' ] . color = color_doc_chap
scene . objects [ ' Book_level_button ' ] . setVisible ( False , True )
scene . objects [ " mission_ " + str ( scene . objects [ ' Points ' ] [ ' mission ' ] ) + " -card " ] . color = color_doc_mission
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
2022-08-21 02:22:56 +02:00
# 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
2022-08-21 03:03:11 +02:00
# Page par défaut
scene . objects [ ' Doc ' ] [ ' page_chap ' ] = " general "
##
# Ouvrir la tablette
##
def open ( ) :
2022-08-21 02:22:56 +02:00
# Placer la tablette
2022-08-19 15:43:20 +02:00
# scene.objects['Doc'].worldPosition = [0, -21, 15.75]
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 ' ] . setVisible ( False , True )
scene . objects [ ' Doc_text ' ] . setVisible ( False , True )
2022-08-21 03:03:11 +02:00
# Placer le nouveau chapitre
name_chap = scene . objects [ ' Doc ' ] [ ' page_chap ' ]
scene . objects [ ' Doc- ' + name_chap ] . color = color_doc_activate
scene . objects [ ' Doc- ' + name_chap + ' -text ' ] . color = color_doc_activate
scene . objects [ ' Doc_chap- ' + name_chap ] . worldPosition = scene . objects [ ' Doc ' ] . worldPosition
scene . objects [ ' Doc_chap- ' + name_chap ] . setVisible ( True , True )
2022-09-20 06:40:11 +02:00
# Affichage ou pas du bouton de selection de la mission
2022-08-22 04:41:22 +02:00
if name_chap == " missions " :
2022-09-20 06:40:11 +02:00
name_fct = scene . objects [ ' Doc_chap-missions ' ] [ ' page_fct ' ]
if name_fct != " " :
if scene . objects [ name_fct ] [ ' mission ' ] < = scene . objects [ ' Points ' ] [ ' level ' ] and scene . objects [ name_fct ] [ ' mission ' ] != scene . objects [ ' Points ' ] [ ' mission ' ] :
scene . objects [ ' Book_level_button ' ] . setVisible ( True , True )
else :
scene . objects [ ' Book_level_button ' ] . setVisible ( False , True )
else :
scene . objects [ ' Book_level_button ' ] . setVisible ( False , True )
2022-08-22 04:41:22 +02:00
2022-10-02 01:36:40 +02:00
# 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 ( )
2022-08-21 03:03:11 +02:00
# 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_text ' ] [ ' Text ' ] = card_description [ name_fct ] [ 1 ]
scene . objects [ ' Doc_title ' ] . setVisible ( True , False )
scene . objects [ ' Doc_text ' ] . setVisible ( True , False )
else :
scene . objects [ ' Doc_title ' ] . setVisible ( False , True )
scene . objects [ ' Doc_text ' ] . setVisible ( False , True )
else :
2022-09-20 06:40:11 +02:00
if name_chap != " missions " :
scene . objects [ ' Doc_title ' ] . setVisible ( False , True )
scene . objects [ ' Doc_text ' ] . setVisible ( False , True )
else :
scene . objects [ ' Doc_title ' ] . setVisible ( False , True )
scene . objects [ ' Doc_text ' ] . setVisible ( False , True )
2022-08-19 15:43:20 +02:00
##
# Fermeture du livre
##
def close ( ) :
# sound_play (sndbuff_book_close)
2022-08-21 02:22:56 +02:00
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 ' ]
2022-08-19 15:43:20 +02:00
scene . objects [ ' Doc ' ] . setVisible ( False , True )
scene . objects [ ' Doc ' ] . worldPosition = [ 35 , - 2 , 2 ]
##
# Highlight du livre
##
def hl ( cont ) :
2022-08-21 02:22:56 +02:00
# Activation
2022-08-19 15:43:20 +02:00
if cont . sensors [ ' MO ' ] . status == JUST_ACTIVATED :
obj = cont . owner
name = obj . name [ : - 7 ]
2022-08-21 02:22:56 +02:00
name_text = name + " -text "
name_icon = name + " -icon "
# Close
2022-09-20 06:40:11 +02:00
if name == " Doc_close " or name == " Book_level_button " :
2022-08-19 15:43:20 +02:00
scene . objects [ name ] . color = color_doc_hl
2022-08-21 02:22:56 +02:00
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
2022-08-21 03:03:11 +02:00
name_chap = scene . objects [ ' Doc ' ] [ ' page_chap ' ]
if name == scene . objects [ ' Doc_chap- ' + name_chap ] [ ' page_fct ' ] :
2022-08-21 02:22:56 +02:00
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
2022-08-19 15:43:20 +02:00
if cont . sensors [ ' MO ' ] . status == JUST_RELEASED :
obj = cont . owner
name = obj . name [ : - 7 ]
name_text = obj . name [ : - 7 ] + " -text "
2022-08-20 22:44:17 +02:00
name_icon = obj . name [ : - 7 ] + " -icon "
2022-08-21 02:22:56 +02:00
# Close
2022-09-20 06:40:11 +02:00
if name == " Doc_close " or name == " Book_level_button " :
2022-08-19 15:43:20 +02:00
scene . objects [ name ] . color = color_doc_fct
2022-08-21 02:22:56 +02:00
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
2022-08-21 03:03:11 +02:00
name_chap = scene . objects [ ' Doc ' ] [ ' page_chap ' ]
if name == scene . objects [ ' Doc_chap- ' + name_chap ] [ ' page_fct ' ] :
2022-08-21 02:22:56 +02:00
scene . objects [ name ] . color = color_doc_activate
scene . objects [ name_text ] . color = color_doc_activate
scene . objects [ name_icon ] . color = color_doc_activate
else :
2022-09-20 06:40:11 +02:00
if name == " mission_ " + str ( scene . objects [ ' Points ' ] [ ' mission ' ] ) + " -card " :
2022-08-22 21:56:46 +02:00
scene . objects [ name ] . color = color_doc_mission
scene . objects [ name_text ] . color = color_doc_mission
scene . objects [ name_icon ] . color = color_doc_mission
else :
scene . objects [ name ] . color = color_doc_fct
scene . objects [ name_text ] . color = color_doc_fct
scene . objects [ name_icon ] . color = color_doc_fct
2022-08-19 15:43:20 +02:00
##
# Afficher le chapitre
##
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
2022-08-21 02:22:56 +02:00
# 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
2022-08-19 15:43:20 +02:00
scene . objects [ ' Doc_chap- ' + name_chap ] . worldPosition = scene . objects [ ' Doc ' ] . worldPosition
scene . objects [ ' Doc_chap- ' + name_chap ] . setVisible ( True , True )
2022-08-21 03:03:11 +02:00
2022-09-20 06:40:11 +02:00
# Bouton de selection de la mission
2022-08-22 04:41:22 +02:00
if name_chap == " missions " :
2022-09-20 06:40:11 +02:00
name_fct = scene . objects [ ' Doc_chap-missions ' ] [ ' page_fct ' ]
if name_fct != " " :
if scene . objects [ name_fct ] [ ' mission ' ] < = scene . objects [ ' Points ' ] [ ' level ' ] and scene . objects [ name_fct ] [ ' mission ' ] != scene . objects [ ' Points ' ] [ ' mission ' ] :
scene . objects [ ' Book_level_button ' ] . setVisible ( True , True )
else :
scene . objects [ ' Book_level_button ' ] . setVisible ( False , True )
else :
scene . objects [ ' Book_level_button ' ] . setVisible ( False , True )
2022-08-22 04:41:22 +02:00
2022-10-02 01:36:40 +02:00
# 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 ( )
2022-08-21 03:03:11 +02:00
# 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_text ' ] [ ' Text ' ] = card_description [ name_fct ] [ 1 ]
scene . objects [ ' Doc_title ' ] . setVisible ( True , False )
scene . objects [ ' Doc_text ' ] . setVisible ( True , False )
else :
scene . objects [ ' Doc_title ' ] . setVisible ( False , True )
scene . objects [ ' Doc_text ' ] . setVisible ( False , True )
else :
scene . objects [ ' Doc_title ' ] . setVisible ( False , True )
scene . objects [ ' Doc_text ' ] . setVisible ( False , True )
2022-08-21 02:22:56 +02:00
2022-08-19 15:43:20 +02:00
##
# Afficher les details de la fonction à partir d'une carte
##
def card ( cont ) :
if cont . sensors [ ' Click ' ] . status == JUST_ACTIVATED and cont . sensors [ ' MO ' ] . positive :
2022-08-20 22:44:17 +02:00
# sound_play (sndbuff_book_flip)
2022-08-19 15:43:20 +02:00
obj = cont . owner
2022-08-21 03:03:11 +02:00
name_chap = scene . objects [ ' Doc ' ] [ ' page_chap ' ]
2022-08-21 02:22:56 +02:00
name_fct = obj . name [ : - 7 ]
2022-09-14 21:58:33 +02:00
scene . objects [ ' Doc_title ' ] [ ' Text ' ] = " "
scene . objects [ ' Doc_text ' ] [ ' Text ' ] = " "
2022-08-21 02:22:56 +02:00
# Enlever l'ancienne carte
2022-08-21 03:03:11 +02:00
if scene . objects [ ' Doc_chap- ' + name_chap ] [ ' page_fct ' ] != " " :
2022-08-22 21:56:46 +02:00
# Placer la carte de la mission active
2022-09-20 06:40:11 +02:00
if scene . objects [ ' Doc_chap- ' + name_chap ] [ ' page_fct ' ] == " mission_ " + str ( scene . objects [ ' Points ' ] [ ' mission ' ] ) + " -card " :
2022-08-22 21:56:46 +02:00
scene . objects [ scene . objects [ ' Doc_chap- ' + name_chap ] [ ' page_fct ' ] ] . color = color_doc_mission
scene . objects [ scene . objects [ ' Doc_chap- ' + name_chap ] [ ' page_fct ' ] + ' -text ' ] . color = color_doc_mission
scene . objects [ scene . objects [ ' Doc_chap- ' + name_chap ] [ ' page_fct ' ] + ' -icon ' ] . color = color_doc_mission
else :
scene . objects [ scene . objects [ ' Doc_chap- ' + name_chap ] [ ' page_fct ' ] ] . color = color_doc_fct
scene . objects [ scene . objects [ ' Doc_chap- ' + name_chap ] [ ' page_fct ' ] + ' -text ' ] . color = color_doc_fct
scene . objects [ scene . objects [ ' Doc_chap- ' + name_chap ] [ ' page_fct ' ] + ' -icon ' ] . color = color_doc_fct
2022-08-21 02:22:56 +02:00
# Afficher le texte de la carte
2022-08-21 03:03:11 +02:00
scene . objects [ ' Doc_chap- ' + name_chap ] [ ' page_fct ' ] = name_fct
2022-08-21 02:22:56 +02:00
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 )
2022-08-19 15:43:20 +02:00
2022-09-20 06:40:11 +02:00
# Sélection de la mission
if " mission_ " in name_fct :
if scene . objects [ name_fct ] [ ' mission ' ] < = scene . objects [ ' Points ' ] [ ' level ' ] and scene . objects [ name_fct ] [ ' mission ' ] != scene . objects [ ' Points ' ] [ ' mission ' ] :
scene . objects [ ' Book_level_button ' ] . setVisible ( True , True )
else :
scene . objects [ ' Book_level_button ' ] . setVisible ( False , True )
##
# Sélectionner le niveau
##
def level_button ( cont ) :
if cont . sensors [ ' Click ' ] . status == JUST_ACTIVATED and cont . sensors [ ' MO ' ] . positive :
# sound_play (sndbuff_book_flip)
obj = cont . owner
name_fct = scene . objects [ ' Doc_chap-missions ' ] [ ' page_fct ' ]
if name_fct != " " :
mission_select = scene . objects [ name_fct ] [ ' mission ' ]
if mission_select < = scene . objects [ ' Points ' ] [ ' level ' ] and mission_select != scene . objects [ ' Points ' ] [ ' mission ' ] :
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
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 ' ] )
scene . objects [ ' Book_level_button ' ] . setVisible ( False , True )
2022-08-19 15:43:20 +02:00
##
# Sounds
##
def sound_play ( sound ) :
pass # FIXME
# if scene.objects['Commands']['sound']:
# audiodev.play(sound)