Changeset 1111 for cacatris/trunk/src
- Timestamp:
- Sep 26, 2006, 11:41:10 PM (17 years ago)
- Location:
- cacatris/trunk/src
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
cacatris/trunk/src/cacatris.h
r1108 r1111 50 50 51 51 52 void infos_populate(cucul_canvas_t * );52 void infos_populate(cucul_canvas_t *, unsigned int score); 53 53 void playfield_draw(cucul_canvas_t *); 54 54 void put_piece(unsigned int, unsigned int, unsigned int, unsigned int); -
cacatris/trunk/src/main.c
r1108 r1111 21 21 unsigned int speed = 32; 22 22 unsigned int fixed_y = 0; 23 23 unsigned char lost = 0; 24 unsigned int score = 0; 25 unsigned int lines = 0; 24 26 25 27 field = cucul_create_canvas(0, 0); … … 80 82 } 81 83 84 if(lost) continue; 85 86 87 if(y==0 && has_landed(current_piece, x ,y, rotation)) { 88 lost = 1; 89 continue; 90 } 91 82 92 if(left) 83 93 { … … 89 99 if(movable(current_piece, x+1, y, rotation)) 90 100 x++; 101 } 102 if(down) 103 { 104 while((movable(current_piece, x-1, y, rotation)) && (!has_landed(current_piece, x-1, y, rotation))) 105 { 106 fixed_y+=speed; 107 y = fixed_y>>8; 108 } 91 109 } 92 110 … … 111 129 112 130 /* Populate info canvas */ 113 infos_populate(infos );131 infos_populate(infos, score); 114 132 /* Draw everything on playfield */ 115 133 put_piece(current_piece, x ,y, rotation); … … 137 155 } 138 156 139 140 maybe_remove_line(); 157 lines = maybe_remove_line(); 158 if(lines) 159 { 160 score += (lines*40); 161 162 } 141 163 142 164 if(!baseTime) … … 154 176 155 177 156 void infos_populate(cucul_canvas_t *inf )178 void infos_populate(cucul_canvas_t *inf, unsigned int score) 157 179 { 158 180 unsigned int i; 181 char scoreline[1024]; 182 183 sprintf(scoreline, " Score : %05d ", score); 184 159 185 cucul_set_color(inf, CUCUL_COLOR_WHITE, CUCUL_COLOR_BLUE); 160 186 cucul_putstr(inf, 0, 0," =Cacatris= "); … … 163 189 cucul_putstr(inf, 0, 3," __________________ "); 164 190 cucul_putstr(inf, 0, 4," "); 165 cucul_putstr(inf, 0, 5, " Score : NXXXX ");191 cucul_putstr(inf, 0, 5,scoreline); 166 192 cucul_putstr(inf, 0, 6," Time : XX:XX "); 167 193 … … 287 313 int x, v=0; 288 314 unsigned char *p = &playfield[(FIELD_HEIGHT-1)*FIELD_WIDTH]; 315 int ret = 0; 289 316 for(x = 0; x < FIELD_WIDTH ; x++) 290 317 if(*p++) … … 293 320 if(v==FIELD_WIDTH) { 294 321 memmove(&playfield[FIELD_WIDTH], playfield, (FIELD_HEIGHT-1)*FIELD_WIDTH); 295 return 1; 322 ret += maybe_remove_line(); 323 return ret; 296 324 } 297 325 return 0;
Note: See TracChangeset
for help on using the changeset viewer.