dimanche 10 mars 2019

Pygame Random Coordinates Spawning

In the game I'm trying to create, I want to spawn mummies outside of the screen and have them run towards the player. The problem I'm getting is that it won't take one variable for both the x and y coordinates. How can I make it so I can use just one variable for both the x and y coordinates?

screenx = 800
screeny = 600

class enemy():
    def __init__(self, x, y, width, height):
        self.x = x
        self.y = y
        self.width = width
        self.height = height
        self.alive = False
        self.vel = 2

randomspawnabove = (random.randint(0, screenx), -100)
randomspawnbelow = (random.randint(0, screenx), (screeny + 100))
randomspawnleft = (-100, random.randint(0, screeny))
randomspawnright = ((screenx + 100), random.randint(0, screeny))

mummy_Spawn = [randomspawnleft, randomspawnright, randomspawnabove, randomspawnbelow]
mummy = enemy(random.choice(mummy_Spawn), 134, 134)




Aucun commentaire:

Enregistrer un commentaire