|
- #ifndef CHAPTER_X_HEADER
- #define CHAPTER_X_HEADER
-
- #include "chapter_0.h"
- #include "chapter_1.h"
- #include "chapter_2.h"
- #include "chapter_3.h"
-
- /*
- 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
- 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,
- 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,
- 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,
- 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
- make a simple terminal rogue-like game using what we wrote in previous chapters.
-
- First of all, lets talk briefly about keyword 'typedef' and why I hate to use it.
- */
-
- typedef int number_t;
- typedef void procedure_t;
- typedef char * string_t;
- typedef void * memory_t;
-
- typedef enum action_t {
- GAME_ACTION_NONE,
- GAME_ACTION_WAIT, GAME_ACTION_WALK, GAME_ACTION_REST, GAME_ACTION_CAMP,
- GAME_ACTION_SWING_BLADE, GAME_ACTION_SWING_AXE, GAME_ACTION_SHOOT_ARROW, GAME_ACTION_THROW_SPEAR,
- GAME_ACTION_SUMMON_PUPPET, GAME_ACTION_CALL_NATURE, GAME_ACTION_CITE_RUNE, GAME_ACTION_CAST_CHARM,
- GAME_ACTION_COUNT
- } action_t;
-
- typedef struct bundle_t {
- number_t minimum;
- number_t maximum;
- number_t current;
- } bundle_t;
-
- typedef struct symbol_t {
- number_t character;
- number_t colour;
- number_t effect;
- } symbol_t;
-
- typedef struct sprite_t {
- number_t width;
- number_t height;
- memory_t data;
- } sprite_t;
-
- typedef struct attribute_t {
- string_t name;
- number_t positive_count;
- number_t negative_count;
- bundle_t * points;
- action_t * positive;
- action_t * negative;
- } attribute_t;
-
- typedef struct skill_t {
- string_t name;
- number_t positive_count;
- number_t learning_rate;
- bundle_t * points;
- action_t * positive;
- } skill_t;
-
- typedef struct bot_t {
- string_t name;
- number_t x;
- number_t y;
- symbol_t * symbol;
- sprite_t * sprite;
- bundle_t * health;
- bundle_t * mana;
- bundle_t * stamina;
- } bot_t;
-
- typedef struct player_t {
- string_t name;
- number_t x;
- number_t y;
- symbol_t * symbol;
- sprite_t * sprite;
- bundle_t * health;
- bundle_t * mana;
- bundle_t * stamina;
- number_t attribute_count;
- number_t skill_count;
- attribute_t * * attributes;
- skill_t * * skills;
- } player_t;
-
- typedef struct block_t {
- string_t name;
- number_t collision;
- number_t override;
- symbol_t * symbol;
- sprite_t * sprite;
- } block_t;
-
- typedef struct world_t {
- number_t width;
- number_t height;
- number_t item_count;
- number_t bot_count;
- block_t * * block;
- bot_t * bots;
- player_t * player;
- } world_t;
-
- typedef procedure_t (* generate_t) (world_t *, memory_t, number_t, number_t, number_t, number_t);
-
- typedef struct generator_t {
- generate_t generate;
- } generator_t;
-
- extern procedure_t game_clean_up (procedure_t);
-
- extern bundle_t * game_bundle (number_t minimum, number_t maximum, number_t current);
- extern symbol_t * game_symbol (number_t character, number_t colour, number_t effect);
- extern sprite_t * game_sprite (number_t width, number_t height, memory_t data);
-
- extern generator_t * game_generator (generate_t generator);
-
- extern attribute_t * game_attribute (string_t name, bundle_t * points, ...);
- extern skill_t * game_skill (string_t name, bundle_t * points, ...);
-
- extern bot_t * game_bot (string_t name, symbol_t * symbol, sprite_t * sprite, bundle_t * health, bundle_t * mana, bundle_t * stamina);
- extern player_t * game_player (string_t name, symbol_t * symbol, sprite_t * sprite, bundle_t * health, bundle_t * mana, bundle_t * stamina, ...);
-
- extern block_t * game_block (string_t name, symbol_t * symbol, sprite_t * sprite, number_t collision, number_t override);
-
- extern world_t * game_world (number_t width, number_t height, ...);
-
- extern procedure_t game_render_attribute (attribute_t * attribute, number_t x, number_t y);
- extern procedure_t game_render_skill (skill_t * skill, number_t x, number_t y);
-
- extern procedure_t game_render_bot (bot_t * bot);
- extern procedure_t game_render_player (player_t * player);
-
- extern procedure_t game_render_block (block_t * block, number_t x, number_t y);
-
- extern procedure_t game_render_world (world_t * world, number_t x, number_t y, number_t width, number_t height);
-
- #endif
|