Page 1 of 1

Tutorial - How to divide area to rooms

PostPosted: Wed Sep 15, 2010 7:04 pm
by lcl
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