add enemy sprite animations
This commit is contained in:
parent
caa6186727
commit
25fd91e67c
2
lib/sb
2
lib/sb
@ -1 +1 @@
|
||||
Subproject commit 333a7b73ac7a20aa39de2241effcd3549273c9b6
|
||||
Subproject commit 110b876648f7e529caddde3475b1f5543897f6de
|
@ -83,7 +83,7 @@
|
||||
"enemies": [
|
||||
["fish", 0.5, 0.16, 40.000000, 0.0],
|
||||
["fish", 0.16, 0.1, 70.000000, 0.0],
|
||||
["projector", [432, 400, 0.0], 10.00000, 2.0, 0.3, 3]
|
||||
["projector", [432, 400, 0.0], 10.00000, 2.0, 0.6, 3]
|
||||
]
|
||||
},
|
||||
|
||||
@ -106,13 +106,13 @@
|
||||
[750, 243]
|
||||
],
|
||||
"enemies": [
|
||||
["projector", [100, 213, 0.0], 4, 4, 0.3],
|
||||
["projector", [200, 293, 0.0], 4, 4, 0.3],
|
||||
["projector", [300, 173, 0.0], 4, 4, 0.3],
|
||||
["projector", [400, 333, 0.0], 4, 4, 0.3],
|
||||
["projector", [500, 133, 0.0], 4, 4, 0.3],
|
||||
["projector", [600, 373, 0.0], 4, 4, 0.3, 3],
|
||||
["projector", [700, 93, 0.0], 4, 4, 0.3]
|
||||
["projector", [100, 213, 0.0], 4, 4, 0.6],
|
||||
["projector", [200, 293, 0.0], 4, 4, 0.6],
|
||||
["projector", [300, 173, 0.0], 4, 4, 0.6],
|
||||
["projector", [400, 333, 0.0], 4, 4, 0.6],
|
||||
["projector", [500, 133, 0.0], 4, 4, 0.6],
|
||||
["projector", [600, 373, 0.0], 4, 4, 0.6, 3],
|
||||
["projector", [700, 93, 0.0], 4, 4, 0.6]
|
||||
],
|
||||
"checkpoints": [
|
||||
{
|
||||
@ -265,11 +265,11 @@
|
||||
[494.333333, -205.000000], [1222.666667, 244.000000], [434.000000, 148.000000]
|
||||
],
|
||||
"enemies": [
|
||||
["projector", [139.000000, 95.000000, 0.0], 5.00000, 4.0, 0.3, 5],
|
||||
["projector", [154.000000, 373.000000, 0.0], 5.00000, 3.0, 0.3],
|
||||
["projector", [660.000000, 386.000000, 0.0], 5.00000, 2.0, 0.3],
|
||||
["projector", [671.000000, 106.000000, 0.0], 5.00000, 1.0, 0.3],
|
||||
["projector", [668.000000, 239.000000, 0.0], 5.00000, 2.0, 0.3]
|
||||
["projector", [139.000000, 95.000000, 0.0], 5.00000, 4.0, 0.6, 5],
|
||||
["projector", [154.000000, 373.000000, 0.0], 5.00000, 3.0, 0.6],
|
||||
["projector", [660.000000, 386.000000, 0.0], 5.00000, 2.0, 0.6],
|
||||
["projector", [671.000000, 106.000000, 0.0], 5.00000, 1.0, 0.6],
|
||||
["projector", [668.000000, 239.000000, 0.0], 5.00000, 2.0, 0.6]
|
||||
]
|
||||
},
|
||||
|
||||
@ -425,8 +425,8 @@
|
||||
["slicer", 0.135, 2.5, 30.0],
|
||||
["slicer", 0.57, 5.0, 100.0],
|
||||
|
||||
["projector", [64, 120, 0.0], 5.5, 6.5, 0.3],
|
||||
["projector", [800, 120, 0.0], 5.5, 6.5, 0.3],
|
||||
["projector", [64, 120, 0.0], 5.5, 6.5, 0.6],
|
||||
["projector", [800, 120, 0.0], 5.5, 6.5, 0.6],
|
||||
|
||||
["wave", 0.0, 7.0, 0.712, 0.25, 0.75]
|
||||
],
|
||||
@ -485,10 +485,10 @@
|
||||
[ 432.0, 34.0], [ 432.0, 34.0], [ 432.0, 261.0], [ 432.0, 261.0]
|
||||
],
|
||||
"enemies": [
|
||||
["projector", [64, 64, 0.0], 6.00000, 7.0, 0.3],
|
||||
["projector", [800, 64, 0.0], 6.00000, 7.0, 0.3],
|
||||
["projector", [64, 422, 0.0], 6.00000, 7.0, 0.3],
|
||||
["projector", [800, 422, 0.0], 6.00000, 7.0, 0.3],
|
||||
["projector", [64, 64, 0.0], 6.00000, 7.0, 0.6],
|
||||
["projector", [800, 64, 0.0], 6.00000, 7.0, 0.6],
|
||||
["projector", [64, 422, 0.0], 6.00000, 7.0, 0.6],
|
||||
["projector", [800, 422, 0.0], 6.00000, 7.0, 0.6],
|
||||
|
||||
["slicer", 0.0445, 4.0, 350],
|
||||
["slicer", 0.136, 4.0, 350],
|
||||
@ -560,7 +560,7 @@
|
||||
[ 2571.0, 173.0]
|
||||
],
|
||||
"enemies": [
|
||||
["projector", [130, 280, 0.0], 0.5, 4.0, 0.3],
|
||||
["projector", [130, 280, 0.0], 0.5, 4.0, 0.6],
|
||||
["fish", 0.561, 0.05, 40.000000, 0.0],
|
||||
["fish", 0.561, 0.05, 60.000000, 0.0],
|
||||
["fish", 0.561, 0.05, 80.000000, 0.0],
|
||||
@ -844,9 +844,9 @@
|
||||
[485.000000, 259.000000], [-1191.000000, -246.000000], [303.000000, 711.000000], [452.000000, 375.000000]
|
||||
],
|
||||
"enemies": [
|
||||
["projector", [136.000000, 299.000000, 0.0], 15.50000, 2.0, 0.3],
|
||||
["projector", [136.000000, 299.000000, 0.0], 15.50000, 2.0, 0.6],
|
||||
["slicer", 0.66667, 7.75000, 57.50000],
|
||||
["projector", [400.000000, 56.000000, 0.0], 11.25000, 2.25, 0.3],
|
||||
["projector", [400.000000, 56.000000, 0.0], 11.25000, 2.25, 0.6],
|
||||
["slicer", 0.03333, 5.00000, 60.00000],
|
||||
["slicer", 0.05000, 5.00000, 60.00000],
|
||||
["slicer", 0.06667, 5.00000, 60.00000],
|
||||
|
@ -138,7 +138,7 @@ Cakefoot::Cakefoot()
|
||||
if (fonts[name].get() == nullptr)
|
||||
{
|
||||
message << "Could not load " << font_config["path"] << ". Using framework's font instead.";
|
||||
sb::Log::log(message, sb::Log::ERROR);
|
||||
sb::Log::log(message, sb::Log::ERR);
|
||||
|
||||
/* Default to framework's font */
|
||||
fonts[name] = font();
|
||||
@ -1189,7 +1189,7 @@ void Cakefoot::write_progress() const
|
||||
{
|
||||
std::ostringstream message;
|
||||
message << "Could not create storage directory. Progress will not be saved. " << error.what();
|
||||
sb::Log::log(message, sb::Log::ERROR);
|
||||
sb::Log::log(message, sb::Log::ERR);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1208,7 +1208,7 @@ void Cakefoot::write_progress() const
|
||||
{
|
||||
std::ostringstream message;
|
||||
message << "Could not save progress to " << progress_file_path;
|
||||
sb::Log::log(message, sb::Log::ERROR);
|
||||
sb::Log::log(message, sb::Log::ERR);
|
||||
}
|
||||
progress_file.close();
|
||||
|
||||
@ -1238,7 +1238,7 @@ void Cakefoot::write_scores() const
|
||||
{
|
||||
std::ostringstream message;
|
||||
message << "Could not create storage directory. Scores will not be saved. " << error.what();
|
||||
sb::Log::log(message, sb::Log::ERROR);
|
||||
sb::Log::log(message, sb::Log::ERR);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1254,7 +1254,7 @@ void Cakefoot::write_scores() const
|
||||
{
|
||||
std::ostringstream message;
|
||||
message << "Could not save arcade scores to " << arcade_scores_file_path;
|
||||
sb::Log::log(message, sb::Log::ERROR);
|
||||
sb::Log::log(message, sb::Log::ERR);
|
||||
}
|
||||
arcade_scores_file.close();
|
||||
|
||||
|
@ -56,6 +56,9 @@ Slicer::Slicer(const Curve& curve, float relative, float speed, float stray) : c
|
||||
{
|
||||
position = start();
|
||||
sprite.texture("resource/slicer/slicer-1.png");
|
||||
sprite.texture("resource/slicer/slicer-2.png");
|
||||
sprite.frames.frame_length(0.5f);
|
||||
sprite.frames.play();
|
||||
|
||||
/* Get size as the pixels divided by the original resolution */
|
||||
float size = 12.0f / 486.0f;
|
||||
@ -74,6 +77,8 @@ void Slicer::coin(const sb::Sprite& sprite, float radius, float angle)
|
||||
|
||||
void Slicer::update(const sb::Timer& timer)
|
||||
{
|
||||
sprite.update(timer);
|
||||
|
||||
float move = timer.delta(speed);
|
||||
glm::vec3 destination;
|
||||
|
||||
@ -165,6 +170,9 @@ Fish::Fish(const Curve& curve, float relative, float speed, float radius, float
|
||||
curve(curve), relative(relative), speed(speed), radius(radius), offset(offset)
|
||||
{
|
||||
sprite.texture("resource/fish/fish-1.png");
|
||||
sprite.texture("resource/fish/fish-2.png");
|
||||
sprite.frames.frame_length(0.3f);
|
||||
sprite.frames.play();
|
||||
|
||||
/* Set size of objects */
|
||||
glm::vec2 size {12.0f / 486.0f};
|
||||
@ -186,6 +194,8 @@ void Fish::coin(const sb::Sprite& sprite, float radius, float angle)
|
||||
|
||||
void Fish::update(const sb::Timer& timer)
|
||||
{
|
||||
sprite.update(timer);
|
||||
|
||||
/* On the first update, record the timestamp of the timer, so the difference between subsequent timestamps and the first timestamp can
|
||||
* be used to measure the angle position of the fish. Do this instead of adding to the angle position every frame to avoid letting
|
||||
* floating point addition error accumulate differently among fish with different speeds. */
|
||||
@ -255,6 +265,11 @@ Projectile::Projectile(const glm::vec3& position, const glm::vec3& target, float
|
||||
|
||||
/* Initialize sprite */
|
||||
sprite.texture("resource/projectile/projectile-1.png");
|
||||
sprite.texture("resource/projectile/projectile-2.png");
|
||||
sprite.texture("resource/projectile/projectile-3.png");
|
||||
sprite.texture("resource/projectile/projectile-4.png");
|
||||
sprite.frames.frame_length(0.05f);
|
||||
sprite.frames.play();
|
||||
|
||||
/* Set size of objects */
|
||||
glm::vec2 size {12.0f / 486.0f};
|
||||
@ -273,6 +288,9 @@ void Projectile::coinify(const sb::Sprite& sprite)
|
||||
|
||||
void Projectile::update(const sb::Timer& timer)
|
||||
{
|
||||
sprite.update(timer);
|
||||
|
||||
/* Move */
|
||||
position += glm::vec3{sb::angle_to_vector(angle, timer.delta(speed)), 0.0f};
|
||||
sprite.translate(position);
|
||||
|
||||
@ -315,6 +333,7 @@ Projector::Projector(const Character& character, const glm::vec3& position, floa
|
||||
{
|
||||
animation_charge.frame_length(rate);
|
||||
sprite.texture("resource/projector/projector-1.png");
|
||||
sprite.texture("resource/projector/projector-2.png");
|
||||
|
||||
/* Set size and position of objects */
|
||||
glm::vec2 size {12.0f / 486.0f};
|
||||
@ -343,6 +362,8 @@ void Projector::coin(const sb::Sprite& sprite, int frequency)
|
||||
|
||||
void Projector::update(const sb::Timer& timer)
|
||||
{
|
||||
sprite.update(timer);
|
||||
|
||||
/* Update the animation timers */
|
||||
animation_charge.update(timer.stamp());
|
||||
animation_release.update(timer.stamp());
|
||||
@ -419,11 +440,14 @@ bool Projector::collide_coin(sb::Box box, const glm::vec3& clip_lower, const glm
|
||||
|
||||
void Projector::charge()
|
||||
{
|
||||
sprite.texture_index(1);
|
||||
animation_release.play_once(release_delay);
|
||||
}
|
||||
|
||||
void Projector::release()
|
||||
{
|
||||
sprite.texture_index(0);
|
||||
|
||||
/* Keep a count of how many projectiles have been fired */
|
||||
count++;
|
||||
|
||||
@ -446,9 +470,14 @@ Flame::Flame(const sb::Box field, const glm::vec3& position, float speed, float
|
||||
initial_angle = angle;
|
||||
initial_position = position;
|
||||
|
||||
/* Set up animation */
|
||||
sprite.texture("resource/flame/flame-1.png");
|
||||
sprite.texture("resource/flame/flame-2.png");
|
||||
sprite.frames.frame_length(0.3f);
|
||||
sprite.frames.play();
|
||||
|
||||
/* Initialize object size and position */
|
||||
glm::vec2 size {12.0f / 486.0f};
|
||||
sprite.texture("resource/flame/flame-1.png");
|
||||
sprite.scale(size);
|
||||
sprite.translate(position);
|
||||
box.size(2.0f * size);
|
||||
@ -471,6 +500,9 @@ void Flame::coin(const sb::Sprite& sprite, float radius, float angle)
|
||||
|
||||
void Flame::update(const sb::Timer& timer)
|
||||
{
|
||||
sprite.update(timer);
|
||||
|
||||
/* Move */
|
||||
animation_mirror.update(timer.stamp());
|
||||
position += glm::vec3{sb::angle_to_vector(angle, timer.delta(speed)), 0.0f};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user