Tutorial - How to divide area to rooms

Learn how to make certain types of games and use gameEditor.

Tutorial - How to divide area to rooms

Postby lcl » Wed Sep 15, 2010 7:04 pm

Many has asked about rooms in GE, and I have now one very simple way to make "rooms". :D

First, create actor named Canvas and change its type to canvas.
Drag it on view and make it as large as view. Then add view as it's parent and it's Z Depth to 1.
Create variable called var. Make it integer and global variable.

Then, go to create actor, script editor:
Code: Select all
erase(0, 0, 0, 0);
var = 1;


Then go to draw actor, script editor:
Code: Select all
if (var == 0 && transp > 0)
{
    transp -= .05;
}

if (var == 1 && transp < 1)
{
    transp += .05;
}


And then, main actors Draw Actor - Script Editor:
Code: Select all
if (x > view.x + view.width)
{
    view.x += view.width;
    var = 1;
    Canvas.transp = 0;
}

if (x < view.x)
{
    view.x -= view.width;
    var = 1;
    Canvas.transp = 0;
}

if (y > view.y + view. height)
{
    view.y += view.height;
    var = 1;
    Canvas.transp = 0;
}

if (y < view.y)
{
    view.y -= view.height;
    var = 1;
    Canvas.transp = 0;
}


And you can easily build levels like rooms because of GE's grid that has
areas of same size as view. :D

I hope this was helpful! :D
Attachments
Rooms.PNG
Rooms.zip
(14.96 KiB) Downloaded 149 times
User avatar
lcl
 
Posts: 2339
Joined: Thu Mar 25, 2010 5:55 pm
Location: Finland
Score: 276 Give a positive score

Return to Tutorials

Who is online

Users browsing this forum: No registered users and 1 guest