@@ -2,14 +2,14 @@ | |||
set -xe | |||
#~clang -g -std=gnu17 -Weverything -Werror -Ofast -c -o ./source/engine.o ./source/engine.c | |||
clang -g -std=gnu17 -Weverything -Werror -Ofast -c -o ./source/engine.o ./source/engine.c | |||
clang -g -std=gnu17 -Weverything -Werror -Ofast -c -o ./source/render.o ./source/render.c | |||
clang -g -std=gnu17 -Weverything -Werror -Ofast -c -o ./source/game.o ./source/game.c | |||
clang -g -std=gnu17 -Weverything -Werror -Ofast -c -o ./source/menu.o ./source/menu.c | |||
#~clang -g -std=gnu17 -Weverything -Werror -Ofast -c -o ./source/source.o ./source/source.c | |||
clang -g -std=gnu17 -Weverything -Werror -Ofast -c -o ./source/main.o ./source/main.c | |||
#~gcc -g -std=gnu17 -Wall -Wextra -Wpedantic -Werror -Ofast -c -o ./source/engine.o ./source/engine.c | |||
gcc -g -std=gnu17 -Wall -Wextra -Wpedantic -Werror -Ofast -c -o ./source/engine.o ./source/engine.c | |||
gcc -g -std=gnu17 -Wall -Wextra -Wpedantic -Werror -Ofast -c -o ./source/render.o ./source/render.c | |||
gcc -g -std=gnu17 -Wall -Wextra -Wpedantic -Werror -Ofast -c -o ./source/game.o ./source/game.c | |||
gcc -g -std=gnu17 -Wall -Wextra -Wpedantic -Werror -Ofast -c -o ./source/menu.o ./source/menu.c | |||
@@ -17,7 +17,7 @@ gcc -g -std=gnu17 -Wall -Wextra -Wpedantic -Werror -Ofast -c -o ./source/menu.o | |||
gcc -g -std=gnu17 -Wall -Wextra -Wpedantic -Werror -Ofast -c -o ./source/main.o ./source/main.c | |||
#~gcc -o umorna ./source/main.o ./source/source.o ./source/menu.o ./source/game.o ./source/engine.o -lraylib | |||
gcc -o umorna ./source/main.o ./source/menu.o ./source/game.o ./source/render.o -lraylib | |||
gcc -o umorna ./source/main.o ./source/game.o ./source/engine.o ./source/menu.o ./source/render.o -lraylib | |||
#~gcc -o umorna ./source/main.o ./source/game.o ./source/engine.o -lraylib | |||
exit |
@@ -1,57 +1,53 @@ | |||
#include <string.h> | |||
#include <stdlib.h> | |||
#include <raylib.h> | |||
#define BASE_SIZE (16) | |||
#define ICON_SIZE (32) | |||
#define FONT_SIZE (24) | |||
#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> | |||
static Texture2D unit_data [3]; | |||
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); | |||
#include "engine.h" | |||
void view_unit (int race, int unit, int x, int y) { | |||
int u = 0; | |||
int v = (unit - race * 18) * BASE_SIZE; | |||
int width = BASE_SIZE; | |||
int height = BASE_SIZE; | |||
switch (race) { | |||
case orc: render_sprite (orcs, x, y, u, v, width, height); break; | |||
case human: render_sprite (humans, x, y, u, v, width, height); break; | |||
case elf: render_sprite (elves, x, y, u, v, width, height); break; | |||
default: break; | |||
} | |||
} | |||
static Texture2D icons; | |||
void view_menu (int menu, int align, int x, int y) { | |||
int width = (int) strlen (menu_text [menu] [0]) * ICON_SIZE; | |||
int height = menu_items [menu] * ICON_SIZE; | |||
int item; | |||
if (menu_show [menu] == 0) { | |||
return; | |||
} | |||
//~if (menu_alpha [menu] != 0) { | |||
//~DrawRectangle (x, y, width, height, BLACK); | |||
//~} | |||
static Texture2D ashlands_data; | |||
for (item = 0; item < menu_items [menu]; ++item) { | |||
int u = (menu_icon [menu] [item] / 10) * ICON_SIZE; | |||
int v = (menu_icon [menu] [item] % 10) * ICON_SIZE; | |||
int aligned_x = (align == 0) ? x : ((render_width () - width) / 2); | |||
int aligned_y = (align == 0) ? y : ((render_height () - height) / 2); | |||
void render_map (void) { | |||
render_sprite (ui, aligned_x, aligned_y + item * ICON_SIZE, u, v, ICON_SIZE, ICON_SIZE); | |||
render_string (menu_text [menu] [item], aligned_x + ICON_SIZE, aligned_y + item * ICON_SIZE); | |||
} | |||
} | |||
void view_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 }; | |||
int index = chad_world [0] [x] [y]; | |||
int catch = (y * y + x + x / (y + 1) + y / (x + 1)) % chad_block_change [index]; | |||
DrawTexturePro (ashlands_data, source, destination, (Vector2) { 0, 0 }, 0.0F, WHITE); | |||
render_sprite (ashlands, x * BASE_SIZE, y * BASE_SIZE, catch * BASE_SIZE, index * BASE_SIZE, BASE_SIZE, BASE_SIZE); | |||
} | |||
} | |||
} |
@@ -1 +1,16 @@ | |||
#ifndef UMORNA_ENGINE | |||
#define UMORNA_ENGINE | |||
#include "game.h" | |||
#include "menu.h" | |||
#include "render.h" | |||
#include <string.h> | |||
extern void view_unit (int race, int unit, int x, int y); | |||
extern void view_menu (int menu, int align, int x, int y); | |||
extern void view_map (void); | |||
#endif |
@@ -1,3 +1,6 @@ | |||
#ifndef UMORNA_GAME | |||
#define UMORNA_GAME | |||
#define CHAD_TRAIT_LIMIT ( 3) | |||
#define CHAD_SKILL_LIMIT (24) | |||
#define CHAD_VALUE_LIMIT (10) | |||
@@ -61,3 +64,5 @@ enum { | |||
}; | |||
extern void game_configure (void); | |||
#endif |
@@ -15,17 +15,17 @@ int main (void) { | |||
ClearBackground (BLACK); | |||
render_map (); | |||
view_map (); | |||
menu_show [menu_resources] = 1; | |||
menu_show [menu_traits] = 1; | |||
menu_show [menu_skills] = 1; | |||
menu_show [menu_values] = 1; | |||
render_menu (menu_resources, 1, 0, 0); | |||
render_menu (menu_traits, 0, 0, 0); | |||
render_menu (menu_skills, 0, 200, 0); | |||
render_menu (menu_values, 0, 400, 0); | |||
view_menu (menu_resources, 1, 0, 0); | |||
view_menu (menu_traits, 0, 0, 0); | |||
view_menu (menu_skills, 0, 200, 0); | |||
view_menu (menu_values, 0, 400, 0); | |||
//~Rectangle source = { 0, 0, BASE_SIZE * 15, BASE_SIZE * 10 }; | |||
//~Rectangle destination = { 128, 128, BASE_SIZE * 15 * zoom, BASE_SIZE * 10 * zoom }; | |||
@@ -33,9 +33,9 @@ int main (void) { | |||
//~DrawTexturePro (vvv, source, destination, (Vector2) { 0, 0 }, 0.0F, WHITE); | |||
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); | |||
view_unit (orc, i, 900 + 32 * i, 32); | |||
view_unit (human, i, 900 + 32 * i, 64); | |||
view_unit (elf, i, 900 + 32 * i, 96); | |||
} | |||
EndDrawing (); | |||
@@ -1,92 +1,52 @@ | |||
#include "core.h" | |||
#include "game.h" | |||
//~#include "engine.h" | |||
#include "render.h" | |||
#include "menu.h" | |||
int define_menu_item (int menu, | |||
char * text, | |||
int icon, | |||
void (* action) (void)) { | |||
int menu_count = 0; | |||
int menu_items [MENU_LIMIT]; | |||
int menu_show [MENU_LIMIT]; | |||
int menu_alpha [MENU_LIMIT]; | |||
char * menu_text [MENU_LIMIT] [MINIMENU_LIMIT]; | |||
int menu_icon [MENU_LIMIT] [MINIMENU_LIMIT]; | |||
void (* menu_action [MENU_LIMIT] [MINIMENU_LIMIT]) (void); | |||
static void define_minimenu (int menu, char * text, int icon, void (* action) (void)) { | |||
menu_text [menu] [menu_items [menu]] = text; | |||
menu_icon [menu] [menu_items [menu]] = icon; | |||
menu_action [menu] [menu_items [menu]] = action; | |||
return (menu_items [menu]++); | |||
menu_items [menu]++; | |||
} | |||
int define_menu (int alpha) { | |||
static void define_menu (int alpha) { | |||
menu_items [menu_count] = 0; | |||
menu_show [menu_count] = 0; | |||
menu_alpha [menu_count] = alpha; | |||
return (menu_count++); | |||
} | |||
void render_menu_item (int menu, int item, int x, int y) { | |||
int u = (menu_icon [menu] [item] / 10) * ICON_SIZE; | |||
int v = (menu_icon [menu] [item] % 10) * ICON_SIZE; | |||
render_sprite (u, v, ICON_SIZE, ICON_SIZE, x, y + item * ICON_SIZE); | |||
render_string (menu_text [menu] [item], x + ICON_SIZE, y + item * ICON_SIZE); | |||
} | |||
void render_menu (int menu, int align, int x, int y) { | |||
int item; | |||
int u = (int) strlen (menu_text [menu] [0]) * ICON_SIZE; | |||
int v = menu_items [menu] * ICON_SIZE; | |||
if (menu_show [menu] == 0) { | |||
return; | |||
} | |||
if (menu_alpha [menu] != 0) { | |||
DrawRectangle (x, y, u, v, BLACK); | |||
} | |||
for (item = 0; item < menu_items [menu]; ++item) { | |||
if (align == 0) { | |||
render_menu_item (menu, item, x, y); | |||
} else { | |||
render_menu_item (menu, item, (GetScreenWidth () - u) / 2, (GetScreenHeight () - v) / 2); | |||
} | |||
} | |||
menu_count++; | |||
} | |||
void menu_configure (void) { | |||
int index; | |||
menu_traits = define_menu (1); | |||
menu_skills = define_menu (1); | |||
menu_values = define_menu (1); | |||
menu_resources = define_menu (0); | |||
define_menu (1); | |||
define_menu (1); | |||
define_menu (1); | |||
define_menu (0); | |||
for (index = 0; index < chad_trait_count; ++index) { | |||
(void) define_menu_item (menu_traits, chad_trait_name [index], index, 0); | |||
define_minimenu (menu_traits, chad_trait_name [index], index, 0); | |||
} | |||
for (index = 0; index < chad_skill_count; ++index) { | |||
(void) define_menu_item (menu_skills, chad_skill_name [index], 3 + index, 0); | |||
define_minimenu (menu_skills, chad_skill_name [index], 3 + index, 0); | |||
} | |||
for (index = 0; index < chad_value_count; ++index) { | |||
(void) define_menu_item (menu_values, chad_value_name [index], 27 + index, 0); | |||
define_minimenu (menu_values, chad_value_name [index], 27 + index, 0); | |||
} | |||
(void) define_menu_item (menu_resources, "ABC", 1, 0); | |||
(void) define_menu_item (menu_resources, "DEF", 1, 0); | |||
(void) define_menu_item (menu_resources, "GHI", 1, 0); | |||
define_minimenu (menu_resources, "ABC", 1, 0); | |||
define_minimenu (menu_resources, "DEF", 1, 0); | |||
define_minimenu (menu_resources, "GHI", 1, 0); | |||
} | |||
int menu_count = 0; | |||
int menu_items [24]; | |||
int menu_show [24]; | |||
int menu_alpha [24]; | |||
char * menu_text [24] [24]; | |||
int menu_icon [24] [24]; | |||
void (* menu_action [24] [24]) (void); | |||
int menu_traits, menu_skills, menu_values, menu_resources; |
@@ -1,18 +1,25 @@ | |||
extern void menu_configure (void); | |||
#ifndef UMORNA_MENU | |||
#define UMORNA_MENU | |||
#include "game.h" | |||
#define MENU_LIMIT (24) | |||
#define MINIMENU_LIMIT (24) | |||
extern int define_menu_item (int menu, char * text, int icon, void (* action) (void)); | |||
extern int define_menu (int alpha); | |||
extern void render_menu_item (int menu, int item, int x, int y); | |||
extern void render_menu (int menu, int align, int x, int y); | |||
enum { | |||
menu_traits, menu_skills, menu_values, menu_resources | |||
}; | |||
extern int menu_count; | |||
extern int menu_items [24]; | |||
extern int menu_show [24]; | |||
extern int menu_alpha [24]; | |||
extern int menu_items [MENU_LIMIT]; | |||
extern int menu_show [MENU_LIMIT]; | |||
extern int menu_alpha [MENU_LIMIT]; | |||
extern char * menu_text [24] [24]; | |||
extern int menu_icon [24] [24]; | |||
extern void (* menu_action [24] [24]) (void); | |||
extern char * menu_text [MENU_LIMIT] [MINIMENU_LIMIT]; | |||
extern int menu_icon [MENU_LIMIT] [MINIMENU_LIMIT]; | |||
extern void (* menu_action [MENU_LIMIT] [MINIMENU_LIMIT]) (void); | |||
extern void menu_configure (void); | |||
extern int menu_traits, menu_skills, menu_values, menu_resources; | |||
#endif |
@@ -1,15 +1,20 @@ | |||
#include "render.h" | |||
float render_zoom = 2.0F; | |||
Texture2D render_texture [render_texture_count]; | |||
int render_width (void) { return (GetScreenWidth ()); } | |||
int render_height (void) { return (GetScreenHeight ()); } | |||
void render_sprite (int sprite, int x, int y, int u, int v, int width, int height) { | |||
DrawTextureRec (icons, (Rectangle) { u, v, width, height }, (Vector2) { x, y }, WHITE); | |||
Rectangle source = { u, v, width, height }; | |||
Rectangle destination = { x, y, width, height }; | |||
Vector2 origin = { 0, 0 }; | |||
DrawTexturePro (render_texture [sprite], source, destination, origin, 0.0, WHITE); | |||
} | |||
void render_string (char * string, int x, int y) { | |||
DrawText (text, x + 6, y + 6, FONT_SIZE, WHITE); | |||
DrawText (string, x + 4, y + 4, FONT_SIZE, WHITE); | |||
} | |||
static void render_clean_up (void) { | |||
@@ -23,21 +28,15 @@ void render_configure (void) { | |||
atexit (render_clean_up); | |||
render_texture [ui] = LoadTexture ("sprite/menu/menu.png"); | |||
render_texture [ui] = LoadTexture ("sprite/ui.png"); | |||
SetTextureFilter (render_texture [ui], TEXTURE_FILTER_POINT); | |||
render_texture [traits] = LoadTexture ("sprite/menu/traits.png"); | |||
render_texture [skills] = LoadTexture ("sprite/menu/skills.png"); | |||
render_texture [values] = LoadTexture ("sprite/menu/values.png"); | |||
render_texture [units] = LoadTexture ("sprite/menu/units.png"); | |||
render_texture [blocks] = LoadTexture ("sprite/menu/blocks.png"); | |||
ashlands_data = LoadTexture ("sprite/world/ashlands.png"); | |||
//~Texture2D vvv = LoadTexture ("sprite/orc/manor.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"); | |||
render_texture [traits] = LoadTexture ("sprite/traits.png"); | |||
render_texture [skills] = LoadTexture ("sprite/skills.png"); | |||
render_texture [values] = LoadTexture ("sprite/values.png"); | |||
render_texture [orcs] = LoadTexture ("sprite/orcs.png"); | |||
render_texture [humans] = LoadTexture ("sprite/humans.png"); | |||
render_texture [elves] = LoadTexture ("sprite/elves.png"); | |||
render_texture [ashlands] = LoadTexture ("sprite/ashlands.png"); | |||
} |
@@ -1,4 +1,6 @@ | |||
#include <string.h> | |||
#ifndef UMORNA_RENDER | |||
#define UMORNA_RENDER | |||
#include <stdlib.h> | |||
#include <raylib.h> | |||
@@ -7,15 +9,18 @@ | |||
#define FONT_SIZE (24) | |||
enum { | |||
ui, traits, skills, values, units, blocks, | |||
ui, traits, skills, values, orcs, humans, elves, ashlands, | |||
render_texture_count | |||
}; | |||
extern float render_zoom; | |||
extern Texture2D render_texture [render_texture_count]; | |||
extern int render_width (void); | |||
extern int render_height (void); | |||
extern void render_sprite (int sprite, int x, int y, int u, int v, int width, int height); | |||
extern void render_string (char * string, int x, int y); | |||
extern void render_configure (void); | |||
#endif |
@@ -1,3 +1,6 @@ | |||
#ifndef UMORNA_SOURCE | |||
#define UMORNA_SOURCE | |||
#include <string.h> | |||
#define SYNTAX_LIMIT (64) | |||
@@ -192,3 +195,5 @@ static void render_c_code (char * string, | |||
} | |||
} | |||
} | |||
#endif |
@@ -1 +1,4 @@ | |||
#ifndef UMORNA_SYSTEM | |||
#define UMORNA_SYSTEM | |||
#endif |