1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56
|
class MyGameState : public VGL_GameState {
public:
// add here any required variables ////
unsigned int CubeTexture; // a texture id
Vector3 CubePos; // a 3d vertex position
Vector3 CubePos2;
void Init() {
CubeTexture = LoadTGA("data/floor1.tga"); CubePos = Vector3(0,0,-10.0f); // the cube position in 3d space
CubePos2 = Vector3(2,2,-10.0f); // the cube position in 3d space
};
void Draw() {
static float rot2 =0.0f;
rot2+=0.1f;
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glLoadIdentity();
gluLookAt(0,0,0,CubePos.x,CubePos.y,CubePos.z,0,1,0);
BIND(CubeTexture); // use the CubeTexture
// c cette partie de code qui est importante pour toi
glPushMatrix();
Translate(CubePos); // translate to the cube position
DrawCube(1.0f); // draw of cube of 1.0f size
glPopMatrix();
glPushMatrix();
Translate(CubePos2); // translate to the cube position
Rotate(rot2);
DrawCube(1.0f); // draw of cube of 1.0f size
glPopMatrix();
engine->fnt->Print(10,10,"cube 2 x %f %.2y %.2f",CubePos2.x,CubePos2.y);
};
bool ProcessInput() {
if ( KeyDown(DIK_ESCAPE) ) return false; // return false mean that we will quit the engine
if ( KeyDown(DIK_LEFT) ) CubePos2.x-=engine->deltaTime*0.01f; // moves the cube left
if ( KeyDown(DIK_RIGHT) ) CubePos2.x+=engine->deltaTime*0.01f; // moves the cube right
return true; // dont quit for the moment
};
}; |