Consolidated jump and shoot animations for monsters into MonsterData.
This commit is contained in:
parent
d990d021c1
commit
5566eced77
@ -1,12 +1,6 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
#include "Bullet.h"
|
#include "Bullet.h"
|
||||||
|
|
||||||
struct GenericBullet:public Bullet{
|
|
||||||
GenericBullet(vf2d pos,vf2d vel,float radius,int damage,Pixel col=WHITE);
|
|
||||||
GenericBullet(vf2d pos,vf2d vel,float radius,int damage,AnimationState animation,bool hitsMultiple=false,float lifetime=INFINITE,bool rotatesWithAngle=false,Pixel col=WHITE);
|
|
||||||
void Update(float fElapsedTime)override;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct EnergyBolt:public Bullet{
|
struct EnergyBolt:public Bullet{
|
||||||
float lastParticleSpawn=0;
|
float lastParticleSpawn=0;
|
||||||
EnergyBolt(vf2d pos,vf2d vel,float radius,int damage,Pixel col=WHITE);
|
EnergyBolt(vf2d pos,vf2d vel,float radius,int damage,Pixel col=WHITE);
|
||||||
|
@ -12,33 +12,6 @@ INCLUDE_DAMAGENUMBER_LIST
|
|||||||
INCLUDE_game
|
INCLUDE_game
|
||||||
INCLUDE_BULLET_LIST
|
INCLUDE_BULLET_LIST
|
||||||
|
|
||||||
MonsterData::MonsterData(){}
|
|
||||||
MonsterData::MonsterData(MonsterName type,int hp,int atk,std::vector<AnimationState>animations,float moveSpd,float size,MonsterStrategy strategy,int collisionDmg):
|
|
||||||
type(type),hp(hp),atk(atk),moveSpd(moveSpd),size(size),strategy(strategy),animations(animations),collisionDmg(collisionDmg){
|
|
||||||
}
|
|
||||||
int MonsterData::GetHealth(){
|
|
||||||
return hp;
|
|
||||||
}
|
|
||||||
int MonsterData::GetAttack(){
|
|
||||||
return atk;
|
|
||||||
}
|
|
||||||
float MonsterData::GetMoveSpdMult(){
|
|
||||||
return moveSpd;
|
|
||||||
}
|
|
||||||
float MonsterData::GetSizeMult(){
|
|
||||||
return size;
|
|
||||||
}
|
|
||||||
int MonsterData::GetCollisionDmg(){
|
|
||||||
return collisionDmg;
|
|
||||||
}
|
|
||||||
MonsterName MonsterData::GetType(){
|
|
||||||
return type;
|
|
||||||
}
|
|
||||||
MonsterStrategy MonsterData::GetAIStrategy(){
|
|
||||||
return strategy;
|
|
||||||
}
|
|
||||||
|
|
||||||
Monster::Monster(){}
|
|
||||||
Monster::Monster(vf2d pos,MonsterData data):
|
Monster::Monster(vf2d pos,MonsterData data):
|
||||||
pos(pos),hp(data.GetHealth()),maxhp(data.GetHealth()),atk(data.GetAttack()),moveSpd(data.GetMoveSpdMult()),size(data.GetSizeMult()),strategy(data.GetAIStrategy()),type(data.GetType()){
|
pos(pos),hp(data.GetHealth()),maxhp(data.GetHealth()),atk(data.GetAttack()),moveSpd(data.GetMoveSpdMult()),size(data.GetSizeMult()),strategy(data.GetAIStrategy()),type(data.GetType()){
|
||||||
bool firstAnimation=true;
|
bool firstAnimation=true;
|
||||||
@ -81,36 +54,10 @@ void Monster::UpdateAnimation(AnimationState state){
|
|||||||
animation.ChangeState(internal_animState,state);
|
animation.ChangeState(internal_animState,state);
|
||||||
}
|
}
|
||||||
void Monster::PerformJumpAnimation(){
|
void Monster::PerformJumpAnimation(){
|
||||||
switch(type){
|
animation.ChangeState(internal_animState,MONSTER_DATA[type].GetJumpAnimation());
|
||||||
case SLIME_GREEN:{
|
|
||||||
animation.ChangeState(internal_animState,AnimationState::GREEN_SLIME_JUMP);
|
|
||||||
}break;
|
|
||||||
case SLIME_BLUE:{
|
|
||||||
animation.ChangeState(internal_animState,AnimationState::BLUE_SLIME_JUMP);
|
|
||||||
}break;
|
|
||||||
case SLIME_RED:{
|
|
||||||
animation.ChangeState(internal_animState,AnimationState::RED_SLIME_JUMP);
|
|
||||||
}break;
|
|
||||||
case SLIME_YELLOW:{
|
|
||||||
animation.ChangeState(internal_animState,AnimationState::YELLOW_SLIME_JUMP);
|
|
||||||
}break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
void Monster::PerformShootAnimation(){
|
void Monster::PerformShootAnimation(){
|
||||||
switch(type){
|
animation.ChangeState(internal_animState,MONSTER_DATA[type].GetShootAnimation());
|
||||||
case SLIME_GREEN:{
|
|
||||||
animation.ChangeState(internal_animState,AnimationState::GREEN_SLIME_SPIT);
|
|
||||||
}break;
|
|
||||||
case SLIME_BLUE:{
|
|
||||||
animation.ChangeState(internal_animState,AnimationState::BLUE_SLIME_SPIT);
|
|
||||||
}break;
|
|
||||||
case SLIME_RED:{
|
|
||||||
animation.ChangeState(internal_animState,AnimationState::RED_SLIME_SPIT);
|
|
||||||
}break;
|
|
||||||
case SLIME_YELLOW:{
|
|
||||||
animation.ChangeState(internal_animState,AnimationState::YELLOW_SLIME_SPIT);
|
|
||||||
}break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
bool Monster::SetX(float x){
|
bool Monster::SetX(float x){
|
||||||
vf2d newPos={x,pos.y};
|
vf2d newPos={x,pos.y};
|
||||||
@ -207,7 +154,9 @@ bool Monster::Update(float fElapsedTime){
|
|||||||
queueShotTimer-=fElapsedTime;
|
queueShotTimer-=fElapsedTime;
|
||||||
if(queueShotTimer<0){
|
if(queueShotTimer<0){
|
||||||
queueShotTimer=0;
|
queueShotTimer=0;
|
||||||
BULLET_LIST.push_back(std::make_unique<Bullet>(Bullet(pos+vf2d{0,-4},geom2d::line(pos+vf2d{0,-4},game->GetPlayer().GetPos()).vector().norm()*24*3.f,2,GetAttack(),{75/2,162/2,225/2})));
|
{
|
||||||
|
BULLET_LIST.push_back(std::make_unique<Bullet>(Bullet(pos + vf2d{ 0,-4 }, geom2d::line(pos + vf2d{ 0,-4 }, game->GetPlayer().GetPos()).vector().norm() * 24 * 3.f, 2, GetAttack(), { 75 / 2,162 / 2,225 / 2 })));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
geom2d::line line(pos,game->GetPlayer().GetPos());
|
geom2d::line line(pos,game->GetPlayer().GetPos());
|
||||||
|
@ -32,10 +32,13 @@ struct MonsterData{
|
|||||||
MonsterStrategy strategy;
|
MonsterStrategy strategy;
|
||||||
MonsterName type;
|
MonsterName type;
|
||||||
int collisionDmg;
|
int collisionDmg;
|
||||||
|
AnimationState jumpAnimation=AnimationState::WARRIOR_IDLE_S;
|
||||||
|
AnimationState shootAnimation=AnimationState::WARRIOR_IDLE_S;
|
||||||
public:
|
public:
|
||||||
MonsterData();
|
MonsterData();
|
||||||
//When specifying animations, the first one will become the default animation. The last becomes the death animation.
|
//When specifying animations, the first one will become the default animation. The last becomes the death animation.
|
||||||
MonsterData(MonsterName type,int hp,int atk,std::vector<AnimationState>animations,float moveSpd=1.0f,float size=1.0f,MonsterStrategy strategy=RUN_TOWARDS,int collisionDmg=0);
|
MonsterData(MonsterName type,int hp,int atk,std::vector<AnimationState>animations,float moveSpd=1.0f,float size=1.0f,MonsterStrategy strategy=RUN_TOWARDS,int collisionDmg=0
|
||||||
|
,AnimationState jumpAnimation=AnimationState::WARRIOR_IDLE_S,AnimationState shootAnimation=AnimationState::WARRIOR_IDLE_S);
|
||||||
int GetHealth();
|
int GetHealth();
|
||||||
int GetAttack();
|
int GetAttack();
|
||||||
float GetMoveSpdMult();
|
float GetMoveSpdMult();
|
||||||
@ -43,6 +46,8 @@ struct MonsterData{
|
|||||||
MonsterName GetType();
|
MonsterName GetType();
|
||||||
MonsterStrategy GetAIStrategy();
|
MonsterStrategy GetAIStrategy();
|
||||||
int GetCollisionDmg();
|
int GetCollisionDmg();
|
||||||
|
AnimationState GetJumpAnimation();
|
||||||
|
AnimationState GetShootAnimation();
|
||||||
std::vector<AnimationState>GetAnimations(){
|
std::vector<AnimationState>GetAnimations(){
|
||||||
return animations;
|
return animations;
|
||||||
}
|
}
|
||||||
@ -73,8 +78,9 @@ struct Monster{
|
|||||||
AnimationState GetDeathAnimationName();
|
AnimationState GetDeathAnimationName();
|
||||||
bool hasHitPlayer=false;
|
bool hasHitPlayer=false;
|
||||||
bool canMove=true; //Set to false when stuck due to collisions.
|
bool canMove=true; //Set to false when stuck due to collisions.
|
||||||
|
protected:
|
||||||
public:
|
public:
|
||||||
Monster();
|
Monster()=delete;
|
||||||
Monster(vf2d pos,MonsterData data);
|
Monster(vf2d pos,MonsterData data);
|
||||||
vf2d&GetPos();
|
vf2d&GetPos();
|
||||||
int GetHealth();
|
int GetHealth();
|
||||||
|
@ -2,9 +2,46 @@
|
|||||||
#include "Monster.h"
|
#include "Monster.h"
|
||||||
#include "Animation.h"
|
#include "Animation.h"
|
||||||
|
|
||||||
|
|
||||||
std::map<MonsterName,MonsterData>MONSTER_DATA={
|
std::map<MonsterName,MonsterData>MONSTER_DATA={
|
||||||
{SLIME_GREEN,MonsterData(MonsterName::SLIME_GREEN,10,5,{{AnimationState::GREEN_SLIME_IDLE,AnimationState::GREEN_SLIME_JUMP,AnimationState::GREEN_SLIME_ROLL,AnimationState::GREEN_SLIME_DIE,AnimationState::GREEN_SLIME_SPIT}},1.1f,0.8f,MonsterStrategy::RUN_TOWARDS,5)},
|
{SLIME_GREEN,MonsterData(MonsterName::SLIME_GREEN,10,5,{{AnimationState::GREEN_SLIME_IDLE,AnimationState::GREEN_SLIME_JUMP,AnimationState::GREEN_SLIME_ROLL,AnimationState::GREEN_SLIME_DIE,AnimationState::GREEN_SLIME_SPIT}},1.1f,0.8f,MonsterStrategy::RUN_TOWARDS,5,AnimationState::GREEN_SLIME_JUMP,AnimationState::GREEN_SLIME_SPIT)},
|
||||||
{SLIME_BLUE,MonsterData(MonsterName::SLIME_BLUE,30,10,{{AnimationState::BLUE_SLIME_IDLE,AnimationState::BLUE_SLIME_JUMP,AnimationState::BLUE_SLIME_ROLL,AnimationState::BLUE_SLIME_DIE,AnimationState::BLUE_SLIME_SPIT}},0.8f,1.0f,MonsterStrategy::SHOOT_AFAR)},
|
{SLIME_BLUE,MonsterData(MonsterName::SLIME_BLUE,30,10,{{AnimationState::BLUE_SLIME_IDLE,AnimationState::BLUE_SLIME_JUMP,AnimationState::BLUE_SLIME_ROLL,AnimationState::BLUE_SLIME_DIE,AnimationState::BLUE_SLIME_SPIT}},0.8f,1.0f,MonsterStrategy::SHOOT_AFAR,0,AnimationState::BLUE_SLIME_JUMP,AnimationState::BLUE_SLIME_SPIT)},
|
||||||
{SLIME_RED,MonsterData(MonsterName::SLIME_RED,25,10,{{AnimationState::RED_SLIME_IDLE,AnimationState::RED_SLIME_JUMP,AnimationState::RED_SLIME_ROLL,AnimationState::RED_SLIME_DIE,AnimationState::RED_SLIME_SPIT}},0.95f,1.2f,MonsterStrategy::RUN_TOWARDS,10)},
|
{SLIME_RED,MonsterData(MonsterName::SLIME_RED,25,10,{{AnimationState::RED_SLIME_IDLE,AnimationState::RED_SLIME_JUMP,AnimationState::RED_SLIME_ROLL,AnimationState::RED_SLIME_DIE,AnimationState::RED_SLIME_SPIT}},0.95f,1.2f,MonsterStrategy::RUN_TOWARDS,10,AnimationState::RED_SLIME_JUMP,AnimationState::RED_SLIME_SPIT)},
|
||||||
{SLIME_YELLOW,MonsterData(MonsterName::SLIME_YELLOW,175,10,{{AnimationState::YELLOW_SLIME_IDLE,AnimationState::YELLOW_SLIME_JUMP,AnimationState::YELLOW_SLIME_ROLL,AnimationState::YELLOW_SLIME_DIE,AnimationState::YELLOW_SLIME_SPIT}},0.4f,1.6f,MonsterStrategy::RUN_TOWARDS,15)},
|
{SLIME_YELLOW,MonsterData(MonsterName::SLIME_YELLOW,175,10,{{AnimationState::YELLOW_SLIME_IDLE,AnimationState::YELLOW_SLIME_JUMP,AnimationState::YELLOW_SLIME_ROLL,AnimationState::YELLOW_SLIME_DIE,AnimationState::YELLOW_SLIME_SPIT}},0.4f,1.6f,MonsterStrategy::RUN_TOWARDS,15,AnimationState::YELLOW_SLIME_JUMP,AnimationState::YELLOW_SLIME_SPIT)},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
MonsterData::MonsterData(){}
|
||||||
|
MonsterData::MonsterData(MonsterName type,int hp,int atk,std::vector<AnimationState>animations,float moveSpd,float size,MonsterStrategy strategy,int collisionDmg
|
||||||
|
,AnimationState jumpAnimation,AnimationState shootAnimation):
|
||||||
|
type(type),hp(hp),atk(atk),moveSpd(moveSpd),size(size),strategy(strategy),animations(animations),collisionDmg(collisionDmg)
|
||||||
|
,jumpAnimation(jumpAnimation),shootAnimation(shootAnimation){
|
||||||
|
}
|
||||||
|
int MonsterData::GetHealth(){
|
||||||
|
return hp;
|
||||||
|
}
|
||||||
|
int MonsterData::GetAttack(){
|
||||||
|
return atk;
|
||||||
|
}
|
||||||
|
float MonsterData::GetMoveSpdMult(){
|
||||||
|
return moveSpd;
|
||||||
|
}
|
||||||
|
float MonsterData::GetSizeMult(){
|
||||||
|
return size;
|
||||||
|
}
|
||||||
|
int MonsterData::GetCollisionDmg(){
|
||||||
|
return collisionDmg;
|
||||||
|
}
|
||||||
|
MonsterName MonsterData::GetType(){
|
||||||
|
return type;
|
||||||
|
}
|
||||||
|
MonsterStrategy MonsterData::GetAIStrategy(){
|
||||||
|
return strategy;
|
||||||
|
}
|
||||||
|
|
||||||
|
AnimationState MonsterData::GetJumpAnimation(){
|
||||||
|
return jumpAnimation;
|
||||||
|
}
|
||||||
|
AnimationState MonsterData::GetShootAnimation(){
|
||||||
|
return shootAnimation;
|
||||||
|
}
|
@ -414,7 +414,7 @@ void Player::Update(float fElapsedTime){
|
|||||||
UpdateAnimation(AnimationState::WARRIOR_SWINGSONICSWORD_S);
|
UpdateAnimation(AnimationState::WARRIOR_SWINGSONICSWORD_S);
|
||||||
}break;
|
}break;
|
||||||
}
|
}
|
||||||
PLAYER_BULLET_LIST.push_back(std::make_unique<Bullet>(Bullet(pos,bulletVel,30,GetAttack()*8,AnimationState::SONICSLASH,true,2.25,true)));
|
PLAYER_BULLET_LIST.push_back(std::make_unique<Bullet>(pos,bulletVel,30,GetAttack()*8,AnimationState::SONICSLASH,true,2.25,true));
|
||||||
game->SetupWorldShake(0.5);
|
game->SetupWorldShake(0.5);
|
||||||
}break;
|
}break;
|
||||||
case THIEF:{
|
case THIEF:{
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
#define VERSION_MAJOR 0
|
#define VERSION_MAJOR 0
|
||||||
#define VERSION_MINOR 2
|
#define VERSION_MINOR 2
|
||||||
#define VERSION_PATCH 0
|
#define VERSION_PATCH 0
|
||||||
#define VERSION_BUILD 347
|
#define VERSION_BUILD 352
|
||||||
|
|
||||||
#define stringify(a) stringify_(a)
|
#define stringify(a) stringify_(a)
|
||||||
#define stringify_(a) #a
|
#define stringify_(a) #a
|
||||||
|
7
Crawler/monSlimeA.cpp
Normal file
7
Crawler/monSlimeA.cpp
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
#include "MonsterType.h"
|
||||||
|
|
||||||
|
monSlimeA::monSlimeA(vf2d pos,MonsterData data)
|
||||||
|
:Monster(pos,data){
|
||||||
|
jumpAnimation=AnimationState::GREEN_SLIME_JUMP;
|
||||||
|
shootAnimation=AnimationState::GREEN_SLIME_SPIT;
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user