Redone menus and what not...
This commit is contained in:
parent
71a1285a0e
commit
2b9aa4adc6
@ -37,16 +37,19 @@ void view_hud (int x, int y, int width, int height, int small, int alpha) {
|
||||
render_sprite (neonui, x + ICON_SIZE * (width - 1) + u, y + (i - (small == 0)) * ICON_SIZE + v, 256, 128, ICON_SIZE, ICON_SIZE);
|
||||
}
|
||||
|
||||
u += ICON_SIZE * (width - 2 * (small == 0) - 1);
|
||||
v += ICON_SIZE * (height - 2 * (small == 0) - 1);
|
||||
|
||||
if (small == 0) {
|
||||
render_sprite (neonui, x, y, 288, 0, 3 * ICON_SIZE, 3 * ICON_SIZE);
|
||||
render_sprite (neonui, x + ICON_SIZE * (width - 2 * (small == 0) - 1) + u, y, 384, 0, 3 * ICON_SIZE, 3 * ICON_SIZE);
|
||||
render_sprite (neonui, x, y + ICON_SIZE * (height - 2 * (small == 0) - 1) + v, 288, 96, 3 * ICON_SIZE, 3 * ICON_SIZE);
|
||||
render_sprite (neonui, x + ICON_SIZE * (width - 2 * (small == 0) - 1) + u, y + ICON_SIZE * (height - 2 * (small == 0) - 1) + v, 384, 96, 3 * ICON_SIZE, 3 * ICON_SIZE);
|
||||
render_sprite (neonui, x + u, y, 384, 0, 3 * ICON_SIZE, 3 * ICON_SIZE);
|
||||
render_sprite (neonui, x, y + v, 288, 96, 3 * ICON_SIZE, 3 * ICON_SIZE);
|
||||
render_sprite (neonui, x + u, y + v, 384, 96, 3 * ICON_SIZE, 3 * ICON_SIZE);
|
||||
} else {
|
||||
render_sprite (neonui, x, y, 288, 192, ICON_SIZE, ICON_SIZE);
|
||||
render_sprite (neonui, x + ICON_SIZE * (width - 2 * (small == 0) - 1) + u, y, 320, 192, ICON_SIZE, ICON_SIZE);
|
||||
render_sprite (neonui, x, y + ICON_SIZE * (height - 2 * (small == 0) - 1) + v, 288, 224, ICON_SIZE, ICON_SIZE);
|
||||
render_sprite (neonui, x + ICON_SIZE * (width - 2 * (small == 0) - 1) + u, y + ICON_SIZE * (height - 2 * (small == 0) - 1) + v, 320, 224, ICON_SIZE, ICON_SIZE);
|
||||
render_sprite (neonui, x + u, y, 320, 192, ICON_SIZE, ICON_SIZE);
|
||||
render_sprite (neonui, x, y + v, 288, 224, ICON_SIZE, ICON_SIZE);
|
||||
render_sprite (neonui, x + u, y + v, 320, 224, ICON_SIZE, ICON_SIZE);
|
||||
}
|
||||
}
|
||||
|
||||
@ -86,7 +89,8 @@ void view_map (int offset_x, int offset_y) {
|
||||
|
||||
for (x = 0; (x < (render_width () - SIDE_SIZE) / (BASE_SIZE * render_zoom)) && (x < world_width); ++x) {
|
||||
for (y = 0; (y < render_height () / (BASE_SIZE * render_zoom)) && (y < world_height); ++y) {
|
||||
render_sprite (ashlands, (int) (x * BASE_SIZE * render_zoom), (int) (y * BASE_SIZE * render_zoom), 0,
|
||||
render_sprite (ashlands, (int) (x * BASE_SIZE * render_zoom), (int) (y * BASE_SIZE * render_zoom),
|
||||
0,
|
||||
world [0] [(offset_x + x) * world_height + offset_y + y] * BASE_SIZE, BASE_SIZE, BASE_SIZE);
|
||||
}
|
||||
}
|
||||
@ -106,7 +110,7 @@ void view_map (int offset_x, int offset_y) {
|
||||
}
|
||||
|
||||
void view_map_overlay (void) {
|
||||
render_sprite (overui, 0, render_height () - 784, 0, 0, 1472, 784);
|
||||
render_sprite (overui, ICON_SIZE, render_height () - 784 + ICON_SIZE, 0, 0, 1472, 784);
|
||||
}
|
||||
|
||||
void view_side_hud (void) {
|
||||
|
@ -5,49 +5,15 @@
|
||||
|
||||
#include <raylib.h>
|
||||
|
||||
static void limit (int * pointer, int minimum, int maximum) {
|
||||
if (* pointer < minimum) { * pointer = minimum; }
|
||||
if (* pointer > maximum) { * pointer = maximum; }
|
||||
}
|
||||
|
||||
int main (void) {
|
||||
Color background = { 0, 0, 0, 0 };
|
||||
|
||||
game_configure ();
|
||||
|
||||
render_configure ();
|
||||
|
||||
menu_configure ();
|
||||
|
||||
world_model [0] [0] = 44;
|
||||
world_model_x [0] [0] = 2;
|
||||
world_model_y [0] [0] = 2;
|
||||
world_model [0] [1] = 44;
|
||||
world_model_x [0] [1] = 3;
|
||||
world_model_y [0] [1] = 3;
|
||||
world_model [0] [2] = 44;
|
||||
world_model_x [0] [2] = 3;
|
||||
world_model_y [0] [2] = 2;
|
||||
world_model [0] [3] = 44;
|
||||
world_model_x [0] [3] = 2;
|
||||
world_model_y [0] [3] = 3;
|
||||
|
||||
while (! WindowShouldClose ()) {
|
||||
if (IsKeyPressed (KEY_RIGHT)) { camera_x++; limit (& camera_x, 0, world_width - (render_width () / (int) (BASE_SIZE * render_zoom))); }
|
||||
if (IsKeyPressed (KEY_LEFT)) { camera_x--; limit (& camera_x, 0, world_width - (render_width () / (int) (BASE_SIZE * render_zoom))); }
|
||||
if (IsKeyPressed (KEY_DOWN)) { camera_y++; limit (& camera_y, 0, world_height - (render_height () / (int) (BASE_SIZE * render_zoom))); }
|
||||
if (IsKeyPressed (KEY_UP)) { camera_y--; limit (& camera_y, 0, world_height - (render_height () / (int) (BASE_SIZE * render_zoom))); }
|
||||
|
||||
if (IsKeyPressed (KEY_T)) { menu_show [menu_traits] = menu_show [menu_traits] ? 0 : 1; }
|
||||
if (IsKeyPressed (KEY_S)) { menu_show [menu_skills] = menu_show [menu_skills] ? 0 : 1; }
|
||||
if (IsKeyPressed (KEY_V)) { menu_show [menu_values] = menu_show [menu_values] ? 0 : 1; }
|
||||
if (IsKeyPressed (KEY_R)) { menu_show [menu_resources] = menu_show [menu_resources] ? 0 : 1; }
|
||||
|
||||
/*if (IsKeyPressed (KEY_P)) { dump_world_screenshot (); }*/
|
||||
|
||||
BeginDrawing ();
|
||||
|
||||
ClearBackground (background);
|
||||
while (render_active != 0) {
|
||||
render_synchronize ();
|
||||
|
||||
view_map (camera_x, camera_y);
|
||||
|
||||
@ -61,8 +27,6 @@ int main (void) {
|
||||
view_menu (menu_traits, 0, 0, 1, 1, 0);
|
||||
view_menu (menu_skills, 0, 0, 0, 0, 0);
|
||||
view_menu (menu_values, 96, 240, 0, 0, 0);
|
||||
|
||||
EndDrawing ();
|
||||
}
|
||||
|
||||
return (0);
|
||||
|
@ -1,4 +1,5 @@
|
||||
#include "render.h"
|
||||
#include "engine.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <raylib.h>
|
||||
@ -11,9 +12,18 @@ static Font font = { 0 };
|
||||
static Color tint = { 255, 255, 255, 255 };
|
||||
static Vector2 dump = { 0, 0 };
|
||||
|
||||
static void render_clean_up (void) {
|
||||
CloseWindow ();
|
||||
}
|
||||
|
||||
int render_width (void) { return (GetScreenWidth ()); }
|
||||
int render_height (void) { return (GetScreenHeight ()); }
|
||||
|
||||
static void limit (int * pointer, int minimum, int maximum) {
|
||||
if (* pointer < minimum) { * pointer = minimum; }
|
||||
if (* pointer > maximum) { * pointer = maximum; }
|
||||
}
|
||||
|
||||
void render_sprite (int sprite, int x, int y, int u, int v, int width, int height) {
|
||||
Rectangle source, destination;
|
||||
|
||||
@ -39,19 +49,26 @@ void render_string (char * string, int x, int y) {
|
||||
DrawTextPro (font, string, position, dump, 0.0, FONT_SIZE, 4, tint);
|
||||
}
|
||||
|
||||
static void render_clean_up (void) {
|
||||
CloseWindow ();
|
||||
int render_active = 0;
|
||||
|
||||
static void render_exit (void) {
|
||||
render_active = 0;
|
||||
}
|
||||
|
||||
static void (* render_action [80]) (void);
|
||||
|
||||
void render_configure (void) {
|
||||
render_active = 1;
|
||||
|
||||
InitWindow (1800, 900, "EAX");
|
||||
SetExitKey (KEY_ESCAPE);
|
||||
SetTargetFPS (60);
|
||||
|
||||
font = LoadFont ("sprite/gothic.ttf");
|
||||
|
||||
atexit (render_clean_up);
|
||||
|
||||
render_action [0] = render_exit;
|
||||
|
||||
render_texture [neonui] = LoadTexture ("sprite/neonui.png");
|
||||
render_texture [ui] = LoadTexture ("sprite/ui.png");
|
||||
render_texture [overui] = LoadTexture ("sprite/hack.png");
|
||||
@ -65,3 +82,27 @@ void render_configure (void) {
|
||||
render_texture [elves] = LoadTexture ("sprite/elves.png");
|
||||
render_texture [ashlands] = LoadTexture ("sprite/ashlands.png");
|
||||
}
|
||||
|
||||
void render_synchronize (void) {
|
||||
Color background = { 0, 0, 0, 0 };
|
||||
|
||||
if (IsKeyPressed (KEY_RIGHT)) { camera_x++; limit (& camera_x, 0, world_width - (render_width () / (int) (BASE_SIZE * render_zoom))); }
|
||||
if (IsKeyPressed (KEY_LEFT)) { camera_x--; limit (& camera_x, 0, world_width - (render_width () / (int) (BASE_SIZE * render_zoom))); }
|
||||
if (IsKeyPressed (KEY_DOWN)) { camera_y++; limit (& camera_y, 0, world_height - (render_height () / (int) (BASE_SIZE * render_zoom))); }
|
||||
if (IsKeyPressed (KEY_UP)) { camera_y--; limit (& camera_y, 0, world_height - (render_height () / (int) (BASE_SIZE * render_zoom))); }
|
||||
|
||||
if (IsKeyPressed (KEY_T)) { menu_show [menu_traits] = menu_show [menu_traits] ? 0 : 1; }
|
||||
if (IsKeyPressed (KEY_S)) { menu_show [menu_skills] = menu_show [menu_skills] ? 0 : 1; }
|
||||
if (IsKeyPressed (KEY_V)) { menu_show [menu_values] = menu_show [menu_values] ? 0 : 1; }
|
||||
if (IsKeyPressed (KEY_R)) { menu_show [menu_resources] = menu_show [menu_resources] ? 0 : 1; }
|
||||
|
||||
if (WindowShouldClose ()) { render_active = 0; }
|
||||
|
||||
/*if (IsKeyPressed (KEY_P)) { dump_world_screenshot (); }*/
|
||||
|
||||
EndDrawing ();
|
||||
|
||||
BeginDrawing ();
|
||||
|
||||
ClearBackground (background);
|
||||
}
|
||||
|
@ -12,6 +12,7 @@ enum {
|
||||
};
|
||||
|
||||
extern float render_zoom;
|
||||
extern int render_active;
|
||||
|
||||
extern int render_width (void);
|
||||
extern int render_height (void);
|
||||
@ -20,5 +21,6 @@ extern void render_sprite (int sprite, int x, int y, int u, int v, int width,
|
||||
extern void render_string (char * string, int x, int y);
|
||||
|
||||
extern void render_configure (void);
|
||||
extern void render_synchronize (void);
|
||||
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user