forked from: クォータービュー迷路
// forked from rsakane's クォータービュー迷路
// forked from rsakane's 迷路自動生成(棒倒し法)
package
{
import flash.display.Sprite;
import flash.events.MouseEvent;
import org.libspark.betweenas3.BetweenAS3;
import org.libspark.betweenas3.tweens.ITween;
[SWF(width="465", height="465", frameRate="30", backgroundColor="0xF3EFE4")]
public class Main extends Sprite
{
private const SIZE:int = 27; // Odd Number
private var pos:Array;
public function Main()
{
pos = new Array(SIZE);
for (var i:int = 0; i < SIZE; i++) pos[i] = new Array();
boutaoshi();
for (var y:int = 0; y < SIZE; y++)
{
for (var x:int = SIZE - 1; x >= 0; x--)
{
if (pos[x][y])
{
var block:Block = new Block();
addChild(block);
var t:ITween = BetweenAS3.tween(block, { x:(x + y) * 12 - 100, y:(y - x) * 6 + 240}, null, 2.0);
BetweenAS3.delay(t, Math.random() * 5).play();
}
}
}
}
private function boutaoshi():void
{
for (var i:int = 0; i < SIZE; i++)
{
for (var j:int = 0; j < SIZE; j++)
{
if (i == 0 || j == 0 || i == SIZE - 1 || j == SIZE - 1 || i % 2 == 0 && j % 2 == 0) pos[i][j] = true;
else pos[i][j] = false;
}
}
for (var y:int = 2; y < SIZE - 1; y += 2)
{
var dx:int = 2;
var dy:int = y;
switch (Math.floor(Math.random() * 4))
{
case 0:
dx++;
break;
case 1:
dx--;
break;
case 2:
dy++;
break;
case 3:
dy--;
break;
}
if (!pos[dx][dy]) pos[dx][dy] = true;
else y -= 2;
}
for (var x:int = 4; x < SIZE - 1; x += 2)
{
for (y = 2; y < SIZE - 1; y += 2)
{
dx = x;
dy = y;
switch (Math.floor(Math.random() * 3))
{
case 0:
dy++;
break;
case 1:
dy--;
break;
case 2:
dx++;
break;
}
if (!pos[dx][dy]) pos[dx][dy] = true;
else y -= 2;
}
}
}
}
}
import flash.display.Sprite;
class Block extends Sprite
{
public function Block()
{
//graphics.beginFill(0x99D9EA);
graphics.beginFill(0x995030);
graphics.moveTo(0, 6);
graphics.lineTo(12, 0);
graphics.lineTo(24, 6);
graphics.lineTo(12, 12);
graphics.lineTo(0, 6);
graphics.endFill();
//graphics.beginFill(0x546D8E);
graphics.beginFill(0xe5aa7a);
graphics.lineTo(0, 18);
graphics.lineTo(12, 24);
graphics.lineTo(12, 12);
graphics.lineTo(0, 6);
graphics.endFill();
//graphics.beginFill(0x709AD1);
graphics.beginFill(0xefcaab);
graphics.moveTo(13, 15);
graphics.lineTo(12, 24);
graphics.lineTo(24, 18);
graphics.lineTo(24, 6);
graphics.lineTo(12, 12);
graphics.endFill();
}
}