Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

Hi I'm trying to make a screen that will have a bunch of platforms that will place themselves randomly around a JFrame. I know how to do the stuff to make the character jump and to deal with the collisions just not a way to place the platforms on the screen randomly so they are close enough together that the character could reach. Any help is appreciated.

share|improve this question

1 Answer 1

Think of the problem in reverse. Instead of creating platforms that are randomly placed and then making sure they are withing jumping range of the player, instead create the platforms at the maximum jumping range of the player and then move them randomly. So long as all your random movements are done towards the player you are guaranteed that they will be in range.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.