diff --git a/src/main.cpp b/src/main.cpp index 5cbfb92..3690f47 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -25,12 +25,12 @@ int main() { SetTargetFPS(60); - GenDefaultTexture(); + Texture Texturemissing = GenDefaultTexture(); raylib::Rectangle playerrect{screenWidth / 2.0f, screenHeight / 2.0f,64,64}; Entity player{1, playerrect, "MainPlayer", 100, 100}; player.controller = PlayerController; - player.spriteid = 1; + player.spriteid = 0; entityTextures.LoadImage("./src/assets/playersprite.png"); tileTextures.LoadImage("./src/assets/BasicTile.png"); @@ -52,13 +52,13 @@ int main() { BeginMode2D(camera); - camera.target = { player.rect.x, player.rect.y }; + camera.target = { player.rect.x + player.rect.width / 2.0f, player.rect.y + player.rect.height / 2.0f}; if (IsKeyDown(KEY_Q)) camera.zoom += 0.1f; DrawText("Middle", 190, 200, 20, WHITE); - Texture bg = tileTextures.GetTexture(1); + Texture bg = tileTextures.GetTexture(0); // Infinite Background int bh = bg.height; diff --git a/src/render/textures.cpp b/src/render/textures.cpp index dc365e0..25dba36 100644 --- a/src/render/textures.cpp +++ b/src/render/textures.cpp @@ -6,14 +6,15 @@ using namespace std; typedef int ID; +Texture defaultTexture; + TextureAtlas::TextureAtlas (){ atlas.clear(); - atlas.push_back(defaultTexture); } Texture TextureAtlas::GetTexture(ID id) { if (atlas.size() <= id) { - return atlas[0]; + return defaultTexture; } return atlas[id]; } @@ -26,15 +27,15 @@ void TextureAtlas::AddTexture(Texture texture){ atlas.push_back(texture); } -Texture defaultTexture; TextureAtlas entityTextures; TextureAtlas backgroundTextures; TextureAtlas tileTextures; -void GenDefaultTexture(){ - Image img = GenImageChecked(64, 64, 16, 16, PURPLE, BLACK); +Texture GenDefaultTexture(){ + Image img = GenImageChecked(64, 64, 32, 32, PURPLE, BLACK); defaultTexture = LoadTextureFromImage(img); UnloadImage(img); + return defaultTexture; } diff --git a/src/render/textures.hpp b/src/render/textures.hpp index 3e49d52..2b6d800 100644 --- a/src/render/textures.hpp +++ b/src/render/textures.hpp @@ -22,6 +22,6 @@ extern TextureAtlas entityTextures; extern TextureAtlas backgroundTextures; extern TextureAtlas tileTextures; -void GenDefaultTexture(); +Texture GenDefaultTexture(); #endif // !TEXTURES_HPP