crocparty/game/game_collectible.c
2024-02-28 16:10:09 -08:00

57 lines
1.7 KiB
C

#include <assert.h>
#include "game.h"
#include "art/game_collectibles.h"
// If this isn't enough, raise the number
#define GAME_COLLECTIBLES_N 32
sys_i32 game_collectible_next = 0;
game_collectible game_collectibles[GAME_COLLECTIBLES_N];
sys_i32 game_collectible_wobb_frame = 0;
void game_collectibles_preinit() {
}
void game_collectible_create(sys_i32 x, sys_i32 y, game_collectible_type type) {
assert(game_collectible_next < GAME_COLLECTIBLES_N && "too many collectibles");
sys_i32 id = game_collectible_next++;
game_collectibles[id].x = x;
game_collectibles[id].y = y;
game_collectibles[id].type = type;
}
void game_collectibles_init() {
}
void game_collectibles_update() {
game_collectible_wobb_frame += 1;
}
void game_collectibles_draw() {
for (sys_i32 i = 0; i < game_collectible_next; i++) {
game_collectible c = game_collectibles[i];
sys_i32 x = c.x / PIXEL_SZ_MICROPIXEL;
sys_i32 y = c.y / PIXEL_SZ_MICROPIXEL;
y += game_wobb3(game_collectible_wobb_frame & 0xff);
switch(c.type) {
case GAME_COLLECTIBLE_TYPE_CAKE:
sys_sprite_draw_ext(
spr_game_collectibles,0,x-16,y-16,4,4,false,false);
break;
case GAME_COLLECTIBLE_TYPE_MONEY_BIG:
sys_sprite_draw_ext(
spr_game_collectibles,4,x-8,y-8,2,2,false,false);
break;
case GAME_COLLECTIBLE_TYPE_MONEY_SMALL:
sys_sprite_draw_ext(
spr_game_collectibles,16,x-8,y-8,2,2,false,false);
break;
default:
assert(false&&"invalid collectible");
}
}
}