|
@@ -27,16 +27,16 @@ int main(int argc, char *argv[]) |
|
|
unsigned char level = 0; |
|
|
unsigned char level = 0; |
|
|
unsigned char total_lines = 0; |
|
|
unsigned char total_lines = 0; |
|
|
|
|
|
|
|
|
field = cucul_create_canvas(0, 0); |
|
|
|
|
|
infos = cucul_create_canvas(0, 0); |
|
|
|
|
|
screen = cucul_create_canvas(0, 0); |
|
|
|
|
|
|
|
|
field = caca_create_canvas(0, 0); |
|
|
|
|
|
infos = caca_create_canvas(0, 0); |
|
|
|
|
|
screen = caca_create_canvas(0, 0); |
|
|
|
|
|
|
|
|
dp = caca_create_display(screen); |
|
|
dp = caca_create_display(screen); |
|
|
if(!dp) |
|
|
if(!dp) |
|
|
return 1; |
|
|
return 1; |
|
|
|
|
|
|
|
|
cucul_set_canvas_size(infos, INFO_WIDTH, cucul_get_canvas_height(screen)); |
|
|
|
|
|
cucul_set_canvas_size(field, FIELD_CANVAS_WIDTH, FIELD_CANVAS_HEIGHT); |
|
|
|
|
|
|
|
|
caca_set_canvas_size(infos, INFO_WIDTH, caca_get_canvas_height(screen)); |
|
|
|
|
|
caca_set_canvas_size(field, FIELD_CANVAS_WIDTH, FIELD_CANVAS_HEIGHT); |
|
|
|
|
|
|
|
|
caca_set_display_time(dp, 20000); |
|
|
caca_set_display_time(dp, 20000); |
|
|
|
|
|
|
|
@@ -45,8 +45,8 @@ int main(int argc, char *argv[]) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* Set current and next piece to random */ |
|
|
/* Set current and next piece to random */ |
|
|
current_piece = cucul_rand(0, 6); |
|
|
|
|
|
next_piece = cucul_rand(0, 6); |
|
|
|
|
|
|
|
|
current_piece = caca_rand(0, 6); |
|
|
|
|
|
next_piece = caca_rand(0, 6); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for(;;) |
|
|
for(;;) |
|
@@ -137,9 +137,9 @@ int main(int argc, char *argv[]) |
|
|
playfield_draw(field); |
|
|
playfield_draw(field); |
|
|
remove_piece(current_piece, x ,y, rotation); |
|
|
remove_piece(current_piece, x ,y, rotation); |
|
|
/* blit infos canvas into general one */ |
|
|
/* blit infos canvas into general one */ |
|
|
cucul_blit(screen, (cucul_get_canvas_width(screen)) - INFO_WIDTH, 0, infos, NULL); |
|
|
|
|
|
|
|
|
caca_blit(screen, (caca_get_canvas_width(screen)) - INFO_WIDTH, 0, infos, NULL); |
|
|
/* blit playfield canvas into general one */ |
|
|
/* blit playfield canvas into general one */ |
|
|
cucul_blit(screen, 18, 0, field, NULL); |
|
|
|
|
|
|
|
|
caca_blit(screen, 18, 0, field, NULL); |
|
|
|
|
|
|
|
|
caca_refresh_display(dp); |
|
|
caca_refresh_display(dp); |
|
|
|
|
|
|
|
@@ -151,7 +151,7 @@ int main(int argc, char *argv[]) |
|
|
x = (FIELD_WIDTH/2)-1; |
|
|
x = (FIELD_WIDTH/2)-1; |
|
|
current_piece = next_piece; |
|
|
current_piece = next_piece; |
|
|
rotation = 0; |
|
|
rotation = 0; |
|
|
next_piece = cucul_rand(0, 6); |
|
|
|
|
|
|
|
|
next_piece = caca_rand(0, 6); |
|
|
last_has_landed = 1; |
|
|
last_has_landed = 1; |
|
|
old_x = x; |
|
|
old_x = x; |
|
|
old_y = 0; |
|
|
old_y = 0; |
|
@@ -180,45 +180,45 @@ int main(int argc, char *argv[]) |
|
|
|
|
|
|
|
|
end: |
|
|
end: |
|
|
caca_free_display(dp); |
|
|
caca_free_display(dp); |
|
|
cucul_free_canvas(field); |
|
|
|
|
|
cucul_free_canvas(infos); |
|
|
|
|
|
cucul_free_canvas(screen); |
|
|
|
|
|
|
|
|
caca_free_canvas(field); |
|
|
|
|
|
caca_free_canvas(infos); |
|
|
|
|
|
caca_free_canvas(screen); |
|
|
|
|
|
|
|
|
return 0; |
|
|
return 0; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void infos_populate(cucul_canvas_t *inf, unsigned int score, |
|
|
|
|
|
|
|
|
void infos_populate(caca_canvas_t *inf, unsigned int score, |
|
|
unsigned char level, unsigned char total) |
|
|
unsigned char level, unsigned char total) |
|
|
{ |
|
|
{ |
|
|
unsigned int i; |
|
|
|
|
|
char scoreline[256]; |
|
|
char scoreline[256]; |
|
|
char levelline[256]; |
|
|
char levelline[256]; |
|
|
char totalline[256]; |
|
|
char totalline[256]; |
|
|
|
|
|
int i; |
|
|
|
|
|
|
|
|
sprintf(scoreline, " Score : %05d ", score); |
|
|
sprintf(scoreline, " Score : %05d ", score); |
|
|
sprintf(levelline, " Level : %02d ", level); |
|
|
sprintf(levelline, " Level : %02d ", level); |
|
|
sprintf(totalline, " Lines : %02d ", total); |
|
|
sprintf(totalline, " Lines : %02d ", total); |
|
|
|
|
|
|
|
|
cucul_set_color_ansi(inf, CUCUL_WHITE, CUCUL_BLUE); |
|
|
|
|
|
cucul_put_str(inf, 0, 0, " =Cacatris= "); |
|
|
|
|
|
cucul_put_str(inf, 0, 1, " Arrows : move "); |
|
|
|
|
|
cucul_put_str(inf, 0, 2, " Space : pouf "); |
|
|
|
|
|
cucul_put_str(inf, 0, 3, " __________________ "); |
|
|
|
|
|
cucul_put_str(inf, 0, 4, " "); |
|
|
|
|
|
cucul_put_str(inf, 0, 5, levelline); |
|
|
|
|
|
cucul_put_str(inf, 0, 6, scoreline); |
|
|
|
|
|
cucul_put_str(inf, 0, 7, totalline); |
|
|
|
|
|
cucul_put_str(inf, 0, 8, " Time : XX:XX "); |
|
|
|
|
|
|
|
|
|
|
|
for(i = 8; i < cucul_get_canvas_height(inf); i++) |
|
|
|
|
|
|
|
|
caca_set_color_ansi(inf, CACA_WHITE, CACA_BLUE); |
|
|
|
|
|
caca_put_str(inf, 0, 0, " =Cacatris= "); |
|
|
|
|
|
caca_put_str(inf, 0, 1, " Arrows : move "); |
|
|
|
|
|
caca_put_str(inf, 0, 2, " Space : pouf "); |
|
|
|
|
|
caca_put_str(inf, 0, 3, " __________________ "); |
|
|
|
|
|
caca_put_str(inf, 0, 4, " "); |
|
|
|
|
|
caca_put_str(inf, 0, 5, levelline); |
|
|
|
|
|
caca_put_str(inf, 0, 6, scoreline); |
|
|
|
|
|
caca_put_str(inf, 0, 7, totalline); |
|
|
|
|
|
caca_put_str(inf, 0, 8, " Time : XX:XX "); |
|
|
|
|
|
|
|
|
|
|
|
for(i = 8; i < caca_get_canvas_height(inf); i++) |
|
|
{ |
|
|
{ |
|
|
cucul_put_str(inf, 0, i," "); |
|
|
|
|
|
|
|
|
caca_put_str(inf, 0, i," "); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void playfield_draw(cucul_canvas_t *canvas) |
|
|
|
|
|
|
|
|
void playfield_draw(caca_canvas_t *canvas) |
|
|
{ |
|
|
{ |
|
|
unsigned int x, y; |
|
|
unsigned int x, y; |
|
|
float ox=0, oy=0; |
|
|
float ox=0, oy=0; |
|
@@ -232,9 +232,9 @@ void playfield_draw(cucul_canvas_t *canvas) |
|
|
unsigned int oxi = (unsigned int) ox; |
|
|
unsigned int oxi = (unsigned int) ox; |
|
|
unsigned int oyi = (unsigned int) oy; |
|
|
unsigned int oyi = (unsigned int) oy; |
|
|
unsigned int c = playfield[oxi+oyi*FIELD_WIDTH]; |
|
|
unsigned int c = playfield[oxi+oyi*FIELD_WIDTH]; |
|
|
cucul_set_color_ansi(canvas, CUCUL_BLACK, |
|
|
|
|
|
c ? blocks_palette[c-1] : CUCUL_DARKGRAY); |
|
|
|
|
|
cucul_put_char(canvas, x, y, ' '); |
|
|
|
|
|
|
|
|
caca_set_color_ansi(canvas, CACA_BLACK, |
|
|
|
|
|
c ? blocks_palette[c-1] : CACA_DARKGRAY); |
|
|
|
|
|
caca_put_char(canvas, x, y, ' '); |
|
|
ox+=incx; |
|
|
ox+=incx; |
|
|
} |
|
|
} |
|
|
ox = 0; |
|
|
ox = 0; |
|
|