I need to find a method using which I can ensure that random enemies and objects don't spawn just near the player. In fact, if they do, the player will be more likely to collide with them and lose.
These enemies and objects spawn relatively to the player's score and to some userevents.
I've tried to use a recursive function in these objects' classes in order to check whether the object's coordinates obey to the condition that they shouldn't be near the player's coordinates and if they are valid (they obey to that condition), I can blit their images to the screen.
But I found that this idea isn't a good one and demands lots of code so I abandonned it.
So is there any other method to implement that ?
NOTE :
Enemies coordinates are generated randomly like this:
self.x = random.randrange(2, 502, 20)
self.y = random.randrange(2, 502, 20)
Then, they're blitted to the screen at these coordinates :
screen.blit(myenemy.img, (self.x, self.y))