/* Copyright (c) 2023 : Ognjen 'xolatile' Milan Robovic Xhartae is free software! You will redistribute it or modify it under the terms of the GNU General Public License by Free Software Foundation. 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. 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. */ #ifndef CHAPTER_5_HEADER #define CHAPTER_5_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, maximum, current; } bundle_t; typedef struct symbol_t { number_t character, colour, effect; } symbol_t; typedef struct attribute_t { string_t name; number_t positive_count, negative_count; bundle_t * points; action_t * positive; action_t * negative; } attribute_t; typedef struct skill_t { string_t name; number_t positive_count, learning_rate; bundle_t * points; action_t * positive; } skill_t; typedef struct player_t { string_t name; number_t x, y; symbol_t * symbol; //~bundle_t * health, * armour, * mana, * stamina; //~attribute_t strength, edurance, intelligence, agility; //~skill_t blades, axes, bows, spears; //~skill_t puppet_magic, nature_magic, rune_magic, charm_magic; } player_t; typedef struct block_t { string_t name; number_t collision, override; symbol_t * symbol; } block_t; typedef struct world_t { number_t width, height; block_t * * block; } world_t; typedef procedure_t (* generate_t) (world_t *, number_t, number_t, number_t, number_t, block_t *); typedef struct generator_t { generate_t generate; } generator_t; extern memory_t memorize (number_t size); extern bundle_t * format_bundle (number_t minimum, number_t maximum, number_t current); extern symbol_t * format_symbol (number_t character, number_t colour, number_t effect); 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 player_t * game_player (string_t name, symbol_t * symbol); extern block_t * game_block (string_t name, symbol_t * symbol, 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_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); extern procedure_t play_game (procedure_t); #endif