Hi friends,

I am trying to develop the Bloxorz game in OpenGL.

Please see this link http://www.albinoblacksheep.com/games/bloxorz

To do that I have draw the squares floor and a rectangle on top of it.

By I have trouble starting this. I mean I can't figure out how can I draw the floor like in 3d and a rectangular cube thing.

Please guide me.

I have googled this item , but haven't got anything.

**1**

# Bloxorz game in OpenGL.

Started by Yasaswi Srikanth, May 30 2012 08:00 AM

8 replies to this topic

Sponsor:

###
#3
Members - Reputation: **154**

Posted 31 May 2012 - 12:58 AM

dpadam450 is right. but first you'd rather get basics of OpenGL first. Nehe tutorials would be a good and fun start.

http://nehe.gamedev.net/ . Links to lessons on the right side.

http://nehe.gamedev.net/ . Links to lessons on the right side.

###
#4
Members - Reputation: **108**

Posted 31 May 2012 - 10:11 PM

The http://nehe.gamedev.net/ . Yes I have seen them.

Do you mean the Legacy Tutorials?

I think these are very old like in 2000 . Will it be still useful for beginners in OpenGL to follow them?

Do you mean the Legacy Tutorials?

I think these are very old like in 2000 . Will it be still useful for beginners in OpenGL to follow them?

###
#5
Members - Reputation: **154**

Posted 01 June 2012 - 12:53 AM

The http://nehe.gamedev.net/ . Yes I have seen them.

Do you mean the Legacy Tutorials?

I think these are very old like in 2000 . Will it be still useful for beginners in OpenGL to follow them?

Yes, those are the ones that I meant. Yes, it got originated in early 2000's, but will remain useful for another century or so. It will teach you fundamentals of 3D programming which does not change within a decade.

###
#7
Members - Reputation: **1332**

Posted 07 June 2012 - 09:13 AM

No, you should create 1 tile only. Then you can have a level editor / map file to load where you have the empty spots and spots with tiles. Otherwise you have a giant bitmap with no sense of "What is the x,y,z position of tile 1, tile 2" you dont know because all you have is a single bitmap holding tons of tiles.

If this is causing you this much trouble, try doing something else. Or at least start with creating and loading a 2d map of tiles. For instance, back in the day me/classmates used to design tiles by loading a text file. X meant blank space, O meant a tile. Load this into a 2D array.

Map.txt

oxxooo

ooooo

xxooo

xxxoo

for(int i = 0;.......)

