Bosses and other enemies now have a 2 frame animation, the first boss the Rat King now screams at you and attacks.
This commit is contained in:
parent
b3b8cbbeee
commit
43835da88f
24 changed files with 35 additions and 22 deletions
|
@ -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
|
||||
|
|
|
@ -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": {
|
||||
|
|
BIN
assets/rat_king_2_frame_animation.png
Normal file
BIN
assets/rat_king_2_frame_animation.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1,011 KiB |
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
assets/sounds/Creature_Sounds-Marmot_Scream_1.ogg
Normal file
BIN
assets/sounds/Creature_Sounds-Marmot_Scream_1.ogg
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
assets/sounds/Creature_Sounds-Spider_2.ogg
Normal file
BIN
assets/sounds/Creature_Sounds-Spider_2.ogg
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -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<components::GameConfig>();
|
||||
$sounds = components::get<components::Sound>(config.enemies["RAT_KING"]);
|
||||
$animation = components::get<components::Animation>(config.enemies["RAT_KING"]);
|
||||
$animation.texture_width = 720;
|
||||
|
||||
$status.world().set_the<Background>({$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});
|
||||
sf::IntRect frame_rect{{0,0},{720,720}};
|
||||
auto scale = $scale;
|
||||
$animation.step(scale, frame_rect);
|
||||
$boss_image.sprite->setScale(scale);
|
||||
|
||||
if(scale > 1.0) {
|
||||
if(!sound::playing($sounds.attack)) sound::play($sounds.attack);
|
||||
$boss_image.sprite->setColor({255,255,255});
|
||||
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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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();
|
||||
|
|
2
main.cpp
2
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);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue