PDA

Click to See Complete Forum and Search --> : Help me with Rpg!!!!!


tonyp
Jul 6th, 2000, 10:15 AM
im making a rpg or trying to make but i don't know
how to stop the character to stop moving when hes walking on a tree.

the background is image1 jpg and the character is image2 and the tree is image3.

the code is:

Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = vbKeyUp Then Image2.Top = Image2.Top - 200
If KeyCode = vbKeyDown Then Image2.Top = Image2.Top + 200
If KeyCode = vbKeyLeft Then Image2.Move Image2.Left - 200
If KeyCode = vbKeyRight Then Image2.Move Image2.Left + 200


End Sub

Jul 6th, 2000, 10:29 AM
First, you should have a numeric version of your Map stored in a 2-D Array. Then, before you move your character, check what is above him. If it's a Tree then don't move him.

SteveCRM
Jul 6th, 2000, 08:22 PM
But how would you know what side he is being hit by? You have to be able to make one of the directions not work. How do we know which one?

Fox
Jul 7th, 2000, 03:02 AM
Just check all directions.. you can make something like this to define collidable sides:


tTile
CollideLeft as Boolean
CollideTop as Boolean
...
End Type

Map(W,H) as tTile

MoveChar()
If Map(Player.x / TileWidth, Player.y / TileHeight).CollideLeft = True Then
'Collide left
EndIf

If Map(Player.x / TileWidth, Player.y / TileHeight).CollideTop = True Then
'Collide top
EndIf

...
End Sub


See the idea?

~@lienKiller~
Jul 7th, 2000, 04:19 PM
This post is for Fox
Im usin 1 of you characters that i got from your project on animation and im wonder the same question but how do i put that into the code i got already.....you should kno the code it came from your web page.