aboutsummaryrefslogtreecommitdiffstats
path: root/src/clicky.c
blob: d8d64f9ca3afae74f369cf1fa4c67cfacd7a14d8 (plain) (blame)
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
#include "clicky.h"
#include "game.h"
#include "assets.h"
#include <raylib.h>

void updateClicky(Game* game, Clicky* clicky)
{
    clicky->updateCB(game, clicky);
}

void updatePenguinLol(Game* game, Clicky* clicky)
{
    if (IsMouseButtonPressed(MOUSE_LEFT_BUTTON))
    {
        replayAnimation(&clicky->animation);
    }

    // Run animation and update.
    runAnimation(&clicky->animation);

    Texture texture = clicky->animation.texture;
    DrawTexturePro(texture, (Rectangle){0.0, 0.0, texture.width, texture.height},
                   clicky->rect, Vector2Zero(), 0.0, WHITE);
}

Clicky createPenguinLolClicky(Game* game)
{
    Clicky clicky;

    clicky.animation = createAnimation(&game->assets.animations[PENGUIN_LOL_ANIMATION], ANIMATION_DEFAULT_DELAY);
    clicky.animation.repeat = false;
    clicky.texture = NULL;
    clicky.rect = (Rectangle){0.0, 0.0, 128.0, 128.0};

    clicky.data = NULL;
    clicky.updateCB = updatePenguinLol;

    return clicky;
}

void freePenginLolClicky(Clicky clicky)
{
    closeAnimation(&clicky.animation);
}