Computer Science Canada ball control using mouse help |
Author: | neufelni [ Tue May 03, 2005 11:07 am ] |
Post subject: | ball control using mouse help |
I am making a mini golf game and I need some help. How would you be able to use your mouse to control the ball. I want to be able to click on the ball and pull the mouse back and sideways to change the velocity and the angle that the ball will travel at. |
Author: | Viper [ Tue May 03, 2005 1:28 pm ] |
Post subject: | |
i think you could do something like this if mb>=1 and whatdotcolour (mx,my)=white(ball colour) then if ballx-mx>=10 then(this determines how far you pulled the mouse from the ball to the left only youll have to put something to determine which way they pulled the mouse or have all courses go one way) ballxincrease=5(ballxincrease is how many x picks it will move a one time) .... .... i cant help with the direction though i know you need to us math n angles not much help but a basic idea i guess |
Author: | Cervantes [ Tue May 03, 2005 7:37 pm ] | ||
Post subject: | |||
This is more for a pool type game, but here:
|
Author: | neufelni [ Wed May 04, 2005 10:58 am ] | ||
Post subject: | |||
Cervantes had the line of code :
The Math.Distance does not work with the version of Turing that I am using. It tells me that Distance is nt an export command of Math. Is there any other way that I could do this without using Math.Distance? |
Author: | fehrge [ Wed May 04, 2005 11:06 am ] | ||
Post subject: | |||
Here is a simple way of doing it that worked for me. I had to put the check process in or else the ball would never stop. It has some minor glitches but it works.
|
Author: | Cervantes [ Wed May 04, 2005 7:43 pm ] | ||
Post subject: | |||
fehrge: processes = evil! Nick: Use the distance formula, to write your own distance function:
|
Author: | neufelni [ Mon May 09, 2005 11:05 am ] |
Post subject: | |
I do not like that fehrge has proccesses in his code but his ball slows down, unlike Cervantes' and I need it to slow down. I would uses fehrge's code but I do not like using proccesses and since I am new to Turing I do not know how I can change either fehrge's or Cervantes' code to be like I want it. fehrge : Get rid of the proccesses and keep everything else the same, OR Cervantes : Could you make it so the ball slows down and you are only able to shoot the ball once? And also slow the ball down a little. It goes to fast. |
Author: | Cervantes [ Mon May 09, 2005 4:47 pm ] |
Post subject: | |
Nick wrote: Cervantes : Could you make it so the ball slows down and you are only able to shoot the ball once? And also slow the ball down a little. It goes to fast. Yes, I can do all of that. The question is, can you? This is your project, not mine. ![]() That said, let's go through how we will accomplish these things: To slow the ball down, we want to decrease it's velocity by a certain ratio each time through the loop. If we multiply the velocity of the object by, say, 0.99, we will effectively slow the object down over time. To prevent the ball from being shot more than once, we simply need a boolean variable to keep track of whether the ball has been shot or not. As soon as we shoot, we want to set this boolean to true. We want to prevent the user from shooting if this boolean is false. To slow the ball down a little, you just play with the speedAdjust variable. Okay, so I've basically told you how to do these things. I think it should be pretty easy for you, provided you can understand the original code I posted. Let us know if you need any clarification with the code I posted above or anything I've said in this post. -Cervantes |