How do I recreate IF statements

0 favourites
  • 6 posts
From the Asset Store
Create a boss fight with this easy to follow game pack. Recreate the classic attacks of Mutoid Man from Super Smash TV
  • Still with the theme of this cave jumping game:

    I wish to generate a set of vertical platforms, that are within a certain distance of each other but also not outside the playing field, that are generated randomly each time the game is loaded (if that makes sense)

    I've come to the conclusion that I need to try to recreate an IF statement to generate a platform:

    IF platform.x < previousplatform.x - 200 OR platform.x > previousplatform.x + 200
    AND platform.x < leftboundary AND platform.x > rightboundary
    THEN regenerate platform.x
    ELSE create platform at platform.x, platform.y[/code:3h0oimej]
    Am I over complicating this? if not, how do I go about translating this into events?
    If so, how would I go about doing this?
    Here's a screenshot of my events page:
  • Hello Tia,

    I understand the frustration, but I don't fully understand what you want.

    Yet, I have fiddled around and it became somewhat bigger than I have thought.

    Hopefully this can help you further ... sp=sharing


  • ikke2902

    that is EXACTLY what I am looking for, just vertically

    any chance you could, possibly, flip that round?

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Hey Tia,

    It is perfectly possible to make it vertically with this example. I can change it, but I think it is a good opportunity to learn why this code works. This should provide sufficient information on making it vertically.

    Also remove the solid behavior from platform object and add the Jump-through behavior.

    Wish you all the best

  • Yep I see this now -- I'll let you know I get on!

  • If I wanted to enter that particular IF statement, I would enter something like this:

    Compare two values:

    first value:

    1*(platform.x < previousplatform.x - 200) + 1*(platform.x > previousplatform.x + 200) + 10*(platform.x < leftboundary) + 10*(platform.x > rightboundary)

    greater than

    Second Value: 20

    THEN regenerate platform.x

    ELSE create platform at platform.x, platform.y

    If the expression in the parentheses is true, it's value will be 1 and if false it equals 0

    Multiplied by the number in front, and then adding up the different values, both ands have to be there, so the value must be at least 20, and since you need one of the two 1s to be there, Over 20 will trigger this event as true.

    It could be simplified to

    (platform.x < previousplatform.x - 200) + (platform.x > previousplatform.x + 200) + 10*(platform.x < leftboundary) + 10*(platform.x > rightboundary)

    But I showed a multiplier in front of each because it is so versatile.

    for example as a button toggle:

    Does that make sense?

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