Jump to content

Implementation of levels and collision in a Frogger implementation


mxschumacher
 Share

Recommended Posts

Hi there,

being new to JS and game development I have two questions (I'll create a post for each) regarding a implementation of Frogger I'm working on. Part of the images are taken from Udacity's OOP JS course, though I'm not enrolled in the program anymore (so you're not helping me cheat).

1. In order to provide accurate scaling I use a scaling factor that I multiply image sizes with, e.g.

 

var gameWidth = Math.max(document.documentElement.clientWidth, window.innerWidth || 0) / 2.5;var gameHeight = gameWidth * 1.25;var scalingFactor = gameWidth / 800; //build for 800px width, actual screen-size via scalingvar rockBarrier = world.create(game.world.randomX, positionY, 'blockRock');rockBarrier.scale.set(scalingFactor);

Yet collision does not scale in the same way, e.g. my player is ~80 px away from the rock and hits an invisible wall, same goes for collecting bonues (gems in my case) the collision function is triggered before my character actually touches the gem.

The whole code-base can be found here: 

https://github.com/MaxSchumacher/Frosch

Any advice on how to fix this would be highly appreciated.

Greetings,
Max

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...