Trouble making a true equation

If you have questions about any aspect of QBasic programming, or would like to help fellow programmers solve their problems, check out this board!

Moderators: Pete, Mods

DaveUnit
Veteran
Posts: 72
Joined: Sat Oct 29, 2005 10:07 am
Contact:

Trouble making a true equation

Sorry about the vague title...
My program loads a map file and whatnot, let's say one of the points has a tile number of 9. I need to take that number, then, based on the number of tiles horizontal and the number of tiles vertical in the tileset, find the column and row that tile is in, then finally convert those to x and y coordinates.
So... In a step by step form
let's say...
tile number= 9
tiles vertical= 3
tiles horizontal= 6

step 1: see how many times 6 can go into 9, subtract 6 * the amount of times six goes into 9, which is one, we're left with 3. 3 is the column the tile is in.
step 2: the amount of times 6 went into 9 plus one will equal the row the tiles is in.

I may have screwed up typing and totally made my idea total gibberish so point out if I did.

I can think of how to do it in my head but when I try to type down actual equations for it everything gets all frigged up.

I came close today but there's something that mod does that ruins it.

This should be simple math but for some reason I can't think of the equation.

Thanks for any help. It's much appreciated.

Dave.

DaveUnit
Veteran
Posts: 72
Joined: Sat Oct 29, 2005 10:07 am
Contact:
EDIT: got rid of everything I posted earlier...
I just thought of something...
ya know those old qb double buffering tutorials?
ya know to put the right pixel color on the right spot on the array you'd use the equation x+320*y?
Well... for me the 320 would be whatever the image width was.
It sucks there are two variables for me to eliminate, it makes it hard to work with that equation to fit my needs of starting without an x,y coordinate.
I'm trying to remember stuff from my geometry class 1st semester but I'm drawing a blank, how can I possibly work with that equation to create the new one I need for my program?

DaveUnit
Veteran
Posts: 72
Joined: Sat Oct 29, 2005 10:07 am
Contact:
I imagine that I confused the hell out of all of you. Sorry.
But I'm kinda glad no one replied because I figured it out on my own, and it was really easy too! I can't believe it took me so long to figure out.

Veteran
Posts: 703
Joined: Sun Nov 14, 2004 7:36 am
Contact:
Hey, don't worry about it...sometimes you just don't see it until you slept it off and sometimes even a few days hehe. Something to be said about looking at your code for too long .
When God created light, so too was born, the first Shadow!

Need hosting? http://www.jc-hosting.net

Interested in Text & ASCII development? Look no further!
http://www.ascii-world.com

Zim
Veteran
Posts: 98
Joined: Mon Dec 05, 2005 4:31 pm
Location: Wisconsin, USA
Contact:
As a teacher, one of the things I've noticed with students having difficulties is this. If you can force the student into an EXACT explanation of their question, many times they will spontaneously obtain the solution at that point. Forcing yourself to formulate an exact question (in writing, as on a message board) helps you to find the answer yourself!
--- Zim ---
--- Time flies like an arrow, but fruit flies like a banana ---

DaveUnit
Veteran
Posts: 72
Joined: Sat Oct 29, 2005 10:07 am
Contact:
Hmmm... that's really interesting, Zim. Thanks for the advice!
I realized my problem was with the division being rounded up so I ended up subtracting .4 from the result and it will always being a number rounded down. it has worked flawlessly and now I got my map displaying properly. My first FB scroller! woot. My map format works nicely too. I'm pretty proud of where my program is going. Everything has been neat and orgranized so far. Granted, I only have a scrolling map at the moment. Next is sprite handling! Hopefully I won't screw up too bad!

Later,
Dave