Angry Birds like game - Problem with physic force

For questions about using Classic.

Post » Thu Jul 26, 2012 12:11 pm

Hi guys,
I have a little-big problem. I tried to create Angry Birds-like game and I get stuck with one problem.

I created variable global('power') that is used to set force for barrel flying from cannon. I use [Key Left Mouse Button is down] for adding 5 to the variable. The i use [On Key Left Mouse Button released] to shoot using [barrel: Set force: global('power') towards mouse.X mouse.Y]. I use Text object to show the current power using [power_variable: Set text].

So, now the problem.

The force applied to barrel sems to be random :/
Text is showing Force: 200 but one time it shoot with ~300 or ~100...

Here's the whole code:

B
11
S
2
Posts: 15
Reputation: 797

Post » Thu Jul 26, 2012 3:15 pm

I don't have Classic Construct. But try moving your mouse release event to after the mouse button event. and on your mouse button down sub event (power > 200) Try setting power to 200 instead of decrementing it. You might also want to change DOWN to pressed. Holding a key down will poll it every tick. You can literally get a very large number in a small amount of time.

For example: If a tick occurs 20 times in 1 second. Your power variable will increment 100 every second. When you are checking the range (Power > 200), I assume you want to set a max Power. Decrementing it every tick will give you random results depending on the event/tick relationship.

Try:

+ Left Mouse Button down
   - Power > 200 : Set power 200
+ Left Mouse Button Released

....digitalsmeg2012-07-26 15:20:08
B
12
G
1
Posts: 19
Reputation: 1,066

Post » Thu Jul 26, 2012 6:32 pm

Even if there's fixed value for global('power') it still looks like it shooting at random... Here's a quick movie showing problem:

http://youtu.be/WsocoLsDiec
B
11
S
2
Posts: 15
Reputation: 797


Return to Help & Support using Construct Classic

Who is online

Users browsing this forum: No registered users and 1 guest