Thunderfist

Collision not working

Recommended Posts

So, I've managed to make my character sprite move, but the collision doesn't work and the sprite can move out of bound even though I've defined the outOfBounds function.

Is there anything I can do about this?

And so you know, when this:

if (!obstacleCollision) {
    this.drawX = newDrawX;
    this.drawY = newDrawY;
}

is changed to this:

if (!obstacleCollision && !outOfBounds (this, newDrawX, newDrawY) {
    this.drawX = newDrawX;
    this.drawY = newDrawY;
} 

The sprite is locked in place! I had to remove that part in order for the code to work.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.