Umorna -- Tiny game written to test 'chads' library, it uses assets from itch.io...
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.

54 lines
1.7KB

  1. #include "engine.h"
  2. void view_unit (int race, int unit, int x, int y) {
  3. int u = 0;
  4. int v = (unit - race * 18) * BASE_SIZE;
  5. int width = BASE_SIZE;
  6. int height = BASE_SIZE;
  7. switch (race) {
  8. case orc: render_sprite (orcs, x, y, u, v, width, height); break;
  9. case human: render_sprite (humans, x, y, u, v, width, height); break;
  10. case elf: render_sprite (elves, x, y, u, v, width, height); break;
  11. default: break;
  12. }
  13. }
  14. void view_menu (int menu, int align, int x, int y) {
  15. int width = (int) strlen (menu_text [menu] [0]) * ICON_SIZE;
  16. int height = menu_items [menu] * ICON_SIZE;
  17. int item;
  18. if (menu_show [menu] == 0) {
  19. return;
  20. }
  21. //~if (menu_alpha [menu] != 0) {
  22. //~DrawRectangle (x, y, width, height, BLACK);
  23. //~}
  24. for (item = 0; item < menu_items [menu]; ++item) {
  25. int u = (menu_icon [menu] [item] / 10) * ICON_SIZE;
  26. int v = (menu_icon [menu] [item] % 10) * ICON_SIZE;
  27. int aligned_x = (align == 0) ? x : ((render_width () - width) / 2);
  28. int aligned_y = (align == 0) ? y : ((render_height () - height) / 2);
  29. render_sprite (ui, aligned_x, aligned_y + item * ICON_SIZE, u, v, ICON_SIZE, ICON_SIZE);
  30. render_string (menu_text [menu] [item], aligned_x + ICON_SIZE, aligned_y + item * ICON_SIZE);
  31. }
  32. }
  33. void view_map (void) {
  34. int x, y;
  35. for (x = 0; x < CHAD_WORLD_WIDTH; ++x) {
  36. for (y = 0; y < CHAD_WORLD_HEIGHT; ++y) {
  37. int index = chad_world [0] [x] [y];
  38. int catch = (y * y + x + x / (y + 1) + y / (x + 1)) % chad_block_change [index];
  39. render_sprite (ashlands, x * BASE_SIZE, y * BASE_SIZE, catch * BASE_SIZE, index * BASE_SIZE, BASE_SIZE, BASE_SIZE);
  40. }
  41. }
  42. }