annotate lamertetris/sources/szlam.C @ 20:b637ac9c6605

lamertetris - PKGBUILD corrections
author Przemyslaw <prymula76@outlook.com>
date Sun, 31 Mar 2024 16:21:08 +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 project: Lamer Teris
prymula <prymula76@outlook.com>
parents:
diff changeset
3 file: szlam.C
prymula <prymula76@outlook.com>
parents:
diff changeset
4 write: PRP
prymula <prymula76@outlook.com>
parents:
diff changeset
5 licence: Public Domain
prymula <prymula76@outlook.com>
parents:
diff changeset
6 date: 9-10-2018
prymula <prymula76@outlook.com>
parents:
diff changeset
7 editor: VSCode
prymula <prymula76@outlook.com>
parents:
diff changeset
8 */
prymula <prymula76@outlook.com>
parents:
diff changeset
9 #include "field.h"
prymula <prymula76@outlook.com>
parents:
diff changeset
10 #include "szlam.h"
prymula <prymula76@outlook.com>
parents:
diff changeset
11 #include <iostream>
prymula <prymula76@outlook.com>
parents:
diff changeset
12
prymula <prymula76@outlook.com>
parents:
diff changeset
13 char szlamField [30][20]; // 600/20x400/20
prymula <prymula76@outlook.com>
parents:
diff changeset
14 bool szlamGhost [30] = {SDL_FALSE};
prymula <prymula76@outlook.com>
parents:
diff changeset
15
prymula <prymula76@outlook.com>
parents:
diff changeset
16 Szlam::Szlam(){
prymula <prymula76@outlook.com>
parents:
diff changeset
17
prymula <prymula76@outlook.com>
parents:
diff changeset
18 field=this->createField(400,600, 255, 255, 255);
prymula <prymula76@outlook.com>
parents:
diff changeset
19 SDL_SetColorKey(field, SDL_TRUE, getpixel(field,0,0)); //getpixel2
prymula <prymula76@outlook.com>
parents:
diff changeset
20
prymula <prymula76@outlook.com>
parents:
diff changeset
21 }
prymula <prymula76@outlook.com>
parents:
diff changeset
22 SDL_Surface * Szlam::get() {
prymula <prymula76@outlook.com>
parents:
diff changeset
23
prymula <prymula76@outlook.com>
parents:
diff changeset
24 return field;
prymula <prymula76@outlook.com>
parents:
diff changeset
25 }
prymula <prymula76@outlook.com>
parents:
diff changeset
26
prymula <prymula76@outlook.com>
parents:
diff changeset
27 void Szlam::reset()
prymula <prymula76@outlook.com>
parents:
diff changeset
28 {
prymula <prymula76@outlook.com>
parents:
diff changeset
29 int i,j;
prymula <prymula76@outlook.com>
parents:
diff changeset
30
prymula <prymula76@outlook.com>
parents:
diff changeset
31 for (i=0; i<600/20; i++){
prymula <prymula76@outlook.com>
parents:
diff changeset
32 for (j=0; j<400/20; j++) {
prymula <prymula76@outlook.com>
parents:
diff changeset
33 szlamField[i][j]=0;
prymula <prymula76@outlook.com>
parents:
diff changeset
34 }
prymula <prymula76@outlook.com>
parents:
diff changeset
35 szlamGhost[i]=SDL_FALSE;
prymula <prymula76@outlook.com>
parents:
diff changeset
36 }
prymula <prymula76@outlook.com>
parents:
diff changeset
37 }
prymula <prymula76@outlook.com>
parents:
diff changeset
38
prymula <prymula76@outlook.com>
parents:
diff changeset
39 void Szlam::draw(){
prymula <prymula76@outlook.com>
parents:
diff changeset
40
prymula <prymula76@outlook.com>
parents:
diff changeset
41 SDL_Surface *px;
prymula <prymula76@outlook.com>
parents:
diff changeset
42 SDL_Rect box;
prymula <prymula76@outlook.com>
parents:
diff changeset
43 int i,j;
prymula <prymula76@outlook.com>
parents:
diff changeset
44 int r,g,b;
prymula <prymula76@outlook.com>
parents:
diff changeset
45
prymula <prymula76@outlook.com>
parents:
diff changeset
46 px=this->createField(20,20, 128, 128, 100);
prymula <prymula76@outlook.com>
parents:
diff changeset
47 SDL_FillRect(field, NULL, SDL_MapRGB(field->format, 255, 255, 255));
prymula <prymula76@outlook.com>
parents:
diff changeset
48 SDL_SetColorKey(field,SDL_TRUE, getpixel(field,0,0)); //getpixel2
prymula <prymula76@outlook.com>
parents:
diff changeset
49
prymula <prymula76@outlook.com>
parents:
diff changeset
50 for (i=0; i<600/20; i++){
prymula <prymula76@outlook.com>
parents:
diff changeset
51 for (j=0; j<400/20; j++) {
prymula <prymula76@outlook.com>
parents:
diff changeset
52 if (szlamField[i][j]==0) {
prymula <prymula76@outlook.com>
parents:
diff changeset
53 asm("nop");
prymula <prymula76@outlook.com>
parents:
diff changeset
54 //putchar(' ');
prymula <prymula76@outlook.com>
parents:
diff changeset
55 }
prymula <prymula76@outlook.com>
parents:
diff changeset
56 else if (szlamField[i][j]!=0) {
prymula <prymula76@outlook.com>
parents:
diff changeset
57 box = set_rect(j*20, i*20, 20, 20);
prymula <prymula76@outlook.com>
parents:
diff changeset
58 this->setColor(szlamField[i][j],&r,&g,&b);
prymula <prymula76@outlook.com>
parents:
diff changeset
59 SDL_FillRect(px, NULL, SDL_MapRGB(field->format, r,g,b));
prymula <prymula76@outlook.com>
parents:
diff changeset
60 SDL_BlitSurface( px, NULL, field, &box );
prymula <prymula76@outlook.com>
parents:
diff changeset
61 //putchar('#');
prymula <prymula76@outlook.com>
parents:
diff changeset
62 }
prymula <prymula76@outlook.com>
parents:
diff changeset
63 }
prymula <prymula76@outlook.com>
parents:
diff changeset
64 //putchar('\n');
prymula <prymula76@outlook.com>
parents:
diff changeset
65 }
prymula <prymula76@outlook.com>
parents:
diff changeset
66
prymula <prymula76@outlook.com>
parents:
diff changeset
67 SDL_FreeSurface(px);
prymula <prymula76@outlook.com>
parents:
diff changeset
68 }
prymula <prymula76@outlook.com>
parents:
diff changeset
69
prymula <prymula76@outlook.com>
parents:
diff changeset
70 bool Szlam::addBottom(SDL_Surface *s, int n_figure, int n_element, int color, int posX, int posY) {
prymula <prymula76@outlook.com>
parents:
diff changeset
71 Uint32 c;
prymula <prymula76@outlook.com>
parents:
diff changeset
72 Uint8 r,g,b,a;
prymula <prymula76@outlook.com>
parents:
diff changeset
73 int j,i,down = 0, v = 0, vv = 0;
prymula <prymula76@outlook.com>
parents:
diff changeset
74
prymula <prymula76@outlook.com>
parents:
diff changeset
75 for(j=0;j<80;j+=20){ //j++
prymula <prymula76@outlook.com>
parents:
diff changeset
76 for (i=0;i<80;i+=1){ //i++
prymula <prymula76@outlook.com>
parents:
diff changeset
77 c=getpixel(s, j, i); //getpixel2
prymula <prymula76@outlook.com>
parents:
diff changeset
78 SDL_GetRGBA(c, s->format, &r, &g, &b, &a);
prymula <prymula76@outlook.com>
parents:
diff changeset
79 if (r !=255 || g !=255 || b !=255) {
prymula <prymula76@outlook.com>
parents:
diff changeset
80 if (i>down)
prymula <prymula76@outlook.com>
parents:
diff changeset
81 {
prymula <prymula76@outlook.com>
parents:
diff changeset
82 down=i;
prymula <prymula76@outlook.com>
parents:
diff changeset
83
prymula <prymula76@outlook.com>
parents:
diff changeset
84 switch (80 % down){
prymula <prymula76@outlook.com>
parents:
diff changeset
85 case 1:
prymula <prymula76@outlook.com>
parents:
diff changeset
86 v = 0;
prymula <prymula76@outlook.com>
parents:
diff changeset
87 vv = 0;
prymula <prymula76@outlook.com>
parents:
diff changeset
88 break;
prymula <prymula76@outlook.com>
parents:
diff changeset
89 case 21:
prymula <prymula76@outlook.com>
parents:
diff changeset
90 v = 1;
prymula <prymula76@outlook.com>
parents:
diff changeset
91 vv = 20;
prymula <prymula76@outlook.com>
parents:
diff changeset
92 break;
prymula <prymula76@outlook.com>
parents:
diff changeset
93 case 2:
prymula <prymula76@outlook.com>
parents:
diff changeset
94 v = 2;
prymula <prymula76@outlook.com>
parents:
diff changeset
95 vv = 40;
prymula <prymula76@outlook.com>
parents:
diff changeset
96 break;
prymula <prymula76@outlook.com>
parents:
diff changeset
97 }
prymula <prymula76@outlook.com>
parents:
diff changeset
98 }
prymula <prymula76@outlook.com>
parents:
diff changeset
99 }
prymula <prymula76@outlook.com>
parents:
diff changeset
100 else {
prymula <prymula76@outlook.com>
parents:
diff changeset
101
prymula <prymula76@outlook.com>
parents:
diff changeset
102 }
prymula <prymula76@outlook.com>
parents:
diff changeset
103 }
prymula <prymula76@outlook.com>
parents:
diff changeset
104 }
prymula <prymula76@outlook.com>
parents:
diff changeset
105
prymula <prymula76@outlook.com>
parents:
diff changeset
106 if (down+posY+vv>=600) {
prymula <prymula76@outlook.com>
parents:
diff changeset
107 for (i=0; i<4; i++){
prymula <prymula76@outlook.com>
parents:
diff changeset
108 for (j=0; j<4; j++) {
prymula <prymula76@outlook.com>
parents:
diff changeset
109 if (this->elements[n_figure][i+n_element*4][j]==0) {
prymula <prymula76@outlook.com>
parents:
diff changeset
110 asm("nop");
prymula <prymula76@outlook.com>
parents:
diff changeset
111 putchar(' ');
prymula <prymula76@outlook.com>
parents:
diff changeset
112 }
prymula <prymula76@outlook.com>
parents:
diff changeset
113 else if (this->elements[n_figure][i+n_element*4][j]==1) {
prymula <prymula76@outlook.com>
parents:
diff changeset
114 szlamField[posY/20+i+v][posX/20+j]=color;
prymula <prymula76@outlook.com>
parents:
diff changeset
115
prymula <prymula76@outlook.com>
parents:
diff changeset
116 putchar('#');
prymula <prymula76@outlook.com>
parents:
diff changeset
117 }
prymula <prymula76@outlook.com>
parents:
diff changeset
118 }
prymula <prymula76@outlook.com>
parents:
diff changeset
119 putchar('\n');
prymula <prymula76@outlook.com>
parents:
diff changeset
120 }
prymula <prymula76@outlook.com>
parents:
diff changeset
121 return true;
prymula <prymula76@outlook.com>
parents:
diff changeset
122 }
prymula <prymula76@outlook.com>
parents:
diff changeset
123 return false;
prymula <prymula76@outlook.com>
parents:
diff changeset
124 }
prymula <prymula76@outlook.com>
parents:
diff changeset
125
prymula <prymula76@outlook.com>
parents:
diff changeset
126 bool Szlam::collisionLeft(SDL_Surface *s, int n_element,
prymula <prymula76@outlook.com>
parents:
diff changeset
127 int figure, int x_s, int y_s, int color){
prymula <prymula76@outlook.com>
parents:
diff changeset
128
prymula <prymula76@outlook.com>
parents:
diff changeset
129 Uint32 cf, cs;
prymula <prymula76@outlook.com>
parents:
diff changeset
130 Uint8 r,g,b,a, r2,g2,b2,a2;
prymula <prymula76@outlook.com>
parents:
diff changeset
131 int i, j=0;
prymula <prymula76@outlook.com>
parents:
diff changeset
132
prymula <prymula76@outlook.com>
parents:
diff changeset
133 for(j=0;j<80;j+=1){ // y j++
prymula <prymula76@outlook.com>
parents:
diff changeset
134 for (i=0;i<80;i+=1){ // x i++
prymula <prymula76@outlook.com>
parents:
diff changeset
135
prymula <prymula76@outlook.com>
parents:
diff changeset
136 cs=getpixel(s, i, j); //getpixel2
prymula <prymula76@outlook.com>
parents:
diff changeset
137 SDL_GetRGBA(cs, s->format, &r, &g, &b, &a);
prymula <prymula76@outlook.com>
parents:
diff changeset
138 cf=getpixel(field, i+x_s-20, j+y_s); //getpixel2
prymula <prymula76@outlook.com>
parents:
diff changeset
139 printf("2\n");
prymula <prymula76@outlook.com>
parents:
diff changeset
140 SDL_GetRGBA(cf, field->format, &r2, &g2, &b2, &a2);
prymula <prymula76@outlook.com>
parents:
diff changeset
141
prymula <prymula76@outlook.com>
parents:
diff changeset
142 if ((r2!=255 || g2!=255 || b2!=255) &&
prymula <prymula76@outlook.com>
parents:
diff changeset
143 (r!=255 || g!=255 || b!=255)) {
prymula <prymula76@outlook.com>
parents:
diff changeset
144 //*bottom=0;
prymula <prymula76@outlook.com>
parents:
diff changeset
145 //printf ("----bottom: %d\n", *bottom);
prymula <prymula76@outlook.com>
parents:
diff changeset
146 return SDL_TRUE;
prymula <prymula76@outlook.com>
parents:
diff changeset
147 //break;
prymula <prymula76@outlook.com>
parents:
diff changeset
148 }
prymula <prymula76@outlook.com>
parents:
diff changeset
149 }
prymula <prymula76@outlook.com>
parents:
diff changeset
150 }
prymula <prymula76@outlook.com>
parents:
diff changeset
151 return SDL_FALSE;
prymula <prymula76@outlook.com>
parents:
diff changeset
152 }
prymula <prymula76@outlook.com>
parents:
diff changeset
153
prymula <prymula76@outlook.com>
parents:
diff changeset
154 bool Szlam::collisionRight(SDL_Surface *s, int n_element,
prymula <prymula76@outlook.com>
parents:
diff changeset
155 int figure, int x_s, int y_s, int color){
prymula <prymula76@outlook.com>
parents:
diff changeset
156
prymula <prymula76@outlook.com>
parents:
diff changeset
157 Uint32 cf, cs;
prymula <prymula76@outlook.com>
parents:
diff changeset
158 Uint8 r,g,b,a, r2,g2,b2,a2;
prymula <prymula76@outlook.com>
parents:
diff changeset
159 int i, j=0;
prymula <prymula76@outlook.com>
parents:
diff changeset
160
prymula <prymula76@outlook.com>
parents:
diff changeset
161 for(j=0;j<80;j+=1){ // y j++
prymula <prymula76@outlook.com>
parents:
diff changeset
162 for (i=0;i<80;i+=1){ // x i++
prymula <prymula76@outlook.com>
parents:
diff changeset
163
prymula <prymula76@outlook.com>
parents:
diff changeset
164 cs=getpixel(s, i, j); //getpixel2
prymula <prymula76@outlook.com>
parents:
diff changeset
165 SDL_GetRGBA(cs, s->format, &r, &g, &b, &a);
prymula <prymula76@outlook.com>
parents:
diff changeset
166 cf=getpixel(field, i+x_s+20, j+y_s); //getpixel2
prymula <prymula76@outlook.com>
parents:
diff changeset
167 SDL_GetRGBA(cf, field->format, &r2, &g2, &b2, &a2);
prymula <prymula76@outlook.com>
parents:
diff changeset
168
prymula <prymula76@outlook.com>
parents:
diff changeset
169 if ((r2!=255 || g2!=255 || b2!=255) &&
prymula <prymula76@outlook.com>
parents:
diff changeset
170 (r!=255 || g!=255 || b!=255)) {
prymula <prymula76@outlook.com>
parents:
diff changeset
171 //*bottom=0;
prymula <prymula76@outlook.com>
parents:
diff changeset
172 return SDL_TRUE;
prymula <prymula76@outlook.com>
parents:
diff changeset
173 //break;
prymula <prymula76@outlook.com>
parents:
diff changeset
174 }
prymula <prymula76@outlook.com>
parents:
diff changeset
175 }
prymula <prymula76@outlook.com>
parents:
diff changeset
176 }
prymula <prymula76@outlook.com>
parents:
diff changeset
177 return SDL_FALSE;
prymula <prymula76@outlook.com>
parents:
diff changeset
178 }
prymula <prymula76@outlook.com>
parents:
diff changeset
179
prymula <prymula76@outlook.com>
parents:
diff changeset
180 bool Szlam::collisionRotate(SDL_Surface *s, int n_element,
prymula <prymula76@outlook.com>
parents:
diff changeset
181 int figure, int x_s, int y_s, int color){
prymula <prymula76@outlook.com>
parents:
diff changeset
182
prymula <prymula76@outlook.com>
parents:
diff changeset
183 Uint32 cf, cs;
prymula <prymula76@outlook.com>
parents:
diff changeset
184 Uint8 r,g,b,a, r2,g2,b2,a2;
prymula <prymula76@outlook.com>
parents:
diff changeset
185 int i, j=0;
prymula <prymula76@outlook.com>
parents:
diff changeset
186
prymula <prymula76@outlook.com>
parents:
diff changeset
187 for(j=0;j<80;j+=1){ // y j++
prymula <prymula76@outlook.com>
parents:
diff changeset
188 for (i=0;i<80;i+=1){ // x i++
prymula <prymula76@outlook.com>
parents:
diff changeset
189
prymula <prymula76@outlook.com>
parents:
diff changeset
190 cs=getpixel(s, i, j); //getpixel2
prymula <prymula76@outlook.com>
parents:
diff changeset
191 SDL_GetRGBA(cs, s->format, &r, &g, &b, &a);
prymula <prymula76@outlook.com>
parents:
diff changeset
192 cf=getpixel(field, i+x_s, j+y_s); //getpixel2
prymula <prymula76@outlook.com>
parents:
diff changeset
193 SDL_GetRGBA(cf, field->format, &r2, &g2, &b2, &a2);
prymula <prymula76@outlook.com>
parents:
diff changeset
194
prymula <prymula76@outlook.com>
parents:
diff changeset
195 if ((r2!=255 || g2!=255 || b2!=255) &&
prymula <prymula76@outlook.com>
parents:
diff changeset
196 (r!=255 || g!=255 || b!=255)) {
prymula <prymula76@outlook.com>
parents:
diff changeset
197 // *bottom=0;
prymula <prymula76@outlook.com>
parents:
diff changeset
198 return SDL_TRUE;
prymula <prymula76@outlook.com>
parents:
diff changeset
199 //break;
prymula <prymula76@outlook.com>
parents:
diff changeset
200 }
prymula <prymula76@outlook.com>
parents:
diff changeset
201 }
prymula <prymula76@outlook.com>
parents:
diff changeset
202 }
prymula <prymula76@outlook.com>
parents:
diff changeset
203 return SDL_FALSE;
prymula <prymula76@outlook.com>
parents:
diff changeset
204 }
prymula <prymula76@outlook.com>
parents:
diff changeset
205
prymula <prymula76@outlook.com>
parents:
diff changeset
206 bool Szlam::collisionBottom(SDL_Surface *s, int n_element,
prymula <prymula76@outlook.com>
parents:
diff changeset
207 int figure, int x_s, int y_s, int color) {
prymula <prymula76@outlook.com>
parents:
diff changeset
208
prymula <prymula76@outlook.com>
parents:
diff changeset
209
prymula <prymula76@outlook.com>
parents:
diff changeset
210 Uint32 cf, cs;
prymula <prymula76@outlook.com>
parents:
diff changeset
211 Uint8 r,g,b,a, r2,g2,b2,a2;
prymula <prymula76@outlook.com>
parents:
diff changeset
212 int i, j=0;
prymula <prymula76@outlook.com>
parents:
diff changeset
213 bool go_szlam=false;
prymula <prymula76@outlook.com>
parents:
diff changeset
214
prymula <prymula76@outlook.com>
parents:
diff changeset
215 for(j=0;j<80;j+=1){ // y j++
prymula <prymula76@outlook.com>
parents:
diff changeset
216 for (i=0;i<80;i+=20){ // x i++
prymula <prymula76@outlook.com>
parents:
diff changeset
217 cs=getpixel(s, i, j); //getpixel2
prymula <prymula76@outlook.com>
parents:
diff changeset
218 SDL_GetRGBA(cs, s->format, &r, &g, &b, &a);
prymula <prymula76@outlook.com>
parents:
diff changeset
219 cf=getpixel(field, i+x_s, j+y_s); //getpixel2
prymula <prymula76@outlook.com>
parents:
diff changeset
220 SDL_GetRGBA(cf, field->format, &r2, &g2, &b2, &a2);
prymula <prymula76@outlook.com>
parents:
diff changeset
221
prymula <prymula76@outlook.com>
parents:
diff changeset
222 if ((r2!=255 || g2!=255 || b2!=255) &&
prymula <prymula76@outlook.com>
parents:
diff changeset
223 (r!=255 || g!=255 || b!=255)) {
prymula <prymula76@outlook.com>
parents:
diff changeset
224 go_szlam=true;
prymula <prymula76@outlook.com>
parents:
diff changeset
225 break;
prymula <prymula76@outlook.com>
parents:
diff changeset
226 }
prymula <prymula76@outlook.com>
parents:
diff changeset
227 }
prymula <prymula76@outlook.com>
parents:
diff changeset
228 }
prymula <prymula76@outlook.com>
parents:
diff changeset
229
prymula <prymula76@outlook.com>
parents:
diff changeset
230
prymula <prymula76@outlook.com>
parents:
diff changeset
231 if (go_szlam) {
prymula <prymula76@outlook.com>
parents:
diff changeset
232 for (i=0; i<4; i++){
prymula <prymula76@outlook.com>
parents:
diff changeset
233 for (j=0; j<4; j++) {
prymula <prymula76@outlook.com>
parents:
diff changeset
234 if (this->elements[figure][i+n_element*4][j]==0) {
prymula <prymula76@outlook.com>
parents:
diff changeset
235 asm("nop");
prymula <prymula76@outlook.com>
parents:
diff changeset
236 }
prymula <prymula76@outlook.com>
parents:
diff changeset
237 else if (this->elements[figure][i+n_element*4][j]==1) {
prymula <prymula76@outlook.com>
parents:
diff changeset
238 szlamField[y_s/20+i][x_s/20+j]=color;
prymula <prymula76@outlook.com>
parents:
diff changeset
239 }
prymula <prymula76@outlook.com>
parents:
diff changeset
240 }
prymula <prymula76@outlook.com>
parents:
diff changeset
241 }
prymula <prymula76@outlook.com>
parents:
diff changeset
242 return true;
prymula <prymula76@outlook.com>
parents:
diff changeset
243 }
prymula <prymula76@outlook.com>
parents:
diff changeset
244
prymula <prymula76@outlook.com>
parents:
diff changeset
245 return false;
prymula <prymula76@outlook.com>
parents:
diff changeset
246 }
prymula <prymula76@outlook.com>
parents:
diff changeset
247
prymula <prymula76@outlook.com>
parents:
diff changeset
248 // sprawdza czy równa powierzchnia
prymula <prymula76@outlook.com>
parents:
diff changeset
249 int Szlam::evenSurface(int *height)
prymula <prymula76@outlook.com>
parents:
diff changeset
250 {
prymula <prymula76@outlook.com>
parents:
diff changeset
251 int i, j, count=0;
prymula <prymula76@outlook.com>
parents:
diff changeset
252 int full[600/20] = {0};
prymula <prymula76@outlook.com>
parents:
diff changeset
253 //bool flag[30] = SDL_FALSE;
prymula <prymula76@outlook.com>
parents:
diff changeset
254
prymula <prymula76@outlook.com>
parents:
diff changeset
255 for (i=0; i<600/20; i++){
prymula <prymula76@outlook.com>
parents:
diff changeset
256 for (j=0; j<400/20; j++) {
prymula <prymula76@outlook.com>
parents:
diff changeset
257 if (szlamField[i][j] !=0 && szlamGhost[i]==SDL_FALSE) {
prymula <prymula76@outlook.com>
parents:
diff changeset
258 full[i]+=1;
prymula <prymula76@outlook.com>
parents:
diff changeset
259
prymula <prymula76@outlook.com>
parents:
diff changeset
260 }
prymula <prymula76@outlook.com>
parents:
diff changeset
261 }
prymula <prymula76@outlook.com>
parents:
diff changeset
262 }
prymula <prymula76@outlook.com>
parents:
diff changeset
263 for (i=0; i < 600/20; i++){
prymula <prymula76@outlook.com>
parents:
diff changeset
264 if (full[i]==20) {
prymula <prymula76@outlook.com>
parents:
diff changeset
265 count++;
prymula <prymula76@outlook.com>
parents:
diff changeset
266 szlamGhost[i]=SDL_TRUE;
prymula <prymula76@outlook.com>
parents:
diff changeset
267 }
prymula <prymula76@outlook.com>
parents:
diff changeset
268 if (full[i]!=0) (*height)++;
prymula <prymula76@outlook.com>
parents:
diff changeset
269 }
prymula <prymula76@outlook.com>
parents:
diff changeset
270 return count;
prymula <prymula76@outlook.com>
parents:
diff changeset
271 }
prymula <prymula76@outlook.com>
parents:
diff changeset
272
prymula <prymula76@outlook.com>
parents:
diff changeset
273 // skraca studnie
prymula <prymula76@outlook.com>
parents:
diff changeset
274 void Szlam::cutSurface(int n, int h)
prymula <prymula76@outlook.com>
parents:
diff changeset
275 {
prymula <prymula76@outlook.com>
parents:
diff changeset
276 int i, j, k;
prymula <prymula76@outlook.com>
parents:
diff changeset
277
prymula <prymula76@outlook.com>
parents:
diff changeset
278 while (n-->0) {
prymula <prymula76@outlook.com>
parents:
diff changeset
279 //for (i=600/20-1, k=h; k>0; i--, k--) {
prymula <prymula76@outlook.com>
parents:
diff changeset
280 for (i=600/20-1, k=h; i>0; i--, k--) {
prymula <prymula76@outlook.com>
parents:
diff changeset
281 for (j=400/20-1; j>=0; j--){
prymula <prymula76@outlook.com>
parents:
diff changeset
282 szlamField[i][j] = szlamField[i-1][j];
prymula <prymula76@outlook.com>
parents:
diff changeset
283 szlamGhost[i] = szlamGhost[i-1];
prymula <prymula76@outlook.com>
parents:
diff changeset
284
prymula <prymula76@outlook.com>
parents:
diff changeset
285 }
prymula <prymula76@outlook.com>
parents:
diff changeset
286 }
prymula <prymula76@outlook.com>
parents:
diff changeset
287 }
prymula <prymula76@outlook.com>
parents:
diff changeset
288 }
prymula <prymula76@outlook.com>
parents:
diff changeset
289
prymula <prymula76@outlook.com>
parents:
diff changeset
290 bool Szlam::highFull()
prymula <prymula76@outlook.com>
parents:
diff changeset
291 {
prymula <prymula76@outlook.com>
parents:
diff changeset
292 int j;
prymula <prymula76@outlook.com>
parents:
diff changeset
293
prymula <prymula76@outlook.com>
parents:
diff changeset
294 for (j=0; j<400/20; j++){
prymula <prymula76@outlook.com>
parents:
diff changeset
295 if (szlamField[0][j] != 0 || szlamField[1][j] != 0)
prymula <prymula76@outlook.com>
parents:
diff changeset
296 return SDL_TRUE;
prymula <prymula76@outlook.com>
parents:
diff changeset
297 }
prymula <prymula76@outlook.com>
parents:
diff changeset
298 return SDL_FALSE;
prymula <prymula76@outlook.com>
parents:
diff changeset
299 }
prymula <prymula76@outlook.com>
parents:
diff changeset
300