Split 'paddle' class into header and implementation files
This commit is contained in:
		@@ -14,43 +14,25 @@ public:
 | 
			
		||||
	raylib::Vector2 velocity; /* This variable is made public to allow easy modification (no need for getters/setters) */
 | 
			
		||||
 | 
			
		||||
	/* Functions */
 | 
			
		||||
	Paddle(int pos_x, int pos_y, int width, int height) {
 | 
			
		||||
		this->rectangle = raylib::Rectangle(pos_x, pos_y, width, height);
 | 
			
		||||
		this->initial_pos = raylib::Vector2(pos_x, pos_y);
 | 
			
		||||
		this->color = raylib::Color::White();
 | 
			
		||||
		this->velocity = raylib::Vector2(0,0);
 | 
			
		||||
		points = 0;
 | 
			
		||||
		return;
 | 
			
		||||
	}
 | 
			
		||||
	Paddle(int pos_x, int pos_y, int width, int height);
 | 
			
		||||
 | 
			
		||||
	raylib::Rectangle getRect() {
 | 
			
		||||
		return this->rectangle;
 | 
			
		||||
	}
 | 
			
		||||
	/* Returns the raylib::Rectangle object of this paddle */
 | 
			
		||||
	raylib::Rectangle getRect();
 | 
			
		||||
 | 
			
		||||
	int getPoints() {
 | 
			
		||||
		return points;
 | 
			
		||||
	}
 | 
			
		||||
	void incrementPoints() {
 | 
			
		||||
		points++;
 | 
			
		||||
		return;
 | 
			
		||||
	}
 | 
			
		||||
	/* Returns the number of points that this paddle has earned */
 | 
			
		||||
	int getPoints();
 | 
			
		||||
 | 
			
		||||
	void reset() {
 | 
			
		||||
		this->rectangle.x = this->initial_pos.x;
 | 
			
		||||
		this->rectangle.y = this->initial_pos.y;
 | 
			
		||||
		this->velocity = raylib::Vector2(0,0);
 | 
			
		||||
		return;
 | 
			
		||||
	}
 | 
			
		||||
	/* Increments the number of points that this paddle has earned */
 | 
			
		||||
	void incrementPoints();
 | 
			
		||||
 | 
			
		||||
	void updatePosition() {
 | 
			
		||||
		this->rectangle.x += this->velocity.x;
 | 
			
		||||
		this->rectangle.y += this->velocity.y;
 | 
			
		||||
		return;
 | 
			
		||||
	}
 | 
			
		||||
	void draw() {
 | 
			
		||||
		this->rectangle.Draw(this->color);
 | 
			
		||||
		return;
 | 
			
		||||
	}
 | 
			
		||||
	/* Resets the paddle position */
 | 
			
		||||
	void reset();
 | 
			
		||||
 | 
			
		||||
	/* Update the paddle position, based on its velocity */
 | 
			
		||||
	void updatePosition();
 | 
			
		||||
 | 
			
		||||
	/* Draw the paddle onto the screen */
 | 
			
		||||
	void draw();
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
#endif
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										40
									
								
								paddle.cpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										40
									
								
								paddle.cpp
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,40 @@
 | 
			
		||||
#include "includes/raylib-cpp/raylib-cpp.hpp"
 | 
			
		||||
#include "includes/paddle.hpp"
 | 
			
		||||
 | 
			
		||||
Paddle::Paddle(int pos_x, int pos_y, int width, int height) {
 | 
			
		||||
	this->rectangle = raylib::Rectangle(pos_x, pos_y, width, height);
 | 
			
		||||
	this->initial_pos = raylib::Vector2(pos_x, pos_y);
 | 
			
		||||
	this->color = raylib::Color::White();
 | 
			
		||||
	this->velocity = raylib::Vector2(0,0);
 | 
			
		||||
	points = 0;
 | 
			
		||||
	return;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
raylib::Rectangle Paddle::getRect() {
 | 
			
		||||
	return this->rectangle;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
int Paddle::getPoints() {
 | 
			
		||||
	return points;
 | 
			
		||||
}
 | 
			
		||||
void Paddle::incrementPoints() {
 | 
			
		||||
	points++;
 | 
			
		||||
	return;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void Paddle::reset() {
 | 
			
		||||
	this->rectangle.x = this->initial_pos.x;
 | 
			
		||||
	this->rectangle.y = this->initial_pos.y;
 | 
			
		||||
	this->velocity = raylib::Vector2(0,0);
 | 
			
		||||
	return;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void Paddle::updatePosition() {
 | 
			
		||||
	this->rectangle.x += this->velocity.x;
 | 
			
		||||
	this->rectangle.y += this->velocity.y;
 | 
			
		||||
	return;
 | 
			
		||||
}
 | 
			
		||||
void Paddle::draw() {
 | 
			
		||||
	this->rectangle.Draw(this->color);
 | 
			
		||||
	return;
 | 
			
		||||
}
 | 
			
		||||
		Reference in New Issue
	
	Block a user