umorna/source/main.c

70 lines
2.2 KiB
C
Raw Normal View History

#include "game.h"
#include "render.h"
#include "engine.h"
#include "menu.h"
2023-12-23 10:53:45 -05:00
#include <raylib.h>
2023-12-22 02:09:39 -05:00
static void limit (int * pointer, int minimum, int maximum) {
if (* pointer < minimum) { * pointer = minimum; }
if (* pointer > maximum) { * pointer = maximum; }
}
int main (void) {
2023-12-29 07:14:30 -05:00
Color background = { 0, 0, 0, 0 };
game_configure ();
render_configure ();
menu_configure ();
2023-12-29 07:14:30 -05:00
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;
2023-12-23 10:53:45 -05:00
while (! WindowShouldClose ()) {
2023-12-29 07:14:30 -05:00
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))); }
2023-12-23 10:53:45 -05:00
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 ();
2023-12-29 07:14:30 -05:00
ClearBackground (background);
2023-12-22 02:09:39 -05:00
view_map (camera_x, camera_y);
2023-12-29 07:14:30 -05:00
view_map_overlay ();
view_hud (render_width () - SIDE_SIZE, 0, SIDE_SIZE, render_height (), 0, 0);
view_hud (0, 0, render_width () - SIDE_SIZE, render_height (), 0, 1);
view_menu (menu_resources, 96, 96, 1, 0, 1);
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);
}