Add textures, gameplay pause, and menu state placeholders.

This commit is contained in:
2026-05-20 13:59:01 +03:00
parent 67f5fcf374
commit 25a7fefa04
11 changed files with 276 additions and 47 deletions
+30 -8
View File
@@ -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);
}
}