1. ## Problem

Hi, this problem is a little hard to explain. I'm working on a programming problem for a game. These numbers are the position on the screen, and each position on the screen exists in a tile. Note: I'm using hexidecimal numbers

$00 to$07 is tile1
$08 to$0F is tile2
$10 to$17 is tile3...

I want to be able to put any number into a formula that will come out with the tile number that number is in.
If I put in $06 the formula will come out with the number$01.
If I put in the number $14 the formula will come out with the number$03.

Can you explain what kind of formula/equation would do this?

2. Originally Posted by Ash11
Hi, this problem is a little hard to explain. I'm working on a programming problem for a game. These numbers are the position on the screen, and each position on the screen exists in a tile. Note: I'm using hexidecimal numbers

$00 to$07 is tile1
$08 to$0F is tile2
$10 to$17 is tile3...

I want to be able to put any number into a formula that will come out with the tile number that number is in.
If I put in $06 the formula will come out with the number$01.
If I put in the number $14 the formula will come out with the number$03.

Can you explain what kind of formula/equation would do this?
tile_number=(x/$008)+$001

here I am assuming that (hex) integer division is rounded down to the largest integer less than actual result.

RonL

3. Thanks, that works great!

4. Ok, I've just realised I have to specify the x and y position for the sprite, so that makes it more complicated than I realised, sorry.

if x = $00 to$07 AND y = $00 to$07 it's tile1
if x = $08 to$0F AND y = $00 to$07 it's tile2
if x = $10 to$17 AND y = $00 to$07 it's tile3...

one row down:
if x = $00 to$07 AND y = $08 to$0F it's tile33
if x = $08 to$0F AND y = $08 to$0F it's tile34
if x = $10 to$17 AND y = $08 to$0F it's tile35...

There's 32 tiles on every row. The tiles are numbered from the top row going left to right then one row down going left to right etc... like this

1 2 3...
-> -> -> -> -> -> -> -> -> -> -> ->

33 34 35...
-> -> -> -> -> -> -> -> -> -> -> ->

65 66 67...
-> -> -> -> -> -> -> -> -> -> -> -> ...

I need to have a function that I put x and y into and it tells me the tile number. Can you help?

5. Originally Posted by Ash11
Ok, I've just realised I have to specify the x and y position for the sprite, so that makes it more complicated than I realised, sorry.

if x = $00 to$07 AND y = $00 to$07 it's tile1
if x = $08 to$0F AND y = $00 to$07 it's tile2
if x = $10 to$17 AND y = $00 to$07 it's tile3...

one row down:
if x = $00 to$07 AND y = $08 to$0F it's tile33
if x = $08 to$0F AND y = $08 to$0F it's tile34
if x = $10 to$17 AND y = $08 to$0F it's tile35...

There's 32 tiles on every row. The tiles are numbered from the top row going left to right then one row down going left to right etc... like this

1 2 3...
-> -> -> -> -> -> -> -> -> -> -> ->

33 34 35...
-> -> -> -> -> -> -> -> -> -> -> ->

65 66 67...
-> -> -> -> -> -> -> -> -> -> -> -> ...

I need to have a function that I put x and y into and it tells me the tile number. Can you help?
row=y/$08+1 col=x/$08+1

ncol=\$020

tile=ncol*(row-1)+col

(needs some checking)

RonL