|
-
Jul 6th, 2000, 10:15 AM
#1
Thread Starter
Junior Member
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
#2
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.
-
Jul 6th, 2000, 08:22 PM
#3
Frenzied Member
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?
-
Jul 7th, 2000, 03:02 AM
#4
PowerPoster
Just check all directions.. you can make something like this to define collidable sides:
Code:
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?
-
Jul 7th, 2000, 04:19 PM
#5
New Member
Ok.......
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.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|