Omnimaga

Calculator Community => TI Calculators => Axe => Topic started by: Keoni29 on June 02, 2011, 01:46:38 pm

Title: Check if there is a solid tile
Post by: Keoni29 on June 02, 2011, 01:46:38 pm
I want to check if there is a solid tile. I'm using this code for tilemapping.
Code: [Select]
:[000000000000]→GDB1
:[000000000000]
:[000000000000]
:[000001200000]
:[000003400000]
:[000000000000]
:[000000000000]
:[000000000000]
Code: [Select]
:For(V,0,7)
:For(H,0,5)
:{V*6+H+GDB1}→A
:Pt-On(H*16,V*8,A/16*8+Pic1)
:Pt-On(H*16+8,V*8,A^16*8+Pic1)
:End
:End
:DispGraph
I ripped it from a french tutorial. I don't know if they mentioned this subject.
Title: Re: Check if there is a solid tile
Post by: Keoni29 on June 03, 2011, 04:55:22 am
I figured this out:
{Y*6+X*GBD1}/16
{Y*6+X*GBD1}^16
These two give you the id of 2 tiles
When the x is even I have to check if{Y*6+X*GBD1}/16
When the x is not even I have to check if{Y*6+X*GBD1}^16

How do I check whether X/4 is an even number?
Code: [Select]
if X/4=????even???
{Y/8+1*6+(X/8)+GBD1}^16->BL
{Y/8+1*6+(X+7/8)+GBD1}/16->BR
{Y-1/8*6+(X/8)+GBD1}^16->TL
{Y-1/8*6+(X+7/8)+GBD1}/16->TR
{Y/8*6+(X-1/8)+GBD1}^16->LT
{Y/8*6+(X/8)+1+GBD1}^16->RT
{Y+7/8*6+(X-1/8)+GBD1}^16->LB
{Y+7/8*6+(X/8)+1+GBD1}^16->RB
Else
{Y/8+1*6+(X/8)+GBD1}/16->BL
{Y/8+1*6+(X+7/8)+GBD1}^16->BR
{Y-1/8*6+(X/8)+GBD1}/16->TL
{Y-1/8*6+(X+7/8)+GBD1}^16->TR
{Y/8*6+(X-1/8)+GBD1}/16->LT
{Y/8*6+(X/8)+1+GBD1}/16->RT
{Y+7/8*6+(X-1/8)+GBD1}/16->LB
{Y+7/8*6+(X/8)+1+GBD1}/16->RB
End

Is there an optimized way of doing this?
Title: Re: Check if there is a solid tile
Post by: Aichi on June 03, 2011, 05:53:21 am
That's the function I'm using in my current Axe Parser project:

Text(1,,sub(CL,X,Y)>DEC
Lbl CL
{ + 4 / 8 * (Tilemap width) + ( r1 + 4 / 8 ) + (Tilemap Pointer) }
Return

It returns the tile ID of the tile at the middle point of an 8x8 object.
A bounding box can be constructed with sub(CL,X+4,Y+4) + sub(CL,X-4,Y+4) + sub(CL,X-4,Y-4) + sub(CL,X+4,Y-4)
Title: Re: Check if there is a solid tile
Post by: Ashbad on June 03, 2011, 06:37:30 am
Well, if you simply want to check if something is an even number:

Code: [Select]
If X/4^2 = 0
  .It's zero
End