Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

mkoday

walkability

This topic is 6685 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Advertisement
You can represent walkability with a boolean variable.Just declare a boolean variable(e.g. WalkOn) and two constants,e.g. WALKON_NO = 0 and WALKON_YES = 1.
Your tiles should have this variable as a property.If the tile is walkable then its WalkOn variable''s value is 1 or else if not walkable the value is 0.
So during the game the only thing you have to do to see a tile''s walkability is to check its WalkOn value.

Share this post


Link to post
Share on other sites
enums are nice too, if you are using C++, since you could define a whole set of movement values and alterations. For instance perhaps you could swim in shallow water but not deep or swamp tiles slow you by 50% but you can still walk through it. A little more detail than the standard walk-can''t walk boolean.

Sieggy

Share this post


Link to post
Share on other sites
Right.There aren''t only walkable and non walkable tiles.Sieggy gave you some nice examples of tiles that are partially walkable.You may have a variable that takes values between 0 and 4 each one with a different walking attitude.I think this is a more common way to define walkability in games.

Share this post


Link to post
Share on other sites
The answer you seek is very dependant on the type of game you are making.

if, for example, you are making a strategy game, then the movement cost for terrain is most likely the appropriate way to go about it.

however, if you are making an arcade game, then you may just be able to get away with "walk" "no walk", or you might have "walk", "no walk", "pass only if wearing the magic boots of Ra" "pass but take fire damage" and so on.

Share this post


Link to post
Share on other sites
You could have a function that attempts to move a creature in a certain direction (and returns a boolean indicating success). Given the direction, find out which tile the destination is. From that tile, you should be able to get information on whether you can move there. If you can, move there, and return true. If you can''t, return false.

Share this post


Link to post
Share on other sites
Hi

How do you handle the actaul transition from one tile to another?

You could just make the player character ''jump'' to the new tile instantiously but that would look very odd. I would much prefer having the character walk from tile to tile with some animation. But then you need your character to be able to move within a tile, don''t you?

Also at some point the charecter would be both a bit inside the old tile and the new tile. When do you update the data structures of the map and the character with the new tile coordinates? When the character starts moving, when it ends moving? Or somewher in between?

Regards

nicba

Share this post


Link to post
Share on other sites
quote:
Original post by nicba
But then you need your character to be able to move within a tile, don't you?

Also at some point the character would be both a bit inside the old tile and the new tile. When do you update the data structures of the map and the character with the new tile coordinates?



It depends on how you want to handle it. Many games allow for sprites to move somewhat independently of the tiles (their movement is restricted by it, but they can move within a single tile this is handled by using offsets). Examples of that would be most RTS games, Diablo , and the like.

There's still just as many games that fix the sprites to the tiles (sort of making them tiles themselves). Some examples: isometric chess/checkers games, XCOM, and some other turn-based strategy games. In this case, you'd probably want to do the movement animation, and then update the position at the end. It all depends on how you handle the animation's offsets though. Happy coding




while( strcmp(reply,flame) )
followThread();


random-nomad

Edited by - random-nomad on 4/23/00 7:46:32 AM

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!