0 Favourites

Angry Birds like game - Problem with physic force

This forum is currently in read-only mode.
  • 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:

    <img src="https://dl.dropbox.com/u/40649602/code.jpg" border="0" />

  • 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

    ....

  • Construct 3

    Buy Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Buy Now Construct 3 users don't see these ads
  • 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

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)