Ver código fonte

Port cacatris to the unified libcaca 0.99.beta15 API.

git-svn-id: file:///srv/caca.zoy.org/var/lib/svn/cacatris/trunk@2981 92316355-f0b4-4df1-b90c-862c8a59935f
master
sam 16 anos atrás
pai
commit
5eb647f197
3 arquivos alterados com 35 adições e 38 exclusões
  1. +2
    -2
      configure.ac
  2. +1
    -4
      src/cacatris.h
  3. +32
    -32
      src/main.c

+ 2
- 2
configure.ac Ver arquivo

@@ -26,10 +26,10 @@ if test "$build" != "$host" -a "${PKG_CONFIG_LIBDIR}" = ""; then
fi

CACA="no"
PKG_CHECK_MODULES(CACA, caca >= 0.99.beta9,
PKG_CHECK_MODULES(CACA, caca >= 0.99.beta15,
[CACA="yes"],
[AC_MSG_RESULT(no)
AC_MSG_ERROR([you need libcaca version 0.99.beta9 or later])])
AC_MSG_ERROR([you need libcaca version 0.99.beta15 or later])])

# Optimizations
CFLAGS="${CFLAGS} -g -O2 -fno-strength-reduce -fomit-frame-pointer"


+ 1
- 4
src/cacatris.h Ver arquivo

@@ -19,10 +19,7 @@
# define M_PI 3.14159265358979323846
#endif


#include "cucul.h"
#include "caca.h"

#include <caca.h>

#define INFO_WIDTH 20
#define FIELD_WIDTH 10


+ 32
- 32
src/main.c Ver arquivo

@@ -27,16 +27,16 @@ int main(int argc, char *argv[])
unsigned char level = 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);
if(!dp)
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);

@@ -45,8 +45,8 @@ int main(int argc, char *argv[])


/* 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(;;)
@@ -137,9 +137,9 @@ int main(int argc, char *argv[])
playfield_draw(field);
remove_piece(current_piece, x ,y, rotation);
/* 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 */
cucul_blit(screen, 18, 0, field, NULL);
caca_blit(screen, 18, 0, field, NULL);

caca_refresh_display(dp);

@@ -151,7 +151,7 @@ int main(int argc, char *argv[])
x = (FIELD_WIDTH/2)-1;
current_piece = next_piece;
rotation = 0;
next_piece = cucul_rand(0, 6);
next_piece = caca_rand(0, 6);
last_has_landed = 1;
old_x = x;
old_y = 0;
@@ -180,45 +180,45 @@ int main(int argc, char *argv[])

end:
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;
}


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 int i;
char scoreline[256];
char levelline[256];
char totalline[256];
int i;

sprintf(scoreline, " Score : %05d ", score);
sprintf(levelline, " Level : %02d ", level);
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;
float ox=0, oy=0;
@@ -232,9 +232,9 @@ void playfield_draw(cucul_canvas_t *canvas)
unsigned int oxi = (unsigned int) ox;
unsigned int oyi = (unsigned int) oy;
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 = 0;


Carregando…
Cancelar
Salvar