From 135d46497cae4fbfcc500b3bd22b6c8d97d53084 Mon Sep 17 00:00:00 2001 From: Clyne Sullivan Date: Tue, 27 Oct 2015 08:48:01 -0400 Subject: bird AI + xcfs --- src/entities.cpp | 6 +++++- src/gameplay.cpp | 4 ++-- 2 files changed, 7 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/entities.cpp b/src/entities.cpp index da096bc..0479d5e 100644 --- a/src/entities.cpp +++ b/src/entities.cpp @@ -332,6 +332,7 @@ unsigned int Structures::spawn(_TYPE t, float x, float y){ //spawns a structure void Mob::wander(int timeRun){ static int direction; //variable to decide what direction the entity moves + static unsigned int hey=0,hi=0; switch(subtype){ case MS_RABBIT: if(!ticksToUse){ @@ -350,7 +351,10 @@ void Mob::wander(int timeRun){ ticksToUse--; //removes one off of the entities timer break; case MS_BIRD: - if(loc.y<=init_y-.2)vel.y+=.005*deltaTime; // TODO handle direction + if(loc.y<=init_y-.2)vel.y=.02*deltaTime; // TODO handle direction + vel.x=.02*deltaTime; + if(++hey==200){hey=0;hi^=1;} + if(hi)vel.x*=-1; break; default: break; diff --git a/src/gameplay.cpp b/src/gameplay.cpp index 1de542d..d1cc69d 100644 --- a/src/gameplay.cpp +++ b/src/gameplay.cpp @@ -84,9 +84,9 @@ void initEverything(void){ entity.push_back(mob.back()); mob.back()->spawn(200,100); - mob.push_back(new Mob(2)); + mob.push_back(new Mob(MS_BIRD)); entity.push_back(mob.back()); - mob.back()->spawn(200,100); + mob.back()->spawn(-500,500); /* * Link all the entities that were just created to the initial world, and setup a test AI function. -- cgit v1.2.3