How do I make an Impulse Bar

Get help using Construct 2

Post » Mon Jun 22, 2015 11:00 am

Hello again Constructors! once again I need some help from the pros...

I have been developing a game which uses a catapult system, specifically the power of the shot is equal to the distance between the touch (cursor) position and the ball position.

The thing is that I have a radial power bar with 24 frames that should display the force of the shot. The idea is to link all together, if the cursor gets closer then the radial bar should be something around the 3rd or 6th frame.

There should be a limitation on the force as well, because the max force will be when the radial reaches the 24th frame, even if the player points far in the distance the max force should stay at the same value for the 24th frame.

I'm not sure if I explained it in a way it doesn't look complicated, I don't have a CAPX due this problem is quite abstract for me right now. Though questions are more than welcome to clarify the information for those helping minds :)

Thanks in advance!
B
4
S
1
Posts: 34
Reputation: 416

Post » Mon Jun 22, 2015 11:12 am

If you have a maximum value and a minimum value for the power it would be quite easy..
Should be something like this:

set Variable PowerOfShot to : clamp(distance(touch.x,touch.y,ball.x,ball.y),0,maximum)

radial powerball set frame to : round(24*(PowerOfShot/maximum))
I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775

Post » Mon Jun 22, 2015 12:42 pm

Hi Stain, thanks for your fast response!

Sorry but I still don`t get it, part of my brain is fried right now. Can you explain it once again, please?
B
4
S
1
Posts: 34
Reputation: 416

Post » Mon Jun 22, 2015 1:03 pm

Indomitus wrote:Hi Stain, thanks for your fast response!

Sorry but I still don`t get it, part of my brain is fried right now. Can you explain it once again, please?


That would be quite useless, for the explanation would be the same..

the clamp expression keeps the value of the variable PowerOfShot between a maximum and a minimum..

by dividing the variable PowerOfShot with the maximum power you get a number between 0 and 1, when you multiply this by 24 you get a number between 0 and 24, by rounding it it will be an integer instead of a float and the frame can be set..
I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775

Post » Tue Jun 30, 2015 11:49 am

Sorry for the delay on my post. After cooling my head down I could understand what you said and worked like a charm, thanks a lot!
B
4
S
1
Posts: 34
Reputation: 416


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 9 guests