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);
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));
SPAWNER_LIST.push_back(MonsterSpawner({360*1,96},4*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*2,96},4*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}}
,{MonsterName::SLIME_RED,{(rand()%20/2.f-5)*24,(rand()%20/2.f-5)*24}}
}}));
SPAWNER_LIST.push_back(MonsterSpawner({360*3,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({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}}
,{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;
}

@ -20,7 +20,7 @@ public:
Crawler();
public:
const vi2d WORLD_SIZE={64,8};
const vi2d WORLD_SIZE={120,8};
TileTransformedView view;
bool OnUserCreate() 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){
geom2d::line moveTowardsLine=geom2d::line(pos,target);
if(abs(moveTowardsLine.vector().norm().y)>=0.5){
std::cout<<moveTowardsLine.vector().norm().x<<std::endl;
state=MOVE_AWAY;
} else {
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){
geom2d::line moveTowardsLine=geom2d::line(pos,target);
if(abs(moveTowardsLine.vector().norm().x)>=0.5){
std::cout<<moveTowardsLine.vector().norm().x<<std::endl;
state=MOVE_AWAY;
} else {
state=NORMAL;

Loading…
Cancel
Save