I’m actually trying to reproduce the Tetris game while using the Blender Game Engine and some Python.
For now, I simply have a keyboard input to add a cube to the scene and that cube acts that way :
import bge import Rasterizer import time cont = bge.logic.getCurrentController() tetrocube = cont.owner # It's a Dynamic object. Btw, gravity = 0 # get the scene for mouse and other things scene = bge.logic.getCurrentScene() # get the keyboard keyboard = bge.logic.keyboard # get the mouse (I just like to have it when I'm testing my code) mouse = bge.logic.mouse Rasterizer.showMouse(True) # get the touch sensor touch = cont.sensors["Collision"] def main(): wait_and_apply(tetrocube) def wait_and_apply(object): # I don't know why but if I do (while touch.positive is False:), the loop overload. a = 0 # Corresponds to the number of movements (equal to the number of 'squares' crossed by the cube) while a<20: if touch.positive is False: time.sleep(1) Move(object) a+=1 else: a = 20 def Move(object): object.applyMovement([0, 0, -1], False) main()
But when I play the game, Blender doesn’t respond until the cube reached the bottom of the scene (= until touch.positive is True), so I can’t see that ‘jerky’ movement like in Tetris.
Does anyone can help me ?
Thanks in advance.