Results 1 to 5 of 5

- May 6th 2008, 09:53 PM #1

- Joined
- May 2008
- Posts
- 3

## 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?

- May 6th 2008, 10:43 PM #2

- Joined
- Nov 2005
- From
- someplace
- Posts
- 14,972
- Thanks
- 4

- May 7th 2008, 12:03 AM #3

- Joined
- May 2008
- Posts
- 3

- May 7th 2008, 12:37 AM #4

- Joined
- May 2008
- Posts
- 3

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?

- May 7th 2008, 02:31 AM #5

- Joined
- Nov 2005
- From
- someplace
- Posts
- 14,972
- Thanks
- 4