Umorna -- Tiny game written to test 'chads' library, it uses assets from itch.io...
Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

68 lines
1.9KB

  1. #include "render.h"
  2. #include <stdlib.h>
  3. #include <raylib.h>
  4. float render_zoom = 2.0;
  5. static Texture2D render_texture [render_texture_count];
  6. static Font font = { 0 };
  7. static Color tint = { 255, 255, 255, 255 };
  8. static Vector2 dump = { 0, 0 };
  9. int render_width (void) { return (GetScreenWidth ()); }
  10. int render_height (void) { return (GetScreenHeight ()); }
  11. void render_sprite (int sprite, int x, int y, int u, int v, int width, int height) {
  12. Rectangle source, destination;
  13. source.x = u;
  14. source.y = v;
  15. source.width = width;
  16. source.height = height;
  17. destination.x = x;
  18. destination.y = y;
  19. destination.width = width * ((sprite <= overui) ? 1 : render_zoom);
  20. destination.height = height * ((sprite <= overui) ? 1 : render_zoom);
  21. DrawTexturePro (render_texture [sprite], source, destination, dump, 0.0, tint);
  22. }
  23. void render_string (char * string, int x, int y) {
  24. Vector2 position = { 4, 4 };
  25. position.x += x;
  26. position.y += y;
  27. DrawTextPro (font, string, position, dump, 0.0, FONT_SIZE, 4, tint);
  28. }
  29. static void render_clean_up (void) {
  30. CloseWindow ();
  31. }
  32. void render_configure (void) {
  33. InitWindow (1800, 900, "EAX");
  34. SetExitKey (KEY_ESCAPE);
  35. SetTargetFPS (60);
  36. font = LoadFont ("sprite/gothic.ttf");
  37. atexit (render_clean_up);
  38. render_texture [neonui] = LoadTexture ("sprite/neonui.png");
  39. render_texture [ui] = LoadTexture ("sprite/ui.png");
  40. render_texture [overui] = LoadTexture ("sprite/hack.png");
  41. SetTextureFilter (render_texture [neonui], TEXTURE_FILTER_POINT);
  42. SetTextureFilter (render_texture [ui], TEXTURE_FILTER_POINT);
  43. SetTextureFilter (render_texture [overui], TEXTURE_FILTER_POINT);
  44. render_texture [orcs] = LoadTexture ("sprite/orcs.png"); /* TODO */
  45. render_texture [humans] = LoadTexture ("sprite/humans.png");
  46. render_texture [elves] = LoadTexture ("sprite/elves.png");
  47. render_texture [ashlands] = LoadTexture ("sprite/ashlands.png");
  48. }