mirror of
https://forge.apps.education.fr/blender-edutech/ropy.git
synced 2024-01-27 08:23:20 +01:00
Ajout du nombre de pas et du nombre de lignes
This commit is contained in:
parent
3abb52deed
commit
6272f95926
BIN
ropy-09.blend
Normal file
BIN
ropy-09.blend
Normal file
Binary file not shown.
9
rp.py
9
rp.py
@ -172,7 +172,6 @@ def terrain_init ():
|
||||
def terrain_run ():
|
||||
|
||||
# Pause
|
||||
# FIXME : HL alors que c'est avec les touches
|
||||
if scene.objects['Terrain']['run'] == True:
|
||||
scene.objects['Terrain']['run']=False
|
||||
scene.objects['Pause'].setVisible(False,False)
|
||||
@ -182,7 +181,6 @@ def terrain_run ():
|
||||
scene.objects['Run-Hl'].setVisible(True,False)
|
||||
|
||||
# Run
|
||||
# FIXME : HL alors que c'est avec les touches
|
||||
else :
|
||||
scene.objects['Terrain']['run']=True
|
||||
scene.objects['Run'].setVisible(False,False)
|
||||
@ -196,6 +194,13 @@ def terrain_run ():
|
||||
scene.objects['Terrain']['thread_cmd']=True
|
||||
rp_map.map_reset()
|
||||
time.sleep(0.25)
|
||||
|
||||
# Nombre de ligne du script Python
|
||||
# print (os.getcwd())
|
||||
file = open('rp_cmd.py', 'r')
|
||||
file_txt = file.read()
|
||||
scene.objects['Points']['nbligne'] = len(file_txt.split("\n"))-28 # 28 lignes utilisées de base
|
||||
file.close()
|
||||
runpy.run_module('rp_cmd', run_name='start') # Execution du script utilisateur
|
||||
|
||||
# Arrêt de la pause
|
||||
|
48
rp_cmd.py
48
rp_cmd.py
@ -3,7 +3,7 @@ from rp_lib import * # Bibliothèque Ropy
|
||||
|
||||
###############################################################################
|
||||
# rp_cmd.py
|
||||
# @title: Commandes du Robot Ropy
|
||||
# @title: Commandes pour le Rover Ropy
|
||||
# @project: Ropy (Blender-EduTech)
|
||||
###############################################################################
|
||||
|
||||
@ -19,42 +19,23 @@ def mrp_avancer():
|
||||
# Commandes
|
||||
###############################################################################
|
||||
|
||||
def commands():
|
||||
def commandes():
|
||||
|
||||
print("Go !!")
|
||||
# rp_marquer() # A tendance au plantage
|
||||
|
||||
rp_gauche()
|
||||
mrp_avancer()
|
||||
mrp_avancer()
|
||||
|
||||
rp_droite()
|
||||
mrp_avancer()
|
||||
mrp_avancer()
|
||||
mrp_avancer()
|
||||
mrp_avancer()
|
||||
mrp_avancer()
|
||||
mrp_avancer()
|
||||
|
||||
rp_avancer()
|
||||
rp_droite()
|
||||
rp_marquer()
|
||||
mrp_avancer()
|
||||
rp_marquer()
|
||||
mrp_avancer()
|
||||
rp_marquer()
|
||||
mrp_avancer()
|
||||
mrp_avancer()
|
||||
rp_droite()
|
||||
mrp_avancer()
|
||||
mrp_avancer()
|
||||
|
||||
rp_droite()
|
||||
rp_droite()
|
||||
mrp_avancer()
|
||||
mrp_avancer()
|
||||
mrp_avancer()
|
||||
mrp_avancer()
|
||||
|
||||
rp_droite()
|
||||
mrp_avancer()
|
||||
mrp_avancer()
|
||||
mrp_avancer()
|
||||
mrp_avancer()
|
||||
mrp_avancer()
|
||||
mrp_avancer()
|
||||
mrp_avancer()
|
||||
mrp_avancer()
|
||||
|
||||
|
||||
rp_fin()
|
||||
|
||||
@ -64,7 +45,6 @@ def commands():
|
||||
###############################################################################
|
||||
|
||||
if __name__=='start':
|
||||
thread_cmd_start(commands)
|
||||
thread_cmd_start(commandes)
|
||||
if __name__=='stop':
|
||||
thread_cmd_stop()
|
||||
|
||||
|
@ -1,11 +1,11 @@
|
||||
<data>
|
||||
<config>
|
||||
<speed>4.0</speed>
|
||||
<speed>1.0</speed>
|
||||
<sound>True</sound>
|
||||
<cam>
|
||||
<worldPosition.x>-7.034218788146973</worldPosition.x>
|
||||
<worldPosition.y>-10.528145790100098</worldPosition.y>
|
||||
<worldPosition.z>12.590240478515625</worldPosition.z>
|
||||
<worldPosition.x>-7.927214622497559</worldPosition.x>
|
||||
<worldPosition.y>-9.915717124938965</worldPosition.y>
|
||||
<worldPosition.z>10.973342895507812</worldPosition.z>
|
||||
</cam>
|
||||
</config>
|
||||
<mission>
|
||||
|
@ -4,7 +4,7 @@ import rp_map1 # Map definition
|
||||
|
||||
###############################################################################
|
||||
# rp_doc.py
|
||||
# @title: Documentation du Robot Ropy
|
||||
# @title: Documentation du Rover Ropy
|
||||
# @project: Ropy (Blender-EduTech)
|
||||
# @lang: fr
|
||||
# @authors: Philippe Roy <philippe.roy@ac-grenoble.fr>
|
||||
|
@ -10,7 +10,7 @@ import random
|
||||
|
||||
###############################################################################
|
||||
# rp_lib.py
|
||||
# @title: Bibliothèque du Robot Ropy (rp_*)
|
||||
# @title: Bibliothèque du Rover Ropy (rp_*)
|
||||
# @project: Ropy (Blender-EduTech)
|
||||
# @lang: fr
|
||||
# @authors: Philippe Roy <philippe.roy@ac-grenoble.fr>
|
||||
@ -18,7 +18,6 @@ import random
|
||||
# @license: GNU GPL
|
||||
#
|
||||
# Bibliothèque des actions du robot
|
||||
# Bibliothèque pour la construction des murs
|
||||
#
|
||||
# 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.
|
||||
@ -179,6 +178,7 @@ def sound_play (sound):
|
||||
|
||||
def rp_avancer ():
|
||||
print ("rp_avancer()")
|
||||
scene.objects['Points']['step'] +=1
|
||||
step =1
|
||||
obj=scene.objects['Rover']
|
||||
# print (obj.worldOrientation.to_euler().z)
|
||||
@ -201,6 +201,7 @@ def rp_avancer ():
|
||||
|
||||
def rp_gauche ():
|
||||
print ("rp_gauche()")
|
||||
scene.objects['Points']['step'] +=1
|
||||
step=math.pi/2 # Pas angulaire
|
||||
obj=scene.objects['Rover']
|
||||
obj.applyRotation((0, 0, step), True)
|
||||
@ -212,6 +213,7 @@ def rp_gauche ():
|
||||
|
||||
def rp_droite ():
|
||||
print ("rp_droite()")
|
||||
scene.objects['Points']['step'] +=1
|
||||
step=math.pi/2 # Pas angulaire
|
||||
obj=scene.objects['Rover']
|
||||
obj.applyRotation((0, 0, -step), True)
|
||||
@ -222,8 +224,9 @@ def rp_droite ():
|
||||
##
|
||||
|
||||
def rp_marquer ():
|
||||
rp_tempo (0.1)
|
||||
print ("rp_marquer()")
|
||||
scene.objects['Points']['step'] +=1
|
||||
rp_tempo (0.1)
|
||||
obj=scene.objects['Rover']
|
||||
x = obj.worldPosition.x
|
||||
y = obj.worldPosition.y
|
||||
|
Loading…
Reference in New Issue
Block a user