How do I set random and min expressions together?

  • Hi guys. I want to make random movement of sprite in x axis. Can I use random and min expressions together?

    How the expression need to look like?

    I want random(317, 700) and something to set minimal distance sprite to move.

    Thanks for help in Advance!

  • Maybe I misunderstand, but the minimal distance of the movement already is 317. The method looks like this: random(minimum, maximum).

  • You know if I set only random from(317, 700) then its possible that 1st time the x position is 317 and next time 400 what i dont need. i want to set minimal distance between those random x. if you know what i mean.

  • that it doesnt create random x from time to time with distance smaller than 100px for example.

  • Ok here's a pretty dirty way to do it:

    [attachment=1:2qqnaum2][/attachment:2qqnaum2]

    So basicly it says: when a certain event is triggered (in this case a button is clicked), it sets a group active and in that group it generates a random number between 317 and 700 at every tick. Then it checks in the subevent if that number does NOT lie between oldLocation-100 and oldLocation+100 (meaning: it does NOT lie within range of 200px of the oldLocation). So if that's the case, it sets that good number as newLocation AND oldLocation, generates an object at that location and sets the group inactive. Until you click the button again.

    I'm sure the more experienced guys here can provide you with a better solution because this is probably not that good performance-wise.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • That's what I wanted to know!

    Thanks man for your time and work!

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