aboutsummaryrefslogtreecommitdiffstats
path: root/src/world.cpp
diff options
context:
space:
mode:
authorClyne Sullivan <tullivan99@gmail.com>2015-09-25 16:15:35 -0400
committerClyne Sullivan <tullivan99@gmail.com>2015-09-25 16:15:35 -0400
commit419d06f319c631c9c4860aababbfc49ee26aeefc (patch)
treeeb05ae42da01622bcd8e36ca4ef7aec197a0ef58 /src/world.cpp
parent144d3d5f39cb2cc9088fade10c6aefb9f79c9665 (diff)
updates ;)
Diffstat (limited to 'src/world.cpp')
-rw-r--r--src/world.cpp27
1 files changed, 9 insertions, 18 deletions
diff --git a/src/world.cpp b/src/world.cpp
index b279f2f..fde75bb 100644
--- a/src/world.cpp
+++ b/src/world.cpp
@@ -50,13 +50,10 @@ World::World(unsigned int width){ // Generates the world and sets all variables
x_start=0-getWidth(this)/2+GEN_INC/2*HLINE; // Calculate x_start (explained in world.h)
behind=infront=NULL; // Set pointers to other worlds to NULL
toLeft=toRight=NULL; // to avoid accidental calls to goWorld... functions
- //peeps=(Entity **)calloc(WORLD_ENTITY_MAX+1,sizeof(Entity *)); // peeps[0] is reserved for the player when detect() is called
- //peepCount=0;
}
World::~World(void){
free(line); // Free (de-allocate) the array 'line'
- //free(peeps); // same for the entity array
}
void World::draw(vec2 *vec){
@@ -106,11 +103,10 @@ LOOP2: // Draw each world
}else{ // Otherwise reset static values and return
yoff=DRAW_Y_OFFSET;
shade=0;
- /*if(peepCount){
- for(i=1;i<peepCount;i++){
- peeps[i]->draw();
- }
- }*/
+ for(i=0;i<entity.size()+1;i++){
+ if(entity[i]->inWorld==this)
+ entity[i]->draw();
+ }
}
}
@@ -133,11 +129,14 @@ void World::singleDetect(Entity *e){
}
}
}
+
+extern unsigned int newEntityCount;
void World::detect(Player *p){
unsigned int i;
singleDetect(p);
- for(i=0;i<=entity.size();i++){
- singleDetect(entity[i]);
+ for(i=0;i<entity.size()+1;i++){
+ if(entity[i]->inWorld==this)
+ singleDetect(entity[i]);
}
}
@@ -185,11 +184,3 @@ World *World::goWorldFront(Player *p){
}
return this;
}
-
-/*void World::addEntity(Entity *e){
- if(peepCount!=WORLD_ENTITY_MAX){
- peeps[1+peepCount++]=e; // See peeps's allocation in World() for explanation of the 1+...
- }else{
- std::cout<<"Warning: can't add any more entities"<<std::endl;
- }
-}*/