9 Entity *Entity::list[MAX_ENTITIES];
13 if(Entity::count < MAX_ENTITIES){
14 Entity::list[Entity::count] = this;
18 for(int i = 0; i < MAX_ENTITIES; i++)
19 if(Entity::list[i] == NULL)
20 Entity::list[i] = this;
22 void Entity::physics_all(){
23 for(int i = 0; i < count; i++)
29 void Entity::spawn(double sx, double sy, bool gravity){
38 Game::log((string)"Spawning entity '" + name + "' at (" + to_string(x) + ", " + to_string(y) + ")", INFO);
40 bool Entity::physics_check_x(){
43 if(x + width > MAPWIDTH)
45 return physics_check_both();
47 bool Entity::physics_check_y(){
50 if(y + height > MAPHEIGHT)
52 return physics_check_both();
54 bool Entity::physics_check_both(){
55 for(int ix = floor(x); ix <= ceil(x + width - 0.01) - 1; ix++)
56 for(int iy = floor(y); iy <= ceil(y + height - 0.01) - 1; iy++)
57 if(Game::map->getNode(ix, iy)->stable)
61 void Entity::physics_reset_x(){
65 x = (double)(round(x * 10)) / 10;
67 void Entity::physics_reset_y(){
71 y = (double)(round(y * 10)) / 10;
73 void Entity::physics(){
75 double dtx = Entity::t - tx0;
77 x = ax * dtx * dtx / 2 + vx * dtx + x0;
80 if(!physics_check_x())
86 double dty = Entity::t - ty0;
88 y = ay * dty * dty / 2 + vy * dty + y0;
91 if(!physics_check_y())