Valhallen's Recent Forum Activity

  • Do you have the wrap behavior on both the object and the player?

  • You can use 'wallclocktime' and just subtract the last value from the current value. You don't need to keep track of the time directly, just store that time on a click and use that as a reference on the next click.

    That's a good solution, I wasn't aware of "wallclocktime".

    To add to that, I would suggest you store the time when the next button spawns, rather than on click in case there is a delay between buttons.

  • That's okay. How about this:

    Say your sprite starts facing to the right:

    When you press left, your sprite flips 180 to face left. When you press right, your sprite flips 180 to face right again.

    When a bullet object gets spawned from your sprite (your sprite will do "spawn another object"), it will automatically be facing the same direction as your sprite.

    Don't worry about the mouse controls in the video, just focus on how he spawns the bullet. You can use the same thing in your game when you press the spacebar.

  • Hey there, check out this tutorial about spawning bullets: "Game Development w/ Construct 2 Tutorial - 8 - Shooting Bullets" by TheNewBoston on YouTube.

    The bullet will go in the direction the sprite is facing, so if the sprite doesn't flip when you change directions, you'll have to keep track of which way the sprite is facing based on the last movement input, and flip the bullet direction manually.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • You can use the "dt" (delta time) expression to get the amount of time elapsed since last tick. Add "dt" to a variable on tick, and when the button is pressed, get the value in the variable and put it in a list of recorded times, and then set the time keeping variable back to 0. At the end, you take the average by adding all the times in the list together, then dividing by the number of times in the list. So you would be dividing by 10 after adding all the times together.

    Alternatively you can also use Timers to record how much time has passed. Instead of adding delta time every tick, you could set a timer to execute every 0.1 seconds, and add 0.1 to the time keeping variable. This would be more optimal as you're not doing something every tick, only every 0.1 seconds, however this would be accurate only to a tenth of a second. You could decrease the timer interval to increase accuracy.

  • You should make sure that you only check the condition one time when experience is added, rather than on tick or at an interval.

    Alternatively you could keep track of how much experience has been gained since the last level up. If that value becomes greater than 100, then level up and set it back to 0.

  • Thanks for the response. I will do some research into the AJAX object and try to find any simple JSON plugins.

  • I've haven't actually used Construct 2 yet, but I see in the documentation there is a System Condition called "Compare two values" which can take two expressions.

    An expression is something that needs to be evaluated before the condition is checked. You can type it right in, instead of a simple number.

    [quote:ooh7maok]Compare two values

    Compare any two expressions (which can either numbers or text) with each other. They can be compared as Equal, Not equal, Less, Less or equal, Greater or Greater or equal.

    You'll want to use the "Greater" comparison.

    I plan on testing out Construct 2 tonight, so I'll come back and add some more detail to this post if you haven't figured it out by then.

  • You're going to want to check if your experience value can be divided by 100 with a remainder of 0.

    For this, there is the modulo operator %. Modulo gives you the remainder of a division.

    examples:

    200 % 100 = 0

    301 % 100 = 1

    950 % 100 = 50

    therefore:

    if experience % 100 = 0 then you know the experience is a multiple of 100.

    This won't work if they surpass the multiple of 100, going from 99 to 101 for example, so you'll have to do something a bit fancier like this:

    (Warning, some math and programming shenanigans)

    It boils down to this condition, which I will attempt to explain:

    floor( currentExp / expNeededToLevel ) > floor( oldExp / expNeededToLevel ) -> if true, level up!

    "floor()" rounds whatever is in parenthesis down to the nearest integer (whole number). So 0.9 would round to 0 -- and 1.1 would round to 1.

    "expNeededToLevel" is the amount of experience needed in order to level up (in your case this is 100).

    "oldExp" is the experience value BEFORE adding new experience.

    "currentExp" is the experience value AFTER adding new experience.

    ">" is the "greater than" operator and checks if the value on the left of it is greater than the value on the right of it, and says true (1) or false (0) about it.

    So if your character had 99 experience, then killed a bug and gained 2 experience, it would go like this:

    expNeededToLevel = 100

    oldExp = 99

    currentExp = 101 (after adding 2 for the bug)

    So if you remember the condition from above:

    floor( currentExp / expNeededToLevel ) > floor( oldExp / expNeededToLevel )

    If I plug in the values you get:

    floor(101 / 100) > floor(99 / 100)

    which reduces to:

    floor(1.01) > floor(0.99)

    after floor reduces to:

    1 > 0

    meaning "one is greater than zero" which is a true statement, so your character needs to level up!

    You can replace 100 with any number of experience you want.

    I hope this helps you.

  • Hello,

    I'm very new to Construct 2, but I'm an experienced programmer. I'm researching Construct 2 because I have an aversion to JavaScript, but I need to make a commercial web game for a business.

    I'm trying to learn how one might use Construct 2's interface to dynamically build a json string containing variables from a game session, send it to a URL, receive a json response, and access the content of the json.

    In Unity and Unreal Engine, this is a piece of cake, but those engines are too heavy for my needs, and their HTML5/JS export is still very experimental. (Plus, ya know, royalties).

    Say for instance I have a login page, with two fields: Username, Password. The user fills these in. How would I go about plugging those values into a json string, to end up with this?

    {
        login : {
            username : "abc",
            password : "123"
        }
    }
    [/code:27x0e3bh]
    
    And once I have that, I need to send it to my server and receive the json response containing an authentication token, which will be used for all subsequent requests.
    
    I will need to know if the request succeeded/failed and any associated error codes as well.
    
    Is this possible in the current version of Construct 2?
    
    Thanks.
Valhallen's avatar

Valhallen

Member since 10 Jun, 2015

None one is following Valhallen yet!

Trophy Case

  • 9-Year Club
  • RTFM Read the fabulous manual
  • Email Verified

Progress

11/44
How to earn trophies