How can I ensure reasonably spaced out enemies
Posted
by
Samuraisoulification
on Game Development
See other posts from Game Development
or by Samuraisoulification
Published on 2013-11-08T21:08:36Z
Indexed on
2013/11/08
22:18 UTC
Read the original article
Hit count: 164
JavaScript
|random
I have a simple javascript game and I'm initializing their positions on the y axis using random numbers. How can I ensure that they are reasonably spaced apart? My simple algorithm is:
y = (Math.random()*1000%600);
However I frequently get enemies almost directly on top of each other. This is a huge problem for the game, since it's a word game and the enemies have text on their center, that if overlapped makes them impossible to kill since you can't see the words. Any advice would be appreciated! I'm pretty new to making games in general so this has all been a learning experience for me!
© Game Development or respective owner