More to come...
Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.

84 рядки
3.3KB

  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 char * string_t;
  24. typedef void * memory_t;
  25. typedef enum action_t {
  26. GAME_ACTION_NONE,
  27. GAME_ACTION_WAIT, GAME_ACTION_WALK, GAME_ACTION_REST, GAME_ACTION_CAMP,
  28. GAME_ACTION_SWING_BLADE, GAME_ACTION_SWING_AXE, GAME_ACTION_SHOOT_ARROW, GAME_ACTION_THROW_SPEAR,
  29. GAME_ACTION_SUMMON_PUPPET, GAME_ACTION_CALL_NATURE, GAME_ACTION_CITE_RUNE, GAME_ACTION_CAST_CHARM,
  30. GAME_ACTION_COUNT
  31. } action_t;
  32. typedef struct game_t {
  33. number_t active, screen_width, screen_height;
  34. } game_t;
  35. typedef struct bundle_t {
  36. number_t minimum, maximum, current, booster;
  37. } bundle_t;
  38. typedef struct skill_t {
  39. string_t name;
  40. number_t positive_count;
  41. number_t learning_rate;
  42. bundle_t * points;
  43. action_t * positive;
  44. } skill_t;
  45. typedef struct attribute_t {
  46. string_t name;
  47. number_t positive_count, negative_count;
  48. bundle_t * points;
  49. action_t * positive, * negative;
  50. } attribute_t;
  51. typedef struct player_t {
  52. string_t name;
  53. number_t x, y;
  54. bundle_t health, armour, mana, stamina;
  55. attribute_t strength, edurance, intelligence, agility;
  56. skill_t blades, axes, bows, spears;
  57. skill_t puppet_magic, nature_magic, rune_magic, charm_magic;
  58. } player_t;
  59. extern game_t game;
  60. extern player_t player;
  61. extern skill_t * game_skill (string_t name, bundle_t * points, ...);
  62. extern attribute_t * game_attribute (string_t name, bundle_t * points, ...);
  63. extern void game_render_skill (skill_t * skill, number_t x, number_t y);
  64. extern void game_render_attribute (attribute_t * attribute, number_t x, number_t y);
  65. extern void play_game (void);
  66. #endif