diff --git a/assets.cpp b/assets.cpp index 962d313..ddeb977 100644 --- a/assets.cpp +++ b/assets.cpp @@ -13,6 +13,10 @@ static constexpr uint8_t FRUITS_DATA[] = { #embed "assets/images/fruits.bmp" }; +static constexpr uint8_t BASKET_DATA[] = { +#embed "assets/images/basket.bmp" +}; + static constexpr uint8_t BACKGROUND_MUSIC_DATA[] = { #embed "assets/sounds/JamaicanSunrise.wav" }; @@ -58,11 +62,17 @@ void init_assets(flecs::world &world) { TextureAtlasLayout fruits_layout = { .width = 16, .height = 16, .rows = 6, .columns = 38}; + auto *basket = load_texture(BASKET_DATA, sizeof(BASKET_DATA), renderer); + TextureAtlasLayout basket_layout = { + .width = 16, .height = 16, .rows = 1, .columns = 1}; + world.set(TextureAssets{ .background = Texture{.sdl_texture = background, .texture_atlas_layout = background_layout}, - .fruits = Texture{.sdl_texture = fruits, - .texture_atlas_layout = fruits_layout}}); + .fruits = + Texture{.sdl_texture = fruits, .texture_atlas_layout = fruits_layout}, + .basket = Texture{.sdl_texture = basket, + .texture_atlas_layout = basket_layout}}); auto background_music = load_audio(BACKGROUND_MUSIC_DATA, sizeof(BACKGROUND_MUSIC_DATA)); diff --git a/assets.hpp b/assets.hpp index e0e9c3b..b4d76dd 100644 --- a/assets.hpp +++ b/assets.hpp @@ -20,6 +20,7 @@ struct Texture { struct TextureAssets { Texture background; Texture fruits; + Texture basket; }; struct AudioAssets { diff --git a/assets/images/basket.bmp b/assets/images/basket.bmp new file mode 100644 index 0000000..40298a9 Binary files /dev/null and b/assets/images/basket.bmp differ diff --git a/main.cpp b/main.cpp index d62b41d..a460f8f 100644 --- a/main.cpp +++ b/main.cpp @@ -80,9 +80,9 @@ int main() { world.entity("Basket") .set( Position{.x = WINDOW_WIDTH / 2 - 32, .y = WINDOW_HEIGHT - 32}) - .set(Sprite{.texture = &texture_assets->fruits, - .texture_atlas_index = 212}) - .set(Size{.w = 72, .h = 32}) + .set(Sprite{.texture = &texture_assets->basket, + .texture_atlas_index = 0}) + .set(Size{.w = 64, .h = 32}) .add(); world.system("SpawnFruits")