Advertisement
This is comment for paste
Array move
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /// Map Array Storage where Map is your 2d Array
- // define the size of each tile
- var tile_size = 32;
- // define the number of rows and columns in the map
- var num_rows = array_height_2d(map);
- var num_cols = array_length_2d(map, 0);
- // define the offset of the currently visible row
- var row_offset = 0;
- // define the number of visible rows
- var num_visible_rows = room_height div tile_size;
- // draw the visible portion of the map
- for (var row = row_offset; row < row_offset + num_visible_rows; row++) {
- for (var col = 0; col < num_cols; col++) {
- var tile = map[row, col];
- draw_sprite(tile_sprite, tile, col*tile_size, (row-row_offset)*tile_size);
- }
- }
- // increment the row offset when scrolling down
- if (keyboard_check_pressed(vk_down)) {
- row_offset += 1;
- }
- // decrement the row offset when scrolling up
- if (keyboard_check_pressed(vk_up)) {
- row_offset -= 1;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement