summaryrefslogtreecommitdiffhomepage
path: root/games/skully_escape/monster.c
diff options
context:
space:
mode:
Diffstat (limited to 'games/skully_escape/monster.c')
-rw-r--r--games/skully_escape/monster.c54
1 files changed, 54 insertions, 0 deletions
diff --git a/games/skully_escape/monster.c b/games/skully_escape/monster.c
new file mode 100644
index 00000000..643d0a73
--- /dev/null
+++ b/games/skully_escape/monster.c
@@ -0,0 +1,54 @@
+/***********************************************************************************
+*
+* KING GAME JAM - GRAY TEAM
+*
+* <Game title>
+* <Game description>
+*
+* This game has been created using raylib (www.raylib.com)
+* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
+*
+* Copyright (c) 2014 Ramon Santamaria (Ray San - [email protected])
+*
+************************************************************************************/
+
+#include "raylib.h"
+#include "monster.h"
+
+void UpdateMonster(Monster *monster)
+{
+ if (!monster->active)
+ {
+ if (CheckCollisionPointRec(GetMousePosition(), monster->bounds)) monster->selected = true;
+ else monster->selected = false;
+ }
+ else if (monster->spooky)
+ {
+ monster->framesCounter++;
+ monster->currentSeq = 0;
+
+ if (monster->framesCounter > 7)
+ {
+ monster->currentFrame++;
+ monster->framesCounter = 0;
+
+ if (monster->currentFrame > monster->numFrames - 1) monster->currentFrame = 1;
+ }
+ }
+
+ monster->frameRec.x = monster->currentFrame*monster->texture.width/monster->numFrames;
+ monster->frameRec.y = monster->currentSeq*monster->texture.height;
+}
+
+void DrawMonster(Monster monster, int scroll)
+{
+ Vector2 scrollPos = { monster.position.x - scroll, monster.position.y };
+
+ if (monster.selected) DrawTextureRec(monster.texture, monster.frameRec, scrollPos, RED);
+ else DrawTextureRec(monster.texture, monster.frameRec, scrollPos, WHITE);
+}
+
+void UnloadMonster(Monster monster)
+{
+ UnloadTexture(monster.texture);
+} \ No newline at end of file