Public Group

# Rubik Cube C

This topic is 2543 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Hello,

I'm developing a rubik cube in c for a class I have. And I've defined the structures, but, am having a bit of a problem initializing them.

Was wondering if I could get a little help.

 // each square of the little cubes in the rubik cube typedef struct quadr { char collor; char axys; } quad; // Cubes in the rubik cube typedef struct squareR { quad q[6]; char axys; // Check if its side is valid, eg. If it shows on the rubik cube int valid; } square; // Rubik cube typedef struct cubeR { square q[3][3][3]; } cubo; 

I was thinking of doing something like this:

 void startup() { int x,y,z,w; for(x=0;x<3;x++) { for(y=0;y<3;y++) { for(z=0;z<3;z++) { for(w=0;w<6;w++) { //initialization goes here } } } } } 

The hard part i find by now, is making the initialization...

The axys variable has to do to which side the cube(s) are turning to, so that i can show the correct collors.
The collors at the beggining, will be filled probably with numbers from 0 to 5, or something like that.

Thank you,

##### Share on other sites
I have no idea how you plan to use the axys variables so I can't say how to initialize them. For the face colors I would approach things from the opposite direction: for each face color figure out which cubes need to have faces with those colors and then mark the cube faces that color. You should probably start with every cube with every face black or however you plan to mark the faces that face inwards.

##### Share on other sites
Hmm, I agree, thankyou. Just don't still know how to initialize my variables, I might have complicated the problem much more than it was needed to...

1. 1
2. 2
Rutin
21
3. 3
4. 4
A4L
15
5. 5
khawk
14

• 13
• 26
• 10
• 11
• 44
• ### Forum Statistics

• Total Topics
633742
• Total Posts
3013634
×