Jump to content

  • Log In with Google      Sign In   
  • Create Account

We're offering banner ads on our site from just $5!

1. Details HERE. 2. GDNet+ Subscriptions HERE. 3. Ad upload HERE.


WT* ?


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
7 replies to this topic

#1 eltharynd   Members   -  Reputation: 123

Like
1Likes
Like

Posted 27 September 2013 - 04:04 PM

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...



Sponsor:

#2 Cornstalks   Crossbones+   -  Reputation: 6991

Like
16Likes
Like

Posted 27 September 2013 - 04:07 PM

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;

[ 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 ]

#3 eltharynd   Members   -  Reputation: 123

Like
0Likes
Like

Posted 27 September 2013 - 04:09 PM

thanks :) that solved


Edited by eltharynd, 27 September 2013 - 04:13 PM.


#4 Álvaro   Crossbones+   -  Reputation: 13670

Like
7Likes
Like

Posted 27 September 2013 - 04:37 PM

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.

Edited by Álvaro, 27 September 2013 - 09:08 PM.


#5 Muzzy A   Members   -  Reputation: 647

Like
5Likes
Like

Posted 28 September 2013 - 06:37 PM

LOL this topic brightened my day.



#6 Khatharr   Crossbones+   -  Reputation: 3031

Like
6Likes
Like

Posted 28 September 2013 - 09:42 PM

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.

#7 QuinnDexter   Members   -  Reputation: 153

Like
0Likes
Like

Posted 04 October 2013 - 09:42 AM

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



#8 Malabyte   Members   -  Reputation: 589

Like
0Likes
Like

Posted 13 October 2013 - 12:00 PM

(Comment removed for redundancy.)


Edited by Malabyte, 13 October 2013 - 12:16 PM.

- Awl you're base are belong me! -

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





Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS