Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8405713
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T22:54:27+00:00 2026-06-09T22:54:27+00:00

I have a Player Entity that is governed by gravity and I have another

  • 0

I have a Player Entity that is governed by gravity and I have another entity at the bottom of the screen that moves around.

When my falling player entity hits the entity at the bottom I want it to bounce off of it.

Ideally I’d like to use the .bounciness property of the player entity.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T22:54:28+00:00Added an answer on June 9, 2026 at 10:54 pm

    You want your bottom entity to contain the following properties:

    checkAgainst: ig.Entity.TYPE.A, // player entity type
    collides: ig.Entity.COLLIDES.ACTIVE
    

    Then you want your check() method of your bottomEntity to reverse the velocity of the player entity when it collides with it.

    check: function(other) {
      other.vel.y -= 100; // you could also use other.accel.y
    }
    

    Also if you want you can handle deflection angles with collisions as well (similar to the Arkanoid games):

    If the player hits in the center, you want it to go straight up. If it hits on the right half, you want it to go right; if it hits on the left, you want it to go left.

    So find where the player hits the bottom entity, and find its angle relative to the end of the entity.

    var playerPos = player.pos.x - bottomEntity.pos.x;
    var relativePos = ( bottomEntity.size.x - playerPos);
    var angle = relativePos * ( Math.PI / bottomEntity.size.x ); // translate to radians - this finds the number of radians per bottom entity pixel
    

    Once you got the angle, take the cos of it to grab the direction. Multiply the direction times the bottom entities velocity, and you’ve got the bottom entities new velocity.

    var newVel = Math.cos( angle ) * bottomEntity.vel.x;
    

    Then your check() method would look like this:

    check: function(other) {
      var playerPos = other.pos.x - bottomEntity.pos.x;
      var relativePos = ( bottomEntity.size.x - playerPos);
      var angle = relativePos * ( Math.PI / bottomEntity.size.x ); // translate to radians - this finds the number of radians per bottom entity pixel
      other.vel.y -= newVel;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a entity Player that has one to many association to other entities.
I'm having an issue where I have a player object that I'm trying to
I have a music player that links to a song using the following syntax:
I have a flash player that loads in some additional features from flash files
I have a simple JPA entity that uses a generated long ID as its
I have two tables that have a many-many relationship: Player(personID, school) Team(teamID, name) What
I have an Entity baseclass which the classes Player and Enemy Inherit. class Entity
I have an Entity baseclass which the classes Player and Enemy Inherit. Both player
I have a SWF Video player on my webpage. I want to draw a
In Spring MVC 3, I have a customer Formatter that converts my entity objects

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.