diff --git a/Crawler/Animation.h b/Crawler/Animation.h
new file mode 100644
index 00000000..6b28877c
--- /dev/null
+++ b/Crawler/Animation.h
@@ -0,0 +1,6 @@
+#pragma once
+
+enum AnimationState{
+ WALK_S,WALK_E,WALK_N,WALK_W,
+ IDLE_S,IDLE_E,IDLE_N,IDLE_W
+};
\ No newline at end of file
diff --git a/Crawler/Crawler.vcxproj b/Crawler/Crawler.vcxproj
index 124e59b1..aa3c38f3 100644
--- a/Crawler/Crawler.vcxproj
+++ b/Crawler/Crawler.vcxproj
@@ -129,6 +129,7 @@
+
diff --git a/Crawler/Crawler.vcxproj.filters b/Crawler/Crawler.vcxproj.filters
index 9ba021dd..ea456f93 100644
--- a/Crawler/Crawler.vcxproj.filters
+++ b/Crawler/Crawler.vcxproj.filters
@@ -33,6 +33,9 @@
Header Files
+
+ Header Files
+
diff --git a/Crawler/Monster.cpp b/Crawler/Monster.cpp
index a5c71d21..f0924400 100644
--- a/Crawler/Monster.cpp
+++ b/Crawler/Monster.cpp
@@ -1,5 +1,7 @@
#include "Monster.h"
+extern std::mapANIMATION_DATA;
+
MonsterData::MonsterData(){}
MonsterData::MonsterData(int hp,int atk,float moveSpd,float size,MonsterStrategy strategy):
hp(hp),atk(atk),moveSpd(moveSpd),size(size),strategy(strategy){
diff --git a/Crawler/Monster.h b/Crawler/Monster.h
index 008f0d77..624ae8d9 100644
--- a/Crawler/Monster.h
+++ b/Crawler/Monster.h
@@ -1,4 +1,6 @@
#include "olcPixelGameEngine.h"
+#include "Animation.h"
+#include "olcUTIL_Animate2D.h"
enum MonsterStrategy{
RUN_TOWARDS,
@@ -12,6 +14,7 @@ struct MonsterData{
float moveSpd;//1.0=100%
float size;
MonsterStrategy strategy;
+ Animate2D::Animationanimation;
public:
MonsterData();
MonsterData(int hp,int atk,float moveSpd=1.0f,float size=1.0f,MonsterStrategy strategy=RUN_TOWARDS);
@@ -45,4 +48,10 @@ struct Monster{
int GetAttack();
float GetMoveSpdMult();
float GetSizeMult();
+};
+
+struct MonsterSpawner{
+ vf2d pos;
+ int range;
+ std::vector>monsters;
};
\ No newline at end of file
diff --git a/Crawler/assets/slime.png b/Crawler/assets/slime.png
index 8c9a2063..2cb03fb7 100644
Binary files a/Crawler/assets/slime.png and b/Crawler/assets/slime.png differ
diff --git a/Crawler/main.cpp b/Crawler/main.cpp
index f6c1d137..3f2b9539 100644
--- a/Crawler/main.cpp
+++ b/Crawler/main.cpp
@@ -5,15 +5,12 @@
#include "olcPGEX_TransformedView.h"
#include "olcUTIL_Animate2D.h"
#include "Monster.h"
+#include "Animation.h"
const vi2d WINDOW_SIZE={24*8,24*8};
extern std::mapMONSTER_DATA;
-
-enum AnimationState{
- WALK_S,WALK_E,WALK_N,WALK_W,
- IDLE_S,IDLE_E,IDLE_N,IDLE_W
-};
+std::mapANIMATION_DATA;
struct Player{
private:
@@ -72,8 +69,8 @@ struct Player{
void Update(float fElapsedTime){
animation.UpdateState(internal_animState,fElapsedTime);
}
- void AddAnimation(AnimationState state,Animate2D::FrameSequence frame){
- animation.AddState(state,frame);
+ void AddAnimation(AnimationState state){
+ animation.AddState(state,ANIMATION_DATA[state]);
};
void UpdateAnimation(AnimationState animState){
animation.ChangeState(internal_animState,animState);
@@ -119,48 +116,20 @@ public:
GFX_Pl_sheet.Load("assets/nico-warrior.png");
//Animations
- Animate2D::FrameSequence pl_walk_s{0.2};
- pl_walk_s.AddFrame({&GFX_Pl_sheet,{vi2d{0,0}*24,{24,24}}});
- pl_walk_s.AddFrame({&GFX_Pl_sheet,{vi2d{1,0}*24,{24,24}}});
- pl_walk_s.AddFrame({&GFX_Pl_sheet,{vi2d{0,0}*24,{24,24}}});
- pl_walk_s.AddFrame({&GFX_Pl_sheet,{vi2d{2,0}*24,{24,24}}});
- Animate2D::FrameSequence pl_walk_e{0.2};
- pl_walk_e.AddFrame({&GFX_Pl_sheet,{vi2d{0,3}*24,{24,24}}});
- pl_walk_e.AddFrame({&GFX_Pl_sheet,{vi2d{1,3}*24,{24,24}}});
- pl_walk_e.AddFrame({&GFX_Pl_sheet,{vi2d{0,3}*24,{24,24}}});
- pl_walk_e.AddFrame({&GFX_Pl_sheet,{vi2d{2,3}*24,{24,24}}});
- Animate2D::FrameSequence pl_walk_w{0.2};
- pl_walk_w.AddFrame({&GFX_Pl_sheet,{vi2d{0,2}*24,{24,24}}});
- pl_walk_w.AddFrame({&GFX_Pl_sheet,{vi2d{1,2}*24,{24,24}}});
- pl_walk_w.AddFrame({&GFX_Pl_sheet,{vi2d{0,2}*24,{24,24}}});
- pl_walk_w.AddFrame({&GFX_Pl_sheet,{vi2d{2,2}*24,{24,24}}});
- Animate2D::FrameSequence pl_walk_n{0.2};
- pl_walk_n.AddFrame({&GFX_Pl_sheet,{vi2d{0,1}*24,{24,24}}});
- pl_walk_n.AddFrame({&GFX_Pl_sheet,{vi2d{1,1}*24,{24,24}}});
- pl_walk_n.AddFrame({&GFX_Pl_sheet,{vi2d{0,1}*24,{24,24}}});
- pl_walk_n.AddFrame({&GFX_Pl_sheet,{vi2d{2,1}*24,{24,24}}});
- Animate2D::FrameSequence pl_idle_s;
- pl_idle_s.AddFrame({&GFX_Pl_sheet,{vi2d{0,0}*24,{24,24}}});
- Animate2D::FrameSequence pl_idle_e;
- pl_idle_e.AddFrame({&GFX_Pl_sheet,{vi2d{0,3}*24,{24,24}}});
- Animate2D::FrameSequence pl_idle_w;
- pl_idle_w.AddFrame({&GFX_Pl_sheet,{vi2d{0,2}*24,{24,24}}});
- Animate2D::FrameSequence pl_idle_n;
- pl_idle_n.AddFrame({&GFX_Pl_sheet,{vi2d{0,1}*24,{24,24}}});
+ InitializeAnimations();
-
- player.AddAnimation(WALK_N,pl_walk_n);
- player.AddAnimation(WALK_E,pl_walk_e);
- player.AddAnimation(WALK_S,pl_walk_s);
- player.AddAnimation(WALK_W,pl_walk_w);
- player.AddAnimation(IDLE_N,pl_idle_n);
- player.AddAnimation(IDLE_E,pl_idle_e);
- player.AddAnimation(IDLE_S,pl_idle_s);
- player.AddAnimation(IDLE_W,pl_idle_w);
+ player.AddAnimation(AnimationState::WALK_N);
+ player.AddAnimation(AnimationState::WALK_E);
+ player.AddAnimation(AnimationState::WALK_S);
+ player.AddAnimation(AnimationState::WALK_W);
+ player.AddAnimation(AnimationState::IDLE_N);
+ player.AddAnimation(AnimationState::IDLE_E);
+ player.AddAnimation(AnimationState::IDLE_S);
+ player.AddAnimation(AnimationState::IDLE_W);
view=TileTransformedView{GetScreenSize(),{1,1}};
player.SetPos({4*24,4*24});
- player.UpdateAnimation(IDLE_S);
+ player.UpdateAnimation(AnimationState::IDLE_S);
std::cout<