Add project files.

This commit is contained in:
2026-05-20 11:30:06 +03:00
parent fd11dfd2cc
commit 080c675bd8
12 changed files with 10856 additions and 0 deletions
+111
View File
@@ -0,0 +1,111 @@
#pragma once
#include <raylib.h>
#include <string>
#include <vector>
// Game States & Configurations
enum class GameState {
MainMenu,
Playing,
Paused,
GameOver
};
enum class Difficulty {
Easy,
Normal,
Hard
};
constexpr float CPU_SPEED_EASY = 3.0f;
constexpr float CPU_SPEED_NORMAL = 5.5f;
constexpr float CPU_SPEED_HARD = 8.0f;
// --- Base Entities ---
class GameObject {
public:
Vector2 position;
Color color;
public:
GameObject(Vector2 pos, Color c) : position(pos), color(c) {}
virtual ~GameObject() = default;
virtual void Update() = 0;
virtual void Draw() = 0;
};
// --- Game Objects ---
class Paddle : public GameObject {
public:
float width;
float height;
Paddle(Vector2 pos, Color c, float w, float h)
: GameObject(pos, c), width(w), height(h) {
}
void Update() override;
void Draw() override;
};
class Ball : public GameObject {
public:
float radius;
Vector2 velocity;
Ball(Vector2 pos, Color c, float r)
: GameObject(pos, c), radius(r), velocity({ 5.0f, 5.0f }) {
}
void Update() override;
void Draw() override;
};
class CpuPaddle : public Paddle {
private:
float speed;
Difficulty currentDifficulty;
public:
CpuPaddle(Vector2 pos, Color c, float w, float h, Difficulty diff = Difficulty::Normal)
: Paddle(pos, c, w, h) {
SetDifficulty(diff);
}
void SetDifficulty(Difficulty diff) {
currentDifficulty = diff;
switch (currentDifficulty) {
case Difficulty::Easy: speed = CPU_SPEED_EASY; break;
case Difficulty::Normal: speed = CPU_SPEED_NORMAL; break;
case Difficulty::Hard: speed = CPU_SPEED_HARD; break;
}
}
void Update(float ball_y) {
float paddleCenter = position.y + (height / 2.0f);
if (paddleCenter > ball_y + speed) {
position.y -= speed;
}
else if (paddleCenter < ball_y - speed) {
position.y += speed;
}
LimitMovement();
}
void Update() override {}
void LimitMovement() {
if (position.y <= 0) {
position.y = 0;
}
if (position.y + height >= GetScreenHeight()) {
position.y = GetScreenHeight() - height;
}
}
};
+21
View File
@@ -0,0 +1,21 @@
#pragma once
#include "game.h"
#include <string>
#include <vector>
// --- UI / Systems ---
class Menu {
private:
std::string title;
std::vector<std::string> options;
int selectedIndex;
public:
Menu(std::string menuTitle, std::vector<std::string> menuOptions)
: title(menuTitle), options(menuOptions), selectedIndex(0) {
}
void Update(GameState& currentState);
void Draw();
};
+1743
View File
File diff suppressed because it is too large Load Diff
+3139
View File
File diff suppressed because it is too large Load Diff
+5421
View File
File diff suppressed because it is too large Load Diff