update
This commit is contained in:
parent
dbee9f57c6
commit
c707eff1ad
@ -2,12 +2,10 @@
|
|||||||
|
|
||||||
#include <cmath>
|
#include <cmath>
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
#include <format>
|
|
||||||
#include<glad/glad.h>
|
#include<glad/glad.h>
|
||||||
#include<GLFW/glfw3.h>
|
#include<GLFW/glfw3.h>
|
||||||
#include <chrono>
|
#include <chrono>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <numbers>
|
|
||||||
#include <ostream>
|
#include <ostream>
|
||||||
#include <stdexcept>
|
#include <stdexcept>
|
||||||
#include <thread>
|
#include <thread>
|
||||||
@ -25,22 +23,6 @@ typedef unsigned int u8;
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
float angleToRad(float angle){
|
float angleToRad(float angle){
|
||||||
return angle/180*PI;
|
return angle/180*PI;
|
||||||
}
|
}
|
||||||
@ -99,8 +81,8 @@ int main(){
|
|||||||
glClear(GL_COLOR_BUFFER_BIT);
|
glClear(GL_COLOR_BUFFER_BIT);
|
||||||
render();
|
render();
|
||||||
glfwSwapBuffers(window);
|
glfwSwapBuffers(window);
|
||||||
|
// std::this_thread::sleep_for(std::chrono::milliseconds(1000/F_PER_SECOND));
|
||||||
glfwPollEvents();
|
glfwPollEvents();
|
||||||
std::this_thread::sleep_for(std::chrono::milliseconds(1000/F_PER_SECOND));
|
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user