Java Script Objects
JavaScript objects are created to represent different elements in the game, such as platforms or characters. Each object was assigned properties to describe its characteristics or behavior within the game environment.
Creating a Property
Properties are the values associated with a JavaScript objects, so we created one to solve the issue we had. We created a property called onTopofPlatform, so we could correctly assign if it can go left and right.
Application
const tolerance = 10; // Adjust as needed
// Determine if this object's bottom exactly aligns with the other object's top
const onTopofPlatform = Math.abs(thisBottom - otherRect.top) <= tolerance;