Some basic animations working but the loop in bad.
This commit is contained in:
parent
c33f370572
commit
0930b05fc5
5 changed files with 40 additions and 20 deletions
|
|
@ -111,12 +111,22 @@
|
||||||
},
|
},
|
||||||
"test_boss": {
|
"test_boss": {
|
||||||
"_type": "Animation",
|
"_type": "Animation",
|
||||||
"easing": 3,
|
"easing": 1,
|
||||||
"ease_rate": 0.5,
|
"ease_rate": 0.5,
|
||||||
"scale": 0.4,
|
"scale": 0.4,
|
||||||
"simple": true,
|
"simple": true,
|
||||||
"frames": 1,
|
"frames": 1,
|
||||||
"speed": 0.02,
|
"speed": 0.02,
|
||||||
"stationary": true
|
"stationary": true
|
||||||
|
},
|
||||||
|
"rat_king_boss": {
|
||||||
|
"_type": "Animation",
|
||||||
|
"easing": 1,
|
||||||
|
"ease_rate": 0.5,
|
||||||
|
"scale": 0.4,
|
||||||
|
"simple": false,
|
||||||
|
"frames": 2,
|
||||||
|
"speed": 0.02,
|
||||||
|
"stationary": true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2,23 +2,23 @@
|
||||||
"RAT_KING": {
|
"RAT_KING": {
|
||||||
"components": [
|
"components": [
|
||||||
{"_type": "BossFight",
|
{"_type": "BossFight",
|
||||||
"background": "test_background",
|
"background": "boss_fight_background",
|
||||||
"floor": "test_floor",
|
"floor": "devils_fingers_background",
|
||||||
"floor_pos": "floor2",
|
"floor_pos": "floor1",
|
||||||
"player": {
|
"player": {
|
||||||
"sprite": "test_player",
|
"sprite": "peasant_girl_rear_view",
|
||||||
"start_pos": "player2",
|
"start_pos": "player2",
|
||||||
"scale": 0.5,
|
"scale": 0.5,
|
||||||
"mid_cell": false
|
"mid_cell": false
|
||||||
},
|
},
|
||||||
"boss": {
|
"boss": {
|
||||||
"start_pos": "boss3",
|
"start_pos": "boss2",
|
||||||
"scale": 0.7,
|
"scale": 0.7,
|
||||||
"mid_cell": true
|
"mid_cell": true
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{"_type": "Combat", "hp": 20, "max_hp": 20, "damage": 20, "dead": false},
|
{"_type": "Combat", "hp": 20, "max_hp": 20, "damage": 20, "dead": false},
|
||||||
{"_type": "Sprite", "name": "test_boss", "width": 720, "height": 720, "scale": 0.8, "stationary": false},
|
{"_type": "Sprite", "name": "rat_king_boss", "width": 720, "height": 720, "scale": 0.8, "stationary": false},
|
||||||
{"_type": "Sound", "attack": "Marmot_Scream_1", "death": "Creature_Death_1"}
|
{"_type": "Sound", "attack": "Marmot_Scream_1", "death": "Creature_Death_1"}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -88,9 +88,6 @@ namespace boss {
|
||||||
boss::System::combat(attack_id);
|
boss::System::combat(attack_id);
|
||||||
state(State::PLAYER_TURN);
|
state(State::PLAYER_TURN);
|
||||||
} break;
|
} break;
|
||||||
case TICK:
|
|
||||||
$ui.play_animations();
|
|
||||||
break;
|
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
// skip it
|
// skip it
|
||||||
|
|
@ -107,15 +104,12 @@ namespace boss {
|
||||||
break;
|
break;
|
||||||
case ATTACK: {
|
case ATTACK: {
|
||||||
$ui.status(L"BOSS TURN");
|
$ui.status(L"BOSS TURN");
|
||||||
$ui.move_boss(run % 10 < 5 ? "boss1" : "boss3");
|
$ui.move_boss(run % 10 < 5 ? "boss1" : "boss2");
|
||||||
$ui.$boss_anim.play();
|
$ui.$boss_anim.play();
|
||||||
int attack_id = std::any_cast<int>(data);
|
int attack_id = std::any_cast<int>(data);
|
||||||
boss::System::combat(attack_id);
|
boss::System::combat(attack_id);
|
||||||
state(State::BOSS_TURN);
|
state(State::BOSS_TURN);
|
||||||
} break;
|
} break;
|
||||||
case TICK:
|
|
||||||
$ui.play_animations();
|
|
||||||
break;
|
|
||||||
default:
|
default:
|
||||||
// skip it
|
// skip it
|
||||||
break;
|
break;
|
||||||
|
|
@ -134,5 +128,6 @@ namespace boss {
|
||||||
|
|
||||||
void Fight::render(sf::RenderWindow& window) {
|
void Fight::render(sf::RenderWindow& window) {
|
||||||
$ui.render(window);
|
$ui.render(window);
|
||||||
|
$ui.play_animations(window);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
19
boss/ui.cpp
19
boss/ui.cpp
|
|
@ -2,6 +2,8 @@
|
||||||
#include "constants.hpp"
|
#include "constants.hpp"
|
||||||
#include "components.hpp"
|
#include "components.hpp"
|
||||||
#include "animation.hpp"
|
#include "animation.hpp"
|
||||||
|
#include <chrono>
|
||||||
|
#include <thread>
|
||||||
|
|
||||||
namespace boss {
|
namespace boss {
|
||||||
using namespace guecs;
|
using namespace guecs;
|
||||||
|
|
@ -16,7 +18,9 @@ namespace boss {
|
||||||
$boss_sprite = textures::get_sprite(sprite.name);
|
$boss_sprite = textures::get_sprite(sprite.name);
|
||||||
|
|
||||||
// floor is std::optional
|
// floor is std::optional
|
||||||
|
if($scene.floor) {
|
||||||
$floor_sprite = textures::get_sprite(*$scene.floor);
|
$floor_sprite = textures::get_sprite(*$scene.floor);
|
||||||
|
}
|
||||||
|
|
||||||
$player_sprite = textures::get_sprite($scene.player["sprite"]);
|
$player_sprite = textures::get_sprite($scene.player["sprite"]);
|
||||||
|
|
||||||
|
|
@ -41,7 +45,10 @@ namespace boss {
|
||||||
|
|
||||||
move_boss($scene.boss["start_pos"]);
|
move_boss($scene.boss["start_pos"]);
|
||||||
move_player($scene.player["start_pos"]);
|
move_player($scene.player["start_pos"]);
|
||||||
|
|
||||||
|
if($scene.floor) {
|
||||||
position_sprite($floor_sprite, $scene.floor_pos, 1.0, false);
|
position_sprite($floor_sprite, $scene.floor_pos, 1.0, false);
|
||||||
|
}
|
||||||
|
|
||||||
$arena.init();
|
$arena.init();
|
||||||
|
|
||||||
|
|
@ -78,7 +85,10 @@ namespace boss {
|
||||||
$combat_ui.render(window);
|
$combat_ui.render(window);
|
||||||
$arena.render(window);
|
$arena.render(window);
|
||||||
|
|
||||||
|
if($floor_sprite.sprite) {
|
||||||
window.draw(*$floor_sprite.sprite);
|
window.draw(*$floor_sprite.sprite);
|
||||||
|
}
|
||||||
|
|
||||||
window.draw(*$boss_sprite.sprite);
|
window.draw(*$boss_sprite.sprite);
|
||||||
window.draw(*$player_sprite.sprite);
|
window.draw(*$player_sprite.sprite);
|
||||||
|
|
||||||
|
|
@ -106,9 +116,14 @@ namespace boss {
|
||||||
position_sprite($player_sprite, cell_name, $scene.player["scale"], $scene.player["mid_cell"]);
|
position_sprite($player_sprite, cell_name, $scene.player["scale"], $scene.player["mid_cell"]);
|
||||||
}
|
}
|
||||||
|
|
||||||
void UI::play_animations() {
|
void UI::play_animations(sf::RenderWindow& window) {
|
||||||
if($boss_anim.playing) {
|
using namespace std::chrono_literals;
|
||||||
|
|
||||||
|
while($boss_anim.playing) {
|
||||||
animation::apply($boss_anim, *$boss_sprite.sprite, $boss_pos);
|
animation::apply($boss_anim, *$boss_sprite.sprite, $boss_pos);
|
||||||
|
render(window);
|
||||||
|
window.display();
|
||||||
|
std::this_thread::sleep_for(16ms);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -34,6 +34,6 @@ namespace boss {
|
||||||
void status(const std::wstring& msg);
|
void status(const std::wstring& msg);
|
||||||
void move_boss(const std::string& cell_name);
|
void move_boss(const std::string& cell_name);
|
||||||
void move_player(const std::string& cell_name);
|
void move_player(const std::string& cell_name);
|
||||||
void play_animations();
|
void play_animations(sf::RenderWindow& window);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue