2023-11-23 15:23:23 -05:00
|
|
|
/*
|
|
|
|
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_6_SOURCE
|
|
|
|
#define CHAPTER_6_SOURCE
|
|
|
|
|
|
|
|
#include "chapter_6.h"
|
|
|
|
|
|
|
|
#define UNUSED(variable) (void) variable
|
|
|
|
|
|
|
|
static procedure_t generate_full_fill_function (world_t * world, number_t width, number_t height, number_t x, number_t y, block_t * block) {
|
|
|
|
UNUSED (width);
|
|
|
|
UNUSED (height);
|
|
|
|
UNUSED (x);
|
|
|
|
UNUSED (y);
|
|
|
|
|
|
|
|
for (number_t j = 0; j < world->height; ++j) {
|
|
|
|
for (number_t i = 0; i < world->width; ++i) {
|
|
|
|
world->block [j * world->width + i] = block;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static procedure_t generate_rectangle_fill_function (world_t * world, number_t width, number_t height, number_t x, number_t y, block_t * block) {
|
|
|
|
for (number_t j = 0; j < height; ++j) {
|
|
|
|
for (number_t i = 0; i < width; ++i) {
|
|
|
|
world->block [(j + y) * world->width + (i + x)] = block;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static procedure_t generate_rectangle_line_function (world_t * world, number_t width, number_t height, number_t x, number_t y, block_t * block) {
|
|
|
|
for (number_t offset = 0; offset < width; ++offset) {
|
|
|
|
world->block [world->width * y + offset + x] = block;
|
|
|
|
world->block [world->width * (height - 1 + y) + offset + x] = block;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (number_t offset = 0; offset < height; ++offset) {
|
|
|
|
world->block [world->width * (y + offset) + x] = block;
|
|
|
|
world->block [world->width * (y + offset) + width - 1 + x] = block;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
procedure_t play_game (procedure_t) {
|
|
|
|
generator_t * full_fill = game_generator (generate_full_fill_function);
|
|
|
|
generator_t * rectangle_fill = game_generator (generate_rectangle_fill_function);
|
|
|
|
generator_t * rectangle_line = game_generator (generate_rectangle_line_function);
|
|
|
|
|
2023-11-24 06:41:20 -05:00
|
|
|
//~attribute_t * strength = game_attribute ("Strength", game_bundle (1, 12, 0), GAME_ACTION_SWING_BLADE, GAME_ACTION_SWING_AXE, -GAME_ACTION_CAMP, 0);
|
|
|
|
//~attribute_t * edurance = game_attribute ("Edurance", game_bundle (1, 12, 0), GAME_ACTION_WALK, GAME_ACTION_CAMP, -GAME_ACTION_REST, 0);
|
|
|
|
//~attribute_t * wisdom = game_attribute ("Wisdom", game_bundle (1, 12, 0), GAME_ACTION_CITE_RUNE, GAME_ACTION_CAST_CHARM, -GAME_ACTION_WALK, 0);
|
|
|
|
//~attribute_t * agility = game_attribute ("Agility", game_bundle (1, 12, 0), GAME_ACTION_SHOOT_ARROW, GAME_ACTION_THROW_SPEAR, -GAME_ACTION_WAIT, 0);
|
|
|
|
|
|
|
|
skill_t * blades = game_skill ("Blades", game_bundle (10, 120, 0), GAME_ACTION_SWING_BLADE, 0);
|
|
|
|
skill_t * axes = game_skill ("Axes", game_bundle (10, 120, 0), GAME_ACTION_SWING_AXE, 0);
|
|
|
|
skill_t * bows = game_skill ("Bows", game_bundle (10, 120, 0), GAME_ACTION_SHOOT_ARROW, 0);
|
|
|
|
skill_t * spears = game_skill ("Spears", game_bundle (10, 120, 0), GAME_ACTION_THROW_SPEAR, 0);
|
|
|
|
skill_t * puppet_magic = game_skill ("Puppet Magic", game_bundle (10, 120, 0), GAME_ACTION_SUMMON_PUPPET, 0);
|
|
|
|
skill_t * nature_magic = game_skill ("Nature Magic", game_bundle (10, 120, 0), GAME_ACTION_CALL_NATURE, 0);
|
|
|
|
skill_t * rune_magic = game_skill ("Rune Magic", game_bundle (10, 120, 0), GAME_ACTION_CITE_RUNE, 0);
|
|
|
|
skill_t * charm_magic = game_skill ("Charm Magic", game_bundle (10, 120, 0), GAME_ACTION_CAST_CHARM, 0);
|
|
|
|
|
|
|
|
bot_t * goblin = game_bot ("Goblin", game_symbol ('g', COLOUR_RED, EFFECT_NORMAL), game_bundle (0, 11, 11), game_bundle (0, 3, 3), game_bundle (0, 23, 23));
|
|
|
|
bot_t * hob_goblin = game_bot ("Hob Goblin", game_symbol ('g', COLOUR_RED, EFFECT_BOLD), game_bundle (0, 17, 17), game_bundle (0, 7, 7), game_bundle (0, 31, 31));
|
|
|
|
bot_t * orc = game_bot ("Orc", game_symbol ('G', COLOUR_RED, EFFECT_NORMAL), game_bundle (0, 23, 23), game_bundle (0, 5, 5), game_bundle (0, 47, 47));
|
|
|
|
bot_t * ogre = game_bot ("Ogre", game_symbol ('G', COLOUR_RED, EFFECT_BOLD), game_bundle (0, 37, 37), game_bundle (0, 2, 2), game_bundle (0, 83, 83));
|
|
|
|
|
|
|
|
player_t * player = game_player ("Riri", game_symbol ('@', COLOUR_CYAN, EFFECT_BOLD), game_bundle (0, 29, 29), game_bundle (0, 3, 3), game_bundle (0, 37, 37),
|
|
|
|
//~strength, edurance, wisdom, agility, NULL,
|
|
|
|
game_attribute ("Strength", game_bundle (1, 12, 0), GAME_ACTION_SWING_BLADE, GAME_ACTION_SWING_AXE, -GAME_ACTION_CAMP, 0),
|
|
|
|
game_attribute ("Edurance", game_bundle (1, 12, 0), GAME_ACTION_WALK, GAME_ACTION_CAMP, -GAME_ACTION_REST, 0),
|
|
|
|
game_attribute ("Wisdom", game_bundle (1, 12, 0), GAME_ACTION_CITE_RUNE, GAME_ACTION_CAST_CHARM, -GAME_ACTION_WALK, 0),
|
|
|
|
game_attribute ("Agility", game_bundle (1, 12, 0), GAME_ACTION_SHOOT_ARROW, GAME_ACTION_THROW_SPEAR, -GAME_ACTION_WAIT, 0),
|
|
|
|
NULL,
|
|
|
|
blades, axes, bows, spears, puppet_magic, nature_magic, rune_magic, charm_magic, NULL);
|
|
|
|
|
|
|
|
block_t * grass = game_block ("Grass", game_symbol (',', COLOUR_GREEN, EFFECT_BOLD), FALSE, FALSE);
|
|
|
|
block_t * stone_floor = game_block ("Stone Floor", game_symbol ('.', COLOUR_GREY, EFFECT_BOLD), FALSE, FALSE);
|
|
|
|
block_t * stone_wall = game_block ("Stone Wall", game_symbol ('#', COLOUR_GREY, EFFECT_BOLD), TRUE, FALSE);
|
2023-11-23 15:23:23 -05:00
|
|
|
|
|
|
|
world_t * world = game_world (300, 100, full_fill, 0, 0, 0, 0, grass,
|
|
|
|
rectangle_fill, 5, 9, 2, 4, stone_floor,
|
|
|
|
rectangle_line, 5, 9, 2, 4, stone_wall,
|
|
|
|
NULL);
|
|
|
|
|
2023-11-24 06:41:20 -05:00
|
|
|
//~player->attributes [0]->points->current = 7;
|
|
|
|
//~player->attributes [1]->points->current = 3;
|
|
|
|
//~player->attributes [2]->points->current = 5;
|
|
|
|
//~player->attributes [3]->points->current = 3;
|
|
|
|
|
2023-11-23 15:23:23 -05:00
|
|
|
curses_configure ();
|
|
|
|
|
|
|
|
terminal_show_cursor (FALSE);
|
|
|
|
|
|
|
|
while (curses_active) {
|
2023-11-23 16:32:15 -05:00
|
|
|
number_t game_screen_offset = curses_screen_width - 40;
|
|
|
|
|
2023-11-23 15:23:23 -05:00
|
|
|
curses_render_background (' ', COLOUR_WHITE, EFFECT_NORMAL);
|
|
|
|
|
|
|
|
game_render_world (world, 0, 0, game_screen_offset, curses_screen_height);
|
|
|
|
|
2023-11-24 06:41:20 -05:00
|
|
|
game_render_bot (goblin);
|
|
|
|
|
2023-11-23 15:23:23 -05:00
|
|
|
game_render_player (player);
|
|
|
|
|
2023-11-24 06:41:20 -05:00
|
|
|
game_render_attribute (game_screen_offset, 1, player->attributes [0], player->attributes [1], player->attributes [2], player->attributes [3], NULL);
|
2023-11-23 15:23:23 -05:00
|
|
|
|
2023-11-23 16:32:15 -05:00
|
|
|
game_render_skill (game_screen_offset, 6, blades, axes, bows, spears, puppet_magic, nature_magic, rune_magic, charm_magic, NULL);
|
2023-11-23 15:23:23 -05:00
|
|
|
|
|
|
|
switch (curses_character) {
|
|
|
|
case SIGNAL_ARROW_UP: player->y -= 1; limit (& player->y, 0, world->height - 1); break;
|
|
|
|
case SIGNAL_ARROW_DOWN: player->y += 1; limit (& player->y, 0, world->height - 1); break;
|
|
|
|
case SIGNAL_ARROW_LEFT: player->x -= 1; limit (& player->x, 0, world->width - 1); break;
|
|
|
|
case SIGNAL_ARROW_RIGHT: player->x += 1; limit (& player->x, 0, world->width - 1); break;
|
|
|
|
default: break;
|
|
|
|
}
|
|
|
|
|
|
|
|
curses_synchronize ();
|
|
|
|
}
|
|
|
|
|
|
|
|
terminal_show_cursor (TRUE);
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|