Add textures, gameplay pause, and menu state placeholders.
This commit is contained in:
+30
-8
@@ -13,16 +13,27 @@ void Paddle::Update() {
|
||||
}
|
||||
|
||||
// Limit movement
|
||||
if (position.y <= 0) {
|
||||
position.y = 0;
|
||||
if (position.y <= 20.0f) {
|
||||
position.y = 20.0f;
|
||||
}
|
||||
if (position.y + height >= GetScreenHeight()) {
|
||||
position.y = GetScreenHeight() - height;
|
||||
if (position.y + height >= GetScreenHeight() - 20.0f) {
|
||||
position.y = GetScreenHeight() - 20.0f - height;
|
||||
}
|
||||
}
|
||||
|
||||
void Paddle::Draw() {
|
||||
DrawRectangleRounded(Rectangle{ position.x, position.y, width, height }, 0.8f, 0, color);
|
||||
if (texture.id > 0) {
|
||||
DrawTexturePro(
|
||||
texture,
|
||||
Rectangle{ 0.0f, 0.0f, (float)texture.width, (float)texture.height },
|
||||
Rectangle{ position.x, position.y, width, height },
|
||||
Vector2{ 0.0f, 0.0f },
|
||||
0.0f,
|
||||
WHITE
|
||||
);
|
||||
} else {
|
||||
DrawRectangleRounded(Rectangle{ position.x, position.y, width, height }, 0.8f, 0, color);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -32,12 +43,23 @@ void Ball::Update() {
|
||||
position.x += velocity.x;
|
||||
position.y += velocity.y;
|
||||
|
||||
if (position.y + radius >= GetScreenHeight() || position.y - radius <= 0) {
|
||||
if (position.y + radius >= GetScreenHeight() - 20.0f || position.y - radius <= 20.0f) {
|
||||
velocity.y *= -1;
|
||||
}
|
||||
}
|
||||
|
||||
void Ball::Draw() {
|
||||
// Cast to int as DrawCircle expects integers for coordinates
|
||||
DrawCircle((int)position.x, (int)position.y, radius, color);
|
||||
if (texture.id > 0) {
|
||||
DrawTexturePro(
|
||||
texture,
|
||||
Rectangle{ 0.0f, 0.0f, (float)texture.width, (float)texture.height },
|
||||
Rectangle{ position.x - radius, position.y - radius, radius * 2.0f, radius * 2.0f },
|
||||
Vector2{ 0.0f, 0.0f },
|
||||
0.0f,
|
||||
WHITE
|
||||
);
|
||||
} else {
|
||||
// Cast to int as DrawCircle expects integers for coordinates
|
||||
DrawCircle((int)position.x, (int)position.y, radius, color);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user