Skip to content

thorlando/javascript-maze

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

javascript-maze

Tiling engine maze demo I put together as a tinkering experiment. Images are © Nintendo, and I only used them because I love Zelda. Please don't sue.

A map is generated by a 2-dimensional array outlining what tiles belong where. Tiles are 16x16 pixels, and they're positioned absolutely against the scene.

Position is kept in array indices as follows:

Array [
           [1,1,1,1,1,1,1]  0  First (Y)
           [1,0,0,0,0,0,1]  1
           [1,0,0,0,0,0,1]  2
           [1,0,0,0,P,0,1]  3
           [1,0,0,0,0,0,1]  4
           [1,1,1,1,1,1,1]  5
		 	
Second (X)  0 1 2 3 4 5 6
		 	 
		 ];
		 
		 P = Array[3][4]

Player movement occurs along the cartesian grid. So if the player is in position Array[3][4] and moves down one step, he'll end up in Array[4][4]. If he moved up, [2][4]. You get the idea. Note that grid positioning is done as [Y][X] rather than [X][Y].


Options

The board object has a number of options, namely:

  • world allows you to set the map set you'd like to use. It accepts a 2-dimensional array of map objects.
  • map sets the initial map (needs to be from the world you set) to start from. It accepts a map object.
  • mapx and mapy set the starting coordinates on the map grid. It accepts integers.
  • clone lets you enable clones of the main player which move along with the player. When set to true, it'll show you 3 already-existing clones, or you can instantiate new Player objects with the "clone" name/identifier.
  • hidden hides all tiles outside of the player's visibility. The player's visibility is set in the Player class as an integer describing the number of tiles the player can see around them, and it defaults to 3.

Copyright

None. Go nuts.

About

Tiling engine maze demo I put together as a tinkering experiment

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published