How Do You Write A Break In A Coordinate

0 favourites
  • 7 posts
From the Asset Store
Game with complete Source-Code (Construct 3 / .c3p) + HTML5 Exported.
  • Say I want to spawn an object on an X coordinate but there is a specific spot I don't want it to spawn, how would I write that expression? Is it possible?

    IE " random(95,210) and random(350,450) "

    would It be written as random(95,210 : 350,450)

    OR

    random(95,210 * 350,450)

    Or is there another way to write it out?

  • You could do something like:

    choose(random(95,210), random(350,450))

  • Thanks that worked. But I now have an even trickier question. Would It be possible to add the Y coordinates and say hypothetically I want to spawn an object in either the bottom left corner or the top right corner, would that be possible?

    perhaps it might look something like:

    X - choose(random(95,210),random(350,450))

    Y - choose(random(900,1000),random(300,500))

    (unfortunately, I think this would mix and match the possibilities, rather than keeping it "bottom left and top right")

  • How could I get an object to spawn in either section "A" or "B"?

    Section A

    X - 400~600 and Y - 300~500

    Section B

    X - 100~300 and Y - 1000~1100

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • You can do something like this using sub events and else. It should be straightforward.

    start of layout
    -- compare: choose(0,1)=0
    -- -- create at 300,400
    -- else
    -- -- create at 100,100

    You could do it slightly different with mostly equations but the result would be the same. I typically go for whatever is easier for me to read.

    var section=0
    
    start of layout
    -- set section to choose(0,1)
    -- create at 0,0
    -- set x to section?300:100
    -- set y to section?400:100
  • If I understand enough pair random is what you are after. Token approach would be the practical thing to take into account so we just need to random the token order. Incorporate dictionary would be ease storing those "key" coordinates but hey let's just store them as text variable. See what I mean:

    dropbox.com/s/9txbhwr8ai60fpr/pair_random.capx

    In the example I created 3 main spot area as spawn point within their pair coordinates.

  • Thanks for the responses!

    I think I understand what R0J0hound is saying, but unfortunately alextro, yours seems a bit beyond me.

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