1/***********************************************************************************
2*
3* KING GAME JAM - GRAY TEAM
4*
5* <Game title>
6* <Game description>
7*
8* This game has been created using raylib (www.raylib.com)
9* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
10*
11* Copyright (c) 2014 Ramon Santamaria (@raysan5)
12*
13************************************************************************************/
14
15#include "raylib.h"
16#include "monster.h"
17
18void UpdateMonster(Monster *monster)
19{
20 if (!monster->active)
21 {
22 if (CheckCollisionPointRec(GetMousePosition(), monster->bounds)) monster->selected = true;
23 else monster->selected = false;
24 }
25 else if (monster->spooky)
26 {
27 monster->framesCounter++;
28 monster->currentSeq = 0;
29
30 if (monster->framesCounter > 7)
31 {
32 monster->currentFrame++;
33 monster->framesCounter = 0;
34
35 if (monster->currentFrame > monster->numFrames - 1) monster->currentFrame = 1;
36 }
37 }
38
39 monster->frameRec.x = monster->currentFrame*monster->texture.width/monster->numFrames;
40 monster->frameRec.y = monster->currentSeq*monster->texture.height;
41}
42
43void DrawMonster(Monster monster, int scroll)
44{
45 Vector2 scrollPos = { monster.position.x - scroll, monster.position.y };
46
47 if (monster.selected) DrawTextureRec(monster.texture, monster.frameRec, scrollPos, RED);
48 else DrawTextureRec(monster.texture, monster.frameRec, scrollPos, WHITE);
49}
50
51void UnloadMonster(Monster monster)
52{
53 UnloadTexture(monster.texture);
54}