Omnimaga

Calculator Community => TI Calculators => Axe => Topic started by: collechess on November 02, 2011, 07:26:01 pm

Title: Tilemap Collisions
Post by: collechess on November 02, 2011, 07:26:01 pm
How do you create exact tilemap collisions in Axe?  My routine to access the value of a tile divides x and y by 4, which is the size of each tile, but means that there is only a collision if it overlaps on the right or is exactly aligned.  It does not register collisions on the left.  How can I register a collision on any overlap?
Title: Re: Tilemap Collisions
Post by: C0deH4cker on November 02, 2011, 10:29:53 pm
Dont test for pixels. If youre moving to the right, check if there's a solid tile that is one tile to the right. if not, then keep moving.
Title: Re: Tilemap Collisions
Post by: Keoni29 on November 04, 2011, 04:03:33 am
This:
but collision s the most complicated!, Damn!
Tile based works perfectly. I use this:
Code: [Select]
:If getKey(2) and (X≠0)
:sub(CC,X,Y,X,Y+7
:!If R
:X-1→X
:End
:End
Just to check for a tile on the left. Now you figure out how to check for tiles in the other 3 directions :)
Code: [Select]
:Lbl CC
:{r2/8*12+(r1/8)+GDB1}→r5
:{r4/8*12+(r3/8)+GDB1}→r6
:r5+r6→R
:Return
Title: Re: Tilemap Collisions
Post by: LincolnB on November 04, 2011, 10:22:19 am
Changed for prettification and I think also speed gain:

Code: [Select]
:If getKey(2)
:If X
:!If CC(X,Y,X,Y+7)
:X--
:End
:End
:End
:
:
:Lbl CC
:{r2/8*12+(r1/8)+GDB1}→r5
:{r4/8*12+(r3/8)+GDB1}→r6
:r5+r6→R
:Return

I just love function based programming so much :)
Title: Re: Tilemap Collisions
Post by: Keoni29 on November 04, 2011, 12:32:08 pm
Changed for prettification and I think also speed gain:

Code: [Select]
:If getKey(2)
:If X
:!If CC(X,Y,X,Y+7)
:X--
:End
:End
:End
:
:
:Lbl CC
:{r2/8*12+(r1/8)+GDB1}→r5
:{r4/8*12+(r3/8)+GDB1}→r6
:r5+r6→R
:Return

I just love function based programming so much :)
And so do I :D
Title: Re: Tilemap Collisions
Post by: aeTIos on November 04, 2011, 12:42:01 pm
uhh, a full commitment what I'm thinking of ?
lol.
Title: Re: Tilemap Collisions
Post by: flyingfisch on November 04, 2011, 12:43:32 pm
could someone please show me how to do this in lua?
Title: Re: Tilemap Collisions
Post by: LincolnB on November 04, 2011, 10:13:47 pm
Flyingfisch, I would ask that question in a new thread in a different forum.
Title: Re: Tilemap Collisions
Post by: Keoni29 on November 05, 2011, 03:17:13 pm
could someone please show me how to do this in lua?
Same principle, but a different syntax :)
Title: Re: Tilemap Collisions
Post by: collechess on November 06, 2011, 05:42:17 pm
If I have 4x4 tiles, I should change the /8 to /4 right?  What does the x12 do?
Title: Re: Tilemap Collisions
Post by: Darl181 on November 06, 2011, 05:50:37 pm
I'm guessing the *12 was because in an 8*8-tile map, it's 12 tiles wide.  For a 4*4-tile map it's 24 tiles wide.