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,,,~~~,~,,~,~,,,,,,~,~,~,,,,,,~,,,~~,~,,,,,~~,~,~,,~,~~,,~,,,~,,,~~~,,,,,~,,~,~,,,~,~,,~~~~~~,,,,~,,,,,,,,,~,,,~,~~,,,,,,,,~,~~,,,,,~,,~~,,~,~~,,,,,~,,,~,,~~,~,,~,,,,,,,,,~~,~~,~,,,~,,~~,~~,,,~~,,~~~~,,,,,,,,~,,,,,~,~,,
which was generated using a random coin flip
it renders the tiles in weird lines like this:
~.~.~.~.
~.~.~.~.
~.~.~.~.
Here is the link to the source code
Here is the rendering code:
// Tile Renderer.
let screen_w_in_tiles: f32 = ceilf(screen_width() / 32.0);
let screen_h_in_tiles: f32 = ceilf(screen_height() / 32.0);
let center_tile_x = ((screen_width() / 2.0) - worldx as f32) / 32.0;
let center_tile_y = ((screen_height() / 2.0) - worldy as f32) / 32.0;
let lo_tile_x = floorf(center_tile_x - screen_w_in_tiles / 2.0);
let hi_tile_x = floorf(center_tile_x + screen_w_in_tiles / 2.0 + 2.0);
let lo_tile_y = ceilf(center_tile_y - screen_h_in_tiles / 2.0 - 2.0);
let hi_tile_y = ceilf(center_tile_y + screen_h_in_tiles / 2.0);
for i in lo_tile_x as usize..hi_tile_x as usize {
for j in lo_tile_y as usize..hi_tile_y as usize {
match world_data[i] {
','=> tile = grass,
'*'=> tile = sand,
'~'=> tile = water,
'/'=> tile = ice,
_=> tile = unknown,
}
blit(tile, i as isize * 32 + worldx, j as isize * 32 + worldy, 32, 32);
}
}