https://www.dropbox.com/s/tnnrbesnh5irj ... .capx?dl=0 - I am working on the mechanics of a simple running platformer game, however have a small issue which I cannot figure out. In step9, the y-coordinate of the block is set at random(LayoutHeight - self.height). Is there a way to change that to depend on the previous y-coordinate of the block? example can only be 100px above or below previous position?
Develop games in your browser. Powerful, performant & highly capable.
You would need to store the previous position.Y in a variable and then use the < and > in condition for next spawn...
Can you explain the second part further, I have stored the y position as a global variable. However I don't know how to do the second part.
I guess instead of:
random(LayoutHeight - self.height)
You'd use
random(Oldposition-100,Oldposition+100)
Thanks a lot For some reason I thought random values can only be between 0 and another number.
You have to remember the variable is holding a number value in this case so it can be randomized as well.