arctic-masher/blocks.py

23 lines
714 B
Python
Raw Normal View History

import pygame
from constants import *
2023-05-17 11:04:10 +00:00
class Block:
def __init__(self, x, y, gameMap):
self.x = x
self.y = y
self.gameMap = gameMap
self.sprite = pygame.Rect((x*tile) + 2, (y*tile) + 2, tile - 2, tile - 2)
2023-05-17 11:04:10 +00:00
def move(self, x, y, caller=False):
try:
if self.gameMap[self.x + x][self.y + y]:
self.gameMap[self.x + x][self.y + y].move(x, y, caller=self)
self.gameMap[self.x][self.y] = 0
self.x += x
self.sprite.x = (self.x*tile)+2
2023-05-17 11:04:10 +00:00
self.y += y
self.sprite.y = (self.y*tile)+2
2023-05-17 11:04:10 +00:00
self.gameMap[self.x][self.y] = self
except Exception as error:
raise error