Giter Club home page Giter Club logo

Comments (6)

jbockmon avatar jbockmon commented on August 27, 2024

Update: The disappearing issue appears to be a related to collisions with multiple rectangles at the same time.

For testing, I made only a single block collideable, and the r1 sprite no longer disappears.

However, even with a single tile only colliding, the r1 sprite is moved left until they are dumped off the tile.

from bump.

JamesCraster avatar JamesCraster commented on August 27, 2024

I'm new to Hexi, so this may be a dumb question - but why are you calling hitTestRectangle first? Surely this will only prevent things overlapping if they are already colliding. What if the player is not colliding with the tiles already, and moves fast enough to pass through?

from bump.

kittykatattack avatar kittykatattack commented on August 27, 2024

@jbockmon Have to seen the platformer example here?

https://github.com/kittykatattack/hexi/blob/master/examples/src/platforms.js

from bump.

kittykatattack avatar kittykatattack commented on August 27, 2024

@JamesCraster: you're correct, in this case there's no need to call hitTestRectangle - a simple rectangleCollision will do.

from bump.

jbockmon avatar jbockmon commented on August 27, 2024

@JamesCraster the algorithms for detecting collisions in hitTestRectangle and rectangleCollision are different. Furthermore. hitTestRectangle does not alter sprite vx or vy directly, nor does it alter its x or y coords. rectangleCollision, on the other hand, checks for collisions as well as handles sprite movement/correction to prevent collision.

When I relied on rectangleCollision alone, the algorithm it employs returns left/right collisions as well as bottom/top collisions when the lhs sprite spans two or more blocks/sprites. Because rectangleCollision directly modifies the vx and vy values, these left/right collisions would stop my lhs sprite from being able to move. I use hitTestRectangle to filter the unncessary left/right collisions out to prevent it from setting lhs.vx to 0.

from bump.

jbockmon avatar jbockmon commented on August 27, 2024

@kittykatattack I have not. I will have to check it out. Thanks!

from bump.

Related Issues (15)

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.