Changeset 2981


Ignore:
Timestamp:
Oct 18, 2008, 11:29:49 PM (10 years ago)
Author:
Sam Hocevar
Message:

Port cacatris to the unified libcaca 0.99.beta15 API.

Location:
cacatris/trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • cacatris/trunk/configure.ac

    r2540 r2981  
    2727
    2828CACA="no"
    29 PKG_CHECK_MODULES(CACA, caca >= 0.99.beta9,
     29PKG_CHECK_MODULES(CACA, caca >= 0.99.beta15,
    3030 [CACA="yes"],
    3131 [AC_MSG_RESULT(no)
    32   AC_MSG_ERROR([you need libcaca version 0.99.beta9 or later])])
     32  AC_MSG_ERROR([you need libcaca version 0.99.beta15 or later])])
    3333
    3434# Optimizations
  • cacatris/trunk/src/cacatris.h

    r1458 r2981  
    2020#endif
    2121
    22 
    23 #include "cucul.h"
    24 #include "caca.h"
    25 
     22#include <caca.h>
    2623
    2724#define INFO_WIDTH 20
  • cacatris/trunk/src/main.c

    r1755 r2981  
    2828    unsigned char total_lines = 0;
    2929
    30     field = cucul_create_canvas(0, 0);
    31     infos = cucul_create_canvas(0, 0);
    32     screen = cucul_create_canvas(0, 0);
     30    field = caca_create_canvas(0, 0);
     31    infos = caca_create_canvas(0, 0);
     32    screen = caca_create_canvas(0, 0);
    3333
    3434    dp = caca_create_display(screen);
     
    3636        return 1;
    3737
    38     cucul_set_canvas_size(infos, INFO_WIDTH, cucul_get_canvas_height(screen));
    39     cucul_set_canvas_size(field, FIELD_CANVAS_WIDTH, FIELD_CANVAS_HEIGHT);
     38    caca_set_canvas_size(infos, INFO_WIDTH, caca_get_canvas_height(screen));
     39    caca_set_canvas_size(field, FIELD_CANVAS_WIDTH, FIELD_CANVAS_HEIGHT);
    4040
    4141    caca_set_display_time(dp, 20000);
     
    4646
    4747    /* Set current and next piece to random */
    48     current_piece = cucul_rand(0, 6);
    49     next_piece = cucul_rand(0, 6);
     48    current_piece = caca_rand(0, 6);
     49    next_piece = caca_rand(0, 6);
    5050
    5151
     
    138138        remove_piece(current_piece, x ,y, rotation);
    139139        /* blit infos canvas into general one */
    140         cucul_blit(screen, (cucul_get_canvas_width(screen))  - INFO_WIDTH, 0, infos, NULL);
     140        caca_blit(screen, (caca_get_canvas_width(screen))  - INFO_WIDTH, 0, infos, NULL);
    141141        /* blit playfield canvas into general one */
    142         cucul_blit(screen, 18, 0, field, NULL);
     142        caca_blit(screen, 18, 0, field, NULL);
    143143
    144144        caca_refresh_display(dp);
     
    152152            current_piece = next_piece;
    153153            rotation = 0;
    154             next_piece = cucul_rand(0, 6);
     154            next_piece = caca_rand(0, 6);
    155155            last_has_landed = 1;
    156156            old_x = x;
     
    181181 end:
    182182    caca_free_display(dp);
    183     cucul_free_canvas(field);
    184     cucul_free_canvas(infos);
    185     cucul_free_canvas(screen);
     183    caca_free_canvas(field);
     184    caca_free_canvas(infos);
     185    caca_free_canvas(screen);
    186186
    187187    return 0;
     
    189189
    190190
    191 void infos_populate(cucul_canvas_t *inf, unsigned int score,
     191void infos_populate(caca_canvas_t *inf, unsigned int score,
    192192                    unsigned char level, unsigned char total)
    193193{
    194     unsigned int i;
    195194    char scoreline[256];
    196195    char levelline[256];
    197196    char totalline[256];
     197    int i;
    198198
    199199    sprintf(scoreline, " Score    :   %05d ", score);
     
    201201    sprintf(totalline, " Lines    :   %02d    ", total);
    202202
    203     cucul_set_color_ansi(inf, CUCUL_WHITE, CUCUL_BLUE);
    204     cucul_put_str(inf, 0, 0, "      =Cacatris=    ");
    205     cucul_put_str(inf, 0, 1, "  Arrows  :    move ");
    206     cucul_put_str(inf, 0, 2, "  Space :      pouf ");
    207     cucul_put_str(inf, 0, 3, " __________________ ");
    208     cucul_put_str(inf, 0, 4, "                    ");
    209     cucul_put_str(inf, 0, 5, levelline);
    210     cucul_put_str(inf, 0, 6, scoreline);
    211     cucul_put_str(inf, 0, 7, totalline);
    212     cucul_put_str(inf, 0, 8, " Time     :   XX:XX ");
    213 
    214     for(i = 8; i < cucul_get_canvas_height(inf); i++)
    215     {
    216         cucul_put_str(inf, 0, i,"                     ");
    217     }
    218 }
    219 
    220 
    221 void playfield_draw(cucul_canvas_t *canvas)
     203    caca_set_color_ansi(inf, CACA_WHITE, CACA_BLUE);
     204    caca_put_str(inf, 0, 0, "      =Cacatris=    ");
     205    caca_put_str(inf, 0, 1, "  Arrows  :    move ");
     206    caca_put_str(inf, 0, 2, "  Space :      pouf ");
     207    caca_put_str(inf, 0, 3, " __________________ ");
     208    caca_put_str(inf, 0, 4, "                    ");
     209    caca_put_str(inf, 0, 5, levelline);
     210    caca_put_str(inf, 0, 6, scoreline);
     211    caca_put_str(inf, 0, 7, totalline);
     212    caca_put_str(inf, 0, 8, " Time     :   XX:XX ");
     213
     214    for(i = 8; i < caca_get_canvas_height(inf); i++)
     215    {
     216        caca_put_str(inf, 0, i,"                     ");
     217    }
     218}
     219
     220
     221void playfield_draw(caca_canvas_t *canvas)
    222222{
    223223    unsigned int x, y;
     
    233233            unsigned int oyi = (unsigned int) oy;
    234234            unsigned int c = playfield[oxi+oyi*FIELD_WIDTH];
    235             cucul_set_color_ansi(canvas, CUCUL_BLACK,
    236                                  c ? blocks_palette[c-1] : CUCUL_DARKGRAY);
    237             cucul_put_char(canvas, x, y, ' ');
     235            caca_set_color_ansi(canvas, CACA_BLACK,
     236                                c ? blocks_palette[c-1] : CACA_DARKGRAY);
     237            caca_put_char(canvas, x, y, ' ');
    238238            ox+=incx;
    239239        }
Note: See TracChangeset for help on using the changeset viewer.