Jump to content
  • Advertisement
Sign in to follow this  
ghotirein

Problem with some really simple math

This topic is 4078 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi folks, I have this really strange problem :S here is my code: switch(MenuItem) { case 1: engine2d->Render2DImageOn3D(122.0f, 142.0f, 186.0f, 206.0f, exitBig); //2 engine2d->Render2DImageOn3D(186.0f, 110.0f, 314.0f, 238.0f, gameBig); //3 engine2d->Render2DImageOn3D(304.0f, 142.0f, 368.0f, 206.0f, psBig); //4 break; case 11: // do the rotate :) inc++; if(inc == STEPSIZE) { inc = 0; MenuItem = 2; } else { engine2d->Render2DImageOn3D((float)(336 - ((32/STEPSIZE) * inc)), (float)174 - ((32/STEPSIZE) * inc), (float)(336 + ((32/STEPSIZE) * inc)), (float)174 + ((32/STEPSIZE) * inc), btBig); //4 engine2d->Render2DImageOn3D((float)(122 + ((32/STEPSIZE) * inc)), (float)142 + ((32/STEPSIZE) * inc), (float)(186 - ((32/STEPSIZE) * inc)), (float)206 - ((32/STEPSIZE) * inc), exitBig); //1 engine2d->Render2DImageOn3D((float)(186 - ((64/STEPSIZE) * inc)), (float)110 + ((32/STEPSIZE) * inc), (float)(314 - (((64/STEPSIZE) * inc) * 2)), (float)238 - ((32/STEPSIZE) * inc), gameBig); //2 engine2d->Render2DImageOn3D((float)(304 - ((128/STEPSIZE) * inc)), (float)142 - ((32/STEPSIZE) * inc), (float)(368 - ((54/STEPSIZE) * inc)), (float)206 + ((32/STEPSIZE) * inc), psBig); //3 } break; case 2: engine2d->Render2DImageOn3D((float)(122), (float)142, (float)(186), (float)206, gameBig); //2 engine2d->Render2DImageOn3D((float)(186), (float)110, (float)(314), (float)238, psBig); //3 engine2d->Render2DImageOn3D((float)(304), (float)142, (float)(368), (float)206, btBig); //4 break; I go in my menu from 1 to 11 to 2. however the positions from 1 to 11 go without problems, from 11 to 2 however the exact change between them is in positions huge!!, like it is not smooth as is with 1 to 11, it like jumps from the end position from 11 to the position of 2, where i thought it should be smooth and the same position :S any ideas ? (i hope i explained correctly)

Share this post


Link to post
Share on other sites
Advertisement
What exactly is your menu supposed to do? Currently your design isn't very flexible, but if you let me know what you are trying to do then I might be able to suggest improvements.

In general it is a bad idea to hard code things like you are doing. A reason for this is what happens if you want to add a fourth menu option or perhaps add two or three more? Well then your code keeps growing exponentially.

Share this post


Link to post
Share on other sites
Hi yes, well i do it hardcoded because i don't know what is going wrong :S my other code just does it with an array for the pictures so i need a lot less code but to see what is going wrong i wrote it hardcoded.

the problem is that i have a menu with n items. a item is a 128x128 squad with a texture. in the middle it is rendered as 128x128 but next to the middle on both sides there is rendered amenu item only that is scaled to 64x64, when i press right, the menuitem on the most right goes to the middle and changes from 64x64 to 128x128, the middle goes to the left and goes from 128x128 to 64x64, however it does not seem to go right.

Share this post


Link to post
Share on other sites
I have solved the problem, it was a rounding error (well forgetting a casting to float)

thanks for the replies

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!