annotate trix/src/game.c @ 23:489244127359

kopieckreta-0.240903-0
author Przemyslaw <prymula76@outlook.com>
date Mon, 01 Apr 2024 07:15:00 +0200
parents 2787f5e749ae
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
prymula <prymula76@outlook.com>
parents:
diff changeset
1 /*
prymula <prymula76@outlook.com>
parents:
diff changeset
2 * Trix - klikanie po klockach
prymula <prymula76@outlook.com>
parents:
diff changeset
3 * Przemysław R. Pietraszczyk
prymula <prymula76@outlook.com>
parents:
diff changeset
4 *
prymula <prymula76@outlook.com>
parents:
diff changeset
5 * paźdżiernik 2006 r.
prymula <prymula76@outlook.com>
parents:
diff changeset
6 *
prymula <prymula76@outlook.com>
parents:
diff changeset
7 * licencja: Public Domain
prymula <prymula76@outlook.com>
parents:
diff changeset
8 */
prymula <prymula76@outlook.com>
parents:
diff changeset
9
prymula <prymula76@outlook.com>
parents:
diff changeset
10 #include "trix.h"
prymula <prymula76@outlook.com>
parents:
diff changeset
11
prymula <prymula76@outlook.com>
parents:
diff changeset
12 #define X_SCORE_INSCRIPTION 10
prymula <prymula76@outlook.com>
parents:
diff changeset
13 #define X_LEVEL_INSCRIPTION 200
prymula <prymula76@outlook.com>
parents:
diff changeset
14 #define X_HISCORE_INSCRIPTION 340
prymula <prymula76@outlook.com>
parents:
diff changeset
15 #define Y_ALL_INSCRIPTION 0
prymula <prymula76@outlook.com>
parents:
diff changeset
16
prymula <prymula76@outlook.com>
parents:
diff changeset
17 #define X_HIGH_SLAT 1
prymula <prymula76@outlook.com>
parents:
diff changeset
18 #define Y_HIGH_SLAT 40
prymula <prymula76@outlook.com>
parents:
diff changeset
19 #define X_SIZE_HIGH_SLAT (screen->w)
prymula <prymula76@outlook.com>
parents:
diff changeset
20 #define Y_SIZE_HIGH_SLAT FIELD_SIZE
prymula <prymula76@outlook.com>
parents:
diff changeset
21
prymula <prymula76@outlook.com>
parents:
diff changeset
22 #define X_ACTION 1
prymula <prymula76@outlook.com>
parents:
diff changeset
23 #define Y_ACTION 60
prymula <prymula76@outlook.com>
parents:
diff changeset
24 #define X_SIZE_ACTION (screen->w)
prymula <prymula76@outlook.com>
parents:
diff changeset
25 #define Y_SIZE_ACTION (screen->h)
prymula <prymula76@outlook.com>
parents:
diff changeset
26
prymula <prymula76@outlook.com>
parents:
diff changeset
27 /*
prymula <prymula76@outlook.com>
parents:
diff changeset
28 // z trix.h begin
prymula <prymula76@outlook.com>
parents:
diff changeset
29 SDL_Surface * block[8];
prymula <prymula76@outlook.com>
parents:
diff changeset
30 SDL_Surface * explode;
prymula <prymula76@outlook.com>
parents:
diff changeset
31 SDL_Surface * bomb;
prymula <prymula76@outlook.com>
parents:
diff changeset
32 SDL_Surface * wall;
prymula <prymula76@outlook.com>
parents:
diff changeset
33 SDL_Surface * smoke;
prymula <prymula76@outlook.com>
parents:
diff changeset
34
prymula <prymula76@outlook.com>
parents:
diff changeset
35 SDL_Surface * net;
prymula <prymula76@outlook.com>
parents:
diff changeset
36 SDL_Surface * banner;
prymula <prymula76@outlook.com>
parents:
diff changeset
37 SDL_Surface * bg;
prymula <prymula76@outlook.com>
parents:
diff changeset
38 SDL_Surface * screen;
prymula <prymula76@outlook.com>
parents:
diff changeset
39 TTF_Font* font;
prymula <prymula76@outlook.com>
parents:
diff changeset
40
prymula <prymula76@outlook.com>
parents:
diff changeset
41 SDL_Renderer * renderer;
prymula <prymula76@outlook.com>
parents:
diff changeset
42 SDL_Texture * tex_screen;
prymula <prymula76@outlook.com>
parents:
diff changeset
43
prymula <prymula76@outlook.com>
parents:
diff changeset
44 SDL_Rect source, dest;
prymula <prymula76@outlook.com>
parents:
diff changeset
45 int use_net; // zmienna wyswietlania siatki
prymula <prymula76@outlook.com>
parents:
diff changeset
46 int start_level; // start gry od poziomu ...
prymula <prymula76@outlook.com>
parents:
diff changeset
47 int score;
prymula <prymula76@outlook.com>
parents:
diff changeset
48 int bonus; // nalicza premie
prymula <prymula76@outlook.com>
parents:
diff changeset
49
prymula <prymula76@outlook.com>
parents:
diff changeset
50 char * hifile; // path do hiscore
prymula <prymula76@outlook.com>
parents:
diff changeset
51
prymula <prymula76@outlook.com>
parents:
diff changeset
52
prymula <prymula76@outlook.com>
parents:
diff changeset
53 int use_net; // zmienna wyswietlania siatki
prymula <prymula76@outlook.com>
parents:
diff changeset
54 int start_level; // start gry od poziomu ...
prymula <prymula76@outlook.com>
parents:
diff changeset
55 int score;
prymula <prymula76@outlook.com>
parents:
diff changeset
56 int bonus; // nalicza premie
prymula <prymula76@outlook.com>
parents:
diff changeset
57
prymula <prymula76@outlook.com>
parents:
diff changeset
58 char * hifile; // path do hiscore
prymula <prymula76@outlook.com>
parents:
diff changeset
59 struct tab tab_hiscores[5];
prymula <prymula76@outlook.com>
parents:
diff changeset
60 char const catalogue[N_PIC][40];
prymula <prymula76@outlook.com>
parents:
diff changeset
61 // z trix.h end
prymula <prymula76@outlook.com>
parents:
diff changeset
62
prymula <prymula76@outlook.com>
parents:
diff changeset
63 */
prymula <prymula76@outlook.com>
parents:
diff changeset
64
prymula <prymula76@outlook.com>
parents:
diff changeset
65
prymula <prymula76@outlook.com>
parents:
diff changeset
66
prymula <prymula76@outlook.com>
parents:
diff changeset
67 static SDL_Surface * var_level_inscription;
prymula <prymula76@outlook.com>
parents:
diff changeset
68 static SDL_Surface * var_hiscore_inscription;
prymula <prymula76@outlook.com>
parents:
diff changeset
69
prymula <prymula76@outlook.com>
parents:
diff changeset
70 /* tablica struktur przechowuje pozycje kasowanych elementow */
prymula <prymula76@outlook.com>
parents:
diff changeset
71 static struct ghost gh[598];
prymula <prymula76@outlook.com>
parents:
diff changeset
72 static int gh_index;
prymula <prymula76@outlook.com>
parents:
diff changeset
73
prymula <prymula76@outlook.com>
parents:
diff changeset
74 SDL_Surface * prepare_text(int r, int b, int g, char *buffer);
prymula <prymula76@outlook.com>
parents:
diff changeset
75 void load_background(int n);
prymula <prymula76@outlook.com>
parents:
diff changeset
76 void print_inscription(char * buffor, int desx, int desy);
prymula <prymula76@outlook.com>
parents:
diff changeset
77 void draw_text (int x, int y, SDL_Surface * image);
prymula <prymula76@outlook.com>
parents:
diff changeset
78
prymula <prymula76@outlook.com>
parents:
diff changeset
79 void get_name_of_player(void);
prymula <prymula76@outlook.com>
parents:
diff changeset
80
prymula <prymula76@outlook.com>
parents:
diff changeset
81
prymula <prymula76@outlook.com>
parents:
diff changeset
82
prymula <prymula76@outlook.com>
parents:
diff changeset
83 /* sprawdza czy klocki nie osiagnely masymalnej wysokosci */
prymula <prymula76@outlook.com>
parents:
diff changeset
84 int behind_high(void) {
prymula <prymula76@outlook.com>
parents:
diff changeset
85
prymula <prymula76@outlook.com>
parents:
diff changeset
86 int i;
prymula <prymula76@outlook.com>
parents:
diff changeset
87
prymula <prymula76@outlook.com>
parents:
diff changeset
88 /* jesli znajdzie na szczycie jakis klocek o stalym statusie
prymula <prymula76@outlook.com>
parents:
diff changeset
89 zwraca prawde */
prymula <prymula76@outlook.com>
parents:
diff changeset
90 for (i=0; i<23; ++i) {
prymula <prymula76@outlook.com>
parents:
diff changeset
91 if (field[i][1].type && field[i][1].status == STAND)
prymula <prymula76@outlook.com>
parents:
diff changeset
92 return 1;
prymula <prymula76@outlook.com>
parents:
diff changeset
93 }
prymula <prymula76@outlook.com>
parents:
diff changeset
94
prymula <prymula76@outlook.com>
parents:
diff changeset
95 return 0;
prymula <prymula76@outlook.com>
parents:
diff changeset
96 }
prymula <prymula76@outlook.com>
parents:
diff changeset
97
prymula <prymula76@outlook.com>
parents:
diff changeset
98 /* zeruje strukture elementow */
prymula <prymula76@outlook.com>
parents:
diff changeset
99 void zero_field(void) {
prymula <prymula76@outlook.com>
parents:
diff changeset
100
prymula <prymula76@outlook.com>
parents:
diff changeset
101 int i, j;
prymula <prymula76@outlook.com>
parents:
diff changeset
102
prymula <prymula76@outlook.com>
parents:
diff changeset
103 for (j=0; j<26;++j) {
prymula <prymula76@outlook.com>
parents:
diff changeset
104 for (i=0; i<23;++i) {
prymula <prymula76@outlook.com>
parents:
diff changeset
105 field[i][j].type = NULL;
prymula <prymula76@outlook.com>
parents:
diff changeset
106 field[i][j].status=0;
prymula <prymula76@outlook.com>
parents:
diff changeset
107 }
prymula <prymula76@outlook.com>
parents:
diff changeset
108 }
prymula <prymula76@outlook.com>
parents:
diff changeset
109
prymula <prymula76@outlook.com>
parents:
diff changeset
110 }
prymula <prymula76@outlook.com>
parents:
diff changeset
111
prymula <prymula76@outlook.com>
parents:
diff changeset
112
prymula <prymula76@outlook.com>
parents:
diff changeset
113 void set_background(void) {
prymula <prymula76@outlook.com>
parents:
diff changeset
114
prymula <prymula76@outlook.com>
parents:
diff changeset
115 SDL_Rect srcrect, destrect;
prymula <prymula76@outlook.com>
parents:
diff changeset
116
prymula <prymula76@outlook.com>
parents:
diff changeset
117 destrect = set_rect(0, 0, bg->w, bg->h);
prymula <prymula76@outlook.com>
parents:
diff changeset
118 srcrect = set_rect(0,0, bg->w, bg->h);
prymula <prymula76@outlook.com>
parents:
diff changeset
119 SDL_BlitSurface(bg,&srcrect,screen,&destrect);
prymula <prymula76@outlook.com>
parents:
diff changeset
120 }
prymula <prymula76@outlook.com>
parents:
diff changeset
121
prymula <prymula76@outlook.com>
parents:
diff changeset
122 void set_net(void) {
prymula <prymula76@outlook.com>
parents:
diff changeset
123
prymula <prymula76@outlook.com>
parents:
diff changeset
124 SDL_Rect srcrect, destrect;
prymula <prymula76@outlook.com>
parents:
diff changeset
125
prymula <prymula76@outlook.com>
parents:
diff changeset
126 destrect = set_rect(0, 0, net->w, net->h);
prymula <prymula76@outlook.com>
parents:
diff changeset
127 srcrect = set_rect(0,0, net->w, net->h);
prymula <prymula76@outlook.com>
parents:
diff changeset
128 SDL_BlitSurface(net,&srcrect,screen,&destrect);
prymula <prymula76@outlook.com>
parents:
diff changeset
129 }
prymula <prymula76@outlook.com>
parents:
diff changeset
130
prymula <prymula76@outlook.com>
parents:
diff changeset
131
prymula <prymula76@outlook.com>
parents:
diff changeset
132 /* sprawdza czy na planszy sa jakies klocki */
prymula <prymula76@outlook.com>
parents:
diff changeset
133 int shortage_blocks(void) {
prymula <prymula76@outlook.com>
parents:
diff changeset
134
prymula <prymula76@outlook.com>
parents:
diff changeset
135 int i, j;
prymula <prymula76@outlook.com>
parents:
diff changeset
136
prymula <prymula76@outlook.com>
parents:
diff changeset
137 for (j=1; j<26; j++) {
prymula <prymula76@outlook.com>
parents:
diff changeset
138 for (i=0; i<23; i++) {
prymula <prymula76@outlook.com>
parents:
diff changeset
139 if (field[i][j].type) {
prymula <prymula76@outlook.com>
parents:
diff changeset
140 if (field[i][j].type == wall) continue;
prymula <prymula76@outlook.com>
parents:
diff changeset
141 else goto end;
prymula <prymula76@outlook.com>
parents:
diff changeset
142 }
prymula <prymula76@outlook.com>
parents:
diff changeset
143 }
prymula <prymula76@outlook.com>
parents:
diff changeset
144 }
prymula <prymula76@outlook.com>
parents:
diff changeset
145
prymula <prymula76@outlook.com>
parents:
diff changeset
146 end:
prymula <prymula76@outlook.com>
parents:
diff changeset
147 /* gdy brak klockow */
prymula <prymula76@outlook.com>
parents:
diff changeset
148 if (j==26 && i==23) {
prymula <prymula76@outlook.com>
parents:
diff changeset
149 printf ("brak klockow\n");
prymula <prymula76@outlook.com>
parents:
diff changeset
150 return 1;
prymula <prymula76@outlook.com>
parents:
diff changeset
151 }
prymula <prymula76@outlook.com>
parents:
diff changeset
152
prymula <prymula76@outlook.com>
parents:
diff changeset
153 /* gdy sa klocki */
prymula <prymula76@outlook.com>
parents:
diff changeset
154 return 0;
prymula <prymula76@outlook.com>
parents:
diff changeset
155
prymula <prymula76@outlook.com>
parents:
diff changeset
156
prymula <prymula76@outlook.com>
parents:
diff changeset
157 }
prymula <prymula76@outlook.com>
parents:
diff changeset
158
prymula <prymula76@outlook.com>
parents:
diff changeset
159
prymula <prymula76@outlook.com>
parents:
diff changeset
160 /* elementy zaczynaja opadac z gornej belki */
prymula <prymula76@outlook.com>
parents:
diff changeset
161 void drop_from_high_slat(void) {
prymula <prymula76@outlook.com>
parents:
diff changeset
162
prymula <prymula76@outlook.com>
parents:
diff changeset
163 int i;
prymula <prymula76@outlook.com>
parents:
diff changeset
164
prymula <prymula76@outlook.com>
parents:
diff changeset
165 for (i=22; i>=0; --i) {
prymula <prymula76@outlook.com>
parents:
diff changeset
166 field[i][0].status = DROP;
prymula <prymula76@outlook.com>
parents:
diff changeset
167 }
prymula <prymula76@outlook.com>
parents:
diff changeset
168 }
prymula <prymula76@outlook.com>
parents:
diff changeset
169
prymula <prymula76@outlook.com>
parents:
diff changeset
170 void set_element(int f, int x, int y) {
prymula <prymula76@outlook.com>
parents:
diff changeset
171
prymula <prymula76@outlook.com>
parents:
diff changeset
172 switch(f) {
prymula <prymula76@outlook.com>
parents:
diff changeset
173 // od 0 do 49 pustka
prymula <prymula76@outlook.com>
parents:
diff changeset
174 case 50 ... 64:
prymula <prymula76@outlook.com>
parents:
diff changeset
175 field[x][y].type = bomb;
prymula <prymula76@outlook.com>
parents:
diff changeset
176 break;
prymula <prymula76@outlook.com>
parents:
diff changeset
177 case 65 ... 73:
prymula <prymula76@outlook.com>
parents:
diff changeset
178 field[x][y].type = block[0];
prymula <prymula76@outlook.com>
parents:
diff changeset
179 break;
prymula <prymula76@outlook.com>
parents:
diff changeset
180 case 74 ... 80:
prymula <prymula76@outlook.com>
parents:
diff changeset
181 field[x][y].type = block[1];
prymula <prymula76@outlook.com>
parents:
diff changeset
182 break;
prymula <prymula76@outlook.com>
parents:
diff changeset
183 case 81 ... 85:
prymula <prymula76@outlook.com>
parents:
diff changeset
184 field[x][y].type = block[2];
prymula <prymula76@outlook.com>
parents:
diff changeset
185 break;
prymula <prymula76@outlook.com>
parents:
diff changeset
186 case 86 ... 90:
prymula <prymula76@outlook.com>
parents:
diff changeset
187 field[x][y].type = block[3];
prymula <prymula76@outlook.com>
parents:
diff changeset
188 break;
prymula <prymula76@outlook.com>
parents:
diff changeset
189 case 91 ... 99:
prymula <prymula76@outlook.com>
parents:
diff changeset
190 field[x][y].type = block[4];
prymula <prymula76@outlook.com>
parents:
diff changeset
191 break;
prymula <prymula76@outlook.com>
parents:
diff changeset
192 case 100 ... 106:
prymula <prymula76@outlook.com>
parents:
diff changeset
193 field[x][y].type = block[5];
prymula <prymula76@outlook.com>
parents:
diff changeset
194 break;
prymula <prymula76@outlook.com>
parents:
diff changeset
195 case 107 ... 111:
prymula <prymula76@outlook.com>
parents:
diff changeset
196 field[x][y].type = block[6];
prymula <prymula76@outlook.com>
parents:
diff changeset
197 break;
prymula <prymula76@outlook.com>
parents:
diff changeset
198 case 112 ... 116:
prymula <prymula76@outlook.com>
parents:
diff changeset
199 field[x][y].type = block[7];
prymula <prymula76@outlook.com>
parents:
diff changeset
200 break;
prymula <prymula76@outlook.com>
parents:
diff changeset
201 default:
prymula <prymula76@outlook.com>
parents:
diff changeset
202 field[x][y].type = NULL;
prymula <prymula76@outlook.com>
parents:
diff changeset
203 break;
prymula <prymula76@outlook.com>
parents:
diff changeset
204 }
prymula <prymula76@outlook.com>
parents:
diff changeset
205 }
prymula <prymula76@outlook.com>
parents:
diff changeset
206
prymula <prymula76@outlook.com>
parents:
diff changeset
207 /* wypelnia studnie elementami */
prymula <prymula76@outlook.com>
parents:
diff changeset
208 void fill_board(struct data_levels * dl) {
prymula <prymula76@outlook.com>
parents:
diff changeset
209
prymula <prymula76@outlook.com>
parents:
diff changeset
210 int x, y, f;
prymula <prymula76@outlook.com>
parents:
diff changeset
211
prymula <prymula76@outlook.com>
parents:
diff changeset
212 for (y=24; y>2; --y) {
prymula <prymula76@outlook.com>
parents:
diff changeset
213 for (x=0; x<23; ++x) {
prymula <prymula76@outlook.com>
parents:
diff changeset
214 label:
prymula <prymula76@outlook.com>
parents:
diff changeset
215 f=rand()%dl->max;
prymula <prymula76@outlook.com>
parents:
diff changeset
216 if (f<40) goto label;
prymula <prymula76@outlook.com>
parents:
diff changeset
217 set_element(f, x, y);
prymula <prymula76@outlook.com>
parents:
diff changeset
218
prymula <prymula76@outlook.com>
parents:
diff changeset
219 field[x][y].status = DROP;
prymula <prymula76@outlook.com>
parents:
diff changeset
220 }
prymula <prymula76@outlook.com>
parents:
diff changeset
221 }
prymula <prymula76@outlook.com>
parents:
diff changeset
222
prymula <prymula76@outlook.com>
parents:
diff changeset
223 }
prymula <prymula76@outlook.com>
parents:
diff changeset
224
prymula <prymula76@outlook.com>
parents:
diff changeset
225
prymula <prymula76@outlook.com>
parents:
diff changeset
226 /* gorna listwa */
prymula <prymula76@outlook.com>
parents:
diff changeset
227 void high_slat(struct data_levels * dl, SDL_bool only_bomb) {
prymula <prymula76@outlook.com>
parents:
diff changeset
228
prymula <prymula76@outlook.com>
parents:
diff changeset
229 int i, f;
prymula <prymula76@outlook.com>
parents:
diff changeset
230
prymula <prymula76@outlook.com>
parents:
diff changeset
231 /* przesuwamy klocki w prawo */
prymula <prymula76@outlook.com>
parents:
diff changeset
232 for (i=22; i>0; --i)
prymula <prymula76@outlook.com>
parents:
diff changeset
233 field[i][0] = field[i-1][0];
prymula <prymula76@outlook.com>
parents:
diff changeset
234
prymula <prymula76@outlook.com>
parents:
diff changeset
235 /* losujemy element dla pozycji 0,0 */
prymula <prymula76@outlook.com>
parents:
diff changeset
236 if (!only_bomb) f=rand()%dl->max;
prymula <prymula76@outlook.com>
parents:
diff changeset
237 else f=55;
prymula <prymula76@outlook.com>
parents:
diff changeset
238
prymula <prymula76@outlook.com>
parents:
diff changeset
239 set_element(f, 0, 0);
prymula <prymula76@outlook.com>
parents:
diff changeset
240
prymula <prymula76@outlook.com>
parents:
diff changeset
241 field[0][0].status = 0;
prymula <prymula76@outlook.com>
parents:
diff changeset
242
prymula <prymula76@outlook.com>
parents:
diff changeset
243 }
prymula <prymula76@outlook.com>
parents:
diff changeset
244
prymula <prymula76@outlook.com>
parents:
diff changeset
245 /* funkcja sprawdza status elementu i jesli
prymula <prymula76@outlook.com>
parents:
diff changeset
246 element opada to obniza element na planszy */
prymula <prymula76@outlook.com>
parents:
diff changeset
247 void drop_elements(void) {
prymula <prymula76@outlook.com>
parents:
diff changeset
248
prymula <prymula76@outlook.com>
parents:
diff changeset
249 int j, i;
prymula <prymula76@outlook.com>
parents:
diff changeset
250
prymula <prymula76@outlook.com>
parents:
diff changeset
251
prymula <prymula76@outlook.com>
parents:
diff changeset
252 for (j=25; j>=0; --j) {
prymula <prymula76@outlook.com>
parents:
diff changeset
253 for (i=0; i<23; ++i) {
prymula <prymula76@outlook.com>
parents:
diff changeset
254 if (field[i][j].status == DROP) {
prymula <prymula76@outlook.com>
parents:
diff changeset
255
prymula <prymula76@outlook.com>
parents:
diff changeset
256 /* jesli analizowana pozycja jest pusta */
prymula <prymula76@outlook.com>
parents:
diff changeset
257 if (!field[i][j+1].type) {
prymula <prymula76@outlook.com>
parents:
diff changeset
258 field[i][j+1] = field[i][j];
prymula <prymula76@outlook.com>
parents:
diff changeset
259
prymula <prymula76@outlook.com>
parents:
diff changeset
260
prymula <prymula76@outlook.com>
parents:
diff changeset
261 // wyzerowanie poprzedniej pozycji
prymula <prymula76@outlook.com>
parents:
diff changeset
262 field[i][j].status = 0;
prymula <prymula76@outlook.com>
parents:
diff changeset
263 field[i][j].type = NULL;
prymula <prymula76@outlook.com>
parents:
diff changeset
264
prymula <prymula76@outlook.com>
parents:
diff changeset
265 /* osiadlo na dnie */
prymula <prymula76@outlook.com>
parents:
diff changeset
266 if (j==24) {
prymula <prymula76@outlook.com>
parents:
diff changeset
267 field[i][j+1].status = STAND;
prymula <prymula76@outlook.com>
parents:
diff changeset
268 }
prymula <prymula76@outlook.com>
parents:
diff changeset
269 }
prymula <prymula76@outlook.com>
parents:
diff changeset
270 /* wprzeciwnym wypadku stawiamy element na
prymula <prymula76@outlook.com>
parents:
diff changeset
271 elemencie */
prymula <prymula76@outlook.com>
parents:
diff changeset
272 else {
prymula <prymula76@outlook.com>
parents:
diff changeset
273 field[i][j].status = STAND;
prymula <prymula76@outlook.com>
parents:
diff changeset
274 }
prymula <prymula76@outlook.com>
parents:
diff changeset
275
prymula <prymula76@outlook.com>
parents:
diff changeset
276
prymula <prymula76@outlook.com>
parents:
diff changeset
277
prymula <prymula76@outlook.com>
parents:
diff changeset
278
prymula <prymula76@outlook.com>
parents:
diff changeset
279 }
prymula <prymula76@outlook.com>
parents:
diff changeset
280 }
prymula <prymula76@outlook.com>
parents:
diff changeset
281 }
prymula <prymula76@outlook.com>
parents:
diff changeset
282
prymula <prymula76@outlook.com>
parents:
diff changeset
283 }
prymula <prymula76@outlook.com>
parents:
diff changeset
284
prymula <prymula76@outlook.com>
parents:
diff changeset
285 /* kasuje elementy po skasowaniu klockow badz wybuchu bomb */
prymula <prymula76@outlook.com>
parents:
diff changeset
286 void delete_elements(void) {
prymula <prymula76@outlook.com>
parents:
diff changeset
287
prymula <prymula76@outlook.com>
parents:
diff changeset
288 int x, y;
prymula <prymula76@outlook.com>
parents:
diff changeset
289
prymula <prymula76@outlook.com>
parents:
diff changeset
290 /* to musi byc przynajmniej para wiec mozna
prymula <prymula76@outlook.com>
parents:
diff changeset
291 tak sprawdzac */
prymula <prymula76@outlook.com>
parents:
diff changeset
292 if (gh_index) {
prymula <prymula76@outlook.com>
parents:
diff changeset
293
prymula <prymula76@outlook.com>
parents:
diff changeset
294 /* index jest o jeden wiekszy trzeba go zmnniejszyc */
prymula <prymula76@outlook.com>
parents:
diff changeset
295 gh_index--;
prymula <prymula76@outlook.com>
parents:
diff changeset
296
prymula <prymula76@outlook.com>
parents:
diff changeset
297 printf ("gh_index: %d\n", gh_index);
prymula <prymula76@outlook.com>
parents:
diff changeset
298
prymula <prymula76@outlook.com>
parents:
diff changeset
299 do {
prymula <prymula76@outlook.com>
parents:
diff changeset
300 /* kasowanie elementow po zniknieciu lub wybuchu */
prymula <prymula76@outlook.com>
parents:
diff changeset
301 field[gh[gh_index].x][gh[gh_index].y].type = NULL;
prymula <prymula76@outlook.com>
parents:
diff changeset
302 field[gh[gh_index].x][gh[gh_index].y].status = 0;
prymula <prymula76@outlook.com>
parents:
diff changeset
303
prymula <prymula76@outlook.com>
parents:
diff changeset
304 printf ("kasowanie x: %d y: %d\n", gh[gh_index].x, gh[gh_index].y);
prymula <prymula76@outlook.com>
parents:
diff changeset
305
prymula <prymula76@outlook.com>
parents:
diff changeset
306 x = gh[gh_index].x;
prymula <prymula76@outlook.com>
parents:
diff changeset
307 y = gh[gh_index].y - 1; // dotyczy elementu znajdujacego sie nad kasowanym elementem
prymula <prymula76@outlook.com>
parents:
diff changeset
308
prymula <prymula76@outlook.com>
parents:
diff changeset
309 // gh[gh_index].x = 0;
prymula <prymula76@outlook.com>
parents:
diff changeset
310 // gh[gh_index].y = 0;
prymula <prymula76@outlook.com>
parents:
diff changeset
311
prymula <prymula76@outlook.com>
parents:
diff changeset
312 /* zmiana statusu elementom znajdujacym sie wyzej
prymula <prymula76@outlook.com>
parents:
diff changeset
313 o ile nie znikaja */
prymula <prymula76@outlook.com>
parents:
diff changeset
314 while (y>1 && field[x][y].status == STAND) {
prymula <prymula76@outlook.com>
parents:
diff changeset
315 field[x][y].status = DROP;
prymula <prymula76@outlook.com>
parents:
diff changeset
316 --y;
prymula <prymula76@outlook.com>
parents:
diff changeset
317 }
prymula <prymula76@outlook.com>
parents:
diff changeset
318
prymula <prymula76@outlook.com>
parents:
diff changeset
319 }while(gh_index--);
prymula <prymula76@outlook.com>
parents:
diff changeset
320 gh_index = 0;
prymula <prymula76@outlook.com>
parents:
diff changeset
321 }
prymula <prymula76@outlook.com>
parents:
diff changeset
322 }
prymula <prymula76@outlook.com>
parents:
diff changeset
323
prymula <prymula76@outlook.com>
parents:
diff changeset
324
prymula <prymula76@outlook.com>
parents:
diff changeset
325
prymula <prymula76@outlook.com>
parents:
diff changeset
326
prymula <prymula76@outlook.com>
parents:
diff changeset
327 /* wyszukuje klocki o tym samym kolorze i zmienia je w dymek*/
prymula <prymula76@outlook.com>
parents:
diff changeset
328 void search_block(SDL_Surface * color, int x, int y) {
prymula <prymula76@outlook.com>
parents:
diff changeset
329
prymula <prymula76@outlook.com>
parents:
diff changeset
330 // printf ("s... type: %p color: %p x: %d y: %d\n", field[x][y].type, color, x, y);
prymula <prymula76@outlook.com>
parents:
diff changeset
331
prymula <prymula76@outlook.com>
parents:
diff changeset
332 if (field[x][y].type == color && field[x][y].status == STAND) {
prymula <prymula76@outlook.com>
parents:
diff changeset
333
prymula <prymula76@outlook.com>
parents:
diff changeset
334 printf ("Fade : %p color %p x: %d y: %d\n", field[x][y].type, color, x, y);
prymula <prymula76@outlook.com>
parents:
diff changeset
335
prymula <prymula76@outlook.com>
parents:
diff changeset
336 field[x][y].status = FADE;
prymula <prymula76@outlook.com>
parents:
diff changeset
337 field[x][y].type = smoke;
prymula <prymula76@outlook.com>
parents:
diff changeset
338 score++;
prymula <prymula76@outlook.com>
parents:
diff changeset
339 bonus++;
prymula <prymula76@outlook.com>
parents:
diff changeset
340
prymula <prymula76@outlook.com>
parents:
diff changeset
341 /* zapamietuje pozycje ktora trzeba bedzie pozniej skasowac */
prymula <prymula76@outlook.com>
parents:
diff changeset
342 // printf ("gh_index = %d\n", gh_index);
prymula <prymula76@outlook.com>
parents:
diff changeset
343 gh[gh_index].x = x;
prymula <prymula76@outlook.com>
parents:
diff changeset
344 gh[gh_index].y = y;
prymula <prymula76@outlook.com>
parents:
diff changeset
345 gh_index++;
prymula <prymula76@outlook.com>
parents:
diff changeset
346
prymula <prymula76@outlook.com>
parents:
diff changeset
347 /* nastepne klocki do sprawdzenia */
prymula <prymula76@outlook.com>
parents:
diff changeset
348 if (y<25) search_block(color, x, y+1);
prymula <prymula76@outlook.com>
parents:
diff changeset
349 if (y>1) search_block(color,x, y-1);
prymula <prymula76@outlook.com>
parents:
diff changeset
350 if (x>0) search_block(color, x-1, y);
prymula <prymula76@outlook.com>
parents:
diff changeset
351 if (x<22) search_block(color,x+1, y);
prymula <prymula76@outlook.com>
parents:
diff changeset
352
prymula <prymula76@outlook.com>
parents:
diff changeset
353
prymula <prymula76@outlook.com>
parents:
diff changeset
354 }
prymula <prymula76@outlook.com>
parents:
diff changeset
355
prymula <prymula76@outlook.com>
parents:
diff changeset
356 }
prymula <prymula76@outlook.com>
parents:
diff changeset
357
prymula <prymula76@outlook.com>
parents:
diff changeset
358 /* szuka pary do skasowania */
prymula <prymula76@outlook.com>
parents:
diff changeset
359 void pre_delete_block(int x, int y) {
prymula <prymula76@outlook.com>
parents:
diff changeset
360
prymula <prymula76@outlook.com>
parents:
diff changeset
361
prymula <prymula76@outlook.com>
parents:
diff changeset
362 // printf ("\npre_delete: %p x: %d y: %d \n\n", field[x][y].type, x, y);
prymula <prymula76@outlook.com>
parents:
diff changeset
363
prymula <prymula76@outlook.com>
parents:
diff changeset
364 /* szuka przynajmniej pary */
prymula <prymula76@outlook.com>
parents:
diff changeset
365 if (field[x][y].type == field[x][y+1].type ||
prymula <prymula76@outlook.com>
parents:
diff changeset
366 field[x][y].type == field[x][y-1].type ||
prymula <prymula76@outlook.com>
parents:
diff changeset
367 field[x][y].type == field[x+1][y].type ||
prymula <prymula76@outlook.com>
parents:
diff changeset
368 field[x][y].type == field[x-1][y].type && field[x][y].status == STAND) {
prymula <prymula76@outlook.com>
parents:
diff changeset
369
prymula <prymula76@outlook.com>
parents:
diff changeset
370
prymula <prymula76@outlook.com>
parents:
diff changeset
371 if (y<25) search_block(field[x][y].type, x, y+1);
prymula <prymula76@outlook.com>
parents:
diff changeset
372 if (y>1) search_block(field[x][y].type, x, y-1);
prymula <prymula76@outlook.com>
parents:
diff changeset
373 if (x>0) search_block(field[x][y].type, x-1, y);
prymula <prymula76@outlook.com>
parents:
diff changeset
374 if (x<22) search_block(field[x][y].type, x+1, y);
prymula <prymula76@outlook.com>
parents:
diff changeset
375
prymula <prymula76@outlook.com>
parents:
diff changeset
376 // raczej niepotrzebne juz
prymula <prymula76@outlook.com>
parents:
diff changeset
377 // field[x][y].status = FADE;
prymula <prymula76@outlook.com>
parents:
diff changeset
378 // field[x][y].type = smoke;
prymula <prymula76@outlook.com>
parents:
diff changeset
379
prymula <prymula76@outlook.com>
parents:
diff changeset
380 }
prymula <prymula76@outlook.com>
parents:
diff changeset
381
prymula <prymula76@outlook.com>
parents:
diff changeset
382
prymula <prymula76@outlook.com>
parents:
diff changeset
383 }
prymula <prymula76@outlook.com>
parents:
diff changeset
384 /* eksplozja elementow znajdujacych sie wokol bomb */
prymula <prymula76@outlook.com>
parents:
diff changeset
385 void power_strike (int x, int y){
prymula <prymula76@outlook.com>
parents:
diff changeset
386
prymula <prymula76@outlook.com>
parents:
diff changeset
387 if (field[x][y].type != bomb && field[x][y].status == STAND) {
prymula <prymula76@outlook.com>
parents:
diff changeset
388
prymula <prymula76@outlook.com>
parents:
diff changeset
389 field[x][y].status = FADE;
prymula <prymula76@outlook.com>
parents:
diff changeset
390 field[x][y].type = explode;
prymula <prymula76@outlook.com>
parents:
diff changeset
391
prymula <prymula76@outlook.com>
parents:
diff changeset
392 /* zapamietuje pozycje ktora trzeba bedzie pozniej skasowac */
prymula <prymula76@outlook.com>
parents:
diff changeset
393 gh[gh_index].x = x;
prymula <prymula76@outlook.com>
parents:
diff changeset
394 gh[gh_index].y = y;
prymula <prymula76@outlook.com>
parents:
diff changeset
395 gh_index++;
prymula <prymula76@outlook.com>
parents:
diff changeset
396 }
prymula <prymula76@outlook.com>
parents:
diff changeset
397
prymula <prymula76@outlook.com>
parents:
diff changeset
398 }
prymula <prymula76@outlook.com>
parents:
diff changeset
399
prymula <prymula76@outlook.com>
parents:
diff changeset
400 /* szuka bomb i dokonuje eksplozji */
prymula <prymula76@outlook.com>
parents:
diff changeset
401 void search_bomb(int x, int y) {
prymula <prymula76@outlook.com>
parents:
diff changeset
402
prymula <prymula76@outlook.com>
parents:
diff changeset
403 if (field[x][y].type == bomb && field[x][y].status == STAND) {
prymula <prymula76@outlook.com>
parents:
diff changeset
404
prymula <prymula76@outlook.com>
parents:
diff changeset
405 printf ("Fade : %p bomb %p x: %d y: %d\n", field[x][y].type, bomb, x, y);
prymula <prymula76@outlook.com>
parents:
diff changeset
406
prymula <prymula76@outlook.com>
parents:
diff changeset
407 field[x][y].status = FADE;
prymula <prymula76@outlook.com>
parents:
diff changeset
408 field[x][y].type = explode;
prymula <prymula76@outlook.com>
parents:
diff changeset
409
prymula <prymula76@outlook.com>
parents:
diff changeset
410 /* zapamietuje pozycje ktora trzeba bedzie pozniej skasowac */
prymula <prymula76@outlook.com>
parents:
diff changeset
411 gh[gh_index].x = x;
prymula <prymula76@outlook.com>
parents:
diff changeset
412 gh[gh_index].y = y;
prymula <prymula76@outlook.com>
parents:
diff changeset
413 gh_index++;
prymula <prymula76@outlook.com>
parents:
diff changeset
414
prymula <prymula76@outlook.com>
parents:
diff changeset
415 /* nastepne klocki do sprawdzenia */
prymula <prymula76@outlook.com>
parents:
diff changeset
416 if (y<25) search_bomb(x, y+1);
prymula <prymula76@outlook.com>
parents:
diff changeset
417 if (y>1) search_bomb(x, y-1);
prymula <prymula76@outlook.com>
parents:
diff changeset
418 if (x>0) search_bomb(x-1, y);
prymula <prymula76@outlook.com>
parents:
diff changeset
419 if (x<22) search_bomb(x+1, y);
prymula <prymula76@outlook.com>
parents:
diff changeset
420 if (x>0 && y>1) search_bomb(x-1, y-1);
prymula <prymula76@outlook.com>
parents:
diff changeset
421 if (x<22 && y>1) search_bomb(x+1, y-1);
prymula <prymula76@outlook.com>
parents:
diff changeset
422 if (x>0 && y<25) search_bomb(x-1, y+1);
prymula <prymula76@outlook.com>
parents:
diff changeset
423 if (x<22 && y<25) search_bomb(x+1, y+1);
prymula <prymula76@outlook.com>
parents:
diff changeset
424
prymula <prymula76@outlook.com>
parents:
diff changeset
425 /* sila razenia */
prymula <prymula76@outlook.com>
parents:
diff changeset
426 if (y<25) power_strike(x, y+1);
prymula <prymula76@outlook.com>
parents:
diff changeset
427 if (y>1) power_strike(x, y-1);
prymula <prymula76@outlook.com>
parents:
diff changeset
428 if (x>0) power_strike(x-1, y);
prymula <prymula76@outlook.com>
parents:
diff changeset
429 if (x<22) power_strike(x+1, y);
prymula <prymula76@outlook.com>
parents:
diff changeset
430 if (x>0 && y>1) power_strike(x-1, y-1);
prymula <prymula76@outlook.com>
parents:
diff changeset
431 if (x<22 && y>1) power_strike(x+1, y-1);
prymula <prymula76@outlook.com>
parents:
diff changeset
432 if (x>0 && y<25) power_strike(x-1, y+1);
prymula <prymula76@outlook.com>
parents:
diff changeset
433 if (x<22 && y<25) power_strike(x+1, y+1);
prymula <prymula76@outlook.com>
parents:
diff changeset
434
prymula <prymula76@outlook.com>
parents:
diff changeset
435
prymula <prymula76@outlook.com>
parents:
diff changeset
436 }
prymula <prymula76@outlook.com>
parents:
diff changeset
437
prymula <prymula76@outlook.com>
parents:
diff changeset
438 }
prymula <prymula76@outlook.com>
parents:
diff changeset
439
prymula <prymula76@outlook.com>
parents:
diff changeset
440 /* szuka pary bomb */
prymula <prymula76@outlook.com>
parents:
diff changeset
441 void pre_delete_bomb(int x, int y) {
prymula <prymula76@outlook.com>
parents:
diff changeset
442
prymula <prymula76@outlook.com>
parents:
diff changeset
443 /* szuka przynajmniej pary */
prymula <prymula76@outlook.com>
parents:
diff changeset
444 if (field[x][y].type == field[x][y+1].type ||
prymula <prymula76@outlook.com>
parents:
diff changeset
445 field[x][y].type == field[x][y-1].type ||
prymula <prymula76@outlook.com>
parents:
diff changeset
446 field[x][y].type == field[x+1][y].type ||
prymula <prymula76@outlook.com>
parents:
diff changeset
447 field[x][y].type == field[x-1][y].type && field[x][y].status == STAND) {
prymula <prymula76@outlook.com>
parents:
diff changeset
448
prymula <prymula76@outlook.com>
parents:
diff changeset
449
prymula <prymula76@outlook.com>
parents:
diff changeset
450 if (y<25) search_bomb(x, y+1);
prymula <prymula76@outlook.com>
parents:
diff changeset
451 if (y>1) search_bomb(x, y-1);
prymula <prymula76@outlook.com>
parents:
diff changeset
452 if (x>0) search_bomb(x-1, y);
prymula <prymula76@outlook.com>
parents:
diff changeset
453 if (x<22) search_bomb(x+1, y);
prymula <prymula76@outlook.com>
parents:
diff changeset
454
prymula <prymula76@outlook.com>
parents:
diff changeset
455 }
prymula <prymula76@outlook.com>
parents:
diff changeset
456 }
prymula <prymula76@outlook.com>
parents:
diff changeset
457
prymula <prymula76@outlook.com>
parents:
diff changeset
458 /* sprawdza czy mozna dosunac elemnty do prawej strony */
prymula <prymula76@outlook.com>
parents:
diff changeset
459 //void check_before_field(void) {
prymula <prymula76@outlook.com>
parents:
diff changeset
460 void on_the_right(void) {
prymula <prymula76@outlook.com>
parents:
diff changeset
461
prymula <prymula76@outlook.com>
parents:
diff changeset
462 int i,j,k,l;
prymula <prymula76@outlook.com>
parents:
diff changeset
463
prymula <prymula76@outlook.com>
parents:
diff changeset
464 for (i=21; i>=0; --i) {
prymula <prymula76@outlook.com>
parents:
diff changeset
465
prymula <prymula76@outlook.com>
parents:
diff changeset
466 /* jesli pole przed elementem jest puste */
prymula <prymula76@outlook.com>
parents:
diff changeset
467 if (!field[i+1][25].type && field[i][25].status == STAND) {
prymula <prymula76@outlook.com>
parents:
diff changeset
468
prymula <prymula76@outlook.com>
parents:
diff changeset
469 /* sprawdza jak wysoko siegaja kolocki */
prymula <prymula76@outlook.com>
parents:
diff changeset
470 k=0;
prymula <prymula76@outlook.com>
parents:
diff changeset
471 // while(field[i][25-k].type && field[i][25-k].status == STAND)k++;
prymula <prymula76@outlook.com>
parents:
diff changeset
472 while(field[i][25-k].type)k++;
prymula <prymula76@outlook.com>
parents:
diff changeset
473 ++k;
prymula <prymula76@outlook.com>
parents:
diff changeset
474
prymula <prymula76@outlook.com>
parents:
diff changeset
475 // printf (" K: %d\n", k);
prymula <prymula76@outlook.com>
parents:
diff changeset
476
prymula <prymula76@outlook.com>
parents:
diff changeset
477 /* sprawdza czy nie wystaja jakies klocki na przedpolu */
prymula <prymula76@outlook.com>
parents:
diff changeset
478 for (l=0; l<k; l++) {
prymula <prymula76@outlook.com>
parents:
diff changeset
479 /* jesli jest jakis klocek to wyskakuje z petli */
prymula <prymula76@outlook.com>
parents:
diff changeset
480 if (field[i+1][25-l].type) break;
prymula <prymula76@outlook.com>
parents:
diff changeset
481 }
prymula <prymula76@outlook.com>
parents:
diff changeset
482 // printf (" L: %d\n", l);
prymula <prymula76@outlook.com>
parents:
diff changeset
483
prymula <prymula76@outlook.com>
parents:
diff changeset
484 /* gdy brak elementow na przedpolu mozna przesowac */
prymula <prymula76@outlook.com>
parents:
diff changeset
485 if (k == l) {
prymula <prymula76@outlook.com>
parents:
diff changeset
486 j=25;
prymula <prymula76@outlook.com>
parents:
diff changeset
487 /* przesowa kolejno elementy ustawione pionowo oprocz
prymula <prymula76@outlook.com>
parents:
diff changeset
488 eksplozji i zanikniec */
prymula <prymula76@outlook.com>
parents:
diff changeset
489 while (field[i][j].type && field[i][j].status != FADE) {
prymula <prymula76@outlook.com>
parents:
diff changeset
490
prymula <prymula76@outlook.com>
parents:
diff changeset
491 field[i+1][j] = field[i][j];
prymula <prymula76@outlook.com>
parents:
diff changeset
492
prymula <prymula76@outlook.com>
parents:
diff changeset
493 field[i][j].status = 0;
prymula <prymula76@outlook.com>
parents:
diff changeset
494 field[i][j].type = NULL;
prymula <prymula76@outlook.com>
parents:
diff changeset
495 --j;
prymula <prymula76@outlook.com>
parents:
diff changeset
496 }
prymula <prymula76@outlook.com>
parents:
diff changeset
497 }
prymula <prymula76@outlook.com>
parents:
diff changeset
498
prymula <prymula76@outlook.com>
parents:
diff changeset
499 }
prymula <prymula76@outlook.com>
parents:
diff changeset
500 }
prymula <prymula76@outlook.com>
parents:
diff changeset
501
prymula <prymula76@outlook.com>
parents:
diff changeset
502 }
prymula <prymula76@outlook.com>
parents:
diff changeset
503
prymula <prymula76@outlook.com>
parents:
diff changeset
504
prymula <prymula76@outlook.com>
parents:
diff changeset
505 void start_game(void) {
prymula <prymula76@outlook.com>
parents:
diff changeset
506
prymula <prymula76@outlook.com>
parents:
diff changeset
507 int done;
prymula <prymula76@outlook.com>
parents:
diff changeset
508 char buffor[100];
prymula <prymula76@outlook.com>
parents:
diff changeset
509 int i, j, x, y;
prymula <prymula76@outlook.com>
parents:
diff changeset
510 int move=1; // zmienna odpowiedzialna za przesowanie elem. gornel listwy
prymula <prymula76@outlook.com>
parents:
diff changeset
511 int over =-1; // zmienna odpowiedzialna za pojawienie sie napisu game over
prymula <prymula76@outlook.com>
parents:
diff changeset
512 int virtual_level, level;
prymula <prymula76@outlook.com>
parents:
diff changeset
513 int vis, drop_slat, pic;
prymula <prymula76@outlook.com>
parents:
diff changeset
514 SDL_Rect srcrect, destrect;
prymula <prymula76@outlook.com>
parents:
diff changeset
515 SDL_bool only_bomb = SDL_FALSE;
prymula <prymula76@outlook.com>
parents:
diff changeset
516
prymula <prymula76@outlook.com>
parents:
diff changeset
517 /*
prymula <prymula76@outlook.com>
parents:
diff changeset
518 struct data_levels data_level[10] = {
prymula <prymula76@outlook.com>
parents:
diff changeset
519 {85, 200, 0},
prymula <prymula76@outlook.com>
parents:
diff changeset
520 {90, 200, 0},
prymula <prymula76@outlook.com>
parents:
diff changeset
521 {99, 150, 0},
prymula <prymula76@outlook.com>
parents:
diff changeset
522 {99, 150, 0},
prymula <prymula76@outlook.com>
parents:
diff changeset
523 {106, 150, 0},
prymula <prymula76@outlook.com>
parents:
diff changeset
524 {111, 100, 0},
prymula <prymula76@outlook.com>
parents:
diff changeset
525 {111, 150, 1},
prymula <prymula76@outlook.com>
parents:
diff changeset
526 {111, 100, 1},
prymula <prymula76@outlook.com>
parents:
diff changeset
527 {116, 150, 1},
prymula <prymula76@outlook.com>
parents:
diff changeset
528 {116, 100, 1}};
prymula <prymula76@outlook.com>
parents:
diff changeset
529 */
prymula <prymula76@outlook.com>
parents:
diff changeset
530 struct data_levels data_level[10] = {
prymula <prymula76@outlook.com>
parents:
diff changeset
531 {85, 200, 0},
prymula <prymula76@outlook.com>
parents:
diff changeset
532 {90, 200, 0},
prymula <prymula76@outlook.com>
parents:
diff changeset
533 {99, 150, 0},
prymula <prymula76@outlook.com>
parents:
diff changeset
534 {99, 150, 0},
prymula <prymula76@outlook.com>
parents:
diff changeset
535 {106, 200, 0},
prymula <prymula76@outlook.com>
parents:
diff changeset
536 {106, 150, 0},
prymula <prymula76@outlook.com>
parents:
diff changeset
537 {85, 200, 1},
prymula <prymula76@outlook.com>
parents:
diff changeset
538 {90, 200, 1},
prymula <prymula76@outlook.com>
parents:
diff changeset
539 {99, 150, 1},
prymula <prymula76@outlook.com>
parents:
diff changeset
540 {111, 100, 1}};
prymula <prymula76@outlook.com>
parents:
diff changeset
541
prymula <prymula76@outlook.com>
parents:
diff changeset
542 virtual_level = level = start_level;
prymula <prymula76@outlook.com>
parents:
diff changeset
543 score = 0;
prymula <prymula76@outlook.com>
parents:
diff changeset
544 srand(time(NULL));
prymula <prymula76@outlook.com>
parents:
diff changeset
545
prymula <prymula76@outlook.com>
parents:
diff changeset
546 destrect = set_rect(0,0,screen->w,screen->h);
prymula <prymula76@outlook.com>
parents:
diff changeset
547 SDL_FillRect(screen,&destrect,0);
prymula <prymula76@outlook.com>
parents:
diff changeset
548 //SDL_Flip(screen);
prymula <prymula76@outlook.com>
parents:
diff changeset
549
prymula <prymula76@outlook.com>
parents:
diff changeset
550
prymula <prymula76@outlook.com>
parents:
diff changeset
551 sprintf (buffor, "%d", tab_hiscores[0].score);
prymula <prymula76@outlook.com>
parents:
diff changeset
552 var_hiscore_inscription = (SDL_Surface *) prepare_text(255, 255, 255, buffor);
prymula <prymula76@outlook.com>
parents:
diff changeset
553
prymula <prymula76@outlook.com>
parents:
diff changeset
554 new_level:
prymula <prymula76@outlook.com>
parents:
diff changeset
555 bonus = 0;
prymula <prymula76@outlook.com>
parents:
diff changeset
556
prymula <prymula76@outlook.com>
parents:
diff changeset
557 sprintf(buffor, "%d", virtual_level);
prymula <prymula76@outlook.com>
parents:
diff changeset
558 var_level_inscription = (SDL_Surface *) prepare_text(255, 255, 255, buffor);
prymula <prymula76@outlook.com>
parents:
diff changeset
559
prymula <prymula76@outlook.com>
parents:
diff changeset
560 pic = rand()%N_PIC;
prymula <prymula76@outlook.com>
parents:
diff changeset
561 load_background(pic);
prymula <prymula76@outlook.com>
parents:
diff changeset
562
prymula <prymula76@outlook.com>
parents:
diff changeset
563
prymula <prymula76@outlook.com>
parents:
diff changeset
564 drop_slat = data_level[level-1].drop;
prymula <prymula76@outlook.com>
parents:
diff changeset
565 vis = 15;
prymula <prymula76@outlook.com>
parents:
diff changeset
566
prymula <prymula76@outlook.com>
parents:
diff changeset
567 /* ustawia murek */
prymula <prymula76@outlook.com>
parents:
diff changeset
568 if (data_level[level-1].wall) {
prymula <prymula76@outlook.com>
parents:
diff changeset
569 field[10][25].type = wall;
prymula <prymula76@outlook.com>
parents:
diff changeset
570 field[10][25].status = WALL;
prymula <prymula76@outlook.com>
parents:
diff changeset
571 }
prymula <prymula76@outlook.com>
parents:
diff changeset
572
prymula <prymula76@outlook.com>
parents:
diff changeset
573
prymula <prymula76@outlook.com>
parents:
diff changeset
574 /* wypelnia studnie elementami */
prymula <prymula76@outlook.com>
parents:
diff changeset
575 fill_board(&data_level[level-1]);
prymula <prymula76@outlook.com>
parents:
diff changeset
576
prymula <prymula76@outlook.com>
parents:
diff changeset
577 done = 0;
prymula <prymula76@outlook.com>
parents:
diff changeset
578 while (!done)
prymula <prymula76@outlook.com>
parents:
diff changeset
579 {
prymula <prymula76@outlook.com>
parents:
diff changeset
580
prymula <prymula76@outlook.com>
parents:
diff changeset
581
prymula <prymula76@outlook.com>
parents:
diff changeset
582
prymula <prymula76@outlook.com>
parents:
diff changeset
583
prymula <prymula76@outlook.com>
parents:
diff changeset
584 set_background();
prymula <prymula76@outlook.com>
parents:
diff changeset
585
prymula <prymula76@outlook.com>
parents:
diff changeset
586 if (use_net) set_net();
prymula <prymula76@outlook.com>
parents:
diff changeset
587
prymula <prymula76@outlook.com>
parents:
diff changeset
588 /* sprawdza czy na planszy sa jakies klocki */
prymula <prymula76@outlook.com>
parents:
diff changeset
589 if (shortage_blocks()) {
prymula <prymula76@outlook.com>
parents:
diff changeset
590 virtual_level++;
prymula <prymula76@outlook.com>
parents:
diff changeset
591 if (level < 10) level++;
prymula <prymula76@outlook.com>
parents:
diff changeset
592
prymula <prymula76@outlook.com>
parents:
diff changeset
593 SDL_FreeSurface(var_level_inscription);
prymula <prymula76@outlook.com>
parents:
diff changeset
594
prymula <prymula76@outlook.com>
parents:
diff changeset
595 score += bonus *3;
prymula <prymula76@outlook.com>
parents:
diff changeset
596 goto new_level;
prymula <prymula76@outlook.com>
parents:
diff changeset
597 }
prymula <prymula76@outlook.com>
parents:
diff changeset
598
prymula <prymula76@outlook.com>
parents:
diff changeset
599 delete_elements();
prymula <prymula76@outlook.com>
parents:
diff changeset
600
prymula <prymula76@outlook.com>
parents:
diff changeset
601
prymula <prymula76@outlook.com>
parents:
diff changeset
602 SDL_Event event;
prymula <prymula76@outlook.com>
parents:
diff changeset
603
prymula <prymula76@outlook.com>
parents:
diff changeset
604 /* Check for events */
prymula <prymula76@outlook.com>
parents:
diff changeset
605 while (SDL_PollEvent (&event))
prymula <prymula76@outlook.com>
parents:
diff changeset
606 {
prymula <prymula76@outlook.com>
parents:
diff changeset
607 switch (event.type)
prymula <prymula76@outlook.com>
parents:
diff changeset
608 {
prymula <prymula76@outlook.com>
parents:
diff changeset
609 case SDL_KEYDOWN:
prymula <prymula76@outlook.com>
parents:
diff changeset
610 printf("Nacini�o klawisz: %s\n",
prymula <prymula76@outlook.com>
parents:
diff changeset
611 SDL_GetKeyName(event.key.keysym.sym));
prymula <prymula76@outlook.com>
parents:
diff changeset
612
prymula <prymula76@outlook.com>
parents:
diff changeset
613 switch (event.key.keysym.sym) {
prymula <prymula76@outlook.com>
parents:
diff changeset
614 case SDLK_ESCAPE:
prymula <prymula76@outlook.com>
parents:
diff changeset
615 done = 1;
prymula <prymula76@outlook.com>
parents:
diff changeset
616 break;
prymula <prymula76@outlook.com>
parents:
diff changeset
617 case SDLK_b:
prymula <prymula76@outlook.com>
parents:
diff changeset
618 if (only_bomb) only_bomb=SDL_FALSE;
prymula <prymula76@outlook.com>
parents:
diff changeset
619 else only_bomb=SDL_TRUE;
prymula <prymula76@outlook.com>
parents:
diff changeset
620 break;
prymula <prymula76@outlook.com>
parents:
diff changeset
621 }
prymula <prymula76@outlook.com>
parents:
diff changeset
622 break;
prymula <prymula76@outlook.com>
parents:
diff changeset
623 case SDL_QUIT:
prymula <prymula76@outlook.com>
parents:
diff changeset
624 exit(0);
prymula <prymula76@outlook.com>
parents:
diff changeset
625 break;
prymula <prymula76@outlook.com>
parents:
diff changeset
626 case SDL_MOUSEMOTION:
prymula <prymula76@outlook.com>
parents:
diff changeset
627 // if (event.motion.state & SDL_BUTTON(1))
prymula <prymula76@outlook.com>
parents:
diff changeset
628 // printf("Ruch z pierwszym przyciskeim myszy\n");
prymula <prymula76@outlook.com>
parents:
diff changeset
629
prymula <prymula76@outlook.com>
parents:
diff changeset
630 // if (event.motion.state & SDL_BUTTON(2))
prymula <prymula76@outlook.com>
parents:
diff changeset
631 // printf("Ruch z drugim przyciskiem myszy\n");
prymula <prymula76@outlook.com>
parents:
diff changeset
632
prymula <prymula76@outlook.com>
parents:
diff changeset
633 // if (event.motion.state & SDL_BUTTON(3))
prymula <prymula76@outlook.com>
parents:
diff changeset
634 // printf("Ruch z trzecim przyciskiem myszy\n");
prymula <prymula76@outlook.com>
parents:
diff changeset
635
prymula <prymula76@outlook.com>
parents:
diff changeset
636 // printf("Przesuni�o myszk�o %d,%d\n",
prymula <prymula76@outlook.com>
parents:
diff changeset
637 // event.motion.xrel, event.motion.yrel);
prymula <prymula76@outlook.com>
parents:
diff changeset
638 case SDL_MOUSEBUTTONDOWN:
prymula <prymula76@outlook.com>
parents:
diff changeset
639 // printf("Nacini�o przycisk o numerze %d na "
prymula <prymula76@outlook.com>
parents:
diff changeset
640 // "punkcie o wsp�rz�nych %d,%d\n", event.button.button,
prymula <prymula76@outlook.com>
parents:
diff changeset
641 // event.button.x, event.button.y);
prymula <prymula76@outlook.com>
parents:
diff changeset
642
prymula <prymula76@outlook.com>
parents:
diff changeset
643
prymula <prymula76@outlook.com>
parents:
diff changeset
644 if (event.button.button &&
prymula <prymula76@outlook.com>
parents:
diff changeset
645 event.button.x >= X_HIGH_SLAT +1 &&
prymula <prymula76@outlook.com>
parents:
diff changeset
646 event.button.y >= Y_HIGH_SLAT &&
prymula <prymula76@outlook.com>
parents:
diff changeset
647 event.button.x <= X_SIZE_HIGH_SLAT &&
prymula <prymula76@outlook.com>
parents:
diff changeset
648 event.button.y <= (Y_SIZE_HIGH_SLAT + Y_HIGH_SLAT)) {
prymula <prymula76@outlook.com>
parents:
diff changeset
649
prymula <prymula76@outlook.com>
parents:
diff changeset
650 printf ("opadanie\n");
prymula <prymula76@outlook.com>
parents:
diff changeset
651 drop_from_high_slat();
prymula <prymula76@outlook.com>
parents:
diff changeset
652 move = 0;
prymula <prymula76@outlook.com>
parents:
diff changeset
653 drop_slat = data_level[level-1].drop;
prymula <prymula76@outlook.com>
parents:
diff changeset
654 }
prymula <prymula76@outlook.com>
parents:
diff changeset
655 else if (event.button.button &&
prymula <prymula76@outlook.com>
parents:
diff changeset
656 event.button.x >= X_ACTION &&
prymula <prymula76@outlook.com>
parents:
diff changeset
657 event.button.y >= Y_ACTION &&
prymula <prymula76@outlook.com>
parents:
diff changeset
658 event.button.x <= X_SIZE_ACTION &&
prymula <prymula76@outlook.com>
parents:
diff changeset
659 event.button.y <= Y_SIZE_ACTION) {
prymula <prymula76@outlook.com>
parents:
diff changeset
660
prymula <prymula76@outlook.com>
parents:
diff changeset
661 x=event.button.x/FIELD_SIZE;
prymula <prymula76@outlook.com>
parents:
diff changeset
662 y=event.button.y/FIELD_SIZE-2;
prymula <prymula76@outlook.com>
parents:
diff changeset
663
prymula <prymula76@outlook.com>
parents:
diff changeset
664 if (field[x][y].type == bomb)
prymula <prymula76@outlook.com>
parents:
diff changeset
665 pre_delete_bomb(x, y);
prymula <prymula76@outlook.com>
parents:
diff changeset
666 else if (field[x][y].type)
prymula <prymula76@outlook.com>
parents:
diff changeset
667 pre_delete_block(x, y);
prymula <prymula76@outlook.com>
parents:
diff changeset
668
prymula <prymula76@outlook.com>
parents:
diff changeset
669 }
prymula <prymula76@outlook.com>
parents:
diff changeset
670
prymula <prymula76@outlook.com>
parents:
diff changeset
671
prymula <prymula76@outlook.com>
parents:
diff changeset
672 }
prymula <prymula76@outlook.com>
parents:
diff changeset
673 }
prymula <prymula76@outlook.com>
parents:
diff changeset
674
prymula <prymula76@outlook.com>
parents:
diff changeset
675
prymula <prymula76@outlook.com>
parents:
diff changeset
676 drop_slat--;
prymula <prymula76@outlook.com>
parents:
diff changeset
677 /* gdy zero program sam zrzuca klocki z gornej listwy */
prymula <prymula76@outlook.com>
parents:
diff changeset
678 if (!drop_slat) {
prymula <prymula76@outlook.com>
parents:
diff changeset
679 drop_from_high_slat();
prymula <prymula76@outlook.com>
parents:
diff changeset
680 move = 0;
prymula <prymula76@outlook.com>
parents:
diff changeset
681 drop_slat = data_level[level-1].drop;
prymula <prymula76@outlook.com>
parents:
diff changeset
682 }
prymula <prymula76@outlook.com>
parents:
diff changeset
683
prymula <prymula76@outlook.com>
parents:
diff changeset
684
prymula <prymula76@outlook.com>
parents:
diff changeset
685 /* przesowa klocki na gornej listwie zapobiegajac przy okazji
prymula <prymula76@outlook.com>
parents:
diff changeset
686 opadaniu pod katem */
prymula <prymula76@outlook.com>
parents:
diff changeset
687 if (!only_bomb){
prymula <prymula76@outlook.com>
parents:
diff changeset
688 if (move) high_slat(&data_level[level-1], SDL_FALSE);
prymula <prymula76@outlook.com>
parents:
diff changeset
689 else move = 1;
prymula <prymula76@outlook.com>
parents:
diff changeset
690 }
prymula <prymula76@outlook.com>
parents:
diff changeset
691 else {
prymula <prymula76@outlook.com>
parents:
diff changeset
692 if (move) high_slat(&data_level[level-1], SDL_TRUE);
prymula <prymula76@outlook.com>
parents:
diff changeset
693 else move = 1;
prymula <prymula76@outlook.com>
parents:
diff changeset
694 }
prymula <prymula76@outlook.com>
parents:
diff changeset
695
prymula <prymula76@outlook.com>
parents:
diff changeset
696 /* przesowa elemnty do prawej strony */
prymula <prymula76@outlook.com>
parents:
diff changeset
697 on_the_right();
prymula <prymula76@outlook.com>
parents:
diff changeset
698
prymula <prymula76@outlook.com>
parents:
diff changeset
699 /* opuszcza elementy */
prymula <prymula76@outlook.com>
parents:
diff changeset
700 drop_elements();
prymula <prymula76@outlook.com>
parents:
diff changeset
701
prymula <prymula76@outlook.com>
parents:
diff changeset
702
prymula <prymula76@outlook.com>
parents:
diff changeset
703 // for (j=0; j<26; ++j) {
prymula <prymula76@outlook.com>
parents:
diff changeset
704 // for (i=0; i<23; ++i) {
prymula <prymula76@outlook.com>
parents:
diff changeset
705
prymula <prymula76@outlook.com>
parents:
diff changeset
706 // if (field[i][j].type)
prymula <prymula76@outlook.com>
parents:
diff changeset
707 // printf ("j: %d i: %d type: %p\n", j, i, field[i][j].type);
prymula <prymula76@outlook.com>
parents:
diff changeset
708 // }
prymula <prymula76@outlook.com>
parents:
diff changeset
709 // }
prymula <prymula76@outlook.com>
parents:
diff changeset
710 // printf("\n\n");
prymula <prymula76@outlook.com>
parents:
diff changeset
711
prymula <prymula76@outlook.com>
parents:
diff changeset
712
prymula <prymula76@outlook.com>
parents:
diff changeset
713
prymula <prymula76@outlook.com>
parents:
diff changeset
714 /* umieszczanie elementow na planszy */
prymula <prymula76@outlook.com>
parents:
diff changeset
715 srcrect = set_rect(0,0,FIELD_SIZE,FIELD_SIZE);
prymula <prymula76@outlook.com>
parents:
diff changeset
716 for (j=0; j<26; ++j) {
prymula <prymula76@outlook.com>
parents:
diff changeset
717 for (i=0; i<23; ++i) {
prymula <prymula76@outlook.com>
parents:
diff changeset
718
prymula <prymula76@outlook.com>
parents:
diff changeset
719 // if (field[i][j].type)
prymula <prymula76@outlook.com>
parents:
diff changeset
720 // printf ("j: %d i: %d type: %p\n", j, i, field[i][j].type);
prymula <prymula76@outlook.com>
parents:
diff changeset
721
prymula <prymula76@outlook.com>
parents:
diff changeset
722 destrect = set_rect(FIELD_SIZE * i,FIELD_SIZE * j+ 40, FIELD_SIZE, FIELD_SIZE);
prymula <prymula76@outlook.com>
parents:
diff changeset
723 SDL_BlitSurface(field[i][j].type,&srcrect, screen,&destrect);
prymula <prymula76@outlook.com>
parents:
diff changeset
724 }
prymula <prymula76@outlook.com>
parents:
diff changeset
725 }
prymula <prymula76@outlook.com>
parents:
diff changeset
726
prymula <prymula76@outlook.com>
parents:
diff changeset
727 // for (j=0; j<20; ++j) {
prymula <prymula76@outlook.com>
parents:
diff changeset
728 // for (i=0; i<23; ++i) {
prymula <prymula76@outlook.com>
parents:
diff changeset
729 // if (field[i][j].status == DROP) putchar('|');
prymula <prymula76@outlook.com>
parents:
diff changeset
730 // else if (field[i][j].status == STAND) putchar ('=');
prymula <prymula76@outlook.com>
parents:
diff changeset
731 // else if (field[i][j].status == 0) putchar(' ');
prymula <prymula76@outlook.com>
parents:
diff changeset
732 // }
prymula <prymula76@outlook.com>
parents:
diff changeset
733 // putchar('\n');
prymula <prymula76@outlook.com>
parents:
diff changeset
734 // }
prymula <prymula76@outlook.com>
parents:
diff changeset
735
prymula <prymula76@outlook.com>
parents:
diff changeset
736 /* przy rozpoczeciu poziomu wyswietla numer poziomu */
prymula <prymula76@outlook.com>
parents:
diff changeset
737 if (vis) {
prymula <prymula76@outlook.com>
parents:
diff changeset
738 sprintf (buffor, " LEVEL %d", virtual_level);
prymula <prymula76@outlook.com>
parents:
diff changeset
739 print_inscription(buffor, 190, 200);
prymula <prymula76@outlook.com>
parents:
diff changeset
740 vis -= 1;
prymula <prymula76@outlook.com>
parents:
diff changeset
741 }
prymula <prymula76@outlook.com>
parents:
diff changeset
742
prymula <prymula76@outlook.com>
parents:
diff changeset
743 /* sprawdza czy nie ma przepelnienia */
prymula <prymula76@outlook.com>
parents:
diff changeset
744 if (behind_high() && over == -1)
prymula <prymula76@outlook.com>
parents:
diff changeset
745 over = 15;
prymula <prymula76@outlook.com>
parents:
diff changeset
746 /* wyswietla napis game over */
prymula <prymula76@outlook.com>
parents:
diff changeset
747 if (!over)
prymula <prymula76@outlook.com>
parents:
diff changeset
748 done = 1;
prymula <prymula76@outlook.com>
parents:
diff changeset
749 else if (over > 0) {
prymula <prymula76@outlook.com>
parents:
diff changeset
750 strcpy(buffor, "GAME OVER");
prymula <prymula76@outlook.com>
parents:
diff changeset
751 print_inscription(buffor, 160, 200);
prymula <prymula76@outlook.com>
parents:
diff changeset
752 // SDL_UpdateRect(screen, 160, 200, 136, 32);
prymula <prymula76@outlook.com>
parents:
diff changeset
753 over -= 1;
prymula <prymula76@outlook.com>
parents:
diff changeset
754 }
prymula <prymula76@outlook.com>
parents:
diff changeset
755
prymula <prymula76@outlook.com>
parents:
diff changeset
756 sprintf (buffor, "%d", score);
prymula <prymula76@outlook.com>
parents:
diff changeset
757 print_inscription(buffor, 20, Y_ALL_INSCRIPTION);
prymula <prymula76@outlook.com>
parents:
diff changeset
758 draw_text(X_LEVEL_INSCRIPTION, Y_ALL_INSCRIPTION, var_level_inscription);
prymula <prymula76@outlook.com>
parents:
diff changeset
759 draw_text(X_HISCORE_INSCRIPTION, Y_ALL_INSCRIPTION, var_hiscore_inscription);
prymula <prymula76@outlook.com>
parents:
diff changeset
760
prymula <prymula76@outlook.com>
parents:
diff changeset
761 // printf ("wysokosc : %d \n", var_hiscore_inscription->h);
prymula <prymula76@outlook.com>
parents:
diff changeset
762
prymula <prymula76@outlook.com>
parents:
diff changeset
763 // SDL_Flip(screen);
prymula <prymula76@outlook.com>
parents:
diff changeset
764
prymula <prymula76@outlook.com>
parents:
diff changeset
765
prymula <prymula76@outlook.com>
parents:
diff changeset
766
prymula <prymula76@outlook.com>
parents:
diff changeset
767
prymula <prymula76@outlook.com>
parents:
diff changeset
768
prymula <prymula76@outlook.com>
parents:
diff changeset
769 dest = set_rect(0, 0, screen->w, screen->h);
prymula <prymula76@outlook.com>
parents:
diff changeset
770 //SDL_FillRect(screen, &dest, SDL_MapRGB(screen->format, 255, 255, 255));
prymula <prymula76@outlook.com>
parents:
diff changeset
771
prymula <prymula76@outlook.com>
parents:
diff changeset
772 source = set_rect(0, 0, screen->w, screen->h);
prymula <prymula76@outlook.com>
parents:
diff changeset
773
prymula <prymula76@outlook.com>
parents:
diff changeset
774 tex_screen = SDL_CreateTextureFromSurface(renderer, screen);
prymula <prymula76@outlook.com>
parents:
diff changeset
775 SDL_RenderClear ( renderer );
prymula <prymula76@outlook.com>
parents:
diff changeset
776 SDL_RenderCopy(renderer, tex_screen,&source,&dest);
prymula <prymula76@outlook.com>
parents:
diff changeset
777 SDL_RenderPresent(renderer);
prymula <prymula76@outlook.com>
parents:
diff changeset
778 SDL_DestroyTexture(tex_screen);
prymula <prymula76@outlook.com>
parents:
diff changeset
779
prymula <prymula76@outlook.com>
parents:
diff changeset
780
prymula <prymula76@outlook.com>
parents:
diff changeset
781
prymula <prymula76@outlook.com>
parents:
diff changeset
782
prymula <prymula76@outlook.com>
parents:
diff changeset
783
prymula <prymula76@outlook.com>
parents:
diff changeset
784 SDL_Delay(300);
prymula <prymula76@outlook.com>
parents:
diff changeset
785 }
prymula <prymula76@outlook.com>
parents:
diff changeset
786
prymula <prymula76@outlook.com>
parents:
diff changeset
787
prymula <prymula76@outlook.com>
parents:
diff changeset
788 /* sprawdza czy jest mozliwosc wpisu */
prymula <prymula76@outlook.com>
parents:
diff changeset
789 if (score > tab_hiscores[4].score) {
prymula <prymula76@outlook.com>
parents:
diff changeset
790 get_name_of_player();
prymula <prymula76@outlook.com>
parents:
diff changeset
791 }
prymula <prymula76@outlook.com>
parents:
diff changeset
792
prymula <prymula76@outlook.com>
parents:
diff changeset
793 zero_field();
prymula <prymula76@outlook.com>
parents:
diff changeset
794
prymula <prymula76@outlook.com>
parents:
diff changeset
795 /* czysci ekran przed powrotem do menu */
prymula <prymula76@outlook.com>
parents:
diff changeset
796 destrect = set_rect(0,0,screen->w,screen->h);
prymula <prymula76@outlook.com>
parents:
diff changeset
797 SDL_FillRect(screen,&destrect,0);
prymula <prymula76@outlook.com>
parents:
diff changeset
798 // SDL_Flip(screen);
prymula <prymula76@outlook.com>
parents:
diff changeset
799
prymula <prymula76@outlook.com>
parents:
diff changeset
800 source = set_rect(0, 0, screen->w, screen->h);
prymula <prymula76@outlook.com>
parents:
diff changeset
801 tex_screen = SDL_CreateTextureFromSurface(renderer, screen);
prymula <prymula76@outlook.com>
parents:
diff changeset
802 SDL_RenderClear ( renderer );
prymula <prymula76@outlook.com>
parents:
diff changeset
803 SDL_RenderCopy(renderer, tex_screen,&source,&dest);
prymula <prymula76@outlook.com>
parents:
diff changeset
804 SDL_RenderPresent(renderer);
prymula <prymula76@outlook.com>
parents:
diff changeset
805 SDL_DestroyTexture(tex_screen);
prymula <prymula76@outlook.com>
parents:
diff changeset
806
prymula <prymula76@outlook.com>
parents:
diff changeset
807 /* zwalnia pamiec po nieaktualnych obrazkach z liczbami */
prymula <prymula76@outlook.com>
parents:
diff changeset
808 SDL_FreeSurface(var_level_inscription);
prymula <prymula76@outlook.com>
parents:
diff changeset
809 SDL_FreeSurface(var_hiscore_inscription);
prymula <prymula76@outlook.com>
parents:
diff changeset
810
prymula <prymula76@outlook.com>
parents:
diff changeset
811 }
prymula <prymula76@outlook.com>
parents:
diff changeset
812
prymula <prymula76@outlook.com>
parents:
diff changeset
813