Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- constexpr int max_tiles = 128;
- constexpr int tile_size = 32;
- constexpr int panel_tile_size = 128;
- local_persist int tiles[max_tiles][max_tiles] = zero;
- local_persist s_v2 offset = zero;
- local_persist float zoom = 1;
- if(is_key_down(key_up, true))
- {
- offset.y -= 10;
- }
- if(is_key_down(key_down, true))
- {
- offset.y += 10;
- }
- if(is_key_down(key_left, true))
- {
- offset.x -= 10;
- }
- if(is_key_down(key_right, true))
- {
- offset.x += 10;
- }
- zoom += input->wheel_movement * 0.1f;
- draw_rect_ui(v2(0), -5, c_world_size, color(0.1f).rgb);
- draw_rect_ui(v2(0), -4, v2(800, c_world_size.y), color(0.5f).rgb);
- local_persist b8 once = false;
- if(!once)
- {
- once = true;
- for(int y = 0; y < max_tiles; y++)
- {
- for(int x = 0; x < max_tiles; x++)
- {
- tiles[y][x] = game->client_rng.randu() % 2;
- }
- }
- }
- for(int y = 0; y < 10; y++)
- {
- for(int x = 0; x < 10; x++)
- {
- s_v2 pos = v2(
- (x * panel_tile_size - offset.x) * zoom,
- (y * panel_tile_size - offset.y) * zoom
- );
- s_v2 size = v2(panel_tile_size * zoom);
- if(pos.x + size.x > 800) { continue; }
- draw_texture_ui(
- e_texture_atlas,
- pos,
- 0.0f,
- size,
- color(1).rgb,
- v2i(x, y)
- );
- }
- }
- for(int y = 0; y < max_tiles; y++)
- {
- for(int x = 0; x < max_tiles; x++)
- {
- s_v2i index = tiles[y][x] == 0 ? v2i(0, 0) : v2i(0, 1);
- draw_texture_ui(
- e_texture_atlas,
- v2(
- 800 + tile_size * x,
- tile_size * y
- ),
- 0.0f,
- v2(tile_size),
- color(1).rgb,
- index
- );
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement