From a94528fe3e341241eaeb5e35c39ccc4edb1aa9ad Mon Sep 17 00:00:00 2001 From: sigonasr2 Date: Fri, 16 Jun 2023 01:51:26 -0500 Subject: [PATCH] Added Spawners --- Crawler/Crawler.cpp | 57 +++++++++++++++++++++++++++++++-------------- Crawler/Crawler.h | 2 +- Crawler/Monster.cpp | 2 -- 3 files changed, 41 insertions(+), 20 deletions(-) diff --git a/Crawler/Crawler.cpp b/Crawler/Crawler.cpp index 44a7ef31..f23b59d3 100644 --- a/Crawler/Crawler.cpp +++ b/Crawler/Crawler.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>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; } diff --git a/Crawler/Crawler.h b/Crawler/Crawler.h index 5d9ef2d6..45a0337c 100644 --- a/Crawler/Crawler.h +++ b/Crawler/Crawler.h @@ -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; diff --git a/Crawler/Monster.cpp b/Crawler/Monster.cpp index 5e884b6a..bb07b0d5 100644 --- a/Crawler/Monster.cpp +++ b/Crawler/Monster.cpp @@ -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<=game->WORLD_SIZE.y*24-1){ geom2d::line moveTowardsLine=geom2d::line(pos,target); if(abs(moveTowardsLine.vector().norm().x)>=0.5){ - std::cout<