diff --git a/assets/config.json b/assets/config.json index 7198d07..ea0fd89 100644 --- a/assets/config.json +++ b/assets/config.json @@ -7,13 +7,14 @@ "Medium_Rat": "assets/sounds/Creature_Sounds-Medium_Rat.ogg", "Ranger_1": "assets/sounds/Creature_Sounds-Ranger_1.ogg", "Small_Rat": "assets/sounds/Creature_Sounds-Small_Rat.ogg", - "Spider_1": "assets/sounds/Creature_Sounds-Spider_1-001.ogg", - "Spider_2": "assets/sounds/Creature_Sounds-Spider_1-002.ogg", + "Spider_1": "assets/sounds/Creature_Sounds-Spider_1.ogg", + "Spider_2": "assets/sounds/Creature_Sounds-Spider_2.ogg", "Sword_Hit_1": "assets/sounds/Creature_Sounds-Sword_Hit_1.ogg", "Sword_Hit_2": "assets/sounds/Creature_Sounds-Sword_Hit_2.ogg", "walk": "assets/sounds/Creature_Sounds-Walk.ogg", "Creature_Death_1": "assets/sounds/Creature_Sounds-Creature_Death_1.ogg", "Humanoid_Death_1": "assets/sounds/Creature_Sounds-Humanoid_Death_1.ogg", + "Marmot_Scream_1": "assets/sounds/Creature_Sounds-Marmot_Scream_1.ogg", "blank": "assets/sounds/blank.ogg", "pickup": "assets/sounds/pickup.ogg", "ambient_1": "assets/sounds/ambient_1.ogg" @@ -23,6 +24,7 @@ "sword": "assets/cinqueda_1-512.png", "rat_with_sword": "assets/rat_with_sword-256.png", "rat_king": "assets/rat_king-256.png", + "rat_king_boss": "assets/rat_king_2_frame_animation.png", "barrel_small": "assets/wood_barrel_small-256.png", "hanging_brazier": "assets/hanging_brazier-256.png", "torch_pillar": "assets/torch_pillar-256.png", @@ -44,8 +46,7 @@ "axe_ranger": "assets/axe_ranger-256.png", "hairy_spider": "assets/hairy_spider-256.png", "down_the_well": "assets/down_the_well.jpg", - "boss_fight_background": "assets/rat_king_boss_fight_background.jpg", - "boss_fight": "assets/rat_king_boss_fight_sprite.png" + "boss_fight_background": "assets/rat_king_boss_fight_background.jpg" }, "enemy": { "HEARING_DISTANCE": 5 diff --git a/assets/enemies.json b/assets/enemies.json index c9d266d..9649323 100644 --- a/assets/enemies.json +++ b/assets/enemies.json @@ -35,7 +35,7 @@ {"_type": "Motion", "dx": 0, "dy": 0, "random": true}, {"_type": "EnemyConfig", "hearing_distance": 5}, {"_type": "Sprite", "name": "axe_ranger"}, - {"_type": "Animation", "easing": 3, "ease_rate": 0.5, "scale": 0.1, "simple": false, "frames": 10, "speed": 0.6}, + {"_type": "Animation", "easing": 3, "ease_rate": 0.5, "scale": 0.1, "simple": false, "frames": 2, "speed": 0.6}, {"_type": "Sound", "attack": "Sword_Hit_2", "death": "Ranger_1"} ] }, @@ -49,7 +49,7 @@ {"_type": "Motion", "dx": 0, "dy": 0, "random": false}, {"_type": "EnemyConfig", "hearing_distance": 5}, {"_type": "Sprite", "name": "evil_eye"}, - {"_type": "Animation", "easing": 3, "ease_rate": 0.1, "scale": 0.1, "simple": false, "frames": 10, "speed": 0.3}, + {"_type": "Animation", "easing": 3, "ease_rate": 0.1, "scale": 0.1, "simple": false, "frames": 2, "speed": 0.3}, {"_type": "Sound", "attack": "Evil_Eye_Sound_2", "death": "Evil_Eye_Sound_1"} ] }, @@ -68,6 +68,7 @@ ] }, "RAT_KING": { + "placement": "fixed", "components": [ {"_type": "Tile", "display": "\u08ac", "foreground": [205, 164, 100], @@ -76,9 +77,9 @@ {"_type": "Combat", "hp": 50, "max_hp": 50, "damage": 50, "dead": false}, {"_type": "Motion", "dx": 0, "dy": 0, "random": false}, {"_type": "EnemyConfig", "hearing_distance": 3}, - {"_type": "Animation", "easing": 2, "ease_rate": 0.2, "scale": 0.1, "simple": true, "frames": 10, "speed": 1.0}, - {"_type": "Sprite", "name": "rat_king"}, - {"_type": "Sound", "attack": "Sword_Hit_2", "death": "Creature_Death_1"} + {"_type": "Animation", "easing": 2, "ease_rate": 0.2, "scale": 0.2, "simple": false, "frames": 2, "speed": 0.02}, + {"_type": "Sprite", "name": "rat_king_boss"}, + {"_type": "Sound", "attack": "Marmot_Scream_1", "death": "Creature_Death_1"} ] }, "SPIDER_GIANT_HAIRY": { diff --git a/assets/rat_king_2_frame_animation.png b/assets/rat_king_2_frame_animation.png new file mode 100644 index 0000000..06e3c6f Binary files /dev/null and b/assets/rat_king_2_frame_animation.png differ diff --git a/assets/sounds/Creature_Sounds-Creature_Death_1.ogg b/assets/sounds/Creature_Sounds-Creature_Death_1.ogg index baec93b..49b3caf 100644 Binary files a/assets/sounds/Creature_Sounds-Creature_Death_1.ogg and b/assets/sounds/Creature_Sounds-Creature_Death_1.ogg differ diff --git a/assets/sounds/Creature_Sounds-Evil_Eye_Sound_1.ogg b/assets/sounds/Creature_Sounds-Evil_Eye_Sound_1.ogg index 62f1169..4e42118 100644 Binary files a/assets/sounds/Creature_Sounds-Evil_Eye_Sound_1.ogg and b/assets/sounds/Creature_Sounds-Evil_Eye_Sound_1.ogg differ diff --git a/assets/sounds/Creature_Sounds-Evil_Eye_Sound_2.ogg b/assets/sounds/Creature_Sounds-Evil_Eye_Sound_2.ogg index dad290b..8f2e363 100644 Binary files a/assets/sounds/Creature_Sounds-Evil_Eye_Sound_2.ogg and b/assets/sounds/Creature_Sounds-Evil_Eye_Sound_2.ogg differ diff --git a/assets/sounds/Creature_Sounds-Giant_Voice_1.ogg b/assets/sounds/Creature_Sounds-Giant_Voice_1.ogg index 526dcd1..1dee7f5 100644 Binary files a/assets/sounds/Creature_Sounds-Giant_Voice_1.ogg and b/assets/sounds/Creature_Sounds-Giant_Voice_1.ogg differ diff --git a/assets/sounds/Creature_Sounds-Humanoid_Death_1.ogg b/assets/sounds/Creature_Sounds-Humanoid_Death_1.ogg index 64a0fc8..49bc5f5 100644 Binary files a/assets/sounds/Creature_Sounds-Humanoid_Death_1.ogg and b/assets/sounds/Creature_Sounds-Humanoid_Death_1.ogg differ diff --git a/assets/sounds/Creature_Sounds-Marmot_Scream_1.ogg b/assets/sounds/Creature_Sounds-Marmot_Scream_1.ogg new file mode 100644 index 0000000..f41c312 Binary files /dev/null and b/assets/sounds/Creature_Sounds-Marmot_Scream_1.ogg differ diff --git a/assets/sounds/Creature_Sounds-Medium_Rat.ogg b/assets/sounds/Creature_Sounds-Medium_Rat.ogg index ddd50fc..39092ed 100644 Binary files a/assets/sounds/Creature_Sounds-Medium_Rat.ogg and b/assets/sounds/Creature_Sounds-Medium_Rat.ogg differ diff --git a/assets/sounds/Creature_Sounds-Ranger_1.ogg b/assets/sounds/Creature_Sounds-Ranger_1.ogg index 1df01ec..a49caa1 100644 Binary files a/assets/sounds/Creature_Sounds-Ranger_1.ogg and b/assets/sounds/Creature_Sounds-Ranger_1.ogg differ diff --git a/assets/sounds/Creature_Sounds-Small_Rat.ogg b/assets/sounds/Creature_Sounds-Small_Rat.ogg index c0b00ed..3d00bd8 100644 Binary files a/assets/sounds/Creature_Sounds-Small_Rat.ogg and b/assets/sounds/Creature_Sounds-Small_Rat.ogg differ diff --git a/assets/sounds/Creature_Sounds-Spider_1-001.ogg b/assets/sounds/Creature_Sounds-Spider_1-001.ogg deleted file mode 100644 index 278c810..0000000 Binary files a/assets/sounds/Creature_Sounds-Spider_1-001.ogg and /dev/null differ diff --git a/assets/sounds/Creature_Sounds-Spider_1-002.ogg b/assets/sounds/Creature_Sounds-Spider_1.ogg similarity index 76% rename from assets/sounds/Creature_Sounds-Spider_1-002.ogg rename to assets/sounds/Creature_Sounds-Spider_1.ogg index 22a9f16..caace1e 100644 Binary files a/assets/sounds/Creature_Sounds-Spider_1-002.ogg and b/assets/sounds/Creature_Sounds-Spider_1.ogg differ diff --git a/assets/sounds/Creature_Sounds-Spider_2.ogg b/assets/sounds/Creature_Sounds-Spider_2.ogg new file mode 100644 index 0000000..9e76a8f Binary files /dev/null and b/assets/sounds/Creature_Sounds-Spider_2.ogg differ diff --git a/assets/sounds/Creature_Sounds-Sword_Hit_1.ogg b/assets/sounds/Creature_Sounds-Sword_Hit_1.ogg index 1737843..3204afc 100644 Binary files a/assets/sounds/Creature_Sounds-Sword_Hit_1.ogg and b/assets/sounds/Creature_Sounds-Sword_Hit_1.ogg differ diff --git a/assets/sounds/Creature_Sounds-Sword_Hit_2.ogg b/assets/sounds/Creature_Sounds-Sword_Hit_2.ogg index e3fb6fd..1a82cc7 100644 Binary files a/assets/sounds/Creature_Sounds-Sword_Hit_2.ogg and b/assets/sounds/Creature_Sounds-Sword_Hit_2.ogg differ diff --git a/assets/sounds/Creature_Sounds-Walk.ogg b/assets/sounds/Creature_Sounds-Walk.ogg index f7f3686..3d288ad 100644 Binary files a/assets/sounds/Creature_Sounds-Walk.ogg and b/assets/sounds/Creature_Sounds-Walk.ogg differ diff --git a/boss_fight_ui.cpp b/boss_fight_ui.cpp index 4ebcde9..5b9057d 100644 --- a/boss_fight_ui.cpp +++ b/boss_fight_ui.cpp @@ -24,7 +24,10 @@ namespace gui { auto bg_bounds = $boss_background.sprite->getLocalBounds(); $boss_background.sprite->setPosition({300, 0}); - $boss_image = textures::get("boss_fight"); + $boss_image = textures::get("rat_king_boss"); + sf::IntRect frame_rect{{0,0},{720,720}}; + $boss_image.sprite->setTextureRect(frame_rect); + $boss_image.sprite->setScale($scale); auto bounds = $boss_image.sprite->getLocalBounds(); float x_diff = bg_bounds.size.x / 2; $boss_image.sprite->setOrigin({bounds.size.x / 2, bounds.size.y / 2}); @@ -34,6 +37,8 @@ namespace gui { void BossFightUI::init() { auto& config = $level.world->get_the(); $sounds = components::get(config.enemies["RAT_KING"]); + $animation = components::get(config.enemies["RAT_KING"]); + $animation.texture_width = 720; $status.world().set_the({$status.$parser}); @@ -62,16 +67,20 @@ namespace gui { } void BossFightUI::bounce_boss(sf::RenderWindow& window) { - auto time = $clock.getElapsedTime(); - float tick = ease::in_out_back(ease::sine(time.asSeconds() * 10.0f)); - float scale = std::lerp(0.8, 1.1, tick); - $boss_image.sprite->setScale({scale, scale}); - - if(scale > 1.0) { - if(!sound::playing($sounds.attack)) sound::play($sounds.attack); - $boss_image.sprite->setColor({255,255,255}); + sf::IntRect frame_rect{{0,0},{720,720}}; + auto scale = $scale; + $animation.step(scale, frame_rect); + $boss_image.sprite->setScale(scale); + + if(!sound::playing($sounds.attack) && $animation.current == 1) { + sound::play($sounds.attack); + } + + if(!sound::playing("Sword_Hit_2") && $animation.subframe > 1.2 && $animation.subframe < 1.5) { + sound::play("Sword_Hit_2"); } + $boss_image.sprite->setTextureRect(frame_rect); window.draw(*$boss_image.sprite); } @@ -99,8 +108,8 @@ namespace gui { } if($overlay.mouse(x, y)) { + $animation.play(); sound::play("Sword_Hit_1"); - $boss_image.sprite->setColor({255,225,225}); $boss_hit = !$boss_hit; $boss_hp--; } @@ -109,7 +118,6 @@ namespace gui { } void BossFightUI::update_level(GameLevel &level) { - $boss_image.sprite->setColor({255,255,255}); $level = level; $boss_hp = 10 * $level.index + 1; // make him stronger $boss_hit = false; diff --git a/boss_fight_ui.hpp b/boss_fight_ui.hpp index 8c7c808..6e6f4a4 100644 --- a/boss_fight_ui.hpp +++ b/boss_fight_ui.hpp @@ -21,7 +21,9 @@ namespace gui { sf::Clock $clock; int $boss_hp = 10; bool $boss_hit = false; + sf::Vector2f $scale{0.8, 0.8}; components::Sound $sounds; + components::Animation $animation; GameLevel $level; guecs::UI $status; guecs::UI $overlay; diff --git a/components.cpp b/components.cpp index 0c93a92..e5b3cbf 100644 --- a/components.cpp +++ b/components.cpp @@ -56,8 +56,9 @@ namespace components { float tick = twitching(); scale_out.x = std::lerp(scale_out.x, scale_out.x + scale, tick); scale_out.y = std::lerp(scale_out.y, scale_out.y + scale, tick); + if(!simple) { - rect_out.position.x += current * TEXTURE_WIDTH; + rect_out.position.x += current * texture_width; } subframe += speed; diff --git a/components.hpp b/components.hpp index 38228ff..a240ff8 100644 --- a/components.hpp +++ b/components.hpp @@ -108,6 +108,7 @@ namespace components { float subframe = 0; ease::Style easing = ease::IN_OUT_BACK; float ease_rate = 0.5f; + int texture_width = TEXTURE_WIDTH; void play(); float twitching(); diff --git a/gui_fsm.cpp b/gui_fsm.cpp index 8016540..47b1ad2 100644 --- a/gui_fsm.cpp +++ b/gui_fsm.cpp @@ -330,7 +330,6 @@ namespace gui { $renderer.draw($map_ui); } else if(in_state(State::NEXT_LEVEL)) { $window.clear(); - $boss_fight_ui.init(); $boss_fight_ui.render($window); } else { draw_gui(); diff --git a/main.cpp b/main.cpp index 89c047a..d5aa686 100644 --- a/main.cpp +++ b/main.cpp @@ -6,7 +6,7 @@ int main(int argc, char* argv[]) { textures::init(); sound::init(); - sound::mute(true); + sound::mute(false); gui::FSM main; main.event(gui::Event::STARTED); Autowalker walker(main);