Experimental minimal terminal rogue-like game in Ada programming language. I used to write a lot of Ada programs some time ago, then went in full C and assembly mode, and came back to Ada...
No puede seleccionar más de 25 temas Los temas deben comenzar con una letra o número, pueden incluir guiones ('-') y pueden tener hasta 35 caracteres de largo.

78 líneas
2.8KB

  1. ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
  2. -- Copyright (c) 2023 - Ognjen 'xolatile' Milan Robovic
  3. ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
  4. -- Xabina is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either
  5. -- version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the
  6. -- implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
  7. ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
  8. with ada.text_io;
  9. package body core is
  10. ------------------------------------------------------------------------------------------
  11. r : natural := 1;
  12. function randomize (minimum : natural;
  13. maximum : natural) return natural is
  14. begin
  15. r := r + 1;
  16. return minimum + (r mod maximum);
  17. end randomize;
  18. procedure screen_delete is
  19. begin
  20. ada.text_io.put (escape & "[2J");
  21. end screen_delete;
  22. procedure screen_offset is
  23. begin
  24. ada.text_io.put (escape & "[H");
  25. end screen_offset;
  26. procedure screen_hide_cursor is
  27. begin
  28. ada.text_io.put (escape & "[?25l");
  29. end screen_hide_cursor;
  30. procedure screen_show_cursor is
  31. begin
  32. ada.text_io.put (escape & "[?25h");
  33. end screen_show_cursor;
  34. procedure screen_new_line is
  35. begin
  36. ada.text_io.put (carriage_return & line_feed);
  37. end screen_new_line;
  38. procedure render_character (symbol : character;
  39. colour : character;
  40. effect : character;
  41. y : screen_height;
  42. x : screen_width) is
  43. begin
  44. screen_symbol (y, x) := symbol;
  45. screen_colour (y, x) := colour;
  46. screen_effect (y, x) := effect;
  47. end render_character;
  48. procedure render_buffer is
  49. format : string (1 .. 12) := escape & "[E;3CmS" & escape & "[0m";
  50. begin
  51. screen_offset;
  52. for y in screen_height
  53. loop
  54. for x in screen_width
  55. loop
  56. format (8) := screen_symbol (y, x);
  57. format (6) := screen_colour (y, x);
  58. format (3) := screen_effect (y, x);
  59. ada.text_io.put (format);
  60. end loop;
  61. screen_new_line;
  62. end loop;
  63. end render_buffer;
  64. ------------------------------------------------------------------------------------------
  65. end core;