Manually scale textures to correct sizes
|
Before Width: | Height: | Size: 1.1 KiB After Width: | Height: | Size: 8.1 KiB |
|
Before Width: | Height: | Size: 228 KiB After Width: | Height: | Size: 912 KiB |
|
Before Width: | Height: | Size: 41 KiB |
|
Before Width: | Height: | Size: 1.7 MiB After Width: | Height: | Size: 375 KiB |
|
Before Width: | Height: | Size: 91 KiB |
|
Before Width: | Height: | Size: 8.1 KiB After Width: | Height: | Size: 32 KiB |
@@ -84,16 +84,16 @@ AssetModule::AssetModule(entt::registry& registry)
|
||||
// auto renderer = registry.ctx().get<SdlHandles>().renderer;
|
||||
|
||||
// auto* background = load_texture(BACKGROUND_DATA, sizeof(BACKGROUND_DATA), renderer);
|
||||
TextureAtlasLayout background_layout = {.width = 866, .height = 510, .rows = 1, .columns = 1};
|
||||
TextureAtlasLayout background_layout = {.width = 400, .height = 240, .rows = 1, .columns = 1};
|
||||
|
||||
// auto* fruits = load_texture(FRUITS_DATA, sizeof(FRUITS_DATA), renderer);
|
||||
TextureAtlasLayout fruits_layout = {.width = 16, .height = 16, .rows = 6, .columns = 38};
|
||||
TextureAtlasLayout fruits_layout = {.width = 32, .height = 32, .rows = 6, .columns = 38};
|
||||
|
||||
// auto* spiders = load_texture(SPIDERS_DATA, sizeof(SPIDERS_DATA), renderer);
|
||||
TextureAtlasLayout spiders_layout = {.width = 16, .height = 16, .rows = 2, .columns = 4};
|
||||
TextureAtlasLayout spiders_layout = {.width = 32, .height = 32, .rows = 2, .columns = 4};
|
||||
|
||||
// auto* basket = load_texture(BASKET_DATA, sizeof(BASKET_DATA), renderer);
|
||||
TextureAtlasLayout basket_layout = {.width = 16, .height = 16, .rows = 1, .columns = 1};
|
||||
TextureAtlasLayout basket_layout = {.width = 64, .height = 32, .rows = 1, .columns = 1};
|
||||
|
||||
// registry.ctx().emplace<TextureAssets>(TextureAssets{
|
||||
// .background = Texture{.sdl_texture = background, .texture_atlas_layout =
|
||||
|
||||
@@ -1,6 +1,35 @@
|
||||
#include "level.hpp"
|
||||
#include "input.hpp"
|
||||
|
||||
LevelModule::LevelModule(entt::registry& registry)
|
||||
{
|
||||
auto const* texture_assets = ®istry.ctx().get<TextureAssets>();
|
||||
|
||||
auto background = registry.create();
|
||||
registry.emplace<Position>(background, Position{.x = 0, .y = 0});
|
||||
registry.emplace<Sprite>(
|
||||
background, Sprite{.texture = &texture_assets->background, .texture_atlas_index = 0});
|
||||
registry.emplace<Size>(background, Size{.w = WINDOW_WIDTH, .h = WINDOW_HEIGHT});
|
||||
registry.emplace<Background>(background);
|
||||
|
||||
auto basket = registry.create();
|
||||
registry.emplace<WorldPosition>(basket);
|
||||
registry.emplace<Position>(basket,
|
||||
Position{.x = WINDOW_WIDTH / 2 - 32, .y = WINDOW_HEIGHT - 32});
|
||||
registry.emplace<Sprite>(basket,
|
||||
Sprite{.texture = &texture_assets->basket, .texture_atlas_index = 0});
|
||||
registry.emplace<Size>(basket, Size{.w = 64, .h = 32});
|
||||
registry.emplace<Basket>(basket);
|
||||
|
||||
auto basket_cb = registry.create();
|
||||
registry.emplace<WorldPosition>(basket_cb);
|
||||
registry.emplace<Position>(basket_cb, Position{.x = 0, .y = 16});
|
||||
registry.emplace<Size>(basket_cb, Size{.w = 64, .h = 16});
|
||||
registry.emplace<CollisionBox>(basket_cb);
|
||||
registry.emplace<Parent>(basket_cb, basket);
|
||||
registry.emplace<BasketCollisionBox>(basket_cb);
|
||||
}
|
||||
|
||||
void LevelModule::MoveBasket(entt::registry& registry)
|
||||
{
|
||||
auto const& input = registry.ctx().get<ButtonInput>();
|
||||
|
||||
@@ -32,34 +32,7 @@ struct BasketCollisionBox
|
||||
|
||||
struct LevelModule
|
||||
{
|
||||
LevelModule(entt::registry& registry)
|
||||
{
|
||||
auto const* texture_assets = ®istry.ctx().get<TextureAssets>();
|
||||
|
||||
auto background = registry.create();
|
||||
registry.emplace<Position>(background, Position{.x = 0, .y = 0});
|
||||
registry.emplace<Sprite>(
|
||||
background, Sprite{.texture = &texture_assets->background, .texture_atlas_index = 0});
|
||||
registry.emplace<Size>(background, Size{.w = WINDOW_WIDTH, .h = WINDOW_HEIGHT});
|
||||
registry.emplace<Background>(background);
|
||||
|
||||
auto basket = registry.create();
|
||||
registry.emplace<WorldPosition>(basket);
|
||||
registry.emplace<Position>(basket,
|
||||
Position{.x = WINDOW_WIDTH / 2 - 32, .y = WINDOW_HEIGHT - 32});
|
||||
registry.emplace<Sprite>(
|
||||
basket, Sprite{.texture = &texture_assets->basket, .texture_atlas_index = 0});
|
||||
registry.emplace<Size>(basket, Size{.w = 64, .h = 32});
|
||||
registry.emplace<Basket>(basket);
|
||||
|
||||
auto basket_cb = registry.create();
|
||||
registry.emplace<WorldPosition>(basket_cb);
|
||||
registry.emplace<Position>(basket_cb, Position{.x = 0, .y = 16});
|
||||
registry.emplace<Size>(basket_cb, Size{.w = 64, .h = 16});
|
||||
registry.emplace<CollisionBox>(basket_cb);
|
||||
registry.emplace<Parent>(basket_cb, basket);
|
||||
registry.emplace<BasketCollisionBox>(basket_cb);
|
||||
}
|
||||
LevelModule(entt::registry& registry);
|
||||
|
||||
static void MoveBasket(entt::registry& registry);
|
||||
static void SpawnFruits(entt::registry& registry);
|
||||
|
||||