Changeset 524 for libcaca/trunk/examples/cacaball.c
- Timestamp:
- Mar 5, 2006, 7:43:13 PM (15 years ago)
- Location:
- libcaca/trunk/examples
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
libcaca/trunk/examples
- Property svn:ignore
-
old new 3 3 .libs 4 4 .deps 5 cacademo6 cacademo.exe7 5 caca-spritedit 8 6 caca-spritedit.exe
-
- Property svn:ignore
-
libcaca/trunk/examples/cacaball.c
r522 r524 23 23 #endif 24 24 25 #include "cucul.h" 25 26 #include "caca.h" 26 27 … … 43 44 int main(int argc, char **argv) 44 45 { 46 cucul_t *qq; caca_t *kk; 45 47 unsigned int r[256], g[256], b[256], a[256]; 46 48 float d[METABALLS], di[METABALLS], dj[METABALLS], dk[METABALLS]; 47 49 unsigned int x[METABALLS], y[METABALLS]; 48 struct c aca_bitmap *caca_bitmap;50 struct cucul_bitmap *cucul_bitmap; 49 51 float i = 10.0, j = 17.0, k = 11.0; 50 52 int p, frame = 0, pause = 0; 51 53 52 if(caca_init()) 54 qq = cucul_init(); 55 if(!qq) 53 56 return 1; 54 55 caca_set_delay(20000); 57 kk = caca_attach(qq); 58 if(!kk) 59 return 1; 60 61 caca_set_delay(kk, 20000); 56 62 57 63 /* Make the palette eatable by libcaca */ … … 60 66 r[255] = g[255] = b[255] = 0xfff; 61 67 62 /* Create a libc acabitmap smaller than our pixel buffer, so that we68 /* Create a libcucul bitmap smaller than our pixel buffer, so that we 63 69 * display only the interesting part of it */ 64 c aca_bitmap = caca_create_bitmap(8, XSIZ - METASIZE, YSIZ - METASIZE,65 XSIZ, 0, 0, 0, 0);70 cucul_bitmap = cucul_create_bitmap(qq, 8, XSIZ - METASIZE, YSIZ - METASIZE, 71 XSIZ, 0, 0, 0, 0); 66 72 67 73 /* Generate ball sprite */ … … 70 76 for(p = 0; p < METABALLS; p++) 71 77 { 72 d[p] = c aca_rand(0, 100);73 di[p] = (float)c aca_rand(500, 4000) / 6000.0;74 dj[p] = (float)c aca_rand(500, 4000) / 6000.0;75 dk[p] = (float)c aca_rand(500, 4000) / 6000.0;78 d[p] = cucul_rand(0, 100); 79 di[p] = (float)cucul_rand(500, 4000) / 6000.0; 80 dj[p] = (float)cucul_rand(500, 4000) / 6000.0; 81 dk[p] = (float)cucul_rand(500, 4000) / 6000.0; 76 82 } 77 83 … … 79 85 for(;;) 80 86 { 81 switch(caca_get_event( CACA_EVENT_KEY_PRESS))87 switch(caca_get_event(kk, CACA_EVENT_KEY_PRESS)) 82 88 { 83 89 case CACA_EVENT_KEY_PRESS | CACA_KEY_ESCAPE: goto end; … … 110 116 111 117 /* Set the palette */ 112 c aca_set_bitmap_palette(caca_bitmap, r, g, b, a);118 cucul_set_bitmap_palette(qq, cucul_bitmap, r, g, b, a); 113 119 114 120 /* Silly paths for our balls */ … … 135 141 136 142 paused: 137 /* Draw our virtual buffer to screen, letting libcaca resize it */ 138 caca_draw_bitmap(0, 0, caca_get_width() - 1, caca_get_height() - 1, 139 caca_bitmap, pixels + (METASIZE / 2) * (1 + XSIZ)); 140 caca_refresh(); 143 /* Draw our virtual buffer to screen, letting libcucul resize it */ 144 cucul_draw_bitmap(qq, 0, 0, 145 cucul_get_width(qq) - 1, cucul_get_height(qq) - 1, 146 cucul_bitmap, pixels + (METASIZE / 2) * (1 + XSIZ)); 147 caca_refresh(kk); 141 148 } 142 149 143 150 /* End, bye folks */ 144 151 end: 145 caca_free_bitmap(caca_bitmap); 146 caca_end(); 152 cucul_free_bitmap(qq, cucul_bitmap); 153 caca_detach(kk); 154 cucul_end(qq); 147 155 148 156 return 0;
Note: See TracChangeset
for help on using the changeset viewer.