Changeset 2101 in orxonox.OLD for orxonox/branches/chris/src/world.cc
- Timestamp:
- Jul 10, 2004, 2:00:04 PM (21 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
orxonox/branches/chris/src/world.cc
r2096 r2101 15 15 */ 16 16 17 #include <iostream>18 #include <stdlib.h>19 #include <cmath>20 21 17 #include "world.h" 22 18 #include "world_entity.h" 19 #include "collision.h" 20 #include "track.h" 21 #include "player.h" 22 #include "command_node.h" 23 #include "camera.h" 23 24 24 25 using namespace std; … … 32 33 World::World () 33 34 { 34 entities = new List<WorldEntit ites>();35 entities = new List<WorldEntity>(); 35 36 } 36 37 … … 42 43 } 43 44 44 template<class T> T* World::spawn<T>(Location* loc = NULL, WorldEntity* owner = NULL) 45 { 46 Location zeroloc; 47 T* entity = new T(); 48 entities->add ((WorldEntity*)entity, LIST_ADD_NEXT); 49 if( loc == NULL) 50 { 51 zeroloc.dist = 0; 52 zeroloc.part = 0; 53 zeroloc.pos = Vector(); 54 zeroloc.rot = Rotation(); 55 loc = &zeroloc; 56 } 57 entity->init (loc, owner); 58 if (entity->bFree) 59 { 60 track[loc->part].map_coords( loc, entity->get_placement()) 61 } 62 entity->post_spawn (); 63 return entity; 64 } 65 66 template<class T> T* World::spawn<T>(Placement* plc, WorldEntity* owner = NULL) 67 { 68 T* entity = new T(); 69 entities->add ((WorldEntity*)entity, LIST_ADD_NEXT); 70 entity->init (plc, owner); 71 if (!entity->bFree) 72 { 73 printf("Can't spawn unfree entity with placement\n"); 74 entities->remove( (WorldEntity*)entity, LIST_FIND_FW); 75 return NULL; 76 } 77 entity->post_spawn (); 78 return entity; 79 } 80 81 World::collide () 45 void World::collide () 82 46 { 83 47 List<WorldEntity> *a, *b; … … 97 61 if( bobj->bCollide && bobj->collisioncluster != NULL) 98 62 { 99 Uint32ahitflg, bhitflg;100 if check_collision ( aobj->place, aobj->collisioncluster, &ahitflg, bobj->place, bobj->collisioncluster, &bhitflg);63 unsigned long ahitflg, bhitflg; 64 if( check_collision ( &aobj->place, aobj->collisioncluster, &ahitflg, &bobj->place, bobj->collisioncluster, &bhitflg)); 101 65 { 102 66 aobj->collide (bobj, ahitflg, bhitflg); … … 141 105 entity = l->get_object(); 142 106 143 if( entity != bFree)107 if( !entity->isFree()) 144 108 { 145 109 loc = entity->get_location(); … … 156 120 while( track[t].map_coords( loc, plc)) 157 121 { 158 track[t] ->post_leave (entity);122 track[t].post_leave (entity); 159 123 if( loc->part >= tracklen) 160 124 { … … 163 127 break; 164 128 } 165 track[loc->part] ->post_enter (entity);129 track[loc->part].post_enter (entity); 166 130 } 167 131 } … … 194 158 } 195 159 196 for( int i = 0; i < tracklen ) track[i].tick (seconds);160 for( int i = 0; i < tracklen; i++) track[i].tick (seconds); 197 161 } 198 162 … … 223 187 224 188 // create a player 225 World entity* myPlayer =spawn<Player>();189 WorldEntity* myPlayer = (WorldEntity*) spawn<Player>(); 226 190 227 191 // bind input
Note: See TracChangeset
for help on using the changeset viewer.