Add ReverseOneShot animation type support to olcUTIL_Animate2D and config files. Stone Tosses into the air for second boss. Release Build 9994.

mac-build
sigonasr2 5 months ago
parent 08cdf26605
commit 001d5e1c79
  1. 4
      Adventures in Lestoria/Adventures in Lestoria.vcxproj
  2. 3
      Adventures in Lestoria/Adventures in Lestoria.vcxproj.filters
  3. 9
      Adventures in Lestoria/Effect.h
  4. 4
      Adventures in Lestoria/MonsterAttribute.h
  5. 6
      Adventures in Lestoria/MonsterData.cpp
  6. 47
      Adventures in Lestoria/RockLaunch.cpp
  7. 28
      Adventures in Lestoria/StoneGolem.cpp
  8. 2
      Adventures in Lestoria/Version.h
  9. 26
      Adventures in Lestoria/assets/config/MonsterStrategies.txt
  10. 51
      Adventures in Lestoria/assets/config/Monsters.txt
  11. 22
      Adventures in Lestoria/olcUTIL_Animate2D.h
  12. BIN
      x64/Release/Adventures in Lestoria.exe

@ -952,6 +952,10 @@
</SubType> </SubType>
</ClCompile> </ClCompile>
<ClCompile Include="Pixel.cpp" /> <ClCompile Include="Pixel.cpp" />
<ClCompile Include="RockLaunch.cpp">
<SubType>
</SubType>
</ClCompile>
<ClCompile Include="RunAway.cpp" /> <ClCompile Include="RunAway.cpp" />
<ClCompile Include="RunTowards.cpp" /> <ClCompile Include="RunTowards.cpp" />
<ClCompile Include="Pathfinding.cpp" /> <ClCompile Include="Pathfinding.cpp" />

@ -1118,6 +1118,9 @@
<ClCompile Include="Bomb.cpp"> <ClCompile Include="Bomb.cpp">
<Filter>Source Files\Bullet Types</Filter> <Filter>Source Files\Bullet Types</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="RockLaunch.cpp">
<Filter>Source Files\Effects</Filter>
</ClCompile>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<None Include="cpp.hint" /> <None Include="cpp.hint" />

@ -115,4 +115,13 @@ struct SpellCircle:Effect{
Effect spellInsignia{vf2d{},0.f,"spell_insignia.png",false,{}}; Effect spellInsignia{vf2d{},0.f,"spell_insignia.png",false,{}};
virtual bool Update(float fElapsedTime)override final; virtual bool Update(float fElapsedTime)override final;
virtual void Draw()const override final; virtual void Draw()const override final;
};
struct RockLaunch:Effect{
//The lifetime is for how long the effect lasts after it's launched. You don't have to calculate extra lifetime to compensate for the delayTime, it is done for you.
RockLaunch(vf2d pos,float lifetime,std::string imgFile,float delayTime,float size,float fadeout,vf2d spd,Pixel col,float rotation,float rotationSpd,bool additiveBlending=false);
virtual bool Update(float fElapsedTime)override final;
private:
float delayTime;
vf2d futureSpd;
}; };

@ -139,4 +139,8 @@ enum class Attribute{
RESPAWN_LOOPING_SOUND_ID, //NOTE: Store looping sound IDs temporarily with this value. The game automatically cleans this up in Monster::OnDestroy() if you don't, since a monster that dies should not have their looping sound still playing. RESPAWN_LOOPING_SOUND_ID, //NOTE: Store looping sound IDs temporarily with this value. The game automatically cleans this up in Monster::OnDestroy() if you don't, since a monster that dies should not have their looping sound still playing.
SAFE_AREA_WAIT_TIMER, SAFE_AREA_WAIT_TIMER,
PREVIOUS_MONSTER_COUNT, PREVIOUS_MONSTER_COUNT,
CHASE_TIMER,
STONE_RAIN_COUNT,
STONE_TOSS_COUNT,
STONE_TOSS_TIMER,
}; };

