Created
August 10, 2018 19:56
-
-
Save 01010111/852c9d23d9994cdb94876ca2f18c41de to your computer and use it in GitHub Desktop.
Crawler
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package; | |
import flixel.FlxSprite; | |
import flixel.FlxState; | |
import flixel.graphics.FlxGraphic; | |
import flixel.math.FlxPoint; | |
import flixel.tile.FlxBaseTilemap.FlxTilemapAutoTiling; | |
import flixel.tile.FlxTilemap; | |
import flixel.util.FlxPath; | |
import flixel.util.FlxSpriteUtil; | |
class PlayState extends FlxState | |
{ | |
var clockwise:Bool = true; | |
override public function create():Void | |
{ | |
var data = [ | |
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0], | |
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0], | |
[0, 0, 0, 0, 1, 1, 0, 0, 0, 0], | |
[0, 0, 1, 1, 1, 1, 0, 0, 0, 0], | |
[0, 0, 1, 1, 1, 1, 0, 0, 0, 0], | |
[0, 0, 0, 0, 1, 1, 1, 1, 0, 0], | |
[0, 0, 0, 0, 1, 1, 1, 1, 0, 0], | |
[0, 0, 0, 0, 1, 1, 0, 0, 0, 0], | |
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0], | |
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0], | |
]; | |
bgColor = 0xFF808080; | |
var level = new FlxTilemap(); | |
level.loadMapFrom2DArray(data, FlxGraphic.fromClass(GraphicAuto), 8, 8, FlxTilemapAutoTiling.AUTO); | |
add(level); | |
var bug = new FlxSprite(16, 16); | |
bug.makeGraphic(8, 8); | |
FlxSpriteUtil.drawRect(bug, 0, 0, 4, 8, 0xFFFF0000); | |
add(bug); | |
bug.path = new FlxPath(); | |
var p = (x:Int, y:Int) -> FlxPoint.get(x * 8 + 4, y * 8 + 4); | |
bug.path.start([p(3, 2), p(3, 1), p(6, 1), p(6, 4), p(8, 4), p(8, 7), p(6, 7), p(6, 8), p(3, 8), p(3, 5), p(1, 5), p(1, 2)], 50, FlxPath.LOOP_FORWARD, true); | |
super.create(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment