105 lines
2.7 KiB
C
105 lines
2.7 KiB
C
#include "render.h"
|
|
|
|
#include <stdlib.h>
|
|
#include <raylib.h>
|
|
|
|
static Texture2D render_texture [render_texture_count];
|
|
|
|
static Font font = { 0 };
|
|
static Color tint = { 255, 255, 255, 255 };
|
|
static Vector2 dump = { 0, 0 };
|
|
|
|
static void (* render_action [80]) (void);
|
|
|
|
static void render_clean_up (void) {
|
|
CloseWindow ();
|
|
}
|
|
|
|
static void render_exit (void) {
|
|
engine_active = 0;
|
|
}
|
|
|
|
float render_zoom = 2.0;
|
|
int engine_active = 0;
|
|
|
|
int signal = signal_none;
|
|
|
|
int window_width (void) { return (GetScreenWidth ()); }
|
|
int window_height (void) { return (GetScreenHeight ()); }
|
|
|
|
void render_sprite (int sprite, int x, int y, int u, int v, int width, int height) {
|
|
Rectangle source, destination;
|
|
|
|
source.x = u;
|
|
source.y = v;
|
|
source.width = width;
|
|
source.height = height;
|
|
|
|
destination.x = x;
|
|
destination.y = y;
|
|
destination.width = width * ((sprite <= icons) ? 1 : render_zoom);
|
|
destination.height = height * ((sprite <= icons) ? 1 : render_zoom);
|
|
|
|
DrawTexturePro (render_texture [sprite], source, destination, dump, 0.0, tint);
|
|
}
|
|
|
|
void render_string (char * string, int x, int y) {
|
|
Vector2 position = { 4, 4 };
|
|
|
|
position.x += x;
|
|
position.y += y;
|
|
|
|
DrawTextPro (font, string, position, dump, 0.0, FONT_SIZE, 4, tint);
|
|
}
|
|
|
|
void engine_configure (void) {
|
|
engine_active = 1;
|
|
|
|
InitWindow (1800, 900, "EAX");
|
|
SetTargetFPS (60);
|
|
|
|
font = LoadFont ("sprite/gothic.ttf");
|
|
|
|
atexit (render_clean_up);
|
|
|
|
render_action [0] = render_exit;
|
|
|
|
render_texture [menus] = LoadTexture ("sprite/menus.png");
|
|
render_texture [icons] = LoadTexture ("sprite/icons.png");
|
|
|
|
SetTextureFilter (render_texture [menus], TEXTURE_FILTER_POINT);
|
|
SetTextureFilter (render_texture [icons], TEXTURE_FILTER_POINT);
|
|
|
|
render_texture [orcs] = LoadTexture ("sprite/orcs.png"); /* TODO */
|
|
/*render_texture [humans] = LoadTexture ("sprite/humans.png");
|
|
render_texture [elves] = LoadTexture ("sprite/elves.png");*/
|
|
render_texture [ashlands] = LoadTexture ("sprite/ashlands.png");
|
|
}
|
|
|
|
void engine_synchronize (void) {
|
|
Color background = { 0, 0, 0, 0 };
|
|
|
|
EndDrawing ();
|
|
|
|
if (WindowShouldClose ()) { engine_active = 0; }
|
|
|
|
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;
|
|
}
|
|
|
|
BeginDrawing ();
|
|
|
|
ClearBackground (background);
|
|
}
|