Hi,
I want to make a Tetris 3D game using Blender 3D.
I face a problem of cancelling the complete line. Any idea? Boolean in game engine?
Thanks.
Hi,
I want to make a Tetris 3D game using Blender 3D.
I face a problem of cancelling the complete line. Any idea? Boolean in game engine?
Thanks.
The best approach is to make each piece out of cubes. Then, you can use a ray intersection with the xray feature to get all the blocks at the bottom
I am not quite sure how to achieve that, but I think using Booleans in BGE can become very messy.
Your blocks are already modeled. I think it would be far easier if you combine several objects (cubes) into a group to create one block.
EDIT
Whoops! Agoose was faster and he even described it better than me :o
Hi, thanks for your reply.
Actually I made the components using cubes at first. However, I faced a problem of making them together. I tried using ‘parent’ but the 2 problems are:
I think you can select “Compound”, so that child objects connected to parent objects are all a single collision mesh; if one brick stops because it hit something, all of the bricks would stop.
Hi, thanks for your reply. I solved the problem but I faced another 2 problems:
You need to select “tap” in the keyboard-sensor.
Both problems can be solved with Python -
This one should work:
from bge import logic
import math
cont = logic.getCurrentController() # Get the python controller running this script
obj = cont.owner # Get the object running this controller
key = cont.sensors['Keyboard'] # Get the keyboard sensor
if key.positive: # If the key is pressed
obj.applyRotation([0, math.radians(90), 0]) # Rotate by 90 degrees in radians
Put that script in a Python module and connect it to a Keyboard sensor named “Keyboard”. Also, make sure there’s no pulse settings on the sensor. Set that to be the key you want to rotate to the right, and that’s it! If you want to rotate it the other way, just use this script:
from bge import logic
import math
cont = logic.getCurrentController() # Get the python controller running this script
obj = cont.owner # Get the object running this controller
key = cont.sensors['Keyboard'] # Get the keyboard sensor
if key.positive: # If the key is pressed
obj.applyRotation([0, math.radians(-90), 0]) # Rotate by 90 degrees in radians
I’m going to hold off on showing an example of this, though, since I want to know if there are any simpler methods to doing this.
Hi, thanks for your reply! What is the name of this computer language? I would like to learn so I can create more games easier
Anyone ever faces the problem of cannot connect 2 sensors from 2 objects? Because when I click one object and then the other, the sensors of either 1 object does not come out. Kindly refer to attachments.
Hi hanyc93,
The way that you do it, with ray sensors and parenting, is a good way to learn about Blender and the BGE.
If your goal is just learning and experimenting, go on in this direction! I don’t want to criticize you!
But I think that in general, ray sensors are not a good idea for Tetris. BGE sensors telling your game what to do is a bit backward. It is like MS Word saving a .doc as a screenshot image, and loading it using OCR/text recognition.
In my opinion, a list of cubes and their positions should be kept inside a Python controller. The Python controller should tell every BGE cube object to be at the right position, according to the list. When something happens (dropping, rotation, …) , you just update the list.
But you have to know some Python for this.
cheers
Sjoerd
Hi, I use “touch” to cancel the line instead of “ray” or “radar”. Now I face a problem of combining the cubes to form a component.
I tried “Parent” but once any 1 cube ends, the other cubes end. “Parent” gone, “Children” gone. “Children” gone, “Parent Gone”.
Anyone has a solution for combing the cubes to form a component? I want 1 cube ends but the other falls down. Thanks.
I’m not sure why that appears to be the case, but then again I rarely use parenting. In this complexity you may be better off using python. Create an empty which runs the python logic, then create a list of lists of shape coordinates, and randomly select one each second. Then run a loop to add each object for each position in that list, and store those objects in a list of stored objects so that you can displace each of their z positions every frame. Then all you need is to read each z position after displacement and if it is equal to or less than the height of the floor (assuming the floor is above 0.0)end the object
Thanks for everyone’s reply. Really appreciate your help. I’m currently learning to write python script.
Anyone has a solution for combing the cubes to form a component? I want 1 cube ends but the other falls down but my problem is when 1 cube ends, the other cubes of that component end together.
Hi, sorry to trouble you all. Do you know how to make an object move up to certain height then move down to certain -height then move up, down, up, down…?
Animations? If the certain height is the same. If you mean bouncing you can use elasticity in the materials tab (if using this apply material to ground and bouncing obj).
Thanks for telling I can use animation in game engine. I have the loop problem solved.
Seriously, anyone can help me to solve this problem of combing cubes to form a component like “L” component in tetris:
I replied to the PM, it’s not a brilliant solution, but it may work.
testris.blend (465 KB)
Here is a kinda working game. I don’t think it will be of much help to a non programmer, but perhaps others could read and explain.
You just use one cube, a plane and an empty with a long script for the tetris game. Brilliant!
My tetris game consists of so many objects and logics… and I am facing lots of problems…