{

for(int j = 0;.......)

if(board[i][j] == x){//don't do anything, no tile}

if(board[i][j] == o){//draw the regular tile at position x = i, y = j)

If this is causing you this much trouble, try doing something else. Or at least start with creating and loading a 2d map of tiles. For instance, back in the day me/classmates used to design tiles by loading a text file. X meant blank space, O meant a tile. Load this into a 2D array.

Map.txt

oxxooo

ooooo

xxooo

xxxoo

for(int i = 0;.......)

{

for(int j = 0;.......)

if(board[i][j] == x){//don't do anything, no tile}

if(board[i][j] == o){//draw the regular tile at position x = i, y = j)

###
#8
Members - Reputation: **108**

Posted 08 June 2012 - 01:58 AM

hello ,

Thanks dpadam450 for the answer.

I have some how managed to draw the floor and a block on it. by taking two functions like this :

drawFloor present in Floor class outside main :

void Floor::drawFloor()

{

glRotatef(45.5f,1.0f,1.0f,0.0f);

//Draw floor

for(int i = 1;i<6;i++)

{

for(int j = 1;j<6;j++)

{

//For hole to appear at 3,3

if(i == 3 && j==3)

{

glTranslatef(1.0f,0.0f,0.0f);

continue;

}

glBegin(GL_QUADS);

// Top Face

glColor3f(1.0f,0.0f,0.0f);

glTexCoord2f(0.0f, 1.0f); glVertex3f(-0.500f,0.500f,-0.500f); //top left

glTexCoord2f(0.0f, 0.0f); glVertex3f(-0.500f,0.500f,0.500f); //bottom left

glTexCoord2f(1.0f, 0.0f); glVertex3f( 0.500f,0.50f,0.50f); //bottom right

glTexCoord2f(1.0f, 1.0f); glVertex3f( 0.50f,0.50f,-0.50f);//top right

//Left Face

glTexCoord2f(0.0f, 0.0f); glVertex3f(-0.50f, 0.50f, -0.50f); //Top front

glTexCoord2f(1.0f, 0.0f); glVertex3f(-0.50f, 0.30f, -0.50f);

glTexCoord2f(1.0f, 1.0f); glVertex3f(-0.50f, 0.30f, 0.50f);

glTexCoord2f(0.0f, 1.0f); glVertex3f(-0.50f, 0.50f, 0.50f);

// Front Face

glTexCoord2f(0.0f, 0.0f); glVertex3f(0.50f,0.50f, 0.50f); //top right

glTexCoord2f(1.0f, 0.0f); glVertex3f(-0.50f,0.50f,0.50f); // top left

glTexCoord2f(1.0f, 1.0f); glVertex3f(-0.50f,0.30f, 0.50f); //bottom left

glTexCoord2f(0.0f, 1.0f); glVertex3f(0.50f,0.30f, 0.50f); //bottom right

// Bottom Face

glTexCoord2f(1.0f, 1.0f); glVertex3f( 0.50f,0.30f,0.50f); // top right

glTexCoord2f(0.0f, 1.0f); glVertex3f(-0.50f,0.30f,0.50f); // top left

glTexCoord2f(0.0f, 0.0f); glVertex3f(-0.50f,0.30f,-0.50f); // bottom left

glTexCoord2f(1.0f, 0.0f); glVertex3f( 0.50f,0.30f, -0.50f); //bottom right

// Back Face

glTexCoord2f(1.0f, 0.0f); glVertex3f(-0.50f,0.50f,-0.50f); // top left

glTexCoord2f(1.0f, 1.0f); glVertex3f(0.50f, 0.50f,-0.50f); //top right

glTexCoord2f(0.0f, 1.0f); glVertex3f( 0.50f, 0.30f,-0.50f); //bottom right

glTexCoord2f(0.0f, 0.0f); glVertex3f( -0.50f,0.30f, -0.50f);//bottom left

// Right face

glTexCoord2f(1.0f, 0.0f); glVertex3f( 0.50f, 0.50f, -0.50f); // Top right

glTexCoord2f(1.0f, 1.0f); glVertex3f( 0.50f, 0.50f, 0.50f); // top left

glTexCoord2f(0.0f, 1.0f); glVertex3f( 0.50f, 0.30f, 0.50f); //bottom right

glTexCoord2f(0.0f, 0.0f); glVertex3f( 0.50f, 0.30f, -0.50f); //bottom left

glEnd();

glTranslatef(1.0f,0.0f,0.0f);

}

glTranslatef(-5.0f,0.0f,-1.0f);

}

drawCube present in Cube class :

void Cube::drawCube()

{

glBegin(GL_QUADS);

// Top Face

glColor3f(0.0f,1.0f,0.0f);

glTexCoord2f(0.0f, 1.0f); glVertex3f(-0.500f,0.500f,-0.500f); //top left

glTexCoord2f(0.0f, 0.0f); glVertex3f(-0.500f,0.500f,0.500f); //bottom left

glTexCoord2f(1.0f, 0.0f); glVertex3f( 0.500f,0.50f,0.50f); //bottom right

glTexCoord2f(1.0f, 1.0f); glVertex3f( 0.50f,0.50f,-0.50f);//top right

//Left Face

glTexCoord2f(0.0f, 0.0f); glVertex3f(-0.50f, 0.50f, -0.50f); //Top right

glTexCoord2f(1.0f, 0.0f); glVertex3f(-0.50f,-0.5f, -0.50f); //top left

glTexCoord2f(1.0f, 1.0f); glVertex3f(-0.50f,-0.5f, 0.50f); //bottom left

glTexCoord2f(0.0f, 1.0f); glVertex3f(-0.50f, 0.50f, 0.50f); //bottom right

// Front Face

glTexCoord2f(0.0f, 0.0f); glVertex3f(0.50f,0.50f, 0.50f); //top right

glTexCoord2f(1.0f, 0.0f); glVertex3f(-0.50f,0.50f,0.50f); // top left

glTexCoord2f(1.0f, 1.0f); glVertex3f(-0.50f,-0.5f, 0.50f); //bottom left

glTexCoord2f(0.0f, 1.0f); glVertex3f(0.50f,-0.5f, 0.5f); //bottom right

// Bottom Face

glTexCoord2f(1.0f, 1.0f); glVertex3f( 0.50f,-0.50f,0.50f); // top right

glTexCoord2f(0.0f, 1.0f); glVertex3f(-0.50f,-0.50f,0.50f); // top left

glTexCoord2f(0.0f, 0.0f); glVertex3f(-0.50f,-0.50f,-0.50f); // bottom left

glTexCoord2f(1.0f, 0.0f); glVertex3f( 0.50f,-0.50f, -0.50f); //bottom right

// Back Face

glTexCoord2f(1.0f, 0.0f); glVertex3f(-0.50f,0.50f,-0.50f); // top left

glTexCoord2f(1.0f, 1.0f); glVertex3f(0.50f, 0.50f,-0.50f); //top right

glTexCoord2f(0.0f, 1.0f); glVertex3f( 0.50f,-0.50f,-0.50f); //bottom right

glTexCoord2f(0.0f, 0.0f); glVertex3f( -0.50f,-0.50f, -0.50f);//bottom left

// Right face

glTexCoord2f(1.0f, 0.0f); glVertex3f( 0.50f, 0.50f, -0.50f); // Top left

glTexCoord2f(1.0f, 1.0f); glVertex3f( 0.50f, 0.50f, 0.50f); // bottom left

glTexCoord2f(0.0f, 1.0f); glVertex3f( 0.50f, -0.50f, 0.50f); //bottom right

glTexCoord2f(0.0f, 0.0f); glVertex3f( 0.50f, -0.5f, -0.50f); //top right

glEnd();

}

I have placed the hole at 3,3 position look on drawing floor.

My main problem is moving the block left and right . For that I have taken a structure called

typedef struct

{

public:

float x_pos;

float y_pos;

float z_pos;

float radian;

}cube_param;

I created an object like cube_param cube_pos;

while left key is pressed :

case WM_KEYDOWN: // Is A Key Being Held Down?

{

keys[wParam] = TRUE; // If So, Mark It As TRUE

switch(wParam)

{

case VK_LEFT:

{

cube_pos.x_pos = - 1.0f ;

cube_pos.y_pos = -1.0f;

cube_pos.z_pos = 0.0f;

cube_pos.radian = -90.0f;

cube->drawCube(cube_pos);

}

}

return 0;

}

where drawCube(cube_pos); contains the same code as drawCube() but it has to move it.

Here does the structure cube_pos goes away with values to drawCube(cube_param cube_pos)

Look at it :

// For movement of cube

void Cube::drawCube(cube_param cube_pos)

{

float x_pos = cube_pos.x_pos;

float y_pos = cube_pos.y_pos;

float z_pos = cube_pos.z_pos;

float radian = cube_pos.radian;

//glTranslatef(1.0f,1.0f,0.0f);

glRotatef(radian,x_pos,0.0f,0.0f);

glBegin(GL_QUADS);

// Top Face

glColor3f(0.0f,1.0f,0.0f);

glTexCoord2f(0.0f, 1.0f); glVertex3f(-0.5f + x_pos,0.5f + y_pos,-0.5f); //top left

glTexCoord2f(0.0f, 0.0f); glVertex3f(-0.5f + x_pos,0.5f + y_pos,0.5f); //bottom left

glTexCoord2f(1.0f, 0.0f); glVertex3f( 0.5f + x_pos,0.5f + y_pos,0.5f); //bottom right

glTexCoord2f(1.0f, 1.0f); glVertex3f( 0.5f + x_pos,0.5f + y_pos,-0.5f);//top right

//Left Face

glTexCoord2f(0.0f, 0.0f); glVertex3f(-0.50f, 0.50f, -0.50f); //Top right

glTexCoord2f(1.0f, 0.0f); glVertex3f(-0.50f,-0.5f, -0.50f); //top left

glTexCoord2f(1.0f, 1.0f); glVertex3f(-0.50f,-0.5f, 0.50f); //bottom left

glTexCoord2f(0.0f, 1.0f); glVertex3f(-0.50f, 0.50f, 0.50f); //bottom right

// Front Face

glTexCoord2f(0.0f, 0.0f); glVertex3f(0.50f,0.50f, 0.50f); //top right

glTexCoord2f(1.0f, 0.0f); glVertex3f(-0.50f,0.50f,0.50f); // top left

glTexCoord2f(1.0f, 1.0f); glVertex3f(-0.50f,-0.5f, 0.50f); //bottom left

glTexCoord2f(0.0f, 1.0f); glVertex3f(0.50f,-0.5f, 0.5f); //bottom right

// Bottom Face

glTexCoord2f(1.0f, 1.0f); glVertex3f( 0.50f,-0.50f,0.50f); // top right

glTexCoord2f(0.0f, 1.0f); glVertex3f(-0.50f,-0.50f,0.50f); // top left

glTexCoord2f(0.0f, 0.0f); glVertex3f(-0.50f,-0.50f,-0.50f); // bottom left

glTexCoord2f(1.0f, 0.0f); glVertex3f( 0.50f,-0.50f, -0.50f); //bottom right

// Back Face

glTexCoord2f(1.0f, 0.0f); glVertex3f(-0.50f,0.50f,-0.50f); // top left

glTexCoord2f(1.0f, 1.0f); glVertex3f(0.50f, 0.50f,-0.50f); //top right

glTexCoord2f(0.0f, 1.0f); glVertex3f( 0.50f,-0.50f,-0.50f); //bottom right

glTexCoord2f(0.0f, 0.0f); glVertex3f( -0.50f,-0.50f, -0.50f);//bottom left

// Right face

glTexCoord2f(1.0f, 0.0f); glVertex3f( 0.50f, 0.50f, -0.50f); // Top left

glTexCoord2f(1.0f, 1.0f); glVertex3f( 0.50f, 0.50f, 0.50f); // bottom left

glTexCoord2f(0.0f, 1.0f); glVertex3f( 0.50f, -0.50f, 0.50f); //bottom right

glTexCoord2f(0.0f, 0.0f); glVertex3f( 0.50f, -0.5f, -0.50f); //top right

glEnd();

}

My idea is when left key is pressed i want to translate each and every vertex by adding or subtracting the x_pos,y_pos,z_pos present in cube_param structure

and then translate and rotate it. will it ultimately work for each and every move ?

If so how to do it.

Thanks dpadam450 for the answer.

I have some how managed to draw the floor and a block on it. by taking two functions like this :

drawFloor present in Floor class outside main :

void Floor::drawFloor()

{

glRotatef(45.5f,1.0f,1.0f,0.0f);

//Draw floor

for(int i = 1;i<6;i++)

{

for(int j = 1;j<6;j++)

{

//For hole to appear at 3,3

if(i == 3 && j==3)

{

glTranslatef(1.0f,0.0f,0.0f);

continue;

}

glBegin(GL_QUADS);

// Top Face

glColor3f(1.0f,0.0f,0.0f);

glTexCoord2f(0.0f, 1.0f); glVertex3f(-0.500f,0.500f,-0.500f); //top left

glTexCoord2f(0.0f, 0.0f); glVertex3f(-0.500f,0.500f,0.500f); //bottom left

glTexCoord2f(1.0f, 0.0f); glVertex3f( 0.500f,0.50f,0.50f); //bottom right

glTexCoord2f(1.0f, 1.0f); glVertex3f( 0.50f,0.50f,-0.50f);//top right

//Left Face

glTexCoord2f(0.0f, 0.0f); glVertex3f(-0.50f, 0.50f, -0.50f); //Top front

glTexCoord2f(1.0f, 0.0f); glVertex3f(-0.50f, 0.30f, -0.50f);

glTexCoord2f(1.0f, 1.0f); glVertex3f(-0.50f, 0.30f, 0.50f);

glTexCoord2f(0.0f, 1.0f); glVertex3f(-0.50f, 0.50f, 0.50f);

// Front Face

glTexCoord2f(0.0f, 0.0f); glVertex3f(0.50f,0.50f, 0.50f); //top right

glTexCoord2f(1.0f, 0.0f); glVertex3f(-0.50f,0.50f,0.50f); // top left

glTexCoord2f(1.0f, 1.0f); glVertex3f(-0.50f,0.30f, 0.50f); //bottom left

glTexCoord2f(0.0f, 1.0f); glVertex3f(0.50f,0.30f, 0.50f); //bottom right

// Bottom Face

glTexCoord2f(1.0f, 1.0f); glVertex3f( 0.50f,0.30f,0.50f); // top right

glTexCoord2f(0.0f, 1.0f); glVertex3f(-0.50f,0.30f,0.50f); // top left

glTexCoord2f(0.0f, 0.0f); glVertex3f(-0.50f,0.30f,-0.50f); // bottom left

glTexCoord2f(1.0f, 0.0f); glVertex3f( 0.50f,0.30f, -0.50f); //bottom right

// Back Face

glTexCoord2f(1.0f, 0.0f); glVertex3f(-0.50f,0.50f,-0.50f); // top left

glTexCoord2f(1.0f, 1.0f); glVertex3f(0.50f, 0.50f,-0.50f); //top right

glTexCoord2f(0.0f, 1.0f); glVertex3f( 0.50f, 0.30f,-0.50f); //bottom right

glTexCoord2f(0.0f, 0.0f); glVertex3f( -0.50f,0.30f, -0.50f);//bottom left

// Right face

glTexCoord2f(1.0f, 0.0f); glVertex3f( 0.50f, 0.50f, -0.50f); // Top right

glTexCoord2f(1.0f, 1.0f); glVertex3f( 0.50f, 0.50f, 0.50f); // top left

glTexCoord2f(0.0f, 1.0f); glVertex3f( 0.50f, 0.30f, 0.50f); //bottom right

glTexCoord2f(0.0f, 0.0f); glVertex3f( 0.50f, 0.30f, -0.50f); //bottom left

glEnd();

glTranslatef(1.0f,0.0f,0.0f);

}

glTranslatef(-5.0f,0.0f,-1.0f);

}

drawCube present in Cube class :

void Cube::drawCube()

{

glBegin(GL_QUADS);

// Top Face

glColor3f(0.0f,1.0f,0.0f);

glTexCoord2f(0.0f, 1.0f); glVertex3f(-0.500f,0.500f,-0.500f); //top left

glTexCoord2f(0.0f, 0.0f); glVertex3f(-0.500f,0.500f,0.500f); //bottom left

glTexCoord2f(1.0f, 0.0f); glVertex3f( 0.500f,0.50f,0.50f); //bottom right

glTexCoord2f(1.0f, 1.0f); glVertex3f( 0.50f,0.50f,-0.50f);//top right

//Left Face

glTexCoord2f(0.0f, 0.0f); glVertex3f(-0.50f, 0.50f, -0.50f); //Top right

glTexCoord2f(1.0f, 0.0f); glVertex3f(-0.50f,-0.5f, -0.50f); //top left

glTexCoord2f(1.0f, 1.0f); glVertex3f(-0.50f,-0.5f, 0.50f); //bottom left

glTexCoord2f(0.0f, 1.0f); glVertex3f(-0.50f, 0.50f, 0.50f); //bottom right

// Front Face

glTexCoord2f(0.0f, 0.0f); glVertex3f(0.50f,0.50f, 0.50f); //top right

glTexCoord2f(1.0f, 0.0f); glVertex3f(-0.50f,0.50f,0.50f); // top left

glTexCoord2f(1.0f, 1.0f); glVertex3f(-0.50f,-0.5f, 0.50f); //bottom left

glTexCoord2f(0.0f, 1.0f); glVertex3f(0.50f,-0.5f, 0.5f); //bottom right

// Bottom Face

glTexCoord2f(1.0f, 1.0f); glVertex3f( 0.50f,-0.50f,0.50f); // top right

glTexCoord2f(0.0f, 1.0f); glVertex3f(-0.50f,-0.50f,0.50f); // top left

glTexCoord2f(0.0f, 0.0f); glVertex3f(-0.50f,-0.50f,-0.50f); // bottom left

glTexCoord2f(1.0f, 0.0f); glVertex3f( 0.50f,-0.50f, -0.50f); //bottom right

// Back Face

glTexCoord2f(1.0f, 0.0f); glVertex3f(-0.50f,0.50f,-0.50f); // top left

glTexCoord2f(1.0f, 1.0f); glVertex3f(0.50f, 0.50f,-0.50f); //top right

glTexCoord2f(0.0f, 1.0f); glVertex3f( 0.50f,-0.50f,-0.50f); //bottom right

glTexCoord2f(0.0f, 0.0f); glVertex3f( -0.50f,-0.50f, -0.50f);//bottom left

// Right face

glTexCoord2f(1.0f, 0.0f); glVertex3f( 0.50f, 0.50f, -0.50f); // Top left

glTexCoord2f(1.0f, 1.0f); glVertex3f( 0.50f, 0.50f, 0.50f); // bottom left

glTexCoord2f(0.0f, 1.0f); glVertex3f( 0.50f, -0.50f, 0.50f); //bottom right

glTexCoord2f(0.0f, 0.0f); glVertex3f( 0.50f, -0.5f, -0.50f); //top right

glEnd();

}

I have placed the hole at 3,3 position look on drawing floor.

My main problem is moving the block left and right . For that I have taken a structure called

typedef struct

{

public:

float x_pos;

float y_pos;

float z_pos;

float radian;

}cube_param;

I created an object like cube_param cube_pos;

while left key is pressed :

case WM_KEYDOWN: // Is A Key Being Held Down?

{

keys[wParam] = TRUE; // If So, Mark It As TRUE

switch(wParam)

{

case VK_LEFT:

{

cube_pos.x_pos = - 1.0f ;

cube_pos.y_pos = -1.0f;

cube_pos.z_pos = 0.0f;

cube_pos.radian = -90.0f;

cube->drawCube(cube_pos);

}

}

return 0;

}

where drawCube(cube_pos); contains the same code as drawCube() but it has to move it.

Here does the structure cube_pos goes away with values to drawCube(cube_param cube_pos)

Look at it :

// For movement of cube

void Cube::drawCube(cube_param cube_pos)

{

float x_pos = cube_pos.x_pos;

float y_pos = cube_pos.y_pos;

float z_pos = cube_pos.z_pos;

float radian = cube_pos.radian;

//glTranslatef(1.0f,1.0f,0.0f);

glRotatef(radian,x_pos,0.0f,0.0f);

glBegin(GL_QUADS);

// Top Face

glColor3f(0.0f,1.0f,0.0f);

glTexCoord2f(0.0f, 1.0f); glVertex3f(-0.5f + x_pos,0.5f + y_pos,-0.5f); //top left

glTexCoord2f(0.0f, 0.0f); glVertex3f(-0.5f + x_pos,0.5f + y_pos,0.5f); //bottom left

glTexCoord2f(1.0f, 0.0f); glVertex3f( 0.5f + x_pos,0.5f + y_pos,0.5f); //bottom right

glTexCoord2f(1.0f, 1.0f); glVertex3f( 0.5f + x_pos,0.5f + y_pos,-0.5f);//top right

//Left Face

glTexCoord2f(0.0f, 0.0f); glVertex3f(-0.50f, 0.50f, -0.50f); //Top right

glTexCoord2f(1.0f, 0.0f); glVertex3f(-0.50f,-0.5f, -0.50f); //top left

glTexCoord2f(1.0f, 1.0f); glVertex3f(-0.50f,-0.5f, 0.50f); //bottom left

glTexCoord2f(0.0f, 1.0f); glVertex3f(-0.50f, 0.50f, 0.50f); //bottom right

// Front Face

glTexCoord2f(0.0f, 0.0f); glVertex3f(0.50f,0.50f, 0.50f); //top right

glTexCoord2f(1.0f, 0.0f); glVertex3f(-0.50f,0.50f,0.50f); // top left

glTexCoord2f(1.0f, 1.0f); glVertex3f(-0.50f,-0.5f, 0.50f); //bottom left

glTexCoord2f(0.0f, 1.0f); glVertex3f(0.50f,-0.5f, 0.5f); //bottom right

// Bottom Face

glTexCoord2f(1.0f, 1.0f); glVertex3f( 0.50f,-0.50f,0.50f); // top right

glTexCoord2f(0.0f, 1.0f); glVertex3f(-0.50f,-0.50f,0.50f); // top left

glTexCoord2f(0.0f, 0.0f); glVertex3f(-0.50f,-0.50f,-0.50f); // bottom left

glTexCoord2f(1.0f, 0.0f); glVertex3f( 0.50f,-0.50f, -0.50f); //bottom right

// Back Face

glTexCoord2f(1.0f, 0.0f); glVertex3f(-0.50f,0.50f,-0.50f); // top left

glTexCoord2f(1.0f, 1.0f); glVertex3f(0.50f, 0.50f,-0.50f); //top right

glTexCoord2f(0.0f, 1.0f); glVertex3f( 0.50f,-0.50f,-0.50f); //bottom right

glTexCoord2f(0.0f, 0.0f); glVertex3f( -0.50f,-0.50f, -0.50f);//bottom left

// Right face

glTexCoord2f(1.0f, 0.0f); glVertex3f( 0.50f, 0.50f, -0.50f); // Top left

glTexCoord2f(1.0f, 1.0f); glVertex3f( 0.50f, 0.50f, 0.50f); // bottom left

glTexCoord2f(0.0f, 1.0f); glVertex3f( 0.50f, -0.50f, 0.50f); //bottom right

glTexCoord2f(0.0f, 0.0f); glVertex3f( 0.50f, -0.5f, -0.50f); //top right

glEnd();

}

My idea is when left key is pressed i want to translate each and every vertex by adding or subtracting the x_pos,y_pos,z_pos present in cube_param structure

and then translate and rotate it. will it ultimately work for each and every move ?

If so how to do it.

**Edited by Yasaswi Srikanth, 08 June 2012 - 02:06 AM.**

###
#9
Members - Reputation: **154**

Posted 08 June 2012 - 03:45 PM

before you get into a point when you want to move certain object try to create some structure around your code. Instead of hundrets glVertex(...) glTexCoords(...) with hardcoded numbers in those create some easy to use functions that would accept a position as an input and internally would call OpenGL functions to render your objects. Further it would be easier for you to change things upon user action.