Computer Science Canada Hockey Puck in the net Game |
Author: | Gackt [ Tue Feb 17, 2009 10:52 am ] | ||
Post subject: | Hockey Puck in the net Game | ||
Okay, I My Cannon Ball is the hockey puck, and the Target is the net. The Cannon Ball (Puck) has to be in the lower left corner, and the target has to be in the bottom right corner. I need to know how to arc the puck so it goes up and slowy comes down like it would in real life. Right now my coding makes no sense, it doesnt arc up and come down, it just keeps going up. Is there any simpler coding to what I have. I know nothing about it, so explaining isn't really going to help. Im not asking you to write the whole program, just give me an arc coding that will help. I need to insert a power, and angle in the arc. Heres my coding so far...
|
Author: | Gackt [ Tue Feb 17, 2009 8:04 pm ] | ||
Post subject: | Re: Hockey Puck in the net Game | ||
Alright, forgot all that coding up here. I Changed it,
|
Author: | Gackt [ Wed Feb 18, 2009 4:28 pm ] | ||
Post subject: | Re: Hockey Puck in the net Game | ||
Alright, Triple post.... >.> Okay, Why doesnt this code run?
|
Author: | saltpro15 [ Wed Feb 18, 2009 4:43 pm ] |
Post subject: | RE:Hockey Puck in the net Game |
just use the edit button instead of triple posting, it's easier. and something is wrong with your main loop I think |
Author: | DemonWasp [ Wed Feb 18, 2009 4:44 pm ] |
Post subject: | RE:Hockey Puck in the net Game |
It won't run because "time" returns a string which cannot be used in multiplication. |
Author: | Gackt [ Wed Feb 18, 2009 5:52 pm ] |
Post subject: | RE:Hockey Puck in the net Game |
Its just the coding my Teacher gave me to use to make the ball arc. I replaced time with 1 to see if it work and i got an error. It highlighted the second bracket on theta and the 2 at the very end. The error stated "Assigned Value is the wrong type" I have no clue what is wrong. |
Author: | Insectoid [ Wed Feb 18, 2009 6:01 pm ] |
Post subject: | RE:Hockey Puck in the net Game |
it means you're trying to put a string into an integer, or real into integer, or integer/real into string. For example, var foo : string := 3.14 I assume x := x1 + velocity * time * cosd (theta) returns a decimal answer, which cannot fit into an integer variable. |
Author: | Gackt [ Wed Feb 18, 2009 7:44 pm ] |
Post subject: | RE:Hockey Puck in the net Game |
Well, from what my Assignment sheet says, time is sopossed to be a counter that increases by 1 each time through the loop. |
Author: | DemonWasp [ Wed Feb 18, 2009 9:24 pm ] | ||
Post subject: | RE:Hockey Puck in the net Game | ||
Well, then you need to declare a "time" variable - more specifically, you need to declare something like "loopCounter", as "time" is a reserved keyword used by Turing. Check the help (F10). "counter that increases by 1 each time through the loop." means this:
|
Author: | A.J [ Wed Feb 18, 2009 10:21 pm ] |
Post subject: | Re: Hockey Puck in the net Game |
time is already a predefined value used in turing...like DemonWasp mentioned, you can just make another counter and increase that by 1 every time in the loop |
Author: | Gackt [ Thu Feb 19, 2009 7:38 pm ] | ||
Post subject: | Re: Hockey Puck in the net Game | ||
Alright, before I Post my final coding for help. I just want to thank you guys for your help I've worked on this for like an hour straight and can't figure how to have my target stay the same shape and get in a different random stop. It moves, but it like just shrinks or grows and I dont know why.
|
Author: | Ktomislav [ Fri Feb 20, 2009 9:07 am ] | ||
Post subject: | Re: Hockey Puck in the net Game | ||
You have to change randx2, like you did before, because it contains position for old random position of target. And one more thing vy is not angle, it's speed in y direction, and vx is just speed in x direction, not full speed. You have to use trigonometry if you want to do it with angle. |