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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
|
#include "shop.h"
#include "game.h"
#include "assets.h"
// Callbacks.
void createPenguinLolCB(Game* game)
{
}
void initShop(Shop* shop, Game* game)
{
Assets* assets = &game->assets;
// Entries.
shop->penguinLol = LoadTextureFromImage(assets->animations[PENGUIN_LOL_ANIMATION].image);
shop->entries[0] = (ShopEntry){&shop->penguinLol, 10, createPenguinLolCB};
}
void updateShop(Shop* shop, Game* game)
{
Texture shopBoard = game->assets.textures[SHOP_BOARD_TEXTURE];
// Board thingy.
DrawTexturePro(
shopBoard,
(Rectangle){0.0, 0.0, shopBoard.width, shopBoard.height},
(Rectangle){0.0, 0.0, WINDOW_WIDTH, WINDOW_HEIGHT},
(Vector2){0.0, 0.0},
0.0,
WHITE
);
// Penguin thingy thing thing
Texture yoyoyo = game->assets.textures[EMPEROR_SHOP_UI_TEXTURE];
DrawTexturePro(
yoyoyo,
(Rectangle){0.0, 0.0, yoyoyo.width, yoyoyo.height},
(Rectangle){0.0, 0.0, WINDOW_WIDTH, WINDOW_HEIGHT},
(Vector2){0.0, 0.0},
0.0,
WHITE
);
// Entry rects.
double startX = 150.0;
double startY = 80.0;
double width = 100.0;
double height = 100.0;
Rectangle rects[SHOP_ENTRY_COUNT] = {
(Rectangle){startX, startY, width, height}
};
// Entries.
for (int i = 0; i < SHOP_ENTRY_COUNT; ++i)
{
Texture entryTexture = *shop->entries[i].texture;
DrawTexturePro(
entryTexture,
(Rectangle){0.0, 0.0, entryTexture.width, entryTexture.height},
rects[i],
(Vector2){0.0, 0.0},
0.0,
WHITE
);
DrawRectangleLinesEx(rects[i], 2, BLACK);
}
}
void closeShop(Shop* shop)
{
UnloadTexture(shop->penguinLol);
}
|