snake/apple.py
2024-07-18 16:48:01 +08:00

11 lines
322 B
Python

import random
class Apple():
def __init__(self,settings):
self.x = random.randint(1, settings.cell_w - 1)
self.y = random.randint(1, settings.cell_h - 1)
def spawn(self,settings):
self.x = random.randint(1, settings.cell_w - 1)
self.y = random.randint(1, settings.cell_h - 1)