@ -117,6 +117,9 @@ void MonsterData::InitializeMonsterData(){
}else }else
if(data.GetString(2)=="Reverse"){ if(data.GetString(2)=="Reverse"){
style=Animate2D::Style::Reverse; style=Animate2D::Style::Reverse;
}else
if(data.GetString(2)=="ReverseOneShot"){
style=Animate2D::Style::ReverseOneShot;
}else{ }else{
ERR(std::format("WARNING! Invalid Animation Style specified: {}",int(style))); ERR(std::format("WARNING! Invalid Animation Style specified: {}",int(style)));
} }
@ -289,6 +292,9 @@ void MonsterData::InitializeNPCData(){
}else }else
if(data.GetString(2)=="Reverse"){ if(data.GetString(2)=="Reverse"){
style=Animate2D::Style::Reverse; style=Animate2D::Style::Reverse;
}else
if(data.GetString(2)=="ReverseOneShot"){
style=Animate2D::Style::ReverseOneShot;
}else{ }else{
ERR(std::format("WARNING! Invalid Animation Style specified: {}",int(style))); ERR(std::format("WARNING! Invalid Animation Style specified: {}",int(style)));
} }

@ -0,0 +1,47 @@
#pragma region License
/*
License (OLC-3)
~~~~~~~~~~~~~~~
Copyright 2024 Joshua Sigona <sigonasr2@gmail.com>
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
1. Redistributions or derivations of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions or derivative works in binary form must reproduce the above
copyright notice. This list of conditions and the following disclaimer must be
reproduced in the documentation and/or other materials provided with the distribution.
3. Neither the name of the copyright holder nor the names of its contributors may
be used to endorse or promote products derived from this software without specific
prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
SUCH DAMAGE.
Portions of this software are copyright © 2024 The FreeType
Project (www.freetype.org). Please see LICENSE_FT.txt for more information.
All rights reserved.
*/
#pragma endregion
#include "Effect.h"
RockLaunch::RockLaunch(vf2d pos,float lifetime,std::string imgFile,float delayTime,float size,float fadeout,vf2d spd,Pixel col,float rotation,float rotationSpd,bool additiveBlending)
:Effect(pos,lifetime+delayTime,imgFile,false,size,fadeout,{},col,rotation,rotationSpd,additiveBlending),delayTime(delayTime),futureSpd(spd){}
bool RockLaunch::Update(float fElapsedTime){
delayTime-=fElapsedTime;
if(delayTime<=0.f)spd=futureSpd;
return Effect::Update(fElapsedTime);
};

