Page 1 of 1

Check if a tile is in front of you before moving

PostPosted: Tue May 21, 2013 2:23 am
by Hblade
I have a bootleg way for this rambled up in my head, untested though. But what would be a nice efficient way to tell if there's a tile ahead of you before moving?

Re: Check if a tile is in front of you before moving

PostPosted: Tue May 21, 2013 3:43 am
by skydereign
If you don't have some data structure like an array holding the tiles, you'd need to use either getactor, CollisionFree, or a colliding actor. If you do have a data structure, you just need to check the position to the left to see if it is empty or not.

Re: Check if a tile is in front of you before moving

PostPosted: Tue May 21, 2013 3:54 am
by Hblade
If it's not too much trouble, would you mind explaining (or linking to a site that can explain it) a data structure? :)

Re: Check if a tile is in front of you before moving

PostPosted: Tue May 21, 2013 4:14 am
by skydereign
First google search for data structure gives the wiki page. http://en.wikipedia.org/wiki/Data_structure
All you really need is the first sentence from that link. A shorter way of saying the same thing, it is a structure that holds data. Therefore an array is a data structure.

Re: Check if a tile is in front of you before moving

PostPosted: Tue May 21, 2013 5:23 am
by Hblade
Thanks