home *** CD-ROM | disk | FTP | other *** search
/ Maximum CD 2009 February / maximum-cd-2009-02.iso / DiscContents / SMC_1.6_win32.exe / src / overworld / world_player.h < prev    next >
Encoding:
C/C++ Source or Header  |  2008-08-23  |  3.9 KB  |  137 lines

  1. /***************************************************************************
  2.  * ow_player.h  -  header for the corresponding cpp file
  3.  *
  4.  * Copyright (C) 2003 - 2008 Florian Richter
  5.  ***************************************************************************/
  6. /*
  7.    This program is free software; you can redistribute it and/or modify
  8.    it under the terms of the GNU General Public License as published by
  9.    the Free Software Foundation; either version 3 of the License, or
  10.    (at your option) any later version.
  11.    
  12.    You should have received a copy of the GNU General Public License
  13.    along with this program.  If not, see <http://www.gnu.org/licenses/>.
  14. */
  15.  
  16. #ifndef SMC_WORLD_PLAYER_H
  17. #define SMC_WORLD_PLAYER_H
  18.  
  19. #include "../core/globals.h"
  20. #include "../gui/hud.h"
  21. #include "../overworld/world_layer.h"
  22. #include "../player/player.h"
  23. #include "../overworld/world_waypoint.h"
  24.  
  25. /* *** *** *** *** *** *** *** cOverworld_Player *** *** *** *** *** *** *** *** *** *** */
  26.  
  27. class cOverworld_Player : public cImageObjectSprite
  28. {
  29. public:
  30.     cOverworld_Player( void );
  31.     virtual ~cOverworld_Player( void );
  32.  
  33.     // Load images
  34.     void Load_Images( void );
  35.     // Unload images
  36.     void Unload_Images( void );
  37.  
  38.     // Update
  39.     virtual void Update( void );
  40.     // Draw
  41.     virtual void Draw( cSurfaceRequest *request = NULL );
  42.     // Draw debug text
  43.     void Draw_Debug_Text( void );
  44.  
  45.     // Reset
  46.     void Reset( void );
  47.  
  48.     // General input interact event
  49.     void Action_Interact( input_identifier key_type );
  50.     // Stop Interacting event
  51.     void Action_Stop_Interact( input_identifier key_type );
  52.  
  53.     // Set the velocity for the current direction
  54.     void Update_Vel( void );
  55.  
  56.     // Activates the current Waypoint
  57.     void Activate_Waypoint( void );
  58.  
  59.     /* Start walking into the given direction
  60.      * returns 0 if the next level is not accessible or not available
  61.     */
  62.     bool Start_Walk( ObjectDirection new_direction );
  63.     /* Updates walking
  64.      * checks for new line contacts and updates the Animation
  65.     */
  66.     void Update_Walk( void );
  67.     // Start fixed walking into the given Waypoint
  68.     void Start_Waypoint_Walk( unsigned int new_waypoint );
  69.     /* Fixed walking into the Waypoint
  70.      * moves maryo smoothly into the found Waypoint
  71.     */
  72.     void Update_Waypoint_Walk( void );
  73.  
  74.     // Set Maryo to the given Waypoint position
  75.     bool Set_Waypoint( unsigned int waypoint, bool new_startpos = 0 );
  76.     // Get current Waypoint
  77.     cWaypoint *Get_Waypoint( void );
  78.  
  79.     // Returns the current Waypoint front line
  80.     cLayer_Line *Get_Front_Line( ObjectDirection dir );
  81.  
  82.     /* Checks how much Maryo can walk into all directions
  83.      * and sets the size into the path directions
  84.     */
  85.     void Update_Path_Diff( unsigned int csize = 25 );
  86.  
  87.     // Maryo changes direction if a near path is found or turns around 
  88.     void Change_Direction( void );
  89.  
  90.     /* Automatically corrects Maryo's position to the walkable Layer Line
  91.      * with the given size and the minimal distance to not-walkable area
  92.     */
  93.     void Auto_Pos_Correction( float size = 1.7f, float min_distance = 5 );
  94.  
  95.     // state
  96.     Maryo_type maryo_state;
  97.     // current waypoint
  98.     int current_waypoint;
  99.     // line waypoint
  100.     unsigned int line_waypoint;
  101.     // current line ( if walking )
  102.     int current_line;
  103.  
  104.     // Animation counter
  105.     float anim_counter;
  106.     // Animation Speed
  107.     float anim_speed;
  108.     // last image available for the animation
  109.     unsigned int anim_max;
  110.  
  111.     // if touched a Waypoint use fixed walking
  112.     bool fixed_walking;
  113.  
  114.     // valid path detection lines
  115.     cLine_collision line_hor, line_ver;
  116.  
  117. private:
  118.     // Debug Last Set Data
  119.     int debug_current_line_last;
  120.     int debug_lines_last;
  121.     int debug_current_waypoint_last;
  122.  
  123.     // Debug Text Sprites
  124.     cHudSprite *debug_current_waypoint;
  125.     cHudSprite *debug_lines;
  126.     cHudSprite *debug_current_line;
  127. };
  128.  
  129. /* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
  130.  
  131. // Overworld Player
  132. extern cOverworld_Player *pOverworld_Player;
  133.  
  134. /* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
  135.  
  136. #endif
  137.