Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- obj_Controller
- ---------------------------------------------------------------------------------------------------------------------------------------
- ///Level Creation
- //Set Grid Size
- var gHeight = room_height div CELL_HEIGHT;
- var gWidth = room_width div CELL_WIDTH;
- //Create the Grid
- grid = ds_grid_create(gWidth, gHeight);
- //Fill grid with Air
- ds_grid_set_region(grid, 0, 0, gWidth-1, gHeight-1, AIR);
- //Randomize the world
- randomize();
- //Create a controller
- var cx = 0;
- var cy = room_height;
- //Give the controller a random direction
- var cdir = irandom(3);
- //Chance of controller changing direction
- var odds = 1;
- //Start Creating the level
- repeat (650) {
- //Place a ground tile
- //if (cy > room_height - CELL_WIDTH * 10) {
- grid[# cx, cy] = GROUND;
- //}
- //Randomize the direction of the controller
- if (irandom(odds) == odds) {
- cdir = irandom(3);
- }
- //Move the Controller
- var xdir = lengthdir_x(1, cdir*90);
- var ydir = lengthdir_y(1, cdir*90);
- cx += xdir;
- cy += ydir;
- //Keep the Controller inside the grid
- cx = clamp(cx, 1, gWidth-2);
- cy = clamp(cy, 1, gHeight-2);
- }
- //Time To Add The Ground
- for (var yy = 0; yy < gHeight; yy++) {
- for (var xx = 0; xx < gWidth; xx++) {
- if (grid[# xx, yy] == GROUND) {
- tile_add(tile_stonebricks, 0, 0, CELL_WIDTH, CELL_HEIGHT, xx*CELL_WIDTH, yy*CELL_HEIGHT, 0);
- }
- }
- }
- ---------------------------------------------------------------------------------------
- ///Restart The Room
- room_restart();
Advertisement
Add Comment
Please, Sign In to add comment