umorna/source/engine.c

78 lines
2.0 KiB
C
Raw Normal View History

#include "core.h"
#include "game.h"
#include "engine.h"
static float zoom = 2.0F;
static Texture2D unit_data [3];
void render_unit (int race,
int unit,
int x,
int y) {
Rectangle source = { 0, (unit - race * 18) * BASE_SIZE, BASE_SIZE, BASE_SIZE };
Rectangle destination = { x, y, BASE_SIZE * zoom, BASE_SIZE * zoom };
Vector2 origin = { 0, 0 };
DrawTexturePro (unit_data [race], source, destination, origin, 0.0F, WHITE);
}
static Texture2D icons;
void render_icon (int x,
int y,
int u,
int v,
int p,
int q) {
DrawTextureRec (icons, (Rectangle) { x, y, u, v }, (Vector2) { p, q }, WHITE);
}
void render_text (char * text,
int x,
int y) {
DrawText (text, x + 6, y + 6, FONT_SIZE, WHITE);
}
static Texture2D ashlands_data;
void render_map (void) {
int x, y;
for (x = 0; x < CHAD_WORLD_WIDTH; ++x) {
for (y = 0; y < CHAD_WORLD_HEIGHT; ++y) {
int index = chad_world [0] [x] [y];
int catch = (y * y + x + x / (y + 1) + y / (x + 1)) % chad_block_change [index];
Rectangle source = { catch * BASE_SIZE, index * BASE_SIZE, BASE_SIZE, BASE_SIZE };
Rectangle destination = { x * BASE_SIZE * zoom, y * BASE_SIZE * zoom, BASE_SIZE * zoom, BASE_SIZE * zoom };
DrawTexturePro (ashlands_data, source, destination, (Vector2) { 0, 0 }, 0.0F, WHITE);
}
}
}
static void clean_up (void) {
CloseWindow ();
}
void engine_configure (void) {
InitWindow (1800, 900, "EAX");
SetExitKey (KEY_ESCAPE);
SetTargetFPS (60);
atexit (clean_up);
icons = LoadTexture ("sprite/menu/menu.png");
SetTextureFilter (icons, TEXTURE_FILTER_POINT);
ashlands_data = LoadTexture ("sprite/world/ashlands.png");
//~Texture2D vvv = LoadTexture ("sprite/orc/manor.png");
unit_data [orc] = LoadTexture ("sprite/orc/units.png");
unit_data [human] = LoadTexture ("sprite/human/units.png");
unit_data [elf] = LoadTexture ("sprite/elf/units.png");
}