original 1.0.1 release
[xwelltris.git] / src / include / wellclass.h
blobe75201e04f811584acfed8f9f88a016945453bf6
1 #ifndef WELLCLASS_H
2 #define WELLCLASS_H
4 #include "globals.h"
5 #include "welltris.h"
6 #include "wellobject.h"
7 #include "welldrawing.h"
8 #include "wellengine.h"
9 #include "wellimagefont.h"
10 #include "welltopnine.h"
12 //define structures for work with figures
13 struct thing_t
15 int squares, polyomino_number;
16 int xpos, ypos;
17 int size, color_number;
18 int bonus, random_rotation, random_reflection;
19 long random_number;
20 thing_t()
22 squares=polyomino_number=xpos=ypos=size=0;
23 color_number=bonus=random_rotation=random_reflection=0;
24 random_number=0;
28 struct Polyominoes
30 int rotation;
31 int reflection;
32 int start_height;
33 int shape[MAX_SQUARES][MAX_SQUARES];
34 int size;
37 struct Mode
39 int number[MAX_MODES][MAX_TYPES];
40 int start[MAX_START_POLYOMINOES][MAX_TYPES];
41 int turn_style;
44 struct Polytris
46 Polyominoes polyomino[MAX_POLYOMINOES];
47 Mode mode[MAX_MODES];
48 int diagonal_switch;
51 struct Field
53 int pmid, cid;
57 class WellBase: public WellObject
59 protected:
60 Polytris tris[MAX_SQUARES - MIN_SQUARES + 1];
61 int frozen_wall[MAX_SIDES];
62 thing_t curThing, nextThing;
63 Field wall[MAX_DEPTH+MAX_WIDTH][MAX_PERIMETER];
64 Field base[MAX_WIDTH][MAX_WIDTH];
66 int level, score, rows, rows_levelup;
68 bool bonusNow;
70 //Options
71 bool showNext;
72 bool beep;
73 bool diagonal;
74 bool mixed;
75 bool bonus;
76 bool grid;
77 bool cw;
78 bool gradualAppear;
79 bool rotation;
80 int squares, pause, steps_to_rotate;
82 //Drawing Engine
84 WellDrawingEngine *dre;
85 WellImageFont *txt_score;
86 WellImageFont *txt_lines;
87 WellImageFont *txt_levelup;
88 WellImageFont *txt_level;
90 WellImageFont *txt_first;
91 WellImageFont *txt_second;
92 WellImageFont *txt_third;
94 Score *player_score;
96 ObjectCaller game_over_object;
98 char player_name[PLAYER_NAME_LEN];
100 void set_default_options();
102 void read_polyominoes();
103 void new_thing();
104 void redo_next();
105 void put_box();
106 bool overlapping();
107 bool at_bottom();
108 bool at_base_fully();
109 bool at_base_partially();
110 bool wall_change(thing_t old,thing_t new_t);
111 bool all_frozen();
112 void wall_to_base(int* base_x,int* base_y,int wall_x,int wall_y);
113 void try_move(Actions move);
114 void draw_thing_diff(thing_t* old);
115 void draw_thing();
116 void draw_field();
117 void fill_lines();
118 void freeze_wall(int w);
119 void defreeze_wall(int w);
120 void drop_wall(int);
121 void check_freeze();
122 int check_lines();
123 void check_update_lines();
124 bool process_action(Actions action);
125 void make_pause();
126 void make_rotation();
128 virtual void draw_status();
129 virtual void draw_next();
130 virtual void clear_next();
131 virtual void draw_grid();
132 virtual void draw_box(int color, int x, int y);
134 public:
135 WellBase();
136 void init(WellEngine*);
137 void udelay(int msec);
138 bool move_one_step(Actions);
139 void game_over();
140 void new_game();
141 void new_level_calc();
142 void redraw_all();
143 void set_level(int il) { level=il; dbgprintf(("Level now is %d\n",level));};
144 void set_rotation(bool r) { rotation=r;};
145 void set_mixed(bool r) { mixed=r;};
146 void set_next_piece(bool r) { showNext=r;};
147 void set_squares(int i) { squares=i;};
148 void set_object_on_game_over(ObjectCaller obj)
150 game_over_object=obj;
152 void set_player_name(char *pn)
154 strcpy(player_name,pn);
156 virtual bool process_event(wEvent);
157 virtual void show();
158 virtual void hide();
161 #endif