This is for pygame
Block class:
The Block class inherits from Drawable and it will draw a square with a black outline at its current location. You must implement at the very least the required methods of the base class (draw and get_rect), as well as a constructor. You may need to implement other methods as part of the public interface.
This is the drawable class
import pygame
import abc
import random
class Drawable(metaclass=abc.ABCMeta):
def __init__(self, x=0, y=0):
self.x = x
self.y = y
self.position = (self.x, self.y)
self.visible = False
def setloc(self, p):
self.x = p[0]
self.y = p[1]
def getLoc(self):
return (self.x, self.y)
def getx(self):
return self.x
def getY(self):
return self.y
@abc.abstractmethod
def draw(self, surface):
pass
@abc.abstractmethod
def get_rect(self):
pass