Created
April 21, 2016 16:59
-
-
Save larsiusprime/eeead2179393bc8bd8276f991e94bdef to your computer and use it in GitHub Desktop.
tiles
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 tiles | |
{ | |
//this is where we define the "Shape" of each tile vis-a-vis the movement/edge grid | |
//NOTE: previously we were using the word "edge" to refer to segments.. this is confusing | |
public class edgedefs | |
{ | |
//edge states are stored in two 6-length lists, one for X edges (vertical) and one for Y edges (horizontal) | |
// -each list defines the edges in a 3x2 (X) or 2x3 (Y) region of cells, with the second entry corresponding to the top-left corner of the tile | |
// -: Y edge, |: X edge, +: both edges, *: both edges, tile's top-left corner | |
// -- | |
// |*+ | |
// |++ | |
// | |
// X: | |
// abc | |
// def | |
// | |
// Y: | |
// ad | |
// be | |
// cf | |
// | |
// "b" is the top-left corner of the cell (the cell covers bcef) | |
//each tiletype's list of edge states starts at tiletypeID*6 | |
// | |
//-note that we only need to set non-empty state, since empty == 0 is the default value for ints | |
private static const edgestates_X:Vector.<int> = new Vector.<int>(tiletypes.num_tile_types * 6, true); | |
private static const edgestates_Y:Vector.<int> = new Vector.<int>(tiletypes.num_tile_types * 6, true); | |
HELPER_SetEdgeStates_X(tiletypes.FULL, 2, 0, 2, 2, 0, 2); | |
HELPER_SetEdgeStates_Y(tiletypes.FULL, 2, 0, 2, 2, 0, 2); | |
HELPER_SetEdgeStates_Y(tiletypes.EDGE_BOTTOM, 0, 0, 2, 0, 0, 2); | |
HELPER_SetEdgeStates_Rotate90(tiletypes.EDGE_BOTTOM, tiletypes.EDGE_LEFT); | |
HELPER_SetEdgeStates_Rotate180(tiletypes.EDGE_BOTTOM, tiletypes.EDGE_TOP); | |
HELPER_SetEdgeStates_Rotate270(tiletypes.EDGE_BOTTOM, tiletypes.EDGE_RIGHT); | |
HELPER_SetEdgeStates_X(tiletypes.HALF_BOTTOM, 0, 0, 0, 2, 0, 2); | |
HELPER_SetEdgeStates_Y(tiletypes.HALF_BOTTOM, 0, 2, 2, 0, 2, 2); | |
HELPER_SetEdgeStates_Rotate90(tiletypes.HALF_BOTTOM, tiletypes.HALF_LEFT); | |
HELPER_SetEdgeStates_Rotate180(tiletypes.HALF_BOTTOM, tiletypes.HALF_TOP); | |
HELPER_SetEdgeStates_Rotate270(tiletypes.HALF_BOTTOM, tiletypes.HALF_RIGHT); | |
HELPER_SetEdgeStates_X(tiletypes.CONCAVE_PP, 2, 0, 1, 2, 1, 0); | |
HELPER_SetEdgeStates_Y(tiletypes.CONCAVE_PP, 2, 0, 1, 2, 1, 0); | |
HELPER_SetEdgeStates_Rotate90(tiletypes.CONCAVE_PP, tiletypes.CONCAVE_NP); | |
HELPER_SetEdgeStates_Rotate180(tiletypes.CONCAVE_PP, tiletypes.CONCAVE_NN); | |
HELPER_SetEdgeStates_Rotate270(tiletypes.CONCAVE_PP, tiletypes.CONCAVE_PN); | |
HELPER_SetEdgeStates_X(tiletypes.CONVEX_PP, 2, 0, 1, 2, 0, 1); | |
HELPER_SetEdgeStates_Y(tiletypes.CONVEX_PP, 2, 0, 1, 2, 0, 1); | |
HELPER_SetEdgeStates_Rotate90(tiletypes.CONVEX_PP, tiletypes.CONVEX_NP); | |
HELPER_SetEdgeStates_Rotate180(tiletypes.CONVEX_PP, tiletypes.CONVEX_NN); | |
HELPER_SetEdgeStates_Rotate270(tiletypes.CONVEX_PP, tiletypes.CONVEX_PN); | |
HELPER_SetEdgeStates_Copy(tiletypes.CONCAVE_PP, tiletypes.MED_PP); | |
HELPER_SetEdgeStates_Copy(tiletypes.CONCAVE_NP, tiletypes.MED_NP); | |
HELPER_SetEdgeStates_Copy(tiletypes.CONCAVE_NN, tiletypes.MED_NN); | |
HELPER_SetEdgeStates_Copy(tiletypes.CONCAVE_PN, tiletypes.MED_PN); | |
HELPER_SetEdgeStates_X(tiletypes.SMALL_22_PP, 2, 0, 1, 0, 0, 0); | |
HELPER_SetEdgeStates_Y(tiletypes.SMALL_22_PP, 2, 1, 0, 2, 1, 0); | |
HELPER_SetEdgeStates_Rotate90(tiletypes.SMALL_22_PP, tiletypes.SMALL_67_NP); | |
HELPER_SetEdgeStates_Rotate180(tiletypes.SMALL_22_PP, tiletypes.SMALL_22_NN); | |
HELPER_SetEdgeStates_Rotate270(tiletypes.SMALL_22_PP, tiletypes.SMALL_67_PN); | |
HELPER_SetEdgeStates_X(tiletypes.SMALL_67_PP, 2, 1, 0, 2, 1, 0); | |
HELPER_SetEdgeStates_Y(tiletypes.SMALL_67_PP, 2, 0, 1, 0, 0, 0); | |
HELPER_SetEdgeStates_Rotate90(tiletypes.SMALL_67_PP, tiletypes.SMALL_22_NP); | |
HELPER_SetEdgeStates_Rotate180(tiletypes.SMALL_67_PP, tiletypes.SMALL_67_NN); | |
HELPER_SetEdgeStates_Rotate270(tiletypes.SMALL_67_PP, tiletypes.SMALL_22_PN); | |
HELPER_SetEdgeStates_X(tiletypes.LARGE_22_PP, 2, 0, 2, 2, 0, 1); | |
HELPER_SetEdgeStates_Y(tiletypes.LARGE_22_PP, 2, 0, 1, 2, 0, 1); | |
HELPER_SetEdgeStates_Rotate90(tiletypes.LARGE_22_PP, tiletypes.LARGE_67_NP); | |
HELPER_SetEdgeStates_Rotate180(tiletypes.LARGE_22_PP, tiletypes.LARGE_22_NN); | |
HELPER_SetEdgeStates_Rotate270(tiletypes.LARGE_22_PP, tiletypes.LARGE_67_PN); | |
HELPER_SetEdgeStates_X(tiletypes.LARGE_67_PP, 2, 0, 1, 2, 0, 1); | |
HELPER_SetEdgeStates_Y(tiletypes.LARGE_67_PP, 2, 0, 2, 2, 0, 1); | |
HELPER_SetEdgeStates_Rotate90(tiletypes.LARGE_67_PP, tiletypes.LARGE_22_NP); | |
HELPER_SetEdgeStates_Rotate180(tiletypes.LARGE_67_PP, tiletypes.LARGE_67_NN); | |
HELPER_SetEdgeStates_Rotate270(tiletypes.LARGE_67_PP, tiletypes.LARGE_22_PN); | |
//NOTE: offset should be a number from 0 to 5 | |
public static function GetEdgeState_X(tiletype:int, offset:int):int | |
{ | |
return edgestates_X[(tiletype * 6) + offset]; | |
} | |
public static function GetEdgeState_Y(tiletype:int, offset:int):int | |
{ | |
return edgestates_Y[(tiletype * 6) + offset]; | |
} | |
private static function HELPER_SetEdgeStates_X(tiletype:int, a:int, b:int, c:int, d:int, e:int, f:int):void | |
{ | |
var base_index:int = tiletype * 6; | |
edgestates_X[base_index + 0] = a; | |
edgestates_X[base_index + 1] = b; | |
edgestates_X[base_index + 2] = c; | |
edgestates_X[base_index + 3] = d; | |
edgestates_X[base_index + 4] = e; | |
edgestates_X[base_index + 5] = f; | |
} | |
private static function HELPER_SetEdgeStates_Y(tiletype:int, a:int, b:int, c:int, d:int, e:int, f:int):void | |
{ | |
var base_index:int = tiletype * 6; | |
edgestates_Y[base_index + 0] = a; | |
edgestates_Y[base_index + 1] = b; | |
edgestates_Y[base_index + 2] = c; | |
edgestates_Y[base_index + 3] = d; | |
edgestates_Y[base_index + 4] = e; | |
edgestates_Y[base_index + 5] = f; | |
} | |
private static function HELPER_SetEdgeStates_Copy(source_type:int, dest_type:int):void | |
{ | |
var source_index:int = source_type * 6; | |
var dest_index:int = dest_type * 6; | |
edgestates_X[dest_index + 0] = edgestates_X[source_index + 0]; | |
edgestates_X[dest_index + 1] = edgestates_X[source_index + 1]; | |
edgestates_X[dest_index + 2] = edgestates_X[source_index + 2]; | |
edgestates_X[dest_index + 3] = edgestates_X[source_index + 3]; | |
edgestates_X[dest_index + 4] = edgestates_X[source_index + 4]; | |
edgestates_X[dest_index + 5] = edgestates_X[source_index + 5]; | |
edgestates_Y[dest_index + 0] = edgestates_Y[source_index + 0]; | |
edgestates_Y[dest_index + 1] = edgestates_Y[source_index + 1]; | |
edgestates_Y[dest_index + 2] = edgestates_Y[source_index + 2]; | |
edgestates_Y[dest_index + 3] = edgestates_Y[source_index + 3]; | |
edgestates_Y[dest_index + 4] = edgestates_Y[source_index + 4]; | |
edgestates_Y[dest_index + 5] = edgestates_Y[source_index + 5]; | |
} | |
//we define edge states for the PP version of each tile, and then call these functions to init the NP, NN, and PN versions | |
//(corresponding to 1, 2, and 3 CW 90deg rotations of the input data) | |
// | |
// abc ad -> da cba | |
// def be eb fed | |
// cf fc | |
private static function HELPER_SetEdgeStates_Rotate90(source_type:int, dest_type:int):void | |
{ | |
var source_index:int = source_type * 6; | |
var dest_index:int = dest_type * 6; | |
edgestates_Y[dest_index + 0] = edgestates_X[source_index + 3]; | |
edgestates_Y[dest_index + 1] = edgestates_X[source_index + 4]; | |
edgestates_Y[dest_index + 2] = edgestates_X[source_index + 5]; | |
edgestates_Y[dest_index + 3] = edgestates_X[source_index + 0]; | |
edgestates_Y[dest_index + 4] = edgestates_X[source_index + 1]; | |
edgestates_Y[dest_index + 5] = edgestates_X[source_index + 2]; | |
edgestates_X[dest_index + 0] = edgestates_Y[source_index + 2]; | |
edgestates_X[dest_index + 1] = edgestates_Y[source_index + 1]; | |
edgestates_X[dest_index + 2] = edgestates_Y[source_index + 0]; | |
edgestates_X[dest_index + 3] = edgestates_Y[source_index + 5]; | |
edgestates_X[dest_index + 4] = edgestates_Y[source_index + 4]; | |
edgestates_X[dest_index + 5] = edgestates_Y[source_index + 3]; | |
} | |
// abc ad -> fed fc | |
// def be cba eb | |
// cf da | |
private static function HELPER_SetEdgeStates_Rotate180(source_type:int, dest_type:int):void | |
{ | |
var source_index:int = source_type * 6; | |
var dest_index:int = dest_type * 6; | |
edgestates_X[dest_index + 0] = edgestates_X[source_index + 5]; | |
edgestates_X[dest_index + 1] = edgestates_X[source_index + 4]; | |
edgestates_X[dest_index + 2] = edgestates_X[source_index + 3]; | |
edgestates_X[dest_index + 3] = edgestates_X[source_index + 2]; | |
edgestates_X[dest_index + 4] = edgestates_X[source_index + 1]; | |
edgestates_X[dest_index + 5] = edgestates_X[source_index + 0]; | |
edgestates_Y[dest_index + 0] = edgestates_Y[source_index + 5]; | |
edgestates_Y[dest_index + 1] = edgestates_Y[source_index + 4]; | |
edgestates_Y[dest_index + 2] = edgestates_Y[source_index + 3]; | |
edgestates_Y[dest_index + 3] = edgestates_Y[source_index + 2]; | |
edgestates_Y[dest_index + 4] = edgestates_Y[source_index + 1]; | |
edgestates_Y[dest_index + 5] = edgestates_Y[source_index + 0]; | |
} | |
// abc ad -> cf def | |
// def be be abc | |
// cf ad | |
private static function HELPER_SetEdgeStates_Rotate270(source_type:int, dest_type:int):void | |
{ | |
var source_index:int = source_type * 6; | |
var dest_index:int = dest_type * 6; | |
edgestates_Y[dest_index + 0] = edgestates_X[source_index + 2]; | |
edgestates_Y[dest_index + 1] = edgestates_X[source_index + 1]; | |
edgestates_Y[dest_index + 2] = edgestates_X[source_index + 0]; | |
edgestates_Y[dest_index + 3] = edgestates_X[source_index + 5]; | |
edgestates_Y[dest_index + 4] = edgestates_X[source_index + 4]; | |
edgestates_Y[dest_index + 5] = edgestates_X[source_index + 3]; | |
edgestates_X[dest_index + 0] = edgestates_Y[source_index + 3]; | |
edgestates_X[dest_index + 1] = edgestates_Y[source_index + 4]; | |
edgestates_X[dest_index + 2] = edgestates_Y[source_index + 5]; | |
edgestates_X[dest_index + 3] = edgestates_Y[source_index + 0]; | |
edgestates_X[dest_index + 4] = edgestates_Y[source_index + 1]; | |
edgestates_X[dest_index + 5] = edgestates_Y[source_index + 2]; | |
} | |
} | |
} |
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 tiles | |
{ | |
//edge states used by the edge grid | |
public class edgetypes | |
{ | |
//NOTE: these are in order, because we use max(stateA, stateB) to set edges to the most-solid state given the adjacent tiles' edge states | |
public static const EMPTY:int = 0; | |
public static const PARTIAL:int = 1; | |
public static const SOLID:int = 2; | |
} | |
} |
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 tiles | |
{ | |
import simulation.collision.Segment; | |
//this is a brain-dead method of defining tile geometry; we explicitly define tiles as lists of Segments in "tilespace" | |
//(tilespace has the origin in the center of the tile, and all coordinates in [-1,1] | |
// | |
//edges are defined in two ways: | |
// -edges that lie along the boundary between tiles are defined using a set of flags, so that we can filter out external edges | |
// -we then index into a table of archetypes | |
// -all other edges are defined using "archetypes" | |
// -each tile can have at most one non-boundary edge | |
public class tiledefs | |
{ | |
//define the non-boundary edges | |
private static const segdefs:Vector.<TileEdgeArchetype> = new Vector.<TileEdgeArchetype>(tiletypes.num_tile_types, true); | |
segdefs[tiletypes.EMPTY] = null; | |
segdefs[tiletypes.FULL] = null; | |
segdefs[tiletypes.EDGE_TOP] = null; | |
segdefs[tiletypes.EDGE_RIGHT] = null; | |
segdefs[tiletypes.EDGE_BOTTOM] = null; | |
segdefs[tiletypes.EDGE_LEFT] = null; | |
segdefs[tiletypes.EDGE_CORNER_UL] = null; | |
segdefs[tiletypes.EDGE_CORNER_UR] = null; | |
segdefs[tiletypes.EDGE_CORNER_DL] = null; | |
segdefs[tiletypes.EDGE_CORNER_DR] = null; | |
segdefs[tiletypes.HALF_TOP] = new TileEdgeArchetype_Linear( -1, 0, 1, 0); | |
segdefs[tiletypes.HALF_RIGHT] = segdefs[tiletypes.HALF_TOP].GeneratePerpArchetype(); | |
segdefs[tiletypes.HALF_BOTTOM] = segdefs[tiletypes.HALF_RIGHT].GeneratePerpArchetype(); | |
segdefs[tiletypes.HALF_LEFT] = segdefs[tiletypes.HALF_BOTTOM].GeneratePerpArchetype(); | |
segdefs[tiletypes.MED_PP] = new TileEdgeArchetype_Linear( -1, 1, 1, -1); | |
segdefs[tiletypes.MED_NP] = segdefs[tiletypes.MED_PP].GeneratePerpArchetype(); | |
segdefs[tiletypes.MED_NN] = segdefs[tiletypes.MED_NP].GeneratePerpArchetype(); | |
segdefs[tiletypes.MED_PN] = segdefs[tiletypes.MED_NN].GeneratePerpArchetype(); | |
segdefs[tiletypes.CONVEX_PP] = new TileEdgeArchetype_Circular( -1, 1, 1, -1, -1, -1); | |
segdefs[tiletypes.CONVEX_NP] = segdefs[tiletypes.CONVEX_PP].GeneratePerpArchetype(); | |
segdefs[tiletypes.CONVEX_NN] = segdefs[tiletypes.CONVEX_NP].GeneratePerpArchetype(); | |
segdefs[tiletypes.CONVEX_PN] = segdefs[tiletypes.CONVEX_NN].GeneratePerpArchetype(); | |
segdefs[tiletypes.CONCAVE_PP] = new TileEdgeArchetype_Circular( -1, 1, 1, -1, 1, 1); | |
segdefs[tiletypes.CONCAVE_NP] = segdefs[tiletypes.CONCAVE_PP].GeneratePerpArchetype(); | |
segdefs[tiletypes.CONCAVE_NN] = segdefs[tiletypes.CONCAVE_NP].GeneratePerpArchetype(); | |
segdefs[tiletypes.CONCAVE_PN] = segdefs[tiletypes.CONCAVE_NN].GeneratePerpArchetype(); | |
segdefs[tiletypes.SMALL_22_PP] = new TileEdgeArchetype_Linear( -1, 0, 1, -1); | |
segdefs[tiletypes.SMALL_67_NP] = segdefs[tiletypes.SMALL_22_PP].GeneratePerpArchetype(); | |
segdefs[tiletypes.SMALL_22_NN] = segdefs[tiletypes.SMALL_67_NP].GeneratePerpArchetype(); | |
segdefs[tiletypes.SMALL_67_PN] = segdefs[tiletypes.SMALL_22_NN].GeneratePerpArchetype(); | |
segdefs[tiletypes.SMALL_67_PP] = new TileEdgeArchetype_Linear( -1, 1, 0, -1); | |
segdefs[tiletypes.SMALL_22_NP] = segdefs[tiletypes.SMALL_67_PP].GeneratePerpArchetype(); | |
segdefs[tiletypes.SMALL_67_NN] = segdefs[tiletypes.SMALL_22_NP].GeneratePerpArchetype(); | |
segdefs[tiletypes.SMALL_22_PN] = segdefs[tiletypes.SMALL_67_NN].GeneratePerpArchetype(); | |
segdefs[tiletypes.LARGE_22_PP] = new TileEdgeArchetype_Linear( -1, 1, 1, 0); | |
segdefs[tiletypes.LARGE_67_NP] = segdefs[tiletypes.LARGE_22_PP].GeneratePerpArchetype(); | |
segdefs[tiletypes.LARGE_22_NN] = segdefs[tiletypes.LARGE_67_NP].GeneratePerpArchetype(); | |
segdefs[tiletypes.LARGE_67_PN] = segdefs[tiletypes.LARGE_22_NN].GeneratePerpArchetype(); | |
segdefs[tiletypes.LARGE_67_PP] = new TileEdgeArchetype_Linear( 0, 1, 1, -1); | |
segdefs[tiletypes.LARGE_22_NP] = segdefs[tiletypes.LARGE_67_PP].GeneratePerpArchetype(); | |
segdefs[tiletypes.LARGE_67_NN] = segdefs[tiletypes.LARGE_22_NP].GeneratePerpArchetype(); | |
segdefs[tiletypes.LARGE_22_PN] = segdefs[tiletypes.LARGE_67_NN].GeneratePerpArchetype(); | |
//define the boundary edges | |
//-the boundary of a tile is split into 8 half-tile-size-length segments: | |
// | |
// 6 7 | |
// _ _ | |
// 0| |4 | |
// 1|_ _|5 | |
// 2 3 | |
// | |
//this way the corresponding "opposite" edge is (current_edge_number+4)%8 | |
// | |
// | |
//to simplify the logic when generating geometry, we use a similar method to index into a list of archetypes: | |
// | |
// 11 | |
// / \ | |
// 9 10 | |
// _ _ | |
// / 0| |6 \8 | |
// 2\ 1|_ _|7 / | |
// 3 4 | |
// \ / | |
// 5 | |
//GHA!!!! we were getting fucked-up bugs because this wasn't being defined/initted until AFTER we were calling HELPER_SetBoundaryFlags_Perp().. BAH!! | |
//NOTE: the way that boundary flags are indexed makes them awkward to rotate; this just maps from a given index to the index 90deg CCW from it | |
// | |
//++TODO: this seems stupid.. better solution? | |
private static var perpindex:Vector.<uint> = new Vector.<uint>(8, true); | |
perpindex[0] = 2; | |
perpindex[1] = 3; | |
perpindex[2] = 5; | |
perpindex[3] = 4; | |
perpindex[4] = 6; | |
perpindex[5] = 7; | |
perpindex[6] = 1; | |
perpindex[7] = 0; | |
//++TODO: use an 8bit bitfield instead of 8 bools! | |
private static const boundaryflags:Vector.< Vector.<Boolean> > = new Vector.< Vector.<Boolean> >(tiletypes.num_tile_types, true); | |
HELPER_InitBoundaryFlags(); | |
boundaryflags[tiletypes.FULL][0] = true; | |
boundaryflags[tiletypes.FULL][1] = true; | |
boundaryflags[tiletypes.FULL][2] = true; | |
boundaryflags[tiletypes.FULL][3] = true; | |
boundaryflags[tiletypes.FULL][4] = true; | |
boundaryflags[tiletypes.FULL][5] = true; | |
boundaryflags[tiletypes.FULL][6] = true; | |
boundaryflags[tiletypes.FULL][7] = true; | |
boundaryflags[tiletypes.EDGE_TOP][6] = true; | |
boundaryflags[tiletypes.EDGE_TOP][7] = true; | |
HELPER_SetBoundaryFlags_Perp(tiletypes.EDGE_TOP, tiletypes.EDGE_RIGHT); | |
HELPER_SetBoundaryFlags_Perp(tiletypes.EDGE_RIGHT, tiletypes.EDGE_BOTTOM); | |
HELPER_SetBoundaryFlags_Perp(tiletypes.EDGE_BOTTOM, tiletypes.EDGE_LEFT); | |
boundaryflags[tiletypes.HALF_TOP][0] = true; | |
boundaryflags[tiletypes.HALF_TOP][4] = true; | |
boundaryflags[tiletypes.HALF_TOP][6] = true; | |
boundaryflags[tiletypes.HALF_TOP][7] = true; | |
HELPER_SetBoundaryFlags_Perp(tiletypes.HALF_TOP, tiletypes.HALF_RIGHT); | |
HELPER_SetBoundaryFlags_Perp(tiletypes.HALF_RIGHT, tiletypes.HALF_BOTTOM); | |
HELPER_SetBoundaryFlags_Perp(tiletypes.HALF_BOTTOM, tiletypes.HALF_LEFT); | |
boundaryflags[tiletypes.MED_PP][0] = true; | |
boundaryflags[tiletypes.MED_PP][1] = true; | |
boundaryflags[tiletypes.MED_PP][6] = true; | |
boundaryflags[tiletypes.MED_PP][7] = true; | |
HELPER_SetBoundaryFlags_Perp(tiletypes.MED_PP, tiletypes.MED_NP); | |
HELPER_SetBoundaryFlags_Perp(tiletypes.MED_NP, tiletypes.MED_NN); | |
HELPER_SetBoundaryFlags_Perp(tiletypes.MED_NN, tiletypes.MED_PN); | |
HELPER_SetBoundaryFlags_Copy(tiletypes.MED_PP, tiletypes.CONVEX_PP); | |
HELPER_SetBoundaryFlags_Copy(tiletypes.MED_NP, tiletypes.CONVEX_NP); | |
HELPER_SetBoundaryFlags_Copy(tiletypes.MED_NN, tiletypes.CONVEX_NN); | |
HELPER_SetBoundaryFlags_Copy(tiletypes.MED_PN, tiletypes.CONVEX_PN); | |
HELPER_SetBoundaryFlags_Copy(tiletypes.MED_PP, tiletypes.CONCAVE_PP); | |
HELPER_SetBoundaryFlags_Copy(tiletypes.MED_NP, tiletypes.CONCAVE_NP); | |
HELPER_SetBoundaryFlags_Copy(tiletypes.MED_NN, tiletypes.CONCAVE_NN); | |
HELPER_SetBoundaryFlags_Copy(tiletypes.MED_PN, tiletypes.CONCAVE_PN); | |
boundaryflags[tiletypes.SMALL_22_PP][0] = true; | |
boundaryflags[tiletypes.SMALL_22_PP][6] = true; | |
boundaryflags[tiletypes.SMALL_22_PP][7] = true; | |
HELPER_SetBoundaryFlags_Perp(tiletypes.SMALL_22_PP, tiletypes.SMALL_67_NP); | |
HELPER_SetBoundaryFlags_Perp(tiletypes.SMALL_67_NP, tiletypes.SMALL_22_NN); | |
HELPER_SetBoundaryFlags_Perp(tiletypes.SMALL_22_NN, tiletypes.SMALL_67_PN); | |
boundaryflags[tiletypes.SMALL_67_PP][0] = true; | |
boundaryflags[tiletypes.SMALL_67_PP][1] = true; | |
boundaryflags[tiletypes.SMALL_67_PP][6] = true; | |
HELPER_SetBoundaryFlags_Perp(tiletypes.SMALL_67_PP, tiletypes.SMALL_22_NP); | |
HELPER_SetBoundaryFlags_Perp(tiletypes.SMALL_22_NP, tiletypes.SMALL_67_NN); | |
HELPER_SetBoundaryFlags_Perp(tiletypes.SMALL_67_NN, tiletypes.SMALL_22_PN); | |
boundaryflags[tiletypes.LARGE_22_PP][0] = true; | |
boundaryflags[tiletypes.LARGE_22_PP][1] = true; | |
boundaryflags[tiletypes.LARGE_22_PP][4] = true; | |
boundaryflags[tiletypes.LARGE_22_PP][6] = true; | |
boundaryflags[tiletypes.LARGE_22_PP][7] = true; | |
HELPER_SetBoundaryFlags_Perp(tiletypes.LARGE_22_PP, tiletypes.LARGE_67_NP); | |
HELPER_SetBoundaryFlags_Perp(tiletypes.LARGE_67_NP, tiletypes.LARGE_22_NN); | |
HELPER_SetBoundaryFlags_Perp(tiletypes.LARGE_22_NN, tiletypes.LARGE_67_PN); | |
boundaryflags[tiletypes.LARGE_67_PP][0] = true; | |
boundaryflags[tiletypes.LARGE_67_PP][1] = true; | |
boundaryflags[tiletypes.LARGE_67_PP][2] = true; | |
boundaryflags[tiletypes.LARGE_67_PP][6] = true; | |
boundaryflags[tiletypes.LARGE_67_PP][7] = true; | |
HELPER_SetBoundaryFlags_Perp(tiletypes.LARGE_67_PP, tiletypes.LARGE_22_NP); | |
HELPER_SetBoundaryFlags_Perp(tiletypes.LARGE_22_NP, tiletypes.LARGE_67_NN); | |
HELPER_SetBoundaryFlags_Perp(tiletypes.LARGE_67_NN, tiletypes.LARGE_22_PN); | |
private static const boundarydefs:Vector.<TileEdgeArchetype> = new Vector.<TileEdgeArchetype>(12, true); | |
boundarydefs[0] = new TileEdgeArchetype_Linear( -1, -1, -1, 0); | |
boundarydefs[1] = new TileEdgeArchetype_Linear( -1, 0, -1, 1); | |
boundarydefs[2] = new TileEdgeArchetype_Linear( -1, -1, -1, 1); | |
boundarydefs[9] = boundarydefs[1].GeneratePerpArchetype(); | |
boundarydefs[10] = boundarydefs[0].GeneratePerpArchetype(); | |
boundarydefs[11] = boundarydefs[2].GeneratePerpArchetype(); | |
boundarydefs[7] = boundarydefs[10].GeneratePerpArchetype(); | |
boundarydefs[6] = boundarydefs[9].GeneratePerpArchetype(); | |
boundarydefs[8] = boundarydefs[11].GeneratePerpArchetype(); | |
boundarydefs[4] = boundarydefs[6].GeneratePerpArchetype(); | |
boundarydefs[3] = boundarydefs[7].GeneratePerpArchetype(); | |
boundarydefs[5] = boundarydefs[8].GeneratePerpArchetype(); | |
public static function GenerateTileSegments_Filtered(tiletype:int, neighbIDs:Vector.<int>, tilecenter_x:Number, tilecenter_y:Number, tile_halfwidth:Number):Vector.<Segment> | |
{ | |
if (tiletype < 0 || tiletype >= tiletypes.num_tile_types) | |
{ | |
trace("WARNING! GenerateTileSegments() was passed an invalid tiletype: " + tiletype); | |
return null; | |
} | |
var outList:Vector.<Segment> = new Vector.<Segment>(); | |
//++TODO: filter bflags | |
for(var i:int = 0; i < 4; i++) | |
{ | |
var edgeA:Boolean = boundaryflags[tiletype][(i * 2)] && !boundaryflags[neighbIDs[i]][((i * 2) + 4) % 8]; | |
var edgeB:Boolean = boundaryflags[tiletype][((i * 2) + 1)] && !boundaryflags[neighbIDs[i]][(((i * 2) + 1) + 4) % 8]; | |
//offset = -1; | |
//if(edgeA): offset += 1 | |
//if(edgeB): offset += 2 | |
//if(offset >= 0): lookup archetype_geometry[(i*3)+offset] | |
if (edgeA) | |
{ | |
if (edgeB) | |
{ | |
outList.push(boundarydefs[(i * 3) + 2].GenerateCollisionSegment(tilecenter_x, tilecenter_y, tile_halfwidth)); | |
} | |
else | |
{ | |
outList.push(boundarydefs[(i * 3)].GenerateCollisionSegment(tilecenter_x, tilecenter_y, tile_halfwidth)); | |
} | |
} | |
else if (edgeB) | |
{ | |
outList.push(boundarydefs[(i * 3) + 1].GenerateCollisionSegment(tilecenter_x, tilecenter_y, tile_halfwidth)); | |
} | |
} | |
//collect non-boundary edge | |
var edgearch:TileEdgeArchetype = segdefs[tiletype]; | |
if(edgearch != null) | |
{ | |
outList.push(edgearch.GenerateCollisionSegment(tilecenter_x, tilecenter_y, tile_halfwidth)); | |
} | |
return outList; | |
} | |
public static function GenerateTileSegments(tiletype:int, tilecenter_x:Number, tilecenter_y:Number, tile_halfwidth:Number):Vector.<Segment> | |
{ | |
if (tiletype < 0 || tiletype >= tiletypes.num_tile_types) | |
{ | |
trace("WARNING! GenerateTileSegments() was passed an invalid tiletype: " + tiletype); | |
return null; | |
} | |
var outList:Vector.<Segment> = new Vector.<Segment>(); | |
var bflags:Vector.<Boolean> = boundaryflags[tiletype]; | |
//++TODO: filter bflags | |
for(var i:int = 0; i < 4; i++) | |
{ | |
var edgeA:Boolean = bflags[(i*2)]; | |
var edgeB:Boolean = bflags[(i*2)+1]; | |
//offset = -1; | |
//if(edgeA): offset += 1 | |
//if(edgeB): offset += 2 | |
//if(offset >= 0): lookup archetype_geometry[(i*3)+offset] | |
if (edgeA) | |
{ | |
if (edgeB) | |
{ | |
outList.push(boundarydefs[(i * 3) + 2].GenerateCollisionSegment(tilecenter_x, tilecenter_y, tile_halfwidth)); | |
} | |
else | |
{ | |
outList.push(boundarydefs[(i * 3)].GenerateCollisionSegment(tilecenter_x, tilecenter_y, tile_halfwidth)); | |
} | |
} | |
else if (edgeB) | |
{ | |
outList.push(boundarydefs[(i * 3) + 1].GenerateCollisionSegment(tilecenter_x, tilecenter_y, tile_halfwidth)); | |
} | |
} | |
//collect non-boundary edge | |
var edgearch:TileEdgeArchetype = segdefs[tiletype]; | |
if(edgearch != null) | |
{ | |
outList.push(edgearch.GenerateCollisionSegment(tilecenter_x, tilecenter_y, tile_halfwidth)); | |
} | |
return outList; | |
} | |
private static function HELPER_InitBoundaryFlags():void | |
{ | |
for (var z:int = 0; z < tiletypes.num_tile_types; z++) | |
{ | |
boundaryflags[z] = new Vector.<Boolean>(8, true); | |
for (var zz:int = 0; zz < 8; zz++) | |
{ | |
boundaryflags[z][zz] = false; | |
} | |
} | |
} | |
//this copies the values in inList to the values in outList | |
private static function HELPER_SetBoundaryFlags_Copy(inListID:int, outListID:int):void | |
{ | |
for (var i:int = 0; i < 8; i++) | |
{ | |
boundaryflags[outListID][i] = boundaryflags[inListID][i]; | |
} | |
} | |
//this sets the values in outList to the values in inList rotated 90deg CW | |
private static function HELPER_SetBoundaryFlags_Perp(inListID:int, outListID:int):void | |
{ | |
for (var i:int = 0; i < 8; i++) | |
{ | |
boundaryflags[outListID][i] = boundaryflags[inListID][perpindex[i]]; | |
//trace("whuck? " + i + "->" + perpindex[i]); | |
} | |
} | |
} | |
} |
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 tiles | |
{ | |
import simulation.collision.Segment; | |
//this defines tile geometry and generates it on command | |
// | |
//++TODO: this seems like some sort of factory; it also seems like there's probably a much smarter way to go about doing all of this crap | |
public interface TileEdgeArchetype | |
{ | |
function GeneratePerpArchetype():TileEdgeArchetype;//generates an archetype that's rotated 90deg CW | |
function GenerateCollisionSegment(translate_x:Number, translate_y:Number, scale:Number):Segment; | |
} | |
} |
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 tiles | |
{ | |
import simulation.collision.Segment; | |
import simulation.collision.Segment_Circular; | |
public class TileEdgeArchetype_Circular implements TileEdgeArchetype | |
{ | |
private var x0:Number; | |
private var y0:Number; | |
private var x1:Number; | |
private var y1:Number; | |
private var x2:Number; | |
private var y2:Number; | |
public function TileEdgeArchetype_Circular(xA:Number, yA:Number, xB:Number, yB:Number, xC:Number, yC:Number) | |
{ | |
x0 = xA; | |
y0 = yA; | |
x1 = xB; | |
y1 = yB; | |
x2 = xC; | |
y2 = yC; | |
} | |
public function GeneratePerpArchetype():TileEdgeArchetype | |
{ | |
return new TileEdgeArchetype_Circular( -y0, x0, -y1, x1, -y2, x2); | |
} | |
public function GenerateCollisionSegment(translate_x:Number, translate_y:Number, scale:Number):Segment | |
{ | |
return new Segment_Circular(translate_x + (x2 * scale), translate_y + (y2 * scale), translate_x + (x0 * scale), translate_y + (y0 * scale), translate_x + (x1 * scale), translate_y + (y1 * scale)); | |
} | |
} | |
} |
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 tiles | |
{ | |
import simulation.collision.Segment; | |
import simulation.collision.Segment_Linear; | |
public class TileEdgeArchetype_Linear implements TileEdgeArchetype | |
{ | |
private var x0:Number; | |
private var y0:Number; | |
private var x1:Number; | |
private var y1:Number; | |
public function TileEdgeArchetype_Linear(xA:Number, yA:Number, xB:Number, yB:Number) | |
{ | |
x0 = xA; | |
y0 = yA; | |
x1 = xB; | |
y1 = yB; | |
} | |
public function GeneratePerpArchetype():TileEdgeArchetype | |
{ | |
return new TileEdgeArchetype_Linear( -y0, x0, -y1, x1); | |
} | |
public function GenerateCollisionSegment(translate_x:Number, translate_y:Number, scale:Number):Segment | |
{ | |
return new Segment_Linear(translate_x + (x0 * scale), translate_y + (y0 * scale), translate_x + (x1 * scale), translate_y + (y1 * scale)); | |
} | |
} | |
} |
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 tiles | |
{ | |
//this is a stupid "enum" class containing all tile shape IDs | |
public class tiletypes | |
{ | |
public static const EMPTY:int = 0; //no tile | |
public static const FULL:int = 1; //full tile | |
public static const HALF_TOP:int = 2; //half-tile rectangle | |
public static const HALF_RIGHT:int = 3; | |
public static const HALF_BOTTOM:int = 4; //NOTE: for edge and half types, T/R/B/L corresponds to 0/90/180/270deg CW rotation | |
public static const HALF_LEFT:int = 5; | |
public static const MED_PP:int = 6; //45deg triangle | |
public static const MED_NP:int = 7; | |
public static const MED_NN:int = 8; //NOTE: for 45deg and arcs, PP/NP/NN/PN corresponds to 0/90/180/270deg CW rotation | |
public static const MED_PN:int = 9; //(for 22/67 slopes, it's a bit messy because 90/270deg rotations result in the angles swapping 22<->67) | |
public static const CONVEX_PP:int = 10; //..just in case we forget, "P" and "N" refer to the sign of the slope's normal, i.e +ve=P, -ve=N; PN = +ve X, -ve Y | |
public static const CONVEX_NP:int = 11; | |
public static const CONVEX_NN:int = 12; | |
public static const CONVEX_PN:int = 13; | |
public static const CONCAVE_PP:int = 14; | |
public static const CONCAVE_NP:int = 15; | |
public static const CONCAVE_NN:int = 16; | |
public static const CONCAVE_PN:int = 17; | |
public static const SMALL_22_PP:int = 18; //22.5deg triangle | |
public static const SMALL_22_NP:int = 19; | |
public static const SMALL_22_NN:int = 20; | |
public static const SMALL_22_PN:int = 21; | |
public static const LARGE_22_PP:int = 22; //22.5seg triangle+half-tile base | |
public static const LARGE_22_NP:int = 23; | |
public static const LARGE_22_NN:int = 24; | |
public static const LARGE_22_PN:int = 25; | |
public static const SMALL_67_PP:int = 26; //67.5deg triangle | |
public static const SMALL_67_NP:int = 27; | |
public static const SMALL_67_NN:int = 28; | |
public static const SMALL_67_PN:int = 29; | |
public static const LARGE_67_PP:int = 30; //67.5seg triangle+half-tile base | |
public static const LARGE_67_NP:int = 31; | |
public static const LARGE_67_NN:int = 32; | |
public static const LARGE_67_PN:int = 33;//--- END OF IN-GAME TYPES --- | |
public static const EDGE_TOP:int = 34;//edge tiles | |
public static const EDGE_RIGHT:int = 35;// note:"edge" tiles are used to generate the outer border/boundary around the level | |
public static const EDGE_BOTTOM:int = 36;// (these are somewhat redundant since we could just use full tiles if we didn't mind generating useless extra geometry) | |
public static const EDGE_LEFT:int = 37; | |
public static const EDGE_CORNER_UL:int = 38;//the corners of the tilegrid are empty, but should be drawn full | |
public static const EDGE_CORNER_UR:int = 39;//..since we're drawing oversized graphics, each corner needs a unique type | |
public static const EDGE_CORNER_DL:int = 40; | |
public static const EDGE_CORNER_DR:int = 41; | |
public static const num_tile_types:int = 42; | |
public static const num_ingame_tile_types:int = 34; | |
//each entry maps an old "TID" value to an enum value | |
private static var MAP_OLD_TYPE_TO_NEW_TYPE:Vector.<int> = new Vector.<int>(num_ingame_tile_types, true); | |
MAP_OLD_TYPE_TO_NEW_TYPE[0] = EMPTY; //TID_EMPTY = 0; | |
MAP_OLD_TYPE_TO_NEW_TYPE[1] = FULL;//TID_FULL = 1;//fullAABB tile | |
MAP_OLD_TYPE_TO_NEW_TYPE[2] = MED_PN;//TID_45DEGpn = 2;//45-degree triangle, whose normal is (+ve,-ve) | |
MAP_OLD_TYPE_TO_NEW_TYPE[3] = MED_NN;//TID_45DEGnn = 3;//(+ve,+ve) | |
MAP_OLD_TYPE_TO_NEW_TYPE[4] = MED_NP;//TID_45DEGnp = 4;//(-ve,+ve) | |
MAP_OLD_TYPE_TO_NEW_TYPE[5] = MED_PP;//TID_45DEGpp = 5;//(-ve,-ve) | |
MAP_OLD_TYPE_TO_NEW_TYPE[6] = CONCAVE_PN;//TID_CONCAVEpn = 6;//1/4-circle cutout | |
MAP_OLD_TYPE_TO_NEW_TYPE[7] = CONCAVE_NN;//TID_CONCAVEnn = 7; | |
MAP_OLD_TYPE_TO_NEW_TYPE[8] = CONCAVE_NP;//TID_CONCAVEnp = 8; | |
MAP_OLD_TYPE_TO_NEW_TYPE[9] = CONCAVE_PP;//TID_CONCAVEpp = 9; | |
MAP_OLD_TYPE_TO_NEW_TYPE[10] = CONVEX_PN;//TID_CONVEXpn = 10;//1/4/circle | |
MAP_OLD_TYPE_TO_NEW_TYPE[11] = CONVEX_NN;//TID_CONVEXnn = 11; | |
MAP_OLD_TYPE_TO_NEW_TYPE[12] = CONVEX_NP;//TID_CONVEXnp = 12; | |
MAP_OLD_TYPE_TO_NEW_TYPE[13] = CONVEX_PP;//TID_CONVEXpp = 13; | |
MAP_OLD_TYPE_TO_NEW_TYPE[14] = SMALL_22_PN;//TID_22DEGpnS = 14;//22.5 degree slope | |
MAP_OLD_TYPE_TO_NEW_TYPE[15] = SMALL_22_NN;//TID_22DEGnnS = 15; | |
MAP_OLD_TYPE_TO_NEW_TYPE[16] = SMALL_22_NP;//TID_22DEGnpS = 16; | |
MAP_OLD_TYPE_TO_NEW_TYPE[17] = SMALL_22_PP;//TID_22DEGppS = 17; | |
MAP_OLD_TYPE_TO_NEW_TYPE[18] = LARGE_22_PN;//TID_22DEGpnB = 18; | |
MAP_OLD_TYPE_TO_NEW_TYPE[19] = LARGE_22_NN;//TID_22DEGnnB = 19; | |
MAP_OLD_TYPE_TO_NEW_TYPE[20] = LARGE_22_NP;//TID_22DEGnpB = 20; | |
MAP_OLD_TYPE_TO_NEW_TYPE[21] = LARGE_22_PP;//TID_22DEGppB = 21; | |
MAP_OLD_TYPE_TO_NEW_TYPE[22] = SMALL_67_PN;//TID_67DEGpnS = 22;//67.5 degree slope | |
MAP_OLD_TYPE_TO_NEW_TYPE[23] = SMALL_67_NN;//TID_67DEGnnS = 23; | |
MAP_OLD_TYPE_TO_NEW_TYPE[24] = SMALL_67_NP;//TID_67DEGnpS = 24; | |
MAP_OLD_TYPE_TO_NEW_TYPE[25] = SMALL_67_PP;//TID_67DEGppS = 25; | |
MAP_OLD_TYPE_TO_NEW_TYPE[26] = LARGE_67_PN;//TID_67DEGpnB = 26; | |
MAP_OLD_TYPE_TO_NEW_TYPE[27] = LARGE_67_NN;//TID_67DEGnnB = 27; | |
MAP_OLD_TYPE_TO_NEW_TYPE[28] = LARGE_67_NP;//TID_67DEGnpB = 28; | |
MAP_OLD_TYPE_TO_NEW_TYPE[29] = LARGE_67_PP;//TID_67DEGppB = 29; | |
MAP_OLD_TYPE_TO_NEW_TYPE[30] = HALF_BOTTOM;//TID_HALFd = 30;//half-full tiles | |
MAP_OLD_TYPE_TO_NEW_TYPE[31] = HALF_RIGHT;//TID_HALFr = 31; | |
MAP_OLD_TYPE_TO_NEW_TYPE[32] = HALF_TOP;//TID_HALFu = 32; | |
MAP_OLD_TYPE_TO_NEW_TYPE[33] = HALF_LEFT;//TID_HALFl = 33; | |
public static function GetTypeFromChar(char_val:int):int | |
{ | |
return MAP_OLD_TYPE_TO_NEW_TYPE[char_val]; | |
} | |
//used for debug visualization (tileIDs are 1-2 digits which makes them awkward to trace directly) | |
//each entry maps an old "TID" value to an enum value | |
private static var MAP_NEW_TYPE_TO_CHAR:Vector.<String> = new Vector.<String>(num_ingame_tile_types, true); | |
private static const hacky_debug_chars:String = ".0123456789ABCDEFGHIJKLMNPQRSTUVWX"; | |
public static function GetDebugCharFromID(tileID:int):String | |
{ | |
return hacky_debug_chars.charAt(tileID); | |
} | |
//editor transforms: we need to put these here to ensure that they're defined AFTER the tile types (really they belong in edat.as) | |
// | |
//NOTE: there's probably some clever formula/symmetries for most of these, but let's be stupid and just specify them literally/directly | |
//invert solid/empty shapes | |
public static var XFORM_INVERT:Vector.<int> = new Vector.<int>(num_ingame_tile_types, true); | |
XFORM_INVERT[EMPTY] = FULL; | |
XFORM_INVERT[FULL] = EMPTY; | |
XFORM_INVERT[HALF_TOP] = HALF_BOTTOM; | |
XFORM_INVERT[HALF_RIGHT] = HALF_LEFT; | |
XFORM_INVERT[HALF_BOTTOM] = HALF_TOP; | |
XFORM_INVERT[HALF_LEFT] = HALF_RIGHT; | |
XFORM_INVERT[MED_PP] = MED_NN; | |
XFORM_INVERT[MED_NP] = MED_PN; | |
XFORM_INVERT[MED_NN] = MED_PP; | |
XFORM_INVERT[MED_PN] = MED_NP; | |
XFORM_INVERT[CONVEX_PP] = CONCAVE_NN; | |
XFORM_INVERT[CONVEX_NP] = CONCAVE_PN; | |
XFORM_INVERT[CONVEX_NN] = CONCAVE_PP; | |
XFORM_INVERT[CONVEX_PN] = CONCAVE_NP; | |
XFORM_INVERT[CONCAVE_PP] = CONVEX_NN; | |
XFORM_INVERT[CONCAVE_NP] = CONVEX_PN; | |
XFORM_INVERT[CONCAVE_NN] = CONVEX_PP; | |
XFORM_INVERT[CONCAVE_PN] = CONVEX_NP; | |
XFORM_INVERT[SMALL_22_PP] = LARGE_22_NN; | |
XFORM_INVERT[SMALL_22_NP] = LARGE_22_PN; | |
XFORM_INVERT[SMALL_22_NN] = LARGE_22_PP; | |
XFORM_INVERT[SMALL_22_PN] = LARGE_22_NP; | |
XFORM_INVERT[LARGE_22_PP] = SMALL_22_NN; | |
XFORM_INVERT[LARGE_22_NP] = SMALL_22_PN; | |
XFORM_INVERT[LARGE_22_NN] = SMALL_22_PP; | |
XFORM_INVERT[LARGE_22_PN] = SMALL_22_NP; | |
XFORM_INVERT[SMALL_67_PP] = LARGE_67_NN; | |
XFORM_INVERT[SMALL_67_NP] = LARGE_67_PN; | |
XFORM_INVERT[SMALL_67_NN] = LARGE_67_PP; | |
XFORM_INVERT[SMALL_67_PN] = LARGE_67_NP; | |
XFORM_INVERT[LARGE_67_PP] = SMALL_67_NN; | |
XFORM_INVERT[LARGE_67_NP] = SMALL_67_PN; | |
XFORM_INVERT[LARGE_67_NN] = SMALL_67_PP; | |
XFORM_INVERT[LARGE_67_PN] = SMALL_67_NP; | |
//rotate 90deg clockwise | |
public static var XFORM_ROTCW:Vector.<int> = new Vector.<int>(num_ingame_tile_types, true); | |
XFORM_ROTCW[EMPTY] = EMPTY; | |
XFORM_ROTCW[FULL] = FULL; | |
XFORM_ROTCW[HALF_TOP] = HALF_RIGHT; | |
XFORM_ROTCW[HALF_RIGHT] = HALF_BOTTOM; | |
XFORM_ROTCW[HALF_BOTTOM] = HALF_LEFT; | |
XFORM_ROTCW[HALF_LEFT] = HALF_TOP; | |
XFORM_ROTCW[MED_PP] = MED_NP; | |
XFORM_ROTCW[MED_NP] = MED_NN; | |
XFORM_ROTCW[MED_NN] = MED_PN; | |
XFORM_ROTCW[MED_PN] = MED_PP; | |
XFORM_ROTCW[CONVEX_PP] = CONVEX_NP; | |
XFORM_ROTCW[CONVEX_NP] = CONVEX_NN; | |
XFORM_ROTCW[CONVEX_NN] = CONVEX_PN; | |
XFORM_ROTCW[CONVEX_PN] = CONVEX_PP; | |
XFORM_ROTCW[CONCAVE_PP] = CONCAVE_NP; | |
XFORM_ROTCW[CONCAVE_NP] = CONCAVE_NN; | |
XFORM_ROTCW[CONCAVE_NN] = CONCAVE_PN; | |
XFORM_ROTCW[CONCAVE_PN] = CONCAVE_PP; | |
XFORM_ROTCW[SMALL_22_PP] = SMALL_67_NP; | |
XFORM_ROTCW[SMALL_22_NP] = SMALL_67_NN; | |
XFORM_ROTCW[SMALL_22_NN] = SMALL_67_PN; | |
XFORM_ROTCW[SMALL_22_PN] = SMALL_67_PP; | |
XFORM_ROTCW[LARGE_22_PP] = LARGE_67_NP; | |
XFORM_ROTCW[LARGE_22_NP] = LARGE_67_NN; | |
XFORM_ROTCW[LARGE_22_NN] = LARGE_67_PN; | |
XFORM_ROTCW[LARGE_22_PN] = LARGE_67_PP; | |
XFORM_ROTCW[SMALL_67_PP] = SMALL_22_NP; | |
XFORM_ROTCW[SMALL_67_NP] = SMALL_22_NN; | |
XFORM_ROTCW[SMALL_67_NN] = SMALL_22_PN; | |
XFORM_ROTCW[SMALL_67_PN] = SMALL_22_PP; | |
XFORM_ROTCW[LARGE_67_PP] = LARGE_22_NP; | |
XFORM_ROTCW[LARGE_67_NP] = LARGE_22_NN; | |
XFORM_ROTCW[LARGE_67_NN] = LARGE_22_PN; | |
XFORM_ROTCW[LARGE_67_PN] = LARGE_22_PP; | |
//NOTE: we could also have done ROTCCW[i] = ROTCW[ROTCW[ROTCW[i]]], but what's the point? | |
public static var XFORM_ROTCCW:Vector.<int> = new Vector.<int>(num_ingame_tile_types, true); | |
XFORM_ROTCCW[EMPTY] = EMPTY; | |
XFORM_ROTCCW[FULL] = FULL; | |
XFORM_ROTCCW[HALF_TOP] = HALF_LEFT; | |
XFORM_ROTCCW[HALF_RIGHT] = HALF_TOP; | |
XFORM_ROTCCW[HALF_BOTTOM] = HALF_RIGHT; | |
XFORM_ROTCCW[HALF_LEFT] = HALF_BOTTOM; | |
XFORM_ROTCCW[MED_PP] = MED_PN; | |
XFORM_ROTCCW[MED_NP] = MED_PP; | |
XFORM_ROTCCW[MED_NN] = MED_NP; | |
XFORM_ROTCCW[MED_PN] = MED_NN; | |
XFORM_ROTCCW[CONVEX_PP] = CONVEX_PN; | |
XFORM_ROTCCW[CONVEX_NP] = CONVEX_PP; | |
XFORM_ROTCCW[CONVEX_NN] = CONVEX_NP; | |
XFORM_ROTCCW[CONVEX_PN] = CONVEX_NN; | |
XFORM_ROTCCW[CONCAVE_PP] = CONCAVE_PN; | |
XFORM_ROTCCW[CONCAVE_NP] = CONCAVE_PP; | |
XFORM_ROTCCW[CONCAVE_NN] = CONCAVE_NP; | |
XFORM_ROTCCW[CONCAVE_PN] = CONCAVE_NN; | |
XFORM_ROTCCW[SMALL_22_PP] = SMALL_67_PN; | |
XFORM_ROTCCW[SMALL_22_NP] = SMALL_67_PP; | |
XFORM_ROTCCW[SMALL_22_NN] = SMALL_67_NP; | |
XFORM_ROTCCW[SMALL_22_PN] = SMALL_67_NN; | |
XFORM_ROTCCW[LARGE_22_PP] = LARGE_67_PN; | |
XFORM_ROTCCW[LARGE_22_NP] = LARGE_67_PP; | |
XFORM_ROTCCW[LARGE_22_NN] = LARGE_67_NP; | |
XFORM_ROTCCW[LARGE_22_PN] = LARGE_67_NN; | |
XFORM_ROTCCW[SMALL_67_PP] = SMALL_22_PN; | |
XFORM_ROTCCW[SMALL_67_NP] = SMALL_22_PP; | |
XFORM_ROTCCW[SMALL_67_NN] = SMALL_22_NP; | |
XFORM_ROTCCW[SMALL_67_PN] = SMALL_22_NN; | |
XFORM_ROTCCW[LARGE_67_PP] = LARGE_22_PN; | |
XFORM_ROTCCW[LARGE_67_NP] = LARGE_22_PP; | |
XFORM_ROTCCW[LARGE_67_NN] = LARGE_22_NP; | |
XFORM_ROTCCW[LARGE_67_PN] = LARGE_22_NN; | |
public static var XFORM_FLIPH:Vector.<int> = new Vector.<int>(num_ingame_tile_types, true); | |
XFORM_FLIPH[EMPTY] = EMPTY; | |
XFORM_FLIPH[FULL] = FULL; | |
XFORM_FLIPH[HALF_TOP] = HALF_TOP; | |
XFORM_FLIPH[HALF_RIGHT] = HALF_LEFT; | |
XFORM_FLIPH[HALF_BOTTOM] = HALF_BOTTOM; | |
XFORM_FLIPH[HALF_LEFT] = HALF_RIGHT; | |
XFORM_FLIPH[MED_PP] = MED_NP; | |
XFORM_FLIPH[MED_NP] = MED_PP; | |
XFORM_FLIPH[MED_NN] = MED_PN; | |
XFORM_FLIPH[MED_PN] = MED_NN; | |
XFORM_FLIPH[CONVEX_PP] = CONVEX_NP; | |
XFORM_FLIPH[CONVEX_NP] = CONVEX_PP; | |
XFORM_FLIPH[CONVEX_NN] = CONVEX_PN; | |
XFORM_FLIPH[CONVEX_PN] = CONVEX_NN; | |
XFORM_FLIPH[CONCAVE_PP] = CONCAVE_NP; | |
XFORM_FLIPH[CONCAVE_NP] = CONCAVE_PP; | |
XFORM_FLIPH[CONCAVE_NN] = CONCAVE_PN; | |
XFORM_FLIPH[CONCAVE_PN] = CONCAVE_NN; | |
XFORM_FLIPH[SMALL_22_PP] = SMALL_22_NP; | |
XFORM_FLIPH[SMALL_22_NP] = SMALL_22_PP; | |
XFORM_FLIPH[SMALL_22_NN] = SMALL_22_PN; | |
XFORM_FLIPH[SMALL_22_PN] = SMALL_22_NN; | |
XFORM_FLIPH[LARGE_22_PP] = LARGE_22_NP; | |
XFORM_FLIPH[LARGE_22_NP] = LARGE_22_PP; | |
XFORM_FLIPH[LARGE_22_NN] = LARGE_22_PN; | |
XFORM_FLIPH[LARGE_22_PN] = LARGE_22_NN; | |
XFORM_FLIPH[SMALL_67_PP] = SMALL_67_NP; | |
XFORM_FLIPH[SMALL_67_NP] = SMALL_67_PP; | |
XFORM_FLIPH[SMALL_67_NN] = SMALL_67_PN; | |
XFORM_FLIPH[SMALL_67_PN] = SMALL_67_NN; | |
XFORM_FLIPH[LARGE_67_PP] = LARGE_67_NP; | |
XFORM_FLIPH[LARGE_67_NP] = LARGE_67_PP; | |
XFORM_FLIPH[LARGE_67_NN] = LARGE_67_PN; | |
XFORM_FLIPH[LARGE_67_PN] = LARGE_67_NN; | |
public static var XFORM_FLIPV:Vector.<int> = new Vector.<int>(num_ingame_tile_types, true); | |
XFORM_FLIPV[EMPTY] = EMPTY; | |
XFORM_FLIPV[FULL] = FULL; | |
XFORM_FLIPV[HALF_TOP] = HALF_BOTTOM; | |
XFORM_FLIPV[HALF_RIGHT] = HALF_RIGHT; | |
XFORM_FLIPV[HALF_BOTTOM] = HALF_TOP; | |
XFORM_FLIPV[HALF_LEFT] = HALF_LEFT; | |
XFORM_FLIPV[MED_PP] = MED_PN; | |
XFORM_FLIPV[MED_NP] = MED_NN; | |
XFORM_FLIPV[MED_NN] = MED_NP; | |
XFORM_FLIPV[MED_PN] = MED_PP; | |
XFORM_FLIPV[CONVEX_PP] = CONVEX_PN; | |
XFORM_FLIPV[CONVEX_NP] = CONVEX_NN; | |
XFORM_FLIPV[CONVEX_NN] = CONVEX_NP; | |
XFORM_FLIPV[CONVEX_PN] = CONVEX_PP; | |
XFORM_FLIPV[CONCAVE_PP] = CONCAVE_PN; | |
XFORM_FLIPV[CONCAVE_NP] = CONCAVE_NN; | |
XFORM_FLIPV[CONCAVE_NN] = CONCAVE_NP; | |
XFORM_FLIPV[CONCAVE_PN] = CONCAVE_PP; | |
XFORM_FLIPV[SMALL_22_PP] = SMALL_22_PN; | |
XFORM_FLIPV[SMALL_22_NP] = SMALL_22_NN; | |
XFORM_FLIPV[SMALL_22_NN] = SMALL_22_NP; | |
XFORM_FLIPV[SMALL_22_PN] = SMALL_22_PP; | |
XFORM_FLIPV[LARGE_22_PP] = LARGE_22_PN; | |
XFORM_FLIPV[LARGE_22_NP] = LARGE_22_NN; | |
XFORM_FLIPV[LARGE_22_NN] = LARGE_22_NP; | |
XFORM_FLIPV[LARGE_22_PN] = LARGE_22_PP; | |
XFORM_FLIPV[SMALL_67_PP] = SMALL_67_PN; | |
XFORM_FLIPV[SMALL_67_NP] = SMALL_67_NN; | |
XFORM_FLIPV[SMALL_67_NN] = SMALL_67_NP; | |
XFORM_FLIPV[SMALL_67_PN] = SMALL_67_PP; | |
XFORM_FLIPV[LARGE_67_PP] = LARGE_67_PN; | |
XFORM_FLIPV[LARGE_67_NP] = LARGE_67_NN; | |
XFORM_FLIPV[LARGE_67_NN] = LARGE_67_NP; | |
XFORM_FLIPV[LARGE_67_PN] = LARGE_67_PP; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment