How would I go about making a mouse flick based Mini-golf game?

I would love to create a mini-golf game with a more dynamic putting style. A game that simulates the actual sensation of putting by flicking the mouse. Inspired by the steam game ‘Golf It.’

In order to calculate things like flick length and flick (mouse) speed so that I can apply the mouse flick speed and distance into the balls forward motion, I need to figure out how to tell when the mouse is not moving (idle)… I am not too sure about this.

Does anyone have a more effective or wiser way to go about this?

I really want to try to make this small project a reality, so any advice, or suggestions would be greatly appreciated.

Off the top of my head, you can probably just directly map the club to the position of the mouse. I’ve never played that game, but I assume you hold a button to “activate” the club. I assume it’s the left or right mouse button. Get the mouse’s screen position. Then when the player moves the mouse down the screen, match the difference between the start position and current position, then make the club move relative to that. Then when the club makes contact with the golf ball with a given speed or greater, apply directional force and strength based on how quickly the club was moving before it hit the ball?

Sounds great and logical. Thanks!
I’ll try my best to do that

1 Like

My main concern is I am not too sure how to calculate the mouse speed.

You would calculate the speed of the club, rather than the mouse. You can use the speed of the mouse too, but you’d have to constantly check how far the mouse is moving per interval or per event and use the delta or something like that.

This is just a guess: (I didn’t do so well in physics so this may be completely off)

Procedure You will need to calculate the force applied on the ball (f) by multiplying mass (m) and acceleration (a).

Calculating Acceleration: To calculate acceleration, you simply need to get the absolute value, math.abs(), of the start position subtracted by the end position. The start position will be when the user begins to swing the club and the end position will be when the club makes contact with the ball. You will then divide this value by the time it took to start the swing and hit the ball.

Calculating Mass: Set this value to the mass of the club

Multiply these two values together then I believe you will get the force applied to the ball.

1 Like