# [SOLVED] Power of propelling ball based on mouse pull back

Just started using Construct 2? Post your questions here

### » Tue Jan 27, 2015 10:23 am

G'day Guys,
I'm sure the title is cryptic. I don't know terminology and I belive my inexperience in Construct is my flaw here. I can't for the life of me work out a concept on how to do the following:

Basic ball game. Think similar to pool, marbles, even a sling-shot style game such as Angry Birds.

Help needed with concept / thoughts: Click on the ball, pull backwards. The further you pull back the harder the push / force. (atm it's just clicking on the ball and releasing that works for a pre-coded force)

I am using a screen full of balls and physics. (picture like a pool table).

Click and release is working just fine. It took me a while to work out how to make a directional arrow point where I wanted it to.

Capx attached (very small so far, very little code. Purple ball is the only ball working.
marblem.capx

You do not have the required permissions to view the files attached to this post.
Last edited by humpty on Wed Jan 28, 2015 7:48 am, edited 2 times in total.
B
7
S
1
Posts: 26
Reputation: 549

### » Tue Jan 27, 2015 3:10 pm

You should calculate the Force using the distance and min functions:

min(distance(Sprite.X, Sprite.Y, Mouse.X, Mouse.Y), 200)

The above sets the force applied to the sprite by getting the distance between it and the mouse but will not apply a force higher 200. Remember, min always chooses the lowest value of the options passed into it. Play around with the second value until you feel you have a good max value. Also, if the distance doesn't quite feel like it is giving enough force, do a multiple of the distance. For example, you could multiply the distance by 1.5.

I hope that gets you what you need and good luck with your project.
B
40
S
12
G
11
Posts: 331
Reputation: 7,752

### » Wed Jan 28, 2015 7:47 am

Thanks FragFather. That seems to be exactly what I needed and shouldn't be too hard to convert into some form of visual for the interface

I really appreciate it and yes yet again my limitation is my inexperience THANKS !!!
B
7
S
1
Posts: 26
Reputation: 549