Jump to content

Collision not working


Thunderfist
 Share

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.

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.

Guest
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.

Loading...
 Share

  • Recently Browsing   0 members

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