Jump to content

Implementation of levels and collision in a Frogger implementation


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: 


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


Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Recently Browsing   0 members

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