Zaknafein
Mar 4th, 2002, 01:56 AM
This might be a little different way of doing collision detection but hopefully someone can help me. I'm woking on a game that has elements like the old Sierra Adventure games where you can walk around objects on the screen by clicking where you want to go. Below is how I define obsticals (rectangles in pixels). It works great, but how would I modify it to determine if you've steped onto a obstical that is in the shape of a circle instead?
Public Sub stopIfObstical()
'note 90 is how many pixels tall the sprite is, needed since Sprite2Y is the top pixel adding 90 makes it the feet instead or bottom pixel of the sprite.
'-----------Fountain----------------
If Sprite2X > 420 And Sprite2X < 737 And (Sprite2Y + 90) >470 And (Sprite2Y + 90) < 590 Then
'Stop moving onto the obstical and go back where you just were
Sprite2X = lastX
Sprite2Y = lastY
stopMove = True
End If
'------------------------------
'---Remember the last legal move-----
lastX = Sprite2X
lastY = Sprite2Y
'------------------------------------
End Sub
Public Sub stopIfObstical()
'note 90 is how many pixels tall the sprite is, needed since Sprite2Y is the top pixel adding 90 makes it the feet instead or bottom pixel of the sprite.
'-----------Fountain----------------
If Sprite2X > 420 And Sprite2X < 737 And (Sprite2Y + 90) >470 And (Sprite2Y + 90) < 590 Then
'Stop moving onto the obstical and go back where you just were
Sprite2X = lastX
Sprite2Y = lastY
stopMove = True
End If
'------------------------------
'---Remember the last legal move-----
lastX = Sprite2X
lastY = Sprite2Y
'------------------------------------
End Sub