umorna/source/engine.c

54 lines
1.7 KiB
C
Raw Normal View History

#include "engine.h"
void view_unit (int race, int unit, int x, int y) {
int u = 0;
int v = (unit - race * 18) * BASE_SIZE;
int width = BASE_SIZE;
int height = BASE_SIZE;
switch (race) {
case orc: render_sprite (orcs, x, y, u, v, width, height); break;
case human: render_sprite (humans, x, y, u, v, width, height); break;
case elf: render_sprite (elves, x, y, u, v, width, height); break;
default: break;
}
}
void view_menu (int menu, int align, int x, int y) {
int width = (int) strlen (menu_text [menu] [0]) * ICON_SIZE;
int height = menu_items [menu] * ICON_SIZE;
int item;
if (menu_show [menu] == 0) {
return;
}
//~if (menu_alpha [menu] != 0) {
//~DrawRectangle (x, y, width, height, BLACK);
//~}
for (item = 0; item < menu_items [menu]; ++item) {
int u = (menu_icon [menu] [item] / 10) * ICON_SIZE;
int v = (menu_icon [menu] [item] % 10) * ICON_SIZE;
int aligned_x = (align == 0) ? x : ((render_width () - width) / 2);
int aligned_y = (align == 0) ? y : ((render_height () - height) / 2);
render_sprite (ui, aligned_x, aligned_y + item * ICON_SIZE, u, v, ICON_SIZE, ICON_SIZE);
render_string (menu_text [menu] [item], aligned_x + ICON_SIZE, aligned_y + item * ICON_SIZE);
}
}
void view_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];
render_sprite (ashlands, x * BASE_SIZE, y * BASE_SIZE, catch * BASE_SIZE, index * BASE_SIZE, BASE_SIZE, BASE_SIZE);
}
}
}