mirror of
https://github.com/OpenBMB/ChatDev.git
synced 2024-09-18 21:57:07 +03:00
19 lines
568 B
Python
19 lines
568 B
Python
'''
|
|
This file contains the Enemy class.
|
|
'''
|
|
import pygame
|
|
import random
|
|
class Enemy:
|
|
def __init__(self):
|
|
self.x = random.randint(0, 750)
|
|
self.y = random.randint(50, 200)
|
|
self.width = 50
|
|
self.height = 50
|
|
self.velocity = random.randint(1, 2)
|
|
def update(self):
|
|
self.y += self.velocity
|
|
if self.y > 600:
|
|
self.y = random.randint(50, 200)
|
|
self.x = random.randint(0, 750)
|
|
def draw(self, window):
|
|
pygame.draw.rect(window, (0, 0, 255), (self.x, self.y, self.width, self.height)) |