How come this doesn't work?

Blitz3D Forums/Blitz3D Beginners Area/How come this doesn't work?

BLaBZ(Posted 2007) [#1]
Global radydistance=(ScreenY# * (578/768))

Where ScreenY# = 768

For some reason it's not returning anything
Any thoughts?


Rob Farley(Posted 2007) [#2]
Just understood what you're trying to do...

It's a float / int thing

Without testing try doing screeny# * (578.0/768.0)


ervin(Posted 2007) [#3]
Hi there.

Try this:
Graphics 640,480,32,2

yScreen=768
Global radydistance=(yScreen * (578.0/768))

Print radydistance
WaitKey()

Your calculation was returning 0 because you were trying to do float division with integers.
Someone else can probably explain this better than me, but if you are calculating a float, you need to use floats in your division.
Which is why the code above has 578.0 instead of 578.

[EDIT] Rob - your post appeared literally 8 seconds before mine.


BLaBZ(Posted 2007) [#4]
Thanks a lot!! It makes complete sense.