Embed resources and update asset loading system

This commit is contained in:
2026-05-26 22:59:14 +03:00
parent 7493daf004
commit 45462a3ba7
12 changed files with 143 additions and 24 deletions
+12 -8
View File
@@ -65,6 +65,10 @@ struct GameContext {
Sound scoreSound = { 0 };
};
// Asset loading helpers
Texture2D LoadTextureFromResource(int id);
Sound LoadSoundFromResource(int id);
// Forward declarations
class Ball;
class Paddle;
@@ -99,10 +103,10 @@ public:
float width;
float height;
Texture2D texture;
Paddle(Vector2 pos, Color c, float w, float h, const std::string& texturePath = "")
Paddle(Vector2 pos, Color c, float w, float h, int textureId = 0)
: GameObject(pos, c), width(w), height(h) {
if (!texturePath.empty()) {
texture = LoadTexture(texturePath.c_str());
if (textureId > 0) {
texture = LoadTextureFromResource(textureId);
} else {
texture = { 0 };
}
@@ -125,10 +129,10 @@ public:
Texture2D texture;
public:
Ball(Vector2 pos, Color c, float r, const std::string& texturePath = "")
Ball(Vector2 pos, Color c, float r, int textureId = 0)
: GameObject(pos, c), radius(r), velocity({ 5.0f, 5.0f }) {
if (!texturePath.empty()) {
texture = LoadTexture(texturePath.c_str());
if (textureId > 0) {
texture = LoadTextureFromResource(textureId);
} else {
texture = { 0 };
}
@@ -150,8 +154,8 @@ private:
Difficulty currentDifficulty;
public:
CpuPaddle(Vector2 pos, Color c, float w, float h, Difficulty diff = Difficulty::Normal, const std::string& texturePath = "")
: Paddle(pos, c, w, h, texturePath) {
CpuPaddle(Vector2 pos, Color c, float w, float h, Difficulty diff = Difficulty::Normal, int textureId = 0)
: Paddle(pos, c, w, h, textureId) {
SetDifficulty(diff);
}
+1 -1
View File
@@ -1333,7 +1333,7 @@ RLAPI Vector2 GetSplinePointBezierCubic(Vector2 p1, Vector2 c2, Vector2 c3, Vect
// Basic shapes collision detection functions
RLAPI bool CheckCollisionRecs(Rectangle rec1, Rectangle rec2); // Check collision between two rectangles
RLAPI bool CheckCollisionCircles(Vector2 center1, float radius1, Vector2 center2, float radius2); // Check collision between two circles
RLAPI bool CheckCollisionCircleRec(Vector2 center, float radius, Rectangle rec); // Check collision between circle and rectangle
RLAPI bool CheckCollisionCircleRec(Vector2 center, float radius, Rectangle rec); // Check collision between circle and rectangle`
RLAPI bool CheckCollisionCircleLine(Vector2 center, float radius, Vector2 p1, Vector2 p2); // Check if circle collides with a line created betweeen two points [p1] and [p2]
RLAPI bool CheckCollisionPointRec(Vector2 point, Rectangle rec); // Check if point is inside rectangle
RLAPI bool CheckCollisionPointCircle(Vector2 point, Vector2 center, float radius); // Check if point is inside circle
+15
View File
@@ -0,0 +1,15 @@
#pragma once
#define IDI_ICON1 100
#define IDR_TEX_BASIC_SPACE 101
#define IDR_TEX_WALLS 102
#define IDR_TEX_LINE 103
#define IDR_TEX_BALL 104
#define IDR_TEX_PADDLE 105
#define IDR_TEX_PADDLE2 106
#define IDR_SND_PADDLE_HIT 201
#define IDR_SND_WALL_HIT 202
#define IDR_SND_SCORE 203
#define IDR_SND_BANANA 204