home *** CD-ROM | disk | FTP | other *** search
/ Maximum CD 2009 February / maximum-cd-2009-02.iso / DiscContents / SMC_1.6_win32.exe / src / objects / moving_platform.h < prev    next >
Encoding:
C/C++ Source or Header  |  2008-07-01  |  5.1 KB  |  157 lines

  1. /***************************************************************************
  2.  * moving_platform.h  -  header for the corresponding cpp file
  3.  *
  4.  * Copyright (C) 2005 - 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_MOVING_PLATFORM_H
  17. #define SMC_MOVING_PLATFORM_H
  18.  
  19. #include "../core/globals.h"
  20. #include "../objects/objectsprite.h"
  21.  
  22.  
  23. /* *** *** *** *** *** *** *** *** Moving Platform states *** *** *** *** *** *** *** *** *** */
  24.  
  25. enum Moving_Platform_State
  26. {
  27.     PLATFORM_STAY = 0,
  28.     PLATFORM_TOUCHED = 1,
  29.     PLATFORM_SHAKE = 2,
  30.     PLATFORM_FALL = 3
  31. };
  32.  
  33. /* *** *** *** *** *** *** cMoving_Platform *** *** *** *** *** *** *** *** *** *** *** */
  34.  
  35. /* todo : 
  36.  * - platform type : static(current) and rotating
  37. */
  38. class cMoving_Platform : public cImageObjectSprite
  39. {
  40. public:
  41.     // constructor
  42.     cMoving_Platform( float x, float y );
  43.     // create from stream
  44.     cMoving_Platform( CEGUI::XMLAttributes &attributes );
  45.     // destructor
  46.     ~cMoving_Platform( void );
  47.     
  48.     // init defaults
  49.     void Init( void );
  50.     // copy
  51.     virtual cMoving_Platform *Copy( void );
  52.  
  53.     // create from stream
  54.     virtual void Create_from_Stream( CEGUI::XMLAttributes &attributes );
  55.     // save to stream
  56.     virtual void Save_to_Stream( ofstream &file );
  57.  
  58.     // load from savegame
  59.     virtual void Load_from_Savegame( cSave_Level_Object *save_object );
  60.     // save to savegame
  61.     virtual cSave_Level_Object *Save_to_Savegame( void );
  62.  
  63.     // Set Massive Type
  64.     virtual void Set_Massive_Type( MassiveType mtype );
  65.     // Set Direction
  66.     void Set_Direction( ObjectDirection dir, bool new_start_direction = 0 );
  67.     // Set Max Distance
  68.     void Set_Max_Distance( int nmax_distance );
  69.     // Set the Speed
  70.     void Set_Speed( float val );
  71.     // Set time when touched until it starts shaking
  72.     void Set_Touch_Time( float val );
  73.     // Set time it's shaking until falling
  74.     void Set_Shake_Time( float val );
  75.     /* Set time when touched until it starts moving
  76.      * if set to 0 automatically moves
  77.     */
  78.     void Set_Touch_Move_Time( float val );
  79.  
  80.     // Set the middle image count
  81.     void Set_Middle_Count( int val );
  82.     // set image
  83.     void Set_Image_Top_Left( GL_Surface *surface );
  84.     void Set_Image_Top_Middle( GL_Surface *surface );
  85.     void Set_Image_Top_Right( GL_Surface *surface );
  86.  
  87.     // update
  88.     virtual void Update( void );
  89.     // draw
  90.     virtual void Draw( cSurfaceRequest *request /* = NULL */ );
  91.  
  92.     // Update rect
  93.     void Update_Rect( void );
  94.     // Update velocity
  95.     void Update_Velocity( void );
  96.  
  97.     // ignore onground check
  98.     virtual void Check_on_Ground( void ) {};
  99.  
  100.     // if update is valid for the current state
  101.     virtual bool Is_Update_Valid( void );
  102.  
  103.     /* Validate the given collision object
  104.      * returns 1 if an internal collision with this object is valid
  105.      * returns 2 if the given object collides with this object (blocking)
  106.     */
  107.     virtual unsigned int Validate_Collision( cSprite *obj );
  108.     // collision from player
  109.     virtual void Handle_Collision_Player( cObjectCollision *collision );
  110.  
  111.     // leveleditor activation
  112.     virtual void Editor_Activate( void );
  113.     // leveleditor events
  114.     bool Editor_Max_Distance_Key( const CEGUI::EventArgs &event );  // editor max distance key up
  115.     bool Editor_Speed_Key( const CEGUI::EventArgs &event );  // editor speed key up
  116.     bool Editor_Hor_Middle_Count_Key( const CEGUI::EventArgs &event );  // editor horizontal middle image count key up
  117.     bool Editor_Image_Top_Left_Key( const CEGUI::EventArgs &event );  // editor image top left key up
  118.     bool Editor_Image_Top_Middle_Key( const CEGUI::EventArgs &event );  // editor image top middle key up
  119.     bool Editor_Image_Top_Right_Key( const CEGUI::EventArgs &event );  // editor image top right key up
  120.     bool Editor_Touch_Time_Key( const CEGUI::EventArgs &event );  // editor touch time key up
  121.     bool Editor_Shake_Time_Key( const CEGUI::EventArgs &event );  // editor shaking time key up
  122.     bool Editor_Touch_Move_Time_Key( const CEGUI::EventArgs &event );  // editor touch moving time key up
  123.  
  124.     // current direction
  125.     ObjectDirection moving_direction;
  126.     // moving speed
  127.     float speed;
  128.     // max moving distance
  129.     int max_distance;
  130.     // count the middle image is used
  131.     unsigned int middle_count;
  132.  
  133.     // internal platform state
  134.     Moving_Platform_State platform_state;
  135.  
  136.     // time when touched until it starts shaking
  137.     float touch_time;
  138.     // time since the platform got touched
  139.     float touch_counter;
  140.     // time it's shaking until falling
  141.     float shake_time;
  142.     // time since shaking started
  143.     float shake_counter;
  144.     // shaking direction counter
  145.     float shake_dir_counter;
  146.     // time when touched until it starts moving
  147.     float touch_move_time;
  148.  
  149. private:
  150.     // Create the Name from the current settings
  151.     void Create_Name( void );
  152. };
  153.  
  154. /* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
  155.  
  156. #endif
  157.