diff --git a/Crawler/Crawler.vcxproj b/Crawler/Crawler.vcxproj
index b6427db2..124e59b1 100644
--- a/Crawler/Crawler.vcxproj
+++ b/Crawler/Crawler.vcxproj
@@ -138,6 +138,7 @@
+
diff --git a/Crawler/Crawler.vcxproj.filters b/Crawler/Crawler.vcxproj.filters
index bd1e3320..9ba021dd 100644
--- a/Crawler/Crawler.vcxproj.filters
+++ b/Crawler/Crawler.vcxproj.filters
@@ -41,5 +41,8 @@
Source Files
+
+ Source Files
+
\ No newline at end of file
diff --git a/Crawler/Monster.cpp b/Crawler/Monster.cpp
new file mode 100644
index 00000000..a5c71d21
--- /dev/null
+++ b/Crawler/Monster.cpp
@@ -0,0 +1,41 @@
+#include "Monster.h"
+
+MonsterData::MonsterData(){}
+MonsterData::MonsterData(int hp,int atk,float moveSpd,float size,MonsterStrategy strategy):
+ hp(hp),atk(atk),moveSpd(moveSpd),size(size),strategy(strategy){
+}
+int MonsterData::GetHealth(){
+ return hp;
+}
+int MonsterData::GetAttack(){
+ return atk;
+}
+float MonsterData::GetMoveSpdMult(){
+ return moveSpd;
+}
+float MonsterData::GetSizeMult(){
+ return size;
+}
+MonsterStrategy MonsterData::GetAIStrategy(){
+ return strategy;
+}
+
+Monster::Monster(){}
+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()){
+}
+vf2d&Monster::GetPos(){
+ return pos;
+}
+int Monster::GetHealth(){
+ return hp;
+}
+int Monster::GetAttack(){
+ return atk;
+}
+float Monster::GetMoveSpdMult(){
+ return moveSpd;
+}
+float Monster::GetSizeMult(){
+ return size;
+}
\ No newline at end of file
diff --git a/Crawler/Monster.h b/Crawler/Monster.h
index 1979f41a..008f0d77 100644
--- a/Crawler/Monster.h
+++ b/Crawler/Monster.h
@@ -13,24 +13,13 @@ struct MonsterData{
float size;
MonsterStrategy strategy;
public:
- MonsterData(){};
- MonsterData(int hp,int atk,float moveSpd=1.0f,float size=1.0f,MonsterStrategy strategy=RUN_TOWARDS):
- hp(hp),atk(atk),moveSpd(moveSpd),size(size),strategy(strategy){}
- int GetHealth(){
- return hp;
- }
- int GetAttack(){
- return atk;
- }
- float GetMoveSpdMult(){
- return moveSpd;
- }
- float GetSizeMult(){
- return size;
- }
- MonsterStrategy GetAIStrategy(){
- return strategy;
- }
+ MonsterData();
+ MonsterData(int hp,int atk,float moveSpd=1.0f,float size=1.0f,MonsterStrategy strategy=RUN_TOWARDS);
+ int GetHealth();
+ int GetAttack();
+ float GetMoveSpdMult();
+ float GetSizeMult();
+ MonsterStrategy GetAIStrategy();
};
enum MonsterName{
@@ -41,5 +30,19 @@ enum MonsterName{
};
struct Monster{
-
+ private:
+ vf2d pos;
+ int hp,maxhp;
+ int atk;
+ float moveSpd;
+ float size;
+ MonsterStrategy strategy;
+ public:
+ Monster();
+ Monster(vf2d pos,MonsterData data);
+ vf2d&GetPos();
+ int GetHealth();
+ int GetAttack();
+ float GetMoveSpdMult();
+ float GetSizeMult();
};
\ No newline at end of file
diff --git a/Crawler/main.cpp b/Crawler/main.cpp
index 63407959..f6c1d137 100644
--- a/Crawler/main.cpp
+++ b/Crawler/main.cpp
@@ -16,18 +16,59 @@ enum AnimationState{
};
struct Player{
+ private:
+ int hp=100,maxhp=hp;
+ int atk=10;
vf2d pos;
- float moveSpd;
+ float moveSpd=1.0f;
+ float size=1.0f;
+ float attack_range=1.5f;
AnimationState animState=AnimationState::IDLE_S;
- private:
Animate2D::Animationanimation;
Animate2D::AnimationState internal_animState;
Key lastReleasedMovementKey;
public:
Player(){};
- Player(vf2d pos,float moveSpd):
- pos(pos),moveSpd(moveSpd){
+ Player(vf2d pos):
+ pos(pos){
};
+ void SetX(float x){
+ pos.x=x;
+ };
+ void SetY(float y){
+ pos.y=y;
+ }
+ void SetPos(vf2d pos){
+ this->pos=pos;
+ }
+ vf2d&GetPos(){
+ return pos;
+ }
+ float GetX(){
+ return pos.x;
+ }
+ float GetY(){
+ return pos.y;
+ }
+ int GetHealth(){
+ return hp;
+ }
+ int GetMaxHealth(){
+ return maxhp;
+ }
+ int GetAttack(){
+ return atk;
+ }
+ float GetMoveSpdMult(){
+ return moveSpd;
+ }
+ float GetSizeMult(){
+ return size;
+ }
+ float GetAttackRangeMult(){
+ return attack_range;
+ }
+
void Update(float fElapsedTime){
animation.UpdateState(internal_animState,fElapsedTime);
}
@@ -55,7 +96,7 @@ class Crawler : public olc::PixelGameEngine
const vi2d WORLD_SIZE={64,8};
Camera2D camera;
TileTransformedView view;
- Player player=Player{{},100};
+ Player player=Player{{}};
Renderable GFX_Pl_sheet;
public:
@@ -70,7 +111,7 @@ public:
//Initialize Camera.
camera=Camera2D{WINDOW_SIZE};
camera.SetMode(olc::utils::Camera2D::Mode::LazyFollow);
- camera.SetTarget(player.pos);
+ camera.SetTarget(player.GetPos());
camera.SetWorldBoundary({0,0},WORLD_SIZE*24);
camera.EnableWorldBoundary(true);
@@ -118,7 +159,7 @@ public:
player.AddAnimation(IDLE_W,pl_idle_w);
view=TileTransformedView{GetScreenSize(),{1,1}};
- player.pos={4*24,4*24};
+ player.SetPos({4*24,4*24});
player.UpdateAnimation(IDLE_S);
std::cout<0){
- player.pos.x-=fElapsedTime*player.moveSpd;
+ if(player.GetPos().x-12+fElapsedTime*100*player.GetMoveSpdMult()>0){
+ player.SetX(player.GetX()-fElapsedTime*100*player.GetMoveSpdMult());
} else {
- player.pos.x=12;
+ player.SetX(12);
}
if(setIdleAnimation){
player.UpdateAnimation(WALK_W);
@@ -158,10 +199,10 @@ public:
setIdleAnimation=false;
}
if(GetKey(UP).bHeld){
- if(player.pos.y-12+fElapsedTime*player.moveSpd>0){
- player.pos.y-=fElapsedTime*player.moveSpd;
+ if(player.GetPos().y-12+fElapsedTime*100*player.GetMoveSpdMult()>0){
+ player.SetY(player.GetY()-fElapsedTime*100*player.GetMoveSpdMult());
} else {
- player.pos.y=12;
+ player.SetY(12);
}
if(setIdleAnimation){
player.UpdateAnimation(WALK_N);
@@ -169,10 +210,10 @@ public:
setIdleAnimation=false;
}
if(GetKey(DOWN).bHeld){
- if(player.pos.y+12+fElapsedTime*player.moveSpdDecal(),player.GetFrame().GetSourceRect().pos,player.GetFrame().GetSourceRect().size);
+ view.DrawPartialDecal(player.GetPos()-vi2d{12,12},player.GetFrame().GetSourceImage()->Decal(),player.GetFrame().GetSourceRect().pos,player.GetFrame().GetSourceRect().size);
}
};