Giter VIP home page Giter VIP logo

icecreamyou / html5-canvas-game-boilerplate Goto Github PK

View Code? Open in Web Editor NEW
240.0 12.0 56.0 5.54 MB

Provides a set of default code that makes getting up and running with an HTML5 canvas game very easy.

Home Page: http://icecreamyou.github.com/HTML5-Canvas-Game-Boilerplate/docs/

License: Other

JavaScript 97.02% CSS 1.71% HTML 1.28%
canvas html5-canvas-game html5-boilerplate javascript boilerplate-html game-engine game-development game-2d game-framework boilerplate

html5-canvas-game-boilerplate's People

Contributors

dependabot[bot] avatar icecreamyou avatar orthographic-pedant avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

html5-canvas-game-boilerplate's Issues

TypeError: collideWith.getAll is not a function

Within the Actor.collideSolid() function there is a section of code:

...
else if ((typeof Collection !== 'undefined' && collideWith instanceof Collection) ||
    (typeof TileMap !== 'undefined' && collideWith instanceof TileMap)) {
  var items = collideWith.getAll();
...

This results in an error when collideWith is a Collection, because getAll() is not defined in Collection (only in TileMap)

A similar problem occurs in Actor.standingOn()

My solution was not to add an additional clause to these if statements, but to standardise by adding to the Collection.prototype:

getAll: function() {
  return this;
},

By-reference arguments when creating new TileMap objects

When creating multiple new TileMap objects, there is a problem with re-using the same array as an input argument:

var gridAsString = 'B\nP';
var gridAsArray = [['B'], ['P']];

// Using a string works correctly:
var blocks = new TileMap(gridAsString, { B: Block });
var pots   = new TileMap(gridAsString, { P: Pot });

// But using an array is broken:
var blocks = new TileMap(gridAsArray, { B: Block });
var pots   = new TileMap(gridAsArray, { P: Pot });

I believe this is because of the code overwriting the grid argument by reference. By the time the pots collection is being created, gridAsArray is already partly filled with Block objects.

To fix this, I just added one line immediately below the function start:

...
function TileMap(grid, map, options) {
  var grid = JSON.parse(JSON.stringify(grid));

  // Setup and options
...

I think this is all the cloning that is necessary. I'm not a Javascript native, so there may be something I've overlooked.

Thanks.

Console errors on Mario example, game won't start

I have these errors in the console:
Uncaught TypeError: Cannot read property 'startCoords' of undefined combined.min.js:8
Uncaught TypeError: Cannot call method 'draw' of undefined

Running on a wamp environment, chrome.

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.