Go Back  Xtreme Visual Basic Talk > Legacy Visual Basic (VB 4/5/6) > Game Programming > rpg collision help


Reply
 
Thread Tools Display Modes
  #1  
Old 10-28-2003, 05:24 AM
peanutman's Avatar
peanutman peanutman is offline
Junior Contributor
 
Join Date: Sep 2003
Location: Belgium
Posts: 316
Question 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,
__________________
http://free-b.org
Reply With Quote
  #2  
Old 10-28-2003, 06:50 AM
Iceplug's Avatar
Iceplug Iceplug is offline
MetaCenturion

Retired Moderator
* Guru *
 
Join Date: Aug 2001
Location: California, USA
Posts: 16,583
Default

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

Iceplug, USN
Quadrill 1 Quadrill 2 (full) Quadrill 3 JumpCross .NET Website is ALIVE! - DL Platform Tour for VB.NET! Posting Guidelines Hint: Specify your location in your user cp profile if you want compassion!
Reply With Quote
  #3  
Old 10-28-2003, 10:13 AM
Machaira's Avatar
Machaira Machaira is offline
Jedi Coder

* Expert *
 
Join Date: Aug 2002
Location: Abingdon, MD
Posts: 3,438
Default

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.
Reply With Quote
  #4  
Old 10-28-2003, 10:55 AM
Faith's Avatar
Faith Faith is offline
Contributor
 
Join Date: Sep 2003
Location: Finland
Posts: 690
Cool

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
Reply With Quote
  #5  
Old 10-28-2003, 11:10 AM
blindwig's Avatar
blindwig blindwig is offline
Ultimate Contributor

* Expert *
 
Join Date: Jun 2003
Location: New York, NY
Posts: 1,929
Default

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
Reply With Quote
  #6  
Old 11-01-2003, 02:11 PM
KevinVogrin KevinVogrin is offline
Newcomer
 
Join Date: Oct 2003
Location: Tunkhannock PA
Posts: 21
Default

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?
Reply With Quote
  #7  
Old 11-05-2003, 12:43 PM
blindwig's Avatar
blindwig blindwig is offline
Ultimate Contributor

* Expert *
 
Join Date: Jun 2003
Location: New York, NY
Posts: 1,929
Default

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
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
This Really is a hard question.. (collision) Faith DirectX 4 04-19-2004 07:29 AM
pics collision yhaim Game Programming 6 07-24-2003 07:05 AM
Problem with Pixel perfect collision... I really need help Kamochan DirectX 4 07-22-2003 07:40 AM
I need some expert help. Twan Game Programming 3 03-01-2003 08:02 PM
Possible solution to collision detection. . . MFCTC Game Programming 3 05-13-2002 08:47 AM

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
 
 
-->