Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 2192 in orxonox.OLD for orxonox/branches/chris


Ignore:
Timestamp:
Jul 17, 2004, 7:40:40 PM (20 years ago)
Author:
chris
Message:

orxonox/branches/chris: it's now possible to add derivations of Track to the World; hit function declaration finalized; implemented splash damage function (World::explosion())

Location:
orxonox/branches/chris/src
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • orxonox/branches/chris/src/message_structures.h

    r2141 r2192  
    2626} Command;
    2727
     28enum DAMAGETYPE{ DMG_ENERY};
     29
     30//! structure that contains a damage message
     31typedef struct
     32{
     33        DAMAGETYPE type;        //!< The type of the damage delivered
     34        float dmg; //!< The amount of damage delivered
     35} Damage;
     36
    2837#endif
  • orxonox/branches/chris/src/player.cc

    r2115 r2192  
    4747}
    4848
    49 void Player::hit (WorldEntity* weapon, Vector loc)
     49void Player::hit (Damage* dmg, WorldEntity* instigator, Uint32 hitflags)
    5050{
    5151}
  • orxonox/branches/chris/src/player.h

    r2141 r2192  
    2020        virtual void post_spawn ();
    2121  virtual void tick (float time);
    22   virtual void hit (WorldEntity* weapon, Vector loc);
     22  virtual void hit (Damage* dmg, WorldEntity* instigator, Uint32 hitflags);
    2323  virtual void destroy ();
    2424  virtual void collide (WorldEntity* other,  Uint32 ownhitflags, Uint32 otherhitflags);
  • orxonox/branches/chris/src/world.cc

    r2141 r2192  
    7070                                {
    7171                                        unsigned long ahitflg, bhitflg;
    72                                         if( check_collision ( &aobj->place, aobj->collisioncluster, &ahitflg, &bobj->place, bobj->collisioncluster, &bhitflg));
     72                                        if( check_collision ( &aobj->place, aobj->collisioncluster, &ahitflg, &bobj->place, bobj->collisioncluster, &bhitflg))
    7373                                        {
    7474                                                aobj->collide (bobj, ahitflg, bhitflg);
     
    183183                        else
    184184                        {
    185                                 while( track[t].map_coords( loc, plc))
     185                                while( track[t]->map_coords( loc, plc))
    186186                                {
    187                                         track[t].post_leave (entity);
     187                                        track[t]->post_leave (entity);
    188188                                        if( loc->part >= tracklen)
    189189                                        {
     
    192192                                                break;
    193193                                        }
    194                                         track[loc->part].post_enter (entity);
     194                                        track[loc->part]->post_enter (entity);
    195195                                }
    196196                        }
     
    227227        }
    228228       
    229         for( int i = 0; i < tracklen; i++) track[i].tick (seconds);
     229        for( int i = 0; i < tracklen; i++) track[i]->tick (seconds);
    230230}
    231231
     
    255255        // create the tracks
    256256        tracklen = 6;
    257         track = new Track[6];
     257        track = new Track*[6];
    258258        for( int i = 0; i < tracklen; i++)
    259259        {
    260                 track[i] = Track( i, (i+1)%tracklen, &pathnodes[i], &pathnodes[(i+1)%tracklen]);
     260                track[i] = new Track( i, (i+1)%tracklen, &pathnodes[i], &pathnodes[(i+1)%tracklen]);
    261261        }
    262262       
     
    277277void World::calc_camera_pos (Location* loc, Placement* plc)
    278278{
    279   track[loc->part].map_camera (loc, plc);
    280 }
     279  track[loc->part]->map_camera (loc, plc);
     280}
     281
     282void World::explosion (Location* loc, Damage* dmg, float r, WorldEntity* instigator)
     283{
     284        Placement mapped;
     285       
     286        track[loc->part]->map_coords (loc, &mapped);
     287        CollisionCluster boom( r, Vector(0,0,0));
     288       
     289        unsigned long boomflags, hflags;
     290        List<WorldEntity> *a;
     291        WorldEntity *aobj;
     292       
     293        a = entities->get_next();
     294       
     295        while( a != NULL)
     296        {
     297                aobj = a->get_object();
     298                if( aobj->bCollide && aobj->collisioncluster != NULL)
     299                {
     300                        hflags = 0;
     301                        if( check_collision ( &aobj->place, aobj->collisioncluster, &hflags, &mapped, &boom, &boomflags))
     302                        {
     303                                aobj->hit (dmg, instigator, hflags);
     304                        }
     305                }
     306                a = a->get_next();
     307        }
     308}
     309
     310void World::explosion (Placement* plc, Damage* dmg, float r, WorldEntity* instigator)
     311{
     312        CollisionCluster boom( r, Vector(0,0,0));
     313       
     314        unsigned long boomflags, hflags;
     315        List<WorldEntity> *a;
     316        WorldEntity *aobj;
     317       
     318        a = entities->get_next();
     319       
     320        while( a != NULL)
     321        {
     322                aobj = a->get_object();
     323                if( aobj->bCollide && aobj->collisioncluster != NULL)
     324                {
     325                        hflags = 0;
     326                        if( check_collision ( &aobj->place, aobj->collisioncluster, &hflags, plc, &boom, &boomflags))
     327                        {
     328                                aobj->hit (dmg, instigator, hflags);
     329                        }
     330                }
     331                a = a->get_next();
     332        }
     333}
  • orxonox/branches/chris/src/world.h

    r2141 r2192  
    3030        void calc_camera_pos (Location* loc, Placement* plc);
    3131       
     32        void explosion (Location* loc, Damage* dmg, float r, WorldEntity* instigator);
     33        void explosion (Placement* plc, Damage* dmg, float r, WorldEntity* instigator);
     34       
    3235        void unload ();
    3336       
     
    3942       
    4043                // base level data
    41         Track* track;
     44        Track** track;
    4245        Uint32 tracklen;
    4346        Vector* pathnodes;
     
    7275        if (entity->bFree)
    7376        {
    74                 track[loc->part].map_coords( loc, entity->get_placement());
     77                track[loc->part]->map_coords( loc, entity->get_placement());
    7578        }
    7679        entity->post_spawn ();
  • orxonox/branches/chris/src/world_entity.cc

    r2141 r2192  
    9494        Handle all stuff that should update with time inside this method (movement, animation, etc.)
    9595*/
    96 void WorldEntity::tick(float time)
    97 {
    98 }
     96void WorldEntity::tick(float time) {}
    9997
    10098/**
     
    103101   This is a central function of an entity: call it to let the entity painted to the screen. Just override this function with whatever you want to be drawn.
    104102*/
    105 void WorldEntity::draw()
    106 {
    107 }
     103void WorldEntity::draw() {}
    108104
    109105/**
     
    118114
    119115/**
    120    \brief this function is called, when the ship is hit by a waepon
    121    \param weapon: the laser/rocket/shoot that hits.
    122    \param loc: place where it is hit
    123 
    124    calculate the damage depending
     116   \brief this function is called when the entity takes damage
     117   \param dmg: a pointer to a structure containing information about the damage
     118   \param instigator: the world entity that dealt the damage
     119   \param hitflags: an integer full of flags signifying the places the enitiy had been hit
     120   
     121   You're free to do what you want with the damage you register here. This function is called from World::explosion() when
     122   dealing splash damage, but can be called from virtually anywhere you want.
    125123*/
    126 void WorldEntity::hit(WorldEntity* weapon, Vector loc) {}
     124void WorldEntity::hit (Damage* dmg, WorldEntity* instigator, Uint32 hitflags) {}
    127125
    128126/**
     
    158156        DO NOT place such code in the constructor, those variables are set AFTER the entity is constucted.
    159157*/
    160 void WorldEntity::post_spawn ()
    161 {
    162 }
     158void WorldEntity::post_spawn () {}
    163159
    164160/**
     
    169165        to send commands from one WorldEntity to another.
    170166*/
    171 void WorldEntity::command (Command* cmd)
    172 {
    173 }
     167void WorldEntity::command (Command* cmd) {}
    174168
    175169/**
     
    180174        to look at the location you return with this.
    181175*/
    182 void WorldEntity::get_lookat (Location* locbuf)
    183 {
    184 }
     176void WorldEntity::get_lookat (Location* locbuf) {}
    185177
    186178/**
     
    190182        place that is not in the world anymore. In both cases you might have to take extreme measures (a.k.a. call destroy).
    191183*/
    192 void WorldEntity::left_world ()
    193 {
    194 }
     184void WorldEntity::left_world () {}
  • orxonox/branches/chris/src/world_entity.h

    r2141 r2192  
    3131        virtual void post_spawn ();
    3232  virtual void tick (float time);
    33   virtual void hit (WorldEntity* weapon, Vector loc);
     33  virtual void hit (Damage* dmg, WorldEntity* instigator, Uint32 hitflags);
    3434  virtual void destroy ();
    3535  virtual void collide (WorldEntity* other,  Uint32 ownhitflags, Uint32 otherhitflags);
Note: See TracChangeset for help on using the changeset viewer.