random size, keep proportions

This forum is currently in read-only mode.
From the Asset Store
A versatile and wide-ranging selection of large to medium-sized creature sounds.
  • hi guys!

    i have a feeling this is a complete noob question, but i really didnt find anything about it:

    i want to create object randomly on a layer, this works fine enough, no problems.

    but i also want to randomly set the size of the object while keeping its proportions. now, i cant find a simple set size action anywhere, i can only find set width and set height, but if i try to randomly set those upon creation, it doesnt keep the sprites proportions, instead, it can make for example width 50pixels, height 90pixels. and id want to keep them both the same amount. is there any simple enough solution i just cant figure out, being noob and all? <img src="smileys/smiley9.gif" border="0" align="middle" />

    also, to make things more interesting, how can i make a random value between two values?

    for example if i want to give a sprite a random size between the sizes 50pixels and 90pixels?

    small bonus question:

    ive been tinkering around with physics hinges, and already made some pretty neat stuff with it, but i still cant figure the basic logic behind hinges.

    for example, if i create hinge from sprite a to sprite b, how can i make it so that the sprite b is also stiff? meanin that it would keep the angle relative to what it is upon creating hinge?

    do i have to make hinges for both, sprite a and b?

    thats all right, but it could get rather tedious when doing alot of hinges together.

    little example:

    if you make a car, 3 parts:

    one body, two wheels. you have to make hinges FROM the body to the wheels, and that kind of confuses me. somehow i think it would be the complete opposite.

    the mass is also something that puzzles me. if i made a say, simple ragdoll, with torso having the biggest mass, so i could apply force to hands, without it affecting the movement of the torso too much, what happens is that when moving the torso, the limbs that have smaller mass start to sort of act erratic, the hinges wont keep their position locked and they act "rubbery" even though having 100 stiffness.

    anyone care to educate me? <img src="smileys/smiley36.gif" border="0" align="middle" />

  • A simple solution for your proportion problem would be to only make either the width or the height random and not both. For example, if the original sprite is 50px wide and 30px high you can make the width random and then make the height equal to Sprite.Width*0.6 This will keep it proportional.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • also, to make things more interesting, how can i make a random value between two values?

    for example if i want to give a sprite a random size between the sizes 50pixels and 90pixels?Just add the offset to random() and use the range+1 in random. For example:

    50 + random(41) => creates a random number in range [50, 90]

    23 + random(101) => creates a random number in range [23, 123]

  • set Var = Sprite.X / Sprite.Y (so you have proportions now)

    Sprite.X = Random(whatyouprefer) + minimumwidth

    Sprite.Width / Var

    This will keep it proportional.

    Can be a bit wrong (but i dont think so), anyway you've got the idea

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