StudyRepo_Synergy/part2_OOP/lesson6/snake/food.py

26 lines
569 B
Python

import os
import random
import pygame as pg
class Food:
FOOD = (
pg.image.load(os.path.join(os.curdir, 'snake', 'img', 'mouse1.png')),
pg.image.load(os.path.join(os.curdir, 'snake', 'img', 'mouse2.png'))
)
def __init__(self) -> None:
self.x = random.randint(0, 25) * 30
self.y = random.randint(0, 19) * 30
self.type = random.choice(self.FOOD)
def draw(self, screen):
screen.blit(self.type, (self.x, self.y))
def get_coords(self):
return self.x, self.y