+ 1

How Do You Create Infinite Obstacles in a game using Java?

I’m creating a program in Java rather similar to Flappy Bird, (mainly using StdDraw) where there’s repetitive obstacle that you have get past (like the pipes in flappy bird). My question is, how do I make it so as the player moves along, more and more obstacles are generated?

19th Jan 2018, 11:05 PM
Michael Sluck
Michael Sluck - avatar
2 Réponses
+ 3
I am not a prodigy in Java, but my guess is to implement a loop that keeps looping infinitely with random results, results being the obstacles! 👍
20th Jan 2018, 12:10 AM
Dread
Dread - avatar
+ 2
Depending on long long your processing loop takes, you could use timer events to insert the next obstacle for short loop times. For longer loop times, call a function every place it is needed for the hardest level. In the function, decide whether a obstacle should be generated. Say you want the easiest to be every 40 or so calls. Add a random adjust of +5 to -5 range and count until you reach it. Adjust until it feels right.
20th Jan 2018, 12:24 AM
John Wells
John Wells - avatar