More to come...
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.

112 rindas
4.5KB

  1. /*
  2. Copyright (c) 2023 : Ognjen 'xolatile' Milan Robovic
  3. Xhartae is free software! You will redistribute it or modify it under the terms of the GNU General Public License by Free Software Foundation.
  4. And when you do redistribute it or modify it, it will use either version 3 of the License, or (at yours truly opinion) any later version.
  5. It is distributed in the hope that it will be useful or harmful, it really depends... But no warranty what so ever, seriously. See GNU/GPLv3.
  6. */
  7. #ifndef CHAPTER_5_HEADER
  8. #define CHAPTER_5_HEADER
  9. #include "chapter_0.h"
  10. #include "chapter_1.h"
  11. #include "chapter_2.h"
  12. #include "chapter_3.h"
  13. /*
  14. Okay, we're finally on chapter five, and now we'll write something fun, not serious and boring. Before the Great Flood, when our ancestors were riding dinosaurs, building
  15. pyramids, killing African men and mating with Asian women, people didn't have dedicated nor integrated graphical processing units, called GPUs. They only had their terminals,
  16. built inside some of their spaceships. And what did they do with them? They played terminal rogue-like games, similar to those that archeologists discovered in ancient Egypt,
  17. Syria, Sumeria, Greece and Atlantis. They were reconstructed around 50 years ago by some guy that made the game Rogue. So, all those myths, sagas and legends about Anubis,
  18. Gilgamesh, Achilles, Inana, Gaea, they were just playable characters or main characters in those games, with different statistics, skills, attributes and back-story. Now, lets
  19. make a simple terminal rogue-like game using what we wrote in previous chapters.
  20. First of all, lets talk briefly about keyword 'typedef' and why I hate to use it.
  21. */
  22. typedef int number_t;
  23. typedef void procedure_t;
  24. typedef char * string_t;
  25. typedef void * memory_t;
  26. typedef enum action_t {
  27. GAME_ACTION_NONE,
  28. GAME_ACTION_WAIT, GAME_ACTION_WALK, GAME_ACTION_REST, GAME_ACTION_CAMP,
  29. GAME_ACTION_SWING_BLADE, GAME_ACTION_SWING_AXE, GAME_ACTION_SHOOT_ARROW, GAME_ACTION_THROW_SPEAR,
  30. GAME_ACTION_SUMMON_PUPPET, GAME_ACTION_CALL_NATURE, GAME_ACTION_CITE_RUNE, GAME_ACTION_CAST_CHARM,
  31. GAME_ACTION_COUNT
  32. } action_t;
  33. typedef struct bundle_t {
  34. number_t minimum, maximum, current;
  35. } bundle_t;
  36. typedef struct symbol_t {
  37. number_t character, colour, effect;
  38. } symbol_t;
  39. typedef struct attribute_t {
  40. string_t name;
  41. number_t positive_count, negative_count;
  42. bundle_t * points;
  43. action_t * positive;
  44. action_t * negative;
  45. } attribute_t;
  46. typedef struct skill_t {
  47. string_t name;
  48. number_t positive_count, learning_rate;
  49. bundle_t * points;
  50. action_t * positive;
  51. } skill_t;
  52. typedef struct player_t {
  53. string_t name;
  54. number_t x, y;
  55. symbol_t * symbol;
  56. //~bundle_t * health, * armour, * mana, * stamina;
  57. //~attribute_t strength, edurance, intelligence, agility;
  58. //~skill_t blades, axes, bows, spears;
  59. //~skill_t puppet_magic, nature_magic, rune_magic, charm_magic;
  60. } player_t;
  61. typedef struct block_t {
  62. string_t name;
  63. number_t collision, override;
  64. symbol_t * symbol;
  65. } block_t;
  66. typedef struct world_t {
  67. number_t width, height;
  68. block_t * * block;
  69. } world_t;
  70. typedef procedure_t (* generate_t) (world_t *, number_t, number_t, number_t, number_t, block_t *);
  71. typedef struct generator_t {
  72. generate_t generate;
  73. } generator_t;
  74. extern memory_t memorize (number_t size);
  75. extern bundle_t * format_bundle (number_t minimum, number_t maximum, number_t current);
  76. extern symbol_t * format_symbol (number_t character, number_t colour, number_t effect);
  77. extern generator_t * game_generator (generate_t generator);
  78. extern attribute_t * game_attribute (string_t name, bundle_t * points, ...);
  79. extern skill_t * game_skill (string_t name, bundle_t * points, ...);
  80. extern player_t * game_player (string_t name, symbol_t * symbol);
  81. extern block_t * game_block (string_t name, symbol_t * symbol, number_t collision, number_t override);
  82. extern world_t * game_world (number_t width, number_t height, ...);
  83. extern procedure_t game_render_attribute (attribute_t * attribute, number_t x, number_t y);
  84. extern procedure_t game_render_skill (skill_t * skill, number_t x, number_t y);
  85. extern procedure_t game_render_player (player_t * player);
  86. extern procedure_t game_render_block (block_t * block, number_t x, number_t y);
  87. extern procedure_t game_render_world (world_t * world, number_t x, number_t y, number_t width, number_t height);
  88. extern procedure_t play_game (procedure_t);
  89. #endif