Jump to content
Retro Lord

Small problem with collision detection

Recommended Posts

I'm having a small issue with my collision detection between the ball and player1.

Player 1 moves from right to left and the player shoots a ball that travels to the right. Most of the times the ball makes contact with player1, player1 dissapears as it should be. But sometimes no collision is detected. Would this be corrected if I made the ball a bit bigger then the standard smallest size?

 

I'm using a simple code for handling the collision:

if collision(ball,player1) then player1y=rand:player1x=135

 

Thanks in advance.

 

 

Share this post


Link to post
Share on other sites

The "player1y=rand" could be the part that is messing things up. Using rand means that sometimes player1 would be in the same y location after a collision.

 

If this is about the game you posted, are you hearing the beep sound every time there is a collision or does the beep not happen sometimes?

Share this post


Link to post
Share on other sites

Thanks for the help once again Random Terrain. The beep plays everytime there is a collision. And as you said, it was the "player1y=rand" that was causing the problems. I managed too fix it =)

Share this post


Link to post
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.

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

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...