Computer Science Canada SLOPE PROBLEM! |
Author: | @DRI@N [ Tue May 25, 2004 9:31 pm ] | ||
Post subject: | SLOPE PROBLEM! | ||
I made a function to calculate slope and shoot on the net..press shift to shoot, but ![]()
|
Author: | guruguru [ Tue May 25, 2004 10:00 pm ] |
Post subject: | |
Your're making both the x and y change equal to the slope?!?! That won't work. The slope is a way of finding the ratio between the x and y change. Learn a bit more about slopes and then try to tackle this problem... if you can't do simple slopes then you will have major problems later in your game development. |
Author: | @DRI@N [ Tue May 25, 2004 11:26 pm ] |
Post subject: | |
What do you mean though! If you add 1 to x and y change then the slope is 1!! So if I'm adding the slope to x and y change then the slope is (slope)...I don't see any other way to do it. |
Author: | guruguru [ Wed May 26, 2004 3:52 pm ] |
Post subject: | |
Say slope is 1/4... then the x increase would be 4, and the y increase 1. Say slope is 6/5... then the x increase would be 5, and the y increase 6. Say slope is 3/1... then the x increase would be 1, and the y increase 3. Say slope is 0... then the x increase would be anything, and the y increase 0. You can then take these values and scale them down to the size you want. Say your total distance is 10. Slope = 3/5 XtempIncrease = 5 YtempIncrease = 3 TotalCurrentIncrease = 8 Total Distance = 10 XIncrease = XtempIncrease * Total Distance / TotalCurrentDistance XIncrease = 5 * 10 / 8 = 6.25 YIncreaes = 3 * 10 / 8 = 3.75 Ta dah. Hope that helps. If any questions, ask away. |
Author: | Tony [ Wed May 26, 2004 4:29 pm ] | ||
Post subject: | |||
@DRI@N : first of all you got to change your controls to allow for sideway movement. So 4 separate if statements for each button. as for the puck - have you tried debugging it? guruguru brings up a good point that your slope is always 45 degrees... and your puck change is 600something pixels at a time (so it shots staright out of the screen) what you have to do is to find the angle and then to find puck change components
|
Author: | @DRI@N [ Wed May 26, 2004 7:23 pm ] |
Post subject: | |
Does the slope go where PuckSpeed is? |
Author: | @DRI@N [ Wed May 26, 2004 7:28 pm ] |
Post subject: | |
Oh yeah that might work, but wouldnt I need to use Tangent? because I want the angle of elevation...and I know the opposite and adjacent lengths... |
Author: | @DRI@N [ Wed May 26, 2004 7:31 pm ] |
Post subject: | |
Sorry just one last thing... the Turing index has basically the same description for functions COS and COSD..can you explain the difference? |
Author: | AsianSensation [ Wed May 26, 2004 7:35 pm ] |
Post subject: | |
cos is in radians, and cosd is in degrees. 180 degrees = pie therefore, 1 degree = pie/180 |
Author: | Cervantes [ Wed May 26, 2004 8:39 pm ] | ||
Post subject: | |||
did you say angle tony? tony wrote: find the angle
you did! ![]() in that case:
your very own angle finding function. enjoy |
Author: | guruguru [ Wed May 26, 2004 9:46 pm ] |
Post subject: | |
lol. Don't get caught up in Cervanted mystical world :p. Stick with what your doing with the slope, its easier and you seem to know what you are doing. And answering your question to Toney... the slope is the slope. THe puckspeed is what I explained as xChange and yChange. ANd don't get into tangents... and trig... Wait... have you been able to find the slope?!?! If you havent then... I did a quick post on trig in your old topic... check tehre... |
Author: | Tony [ Wed May 26, 2004 10:09 pm ] |
Post subject: | |
why are there two threads on the exact same topic? ![]() if you keep calculations based on the slope components, then your X/Y change will depend on the slope itself and could ether move too slow or too fast (I think it was an issue before when the puck shot at 600pixels/frame) |
Author: | guruguru [ Wed May 26, 2004 10:11 pm ] |
Post subject: | |
Tony: I also posted a way to scale it down to a total distance. Look at my above post ![]() |
Author: | Tony [ Wed May 26, 2004 10:25 pm ] | ||
Post subject: | |||
guruguru : have you checked your results? ![]()
result is 7.3. You loosing almost 30% of your original total distance of 10 ![]() |