PGE Engine
 All Classes Namespaces Files Functions Variables Enumerations Enumerator Macros Pages
lvl_block.h
1 /*
2  * Platformer Game Engine by Wohlstand, a free platform for game making
3  * Copyright (c) 2015 Vitaly Novichkov <admin@wohlnet.ru>
4  *
5  * This program is free software: you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation, either version 3 of the License, or
8  * any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program. If not, see <http://www.gnu.org/licenses/>.
17  */
18 
19 #ifndef LVL_BLOCK_H
20 #define LVL_BLOCK_H
21 
22 #include "lvl_base_object.h"
23 #include <data_configs/obj_block.h>
24 #include <common_features/rectf.h>
26 #include "lvl_player.h"
27 
28 #include <luabind/luabind.hpp>
29 #include <lua_inclues/lua.hpp>
30 
31 class LVL_Block : public PGE_Phys_Object
32 {
33 public:
34  LVL_Block();
35  ~LVL_Block();
36  void init();
37 
38  LevelBlock data; //Local settings
39 
40  bool animated;
41  bool sizable;
42  long animator_ID;
43  float offset_x;
44  float offset_y;
45 
46  bool isHidden;
47 
48  bool destroyed;
49 
50  obj_block * setup;//Global config
51 
52  enum directions{
53  left=0,
54  right,
55  up,
56  down
57  };
58 
59  enum shapes{
60  shape_rect = 0,
61  shape_tr_top_left = 1,
62  shape_tr_top_right =-1,
63  shape_tr_bottom_right = 2,
64  shape_tr_bottom_left =-2,
65  stape_polygon = 3
66  };
67 
68  int shape;
69  double shape_slope_angle_ratio;
70 
71  int taskToTransform;
72  int taskToTransform_t;
73  void transformTo(long id, int type=0);
74  void transformTo_x(long id);
75 
76  void hit(directions _dir=up);
77  void hit(bool isUp, LVL_Player* player, int numHits=1);
78  void destroy(bool playEffect=false);
79  directions hitDirection;
80 
81  GLdouble zIndex();
82 
83  /**************Fader**************/
84  float fadeOffset;
85  float targetOffset;
86  float fade_step;
87  int fadeSpeed;
88  void setFade(int speed, float target, float step);
89  bool isFading();
90  bool tickFader(int ticks);
91  int manual_ticks;
92  void fadeStep();
93  /**************Fader**************/
94 
95  void render(double camX, double camY);
96 
97  bool isInited();
98 
99  /************LUA-Specific functions*********/
100  long lua_getID();
101  int lua_contentID_old();
102  void lua_setContentID_old(int npcid);
103  int lua_contentID();
104  void lua_setContentID(int npcid);
105  bool lua_invisible();
106  void lua_setInvisible(bool iv);
107  bool lua_slippery();
108  void lua_setSlippery(bool sl);
109  bool lua_isSolid();
110  static luabind::scope bindToLua();
111  /*******************************************/
112 
113 private:
114  void drawPiece(PGE_RectF target, PGE_RectF block, PGE_RectF texture);
115  bool _isInited;
116 };
117 
118 #endif // LVL_BLOCK_H
Definition: lvl_player.h:39
Definition: lvl_block.h:31
Definition: rectf.h:26
Level specific Block entry structure. Defines preferences of each block.
Definition: lvl_filedata.h:95
PGE File Library.
Definition: obj_block.h:28
The PGE_Phys_Object class.
Definition: lvl_base_object.h:51