You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
40 lines
747 B
C++
40 lines
747 B
C++
11 months ago
|
#ifndef BALL_H
|
||
|
#define BALL_H
|
||
|
|
||
|
class Ball {
|
||
|
public:
|
||
|
/* Variables */
|
||
|
raylib::Vector2 pos;
|
||
|
raylib::Vector2 vel;
|
||
|
int radius;
|
||
|
raylib::Color color;
|
||
|
|
||
|
/* Functions */
|
||
|
Ball(int pos_x, int pos_y, int radius, int vel_x = 0, int vel_y = 0) {
|
||
|
this->pos = raylib::Vector2(pos_x, pos_y);
|
||
|
this->radius = radius;
|
||
|
this->color = raylib::Color::White();
|
||
|
this->vel = raylib::Vector2(vel_x, vel_y);
|
||
|
return;
|
||
|
}
|
||
|
|
||
|
void setPosition(Vector2 pos) {
|
||
|
this->pos = pos;
|
||
|
}
|
||
|
|
||
|
void updatePosition() {
|
||
|
this->pos.x += this->vel.x;
|
||
|
this->pos.y += this->vel.y;
|
||
|
return;
|
||
|
}
|
||
|
|
||
|
void draw() {
|
||
|
updatePosition();
|
||
|
DrawCircle(this->pos.x, this->pos.y, this->radius, this->color); // This is a raylib function, not a raylib-cpp function
|
||
|
return;
|
||
|
}
|
||
|
|
||
|
};
|
||
|
|
||
|
#endif
|