@ -64,6 +64,8 @@ void Monster::STRATEGY::STONE_GOLEM(Monster&m,float fElapsedTime,std::string str
STONE_THROW_FINISH_ANIMATION, STONE_THROW_FINISH_ANIMATION,
SHOCKWAVE, SHOCKWAVE,
FIX_SAFE_AREAS, FIX_SAFE_AREAS,
DOUBLE_ROCK_TOSS,
STONE_RAIN,
}; };
const auto PrepareSafeAreas=[&](){ const auto PrepareSafeAreas=[&](){
@ -230,6 +232,7 @@ void Monster::STRATEGY::STONE_GOLEM(Monster&m,float fElapsedTime,std::string str
CreateBullet(LargeStone)(m.GetPos()+vf2d{0,ConfigFloat("Standard Attack.Stone Throw Height Offset")/2.f},ConfigFloat("Standard Attack.Stone Throw Time"),m.V(A::LOCKON_POS),m.F(A::CASTING_TIMER),ConfigPixels("Standard Attack.Stone Radius"),ConfigFloat("Standard Attack.Stone Throw Height Offset"),acc,ConfigInt("Standard Attack.Stone Damage"),ConfigFloat("Standard Attack.Stone Throw Knockback Factor"),m.OnUpperLevel(),false,INFINITY,false,WHITE,vf2d{1,1}*m.GetSizeMult(),util::random(2*PI))EndBullet; CreateBullet(LargeStone)(m.GetPos()+vf2d{0,ConfigFloat("Standard Attack.Stone Throw Height Offset")/2.f},ConfigFloat("Standard Attack.Stone Throw Time"),m.V(A::LOCKON_POS),m.F(A::CASTING_TIMER),ConfigPixels("Standard Attack.Stone Radius"),ConfigFloat("Standard Attack.Stone Throw Height Offset"),acc,ConfigInt("Standard Attack.Stone Damage"),ConfigFloat("Standard Attack.Stone Throw Knockback Factor"),m.OnUpperLevel(),false,INFINITY,false,WHITE,vf2d{1,1}*m.GetSizeMult(),util::random(2*PI))EndBullet;
}else{ }else{
m.phase=BEAR_ATTACK; m.phase=BEAR_ATTACK;
m.F(A::CHASE_TIMER)=0.f;
} }
}break; }break;
case STONE_THROW_CAST:{ case STONE_THROW_CAST:{
@ -294,6 +297,7 @@ void Monster::STRATEGY::STONE_GOLEM(Monster&m,float fElapsedTime,std::string str
}else m.F(A::SAFE_AREA_WAIT_TIMER)-=fElapsedTime; }else m.F(A::SAFE_AREA_WAIT_TIMER)-=fElapsedTime;
}break; }break;
case BEAR_ATTACK:{ case BEAR_ATTACK:{
m.F(A::CHASE_TIMER)+=fElapsedTime;
BEAR(m,fElapsedTime,"Bear"); BEAR(m,fElapsedTime,"Bear");
//Extending the bear script's variables to read the state of it... //Extending the bear script's variables to read the state of it...
const bool SlamHasFinished=m.I(A::ATTACK_COUNT)!=m.I(A::BEAR_STOMP_COUNT); //The bear script uses the internal phase variable to determine the state of things. const bool SlamHasFinished=m.I(A::ATTACK_COUNT)!=m.I(A::BEAR_STOMP_COUNT); //The bear script uses the internal phase variable to determine the state of things.
@ -301,8 +305,28 @@ void Monster::STRATEGY::STONE_GOLEM(Monster&m,float fElapsedTime,std::string str
m.phase=STANDARD; m.phase=STANDARD;
m.I(A::ATTACK_COUNT)=m.I(A::BEAR_STOMP_COUNT); m.I(A::ATTACK_COUNT)=m.I(A::BEAR_STOMP_COUNT);
}else }else
if(m.I(A::PHASE)==0){ if(m.I(A::PHASE)==0&&m.F(A::CHASE_TIMER)>=ConfigFloat("Max Chase Time")){
//Walking towards... If 7 seconds or more occurs here, fallback to a different plan. m.phase=DOUBLE_ROCK_TOSS;
m.PerformAnimation("RAISE ROCK");
m.I(A::STONE_TOSS_COUNT)=ConfigInt("Stone Rain.Initial Stone Toss Count");
m.F(A::STONE_TOSS_TIMER)=m.GetCurrentAnimation().GetTotalAnimationDuration();
}
}break;
case DOUBLE_ROCK_TOSS:{
m.F(A::STONE_TOSS_TIMER)-=fElapsedTime;
if(m.F(A::STONE_TOSS_TIMER)<=0.f){
m.F(A::STONE_TOSS_TIMER)=ConfigFloat("Stone Rain.Stone Toss Delay");
m.I(A::STONE_TOSS_COUNT)--;
const datafile&throwPos{Config("Stone Rain.Stone Toss Initial Throw Pos")};
game->AddEffect(std::make_unique<RockLaunch>(m.GetPos()+vf2d{util::random_range(throwPos.GetReal(0),throwPos.GetReal(2)),util::random_range(throwPos.GetReal(1),throwPos.GetReal(3))},10.f,"rock.png",ConfigFloat("Stone Rain.Stone Toss Delay"),ConfigFloat("Stone Rain.Stone Toss Rock Size Mult"),0.1f,vf2d{0.f,-ConfigFloat("Stone Rain.Stone Toss Throw Speed")},WHITE,util::random(2*PI),0.f));
if(m.I(A::STONE_TOSS_COUNT)<=0){
m.I(A::STONE_RAIN_COUNT)=ConfigInt("Stone Rain.Stone Count");
m.phase=STONE_RAIN;
m.PerformAnimation("CAST");
}
} }
}break; }break;
} }

@ -39,7 +39,7 @@ All rights reserved.
#define VERSION_MAJOR 1 #define VERSION_MAJOR 1
#define VERSION_MINOR 2 #define VERSION_MINOR 2
#define VERSION_PATCH 3 #define VERSION_PATCH 3
#define VERSION_BUILD 9979 #define VERSION_BUILD 9994
#define stringify(a) stringify_(a) #define stringify(a) stringify_(a)
#define stringify_(a) #a #define stringify_(a) #a

