 |
 |

10-28-2003, 05:24 AM
|
 |
Junior Contributor
|
|
Join Date: Sep 2003
Location: Belgium
Posts: 316
|
|
rpg collision help
|
maybe i'll start making a simple rpg, but i have i question:
i think i can handle the tiles/movement/scrolling...
but i have one big question: how do you know when you hit an object like a tree for example.... this would be easy if the character would move tile-per-tile, but it won't. or for example: if i have tile of a cliff, and half is grass, the other water. how can i make the character go only on the gras part of the tile, and not the water part?
if any sugestions: please post them
Reinout,
|
|

10-28-2003, 06:50 AM
|
 |
MetaCenturion
Retired Moderator * Guru *
|
|
Join Date: Aug 2001
Location: California, USA
Posts: 16,583
|
|
Why are you using fractions of the tile? This makes things more complicated. You are going to need to look at your tile info, and look at where your player is going to move to.
If the tile he is moving to is water, then stop him from moving.
Since half of the tile is grass, then I don't know exactly what's going to happen. Maybe you have a specific tile format for seeing if the tile is grass on left, water on right, and just only move him halfway. 
|
|

10-28-2003, 10:13 AM
|
 |
Jedi Coder
* Expert *
|
|
Join Date: Aug 2002
Location: Abingdon, MD
Posts: 3,438
|
|
|
Border tiles like this you could make so that the water part is not half of the tile. Since character usually are positioned in the center of a tile, when you move the character to the border tile it won't appear that he's standing in water.
|
|

10-28-2003, 10:55 AM
|
 |
Contributor
|
|
Join Date: Sep 2003
Location: Finland
Posts: 690
|
|
|
Hi!
You surely could calculate the distance between the player and the tree and when they distance is smaller than, lets say the amount of the players pictureheight the program will react to this event... I presume that the distance is calculated from the center of both pictures..
|
__________________
I love deadlines. I like the whooshing sound they make as they fly by. - Douglas Adams
|

10-28-2003, 11:10 AM
|
 |
Ultimate Contributor
* Expert *
|
|
Join Date: Jun 2003
Location: New York, NY
Posts: 1,929
|
|
Quote: Originally Posted by peanutman maybe i'll start making a simple rpg, but i have i question:
i think i can handle the tiles/movement/scrolling...
but i have one big question: how do you know when you hit an object like a tree for example.... this would be easy if the character would move tile-per-tile, but it won't. or for example: if i have tile of a cliff, and half is grass, the other water. how can i make the character go only on the gras part of the tile, and not the water part?
if any sugestions: please post them
Reinout,
One way:
Make a mask for all your tiles. For each tile, make another image the same dimensions, then put (for example) white where the player can move and black where they cannot. Then while moving players icons around on the graphical tiles, you check this mask tile to see where they can and cannot move to.
You even could expand this system later - use shades of gray for slower movement (on sand or swap or thick woods, etc), then have different colors for different movement rules (like have areas that are too thick for horses but OK for being on foot, etc)
|
__________________
"Fortunately, I live in the United States of America, where we are gradually coming to understand that nothing we do is ever our fault, especially if it is really stupid." - Dave Barry
|

11-01-2003, 02:11 PM
|
|
Newcomer
|
|
Join Date: Oct 2003
Location: Tunkhannock PA
Posts: 21
|
|
|
Are there any ways to give the pic a value then say have the players mask (the character) reconize the pic value?
example: you move from a grass to a water tile, all tiles you can go through would be a value of 0, all ones you can't go though have a value of 1. When you move onto the water tile the playermask(or something else) would see what the vale of the tile you are on is and if its a 1 it would send you back to the last tile. Another idea would be it would check the next tile and if its a 1 then just move you 0 (no blocks).
Does anyone know the theory or code behind this or how to set the image as a value?
|
|

11-05-2003, 12:43 PM
|
 |
Ultimate Contributor
* Expert *
|
|
Join Date: Jun 2003
Location: New York, NY
Posts: 1,929
|
|
Quote: Originally Posted by KevinVogrin Are there any ways to give the pic a value then say have the players mask (the character) reconize the pic value?
example: you move from a grass to a water tile, all tiles you can go through would be a value of 0, all ones you can't go though have a value of 1. When you move onto the water tile the playermask(or something else) would see what the vale of the tile you are on is and if its a 1 it would send you back to the last tile. Another idea would be it would check the next tile and if its a 1 then just move you 0 (no blocks).
Does anyone know the theory or code behind this or how to set the image as a value?
there are plenty of tutorials on this site for tile-based games - have a search.
but here's a quick run-down of how I'd do it:
Code:
Dim TilePic() as picture
Type TileDef
PicRef as Long
Blocking as boolean
End Type
Dim TileDefinition() as TileDef
Dim Map() as long
Sub Form_Load()
'redim TilePic array, load pictures into all valid elements
'redim TileDefinition array, and loop through:
.PicRef = 'index number of the picture you want in the TilePic array
.Blocking = 'true or false - if objects can pass through this tile
'redim map array, 2d, and loop through:
Map(x,y) = 'index number of TileDefinition for this tile on the map
End Sub
|
__________________
"Fortunately, I live in the United States of America, where we are gradually coming to understand that nothing we do is ever our fault, especially if it is really stupid." - Dave Barry
|
|
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
|
|
|
| Thread Tools |
|
|
| Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
|
|
|
|
 |
|