Initial upload, need to refactor a lot...
7
compile.sh
Normal file
@ -0,0 +1,7 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -xe
|
||||
|
||||
gcc -g -std=gnu17 -Wall -Wextra -Wpedantic -Werror -Ofast -o umorna ./source/main.c -lraylib
|
||||
|
||||
exit
|
9
install.sh
Normal file
@ -0,0 +1,9 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -xe
|
||||
|
||||
mkdir -p /usr/include/xolatile
|
||||
|
||||
cp umorna /usr/bin/umorna
|
||||
|
||||
exit
|
547
source/main.c
Normal file
@ -0,0 +1,547 @@
|
||||
#define CHAD_TRAIT_LIMIT ( 3)
|
||||
#define CHAD_SKILL_LIMIT (24)
|
||||
#define CHAD_VALUE_LIMIT (10)
|
||||
#define CHAD_EFFECT_LIMIT ( 3)
|
||||
#define CHAD_MIGHT_LIMIT ( 1)
|
||||
#define CHAD_MAGIC_LIMIT ( 1)
|
||||
#define CHAD_RACE_LIMIT ( 3)
|
||||
#define CHAD_ITEM_LIMIT ( 3)
|
||||
#define CHAD_UNIT_LIMIT (54)
|
||||
#define CHAD_HERO_LIMIT ( 1)
|
||||
#define CHAD_BLOCK_LIMIT (28)
|
||||
#define CHAD_WORLD_LIMIT ( 1)
|
||||
#define CHAD_WORLD_WIDTH (90)
|
||||
#define CHAD_WORLD_HEIGHT (90)
|
||||
|
||||
#include <xolatile/chads.h>
|
||||
#include <xolatile/chads.c>
|
||||
|
||||
static int strength, dexterity, wisdom;
|
||||
|
||||
static void define_traits (void) {
|
||||
strength = chad_define_trait ("Strength", 1, 1, 10);
|
||||
dexterity = chad_define_trait ("Dexterity", 1, 1, 10);
|
||||
wisdom = chad_define_trait ("Wisdom", 1, 1, 10);
|
||||
}
|
||||
|
||||
static int swords, axes, maces, staves, bows, crossbows, slings, shields, armour, alchemy, medicine, mercantile, farmer, miner, lumber, traps, water_magic, earth_magic,
|
||||
wind_magic, black_magic, rune_magic, summon_magic, ritual_magic, charm_magic;
|
||||
|
||||
static void define_skills (void) {
|
||||
swords = chad_define_skill ("Swords", 1, 1, 100);
|
||||
axes = chad_define_skill ("Axes", 1, 1, 100);
|
||||
maces = chad_define_skill ("Maces", 1, 1, 100);
|
||||
staves = chad_define_skill ("Staves", 1, 1, 100);
|
||||
bows = chad_define_skill ("Bows", 1, 1, 100);
|
||||
crossbows = chad_define_skill ("Crossbows", 1, 1, 100);
|
||||
slings = chad_define_skill ("Slings", 1, 1, 100);
|
||||
shields = chad_define_skill ("Shields", 1, 1, 100);
|
||||
armour = chad_define_skill ("Armour", 1, 1, 100);
|
||||
alchemy = chad_define_skill ("Alchemy", 1, 1, 100);
|
||||
medicine = chad_define_skill ("Medicine", 1, 1, 100);
|
||||
mercantile = chad_define_skill ("Mercantile", 1, 1, 100);
|
||||
farmer = chad_define_skill ("Farmer", 1, 1, 100);
|
||||
miner = chad_define_skill ("Miner", 1, 1, 100);
|
||||
lumber = chad_define_skill ("Lumber", 1, 1, 100);
|
||||
traps = chad_define_skill ("Traps", 1, 1, 100);
|
||||
water_magic = chad_define_skill ("Water Magic", 1, 1, 100);
|
||||
earth_magic = chad_define_skill ("Earth Magic", 1, 1, 100);
|
||||
wind_magic = chad_define_skill ("Wind Magic", 1, 1, 100);
|
||||
black_magic = chad_define_skill ("Black Magic", 1, 1, 100);
|
||||
rune_magic = chad_define_skill ("Rune Magic", 1, 1, 100);
|
||||
summon_magic = chad_define_skill ("Summon Magic", 1, 1, 100);
|
||||
ritual_magic = chad_define_skill ("Ritual Magic", 1, 1, 100);
|
||||
charm_magic = chad_define_skill ("Charm Magic", 1, 1, 100);
|
||||
}
|
||||
|
||||
static int coin, food, wood, stone, iron, gold, silver, coal, gems, mana;
|
||||
|
||||
static void define_values (void) {
|
||||
coin = chad_define_value ("Coin", 1);
|
||||
food = chad_define_value ("Food", 2);
|
||||
wood = chad_define_value ("Wood", 5);
|
||||
stone = chad_define_value ("Stone", 7);
|
||||
iron = chad_define_value ("Iron", 19);
|
||||
gold = chad_define_value ("Silver", 23);
|
||||
silver = chad_define_value ("Gold", 29);
|
||||
coal = chad_define_value ("Coal", 13);
|
||||
gems = chad_define_value ("Gems", 31);
|
||||
mana = chad_define_value ("Mana", 37);
|
||||
}
|
||||
|
||||
static int gain_minor_strength, gain_major_strength, gain_great_strength;
|
||||
|
||||
static void define_effects (void) {
|
||||
gain_minor_strength = chad_define_effect (CHAD_ENTITY_TRAIT, CHAD_TARGET_SELF | CHAD_TARGET_INCREASE, strength, 1);
|
||||
gain_major_strength = chad_define_effect (CHAD_ENTITY_TRAIT, CHAD_TARGET_SELF | CHAD_TARGET_INCREASE, strength, 3);
|
||||
gain_great_strength = chad_define_effect (CHAD_ENTITY_TRAIT, CHAD_TARGET_SELF | CHAD_TARGET_INCREASE, strength, 7);
|
||||
}
|
||||
|
||||
static int might;
|
||||
|
||||
static void define_mights (void) {
|
||||
might = chad_define_might ("Might", gain_minor_strength);
|
||||
}
|
||||
|
||||
static int magic;
|
||||
|
||||
static void define_magics (void) {
|
||||
magic = chad_define_magic ("Magic", 3, gain_major_strength);
|
||||
}
|
||||
|
||||
static int orc, human, elf;
|
||||
|
||||
static void define_races (void) {
|
||||
orc = chad_define_race ("Orc", strength, axes, wood);
|
||||
human = chad_define_race ("Human", dexterity, medicine, iron);
|
||||
elf = chad_define_race ("Elf", wisdom, rune_magic, gems);
|
||||
}
|
||||
|
||||
static int iron_mace, iron_sword, iron_axe;
|
||||
|
||||
static void define_items (void) {
|
||||
iron_mace = chad_define_item ("Iron Mace", 2, CHAD_ITEM_WEAPON, gain_minor_strength);
|
||||
iron_sword = chad_define_item ("Iron Sword", 3, CHAD_ITEM_WEAPON, gain_minor_strength);
|
||||
iron_axe = chad_define_item ("Iron Axe", 2, CHAD_ITEM_WEAPON, gain_minor_strength);
|
||||
}
|
||||
|
||||
static int gnoll, gnoll_shaman, goblin, hob_goblin, thief, looter, warrior, shaman, chief, wolf_rider, boar_rider, overlord, ogre, ogre_mage, troll, war_troll, basilisk, wyvern,
|
||||
peasant, scout, hunter, swordman, axeman, crossbowman, horseman, guard, elite_guard, lancer, knight, kingsman, mage, arch_mage, giant, war_giant, griffin, roc, sprite,
|
||||
nature_spirit, half_elf, ranger, archer, elite_archer, blademaster, water_mage, earth_mage, wind_mage, rune_mage, runemaster, sacrificer, elk_rider, warmaster,
|
||||
coal_golem, iron_golem, sage;
|
||||
|
||||
static void define_units (void) {
|
||||
gnoll = chad_define_unit ("Gnoll", "Dirt-Hut", orc, CHAD_UNIT_RANGE, 1, 2, 7, -1);
|
||||
gnoll_shaman = chad_define_unit ("Gnoll Shaman", "Treehouse", orc, CHAD_UNIT_MAGIC, 1, 3, 7, -1);
|
||||
goblin = chad_define_unit ("Goblin", "Dirty Shed", orc, CHAD_UNIT_MELEE, 2, 3, 7, -1);
|
||||
hob_goblin = chad_define_unit ("Hob-Goblin", "Old Barracks", orc, CHAD_UNIT_MELEE | CHAD_UNIT_MAGIC, 3, 5, 7, -1);
|
||||
thief = chad_define_unit ("Thief", "Thief Storehouse", orc, CHAD_UNIT_MELEE, 3, 7, 7, -1);
|
||||
looter = chad_define_unit ("Looter", "Abandoned Manor", orc, CHAD_UNIT_RANGE, 5, 7, 7, -1);
|
||||
warrior = chad_define_unit ("Warrior", "Longhouse", orc, CHAD_UNIT_MELEE, 7, 11, 7, -1);
|
||||
shaman = chad_define_unit ("Shaman", "Cottage", orc, CHAD_UNIT_MAGIC, 7, 11, 7, -1);
|
||||
chief = chad_define_unit ("Chief", "Campgrounds", orc, CHAD_UNIT_MELEE | CHAD_UNIT_RANGE, 11, 13, 7, -1);
|
||||
wolf_rider = chad_define_unit ("Wolf-Rider", "Wold Den", orc, CHAD_UNIT_MELEE | CHAD_UNIT_RANGE, 17, 17, 7, -1);
|
||||
boar_rider = chad_define_unit ("Boar-Rider", "Boar Ranch", orc, CHAD_UNIT_RANGE, 19, 23, 7, -1);
|
||||
overlord = chad_define_unit ("Overlord", "Orcish Temple", orc, CHAD_UNIT_MELEE | CHAD_UNIT_MAGIC, 23, 13, 7, -1);
|
||||
ogre = chad_define_unit ("Ogre", "Highlands", orc, CHAD_UNIT_MELEE, 29, 23, 7, -1);
|
||||
ogre_mage = chad_define_unit ("Ogre Mage", "Highland Tower", orc, CHAD_UNIT_MELEE | CHAD_UNIT_MAGIC, 31, 29, 7, -1);
|
||||
troll = chad_define_unit ("Troll", "Troll Den", orc, CHAD_UNIT_MELEE, 37, 31, 7, -1);
|
||||
war_troll = chad_define_unit ("War Troll", "Cavern-Fort", orc, CHAD_UNIT_MELEE | CHAD_UNIT_RANGE, 41, 37, 7, -1);
|
||||
basilisk = chad_define_unit ("Basilisk", "Dungeon", orc, CHAD_UNIT_MELEE | CHAD_UNIT_EXTRA, 53, 59, 7, -1);
|
||||
wyvern = chad_define_unit ("Wyvern", "Swamp Pit", orc, CHAD_UNIT_MELEE | CHAD_UNIT_EXTRA, 59, 53, 7, -1);
|
||||
peasant = chad_define_unit ("Peasant", "Farm", human, CHAD_UNIT_MELEE, 1, 1, 7, -1);
|
||||
scout = chad_define_unit ("Scout", "Scout Shack", human, CHAD_UNIT_RANGE, 2, 3, 7, -1);
|
||||
hunter = chad_define_unit ("Hunter", "Archery", human, CHAD_UNIT_RANGE, 2, 3, 7, -1);
|
||||
swordman = chad_define_unit ("Swordman", "House of Slashing", human, CHAD_UNIT_MELEE, 3, 5, 7, -1);
|
||||
axeman = chad_define_unit ("Axeman", "House of Cutting", human, CHAD_UNIT_MELEE, 5, 5, 7, -1);
|
||||
crossbowman = chad_define_unit ("Crossbowman", "House of Shooting", human, CHAD_UNIT_RANGE, 5, 5, 7, -1);
|
||||
horseman = chad_define_unit ("Horseman", "Horse Ranch", human, CHAD_UNIT_MELEE, 7, 11, 7, -1);
|
||||
guard = chad_define_unit ("Guard", "Guard Barracks", human, CHAD_UNIT_MELEE, 7, 7, 7, -1);
|
||||
elite_guard = chad_define_unit ("Elite Guard", "Guard Home", human, CHAD_UNIT_MELEE, 13, 11, 7, -1);
|
||||
lancer = chad_define_unit ("Lancer", "Riding Meadow", human, CHAD_UNIT_MELEE | CHAD_UNIT_RANGE, 17, 17, 7, -1);
|
||||
knight = chad_define_unit ("Knight", "Mansion of Honour", human, CHAD_UNIT_MELEE, 19, 23, 7, -1);
|
||||
kingsman = chad_define_unit ("Kingsman", "King's Academy", human, CHAD_UNIT_MELEE, 19, 17, 7, -1);
|
||||
mage = chad_define_unit ("Mage", "School of Mana", human, CHAD_UNIT_MAGIC, 23, 7, 7, -1);
|
||||
arch_mage = chad_define_unit ("Arch-Mage", "Temple of Mana", human, CHAD_UNIT_MAGIC, 29, 11, 7, -1);
|
||||
giant = chad_define_unit ("Giant", "Mound", human, CHAD_UNIT_MELEE, 41, 59, 7, -1);
|
||||
war_giant = chad_define_unit ("War Giant", "Mound-Fort", human, CHAD_UNIT_MELEE | CHAD_UNIT_RANGE, 43, 67, 7, -1);
|
||||
griffin = chad_define_unit ("Griffin", "Griffin Nest", human, CHAD_UNIT_MELEE, 47, 53, 7, -1);
|
||||
roc = chad_define_unit ("Roc", "Heavenly Temple", human, CHAD_UNIT_MELEE | CHAD_UNIT_MAGIC, 53, 61, 7, -1);
|
||||
sprite = chad_define_unit ("Sprite", "Little Lamp", elf, CHAD_UNIT_MELEE, 1, 1, 7, -1);
|
||||
nature_spirit = chad_define_unit ("Nature Spirit", "Flower Palace", elf, CHAD_UNIT_MELEE, 1, 1, 7, -1);
|
||||
half_elf = chad_define_unit ("Half-Elf", "Slums", elf, CHAD_UNIT_MELEE, 1, 3, 7, -1);
|
||||
ranger = chad_define_unit ("Ranger", "Ranger Guild", elf, CHAD_UNIT_MELEE, 3, 5, 7, -1);
|
||||
archer = chad_define_unit ("Archer", "Arrow House", elf, CHAD_UNIT_MELEE | CHAD_UNIT_RANGE, 3, 7, 7, -1);
|
||||
elite_archer = chad_define_unit ("Elite Archer", "Arrow Fortress", elf, CHAD_UNIT_MELEE | CHAD_UNIT_RANGE, 5, 7, 7, -1);
|
||||
blademaster = chad_define_unit ("Blademaster", "School of Blades", elf, CHAD_UNIT_MELEE | CHAD_UNIT_MAGIC, 7, 11, 7, -1);
|
||||
water_mage = chad_define_unit ("Water Mage", "Water Temple", elf, CHAD_UNIT_MAGIC, 11, 11, 7, -1);
|
||||
earth_mage = chad_define_unit ("Earth Mage", "Earth Temple", elf, CHAD_UNIT_MAGIC, 13, 13, 7, -1);
|
||||
wind_mage = chad_define_unit ("Wind Mage", "Wind Temple", elf, CHAD_UNIT_MAGIC, 13, 17, 7, -1);
|
||||
rune_mage = chad_define_unit ("Rune Mage", "Rune Monastery", elf, CHAD_UNIT_MAGIC, 17, 19, 7, -1);
|
||||
runemaster = chad_define_unit ("Runemaster", "Ancient Ruins", elf, CHAD_UNIT_MAGIC, 19, 23, 7, -1);
|
||||
sacrificer = chad_define_unit ("Sacrificer", "Altair", elf, CHAD_UNIT_MAGIC, 23, 19, 7, -1);
|
||||
elk_rider = chad_define_unit ("Elk Rider", "Elk Ranch-House", elf, CHAD_UNIT_MELEE, 29, 23, 7, -1);
|
||||
warmaster = chad_define_unit ("Warmaster", "Elven Fort", elf, CHAD_UNIT_MELEE | CHAD_UNIT_MAGIC, 41, 59, 7, -1);
|
||||
coal_golem = chad_define_unit ("Coal Golem", "Old Coal Mine", elf, CHAD_UNIT_MELEE, 43, 53, 7, -1);
|
||||
iron_golem = chad_define_unit ("Iron Golem", "Old Iron Mine", elf, CHAD_UNIT_MELEE, 47, 67, 7, -1);
|
||||
sage = chad_define_unit ("Sage", "Cabin in the Woods", elf, CHAD_UNIT_RANGE | CHAD_UNIT_MAGIC, 67, 47, 7, -1);
|
||||
}
|
||||
|
||||
static void define_blocks (void) {
|
||||
(void) chad_define_block ("Ashland", 0, 12, -1, -1, -1);
|
||||
(void) chad_define_block ("Ashdirt", 0, 6, -1, -1, -1);
|
||||
(void) chad_define_block ("Ashdust", 0, 6, -1, -1, -1);
|
||||
|
||||
(void) chad_define_block ("Garbage", CHAD_BLOCK_RANDOM, 12, -1, -1, -1);
|
||||
|
||||
(void) chad_define_block ("Ashdirt", CHAD_BLOCK_UP, 1, 0, 1, -1);
|
||||
(void) chad_define_block ("Ashdirt", CHAD_BLOCK_DOWN, 1, 0, 1, -1);
|
||||
(void) chad_define_block ("Ashdirt", CHAD_BLOCK_LEFT, 1, 0, 1, -1);
|
||||
(void) chad_define_block ("Ashdirt", CHAD_BLOCK_RIGHT, 1, 0, 1, -1);
|
||||
|
||||
(void) chad_define_block ("Ashdirt", CHAD_BLOCK_UP | CHAD_BLOCK_LEFT, 1, 0, 1, -1);
|
||||
(void) chad_define_block ("Ashdirt", CHAD_BLOCK_UP | CHAD_BLOCK_RIGHT, 1, 0, 1, -1);
|
||||
(void) chad_define_block ("Ashdirt", CHAD_BLOCK_DOWN | CHAD_BLOCK_LEFT, 1, 0, 1, -1);
|
||||
(void) chad_define_block ("Ashdirt", CHAD_BLOCK_DOWN | CHAD_BLOCK_RIGHT, 1, 0, 1, -1);
|
||||
(void) chad_define_block ("Ashdirt", CHAD_BLOCK_UP | CHAD_BLOCK_LEFT, 1, 1, 0, -1);
|
||||
(void) chad_define_block ("Ashdirt", CHAD_BLOCK_UP | CHAD_BLOCK_RIGHT, 1, 1, 0, -1);
|
||||
(void) chad_define_block ("Ashdirt", CHAD_BLOCK_DOWN | CHAD_BLOCK_LEFT, 1, 1, 0, -1);
|
||||
(void) chad_define_block ("Ashdirt", CHAD_BLOCK_DOWN | CHAD_BLOCK_RIGHT, 1, 1, 0, -1);
|
||||
|
||||
(void) chad_define_block ("Ashdust", CHAD_BLOCK_UP, 1, 0, 2, -1);
|
||||
(void) chad_define_block ("Ashdust", CHAD_BLOCK_DOWN, 1, 0, 2, -1);
|
||||
(void) chad_define_block ("Ashdust", CHAD_BLOCK_LEFT, 1, 0, 2, -1);
|
||||
(void) chad_define_block ("Ashdust", CHAD_BLOCK_RIGHT, 1, 0, 2, -1);
|
||||
|
||||
(void) chad_define_block ("Ashdust", CHAD_BLOCK_UP | CHAD_BLOCK_LEFT, 1, 0, 2, -1);
|
||||
(void) chad_define_block ("Ashdust", CHAD_BLOCK_UP | CHAD_BLOCK_RIGHT, 1, 0, 2, -1);
|
||||
(void) chad_define_block ("Ashdust", CHAD_BLOCK_DOWN | CHAD_BLOCK_LEFT, 1, 0, 2, -1);
|
||||
(void) chad_define_block ("Ashdust", CHAD_BLOCK_DOWN | CHAD_BLOCK_RIGHT, 1, 0, 2, -1);
|
||||
(void) chad_define_block ("Ashdust", CHAD_BLOCK_UP | CHAD_BLOCK_LEFT, 1, 2, 0, -1);
|
||||
(void) chad_define_block ("Ashdust", CHAD_BLOCK_UP | CHAD_BLOCK_RIGHT, 1, 2, 0, -1);
|
||||
(void) chad_define_block ("Ashdust", CHAD_BLOCK_DOWN | CHAD_BLOCK_LEFT, 1, 2, 0, -1);
|
||||
(void) chad_define_block ("Ashdust", CHAD_BLOCK_DOWN | CHAD_BLOCK_RIGHT, 1, 2, 0, -1);
|
||||
}
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <raylib.h>
|
||||
|
||||
#define BASE_SIZE (16)
|
||||
#define ICON_SIZE (32)
|
||||
#define FONT_SIZE (20)
|
||||
|
||||
static float zoom = 2.0F;
|
||||
|
||||
static Texture2D unit_data [CHAD_UNIT_LIMIT];
|
||||
//~static Texture2D base_data [CHAD_UNIT_LIMIT];
|
||||
|
||||
static void render_unit (int race,
|
||||
int unit,
|
||||
int x,
|
||||
int y) {
|
||||
Rectangle source = { 0, (unit - race * 18) * BASE_SIZE, BASE_SIZE, BASE_SIZE };
|
||||
Rectangle destination = { x, y, BASE_SIZE * zoom, BASE_SIZE * zoom };
|
||||
Vector2 origin = { 0, 0 };
|
||||
|
||||
DrawTexturePro (unit_data [race], source, destination, origin, 0.0F, WHITE);
|
||||
}
|
||||
|
||||
static Texture2D icon_data [CHAD_ENTITY_COUNT];
|
||||
|
||||
static void render_icon (int entity,
|
||||
int index,
|
||||
int x,
|
||||
int y) {
|
||||
char * * name;
|
||||
|
||||
switch (entity) {
|
||||
case CHAD_ENTITY_TRAIT: name = chad_trait_name; break;
|
||||
case CHAD_ENTITY_SKILL: name = chad_skill_name; break;
|
||||
case CHAD_ENTITY_VALUE: name = chad_value_name; break;
|
||||
default: return;
|
||||
}
|
||||
|
||||
DrawTextureRec (icon_data [entity], (Rectangle) { 0, 0 + index * ICON_SIZE, ICON_SIZE, ICON_SIZE }, (Vector2) { x, y }, WHITE);
|
||||
|
||||
DrawText (name [index], x + ICON_SIZE + 6, y + 6, FONT_SIZE, WHITE);
|
||||
}
|
||||
|
||||
static Texture2D ashlands_data;
|
||||
|
||||
static void render_map (void) {
|
||||
int x, y;
|
||||
|
||||
for (x = 0; x < CHAD_WORLD_WIDTH; ++x) {
|
||||
for (y = 0; y < CHAD_WORLD_HEIGHT; ++y) {
|
||||
int index = chad_world [0] [x] [y];
|
||||
int catch = (y * y + x + x / (y + 1) + y / (x + 1)) % chad_block_change [index];
|
||||
|
||||
Rectangle source = { catch * BASE_SIZE, index * BASE_SIZE, BASE_SIZE, BASE_SIZE };
|
||||
Rectangle destination = { x * BASE_SIZE * zoom, y * BASE_SIZE * zoom, BASE_SIZE * zoom, BASE_SIZE * zoom };
|
||||
|
||||
DrawTexturePro (ashlands_data, source, destination, (Vector2) { 0, 0 }, 0.0F, WHITE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#include <fcntl.h>
|
||||
#include <unistd.h>
|
||||
#include <string.h>
|
||||
|
||||
#define SYNTAX_LIMIT (64)
|
||||
|
||||
static int syntax_count = 0;
|
||||
|
||||
static int syntax_enrange [SYNTAX_LIMIT];
|
||||
static int syntax_derange [SYNTAX_LIMIT];
|
||||
static char syntax_begin [SYNTAX_LIMIT] [96];
|
||||
static char syntax_end [SYNTAX_LIMIT] [96];
|
||||
static char syntax_escape [SYNTAX_LIMIT];
|
||||
static int syntax_colour [SYNTAX_LIMIT];
|
||||
|
||||
static int character_compare_array (char character, char * character_array) {
|
||||
int i = 0;
|
||||
|
||||
do {
|
||||
if (character == character_array [i]) {
|
||||
return (1);
|
||||
}
|
||||
} while (++i != (int) strlen (character_array));
|
||||
|
||||
return (0);
|
||||
}
|
||||
|
||||
static void syntax_rule (int enrange,
|
||||
int derange,
|
||||
char * begin,
|
||||
char * end,
|
||||
char escape,
|
||||
int colour) {
|
||||
if (syntax_count >= SYNTAX_LIMIT) {
|
||||
return;
|
||||
}
|
||||
|
||||
strncpy (syntax_begin [syntax_count], begin, 96);
|
||||
strncpy (syntax_end [syntax_count], end, 96);
|
||||
|
||||
syntax_enrange [syntax_count] = enrange;
|
||||
syntax_derange [syntax_count] = derange;
|
||||
syntax_escape [syntax_count] = escape;
|
||||
syntax_colour [syntax_count] = colour;
|
||||
|
||||
++syntax_count;
|
||||
}
|
||||
|
||||
static int syntax_loop (char * string,
|
||||
int * length) {
|
||||
int offset, subset, select;
|
||||
|
||||
for (select = offset = 0; select != syntax_count; ++select) {
|
||||
if (syntax_enrange [select] == 0) {
|
||||
if (syntax_derange [select] == 0) {
|
||||
if (strncmp (string, syntax_begin [select], strlen (syntax_begin [select])) == 0) {
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
if ((strncmp (string, syntax_begin [select], strlen (syntax_begin [select])) == 0)
|
||||
&& (character_compare_array (string [offset + (int) strlen (syntax_begin [select])], syntax_end [select]) == 1)) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
for (subset = 0; subset != (int) strlen (syntax_begin [select]); ++subset) {
|
||||
if (string [offset] == syntax_begin [select] [subset]) {
|
||||
goto selected;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
selected:
|
||||
|
||||
if (select >= syntax_count) {
|
||||
* length = 1;
|
||||
return (select);
|
||||
}
|
||||
|
||||
for (offset = 1; string [offset - 1] != '\0'; ++offset) {
|
||||
if (string [offset] == syntax_escape [select]) {
|
||||
++offset;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (syntax_derange [select] == 0) {
|
||||
if (strncmp (& string [offset], syntax_end [select], strlen (syntax_end [select])) == 0) {
|
||||
* length = offset + (int) strlen (syntax_end [select]);
|
||||
goto finished;
|
||||
}
|
||||
} else {
|
||||
subset = 0;
|
||||
if (strcmp (syntax_end [select], "") == 0) {
|
||||
break;
|
||||
} do {
|
||||
if (string [offset] == syntax_end [select] [subset]) {
|
||||
* length = offset;
|
||||
goto finished;
|
||||
}
|
||||
} while (++subset != (int) strlen (syntax_end [select]));
|
||||
}
|
||||
}
|
||||
|
||||
finished:
|
||||
|
||||
return (select);
|
||||
}
|
||||
|
||||
#define COLOUR_GREY (0)
|
||||
#define COLOUR_WHITE (1)
|
||||
#define COLOUR_BLUE (2)
|
||||
#define COLOUR_YELLOW (3)
|
||||
#define COLOUR_CYAN (4)
|
||||
#define COLOUR_PINK (5)
|
||||
#define COLOUR_LMAO (7)
|
||||
|
||||
static void syntax_c (void) {
|
||||
char * separators = ".,:;<=>+-*/%!&~^?|()[]{}'\" \t\r\n";
|
||||
|
||||
char * keywords [] = {
|
||||
"register", "volatile", "auto", "const", "static", "extern", "if", "else",
|
||||
"do", "while", "for", "continue", "switch", "case", "default", "break",
|
||||
"enum", "union", "struct", "typedef", "goto", "void", "return", "sizeof",
|
||||
"char", "short", "int", "long", "signed", "unsigned", "float", "double"
|
||||
};
|
||||
|
||||
int word;
|
||||
|
||||
syntax_rule (0, 0, "/*", "*/", '\0', COLOUR_GREY);
|
||||
syntax_rule (0, 0, "//", "\n", '\0', COLOUR_GREY);
|
||||
syntax_rule (0, 0, "#", "\n", '\\', COLOUR_LMAO);
|
||||
syntax_rule (0, 0, "'", "'", '\\', COLOUR_PINK);
|
||||
syntax_rule (0, 0, "\"", "\"", '\\', COLOUR_PINK);
|
||||
|
||||
for (word = 0; word != sizeof (keywords) / sizeof (keywords [0]); ++word) {
|
||||
syntax_rule (0, 1, keywords [word], separators, '\0', COLOUR_YELLOW);
|
||||
}
|
||||
|
||||
syntax_rule (1, 0, "()[]{}", "", '\0', COLOUR_BLUE);
|
||||
syntax_rule (1, 0, ".,:;<=>+*-/%!&~^?|", "", '\0', COLOUR_CYAN);
|
||||
|
||||
syntax_rule (1, 1, "0123456789", separators, '\0', COLOUR_PINK);
|
||||
syntax_rule (1, 1, "abcdefghijklmnopqrstuvwxyz", separators, '\0', COLOUR_WHITE);
|
||||
syntax_rule (1, 1, "ABCDEFGHIJKLMNOPQRSTUVWXYZ", separators, '\0', COLOUR_WHITE);
|
||||
syntax_rule (1, 1, "_", separators, '\0', COLOUR_WHITE);
|
||||
}
|
||||
|
||||
static void render_c_code (char * string,
|
||||
int x,
|
||||
int y) {
|
||||
int select, length = 0, offset, reset_x;
|
||||
|
||||
reset_x = x;
|
||||
|
||||
for (offset = 0; offset < (int) strlen (string); offset += length) {
|
||||
char substring [1024] = "";
|
||||
|
||||
int i = 0, square = 16;
|
||||
|
||||
Color colour = RED;
|
||||
|
||||
select = syntax_loop (& string [offset], & length);
|
||||
|
||||
strncpy (substring, & string [offset], (unsigned long int) length);
|
||||
|
||||
switch (syntax_colour [select]) {
|
||||
case COLOUR_GREY: colour = GRAY; break;
|
||||
case COLOUR_WHITE: colour = WHITE; break;
|
||||
case COLOUR_BLUE: colour = BLUE; break;
|
||||
case COLOUR_YELLOW: colour = YELLOW; break;
|
||||
case COLOUR_CYAN: colour = PURPLE; break;
|
||||
case COLOUR_PINK: colour = RED; break;
|
||||
case COLOUR_LMAO: colour = GREEN; break;
|
||||
default: colour = GREEN; break;
|
||||
}
|
||||
|
||||
for (i = 0; i < (int) strlen (substring); ++i) {
|
||||
if (substring [i] == '\n') {
|
||||
y += square;
|
||||
x = reset_x;
|
||||
} else if (substring [i] == '\t') {
|
||||
x += square * 4;
|
||||
} else {
|
||||
DrawTextCodepoint (GetFontDefault (), substring [i], (Vector2) { x, y }, square, colour);
|
||||
x += square;
|
||||
}
|
||||
}
|
||||
|
||||
if (y > 900) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int main (void) {
|
||||
define_traits ();
|
||||
define_skills ();
|
||||
define_values ();
|
||||
define_effects ();
|
||||
define_mights ();
|
||||
define_magics ();
|
||||
define_races ();
|
||||
define_items ();
|
||||
define_units ();
|
||||
define_blocks ();
|
||||
|
||||
(void) chad_define_world ("Ashlands", 0XBEEF, 0, chad_block_count);
|
||||
|
||||
chad_configure ();
|
||||
|
||||
InitWindow (1800, 900, "EAX");
|
||||
SetExitKey (KEY_ESCAPE);
|
||||
SetTargetFPS (60);
|
||||
|
||||
ashlands_data = LoadTexture ("sprite/world/ashlands.png");
|
||||
|
||||
SetTextureFilter (ashlands_data, TEXTURE_FILTER_POINT);
|
||||
|
||||
Texture2D vvv = LoadTexture ("sprite/orc/manor.png");
|
||||
|
||||
icon_data [CHAD_ENTITY_TRAIT] = LoadTexture ("sprite/menu/traits.png");
|
||||
icon_data [CHAD_ENTITY_SKILL] = LoadTexture ("sprite/menu/skills.png");
|
||||
icon_data [CHAD_ENTITY_VALUE] = LoadTexture ("sprite/menu/values.png");
|
||||
|
||||
unit_data [orc] = LoadTexture ("sprite/orc/units.png");
|
||||
unit_data [human] = LoadTexture ("sprite/human/units.png");
|
||||
unit_data [elf] = LoadTexture ("sprite/elf/units.png");
|
||||
|
||||
syntax_c ();
|
||||
|
||||
char * code = NULL;
|
||||
int file = open ("source/main.c", O_RDONLY);
|
||||
int size = (int) lseek (file, 0, SEEK_END);
|
||||
code = calloc ((unsigned long int) size + 1UL, 1UL);
|
||||
code [size] = '\0';
|
||||
lseek (file, 0, SEEK_SET);
|
||||
read (file, code, (unsigned long int) size);
|
||||
close (file);
|
||||
|
||||
while (! WindowShouldClose ()) {
|
||||
BeginDrawing ();
|
||||
|
||||
ClearBackground (BLACK);
|
||||
|
||||
render_map ();
|
||||
|
||||
Rectangle source = { 0, 0, BASE_SIZE * 15, BASE_SIZE * 10 };
|
||||
Rectangle destination = { 128, 128, BASE_SIZE * 15 * zoom, BASE_SIZE * 10 * zoom };
|
||||
|
||||
DrawTexturePro (vvv, source, destination, (Vector2) { 0, 0 }, 0.0F, WHITE);
|
||||
|
||||
render_c_code (code, 0, 0);
|
||||
|
||||
for (int i = 0; i < 18; ++i) {
|
||||
render_unit (orc, i, 900 + 32 * i, 32);
|
||||
render_unit (human, i, 900 + 32 * i, 64);
|
||||
render_unit (elf, i, 900 + 32 * i, 96);
|
||||
}
|
||||
|
||||
for (int i = 0; i < chad_trait_count; ++i) {
|
||||
render_icon (CHAD_ENTITY_TRAIT, i, 0, i * 32);
|
||||
}
|
||||
|
||||
for (int i = 0; i < chad_skill_count; ++i) {
|
||||
render_icon (CHAD_ENTITY_SKILL, i, 300, i * 32);
|
||||
}
|
||||
|
||||
for (int i = 0; i < chad_value_count; ++i) {
|
||||
render_icon (CHAD_ENTITY_VALUE, i, 600, i * 32);
|
||||
}
|
||||
|
||||
EndDrawing ();
|
||||
}
|
||||
|
||||
free (code);
|
||||
|
||||
CloseWindow ();
|
||||
|
||||
return (0);
|
||||
}
|
BIN
sprite/elf/units.png
Normal file
After Width: | Height: | Size: 6.2 KiB |
BIN
sprite/human/units.png
Normal file
After Width: | Height: | Size: 5.5 KiB |
BIN
sprite/menu/base.png
Normal file
After Width: | Height: | Size: 218 B |
BIN
sprite/menu/global.png
Normal file
After Width: | Height: | Size: 106 KiB |
BIN
sprite/menu/skills.png
Normal file
After Width: | Height: | Size: 11 KiB |
BIN
sprite/menu/traits.png
Normal file
After Width: | Height: | Size: 1.2 KiB |
BIN
sprite/menu/values.png
Normal file
After Width: | Height: | Size: 4.1 KiB |
BIN
sprite/orc/manor.png
Normal file
After Width: | Height: | Size: 17 KiB |
BIN
sprite/orc/units.png
Normal file
After Width: | Height: | Size: 6.1 KiB |
BIN
sprite/world/ashlands.png
Normal file
After Width: | Height: | Size: 16 KiB |