GithubHelp home page GithubHelp logo

javascript-maze's Introduction

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.

javascript-maze's People

Contributors

thorlando avatar

Watchers

 avatar James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.