Umorna -- Tiny game written to test 'chads' library, it uses assets from itch.io...
Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

105 rindas
2.7KB

  1. #include "render.h"
  2. #include <stdlib.h>
  3. #include <raylib.h>
  4. static Texture2D render_texture [render_texture_count];
  5. static Font font = { 0 };
  6. static Color tint = { 255, 255, 255, 255 };
  7. static Vector2 dump = { 0, 0 };
  8. static void (* render_action [80]) (void);
  9. static void render_clean_up (void) {
  10. CloseWindow ();
  11. }
  12. static void render_exit (void) {
  13. engine_active = 0;
  14. }
  15. float render_zoom = 2.0;
  16. int engine_active = 0;
  17. int signal = signal_none;
  18. int window_width (void) { return (GetScreenWidth ()); }
  19. int window_height (void) { return (GetScreenHeight ()); }
  20. void render_sprite (int sprite, int x, int y, int u, int v, int width, int height) {
  21. Rectangle source, destination;
  22. source.x = u;
  23. source.y = v;
  24. source.width = width;
  25. source.height = height;
  26. destination.x = x;
  27. destination.y = y;
  28. destination.width = width * ((sprite <= icons) ? 1 : render_zoom);
  29. destination.height = height * ((sprite <= icons) ? 1 : render_zoom);
  30. DrawTexturePro (render_texture [sprite], source, destination, dump, 0.0, tint);
  31. }
  32. void render_string (char * string, int x, int y) {
  33. Vector2 position = { 4, 4 };
  34. position.x += x;
  35. position.y += y;
  36. DrawTextPro (font, string, position, dump, 0.0, FONT_SIZE, 4, tint);
  37. }
  38. void engine_configure (void) {
  39. engine_active = 1;
  40. InitWindow (1800, 900, "EAX");
  41. SetTargetFPS (60);
  42. font = LoadFont ("sprite/gothic.ttf");
  43. atexit (render_clean_up);
  44. render_action [0] = render_exit;
  45. render_texture [menus] = LoadTexture ("sprite/menus.png");
  46. render_texture [icons] = LoadTexture ("sprite/icons.png");
  47. SetTextureFilter (render_texture [menus], TEXTURE_FILTER_POINT);
  48. SetTextureFilter (render_texture [icons], TEXTURE_FILTER_POINT);
  49. render_texture [orcs] = LoadTexture ("sprite/orcs.png"); /* TODO */
  50. /*render_texture [humans] = LoadTexture ("sprite/humans.png");
  51. render_texture [elves] = LoadTexture ("sprite/elves.png");*/
  52. render_texture [ashlands] = LoadTexture ("sprite/ashlands.png");
  53. }
  54. void engine_synchronize (void) {
  55. Color background = { 0, 0, 0, 0 };
  56. EndDrawing ();
  57. if (WindowShouldClose ()) { engine_active = 0; }
  58. signal = GetKeyPressed ();
  59. switch (signal) {
  60. case KEY_UP: signal = signal_up; break;
  61. case KEY_DOWN: signal = signal_down; break;
  62. case KEY_LEFT: signal = signal_left; break;
  63. case KEY_RIGHT: signal = signal_right; break;
  64. case KEY_ESCAPE: signal = signal_escape; break;
  65. case KEY_R: signal = signal_r; break;
  66. case KEY_T: signal = signal_t; break;
  67. case KEY_S: signal = signal_s; break;
  68. case KEY_V: signal = signal_v; break;
  69. default: signal = signal_none; break;
  70. }
  71. BeginDrawing ();
  72. ClearBackground (background);
  73. }