1 // BlinkenSisters - Hunt for the Lost Pixels
2 //     Bringing back the fun of the 80s
3 //
4 // (C) 2005-07 Rene Schickbauer, Wolfgang Dautermann
5 //
6 // See License.txt for licensing information
7 //
8 
9 
10 #ifndef FGOBJECTS_H
11 #define FGOBJECTS_H
12 
13 #include "globals.h"
14 
15 typedef enum _OBJECT_CALLBACK_TYPES {
16 	OBJECT_CB_PLAYERCOLLISION = 0,
17 	OBJECT_CB_PLAYERACTION,
18 	OBJECT_CB_LAST
19 } OBJECT_CALLBACK_TYPES;
20 
21 struct OBJECT_CALLBACKS {
22 	char cbName[MAX_STRING_LENGTH];
23 };
24 
25 typedef struct _FGOBJS {
26 	bool isBlocking;
27 	bool isVisible;
28 	bool isOnTop;
29 	bool isKilling;
30 	bool isPixel;
31 	bool isElevator;
32     bool hasPlayerElevatorCollission;
33 	Uint32 gfxobj;
34 	Sint32 x;
35 	Sint32 y;
36 	OBJECT_CALLBACKS luaCB[OBJECT_CB_LAST];
37 } FGOBJS;
38 
39 typedef struct _FGOVERLAP {
40 	Sint32 left;
41 	Sint32 right;
42 	Sint32 bottom;
43 	Sint32 top;
44 } FGOVERLAP;
45 extern FGOVERLAP fgOverlap;
46 
47 typedef enum _ANIMLOOPTYPE {
48 	ANIMLOOPTYPE_FORWARDLOOP = 0,
49 	ANIMLOOPTYPE_REVERSELOOP,
50 	ANIMLOOPTYPE_PINGPONG
51 } ANIMLOOPTYPE;
52 
53 typedef struct _FGANIMFRAME {
54     Uint32 gfxobj;
55 } FGANIMFRAME;
56 
57 typedef struct _FGANIMS {
58     Uint32 frameCount;
59     Sint32 currentFrame;
60     Sint32 loopDirection;
61     Uint32 looptype;
62     double lastTick;
63     double fps;
64     double tickIncrement;
65     char filetemplate[MAX_STRING_LENGTH];
66     Uint32 filestartnum;
67     Uint32 fileendnum;
68     FGANIMFRAME frames[MAX_FGOBJECTGFX];
69 } FGANIMS;
70 
71 typedef struct _FGGFX {
72     SDL_Surface* surface;
73     char filename[MAX_STRING_LENGTH];
74 } FGGFX;
75 
76 void initFGObjs();
77 void deInitFGObjs();
78 Uint32 addFGObjGFX(const char *fname, bool ignoreLoadError = false);
79 Uint32 addFGObjAnim(const char *templfname, const Uint32 startnum, const Uint32 endnum, const double fps, const Uint32 looptype);
80 Uint32 duplicateFGObjAnim(const Uint32 obj);
81 void advanceFGObjAnim();
82 Uint32 addFGObj(const Uint32 gfxobj, const Sint32 x, const Sint32 y, const bool isBlocking, const bool isVisible, const bool isOnTop, const bool isKilling);
83 bool deleteFGObj(const Uint32 objid);
84 void paintSingleFGObj(SDL_Surface *gfx, const Sint32 x, const Sint32 y);
85 void paintFGObjs(const Uint32 xoffs, const Uint32 yoffs, const bool topObjects);
86 void doFGPlayerAction(const Uint32 playerx, const Uint32 playery);
87 
88 void setFGObjSetVisible(const Uint32 obj, const bool visible);
89 void setFGObjSetBlocking(const Uint32 obj, const bool blocking);
90 void setFGObjSetOnTop(const Uint32 obj, const bool ontop);
91 void setFGObjSetElevator(const Uint32 obj, const bool elevator);
92 void setFGObjSetGFX(const Uint32 obj, const Uint32 gfx);
93 Uint32 getFGObjSetGFX(const Uint32 obj);
94 void setFGObjSetKilling(const Uint32 obj, const bool killing);
95 void setFGObjSetPixel(const Uint32 obj, const bool pixel);
96 void setFGObjSetPos(const Uint32 obj, const Sint32 x, const Sint32 y);
97 void setFGObjSetPosX(const Uint32 obj, const Sint32 x);
98 void setFGObjSetPosY(const Uint32 obj, const Sint32 y);
99 Sint32 getFGObjSetPosX(const Uint32 obj);
100 Sint32 getFGObjSetPosY(const Uint32 obj);
101 bool getFGObjSetVisible(const Uint32 obj);
102 bool getFGObjSetBlocking(const Uint32 obj);
103 bool getFGObjSetOnTop(const Uint32 obj);
104 bool getFGObjSetElevator(const Uint32 obj);
105 bool getFGObjSetKilling(const Uint32 obj);
106 bool getFGObjSetPixel(const Uint32 obj);
107 
108 bool setFGObjAnimLoopType(const Uint32 obj, const Uint32 looptype);
109 bool setFGObjAnimCurrentFrame(const Uint32 obj, const Uint32 frameNum);
110 bool setFGObjAnimCurrentDirection(const Uint32 obj, const Sint32 loopDirection);
111 bool setFGObjAnimFrameRate(const Uint32 obj, const double fps);
112 
113 Uint32 getFGObjAnimLoopType(const Uint32 obj);
114 Uint32 getFGObjAnimCurrentFrame(const Uint32 obj);
115 Sint32 getFGObjAnimCurrentDirection(const Uint32 obj);
116 double getFGObjAnimFrameRate(const Uint32 obj);
117 
118 
119 void handlePlayerFGColission();
120 bool getPlayerFGKillColission();
121 void handlePlayerFGPixelCollission();
122 bool checkPlayerFGTrueCollission(const Uint32 objid);
123 void handlePlayerFGTrueCollission();
124 SDL_Surface* getFGSurface(const Uint32 gfxid);
125 void handlePlayerFGObjCallbacks();
126 
127 extern Uint32 fgobjcnt;
128 extern Uint32 fgobjgfxcnt;
129 extern Uint32 fgobjanimcnt;
130 //extern SDL_Surface *FGOBJ_Surface[];
131 extern FGOBJS *fgObjs[];
132 extern FGGFX *fgGFX[];
133 extern FGANIMS *fgAnims[];
134 extern FGOVERLAP fgOverlap;
135 
136 #endif // FGOBJECTS_H
137