/* * ttyvaders Textmode shoot'em up * Copyright (c) 2002 Sam Hocevar * All Rights Reserved * * $Id$ * * This program is free software. It comes 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" caca_canvas_t *heart_sprite; caca_canvas_t *gem_sprite; void init_bonus(game *g, bonus *bo) { int i; for(i = 0; i < BONUS; i++) { bo->type[i] = BONUS_NONE; } heart_sprite = caca_create_canvas(0, 0); caca_import_file(heart_sprite, "data/bonheart.txt", "utf8"); gem_sprite = caca_create_canvas(0, 0); caca_import_file(gem_sprite, "data/bongem.txt", "utf8"); } void draw_bonus(game *g, bonus *bo) { int i; for(i = 0; i < BONUS; i++) { switch(bo->type[i]) { case BONUS_GREEN: caca_set_frame(gem_sprite, (bo->n[i]/2 % 3) ? 0 : 1); caca_blit(g->cv, bo->x[i], bo->y[i], gem_sprite, NULL); break; case BONUS_LIFE: caca_set_frame(heart_sprite, (bo->n[i] % 3) ? 0 : 1); caca_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; } } }