Added Spawners

pull/28/head
sigonasr2 1 year ago
parent 01d1e44839
commit a94528fe3e
  1. 57
      Crawler/Crawler.cpp
  2. 2
      Crawler/Crawler.h
  3. 2
      Crawler/Monster.cpp

@ -52,23 +52,46 @@ bool Crawler::OnUserCreate(){
player.UpdateAnimation(AnimationState::IDLE_S); player.UpdateAnimation(AnimationState::IDLE_S);
SPAWNER_LIST.push_back(MonsterSpawner({336,96},4*24,{{{MonsterName::SLIME_BLUE,{-32,-40}},{MonsterName::SLIME_GREEN,{64,20}}}})); SPAWNER_LIST.push_back(MonsterSpawner({360*1,96},4*24,{{
std::vector<std::pair<MonsterName,vf2d>>circleSpawn; {MonsterName::SLIME_GREEN,{(rand()%20/2.f-5)*24,(rand()%20/2.f-5)*24}}
for(int i=0;i<12;i++){ ,{MonsterName::SLIME_GREEN,{(rand()%20/2.f-5)*24,(rand()%20/2.f-5)*24}}
float angle=(2*PI)*(i/12.f); }}));
switch(i%3){ SPAWNER_LIST.push_back(MonsterSpawner({360*2,96},4*24,{{
case 0:{ {MonsterName::SLIME_GREEN,{(rand()%20/2.f-5)*24,(rand()%20/2.f-5)*24}}
circleSpawn.push_back({MonsterName::SLIME_BLUE,{cos(angle)*32,sin(angle)*32}}); ,{MonsterName::SLIME_GREEN,{(rand()%20/2.f-5)*24,(rand()%20/2.f-5)*24}}
}break; ,{MonsterName::SLIME_RED,{(rand()%20/2.f-5)*24,(rand()%20/2.f-5)*24}}
case 1:{ }}));
circleSpawn.push_back({MonsterName::SLIME_GREEN,{cos(angle)*32,sin(angle)*32}}); SPAWNER_LIST.push_back(MonsterSpawner({360*3,96},4*24,{{
}break; {MonsterName::SLIME_BLUE,{(rand()%20/2.f-5)*24,(rand()%20/2.f-5)*24}}
case 2:{ ,{MonsterName::SLIME_BLUE,{(rand()%20/2.f-5)*24,(rand()%20/2.f-5)*24}}
circleSpawn.push_back({MonsterName::SLIME_RED,{cos(angle)*32,sin(angle)*32}}); }}));
}break; SPAWNER_LIST.push_back(MonsterSpawner({360*4,96},4*24,{{
} {MonsterName::SLIME_BLUE,{(rand()%20/2.f-5)*24,(rand()%20/2.f-5)*24}}
} ,{MonsterName::SLIME_BLUE,{(rand()%20/2.f-5)*24,(rand()%20/2.f-5)*24}}
SPAWNER_LIST.push_back(MonsterSpawner({540,96},4*24,circleSpawn)); ,{MonsterName::SLIME_GREEN,{(rand()%20/2.f-5)*24,(rand()%20/2.f-5)*24}}
,{MonsterName::SLIME_GREEN,{(rand()%20/2.f-5)*24,(rand()%20/2.f-5)*24}}
,{MonsterName::SLIME_GREEN,{(rand()%20/2.f-5)*24,(rand()%20/2.f-5)*24}}
}}));
SPAWNER_LIST.push_back(MonsterSpawner({360*5,96},4*24,{{
{MonsterName::SLIME_BLUE,{(rand()%20/2.f-5)*24,(rand()%20/2.f-5)*24}}
,{MonsterName::SLIME_BLUE,{(rand()%20/2.f-5)*24,(rand()%20/2.f-5)*24}}
,{MonsterName::SLIME_RED,{(rand()%20/2.f-5)*24,(rand()%20/2.f-5)*24}}
,{MonsterName::SLIME_RED,{(rand()%20/2.f-5)*24,(rand()%20/2.f-5)*24}}
}}));
SPAWNER_LIST.push_back(MonsterSpawner({360*6,96},4*24,{{
{MonsterName::SLIME_RED,{(rand()%20/2.f-5)*24,(rand()%20/2.f-5)*24}}
,{MonsterName::SLIME_RED,{(rand()%20/2.f-5)*24,(rand()%20/2.f-5)*24}}
,{MonsterName::SLIME_RED,{(rand()%20/2.f-5)*24,(rand()%20/2.f-5)*24}}
,{MonsterName::SLIME_RED,{(rand()%20/2.f-5)*24,(rand()%20/2.f-5)*24}}
,{MonsterName::SLIME_RED,{(rand()%20/2.f-5)*24,(rand()%20/2.f-5)*24}}
}}));
SPAWNER_LIST.push_back(MonsterSpawner({360*7,96},4*24,{{
{MonsterName::SLIME_BLUE,{(rand()%20/2.f-5)*24,(rand()%20/2.f-5)*24}}
,{MonsterName::SLIME_BLUE,{(rand()%20/2.f-5)*24,(rand()%20/2.f-5)*24}}
,{MonsterName::SLIME_BLUE,{(rand()%20/2.f-5)*24,(rand()%20/2.f-5)*24}}
,{MonsterName::SLIME_BLUE,{(rand()%20/2.f-5)*24,(rand()%20/2.f-5)*24}}
,{MonsterName::SLIME_BLUE,{(rand()%20/2.f-5)*24,(rand()%20/2.f-5)*24}}
}}));
return true; return true;
} }

@ -20,7 +20,7 @@ public:
Crawler(); Crawler();
public: public:
const vi2d WORLD_SIZE={64,8}; const vi2d WORLD_SIZE={120,8};
TileTransformedView view; TileTransformedView view;
bool OnUserCreate() override; bool OnUserCreate() override;
bool OnUserUpdate(float fElapsedTime) override; bool OnUserUpdate(float fElapsedTime) override;

@ -178,7 +178,6 @@ bool Monster::Update(float fElapsedTime){
if(pos.x-12*size<=1||pos.x+12*size>=game->WORLD_SIZE.x*24-1){ if(pos.x-12*size<=1||pos.x+12*size>=game->WORLD_SIZE.x*24-1){
geom2d::line moveTowardsLine=geom2d::line(pos,target); geom2d::line moveTowardsLine=geom2d::line(pos,target);
if(abs(moveTowardsLine.vector().norm().y)>=0.5){ if(abs(moveTowardsLine.vector().norm().y)>=0.5){
std::cout<<moveTowardsLine.vector().norm().x<<std::endl;
state=MOVE_AWAY; state=MOVE_AWAY;
} else { } else {
state=NORMAL; state=NORMAL;
@ -187,7 +186,6 @@ bool Monster::Update(float fElapsedTime){
if(pos.y-12*size<=1||pos.y+12*size>=game->WORLD_SIZE.y*24-1){ if(pos.y-12*size<=1||pos.y+12*size>=game->WORLD_SIZE.y*24-1){
geom2d::line moveTowardsLine=geom2d::line(pos,target); geom2d::line moveTowardsLine=geom2d::line(pos,target);
if(abs(moveTowardsLine.vector().norm().x)>=0.5){ if(abs(moveTowardsLine.vector().norm().x)>=0.5){
std::cout<<moveTowardsLine.vector().norm().x<<std::endl;
state=MOVE_AWAY; state=MOVE_AWAY;
} else { } else {
state=NORMAL; state=NORMAL;

Loading…
Cancel
Save