Implemented core base system...

This commit is contained in:
Ognjen Milan Robovic 2023-12-21 20:19:30 -05:00
parent 0dfdb22c4a
commit 3a9dc4283a
7 changed files with 43 additions and 16 deletions

View File

@ -38,6 +38,10 @@ void view_menu (int menu, int align, int x, int y) {
void view_neon_menu (int menu, int align, int x, int y) {
int item;
if (menu_show [menu] == 0) {
return;
}
int width = (int) strlen (menu_text [menu] [0]) + 4;
int height = menu_items [menu] + 4;
@ -59,7 +63,7 @@ void view_neon_menu (int menu, int align, int x, int y) {
}
for (int n = 1; n < height - 1; ++n) {
render_sprite (neonui, aligned_x, aligned_y + n * ICON_SIZE, 256, 128, ICON_SIZE, ICON_SIZE);
render_sprite (neonui, aligned_x, aligned_y + n * ICON_SIZE, 256, 128, ICON_SIZE, ICON_SIZE);
render_sprite (neonui, aligned_x + ICON_SIZE * (width - 1), aligned_y + n * ICON_SIZE, 256, 128, ICON_SIZE, ICON_SIZE);
}
@ -89,7 +93,15 @@ void view_map (void) {
int index = chad_world [0] [x] [y];
int catch = (y * y + x + x / (y + 1) + y / (x + 1)) % chad_block_change [index];
render_sprite (ashlands, x * BASE_SIZE, y * BASE_SIZE, catch * BASE_SIZE, index * BASE_SIZE, BASE_SIZE, BASE_SIZE);
render_sprite (ashlands, (int) (x * BASE_SIZE * render_zoom), (int) (y * BASE_SIZE * render_zoom), catch * BASE_SIZE, index * BASE_SIZE, BASE_SIZE, BASE_SIZE);
}
}
}
void view_base_1 (int index, int x, int y) {
render_sprite (base_1, x, y, 0, index * 7 * BASE_SIZE, 10 * BASE_SIZE, 7 * BASE_SIZE);
}
void view_base_2 (int index, int x, int y) {
render_sprite (base_2, x, y, 0, index * 10 * BASE_SIZE, 15 * BASE_SIZE, 10 * BASE_SIZE);
}

View File

@ -15,4 +15,7 @@ extern void view_neon_menu (int menu, int align, int x, int y);
extern void view_map (void);
extern void view_base_1 (int index, int x, int y);
extern void view_base_2 (int index, int x, int y);
#endif

View File

@ -17,28 +17,33 @@ int main (void) {
view_map ();
menu_show [menu_resources] = 1;
menu_show [menu_traits] = 1;
//~menu_show [menu_skills] = 1;
//~menu_show [menu_values] = 1;
view_base_1 (0, 100, 100);
view_base_1 (1, 100, 400);
view_base_2 (0, 1300, 100);
view_base_2 (1, 1300, 500);
//~for (int i = 0; i < 18; ++i) {
//~view_unit (orc, i, 900 + 32 * i, 32);
//~view_unit (human, i, 900 + 32 * i, 64);
//~view_unit (elf, i, 900 + 32 * i, 96);
//~}
if (IsKeyPressed (KEY_RIGHT)) { menu_show [menu_traits] = menu_show [menu_traits] ? 0 : 1; }
if (IsKeyPressed (KEY_LEFT)) { menu_show [menu_skills] = menu_show [menu_skills] ? 0 : 1; }
if (IsKeyPressed (KEY_DOWN)) { menu_show [menu_values] = menu_show [menu_values] ? 0 : 1; }
view_neon_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);
view_neon_menu (menu_traits, 1, 0, 0);
view_neon_menu (menu_skills, 1, 0, 0);
view_neon_menu (menu_values, 1, 0, 0);
//~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);
for (int i = 0; i < 18; ++i) {
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 ();
}

View File

@ -1,5 +1,7 @@
#include "render.h"
float render_zoom = 2.0;
Texture2D render_texture [render_texture_count];
int render_width (void) { return (GetScreenWidth ()); }
@ -7,7 +9,7 @@ int render_height (void) { return (GetScreenHeight ()); }
void render_sprite (int sprite, int x, int y, int u, int v, int width, int height) {
Rectangle source = { u, v, width, height };
Rectangle destination = { x, y, width, height };
Rectangle destination = { x, y, width * ((sprite <= ui) ? 1 : render_zoom), height * ((sprite <= ui) ? 1 : render_zoom) };
Vector2 origin = { 0, 0 };
DrawTexturePro (render_texture [sprite], source, destination, origin, 0.0, WHITE);
@ -41,4 +43,6 @@ void render_configure (void) {
render_texture [humans] = LoadTexture ("sprite/humans.png");
render_texture [elves] = LoadTexture ("sprite/elves.png");
render_texture [ashlands] = LoadTexture ("sprite/ashlands.png");
render_texture [base_1] = LoadTexture ("sprite/base_1.png");
render_texture [base_2] = LoadTexture ("sprite/base_2.png");
}

View File

@ -11,9 +11,12 @@
enum {
neonui,
ui, traits, skills, values, orcs, humans, elves, ashlands,
base_1, base_2,
render_texture_count
};
extern float render_zoom;
extern Texture2D render_texture [render_texture_count];
extern int render_width (void);

BIN
sprite/base_1.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 20 KiB

BIN
sprite/base_2.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 35 KiB