Skip to content

Instantly share code, notes, and snippets.

@videlais
Created October 26, 2013 04:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save videlais/7165354 to your computer and use it in GitHub Desktop.
Save videlais/7165354 to your computer and use it in GitHub Desktop.
Autorunner Level Example
package
{
/**
* ...
* @author Dan Cox
*/
import org.flixel.*;
public class Level extends FlxGroup
{
[Embed(source="data/floor.png")]
private var floorPng:Class;
private var index:Number;
private var timer:FlxTimer;
public function Level()
{
index = 0;
timer = new FlxTimer();
timer.start(2, 1, addMoreBlocks);
for (var i:uint = 0; i < 20; i++)
{
var floor:FlxTileblock = new FlxTileblock(index, FlxG.height - 16, 16, 16);
floor.loadTiles(floorPng);
add(floor);
index += 16;
}
}
public function addMoreBlocks(Timer:FlxTimer = null):void
{
for (var i:uint = 0; i < 18; i++)
{
if (Math.random() * 100 <= 23)
{
for (var j:uint = 0; j < 2; j++)
{
var a:Spikes = new Spikes(index, FlxG.height - 12);
add(a);
index += 16;
}
}
else
{
for (var k:uint = 0; k < 2; k++)
{
var b:FlxTileblock = new FlxTileblock(index, FlxG.height - 16, 16, 16);
b.loadTiles(floorPng);
add(b);
index += 16;
}
}
}
timer.start(2, 1, addMoreBlocks);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment