Monday 30 August 2010

Defeating Math

This is one of the reasons I love programming, pure problem solving!
I have just finished the drawing part of the object maker. Apart from the fact objects can't yet be saved, we can now create any object we want from multiple tilesets if needs be (which by the way is not a feature you find in most map makers. In fact, I've never seen that feature at all before...go figure).

But at what cost? Well aside from various other trixy problems I've had to solve, this one was fun because it was pure number crunching. My favourite type of puzzle! Yeh, I know, I'm a big geek. Sue me.

The puzzle is as follows:
The program has been designed so that tiles from a tileset have a specific ID. For example:
This is a typical tileset. Notice the grey square in the bottom right of the image. This is the size of a single tile and therefore each bed takes up 2 tiles; one above the other.

Each tile has it's own ID, as an example I've drawn this nifty diagram:
Now keep in mind that computers work with pixels, so we must specify the dimensions of a tile...which could be different for every tileset, so the dimensions of a single tile must be able to change. The number of columns and rows per tilesheet may change. The tilesheet itself has dimensions that may change and the tiles that we have selected may also change. For example in the case above I may have selected a square of tiles (5, 6, 9, 10). Now what series of mathematical equationa can I perform for a tileset with X, Y dimensions on a selection of A,B dimensions at position P, O when a single tile is of I, J dimensions so that I get the result of the 4 numbers I just mentioned.
And you thought it was as simple as "take this and draw it" ;)

Enjoy!

P.S.
You can use incrementing numbers (or for loops if you're reading this ogre). By this I mean the first time you do the equation the number is 0. the second time you do the equation the number is incremented to 1. Do the equation again and it becomes 2 etc.
Solution will be posted when I make the next post, whenever that may be...probably tomorow

3 comments:

  1. Maths hurts my brain. I have only a passing familiarity with it.

    ReplyDelete
  2. If I was meant to do maths I'd have a brain more powerful than any computer ever.

    Do you actually refer to yourself as 'we' when thinking about these things, or are you refering to your reader aswell, including them in to the game building process? 'cause I totally never refere to myself as we ¬_¬.

    Also I now have an image of you in deadly battle with maths.

    ReplyDelete
  3. I refer to the reader as well =p
    As for the battle, I still have the scars

    ReplyDelete