2023-12-21 13:03:16 -05:00
|
|
|
#include "render.h"
|
|
|
|
|
2023-12-25 10:02:40 -05:00
|
|
|
#include <stdlib.h>
|
|
|
|
#include <raylib.h>
|
|
|
|
|
2023-12-21 23:08:09 -05:00
|
|
|
static Texture2D render_texture [render_texture_count];
|
|
|
|
|
|
|
|
static Font font = { 0 };
|
|
|
|
static Color tint = { 255, 255, 255, 255 };
|
|
|
|
static Vector2 dump = { 0, 0 };
|
2023-12-21 13:03:16 -05:00
|
|
|
|
2023-12-30 03:23:42 -05:00
|
|
|
static void render_clean_up (void) {
|
|
|
|
CloseWindow ();
|
|
|
|
}
|
|
|
|
|
2023-12-30 06:33:33 -05:00
|
|
|
float render_zoom = 2.0;
|
|
|
|
int render_active = 0;
|
|
|
|
|
|
|
|
int signal = signal_none;
|
|
|
|
|
2023-12-21 14:20:00 -05:00
|
|
|
int render_width (void) { return (GetScreenWidth ()); }
|
|
|
|
int render_height (void) { return (GetScreenHeight ()); }
|
|
|
|
|
2023-12-21 13:03:16 -05:00
|
|
|
void render_sprite (int sprite, int x, int y, int u, int v, int width, int height) {
|
2023-12-21 23:08:09 -05:00
|
|
|
Rectangle source, destination;
|
|
|
|
|
|
|
|
source.x = u;
|
|
|
|
source.y = v;
|
|
|
|
source.width = width;
|
|
|
|
source.height = height;
|
|
|
|
|
|
|
|
destination.x = x;
|
|
|
|
destination.y = y;
|
2023-12-29 07:14:30 -05:00
|
|
|
destination.width = width * ((sprite <= overui) ? 1 : render_zoom);
|
|
|
|
destination.height = height * ((sprite <= overui) ? 1 : render_zoom);
|
2023-12-21 14:20:00 -05:00
|
|
|
|
2023-12-21 23:08:09 -05:00
|
|
|
DrawTexturePro (render_texture [sprite], source, destination, dump, 0.0, tint);
|
2023-12-21 13:03:16 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
void render_string (char * string, int x, int y) {
|
2023-12-21 23:08:09 -05:00
|
|
|
Vector2 position = { 4, 4 };
|
|
|
|
|
|
|
|
position.x += x;
|
|
|
|
position.y += y;
|
|
|
|
|
|
|
|
DrawTextPro (font, string, position, dump, 0.0, FONT_SIZE, 4, tint);
|
2023-12-21 13:03:16 -05:00
|
|
|
}
|
|
|
|
|
2023-12-30 03:23:42 -05:00
|
|
|
static void render_exit (void) {
|
|
|
|
render_active = 0;
|
2023-12-21 13:03:16 -05:00
|
|
|
}
|
|
|
|
|
2023-12-30 03:23:42 -05:00
|
|
|
static void (* render_action [80]) (void);
|
|
|
|
|
2023-12-21 13:03:16 -05:00
|
|
|
void render_configure (void) {
|
2023-12-30 03:23:42 -05:00
|
|
|
render_active = 1;
|
|
|
|
|
2023-12-21 13:03:16 -05:00
|
|
|
InitWindow (1800, 900, "EAX");
|
|
|
|
SetTargetFPS (60);
|
|
|
|
|
2023-12-21 23:08:09 -05:00
|
|
|
font = LoadFont ("sprite/gothic.ttf");
|
|
|
|
|
2023-12-21 13:03:16 -05:00
|
|
|
atexit (render_clean_up);
|
|
|
|
|
2023-12-30 03:23:42 -05:00
|
|
|
render_action [0] = render_exit;
|
|
|
|
|
2023-12-21 16:59:45 -05:00
|
|
|
render_texture [neonui] = LoadTexture ("sprite/neonui.png");
|
|
|
|
render_texture [ui] = LoadTexture ("sprite/ui.png");
|
2023-12-29 07:46:44 -05:00
|
|
|
render_texture [overui] = LoadTexture ("sprite/hack.png");
|
2023-12-21 13:03:16 -05:00
|
|
|
|
2023-12-21 16:59:45 -05:00
|
|
|
SetTextureFilter (render_texture [neonui], TEXTURE_FILTER_POINT);
|
|
|
|
SetTextureFilter (render_texture [ui], TEXTURE_FILTER_POINT);
|
2023-12-29 07:14:30 -05:00
|
|
|
SetTextureFilter (render_texture [overui], TEXTURE_FILTER_POINT);
|
2023-12-21 13:03:16 -05:00
|
|
|
|
2023-12-29 07:46:44 -05:00
|
|
|
render_texture [orcs] = LoadTexture ("sprite/orcs.png"); /* TODO */
|
2023-12-25 10:02:40 -05:00
|
|
|
render_texture [humans] = LoadTexture ("sprite/humans.png");
|
|
|
|
render_texture [elves] = LoadTexture ("sprite/elves.png");
|
|
|
|
render_texture [ashlands] = LoadTexture ("sprite/ashlands.png");
|
2023-12-21 13:03:16 -05:00
|
|
|
}
|
2023-12-30 03:23:42 -05:00
|
|
|
|
|
|
|
void render_synchronize (void) {
|
|
|
|
Color background = { 0, 0, 0, 0 };
|
|
|
|
|
2023-12-30 06:33:33 -05:00
|
|
|
EndDrawing ();
|
2023-12-30 03:23:42 -05:00
|
|
|
|
|
|
|
if (WindowShouldClose ()) { render_active = 0; }
|
|
|
|
|
2023-12-30 06:33:33 -05:00
|
|
|
signal = GetKeyPressed ();
|
|
|
|
|
|
|
|
switch (signal) {
|
|
|
|
case KEY_UP: signal = signal_up; break;
|
|
|
|
case KEY_DOWN: signal = signal_down; break;
|
|
|
|
case KEY_LEFT: signal = signal_left; break;
|
|
|
|
case KEY_RIGHT: signal = signal_right; break;
|
|
|
|
case KEY_ESCAPE: signal = signal_escape; break;
|
|
|
|
case KEY_R: signal = signal_r; break;
|
|
|
|
case KEY_T: signal = signal_t; break;
|
|
|
|
case KEY_S: signal = signal_s; break;
|
|
|
|
case KEY_V: signal = signal_v; break;
|
|
|
|
default: signal = signal_none; break;
|
|
|
|
}
|
2023-12-30 03:23:42 -05:00
|
|
|
|
|
|
|
BeginDrawing ();
|
|
|
|
|
|
|
|
ClearBackground (background);
|
|
|
|
}
|