From a9781681bb8f3277ac310fbec8dc0353972dbc37 Mon Sep 17 00:00:00 2001 From: Clyne Sullivan Date: Thu, 1 Oct 2015 09:19:52 -0400 Subject: improved gravity --- src/entities.cpp | 29 +++++++++++++++++++++-------- 1 file changed, 21 insertions(+), 8 deletions(-) (limited to 'src/entities.cpp') diff --git a/src/entities.cpp b/src/entities.cpp index e7ba599..9d7ce95 100644 --- a/src/entities.cpp +++ b/src/entities.cpp @@ -1,4 +1,5 @@ #include +#include extern std::vectorentity; extern std::vectornpc; @@ -29,6 +30,10 @@ void Entity::draw(void){ //draws the entities glColor3ub(100,0,100); } glRectf(loc.x,loc.y,loc.x+width,loc.y+height); + if(near){ + ui::setFontSize(14); + ui::putText(loc.x,loc.y-ui::fontSize-HLINE/2,"%s",name); + } } void Entity::wander(int timeRun, vec2 *v){ //this makes the entites wander about @@ -45,24 +50,31 @@ void Entity::wander(int timeRun, vec2 *v){ //this makes the entites wander about void Entity::getName(){ rewind(names); - char buf; - char* bufs = (char*)malloc(16); - int max = 0; - int tempNum = rand()%105; + char buf,*bufs = (char *)malloc(16); + int tempNum,max = 0; + for(;!feof(names);max++){ + fgets(bufs,16,(FILE*)names); + } + tempNum = rand()%max; + rewind(names); for(int i=0;i