updated ui input function
parent
8d644c6d4c
commit
6fc06012b6
25
src/game.cc
25
src/game.cc
|
@ -131,16 +131,15 @@ void load_game() {
|
|||
add_mouse_button_listener(SDL_BUTTON_RMASK, &on_erase);
|
||||
add_mouse_button_listener(SDL_BUTTON_MMASK, &on_middle_mouse);
|
||||
add_mouse_listener(0, &on_drag_world);
|
||||
|
||||
}
|
||||
|
||||
void start_game() {
|
||||
g_active_view.width = 21;
|
||||
on_clear_key(1);
|
||||
}
|
||||
|
||||
void update_game() {
|
||||
if(drawing == 1) drawing = 2;
|
||||
update_input();
|
||||
mouse_world_position(&cursor.x, &cursor.y);
|
||||
cursor.x += 0.1f; cursor.y += 0.1f;
|
||||
|
||||
|
@ -175,26 +174,27 @@ void update_game() {
|
|||
}
|
||||
|
||||
void update_ui() {
|
||||
rectshape_t shape = (rectshape_t){
|
||||
0.0f, 0.0f, 1.f, 0.015f, 0, RLAYER_UI,
|
||||
{100,100,100,255}, {0,0,0,0}
|
||||
};
|
||||
int w = world_sheet.w / world_sheet.tile_width,
|
||||
h = world_sheet.h / world_sheet.tile_height,
|
||||
offset_selected = cursor_tile - 1;
|
||||
update_input();
|
||||
|
||||
const int offset_selected = cursor_tile - 1;
|
||||
|
||||
rectshape_t selected_tile_rect = (rectshape_t) {
|
||||
offset_selected * 0.015f, 0.f, 0.015f, 0.015f, 0.001f, RLAYER_UI-10,
|
||||
{0,0,0,0}, {255, 255, 255, 255}
|
||||
};
|
||||
draw_rect(&selected_tile_rect);
|
||||
|
||||
rectshape_t shape = (rectshape_t) {
|
||||
0.0f, 0.0f, 1.f, 0.015f, 0, RLAYER_UI,
|
||||
{100,100,100,255}, {0,0,0,0}
|
||||
};
|
||||
draw_rect(&shape);
|
||||
|
||||
int i = 0;
|
||||
float mx, my;
|
||||
mouse_screen_position(&mx, &my);
|
||||
for(auto& original: g_tilemap.tileset.set) {
|
||||
for(int i=0;i<g_tilemap.tileset.set.size();++i) {
|
||||
// make a copy of the reference sprite and adjust it to fit the ui
|
||||
sprite_t sprite = original;
|
||||
sprite_t sprite = g_tilemap.tileset.set.at(i);
|
||||
sprite.depth = RLAYER_UI-5;
|
||||
sprite.x = i * 0.015f; sprite.y = 0;
|
||||
sprite.sx = 0.015f; sprite.sy = 0.015f;
|
||||
|
@ -210,6 +210,5 @@ void update_ui() {
|
|||
}
|
||||
}
|
||||
|
||||
++i;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue