Jump to content
  • Advertisement
Sign in to follow this  
MichaelMatias

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.

If you intended to correct an error in the post then please contact us.

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 this post


Link to post
Share on other sites
Advertisement
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 this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!