Can someone explain to me how this...
Local IdealRatio:Float = DesktopWidth () / DesktopHeight ()
... can become 1.00000000? Cos I don't get it. I've been tearing my hair out for over an hour on why I couldn't get a simple bubble sort to work until I discovered that DesktopWidth() / DesktopHeight gives me a value of 1.0 when it's *supposed* to give me 1.6 or 1.33333 or whatever depending on resolution. Argh!
Here's the code btw. I've been trying all kinds of shit so it's probably busted by now :P
Local IdealRatio:Float = DesktopWidth () / DesktopHeight ()
Local Ratio:Float[4]
Ratio[1] = IdealRatio - (x[1]/y[1])
Ratio[2] = IdealRatio - (x[2]/y[2])
ratio[3] = IdealRatio - (x[3]/y[3])
ratio[4] = IdealRatio - (x[4]/y[4])' - IdealRatio
If Ratio[1] < 0 Then Ratio[1] = -Ratio[1]
If Ratio[2] < 0 Then Ratio[2] = -Ratio[2]
If Ratio[3] < 0 Then Ratio[3] = -Ratio[3]
If Ratio[4] < 0 Then Ratio[4] = -Ratio[4]
Local n:Int = 4' total amount of resolutions
Repeat
Local swapped:Int=0
For bubble = 1 To n
Local tempx:Int
Local tempy:Int
Local nextx:Int
Local nexty:Int
Local tempratio:Float
If bubble+1 <= n And Ratio[bubble] > Ratio[bubble+1]
tempx = x[bubble]
tempy = y[bubble]
x[bubble] = x[bubble+1]
y[bubble] = y[bubble+1]
x[bubble+1] = tempx
y[bubble+1] = tempy
tempratio = Ratio[bubble]
Ratio[bubble] = Ratio[bubble+1]
Ratio[bubble+1] = tempratio
swapped=1
EndIf
Next
n = n - 1
Until swapped=0
|