You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

53 line
1.6 KiB

  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. #include "raylib.h"
  15. #include "monster.h"
  16. void UpdateMonster(Monster *monster)
  17. {
  18. if (!monster->active)
  19. {
  20. if (CheckCollisionPointRec(GetMousePosition(), monster->bounds)) monster->selected = true;
  21. else monster->selected = false;
  22. }
  23. else if (monster->spooky)
  24. {
  25. monster->framesCounter++;
  26. monster->currentSeq = 0;
  27. if (monster->framesCounter > 7)
  28. {
  29. monster->currentFrame++;
  30. monster->framesCounter = 0;
  31. if (monster->currentFrame > monster->numFrames - 1) monster->currentFrame = 1;
  32. }
  33. }
  34. monster->frameRec.x = monster->currentFrame*monster->texture.width/monster->numFrames;
  35. monster->frameRec.y = monster->currentSeq*monster->texture.height;
  36. }
  37. void DrawMonster(Monster monster, int scroll)
  38. {
  39. Vector2 scrollPos = { monster.position.x - scroll, monster.position.y };
  40. if (monster.selected) DrawTextureRec(monster.texture, monster.frameRec, scrollPos, RED);
  41. else DrawTextureRec(monster.texture, monster.frameRec, scrollPos, WHITE);
  42. }
  43. void UnloadMonster(Monster monster)
  44. {
  45. UnloadTexture(monster.texture);
  46. }