How do I recreate IF statements

Get help using Construct 2

Post » Sun Aug 23, 2015 5:17 pm

Still with the theme of this cave jumping game:
https://www.scirra.com/forum/viewtopic.php?f=147&t=151936

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:

Code: Select all
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


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:
Image

ANY HELP WOULD BE APPRECIATED! I AM TEARING MY HAIR OUT!

TIA
B
6
Posts: 30
Reputation: 298

Post » Sun Aug 23, 2015 7:50 pm

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
https://drive.google.com/file/d/0B_ZRhC ... sp=sharing

ikke2902
It's time for me to return the favor :)
B
32
S
9
G
9
Posts: 132
Reputation: 5,370

Post » Mon Aug 24, 2015 6:55 am

ikke2902

that is EXACTLY what I am looking for, just vertically
any chance you could, possibly, flip that round?
B
6
Posts: 30
Reputation: 298

Post » Mon Aug 24, 2015 7:19 am

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 :D
It's time for me to return the favor :)
B
32
S
9
G
9
Posts: 132
Reputation: 5,370

Post » Mon Aug 24, 2015 8:39 pm

Yep I see this now -- I'll let you know I get on!
B
6
Posts: 30
Reputation: 298

Post » Tue Aug 25, 2015 2:35 am

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:
Image

Does that make sense?
B
233
S
62
G
33
Posts: 902
Reputation: 40,398


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 48 guests