You could use this (put it in Global Code).
- Code: Select all
#define game_height 300
#define rand_range 15
#define tile_width 20
void
create_level ()
{
static int i;
static int slope;
static int offset;
i+=xvelocity;
if(i%(40)==0)
{
offset+=slope;
CreateActor("tile", "tilemask", "(none)", "(none)", x+width+tile_width, y+tile_width+offset, true);
CreateActor("tile", "tilemask", "(none)", "(none)", x+width+tile_width, y+game_height-tile_width+offset, true);
}
if(i>=width)
{
i=0;
slope=rand_range-rand(rand_range*2);
while(offset+game_height+slope*width/tile_width>height || offset+slope*width/tile_width<0)
{
slope=rand_range-rand(rand_range*2);
}
}
}
Then add this to the view's draw.
view -> Draw Actor -> Script Editor
- Code: Select all
create_level();
You also need to set the view's xvelocity, so probably in create.
view -> Create Actor -> Script Editor
- Code: Select all
xvelocity=5;
For this you need an actor named tile, with an animation named tile_anim (but you can change those in the function to fit your game). You'd also probably want to add an out of vision event to destroy the tiles when they leave view. There are definitions in the global code that set the height of the flyable area, and also one for the dimension of the square tile.