Timewaster's Guide Archive

Departments => Webcomics & Free Stuff => Topic started by: Spriggan on May 01, 2003, 01:02:40 PM

Title: My math is off
Post by: Spriggan on May 01, 2003, 01:02:40 PM
ok I can give you all a simple version of a maze game i'm makeing but my math is off I think.

i've got an area 700x500 pixels and  you can enter the number of rows and colums. so say you enter 25x20, I want the "cells" I created to scale down to match that size.  This way you could enter 100x100 and still have it fit in that size.

700/row=newsizey
500/colum=newsizex

to get the scale factor I multiply  (100xnewsize)/oldsize and I do this for both the x and y.  So I should be able to take the oldsize*scale  and get the new "space factor", just putting the new varable there dosen't work.  But this dosen't seam to be working.  It might be something else in the code but I haven't been able to find it yet so I'm checking my math.

humm
cell._x = (i-1)*cellWidth;
           cell._y = (j-1)*cellHeight;
this is the code I'm useing for the spaceing so I shouldn't matter if I just use the newsizex and newsizey so I don't need that oldsize*scale.  But my spaceing is still off.  It worked before I tried this modification.  I and J in that script is the current row/colum number.
Title: Re: My math is off
Post by: The Holy Saint, Grand High Poobah, Master of Monkeys, Ehlers on May 01, 2003, 01:38:09 PM
I'm not sure I understand what you're trying to do. Are you trying to scale the display down to the scale inputted by the user? Or to have the number of cells defined by the user fit to the resolution? Or something else entirely?
Title: Re: My math is off
Post by: Spriggan on May 01, 2003, 01:40:19 PM
yes to the first one...sort of.  the maze will allwayse fit in the total allowed size.  But besided that I want the maze to scale down according to what the user inputs.
Title: Re: My math is off
Post by: The Holy Saint, Grand High Poobah, Master of Monkeys, Ehlers on May 01, 2003, 02:11:44 PM
So you're using a variable number of "squares" (defined by the user) to fill up a resolution (defined by the program and/or the monitor. And you want it to expand those squares to fill up the resolution, right?

So the size of the square on a the "x" side needs to equal the X-axis, and ditto for "Y" So square size should equal
(X- axis / # of squares in that dimension) x (Y-axis / # of squares in that dimension).
Which works if the "squares" are actually rectangles, if you want true square, each side is equal to  the smaller of the x or y-axis divided by the larger number of squares on either side (easiest formula, not always the one that will give you the largest squares).

In short, I *think* your math is right, but being as I keep getting interrupted by the phone and other things I have to do for work (*shakes fist*) I might not be seeing things right.