Correction de la rotation en Z lors de la manipulation clavier et changement du nom des fichiers sur les briques logiques

This commit is contained in:
Philippe Roy 2023-04-30 04:21:49 +02:00
parent b520be6352
commit 8a12c765a3
9 changed files with 21 additions and 21 deletions

View File

@ -3,7 +3,7 @@ import bge # Bibliothèque Blender Game Engine (BGE)
###############################################################################
# 2-labyrinthe.py
# @title: Module (unique) de la scène 3D du labyrinthe à bille
# @project: Blender-EduTech - Tutoriel : Tutoriel 2 Labyrinthe à bille - Passage au Python
# @project: Blender-EduTech - Tutoriel 2 : Labyrinthe à bille - Passage au Python
# @lang: fr
# @authors: Philippe Roy <philippe.roy@ac-grenoble.fr>
# @copyright: Copyright (C) 2023 Philippe Roy
@ -36,19 +36,19 @@ def clavier(cont):
# Flèche haut - Up arrow
if keyboard.inputs[bge.events.UPARROWKEY].status[0] == ACTIVATE:
obj.applyRotation((-resolution,0,0), False)
obj.applyRotation((-resolution,0,-obj.worldOrientation.to_euler().z), False)
# Flèche bas - Down arrow
if keyboard.inputs[bge.events.DOWNARROWKEY].status[0] == ACTIVATE:
obj.applyRotation((resolution,0,0), False)
obj.applyRotation((resolution,0,-obj.worldOrientation.to_euler().z), False)
# Flèche gauche - Left arrow
if keyboard.inputs[bge.events.LEFTARROWKEY].status[0] == ACTIVATE:
obj.applyRotation((0, -resolution,0), False)
obj.applyRotation((0, -resolution,-obj.worldOrientation.to_euler().z), False)
# Flèche droit - Right arrow
if keyboard.inputs[bge.events.RIGHTARROWKEY].status[0] == ACTIVATE:
obj.applyRotation((0, resolution,0), False)
obj.applyRotation((0, resolution, -obj.worldOrientation.to_euler().z), False)
###############################################################################
# Gameplay

View File

@ -2,9 +2,9 @@ import bge # Bibliothèque Blender Game Engine (BGE)
import pyfirmata # Protocole Firmata
###############################################################################
# 3-labyrinthe-manette.py
# @title: Module (unique) de la scène 3D du labyrinthe à bille pilotable avec la manette
# @project: Blender-EduTech - Tutoriel : Tutoriel 3 Labyrinthe à bille - Interfacer avec une carte Arduino
# 3-labyrinthe.py
# @title: Module (unique) de la scène 3D du labyrinthe à bille pilotable avec une "manette Grove"
# @project: Blender-EduTech - Tutoriel 3 : Labyrinthe à bille - Interfacer avec une carte Arduino par le protocole Firmata
# @lang: fr
# @authors: Philippe Roy <philippe.roy@ac-grenoble.fr>
# @copyright: Copyright (C) 2023 Philippe Roy
@ -29,7 +29,7 @@ ACTIVATE = bge.logic.KX_INPUT_ACTIVE
###############################################################################
# carte = pyfirmata.Arduino('COM4') # Windows
carte = pyfirmata.Arduino('/dev/ttyACM0') # GNU/Linux
carte = pyfirmata.Arduino('/dev/ttyACM1') # GNU/Linux
print("Communication Carte Arduino établie")
# Iterateur pour les entrees
@ -54,19 +54,19 @@ def manette(cont):
# Bouton haut - Broche 2
if bt_haut.read() == True and bt_bas.read() == False:
obj.applyRotation((-resolution,0,0), False)
obj.applyRotation((-resolution,0,-obj.worldOrientation.to_euler().z), False)
# Bouton bas - Broche 3
if bt_haut.read() == False and bt_bas.read() == True:
obj.applyRotation((+resolution,0,0), False)
obj.applyRotation((+resolution,0,-obj.worldOrientation.to_euler().z), False)
# Bouton gauche - Broche 4
if bt_gauche.read() == True and bt_droit.read() == False:
obj.applyRotation((0, -resolution,0), False)
obj.applyRotation((0, -resolution,-obj.worldOrientation.to_euler().z), False)
# Bouton droit - Broche 5
if bt_gauche.read() == False and bt_droit.read() == True :
obj.applyRotation((0, resolution,0), False)
obj.applyRotation((0, resolution,-obj.worldOrientation.to_euler().z), False)
###############################################################################
# Gestion du clavier
@ -86,19 +86,19 @@ def clavier(cont):
# Flèche haut - Up arrow
if keyboard.inputs[bge.events.UPARROWKEY].status[0] == ACTIVATE:
obj.applyRotation((-resolution,0,0), False)
obj.applyRotation((-resolution,0,-obj.worldOrientation.to_euler().z), False)
# Flèche bas - Down arrow
if keyboard.inputs[bge.events.DOWNARROWKEY].status[0] == ACTIVATE:
obj.applyRotation((resolution,0,0), False)
obj.applyRotation((resolution,0,-obj.worldOrientation.to_euler().z), False)
# Flèche gauche - Left arrow
if keyboard.inputs[bge.events.LEFTARROWKEY].status[0] == ACTIVATE:
obj.applyRotation((0, -resolution,0), False)
obj.applyRotation((0, -resolution,-obj.worldOrientation.to_euler().z), False)
# Flèche droit - Right arrow
if keyboard.inputs[bge.events.RIGHTARROWKEY].status[0] == ACTIVATE:
obj.applyRotation((0, resolution,0), False)
obj.applyRotation((0, resolution, -obj.worldOrientation.to_euler().z), False)
###############################################################################
# Gameplay

View File

@ -1,9 +1,9 @@
#include "Wire.h"
/******************************************************************************
* 3-labyrinthe-imu.ino
* 4-labyrinthe-imu.ino
# @title: Programme pour la carte Arduino de gestion de centrale inertielle (capteur IMU)
* @project: Blender-EduTech - Tutoriel : Tutoriel 3 Labyrinthe à bille - Interfacer la scène 3D avec une carte Arduino
* @project: Blender-EduTech - Tutoriel 3 : Labyrinthe à bille - Interfacer avec une carte Arduino par la liaision série
* @lang: fr
* @authors: Philippe Roy <philippe.roy@ac-grenoble.fr>
* @copyright: Copyright (C) 2023 Philippe Roy

View File

@ -3,9 +3,9 @@ import serial # Liaison série
import time
###############################################################################
# 3-labyrinthe-imu.py
# 4-labyrinthe.py
# @title: Module (unique) de la scène 3D du labyrinthe à bille pilotable avec une centrale inertielle (capteur IMU)
# @project: Blender-EduTech - Tutoriel : Tutoriel 3 Labyrinthe à bille - Interfacer avec une carte Arduino
# @project: Blender-EduTech - Tutoriel 3 : Labyrinthe à bille - Interfacer avec une carte Arduino par la liaision série
# @lang: fr
# @authors: Philippe Roy <philippe.roy@ac-grenoble.fr>
# @copyright: Copyright (C) 2023 Philippe Roy