update
This commit is contained in:
parent
ee649c5a21
commit
c69c6eaada
@ -11,6 +11,21 @@
|
|||||||
|
|
||||||
const float POINT_SIZE = 32.0f;
|
const float POINT_SIZE = 32.0f;
|
||||||
|
|
||||||
|
class BouncyBall{
|
||||||
|
public:
|
||||||
|
int bx=0,by=0,bsx=5,bsy=7;
|
||||||
|
BouncyBall(int x,int y,int speedX,int speedY):bx(x),by(y),bsx(speedX),bsy(speedY){}
|
||||||
|
BouncyBall* update(){
|
||||||
|
bx+=bsx,by+=bsy;
|
||||||
|
if(bx>=1000||bx<=-1000){
|
||||||
|
bsx=-bsx;
|
||||||
|
}
|
||||||
|
if(by>=1000||by<=-1000){
|
||||||
|
bsy=-bsy;
|
||||||
|
}
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
void render(){
|
void render(){
|
||||||
glBegin(GL_TRIANGLES);
|
glBegin(GL_TRIANGLES);
|
||||||
@ -34,15 +49,12 @@ void render(){
|
|||||||
speed=0.01f;
|
speed=0.01f;
|
||||||
}
|
}
|
||||||
glColor3f(num/1.11f,1.0f-(num/1.12f),num/1.13f);
|
glColor3f(num/1.11f,1.0f-(num/1.12f),num/1.13f);
|
||||||
static int bx=0,by=0,bsx=5,bsy=7;
|
|
||||||
glVertex3f(float(bx)/1000.0f,float(by)/1000.0f,0.0f);
|
static BouncyBall b1(0,0,5,6),b2(500,70,3,-6),b3(-250,-100,-40,-25);
|
||||||
bx+=bsx,by+=bsy;
|
glVertex3f(float(b1.bx)/1000.0f,float(b1.by)/1000.0f,0.0f);
|
||||||
if(bx>=1000||bx<=-1000){
|
glVertex3f(float(b2.bx)/1000.0f,float(b2.by)/1000.0f,0.0f);
|
||||||
bsx=-bsx;
|
glVertex3f(float(b3.bx)/1000.0f,float(b3.by)/1000.0f,0.0f);
|
||||||
}
|
b1.update(),b2.update(),b3.update();
|
||||||
if(by>=1000||by<=-1000){
|
|
||||||
bsy=-bsy;
|
|
||||||
}
|
|
||||||
glEnd();
|
glEnd();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -86,5 +98,6 @@ int main(){
|
|||||||
#include<Windows.h>
|
#include<Windows.h>
|
||||||
int WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) {
|
int WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) {
|
||||||
main();
|
main();
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
Loading…
Reference in New Issue
Block a user