Skip to content

Instantly share code, notes, and snippets.

@sjakaus
Created September 26, 2010 18:26
Show Gist options
  • Save sjakaus/598180 to your computer and use it in GitHub Desktop.
Save sjakaus/598180 to your computer and use it in GitHub Desktop.
package
{
import net.flashpunk.*;
import net.flashpunk.graphics.*;
import flash.geom.*;
public class Level extends Entity
{
[Embed(source = 'assets/bwtiles.png')] private const TILEIMAGE:Class;
public function Level()
{
var myTiles:Tilemap = new Tilemap(TILEIMAGE,1040,1040,16,16);
x = 0;
y = 0;
myTiles.setRegion(0,0,64,64,2);
graphic = myTiles;
var roomtype:uint;
var rotateby:uint;
var roomx:uint;
var roomy:uint;
var rooms:uint = 0;
var maxrooms:uint = 100;
//spam tetraminos
while(rooms < maxrooms)
{
//pick a tetramino
roomtype = FP.rand(7);
roomx = FP.rand(8);
roomy = FP.rand(8);
roomtype = 0;
switch(roomtype)
{
//I
case 0:
if(FP.rand(2) == 0)
{
myTiles.setRegion(roomx*8,roomy*8,33,9,0);
myTiles.setRegion(roomx*8+1,roomy*8+1,31,7,1);
}
else
{
}
break;
//L
case 1:
break;
//J
case 2:
break;
//T
case 3:
break;
//S
case 4:
break;
//Z
case 5:
break;
//O
case 6:
break;
}
rooms++
}
//this is how it's going to go down:
//pick a tetramino. rotate it randomly. pick a location on the map, stick it there.
//repeat a bunch
//draw surrounding walls
//place special rooms
//spam doorways (place doors at this time)
//pick a random spot for the entrance, flag eveything as connected
//make sure enough spots are flagged, otherwise repeat from the top?
//pick a random spot, check if it's flagged, place the entrance
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment