forked from sandsmark/kart
-
Notifications
You must be signed in to change notification settings - Fork 0
/
powerup.c
39 lines (34 loc) · 1.26 KB
/
powerup.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#include "map.h"
#include "powerup.h"
#include "renderer.h"
#include "shell.h"
// none doesnæt have an image
static SDL_Texture *textures[POWERUP_STAR+1] = {0};
void powerup_render(SDL_Renderer *ren, PowerUp type, ivec2 pos)
{
SDL_Rect target;
target.x = pos.x;
target.y = pos.y;
target.w = POWERUPS_WIDTH;
target.h = POWERUPS_HEIGHT;
SDL_RenderCopy(ren, textures[type], 0, &target);
}
int powerups_init()
{
textures[POWERUP_NONE] = ren_load_image("none_powerup.bmp");
textures[POWERUP_BANANA] = ren_load_image("banana.bmp");
textures[POWERUP_GREEN_SHELL] = ren_load_image("green_shell.bmp");
textures[POWERUP_RED_SHELL] = ren_load_image("red_shell.bmp");
textures[POWERUP_BLUE_SHELL] = ren_load_image("blue_shell.bmp");
textures[POWERUP_OIL] = ren_load_image("oil.bmp");
textures[POWERUP_MUSHROOM] = ren_load_image("mushroom.bmp");
textures[POWERUP_BIG_MUSHROOM] = ren_load_image("big_mushroom.bmp");
textures[POWERUP_LIGHTNING] = ren_load_image("lightning.bmp");
textures[POWERUP_STAR] = ren_load_image("star.bmp");
for (int i=0; i<POWERUP_STAR; i++) {
if (!textures[i]) {
return 0;
}
}
return 1;
}