@ -898,6 +898,9 @@ MonsterStrategy
} }
Stone Golem Stone Golem
{ {
# How long before the Stone Golem chooses to use its stone rain attack.
Max Chase Time = 7s
Pillar Respawns Pillar Respawns
{ {
Start HP Threshold = 75% Start HP Threshold = 75%
@ -915,8 +918,6 @@ MonsterStrategy
# Degrees/sec. Positive is CW, Negative is CCW. # Degrees/sec. Positive is CW, Negative is CCW.
Spell Insignia Rotation Spd = 50 Spell Insignia Rotation Spd = 50
} }
Beginning Phase Beginning Phase
{ {
# Number of pillars to spawn. # Number of pillars to spawn.
@ -967,6 +968,27 @@ MonsterStrategy
Shockwave Fadeout Time = 0.5s Shockwave Fadeout Time = 0.5s
Shockwave Color = 255 red, 255 green, 255 blue, 120 alpha Shockwave Color = 255 red, 255 green, 255 blue, 120 alpha
} }
Stone Rain
{
# How many stones the boss throws in the air.
Initial Stone Toss Count = 2
# Provide a Min X, Min Y, Max X, Max Y relative to the boss' position for where the stones appear prior to being tossed.
Stone Toss Initial Throw Pos = -20, -60, 20, -40
# Initial Rock size is 10x9
Stone Toss Rock Size Mult = 2.0
# How long from the stone appearing to being thrown up
Stone Toss Delay = 0.3s
Stone Toss Throw Speed = 350
# Number of stones that will appear.
Stone Count = 25
# Provide a minimum and maximum time for stones to fall.
Stone Fall Delay = 2.5s, 4.0s
# How long the indicator will appear before the rock drops down.
Indicator Time = 1s
Stone Damage = 30
Stone Radius = 50
}
} }
Breaking Pillar Breaking Pillar
{ {

@ -23,7 +23,7 @@ Monsters
Animations Animations
{ {
# Frame Count, Frame Speed (s), Frame Cycling (Repeat,OneShot,PingPong,Reverse) # Frame Count, Frame Speed (s), Frame Cycling (Repeat,OneShot,PingPong,Reverse,ReverseOneShot)
# Animations must be defined in the same order as they are in their sprite sheets # Animations must be defined in the same order as they are in their sprite sheets
# The First Four animations must represent a standing, walking, attack, and death animation. Their names are up to the creator. # The First Four animations must represent a standing, walking, attack, and death animation. Their names are up to the creator.
IDLE = 10, 0.1, Repeat IDLE = 10, 0.1, Repeat
@ -63,7 +63,7 @@ Monsters
Animations Animations
{ {
# Frame Count, Frame Speed (s), Frame Cycling (Repeat,OneShot,PingPong,Reverse) # Frame Count, Frame Speed (s), Frame Cycling (Repeat,OneShot,PingPong,Reverse,ReverseOneShot)
# Animations must be defined in the same order as they are in their sprite sheets # Animations must be defined in the same order as they are in their sprite sheets
# The First Four animations must represent a standing, walking, attack, and death animation. Their names are up to the creator. # The First Four animations must represent a standing, walking, attack, and death animation. Their names are up to the creator.
IDLE = 10, 0.1, Repeat IDLE = 10, 0.1, Repeat
@ -103,7 +103,7 @@ Monsters
Animations Animations
{ {
# Frame Count, Frame Speed (s), Frame Cycling (Repeat,OneShot,PingPong,Reverse) # Frame Count, Frame Speed (s), Frame Cycling (Repeat,OneShot,PingPong,Reverse,ReverseOneShot)
# Animations must be defined in the same order as they are in their sprite sheets # Animations must be defined in the same order as they are in their sprite sheets
# The First Four animations must represent a standing, walking, attack, and death animation. Their names are up to the creator. # The First Four animations must represent a standing, walking, attack, and death animation. Their names are up to the creator.
IDLE = 10, 0.1, Repeat IDLE = 10, 0.1, Repeat
@ -143,7 +143,7 @@ Monsters
Animations Animations
{ {
# Frame Count, Frame Speed (s), Frame Cycling (Repeat,OneShot,PingPong,Reverse) # Frame Count, Frame Speed (s), Frame Cycling (Repeat,OneShot,PingPong,Reverse,ReverseOneShot)
# Animations must be defined in the same order as they are in their sprite sheets # Animations must be defined in the same order as they are in their sprite sheets
# The First Four animations must represent a standing, walking, attack, and death animation. Their names are up to the creator. # The First Four animations must represent a standing, walking, attack, and death animation. Their names are up to the creator.
IDLE = 10, 0.1, Repeat IDLE = 10, 0.1, Repeat
@ -192,7 +192,7 @@ Monsters
Animations Animations
{ {
# Frame Count, Frame Speed (s), Frame Cycling (Repeat,OneShot,PingPong,Reverse) # Frame Count, Frame Speed (s), Frame Cycling (Repeat,OneShot,PingPong,Reverse,ReverseOneShot)
# Animations must be defined in the same order as they are in their sprite sheets # Animations must be defined in the same order as they are in their sprite sheets
# The First Four animations must represent a standing, walking, attack, and death animation. Their names are up to the creator. # The First Four animations must represent a standing, walking, attack, and death animation. Their names are up to the creator.
IDLE = 7, 0.1, PingPong IDLE = 7, 0.1, PingPong
@ -236,7 +236,7 @@ Monsters
Animations Animations
{ {
# Frame Count, Frame Speed (s), Frame Cycling (Repeat,OneShot,PingPong,Reverse) # Frame Count, Frame Speed (s), Frame Cycling (Repeat,OneShot,PingPong,Reverse,ReverseOneShot)
# Animations must be defined in the same order as they are in their sprite sheets # Animations must be defined in the same order as they are in their sprite sheets
# The First Four animations must represent a standing, walking, attack, and death animation. Their names are up to the creator. # The First Four animations must represent a standing, walking, attack, and death animation. Their names are up to the creator.
IDLE = 10, 0.1, Repeat IDLE = 10, 0.1, Repeat
@ -275,7 +275,7 @@ Monsters
Animations Animations
{ {
# Frame Count, Frame Speed (s), Frame Cycling (Repeat,OneShot,PingPong,Reverse) # Frame Count, Frame Speed (s), Frame Cycling (Repeat,OneShot,PingPong,Reverse,ReverseOneShot)
# Animations must be defined in the same order as they are in their sprite sheets # Animations must be defined in the same order as they are in their sprite sheets
# The First Four animations must represent a standing, walking, attack, and death animation. Their names are up to the creator. # The First Four animations must represent a standing, walking, attack, and death animation. Their names are up to the creator.
IDLE = 3, 0.2, PingPong IDLE = 3, 0.2, PingPong
@ -313,7 +313,7 @@ Monsters
Animations Animations
{ {
# Frame Count, Frame Speed (s), Frame Cycling (Repeat,OneShot,PingPong,Reverse) # Frame Count, Frame Speed (s), Frame Cycling (Repeat,OneShot,PingPong,Reverse,ReverseOneShot)
# Animations must be defined in the same order as they are in their sprite sheets # Animations must be defined in the same order as they are in their sprite sheets
# The First Four animations must represent a standing, walking, attack, and death animation. Their names are up to the creator. # The First Four animations must represent a standing, walking, attack, and death animation. Their names are up to the creator.
IDLE = 4, 0.13, PingPong IDLE = 4, 0.13, PingPong
@ -351,7 +351,7 @@ Monsters
Animations Animations
{ {
# Frame Count, Frame Speed (s), Frame Cycling (Repeat,OneShot,PingPong,Reverse) # Frame Count, Frame Speed (s), Frame Cycling (Repeat,OneShot,PingPong,Reverse,ReverseOneShot)
# Animations must be defined in the same order as they are in their sprite sheets # Animations must be defined in the same order as they are in their sprite sheets
# The First Four animations must represent a standing, walking, attack, and death animation. Their names are up to the creator. # The First Four animations must represent a standing, walking, attack, and death animation. Their names are up to the creator.
IDLE = 4, 0.3, Repeat IDLE = 4, 0.3, Repeat
@ -418,7 +418,7 @@ Monsters
Animations Animations
{ {
# Frame Count, Frame Speed (s), Frame Cycling (Repeat,OneShot,PingPong,Reverse) # Frame Count, Frame Speed (s), Frame Cycling (Repeat,OneShot,PingPong,Reverse,ReverseOneShot)
# Animations must be defined in the same order as they are in their sprite sheets # Animations must be defined in the same order as they are in their sprite sheets
# The First Four animations must represent a standing, walking, attack, and death animation. Their names are up to the creator. # The First Four animations must represent a standing, walking, attack, and death animation. Their names are up to the creator.
IDLE = 4, 0.3, Repeat IDLE = 4, 0.3, Repeat
@ -463,7 +463,7 @@ Monsters
Animations Animations
{ {
# Frame Count, Frame Speed (s), Frame Cycling (Repeat,OneShot,PingPong,Reverse) # Frame Count, Frame Speed (s), Frame Cycling (Repeat,OneShot,PingPong,Reverse,ReverseOneShot)
# Animations must be defined in the same order as they are in their sprite sheets # Animations must be defined in the same order as they are in their sprite sheets
# The First Four animations must represent a standing, walking, attack, and death animation. Their names are up to the creator. # The First Four animations must represent a standing, walking, attack, and death animation. Their names are up to the creator.
IDLE = 10, 0.1, Repeat IDLE = 10, 0.1, Repeat
@ -510,7 +510,7 @@ Monsters
Animations Animations
{ {
# Frame Count, Frame Speed (s), Frame Cycling (Repeat,OneShot,PingPong,Reverse) # Frame Count, Frame Speed (s), Frame Cycling (Repeat,OneShot,PingPong,Reverse,ReverseOneShot)
# Animations must be defined in the same order as they are in their sprite sheets # Animations must be defined in the same order as they are in their sprite sheets
# The First Four animations must represent a standing, walking, attack, and death animation. Their names are up to the creator. # The First Four animations must represent a standing, walking, attack, and death animation. Their names are up to the creator.
IDLE = 1, 0.6, Repeat IDLE = 1, 0.6, Repeat
@ -551,7 +551,7 @@ Monsters
Animations Animations
{ {
# Frame Count, Frame Speed (s), Frame Cycling (Repeat,OneShot,PingPong,Reverse) # Frame Count, Frame Speed (s), Frame Cycling (Repeat,OneShot,PingPong,Reverse,ReverseOneShot)
# Animations must be defined in the same order as they are in their sprite sheets # Animations must be defined in the same order as they are in their sprite sheets
# The First Four animations must represent a standing, walking, attack, and death animation. Their names are up to the creator. # The First Four animations must represent a standing, walking, attack, and death animation. Their names are up to the creator.
IDLE = 2, 0.6, Repeat IDLE = 2, 0.6, Repeat
@ -592,7 +592,7 @@ Monsters
Animations Animations
{ {
# Frame Count, Frame Speed (s), Frame Cycling (Repeat,OneShot,PingPong,Reverse) # Frame Count, Frame Speed (s), Frame Cycling (Repeat,OneShot,PingPong,Reverse,ReverseOneShot)
# Animations must be defined in the same order as they are in their sprite sheets # Animations must be defined in the same order as they are in their sprite sheets
# The First Four animations must represent a standing, walking, attack, and death animation. Their names are up to the creator. # The First Four animations must represent a standing, walking, attack, and death animation. Their names are up to the creator.
IDLE = 2, 0.6, Repeat IDLE = 2, 0.6, Repeat
@ -630,7 +630,7 @@ Monsters
Animations Animations
{ {
# Frame Count, Frame Speed (s), Frame Cycling (Repeat,OneShot,PingPong,Reverse) # Frame Count, Frame Speed (s), Frame Cycling (Repeat,OneShot,PingPong,Reverse,ReverseOneShot)
# Animations must be defined in the same order as they are in their sprite sheets # Animations must be defined in the same order as they are in their sprite sheets
# The First Four animations must represent a standing, walking, attack, and death animation. Their names are up to the creator. # The First Four animations must represent a standing, walking, attack, and death animation. Their names are up to the creator.
IDLE = 2, 0.6, Repeat IDLE = 2, 0.6, Repeat
@ -672,7 +672,7 @@ Monsters
Animations Animations
{ {
# Frame Count, Frame Speed (s), Frame Cycling (Repeat,OneShot,PingPong,Reverse) # Frame Count, Frame Speed (s), Frame Cycling (Repeat,OneShot,PingPong,Reverse,ReverseOneShot)
# Animations must be defined in the same order as they are in their sprite sheets # Animations must be defined in the same order as they are in their sprite sheets
# The First Four animations must represent a standing, walking, attack, and death animation. Their names are up to the creator. # The First Four animations must represent a standing, walking, attack, and death animation. Their names are up to the creator.
IDLE = 1, 0.6, Repeat IDLE = 1, 0.6, Repeat
@ -721,7 +721,7 @@ Monsters
Animations Animations
{ {
# Frame Count, Frame Speed (s), Frame Cycling (Repeat,OneShot,PingPong,Reverse) # Frame Count, Frame Speed (s), Frame Cycling (Repeat,OneShot,PingPong,Reverse,ReverseOneShot)
# Animations must be defined in the same order as they are in their sprite sheets # Animations must be defined in the same order as they are in their sprite sheets
# The First Four animations must represent a standing, walking, attack, and death animation. Their names are up to the creator. # The First Four animations must represent a standing, walking, attack, and death animation. Their names are up to the creator.
IDLE = 1, 0.6, Repeat IDLE = 1, 0.6, Repeat
@ -763,7 +763,7 @@ Monsters
Animations Animations
{ {
# Frame Count, Frame Speed (s), Frame Cycling (Repeat,OneShot,PingPong,Reverse) # Frame Count, Frame Speed (s), Frame Cycling (Repeat,OneShot,PingPong,Reverse,ReverseOneShot)
# Animations must be defined in the same order as they are in their sprite sheets # Animations must be defined in the same order as they are in their sprite sheets
# The First Four animations must represent a standing, walking, attack, and death animation. Their names are up to the creator. # The First Four animations must represent a standing, walking, attack, and death animation. Their names are up to the creator.
IDLE = 2, 0.6, Repeat IDLE = 2, 0.6, Repeat
@ -811,7 +811,7 @@ Monsters
Animations Animations
{ {
# Frame Count, Frame Speed (s), Frame Cycling (Repeat,OneShot,PingPong,Reverse) # Frame Count, Frame Speed (s), Frame Cycling (Repeat,OneShot,PingPong,Reverse,ReverseOneShot)
# Animations must be defined in the same order as they are in their sprite sheets # Animations must be defined in the same order as they are in their sprite sheets
# The First Four animations must represent a standing, walking, attack, and death animation. Their names are up to the creator. # The First Four animations must represent a standing, walking, attack, and death animation. Their names are up to the creator.
IDLE = 4, 0.4, OneShot IDLE = 4, 0.4, OneShot
@ -873,7 +873,7 @@ Monsters
Animations Animations
{ {
# Frame Count, Frame Speed (s), Frame Cycling (Repeat,OneShot,PingPong,Reverse) # Frame Count, Frame Speed (s), Frame Cycling (Repeat,OneShot,PingPong,Reverse,ReverseOneShot)
# Animations must be defined in the same order as they are in their sprite sheets # Animations must be defined in the same order as they are in their sprite sheets
# The First Four animations must represent a standing, walking, attack, and death animation. Their names are up to the creator. # The First Four animations must represent a standing, walking, attack, and death animation. Their names are up to the creator.
IDLE = 1, 0.6, Repeat IDLE = 1, 0.6, Repeat
@ -917,7 +917,7 @@ Monsters
Animations Animations
{ {
# Frame Count, Frame Speed (s), Frame Cycling (Repeat,OneShot,PingPong,Reverse) # Frame Count, Frame Speed (s), Frame Cycling (Repeat,OneShot,PingPong,Reverse,ReverseOneShot)
# Animations must be defined in the same order as they are in their sprite sheets # Animations must be defined in the same order as they are in their sprite sheets
# The First Four animations must represent a standing, walking, attack, and death animation. Their names are up to the creator. # The First Four animations must represent a standing, walking, attack, and death animation. Their names are up to the creator.
IDLE = 1, 0.6, Repeat IDLE = 1, 0.6, Repeat
@ -962,7 +962,7 @@ Monsters
Animations Animations
{ {
# Frame Count, Frame Speed (s), Frame Cycling (Repeat,OneShot,PingPong,Reverse) # Frame Count, Frame Speed (s), Frame Cycling (Repeat,OneShot,PingPong,Reverse,ReverseOneShot)
# Animations must be defined in the same order as they are in their sprite sheets # Animations must be defined in the same order as they are in their sprite sheets
# The First Four animations must represent a standing, walking, attack, and death animation. Their names are up to the creator. # The First Four animations must represent a standing, walking, attack, and death animation. Their names are up to the creator.
IDLE = 1, 0.6, Repeat IDLE = 1, 0.6, Repeat
@ -1029,7 +1029,7 @@ Monsters
Animations Animations
{ {
# Frame Count, Frame Speed (s), Frame Cycling (Repeat,OneShot,PingPong,Reverse) # Frame Count, Frame Speed (s), Frame Cycling (Repeat,OneShot,PingPong,Reverse,ReverseOneShot)
# Animations must be defined in the same order as they are in their sprite sheets # Animations must be defined in the same order as they are in their sprite sheets
# The First Four animations must represent a standing, walking, attack, and death animation. Their names are up to the creator. # The First Four animations must represent a standing, walking, attack, and death animation. Their names are up to the creator.
IDLE = 2, 0.6, Repeat IDLE = 2, 0.6, Repeat
@ -1041,6 +1041,7 @@ Monsters
TOSS ROCK CAST = 2, 0.2, Repeat TOSS ROCK CAST = 2, 0.2, Repeat
SLAM = 3, 0.15, OneShot SLAM = 3, 0.15, OneShot
TOSS ROCK = 3, 0.2, OneShot TOSS ROCK = 3, 0.2, OneShot
RAISE ROCK = 3, 0.2, ReverseOneShot
} }
Ignore Collisions = True Ignore Collisions = True
@ -1083,7 +1084,7 @@ Monsters
Animations Animations
{ {
# Frame Count, Frame Speed (s), Frame Cycling (Repeat,OneShot,PingPong,Reverse) # Frame Count, Frame Speed (s), Frame Cycling (Repeat,OneShot,PingPong,Reverse,ReverseOneShot)
# Animations must be defined in the same order as they are in their sprite sheets # Animations must be defined in the same order as they are in their sprite sheets
# The First Four animations must represent a standing, walking, attack, and death animation. Their names are up to the creator. # The First Four animations must represent a standing, walking, attack, and death animation. Their names are up to the creator.
NORMAL = 4, 0.4, OneShot NORMAL = 4, 0.4, OneShot
@ -1133,7 +1134,7 @@ Monsters
Animations Animations
{ {
# Frame Count, Frame Speed (s), Frame Cycling (Repeat,OneShot,PingPong,Reverse) # Frame Count, Frame Speed (s), Frame Cycling (Repeat,OneShot,PingPong,Reverse,ReverseOneShot)
# Animations must be defined in the same order as they are in their sprite sheets # Animations must be defined in the same order as they are in their sprite sheets
# The First Four animations must represent a standing, walking, attack, and death animation. Their names are up to the creator. # The First Four animations must represent a standing, walking, attack, and death animation. Their names are up to the creator.
NORMAL = 4, 0.4, OneShot NORMAL = 4, 0.4, OneShot

@ -99,6 +99,7 @@ namespace olc::utils::Animate2D
Repeat, // Cycle through, go back to beginning Repeat, // Cycle through, go back to beginning
OneShot, // Play once and suspend on final frame OneShot, // Play once and suspend on final frame
PingPong, // Traverse through forwards, then backwards PingPong, // Traverse through forwards, then backwards
ReverseOneShot, // Cycle through sequence backwards and suspend on final frame
Reverse, // Cycle through sequence backwards Reverse, // Cycle through sequence backwards
}; };
@ -146,6 +147,7 @@ namespace olc::utils::Animate2D
{ {
case Style::Repeat: case Style::Repeat:
case Style::OneShot: case Style::OneShot:
case Style::ReverseOneShot:
return m_vFrames.size()*m_fFrameDuration; return m_vFrames.size()*m_fFrameDuration;
case Style::PingPong: case Style::PingPong:
case Style::Reverse: //These two require twice as much time (minus one frame) to complete a full animation cycle. case Style::Reverse: //These two require twice as much time (minus one frame) to complete a full animation cycle.
@ -161,6 +163,7 @@ namespace olc::utils::Animate2D
{ {
case Style::Repeat: case Style::Repeat:
case Style::OneShot: case Style::OneShot:
case Style::ReverseOneShot:
return m_vFrames.size(); return m_vFrames.size();
case Style::PingPong: case Style::PingPong:
case Style::Reverse: //These two require twice as much time (minus one frame) to complete a full animation cycle. case Style::Reverse: //These two require twice as much time (minus one frame) to complete a full animation cycle.
@ -177,19 +180,18 @@ namespace olc::utils::Animate2D
{ {
switch (m_nStyle) switch (m_nStyle)
{ {
case Style::Repeat: case Style::Repeat:
return size_t(fTime * m_fFrameRate) % m_vFrames.size(); return size_t(fTime * m_fFrameRate) % m_vFrames.size();
break; case Style::OneShot:
case Style::OneShot: return std::clamp(size_t(fTime * m_fFrameRate), size_t(0), m_vFrames.size() - 1);
return std::clamp(size_t(fTime * m_fFrameRate), size_t(0), m_vFrames.size() - 1); case Style::PingPong:{
break;
case Style::PingPong:{
size_t frame=size_t(m_fFrameRate*fTime) % (m_vFrames.size()*size_t(2)-size_t(1)); size_t frame=size_t(m_fFrameRate*fTime) % (m_vFrames.size()*size_t(2)-size_t(1));
return frame>=m_vFrames.size()?m_vFrames.size()-frame%m_vFrames.size()-1:frame; return frame>=m_vFrames.size()?m_vFrames.size()-frame%m_vFrames.size()-1:frame;
}break; }break;
case Style::Reverse: case Style::ReverseOneShot:
return (m_vFrames.size() - 1) - (size_t(fTime * m_fFrameRate) % m_vFrames.size()); return std::clamp((m_vFrames.size() - 1) - size_t(fTime * m_fFrameRate), size_t(0), m_vFrames.size() - 1);
break; case Style::Reverse:
return (m_vFrames.size() - 1) - (size_t(fTime * m_fFrameRate) % m_vFrames.size());
} }
return 0; return 0;

Loading…
Cancel
Save