I'm making a Rubix Cube game...

Edited the title to let people better understand what I’m making.

I’m going to attempt to remake a Rubix Cube inside a 3-D environment. I’ve got the cube completed… But I know very, very little of the game engine. :frowning:
So, I’ve got a few questions, first I’d like to know how it would be possible to make the to make the camera pan and rotate like in the object mode. I need more help but I’ll ask more if the nice people of the wonderful Blender Artist community respond.:wink:

Just a little note: This Rubix Cube was originally made with the intent of a render at first, not a game. But I thought I might try and create a game for once. It seemed the best way to go (Plus, I’ve thought of mini-game ideas after the main is completed…)

Another note: My model is a little above 5000 faces. How many Polys can the game engine handle? (On a decent computer.)

Attachments


If you’re not going to have any high-poly environments, 5000 polys is fine. However, I would say that that many faces isn’t NEEDED for that kind of model, but there’s not a good reason now to change it.

As for the camera issue, you can add an empty to the same space as the cube’s center and parent your camera to that. Then you can use the motion actuator for simple rotation, which can be connected to keyboard sensors to rotate the camera. If you want the camera to be controlled by the mouse, you’ll need a python script, but there are TONS out there, you shouldn’t have too hard of a time finding one.

Well, it only came to 5000 because, as I said, I was going to render. See, I used two bevels on the model to give it round … feel. Then copying that cube over, and over again. So, Yeah, I’m not going to use a high poly environment.

interesting…
i always kind of thought about doing this same exact thing. I just couldn’t think of a way to do the controls, so I never tried to actually make it.

164 = 64
That means you got 64 cubes in that big cube.
64
4 = 256
That means you got 256 verticles.
64*6 = 384
That means you got 384 faces
or
It means that you go 768 tris

Hmmm doing the controls for this thing, gives me a headache…:stuck_out_tongue:
I can’t help you…good luck:evilgrin:

Hey wiiario.

I did recently a Pyramorphix in Blender Game Engine.

I’m pretty sure the rubyk is even easier :slight_smile:
I probably can help with part of the logic.

I have three axis (empties) and everytime I want to rotate one of them I run a python script.
The script is responsible for unparent all cubes (pieces) from the axis, and reparent the cubes of the face you want to rotate. Then I set a property value to trigger an IPO sensor. (the rotation).

The secret is the new setParent() implemented one-two Blenders ago.
We should thanks Ben for that. I tried to do this before that and it was way too complex to do without that.

My code to randomly rotate the axis is here. In the case of the 4x4 cube the challenge is different, but if you understand that you gonna be ok.


import GameLogic as G
import random

cont = G.getCurrentController()
sensor = cont.getSensors()

axe = random.choice(G.E_centres)
rotDir = random.choice([-1,-1,1,1])

for i in G.centres:
	i.removeParent()

	if axe.name[-1:] == "A":
		if i.getPosition()[2] > G.E_centres[1].getPosition()[2]:
			i.setParent(axe) 
	
	if axe.name[-1:] == "B":
		if i.getPosition()[1] < G.E_centres[0].getPosition()[1]:
			i.setParent(axe)
	
	if axe.name[-1:] == "C":
		if i.getPosition()[0] > G.E_centres[1].getPosition()[0]:
			i.setParent(axe) 

axe.rotate = rotDir

wow lol Ive been working on a rubix cube game for about a week now

Hey wiiario.

I did recently a Pyramorphix in Blender Game Engine.
http://en.wikipedia.org/wiki/Pyramorphix

I’m pretty sure the rubyk is even easier :slight_smile:
I probably can help with part of the logic.

I have three axis (empties) and everytime I want to rotate one of them I run a python script.
The script is responsible for unparent all cubes (pieces) from the axis, and reparent the cubes of the face you want to rotate. Then I set a property value to trigger an IPO sensor. (the rotation).

The secret is the new setParent() implemented one-two Blenders ago.
We should thanks Ben for that. I tried to do this before that and it was way too complex to do without that.

My code to randomly rotate the axis is here. In the case of the 4x4 cube the challenge is different, but if you understand that you gonna be ok.

Soooooo… If I’m understanding correctly, I place empties in the areas I want to rotate, then use that code to re-parent the cubes to rotate on that axis, right?

Interesting calculation :wink: I’m amazed no one caught that yet.
That model should have 56 individual cubes since the four centre ones would never be seen and therefore have no reason to exist. Right?

They have just been removed. Also the poly count is higher than he calculated because I beveled twice.

Yup :slight_smile:

In your case you gonna need to check if the center of the cubes is between two axis.
In my case I had only 3 axis (empties).
You will need, 12 axis :slight_smile:

My code is not optimized (I didn’t need it to be). As I had only 3 axis I hard-coded their names and position check. However this can be a little tricky to 12 axis.

In your case I would use dictionaries for the axis (something like):


#axe == key of my empties dictionary:

if axe == "Blue01":
	if (i.getPosition()[2] > G.E_centres["Blue01"].getPosition()[2]):
		if (i.getPosition()[2] < G.E_centres["Blue02"].getPosition()[2]):
			i.setParent(axe)

elif axe =="Blue02":
	if (i.getPosition()[2] > G.E_centres["Blue02"].getPosition()[2]):
		i.setParent(axe)
...

My WireFrame

Well I don’t want to take your fun in doing this project.
However if you want I can send you my file (send me a PM, an email, or a comment in my blog, or a letter, or a postcard :)).

I’m going to release the file anyways. I’m waiting to write a nice blog post and push the modelling and texturing a little more.

Good Luck, and have fun :smiley:
Dalai

http://vimeo.com/2170430

I did a video using my pyramorphix and the Video Texture Player.

I hope it can inspire this project :slight_smile: