Computer Science Canada Turing Mathematics |
Author: | Witchcraft [ Sun Oct 12, 2008 4:35 pm ] | ||
Post subject: | Turing Mathematics | ||
Hey, So I just started a nice big turing project to sum things up before I move onto learning Java. My idea is to make a pirate cannon game (kind of like the one from math circus). Well I'm just working on the rough stuff, and I got a ball to shoot up in a parabolic arc that has a vertical stretch depending on how long you hold down the mouse. Now my problem is that pictures can only be drawn on pixel values (which are always ints), but if I use a verticle stretch that is not an int, (such as 3/2) then I will get real numbers as the y values, and so the cannon ball cannont be drawn at that coordinate. This same problem would occur for vertical compression as well because division is even worse for giving you whole numbers as a result. How do I fix this problem? Do I convert a real to a int? The cod is posted below.
Mod edit: Working syntax tags added. |
Author: | Witchcraft [ Sun Oct 12, 2008 4:36 pm ] |
Post subject: | RE:Turing Mathematics |
sorry I tried to get my code to appear as it would in turing, but I'm new to the forums so it didn't work out. How is it done? |
Author: | The_Bean [ Sun Oct 12, 2008 5:25 pm ] | ||
Post subject: | Re: Turing Mathematics | ||
round() % rounds a number according to the one's column, should work for what you want
|
Author: | Witchcraft [ Sun Oct 12, 2008 5:56 pm ] |
Post subject: | RE:Turing Mathematics |
thanks a lot, got it to work |
Author: | Insectoid [ Sun Oct 12, 2008 8:30 pm ] |
Post subject: | RE:Turing Mathematics |
make sure you use 'perfect' collision detection, or if the ball is moving too fast, it will go through the walls. Look it up in the tutorials (it is rather complicated) |