def __init__(self): """ Setup variables in Grid class. """ self.x = 3 self.y = 3 self.shape = Tetromino() self.shape = Ishape() self.shape = Oshape() self.shape.setImageOff() self.grid = TGrid() self.ghost = Pshape() self.ghost.setColorOff() self.ghost.setMaskOff() #self.ghost.setImage("Images/circle_r16.png") self.ghost.setImage("Images/square_phantom32x32.png") #self.next = NextPanel() #self.hold = HoldPanel() #self.score = ScorePanel() #self.stats = StatisticsPanel() self.shape.setBase(self.grid.getPosition()) self.ghost.setBase(self.grid.getPosition()) #default controls self.left = pygame.K_LEFT self.right = pygame.K_RIGHT self.down = pygame.K_DOWN self.up = pygame.K_UP self.cw = pygame.K_x self.ccw = pygame.K_z self.space = pygame.K_SPACE self.debug = pygame.K_p
def setShape(self, type): #print("method: setShape(): type = ", type) s = Tetromino() if type == 'P': s = Pshape() elif type == 'L': s = Lshape() elif type == 'J': s = Jshape() elif type == 'S': s = Sshape() elif type == 'Z': s = Zshape() elif type == 'I': s = Ishape() elif type == 'O': s = Oshape() elif type == 'T': s = Tshape() return s
BLACK = (0, 0, 0) WHITE = (255, 255, 255) GREEN = (0, 255, 0) RED = (255, 0, 0) pygame.init() # Set the width and height of the screen [width, height] size = (700, 500) screen = pygame.display.set_mode(size) pygame.display.set_caption("My Game") #Shapes Being Tested square = Square() tetromino = Tetromino() shape = Sshape() # Loop until the user clicks the close button. done = False # Used to manage how fast the screen updates clock = pygame.time.Clock() # -------- Main Program Loop ----------- while not done: # --- Main event loop for event in pygame.event.get(): if event.type == pygame.QUIT: done = True elif event.type == pygame.MOUSEBUTTONDOWN:
from Classes.Pshape import * todoList = "Next todo: TGrid.clearFullLines " print(todoList) pygame.init() # Set the width and height of the screen [width, height] size = CONSTANTS.WINDOW_SIZE screen = pygame.display.set_mode(size) pygame.display.set_caption("My Game") #Shapes Being Tested square = Square() tetromino = Tetromino() shape = Pshape() #Background background = Background(size) #Grid grid = TGrid() grid.centerXposition(size) #set position of squares #square.setBase(grid.getPosition) square.base_x = grid.x square.base_y = grid.y shape.setBase([grid.x, grid.y])
# Define some colors BLACK = (0, 0, 0) WHITE = (255, 255, 255) GREEN = (0, 255, 0) RED = (255, 0, 0) pygame.init() # Set the width and height of the screen [width, height] size = (700, 500) screen = pygame.display.set_mode(size) pygame.display.set_caption("My Game") square = Square() tetromino = Tetromino() # Loop until the user clicks the close button. done = False # Used to manage how fast the screen updates clock = pygame.time.Clock() # -------- Main Program Loop ----------- while not done: # --- Main event loop for event in pygame.event.get(): if event.type == pygame.QUIT: done = True elif event.type == pygame.MOUSEBUTTONDOWN: square.moveDown()
def randomShape(self): x = randrange(8) #print("method: randomShape(): randValue = ", x) s = Tetromino() if x == 0: s = Pshape() elif x == 1: s = Lshape() elif x == 2: s = Jshape() elif x == 3: s = Sshape() elif x == 4: s = Zshape() elif x == 5: s = Ishape() elif x == 6: s = Oshape() elif x == 7: s = Tshape() s.setImageOff() s.setBase(self.grid.getPosition()) return s