tiens en cadeau un casse brique que je realise
actuellement Breakout 3D Move , met toi au
boulot mon pote, c´est pas les messages de
forum qui vont te faire avancer ! !!
#include "Ball.h" // Class declaration
// Constructor
Ball : : Ball():
x(0.0f),
y(0.0f),
z(0.0f),
xi(0.5f),
yi(0.5f),
zi(0.0f),
speed(0.2f),
speedup(0.00005f),
diameter(0.5f)
{
radius = diameter/2;
sphere=gluNewQuadric(); // Create a pointer to a quadric object
gluQuadricNormals(sphere, GLU_SMOOTH); // Create smooth normals
gluQuadricTexture(sphere, GL_TRUE); // Create texture coords
}
// Destructor
Ball : : ~Ball()
{ }
//------------------------------------------------
------------------//
//- void Reset(void)
-----------------------------------------------//
//------------------------------------------------
------------------//
//- Description: This function resets ball then serves a slow ball -//
//- to losing player. -//
//------------------------------------------------
------------------//
Ball : : Reset(void)
{
x = -radius; // Reset ball and serve it
y = -2.0f;
z = 0.0f;
xi = 0.0f;
yi = -0.5f;
zi = 0.0f;
speed = 0.2f;
}
// Draw to opengl screen
Ball : : Draw()
{
glColor3f(0.2f, 1.0f, 0.2f);
glPushMatrix(); // Save current matrix, so translation doesnt affect rest of program
glTranslatef(x+radius, y-radius, z+radius); // Translate sphere to top left corner ( x,y)
gluSphere(sphere, radius, 10, 10); // Draw sphere
glPopMatrix(); // Restore matrix
}