Logo Search packages:      
Sourcecode: adonthell version File versions  Download package

void mapcharacter::update_move (  )  [private]

Updates the movment of the mapcharacter.

Definition at line 988 of file mapcharacter.cc.

References map_event::c, can_go_east(), can_go_north(), can_go_south(), can_go_west(), currentmove(), map_event::dir, leave(), MAPSQUARE_SIZE, occupy(), offx(), offy(), posx(), posy(), event_handler::raise_event(), set_offset(), set_pos(), stand_east(), stand_north(), stand_south(), stand_west(), submap(), map_event::submap, WALK_EAST, WALK_NORTH, WALK_SOUTH, WALK_WEST, map_event::x, and map_event::y.

Referenced by update().

{
    if (refmap)
        switch (currentmove ())
        {
            case WALK_NORTH:
                if (!offy ())
                {
                    if (!can_go_north ())
                    {
                        stand_north ();
                        break;
                    }
                    leave_event evt;
                    
                    evt.submap = submap ();
                    evt.x = posx ();
                    evt.y = posy ();
                    evt.c = this;
                    evt.dir = WALK_NORTH; 
                    event_handler::raise_event (&evt);
                    
                    occupy (submap (), posx (), posy () - 1);
                    set_offset (offx (), offy () - 1);
                }
                
                set_offset (offx (), offy () - 1);

                if (offy () == -MAPSQUARE_SIZE)
                {
                    leave (submap (), posx (), posy ());
                    leave (submap (), posx (), posy () - 1);
                    set_pos (submap (), posx (), posy () - 1);
                    set_offset (offx (), 0); 
                    stand_north ();
                    
                    enter_event evt;

                    evt.submap = submap ();
                    evt.x = posx ();
                    evt.y = posy ();
                    evt.c = this;
                    evt.dir = WALK_NORTH; 
                    event_handler::raise_event (&evt);
                }
                break;
            case WALK_SOUTH:
                if (!offy ())
                {
                    if (!can_go_south ())
                    {
                        stand_south ();
                        break;
                    }
                    leave_event evt;

                    evt.submap = submap ();
                    evt.x = posx ();
                    evt.y = posy ();
                    evt.c = this;
                    evt.dir = WALK_SOUTH; 
                    event_handler::raise_event (&evt);

                    leave (submap (), posx (), posy ());
                    occupy (submap (), posx (), posy ());
                    set_pos (submap (), posx (), posy () + 1);
                    set_offset (0, -(MAPSQUARE_SIZE - 1));
                 }
                else
                {
                    set_offset (offx (), offy () + 1);

                    if (!offy ())
                    {
                        leave (submap (), posx (), posy () - 1);
                        stand_south ();

                        enter_event evt; 
                        evt.submap = submap ();
                        evt.x = posx ();
                        evt.y = posy ();
                        evt.c = this;
                        evt.dir = WALK_SOUTH; 
                        event_handler::raise_event (&evt);
                    }
                }
                break;
            case WALK_WEST:
                if (!offx ())
                {
                    if (!can_go_west ())
                    {
                        stand_west ();
                        break;
                    }
                    leave_event evt;

                    evt.submap = submap ();
                    evt.x = posx ();
                    evt.y = posy ();
                    evt.c = this;
                    evt.dir = WALK_WEST; 
                    event_handler::raise_event (&evt);

                    occupy (submap (), posx () - 1, posy ()); 
                }
                set_offset (offx () -1, offy ());  
                if (offx () == -MAPSQUARE_SIZE)
                {
                    leave (submap (), posx (), posy ());
                    leave (submap (), posx () - 1, posy ());
                    set_pos (submap (), posx () - 1, posy ());
                    set_offset (0, offy ());  
                    stand_west ();
                    
                    enter_event evt; 
                    evt.submap = submap ();
                    evt.x = posx ();
                    evt.y = posy ();
                    evt.c = this;
                    evt.dir = WALK_WEST; 
                    event_handler::raise_event (&evt);
                }
                break;
            case WALK_EAST:
                if (!offx ())
                {
                    if (!can_go_east ())
                    {
                        stand_east ();
                        break;
                    }
                    leave_event evt;
                    
                    evt.submap = submap ();
                    evt.x = posx ();
                    evt.y = posy ();
                    evt.c = this;
                    evt.dir = WALK_EAST; 
                    event_handler::raise_event (&evt);

                    leave (submap (), posx (), posy ());
                    occupy (submap (), posx (), posy ());
                    set_pos (submap (), posx () + 1, posy ());
                    set_offset (-(MAPSQUARE_SIZE - 1), 0);  
                }
                else
                {
                    set_offset (offx () + 1, offy ());  
                    if (!offx ())
                    {
                        leave (submap (), posx () - 1, posy ());
                        stand_east ();
                        
                        enter_event evt; 
                        evt.submap = submap ();
                        evt.x = posx ();
                        evt.y = posy ();
                        evt.c = this;
                        evt.dir = WALK_EAST; 
                        event_handler::raise_event (&evt);
                    }
                }
                break;
        }
    anim[current_move]->update ();     
}


Generated by  Doxygen 1.6.0   Back to index