/* * ttyvaders Textmode shoot'em up * Copyright (c) 2002 Sam Hocevar * All Rights Reserved * * $Id$ * * This program is free software. It commes without any warranty, to * the extent permitted by applicable law. You can redistribute it * and/or modify it under the terms of the Do What The Fuck You Want * To Public License, Version 2, as published by Sam Hocevar. See * http://sam.zoy.org/wtfpl/COPYING for more details. */ #include "config.h" #include #include "common.h" cucul_canvas_t *heart_sprite; cucul_canvas_t *gem_sprite; void init_bonus(game *g, bonus *bo) { cucul_buffer_t *b; int i; for(i = 0; i < BONUS; i++) { bo->type[i] = BONUS_NONE; } b = cucul_load_file("data/bonheart.caca"); heart_sprite = cucul_import_canvas(b, ""); cucul_free_buffer(b); b = cucul_load_file("data/bongem.caca"); gem_sprite = cucul_import_canvas(b, ""); cucul_free_buffer(b); } void draw_bonus(game *g, bonus *bo) { int i; for(i = 0; i < BONUS; i++) { switch(bo->type[i]) { case BONUS_GREEN: cucul_set_canvas_frame(gem_sprite, (bo->n[i]/2 % 3) ? 0 : 1); cucul_blit(g->cv, bo->x[i], bo->y[i], gem_sprite, NULL); break; case BONUS_LIFE: cucul_set_canvas_frame(heart_sprite, (bo->n[i] % 3) ? 0 : 1); cucul_blit(g->cv, bo->x[i], bo->y[i], heart_sprite, NULL); break; case BONUS_NONE: break; } } } void update_bonus(game *g, bonus *bo) { int i; for(i = 0; i < BONUS; i++) { switch(bo->type[i]) { case BONUS_GREEN: bo->n[i]++; bo->y[i]++; if(bo->y[i] > g->h) { bo->type[i] = BONUS_NONE; } break; case BONUS_LIFE: bo->n[i]++; bo->y[i]++; if(bo->y[i] > g->h) { bo->type[i] = BONUS_NONE; } break; case BONUS_NONE: break; } } } void add_bonus(game *g, bonus *bo, int x, int y, int type) { int i; for(i = 0; i < BONUS; i++) { if(bo->type[i] == BONUS_NONE) { bo->type[i] = type; bo->x[i] = x; bo->y[i] = y; bo->n[i] = 0; break; } } }