Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- // oMAP_BUILDER CREATE EVENT
- */
- // CREATE GRID
- global.rWorldOne = ds_grid_create(3, 3);
- // ROW ONE
- ds_grid_set(global.rWorldOne, 0, 0, "rWorldOne_0");
- ds_grid_set(global.rWorldOne, 1, 0, "rWorldOne_1");
- ds_grid_set(global.rWorldOne, 2, 0, "rWorldOne_2");
- // ROW TWO
- ds_grid_set(global.rWorldOne, 0, 1, "rWorldOne_3");
- ds_grid_set(global.rWorldOne, 1, 1, "rWorldOne_4");
- ds_grid_set(global.rWorldOne, 2, 1, "rWorldOne_5");
- // ROW THREE
- ds_grid_set(global.rWorldOne, 0, 2, "rWorldOne_6");
- ds_grid_set(global.rWorldOne, 1, 2, "rWorldOne_7");
- ds_grid_set(global.rWorldOne, 2, 2, "rWorldOne_8");
- -------------------------------------------------
- /*
- // oTRIGGER CREATE EVENT
- */
- current_world = global.rWorldOne;
- world_width = ds_grid_width(current_world);
- world_height = ds_grid_height(current_world);
- current_room = room_get_name(room);
- width_half = room_width / 2;
- height_half = room_height / 2;
- margin = 32;
- enum warp { none, north, west, east, south }
- warp_state = warp.none;
- warp_room = noone;
- /*
- // oTRIGGER STEP EVENT
- */
- // FIND POSITION IN ROOM
- if y < height_half { warp_state = warp.north; }
- if x < width_half { warp_state = warp.west; }
- if x > width_half { warp_state = warp.east; }
- if y > height_half { warp_state = warp.south; }
- // FIND WARP VALUE FROM WORLD GRID
- var xx;
- for (xx = 0; xx < world_width; xx++)
- {
- var yy;
- for (yy = 0; yy < world_height; yy++)
- {
- var check_room = ds_grid_get(current_world, xx, yy);
- if check_room = current_room
- {
- if warp_state = warp.north && (yy - 1) >= 0 { warp_room = ds_grid_get(current_world, xx, yy - 1); }
- else if warp_state = warp.west && (xx - 1) >= 0 { warp_room = ds_grid_get(current_world, xx - 1, yy); }
- else if warp_state = warp.east && (xx + 1) <= world_width - 1 { warp_room = ds_grid_get(current_world, xx + 1, yy); }
- else if warp_state = warp.south && (yy + 1) <= world_height - 1 { warp_room = ds_grid_get(current_world, xx, yy + 1); }
- }
- }
- }
- // WARP PLAYER ON COLLISION
- if place_meeting(x, y, oPlayer)
- {
- // MARGIN CHECK
- var multiply;
- if warp_state = warp.north || warp_state = warp.west { multiply = -1; } else { multiply = 1; }
- // Y AXIS WARP
- var target_x, target_y;
- if warp_state = warp.north || warp_state = warp.south
- {
- target_y = (room_height - oPlayer.y) + (margin * multiply);
- target_x = oPlayer.x;
- }
- // X AXIS WARP
- else if warp_state = warp.west || warp_state = warp.east
- {
- target_y = oPlayer.y;
- target_x = (room_width - oPlayer.x) + (margin * multiply);
- }
- // COMPLETE COLLISION WITH ROOM WARP
- if warp_room = noone { instance_destroy(id); }
- else {
- oPlayer.y = target_y;
- oPlayer.x = target_x;
- room_goto(asset_get_index(warp_room));
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement