import pygame
import sys
import random
import time
pygame.init()
win = pygame.display.set_mode((800, 800))
white = (200, 200, 200)
red = (220, 51, 102)
green = (120, 120, 200)
black = (0, 0, 0)
class Hunter:
white = pygame.Color(220, 100, 100)
def __init__(self, x, y, h, w, color):
self.x = x
self.y = y
self.h = h
self.w = w
self.color = color
def hunter_show(self):
pygame.draw.rect(win, (self.color), (self.x, self.y, self.h, self.w))
'''def huner_move(self, x, y):
self.x = x
self.y = y'''
class Ex:
def __init__(self, x, y, h, w, color):
self.x = x
self.y = y
self.h = h
self.w = w
self.color = color
def ex_show(self):
pygame.draw.rect(win, (self.color), (self.x, self.y, self.h, self.w))
def ex_position(self, x, y):
self.x = x
self.y = y
h_color = red
hunter_1 = Hunter(1, 1, 5, 5, h_color)
while True:
color = white
pos_x_rand = random.randint(1, 790)
pos_y_rand = random.randint(1, 790)
time.sleep(0.007)
exl = Ex(pos_x_rand, pos_y_rand, 3, 3, color)
for event in pygame.event.get():
if event.type == pygame.QUIT:
sys.exit()
if hunter_1.x < pos_x_rand:
hunter_1.x += 1
if hunter_1.y < pos_y_rand:
hunter_1.y += 2
if hunter_1.y > pos_y_rand:
hunter_1.y -= 2
if hunter_1.x > pos_x_rand:
hunter_1.x -= 1
if hunter_1.x == pos_x_rand:
color = black
if hunter_1.y == pos_y_rand:
color = black
exl.ex_show()
hunter_1.hunter_show()
pygame.display.update()