I want to create copies of the same object with random sizes, but I don't want their proportions to be distorted.
35 + (random 20)
40 + (random 20)
35 and 40 are the original dimensions. The problem is that unless both random numbers are the same the image either looks squished or stretched.
Is there a way to generate a random number and then add/subtract that number to another value?
(could it be done with global or private variables? that's the only way I imagine it would work but I'm not entirely sure how to do it in this case...)
Develop games in your browser. Powerful, performant & highly capable.
You probably should use some basic math for this.
35/40 is 0.875... your ratio basically.
Then set sprite.width to 40 + random(X)
and in the following action you set sprite.height to sprite.width*0.875.
That should work. Remember you will not really get random sizes this way since you're only adding a random number to the size. You should use + random(X) - random(X) or something. Unless you want only bigger versions of course.
Thank you Pixel, I'll give that a try.
(never mind... my project .cap is working perfectly now! )