Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 2101 in orxonox.OLD for orxonox/branches/chris/src/world.cc


Ignore:
Timestamp:
Jul 10, 2004, 2:00:04 PM (21 years ago)
Author:
chris
Message:

orxonox/branches/chris: Finished the "GETITTOCOMPILE" project… compiling should work now, but linking is a different story

File:
1 edited

Legend:

Unmodified
Added
Removed
  • orxonox/branches/chris/src/world.cc

    r2096 r2101  
    1515*/
    1616
    17 #include <iostream>
    18 #include <stdlib.h>
    19 #include <cmath>
    20 
    2117#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"
    2324
    2425using namespace std;
     
    3233World::World ()
    3334{
    34         entities = new List<WorldEntitites>();
     35        entities = new List<WorldEntity>();
    3536}
    3637
     
    4243}
    4344
    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 ()
     45void World::collide ()
    8246{
    8347        List<WorldEntity> *a, *b;
     
    9761                                if( bobj->bCollide && bobj->collisioncluster != NULL)
    9862                                {
    99                                         Uint32 ahitflg, 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));
    10165                                        {
    10266                                                aobj->collide (bobj, ahitflg, bhitflg);
     
    141105                entity = l->get_object();
    142106               
    143                 if( entity != bFree)
     107                if( !entity->isFree())
    144108                {
    145109                        loc = entity->get_location();
     
    156120                                while( track[t].map_coords( loc, plc))
    157121                                {
    158                                         track[t]->post_leave (entity);
     122                                        track[t].post_leave (entity);
    159123                                        if( loc->part >= tracklen)
    160124                                        {
     
    163127                                                break;
    164128                                        }
    165                                         track[loc->part]->post_enter (entity);
     129                                        track[loc->part].post_enter (entity);
    166130                                }
    167131                        }
     
    194158        }
    195159       
    196         for( int i = 0; i < tracklen) track[i].tick (seconds);
     160        for( int i = 0; i < tracklen; i++) track[i].tick (seconds);
    197161}
    198162
     
    223187       
    224188        // create a player
    225         Worldentity* myPlayer = spawn<Player>();
     189        WorldEntity* myPlayer = (WorldEntity*) spawn<Player>();
    226190       
    227191        // bind input
Note: See TracChangeset for help on using the changeset viewer.