Auto attacking now based on click position. Damage numbers will stop when they reach a certain height. Monsters not counted in range if dead.

This commit is contained in:
2023-06-15 04:53:57 -05:00
parent 3aebde6287
commit 7c542740cc
6 changed files with 45 additions and 13 deletions
+26 -1
View File
@@ -2,6 +2,7 @@
#include "Crawler.h"
#include "olcUTIL_Camera2D.h"
#include "DamageNumber.h"
#include "DEFINES.h"
//192x192
const vi2d WINDOW_SIZE={24*8,24*8};
@@ -47,7 +48,25 @@ bool Crawler::OnUserCreate(){
player.SetPos({4*24,4*24});
player.UpdateAnimation(AnimationState::IDLE_S);
SPAWNER_LIST.push_back(MonsterSpawner({336,96},4*24,{{{MonsterName::SLIME_BLUE,{-32,-40}},{MonsterName::SLIME_GREEN,{64,20}}}}));
std::vector<std::pair<MonsterName,vf2d>>circleSpawn;
for(int i=0;i<12;i++){
float angle=(2*PI)*(i/12.f);
switch(i%3){
case 0:{
circleSpawn.push_back({MonsterName::SLIME_BLUE,{cos(angle)*32,sin(angle)*32}});
}break;
case 1:{
circleSpawn.push_back({MonsterName::SLIME_GREEN,{cos(angle)*32,sin(angle)*32}});
}break;
case 2:{
circleSpawn.push_back({MonsterName::SLIME_RED,{cos(angle)*32,sin(angle)*32}});
}break;
}
}
SPAWNER_LIST.push_back(MonsterSpawner({540,96},4*24,circleSpawn));
return true;
}
@@ -321,7 +340,9 @@ void Crawler::RenderWorld(float fElapsedTime){
break;
}
} else {
dn.pos.y-=20*fElapsedTime;
if(dn.lifeTime<DamageNumber::MOVE_UP_TIME){
dn.pos.y-=20*fElapsedTime;
}
std::string text=std::to_string(dn.damage);
view.DrawStringPropDecal(dn.pos-GetTextSizeProp(text)/2,text,DARK_RED);
}
@@ -343,6 +364,10 @@ void Crawler::AddEffect(Effect foreground,Effect background){
backgroundEffects.push_back(background);
}
vf2d Crawler::GetWorldMousePos(){
return GetMousePos()+view.GetWorldOffset();
}
int main()
{
Crawler demo;