WT* ?

Started by
6 comments, last by Ronnie Mado Solbakken 10 years, 6 months ago

i was coding something while i stopped 1 hours on some simple math problem...

at first i thought i was doing something wrong but after a while i realized this


	float x = eng->mWidth;
	float y = eng->mHeight;

returned 0 in x... i had to resolve this way


	float xx = eng->mWidth;
	float yy = eng->mHeight;
	float x = (800 / xx);
	float y = (200 / yy);

and everything worked...

can someone explain to me while i cannot include a member of another class in an equation?? did i do something wrong??? please help me understand...

Advertisement

Huh? The two things you have posted there aren't the same. Anyway, my guess is integer division issues. Does this fix your problem?

float x = 800.0f / eng->mWidth; // (feel free to cast eng->mWidth to float; I didn't because promotion rules will make it at least a float anyway)
float y = 200.0f / eng->mHeight;
[size=2][ I was ninja'd 71 times before I stopped counting a long time ago ] [ f.k.a. MikeTacular ] [ My Blog ] [ SWFer: Gaplessly looped MP3s in your Flash games ]

thanks :) that solved

Wow, Cornstalks. That was impressive. You managed to figure out what the code actually said (`800 / eng->mWidth'), even though the OP posted something else.

To eltharynd: Please copy and paste code in the future so we don't have to rely on Cornstalks's crystal ball.

LOL this topic brightened my day.

Wow, Cornstalks. That was impressive. You managed to figure out what the code actually said (`800 / eng->mWidth'), even though the OP posted something else.

To eltharynd: Please copy and paste code in the future so we don't have to rely on Cornstalks's crystal ball.

Once again I'm impressed by Cornstalks' balls.

void hurrrrrrrr() {__asm sub [ebp+4],5;}

There are ten kinds of people in this world: those who understand binary and those who don't.

There are posts on Gamedev that are boring and some that are interesting but this one made my Friday biggrin.png

(Comment removed for redundancy.)

- Awl you're base are belong me! -

- I don't know, I'm just a noob -

This topic is closed to new replies.

Advertisement