Fixed how sprites/textures are loaded so tehy default to frame 0 of any multi-frame textures.
This commit is contained in:
parent
6d73c87c4e
commit
b832bbd78a
7 changed files with 294 additions and 70 deletions
2
Makefile
2
Makefile
|
@ -41,7 +41,7 @@ clean:
|
||||||
meson compile --clean -C builddir
|
meson compile --clean -C builddir
|
||||||
|
|
||||||
debug_test: build
|
debug_test: build
|
||||||
gdb --nx -x .gdbinit --ex run --args builddir/runtests.exe -e
|
gdb --nx -x .gdbinit --ex run --args builddir/runtests.exe -e "[animation-fail]"
|
||||||
|
|
||||||
win_installer:
|
win_installer:
|
||||||
powershell 'start "C:\Program Files (x86)\solicus\InstallForge\bin\ifbuilderenvx86.exe" win_installer.ifp'
|
powershell 'start "C:\Program Files (x86)\solicus\InstallForge\bin\ifbuilderenvx86.exe" win_installer.ifp'
|
||||||
|
|
|
@ -20,68 +20,288 @@
|
||||||
"ambient_1": "assets/sounds/ambient_1.ogg"
|
"ambient_1": "assets/sounds/ambient_1.ogg"
|
||||||
},
|
},
|
||||||
"sprites": {
|
"sprites": {
|
||||||
"armored_knight": "assets/armored_knight_1-256.png",
|
"armored_knight":
|
||||||
"sword": "assets/cinqueda_1-512.png",
|
{"path": "assets/armored_knight_1-256.png",
|
||||||
"rat_with_sword": "assets/rat_with_sword-256.png",
|
"frame_width": 256,
|
||||||
"rat_king": "assets/rat_king-256.png",
|
"frame_height": 256
|
||||||
"rat_king_boss": "assets/rat_king_2_frame_animation.png",
|
},
|
||||||
"barrel_small": "assets/wood_barrel_small-256.png",
|
"sword":
|
||||||
"hanging_brazier": "assets/hanging_brazier-256.png",
|
{"path": "assets/cinqueda_1-256.png",
|
||||||
"torch_pillar": "assets/torch_pillar-256.png",
|
"frame_width": 256,
|
||||||
"torch_crappy": "assets/torch_crappy-256.png",
|
"frame_height": 256
|
||||||
"torch_horizontal_floor": "assets/torch_horizontal_floor-256.png",
|
},
|
||||||
"evil_eye": "assets/evil_eye-sprites.png",
|
"rat_with_sword":
|
||||||
"peasant_girl": "assets/undead_peasant-256.png",
|
{"path": "assets/rat_with_sword-256.png",
|
||||||
"grave_stone": "assets/grave_stone-256.png",
|
"frame_width": 256,
|
||||||
"floor": "assets/floor_tile_test-256.png",
|
"frame_height": 256
|
||||||
"ceiling": "assets/ceiling_test-256.png",
|
},
|
||||||
"healing_potion_small": "assets/healing_potion_small-256.png",
|
"rat_king":
|
||||||
"well_down": "assets/well_down-256.png",
|
{"path": "assets/rat_king-256.png",
|
||||||
"rope_vines_up": "assets/rope_vines_up-256.png",
|
"frame_width": 256,
|
||||||
"tripwire_trap": "assets/tripwire_trap-256.png",
|
"frame_height": 256
|
||||||
"cinqueda": "assets/cinqueda_1-256.png",
|
},
|
||||||
"left_gui": "assets/left_gui.png",
|
"rat_king_boss":
|
||||||
"blood_splatter": "assets/blood_splatter-256.png",
|
{"path": "assets/rat_king_2_frame_animation.png",
|
||||||
"trash_button": "assets/trash_button.png",
|
"frame_width": 256,
|
||||||
"axe_ranger": "assets/axe_ranger-256.png",
|
"frame_height": 256
|
||||||
"hairy_spider": "assets/hairy_spider-256.png",
|
},
|
||||||
"down_the_well": "assets/down_the_well.jpg",
|
"barrel_small":
|
||||||
"boss_fight_background": "assets/rat_king_boss_fight_background.jpg",
|
{"path": "assets/wood_barrel_small-256.png",
|
||||||
"devils_fingers_background": "assets/devils_fingers_background.jpg",
|
"frame_width": 256,
|
||||||
"devils_fingers_sprite": "assets/devils_fingers_sprite.png",
|
"frame_height": 256
|
||||||
"devils_fingers_stage": "assets/devils_fingers_stage.png",
|
},
|
||||||
"tunnel_with_rocks": "assets/tunnel_with_rocks.png",
|
"torch_pillar":
|
||||||
"tunnel_with_rocks_stage": "assets/tunnel_with_rocks_stage.png",
|
{"path": "assets/torch_pillar-256.png",
|
||||||
"ritual_crafting_area": "assets/ritual_crafting_area.png",
|
"frame_width": 256,
|
||||||
"the_ritual_circle": "assets/the_ritual_circle.png",
|
"frame_height": 256
|
||||||
"paper_ui_background": "assets/paper_ui_background.png",
|
},
|
||||||
"full_screen_paper": "assets/full_screen_paper.png",
|
"torch_crappy":
|
||||||
"broken_locket-64": "assets/rituals/broken_locket-64.png",
|
{"path": "assets/torch_crappy-256.png",
|
||||||
"broken_locket-128": "assets/rituals/broken_locket-128.png",
|
"frame_width": 256,
|
||||||
"broken_pen_knife-64": "assets/rituals/broken_pen_knife-64.png",
|
"frame_height": 256
|
||||||
"broken_pen_knife-128": "assets/rituals/broken_pen_knife-128.png",
|
},
|
||||||
"broken_yoyo-64": "assets/rituals/broken_yoyo-64.png",
|
"torch_horizontal_floor":
|
||||||
"broken_yoyo-128": "assets/rituals/broken_yoyo-128.png",
|
{"path": "assets/torch_horizontal_floor-256.png",
|
||||||
"chess_pawn-64": "assets/rituals/chess_pawn-64.png",
|
"frame_width": 256,
|
||||||
"chess_pawn-128": "assets/rituals/chess_pawn-128.png",
|
"frame_height": 256
|
||||||
"dirty_kerchief-64": "assets/rituals/dirty_kerchief-64.png",
|
},
|
||||||
"dirty_kerchief-128": "assets/rituals/dirty_kerchief-128.png",
|
"evil_eye":
|
||||||
"leather_pouch-64": "assets/rituals/leather_pouch-64.png",
|
{"path": "assets/evil_eye-sprites.png",
|
||||||
"leather_pouch-128": "assets/rituals/leather_pouch-128.png",
|
"frame_width": 256,
|
||||||
"mushroom-64": "assets/rituals/mushroom-64.png",
|
"frame_height": 256
|
||||||
"mushroom-128": "assets/rituals/mushroom-128.png",
|
},
|
||||||
"pocket_watch-64": "assets/rituals/pocket_watch-64.png",
|
"peasant_girl":
|
||||||
"pocket_watch-128": "assets/rituals/pocket_watch-128.png",
|
{"path": "assets/undead_peasant-256.png",
|
||||||
"rusty_nails-64": "assets/rituals/rusty_nails-64.png",
|
"frame_width": 256,
|
||||||
"rusty_nails-128": "assets/rituals/rusty_nails-128.png",
|
"frame_height": 256
|
||||||
"severed_finger-64": "assets/rituals/severed_finger-64.png",
|
},
|
||||||
"severed_finger-128": "assets/rituals/severed_finger-128.png",
|
"grave_stone":
|
||||||
"stone_doll_cursed-64": "assets/rituals/stone_doll_cursed-64.png",
|
{"path": "assets/grave_stone-256.png",
|
||||||
"stone_doll_cursed-128": "assets/rituals/stone_doll_cursed-128.png"
|
"frame_width": 256,
|
||||||
|
"frame_height": 256
|
||||||
|
},
|
||||||
|
"floor":
|
||||||
|
{"path": "assets/floor_tile_test-256.png",
|
||||||
|
"frame_width": 256,
|
||||||
|
"frame_height": 256
|
||||||
|
},
|
||||||
|
"ceiling":
|
||||||
|
{"path": "assets/ceiling_test-256.png",
|
||||||
|
"frame_width": 256,
|
||||||
|
"frame_height": 256
|
||||||
|
},
|
||||||
|
"healing_potion_small":
|
||||||
|
{"path": "assets/healing_potion_small-256.png",
|
||||||
|
"frame_width": 256,
|
||||||
|
"frame_height": 256
|
||||||
|
},
|
||||||
|
"well_down":
|
||||||
|
{"path": "assets/well_down-256.png",
|
||||||
|
"frame_width": 256,
|
||||||
|
"frame_height": 256
|
||||||
|
},
|
||||||
|
"rope_vines_up":
|
||||||
|
{"path": "assets/rope_vines_up-256.png",
|
||||||
|
"frame_width": 256,
|
||||||
|
"frame_height": 256
|
||||||
|
},
|
||||||
|
"tripwire_trap":
|
||||||
|
{"path": "assets/tripwire_trap-256.png",
|
||||||
|
"frame_width": 256,
|
||||||
|
"frame_height": 256
|
||||||
|
},
|
||||||
|
"cinqueda":
|
||||||
|
{"path": "assets/cinqueda_1-256.png",
|
||||||
|
"frame_width": 256,
|
||||||
|
"frame_height": 256
|
||||||
|
},
|
||||||
|
"blood_splatter":
|
||||||
|
{"path": "assets/blood_splatter-256.png",
|
||||||
|
"frame_width": 256,
|
||||||
|
"frame_height": 256
|
||||||
|
},
|
||||||
|
"axe_ranger":
|
||||||
|
{"path": "assets/axe_ranger-256.png",
|
||||||
|
"frame_width": 256,
|
||||||
|
"frame_height": 256
|
||||||
|
},
|
||||||
|
"hairy_spider":
|
||||||
|
{"path": "assets/hairy_spider-256.png",
|
||||||
|
"frame_width": 256,
|
||||||
|
"frame_height": 256
|
||||||
|
},
|
||||||
|
"down_the_well":
|
||||||
|
{"path": "assets/down_the_well.jpg",
|
||||||
|
"frame_width": 900,
|
||||||
|
"frame_height": 600
|
||||||
|
},
|
||||||
|
"boss_fight_background":
|
||||||
|
{"path": "assets/rat_king_boss_fight_background.jpg",
|
||||||
|
"frame_width": 1080,
|
||||||
|
"frame_height": 720
|
||||||
|
},
|
||||||
|
"devils_fingers_background":
|
||||||
|
{"path": "assets/devils_fingers_background.jpg",
|
||||||
|
"frame_width": 1080,
|
||||||
|
"frame_height": 720
|
||||||
|
},
|
||||||
|
"devils_fingers_sprite":
|
||||||
|
{"path": "assets/devils_fingers_sprite.png",
|
||||||
|
"frame_width": 720,
|
||||||
|
"frame_height": 720
|
||||||
|
},
|
||||||
|
"devils_fingers_stage":
|
||||||
|
{"path": "assets/devils_fingers_stage.png",
|
||||||
|
"frame_width": 1080,
|
||||||
|
"frame_height": 720
|
||||||
|
},
|
||||||
|
"tunnel_with_rocks":
|
||||||
|
{"path": "assets/tunnel_with_rocks.png",
|
||||||
|
"frame_width": 1080,
|
||||||
|
"frame_height": 720
|
||||||
|
},
|
||||||
|
"tunnel_with_rocks_stage":
|
||||||
|
{"path": "assets/tunnel_with_rocks_stage.png",
|
||||||
|
"frame_width": 1080,
|
||||||
|
"frame_height": 720
|
||||||
|
},
|
||||||
|
"ritual_crafting_area":
|
||||||
|
{"path": "assets/ritual_crafting_area.png",
|
||||||
|
"frame_width": 380,
|
||||||
|
"frame_height": 720
|
||||||
|
},
|
||||||
|
"the_ritual_circle":
|
||||||
|
{"path": "assets/the_ritual_circle.png",
|
||||||
|
"frame_width": 380,
|
||||||
|
"frame_height": 380
|
||||||
|
},
|
||||||
|
"paper_ui_background":
|
||||||
|
{"path": "assets/paper_ui_background.png",
|
||||||
|
"frame_width": 380,
|
||||||
|
"frame_height": 720
|
||||||
|
},
|
||||||
|
"full_screen_paper":
|
||||||
|
{"path": "assets/full_screen_paper.png",
|
||||||
|
"frame_width": 1280,
|
||||||
|
"frame_height": 720
|
||||||
|
},
|
||||||
|
"broken_locket-64":
|
||||||
|
{"path": "assets/rituals/broken_locket-64.png",
|
||||||
|
"frame_width": 64,
|
||||||
|
"frame_height": 64
|
||||||
|
},
|
||||||
|
"broken_locket-128":
|
||||||
|
{"path": "assets/rituals/broken_locket-128.png",
|
||||||
|
"frame_width": 128,
|
||||||
|
"frame_height": 128
|
||||||
|
},
|
||||||
|
"broken_pen_knife-64":
|
||||||
|
{"path": "assets/rituals/broken_pen_knife-64.png",
|
||||||
|
"frame_width": 64,
|
||||||
|
"frame_height": 64
|
||||||
|
},
|
||||||
|
"broken_pen_knife-128":
|
||||||
|
{"path": "assets/rituals/broken_pen_knife-128.png",
|
||||||
|
"frame_width": 128,
|
||||||
|
"frame_height": 128
|
||||||
|
},
|
||||||
|
"broken_yoyo-64":
|
||||||
|
{"path": "assets/rituals/broken_yoyo-64.png",
|
||||||
|
"frame_width": 64,
|
||||||
|
"frame_height": 64
|
||||||
|
},
|
||||||
|
"broken_yoyo-128":
|
||||||
|
{"path": "assets/rituals/broken_yoyo-128.png",
|
||||||
|
"frame_width": 128,
|
||||||
|
"frame_height": 128
|
||||||
|
},
|
||||||
|
"chess_pawn-64":
|
||||||
|
{"path": "assets/rituals/chess_pawn-64.png",
|
||||||
|
"frame_width": 64,
|
||||||
|
"frame_height": 64
|
||||||
|
},
|
||||||
|
"chess_pawn-128":
|
||||||
|
{"path": "assets/rituals/chess_pawn-128.png",
|
||||||
|
"frame_width": 128,
|
||||||
|
"frame_height": 128
|
||||||
|
},
|
||||||
|
"dirty_kerchief-64":
|
||||||
|
{"path": "assets/rituals/dirty_kerchief-64.png",
|
||||||
|
"frame_width": 64,
|
||||||
|
"frame_height": 64
|
||||||
|
},
|
||||||
|
"dirty_kerchief-128":
|
||||||
|
{"path": "assets/rituals/dirty_kerchief-128.png",
|
||||||
|
"frame_width": 128,
|
||||||
|
"frame_height": 128
|
||||||
|
},
|
||||||
|
"leather_pouch-64":
|
||||||
|
{"path": "assets/rituals/leather_pouch-64.png",
|
||||||
|
"frame_width": 64,
|
||||||
|
"frame_height": 64
|
||||||
|
},
|
||||||
|
"leather_pouch-128":
|
||||||
|
{"path": "assets/rituals/leather_pouch-128.png",
|
||||||
|
"frame_width": 128,
|
||||||
|
"frame_height": 128
|
||||||
|
},
|
||||||
|
"mushroom-64":
|
||||||
|
{"path": "assets/rituals/mushroom-64.png",
|
||||||
|
"frame_width": 64,
|
||||||
|
"frame_height": 64
|
||||||
|
},
|
||||||
|
"mushroom-128":
|
||||||
|
{"path": "assets/rituals/mushroom-128.png",
|
||||||
|
"frame_width": 128,
|
||||||
|
"frame_height": 128
|
||||||
|
},
|
||||||
|
"pocket_watch-64":
|
||||||
|
{"path": "assets/rituals/pocket_watch-64.png",
|
||||||
|
"frame_width": 64,
|
||||||
|
"frame_height": 64
|
||||||
|
},
|
||||||
|
"pocket_watch-128":
|
||||||
|
{"path": "assets/rituals/pocket_watch-128.png",
|
||||||
|
"frame_width": 128,
|
||||||
|
"frame_height": 128
|
||||||
|
},
|
||||||
|
"rusty_nails-64":
|
||||||
|
{"path": "assets/rituals/rusty_nails-64.png",
|
||||||
|
"frame_width": 64,
|
||||||
|
"frame_height": 64
|
||||||
|
},
|
||||||
|
"rusty_nails-128":
|
||||||
|
{"path": "assets/rituals/rusty_nails-128.png",
|
||||||
|
"frame_width": 128,
|
||||||
|
"frame_height": 128
|
||||||
|
},
|
||||||
|
"severed_finger-64":
|
||||||
|
{"path": "assets/rituals/severed_finger-64.png",
|
||||||
|
"frame_width": 64,
|
||||||
|
"frame_height": 64
|
||||||
|
},
|
||||||
|
"severed_finger-128":
|
||||||
|
{"path": "assets/rituals/severed_finger-128.png",
|
||||||
|
"frame_width": 128,
|
||||||
|
"frame_height": 128
|
||||||
|
},
|
||||||
|
"stone_doll_cursed-64":
|
||||||
|
{"path": "assets/rituals/stone_doll_cursed-64.png",
|
||||||
|
"frame_width": 64,
|
||||||
|
"frame_height": 64
|
||||||
|
},
|
||||||
|
"stone_doll_cursed-128":
|
||||||
|
{"path": "assets/rituals/stone_doll_cursed-128.png",
|
||||||
|
"frame_width": 128,
|
||||||
|
"frame_height": 128
|
||||||
|
}
|
||||||
},
|
},
|
||||||
"worldgen": {
|
"worldgen": {
|
||||||
"enemy_probability": 50,
|
"enemy_probability": 50,
|
||||||
"empty_room_probability": 1,
|
"empty_room_probability": 1,
|
||||||
"device_probability": 10
|
"device_probability": 10
|
||||||
|
},
|
||||||
|
"graphics": {
|
||||||
|
"smooth_textures": true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Binary file not shown.
Before Width: | Height: | Size: 85 KiB |
Binary file not shown.
Before Width: | Height: | Size: 36 KiB |
|
@ -28,14 +28,16 @@ namespace guecs {
|
||||||
|
|
||||||
void Sprite::init(lel::Cell &cell) {
|
void Sprite::init(lel::Cell &cell) {
|
||||||
auto sprite_texture = textures::get(name);
|
auto sprite_texture = textures::get(name);
|
||||||
texture = sprite_texture.texture;
|
|
||||||
sprite = make_shared<sf::Sprite>(*texture);
|
sprite = make_shared<sf::Sprite>(
|
||||||
|
*sprite_texture.texture,
|
||||||
|
sprite_texture.sprite->getTextureRect());
|
||||||
|
|
||||||
sprite->setPosition({
|
sprite->setPosition({
|
||||||
float(cell.x + padding),
|
float(cell.x + padding),
|
||||||
float(cell.y + padding)});
|
float(cell.y + padding)});
|
||||||
|
|
||||||
auto bounds = sprite->getGlobalBounds();
|
auto bounds = sprite->getLocalBounds();
|
||||||
|
|
||||||
sprite->setScale({
|
sprite->setScale({
|
||||||
float(cell.w - padding * 2) / bounds.size.x,
|
float(cell.w - padding * 2) / bounds.size.x,
|
||||||
|
|
|
@ -38,7 +38,7 @@ TEST_CASE("animation easing tests", "[animation]") {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
TEST_CASE("animation utility API", "[animation]") {
|
TEST_CASE("animation utility API", "[animation-fail]") {
|
||||||
textures::init();
|
textures::init();
|
||||||
animation::init();
|
animation::init();
|
||||||
|
|
||||||
|
|
16
textures.cpp
16
textures.cpp
|
@ -15,19 +15,21 @@ namespace textures {
|
||||||
void load_sprites() {
|
void load_sprites() {
|
||||||
Config assets("assets/config.json");
|
Config assets("assets/config.json");
|
||||||
|
|
||||||
for(auto& el : assets["sprites"].items()) {
|
for(auto& [name, settings] : assets["sprites"].items()) {
|
||||||
string path = el.value();
|
auto texture = make_shared<sf::Texture>(settings["path"]);
|
||||||
auto texture = make_shared<sf::Texture>(path);
|
|
||||||
|
|
||||||
texture->setSmooth(false);
|
texture->setSmooth(assets["graphics"]["smooth_textures"]);
|
||||||
auto sprite = make_shared<sf::Sprite>(*texture);
|
auto sprite = make_shared<sf::Sprite>(*texture);
|
||||||
|
|
||||||
string name = el.key();
|
int width = settings["frame_width"];
|
||||||
|
int height = settings["frame_height"];
|
||||||
|
sprite->setTextureRect({{0,0}, {width, height}});
|
||||||
|
|
||||||
TMGR.sprite_textures.try_emplace(name, name, sprite, texture);
|
TMGR.sprite_textures.try_emplace(name, name, sprite, texture);
|
||||||
}
|
}
|
||||||
|
|
||||||
TMGR.floor = load_image(assets["sprites"]["floor"]);
|
TMGR.floor = load_image(assets["sprites"]["floor"]["path"]);
|
||||||
TMGR.ceiling = load_image(assets["sprites"]["ceiling"]);
|
TMGR.ceiling = load_image(assets["sprites"]["ceiling"]["path"]);
|
||||||
}
|
}
|
||||||
|
|
||||||
void load_tiles() {
|
void load_tiles() {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue