mirror of
https://forge.apps.education.fr/blender-edutech/ropy.git
synced 2024-01-27 08:23:20 +01:00
Ajout du store.
This commit is contained in:
parent
c180fe5033
commit
47996c5f85
BIN
ropy-19.blend
Normal file
BIN
ropy-19.blend
Normal file
Binary file not shown.
20
rp.py
20
rp.py
@ -54,20 +54,6 @@ fps_time=0.0
|
||||
rp_config = ET.parse('rp_config.xml')
|
||||
rp_config_tree = rp_config.getroot()
|
||||
|
||||
# Colors
|
||||
color_magenta = (0.800, 0.005, 0.315,1)
|
||||
color_orange = (0.799, 0.130, 0.063,1)
|
||||
color_white = (0.8, 0.8, 0.8, 1)
|
||||
color_yellow = (0.8, 0.619, 0.021, 1)
|
||||
color_black = (0, 0, 0, 1)
|
||||
|
||||
color_kaykit_black = (0.019, 0.032, 0.037, 1)
|
||||
|
||||
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)
|
||||
|
||||
# Sounds
|
||||
audiodev = aud.Device()
|
||||
snd_click = aud.Sound('asset/sounds/rp_click.ogg')
|
||||
@ -370,6 +356,7 @@ 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['Store-cmd-Hl'].setVisible(False,False)
|
||||
scene.objects['ResetView-Hl'].setVisible(False,False)
|
||||
scene.objects['About-cmd-Hl'].setVisible(False,False)
|
||||
|
||||
@ -464,6 +451,7 @@ def cmd_hl(cont):
|
||||
"Pause":"Pause (F5)",
|
||||
"Aim-cmd":"Afficher/cacher l'objectif",
|
||||
"Doc-cmd":"Documentation",
|
||||
"Store-cmd":"Magasin",
|
||||
"ResetView": "Reset de la vue (Touche Début)",
|
||||
"About-cmd": "A propos",
|
||||
"Speed_down": "Moins vite (-)",
|
||||
@ -553,6 +541,10 @@ def cmd_click (cont):
|
||||
if obj.name=="About-cmd":
|
||||
sound_play (snd_open)
|
||||
about_open ()
|
||||
# if obj.name=="Store-cmd":
|
||||
# sound_play (snd_open)
|
||||
# print ("Store")
|
||||
|
||||
|
||||
###############################################################################
|
||||
# Gestion du clavier
|
||||
|
@ -1,15 +1,15 @@
|
||||
<data>
|
||||
<config>
|
||||
<speed>10.0</speed>
|
||||
<speed>4.0</speed>
|
||||
<sound>False</sound>
|
||||
<cam>
|
||||
<worldPosition.x>2.1837825775146484</worldPosition.x>
|
||||
<worldPosition.y>-27.433191299438477</worldPosition.y>
|
||||
<worldPosition.z>21.05629539489746</worldPosition.z>
|
||||
<worldPosition.x>-5.090217113494873</worldPosition.x>
|
||||
<worldPosition.y>-16.436044692993164</worldPosition.y>
|
||||
<worldPosition.z>11.98914909362793</worldPosition.z>
|
||||
</cam>
|
||||
</config>
|
||||
<mission>
|
||||
<current>6</current>
|
||||
<current>4</current>
|
||||
<level>6</level>
|
||||
</mission>
|
||||
</data>
|
68
rp_doc.py
68
rp_doc.py
@ -1,5 +1,4 @@
|
||||
import bge # Bibliothèque Blender Game Engine (UPBGE)
|
||||
import aud # Sounds
|
||||
import rp_map1 # Map definition
|
||||
|
||||
###############################################################################
|
||||
@ -26,15 +25,6 @@ color_doc_hl = (0.799, 0.617, 0.021, 1) # Jaune
|
||||
color_doc_activate = (0.936, 0.033, 1, 1) # Rose
|
||||
color_doc_mission = (1, 0.192, 0.03, 1) # Orange
|
||||
|
||||
# Sounds
|
||||
# audiodev = aud.Device()
|
||||
# snd_book_open = aud.Sound('asset/sounds/book_open.ogg')
|
||||
# sndbuff_book_open = aud.Sound.cache(snd_book_open)
|
||||
# snd_book_close = aud.Sound('asset/sounds/book_close.ogg')
|
||||
# sndbuff_book_close = aud.Sound.cache(snd_book_close)
|
||||
# snd_book_flip = aud.Sound('asset/sounds/book_flip.ogg')
|
||||
# sndbuff_book_flip = aud.Sound.cache(snd_book_flip)
|
||||
|
||||
# UPBGE constants
|
||||
JUST_ACTIVATED = bge.logic.KX_INPUT_JUST_ACTIVATED
|
||||
JUST_RELEASED = bge.logic.KX_INPUT_JUST_RELEASED
|
||||
@ -48,46 +38,70 @@ card_description ={}
|
||||
card_description.update(rp_map1.get_card_description())
|
||||
missions_card=rp_map1.get_missions_card()
|
||||
|
||||
###############################################################################
|
||||
# Rover
|
||||
###############################################################################
|
||||
################################################################################
|
||||
# Documentation Rover
|
||||
################################################################################
|
||||
|
||||
rover_card=["avancer-card", "tourner-card", "baliser-card", "detecter-card"]
|
||||
# rover_card=["avancer-card", "tourner-card", "baliser-card", "prendre-card", "detecter-card", "radar-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"]
|
||||
|
||||
# Avancer
|
||||
rp_avancer_title="Avancer"
|
||||
rp_avancer_text=" rp_avancer() \n -> Avance d'un pas en avant."
|
||||
card_description.update({"avancer-card" : [rp_avancer_title, rp_avancer_text]})
|
||||
rp_avancer_type="standard"
|
||||
card_description.update({"avancer-card" : [rp_avancer_title, rp_avancer_text, rp_avancer_type]})
|
||||
|
||||
# Tourner
|
||||
rp_tourner_title="Tourner"
|
||||
rp_tourner_text=" rp_gauche() \n -> Tourne à gauche (90°).\n \n"
|
||||
rp_tourner_text=rp_tourner_text + " rp_droite() \n -> Tourne à droite (90°)."
|
||||
card_description.update({"tourner-card" : [rp_tourner_title, rp_tourner_text]})
|
||||
rp_tourner_type="standard"
|
||||
card_description.update({"tourner-card" : [rp_tourner_title, rp_tourner_text, rp_tourner_type]})
|
||||
|
||||
# Baliser
|
||||
rp_baliser_title="Baliser"
|
||||
rp_baliser_text=" rp_marquer() \n -> Place une balise sur la case. \n \n Ropy possède que 150 balises, \n il ne peut pas en poser plus."
|
||||
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]})
|
||||
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]})
|
||||
|
||||
# Détecter
|
||||
rp_detecter_title="Détecter"
|
||||
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."
|
||||
card_description.update({"detecter-card" : [rp_detecter_title, rp_detecter_text]})
|
||||
rp_detecter_type="standard"
|
||||
card_description.update({"detecter-card" : [rp_detecter_title, rp_detecter_text, rp_detecter_type]})
|
||||
|
||||
# Radar
|
||||
rp_radar_title="Radar"
|
||||
rp_radar_text="FIXME"
|
||||
card_description.update({"radar-card" : [rp_radar_title, rp_radar_text]})
|
||||
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]})
|
||||
|
||||
# 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]})
|
||||
|
||||
# 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]})
|
||||
|
||||
# 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]})
|
||||
|
||||
###############################################################################
|
||||
# Python
|
||||
# Documentation Python
|
||||
###############################################################################
|
||||
|
||||
python_card=["fonction-card", "alternative-card", "boucle-card"]
|
||||
|
81
rp_lib.py
81
rp_lib.py
@ -29,39 +29,11 @@ import rp_map1 as rp_map # Map definition
|
||||
|
||||
scene = bge.logic.getCurrentScene()
|
||||
|
||||
# Colors
|
||||
purple = (0.202, 0.114, 0.521,1)
|
||||
turquoise = (0.051, 0.270, 0.279,1)
|
||||
magenta = (0.799, 0.005, 0.314,1)
|
||||
orange = (0.799, 0.130, 0.063,1)
|
||||
yellow = (0.799, 0.617, 0.021, 1)
|
||||
green = (0.246, 0.687, 0.078, 1)
|
||||
red = (0.799, 0.031, 0.038, 1)
|
||||
blue = (0.127, 0.456, 1.000, 1)
|
||||
black = (0, 0, 0, 1)
|
||||
|
||||
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)
|
||||
|
||||
# ray_yellow = (0.799, 0.617, 0.021, 1) # [0.8, 0.619, 0.021])
|
||||
# ray_blue = (0.127, 0.456, 1.000, 1)
|
||||
# ray_black = (0, 0, 0, 1)
|
||||
|
||||
color_kaykit_black = (0.019, 0.032, 0.037, 1)
|
||||
|
||||
# Sounds
|
||||
# audiodev = aud.Device()
|
||||
# snd_build = aud.Sound('asset/sounds/build.wav')
|
||||
# sndbuff_build = aud.Sound.cache(snd_build)
|
||||
# snd_archer = aud.Sound('asset/sounds/archer.wav')
|
||||
# sndbuff_archer = aud.Sound.cache(snd_archer)
|
||||
# snd_mage = aud.Sound('asset/sounds/mage.wav')
|
||||
# sndbuff_mage = aud.Sound.cache(snd_mage)
|
||||
# snd_life = aud.Sound('asset/sounds/life.ogg')
|
||||
# sndbuff_life = aud.Sound.cache(snd_life)
|
||||
audiodev = aud.Device()
|
||||
snd_click = aud.Sound('asset/sounds/rp_click.ogg')
|
||||
|
||||
# Threads
|
||||
threads_cmd=[]
|
||||
debug_thread = scene.objects['Terrain']['debug_thread']
|
||||
|
||||
@ -254,7 +226,6 @@ def rp_avancer ():
|
||||
|
||||
# Animation
|
||||
if scene.objects['Commands']['speed'] != 10:
|
||||
# obj['avancer_anim']=True
|
||||
start = 1
|
||||
end = 100
|
||||
layer = 0
|
||||
@ -263,7 +234,7 @@ def rp_avancer ():
|
||||
mode = bge.logic.KX_ACTION_MODE_PLAY
|
||||
layerWeight = 0.0
|
||||
ipoFlags = 0
|
||||
speed = scene.objects['Commands']['speed']*4
|
||||
speed = scene.objects['Commands']['speed']*8
|
||||
if round(obj.worldOrientation.to_euler().z, 2) == 0.00: # Sud
|
||||
obj.playAction('Rover-Avancer-Y-', start, end, layer, priority, blendin, mode, layerWeight, ipoFlags, speed)
|
||||
# obj.worldPosition=[x0, y0-step*i, z0]
|
||||
@ -323,7 +294,7 @@ def rp_gauche ():
|
||||
mode = bge.logic.KX_ACTION_MODE_PLAY
|
||||
layerWeight = 0.0
|
||||
ipoFlags = 0
|
||||
speed = scene.objects['Commands']['speed']*4
|
||||
speed = scene.objects['Commands']['speed']*8
|
||||
obj.playAction('Rover-Gauche', start, end, layer, priority, blendin, mode, layerWeight, ipoFlags, speed)
|
||||
scene.objects['Wheel-right-front'].playAction('Wheel-Avancer', start, end, layer, priority, blendin, mode, layerWeight, ipoFlags, speed)
|
||||
scene.objects['Wheel-right-mid'].playAction('Wheel-Avancer', start, end, layer, priority, blendin, mode, layerWeight, ipoFlags, speed)
|
||||
@ -368,7 +339,7 @@ def rp_droite ():
|
||||
mode = bge.logic.KX_ACTION_MODE_PLAY
|
||||
layerWeight = 0.0
|
||||
ipoFlags = 0
|
||||
speed = scene.objects['Commands']['speed']*4
|
||||
speed = scene.objects['Commands']['speed']*8
|
||||
obj.playAction('Rover-Droite', start, end, layer, priority, blendin, mode, layerWeight, ipoFlags, speed)
|
||||
scene.objects['Wheel-right-front'].playAction('Wheel-Reculer', start, end, layer, priority, blendin, mode, layerWeight, ipoFlags, speed)
|
||||
scene.objects['Wheel-right-mid'].playAction('Wheel-Reculer', start, end, layer, priority, blendin, mode, layerWeight, ipoFlags, speed)
|
||||
@ -634,7 +605,7 @@ def map_aim_near (cont):
|
||||
# if sensor.positive :
|
||||
# print ("Goall !!")
|
||||
# rover_goal()
|
||||
|
||||
|
||||
###############################################################################
|
||||
# Temporisation
|
||||
###############################################################################
|
||||
@ -651,3 +622,41 @@ def rp_tempo (duration):
|
||||
# print("Temporization commands :",scene.objects['Terrain']['delay_cmd'])
|
||||
time.sleep(0.001)
|
||||
# # pass
|
||||
|
||||
###############################################################################
|
||||
# Fonction bas niveau
|
||||
###############################################################################
|
||||
|
||||
##
|
||||
# Atteindre une orientation
|
||||
##
|
||||
|
||||
def applyRotationTo(obj, rx=None, ry=None, rz=None, Local=True):
|
||||
rres=0.001 # resolution rotation
|
||||
|
||||
# x
|
||||
if rx is not None:
|
||||
while (abs(rx-obj.worldOrientation.to_euler().x) > rres) :
|
||||
if obj.worldOrientation.to_euler().x-rx > rres:
|
||||
obj.applyRotation((-rres, 0, 0), Local)
|
||||
if rx-obj.worldOrientation.to_euler().x > rres:
|
||||
obj.applyRotation((rres, 0, 0), Local)
|
||||
# print ("delta x ",rx-obj.worldOrientation.to_euler().x)
|
||||
|
||||
# y
|
||||
if ry is not None:
|
||||
while (abs(ry-obj.worldOrientation.to_euler().y) > rres) :
|
||||
if obj.worldOrientation.to_euler().y-ry > rres:
|
||||
obj.applyRotation((0, -rres, 0), Local)
|
||||
if ry-obj.worldOrientation.to_euler().y > rres:
|
||||
obj.applyRotation((0, rres, 0), Local)
|
||||
# print ("delta y ",ry-obj.worldOrientation.to_euler().y)
|
||||
|
||||
# z
|
||||
if rz is not None:
|
||||
while (abs(rz-obj.worldOrientation.to_euler().z) > rres) :
|
||||
if obj.worldOrientation.to_euler().z-rz > rres:
|
||||
obj.applyRotation((0, 0, -rres), Local)
|
||||
if rz-obj.worldOrientation.to_euler().z > rres:
|
||||
obj.applyRotation((0, 0, rres), Local)
|
||||
# print ("delta z ",rz-obj.worldOrientation.to_euler().z)
|
||||
|
395
rp_store.py
Normal file
395
rp_store.py
Normal file
@ -0,0 +1,395 @@
|
||||
from rp_lib import * # Bibliothèque Ropy
|
||||
|
||||
###############################################################################
|
||||
# rp_store.py
|
||||
# @title: Magasin pour le Rover Ropy
|
||||
# @project: Ropy (Blender-EduTech)
|
||||
# @lang: fr
|
||||
# @authors: Philippe Roy <philippe.roy@ac-grenoble.fr>
|
||||
# @copyright: Copyright (C) 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_store_fct = (0, 1, 0.857,1) # Turquoise
|
||||
color_store_hl = (0.799, 0.617, 0.021, 1) # Jaune
|
||||
color_store_activate = (0.936, 0.033, 1, 1) # Rose
|
||||
color_store_inventory = (1, 0.192, 0.03, 1) # Orange
|
||||
|
||||
# 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
|
||||
|
||||
################################################################################
|
||||
# Documentation
|
||||
################################################################################
|
||||
|
||||
# Cards description pour le magasin
|
||||
storecard_description ={}
|
||||
|
||||
# Vitesse
|
||||
sc_vitesse_title="Vitesse"
|
||||
sc_vitesse_text="Permet de modifier\nla vitesse des \ndéplacements."
|
||||
storecard_description.update({"Store-vitesse-card" : [sc_vitesse_title, sc_vitesse_text]})
|
||||
|
||||
# Peinture
|
||||
sc_peinture_title="Peinture"
|
||||
sc_peinture_text="Permet de changer la \ncouleur des objets."
|
||||
storecard_description.update({"Store-peinture-card" : [sc_peinture_title, sc_peinture_text]})
|
||||
|
||||
# Batterie +
|
||||
sc_batterie_title="Batterie +"
|
||||
sc_batterie_text="Augmente la capacité \nde la batterie à 200 \nmouvements (contre \n50)."
|
||||
storecard_description.update({"Store-batterie-card" : [sc_batterie_title, sc_batterie_text]})
|
||||
|
||||
# Balise +
|
||||
sc_balise_title="Balise +"
|
||||
sc_balise_text="Porte le nombre de \nbasiles transportées\nà 200 (contre 50)."
|
||||
storecard_description.update({"Store-balise-card" : [sc_balise_title, sc_balise_text]})
|
||||
|
||||
################################################################################
|
||||
# Init, open et close
|
||||
################################################################################
|
||||
|
||||
def init (cont):
|
||||
obj=scene.objects['Rover']
|
||||
if cont.sensors['Click'].status == JUST_ACTIVATED and cont.sensors['MO'].positive and scene.objects['Terrain']['manip_mode']==0:
|
||||
sound_play (snd_click)
|
||||
thread_cmd_start(open)
|
||||
|
||||
##
|
||||
# Fermeture
|
||||
##
|
||||
|
||||
def close (cont):
|
||||
pass
|
||||
# obj=scene.objects['Rover']
|
||||
# if cont.sensors['Click'].status == JUST_ACTIVATED and cont.sensors['MO'].positive and scene.objects['Terrain']['manip_mode']==0:
|
||||
# sound_play (snd_click)
|
||||
# thread_cmd_start(store)
|
||||
|
||||
##
|
||||
# Ouverture
|
||||
##
|
||||
|
||||
def open():
|
||||
obj=scene.objects['Rover']
|
||||
|
||||
# Pathfinder pour le store
|
||||
rover_go_store()
|
||||
obj.worldPosition.x = -9.75
|
||||
obj.worldPosition.y = -4
|
||||
obj.worldPosition.z = 0.19
|
||||
|
||||
# Overlay
|
||||
scene.objects['Terrain']['manip_mode']=8 # Fenêtre modale type Doc
|
||||
scene.removeOverlayCollection(bpy.data.collections['Hud'])
|
||||
scene.objects['Points'].setVisible(False,True)
|
||||
scene.objects['Commands'].setVisible(False,True)
|
||||
scene.active_camera = scene.objects["Camera-Store"]
|
||||
scene.objects['Camera'].setVisible(False,True)
|
||||
|
||||
# Animation de la bulle
|
||||
start = 1
|
||||
end = 20
|
||||
layer = 0
|
||||
priority = 1
|
||||
blendin = 1.0
|
||||
mode = bge.logic.KX_ACTION_MODE_PLAY
|
||||
layerWeight = 0.0
|
||||
ipoFlags = 0
|
||||
# speed = scene.objects['Commands']['speed']*4
|
||||
speed = 0.5
|
||||
scene.objects['Bubble-1'].playAction('Bubble-1-ShaderAction', start, end, layer, priority, blendin, mode, layerWeight, ipoFlags, speed)
|
||||
scene.objects['Bubble-1-text'].playAction('Bubble-1-text-ShaderAction', start, end, layer, priority, blendin, mode, layerWeight, ipoFlags, speed)
|
||||
|
||||
# Mise en couleurs
|
||||
scene.objects['Store_close'].color= color_store_fct
|
||||
scene.objects['Store_button'].color= color_store_fct
|
||||
function_card=("balise", "batterie", "peinture", "vitesse")
|
||||
for i in range(len(function_card)):
|
||||
scene.objects["Store-"+function_card[i]+"-card"].color = color_store_fct
|
||||
scene.objects["Store-"+function_card[i]+"-card-icon"].color = color_store_fct
|
||||
scene.objects["Store-"+function_card[i]+"-card-text"].color = color_store_fct
|
||||
scene.objects['Store']['page_fct'] =""
|
||||
scene.objects['Store_text']['Text'] = " "
|
||||
scene.objects['Store_text'].setVisible(False,True)
|
||||
|
||||
# Animation de la tablette
|
||||
scene.objects['Store'].setVisible(True,True)
|
||||
scene.objects['Store'].worldPosition = [-12.25, -2.7, 0.4]
|
||||
scene.objects['Store'].worldScale = [0.01, 0.01, 0.01]
|
||||
# applyRotationTo(scene.objects['Store'], None, (-0.2*math.pi)/180, (115*math.pi)/180, False)
|
||||
applyRotationTo(scene.objects['Store'], None, (-2.38*math.pi)/180, (100*math.pi)/180, False)
|
||||
# scene.objects['Store'].applyRotation((math.pi/2+(0.59189*math.pi)/180, 0, 0), True)
|
||||
scene.objects['Store'].applyRotation((math.pi/2+(3*math.pi)/180, 0, 0), True)
|
||||
scene.objects['Store']['timer'] = 0
|
||||
scene.objects['Store']['anim'] = True
|
||||
|
||||
##
|
||||
# Animation du store
|
||||
##
|
||||
|
||||
def open_anim():
|
||||
resol=100
|
||||
x0 = -10.1722
|
||||
y0 = -2.68957
|
||||
z0 =0.42148
|
||||
x1 = -9.05968
|
||||
y1 = -5.01656
|
||||
z1= 0.521224
|
||||
xi = x0+((x1-x0)/resol)*scene.objects['Store']['timer']
|
||||
yi = y0+((y1-y0)/resol)*scene.objects['Store']['timer']
|
||||
zi = z0+((z1-z0)/resol)*scene.objects['Store']['timer']
|
||||
scale0=0.01
|
||||
# scale1=0.169
|
||||
scale1=0.2
|
||||
scalei = scale0+((scale1-scale0)/resol)*scene.objects['Store']['timer']
|
||||
scene.objects['Store'].worldPosition = [xi, yi, zi]
|
||||
scene.objects['Store'].worldScale = [scalei, scalei, scalei]
|
||||
scene.objects['Store']['timer']+=1
|
||||
# print ("Store : timer", scene.objects['Store']['timer'], xi, yi, zi, scalei)
|
||||
if scene.objects['Store']['timer']== resol:
|
||||
scene.objects['Store']['anim'] = False
|
||||
|
||||
###############################################################################
|
||||
# Interface
|
||||
###############################################################################
|
||||
|
||||
##
|
||||
# Highlight du store
|
||||
##
|
||||
|
||||
def hl (cont):
|
||||
|
||||
# Activation
|
||||
if cont.sensors['MO'].status == JUST_ACTIVATED :
|
||||
obj = cont.owner
|
||||
name=obj.name[:-7]
|
||||
print(name)
|
||||
name_text=name+"-text"
|
||||
name_icon=name+"-icon"
|
||||
scene.objects[name].color = color_store_hl
|
||||
|
||||
# Close et button
|
||||
if name == "Store_close" or name == "Store_button":
|
||||
scene.objects[name].color = color_store_hl
|
||||
else:
|
||||
scene.objects[name].color = color_store_hl
|
||||
scene.objects[name_text].color = color_store_hl
|
||||
scene.objects[name_icon].color = color_store_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"
|
||||
|
||||
# Close et button
|
||||
if name == "Store_close" or name == "Store_button":
|
||||
scene.objects[name].color = color_store_fct
|
||||
else:
|
||||
if name == scene.objects['Store']['page_fct'] :
|
||||
scene.objects[name].color = color_store_activate
|
||||
scene.objects[name_text].color = color_store_activate
|
||||
scene.objects[name_icon].color = color_store_activate
|
||||
else:
|
||||
scene.objects[name].color = color_store_fct
|
||||
scene.objects[name_text].color = color_store_fct
|
||||
scene.objects[name_icon].color = color_store_fct
|
||||
|
||||
##
|
||||
# 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 :
|
||||
obj = cont.owner
|
||||
name_fct= obj.name[:-7]
|
||||
scene.objects['Store_text']['Text'] = " "
|
||||
|
||||
# Enlever l'ancienne carte
|
||||
if scene.objects['Store']['page_fct'] !="":
|
||||
scene.objects[scene.objects['Store']['page_fct']].color = color_store_fct
|
||||
scene.objects[scene.objects['Store']['page_fct']+'-text'].color = color_store_fct
|
||||
scene.objects[scene.objects['Store']['page_fct']+'-icon'].color = color_store_fct
|
||||
|
||||
# Afficher le texte de la carte
|
||||
scene.objects['Store']['page_fct'] = name_fct
|
||||
scene.objects[name_fct].color = color_store_activate
|
||||
scene.objects[name_fct+'-icon'].color = color_store_activate
|
||||
scene.objects[name_fct+'-text'].color = color_store_activate
|
||||
scene.objects['Store_text']['Text'] = storecard_description[name_fct][1]
|
||||
scene.objects['Store_text'].setVisible(True, False)
|
||||
|
||||
###############################################################################
|
||||
# Rover
|
||||
###############################################################################
|
||||
|
||||
##
|
||||
# Direction
|
||||
##
|
||||
|
||||
def rover_dir (direction):
|
||||
obj=scene.objects['Rover']
|
||||
step=math.pi/2 # Pas angulaire
|
||||
# print ("rover_dir : ",direction)
|
||||
|
||||
# Nord
|
||||
if direction=="n":
|
||||
if round(obj.worldOrientation.to_euler().z, 2) == 0.00: # Sud
|
||||
rp_gauche()
|
||||
rp_gauche()
|
||||
elif round(obj.worldOrientation.to_euler().z, 2) == round(math.pi,2) or round(obj.worldOrientation.to_euler().z, 2) == - round(math.pi,2) : # Nord
|
||||
pass
|
||||
elif round(obj.worldOrientation.to_euler().z, 2) == round(math.pi/2,2) or round(obj.worldOrientation.to_euler().z, 2) == -round(3*(math.pi/2),2) : # Est
|
||||
rp_gauche()
|
||||
elif round(obj.worldOrientation.to_euler().z, 2) == round(-math.pi/2,2) or round(obj.worldOrientation.to_euler().z, 2) == round(3*(math.pi/2),2) : # Ouest
|
||||
rp_droite()
|
||||
|
||||
# Sud
|
||||
if direction=="s":
|
||||
if round(obj.worldOrientation.to_euler().z, 2) == 0.00: # Sud
|
||||
pass
|
||||
elif round(obj.worldOrientation.to_euler().z, 2) == round(math.pi,2) or round(obj.worldOrientation.to_euler().z, 2) == - round(math.pi,2) : # Nord
|
||||
rp_gauche()
|
||||
rp_gauche()
|
||||
elif round(obj.worldOrientation.to_euler().z, 2) == round(math.pi/2,2) or round(obj.worldOrientation.to_euler().z, 2) == -round(3*(math.pi/2),2) : # Est
|
||||
rp_droite()
|
||||
elif round(obj.worldOrientation.to_euler().z, 2) == round(-math.pi/2,2) or round(obj.worldOrientation.to_euler().z, 2) == round(3*(math.pi/2),2) : # Ouest
|
||||
rp_gauche()
|
||||
|
||||
# Est
|
||||
if direction=="e":
|
||||
if round(obj.worldOrientation.to_euler().z, 2) == 0.00: # Sud
|
||||
rp_gauche()
|
||||
elif round(obj.worldOrientation.to_euler().z, 2) == round(math.pi,2) or round(obj.worldOrientation.to_euler().z, 2) == - round(math.pi,2) : # Nord
|
||||
rp_droite()
|
||||
elif round(obj.worldOrientation.to_euler().z, 2) == round(math.pi/2,2) or round(obj.worldOrientation.to_euler().z, 2) == -round(3*(math.pi/2),2) : # Est
|
||||
pass
|
||||
elif round(obj.worldOrientation.to_euler().z, 2) == round(-math.pi/2,2) or round(obj.worldOrientation.to_euler().z, 2) == round(3*(math.pi/2),2) : # Ouest
|
||||
rp_gauche()
|
||||
rp_gauche()
|
||||
|
||||
# Ouest
|
||||
if direction=="o":
|
||||
if round(obj.worldOrientation.to_euler().z, 2) == 0.00: # Sud
|
||||
rp_droite()
|
||||
elif round(obj.worldOrientation.to_euler().z, 2) == round(math.pi,2) or round(obj.worldOrientation.to_euler().z, 2) == - round(math.pi,2) : # Nord
|
||||
rp_gauche()
|
||||
elif round(obj.worldOrientation.to_euler().z, 2) == round(math.pi/2,2) or round(obj.worldOrientation.to_euler().z, 2) == -round(3*(math.pi/2),2) : # Est
|
||||
rp_gauche()
|
||||
rp_gauche()
|
||||
elif round(obj.worldOrientation.to_euler().z, 2) == round(-math.pi/2,2) or round(obj.worldOrientation.to_euler().z, 2) == round(3*(math.pi/2),2) : # Ouest
|
||||
pass
|
||||
|
||||
##
|
||||
# Avancer pas
|
||||
##
|
||||
|
||||
def rover_avancer_nbpas(pas):
|
||||
for i in range (int(pas)):
|
||||
rp_avancer()
|
||||
|
||||
def rover_dir_nbpas(direction, pas):
|
||||
if pas>0:
|
||||
rover_dir (direction)
|
||||
rover_avancer_nbpas(pas)
|
||||
|
||||
##
|
||||
# Pathfinder pour le store
|
||||
##
|
||||
|
||||
def rover_go_store():
|
||||
obj=scene.objects['Rover']
|
||||
# print("Go store !!")
|
||||
|
||||
# Pathfinder : debug
|
||||
obj.worldPosition.x=-13
|
||||
obj.worldPosition.y=-8
|
||||
|
||||
x0 = obj.worldPosition.x
|
||||
y0 = obj.worldPosition.y
|
||||
z0 = obj.worldPosition.z
|
||||
# print ("Position actuelle :", x0, y0)
|
||||
|
||||
# Pathfinder : zone 1
|
||||
if x0<=-10 and (y0==2 or y0==3):
|
||||
# print ("Store : zone 1 -> -8;4")
|
||||
rover_dir_nbpas("n",4-y0)
|
||||
rover_dir_nbpas("e",-x0-8)
|
||||
x0 = obj.worldPosition.x
|
||||
y0 = obj.worldPosition.y
|
||||
# print ("Position actuelle :", x0, y0)
|
||||
|
||||
# Pathfinder : zone 2
|
||||
if x0<=-9 and y0>=4:
|
||||
# print ("Store : zone 2 -> -8;4")
|
||||
rover_dir_nbpas("e",-x0-8)
|
||||
rover_dir_nbpas("s",y0-4)
|
||||
x0 = obj.worldPosition.x
|
||||
y0 = obj.worldPosition.y
|
||||
# print ("Position actuelle :", x0, y0)
|
||||
|
||||
# Pathfinder : zone 3
|
||||
if x0==-9 and y0==1:
|
||||
# print ("Store : zone 3 -> -8;4")
|
||||
rover_dir_nbpas("e",1)
|
||||
x0 = obj.worldPosition.x
|
||||
y0 = obj.worldPosition.y
|
||||
# print ("Position actuelle :", x0, y0)
|
||||
|
||||
# Pathfinder : zone 4
|
||||
if x0>=14 and y0<=-1:
|
||||
# print ("Store : zone 4 -> x;0")
|
||||
rover_dir_nbpas("n",-y0)
|
||||
x0 = obj.worldPosition.x
|
||||
y0 = obj.worldPosition.y
|
||||
# print ("Position actuelle :", x0, y0)
|
||||
|
||||
# Pathfinder : zone 5
|
||||
if x0>=-8 and y0>=0:
|
||||
# print ("Store : zone 5 -> -8;0 puis -8;-1")
|
||||
rover_dir_nbpas("s",y0)
|
||||
rover_dir_nbpas("o",8+x0)
|
||||
rover_dir_nbpas("s",1)
|
||||
x0 = obj.worldPosition.x
|
||||
y0 = obj.worldPosition.y
|
||||
# print ("Position actuelle :", x0, y0)
|
||||
|
||||
# Pathfinder : zone 6
|
||||
if y0>=-4:
|
||||
# print ("Store : zone 6 -> -10;-4")
|
||||
rover_dir_nbpas("s",y0+4)
|
||||
rover_dir_nbpas("o",10+x0)
|
||||
x0 = obj.worldPosition.x
|
||||
y0 = obj.worldPosition.y
|
||||
# print ("Position actuelle :", x0, y0)
|
||||
|
||||
# Pathfinder : zone 7
|
||||
if x0<=-11 and y0<=-5:
|
||||
# print ("Store : zone 7 -> -10;y")
|
||||
rover_dir_nbpas("e",-x0-10)
|
||||
x0 = obj.worldPosition.x
|
||||
y0 = obj.worldPosition.y
|
||||
# print ("Position actuelle :", x0, y0)
|
||||
|
||||
# Pathfinder : zone 8
|
||||
if y0<=-5:
|
||||
# print ("Store : zone 8 -> -10;-4")
|
||||
rover_dir_nbpas("n",-y0-4)
|
||||
rover_dir_nbpas("o",10+x0)
|
||||
x0 = obj.worldPosition.x
|
||||
y0 = obj.worldPosition.y
|
||||
# print ("Position actuelle :", x0, y0)
|
||||
|
||||
rover_dir ("o")
|
Loading…
x
Reference in New Issue
Block a user