Example #1
0
	def initiateSquares(self):
		#add squares to list
		for i in range(Tetromino.number_of_squares):
			s = Square()
			self.squares.append(s)
		#set position
		for s in self.squares:
			s.setPosition([self.x, self.y])
Example #2
0
# 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")

#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
Example #3
0
from Classes.Zshape import *
from Classes.Sshape import *
from Classes.Jshape import *
from Classes.Lshape import *
from Classes.Pshape import *

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
Example #4
0
from Classes.Lshape import *
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
Example #5
0
	def add(self, tetromino):
		for s in tetromino.squares:
			#t = copy.deepcopy(s)
			x = Square()
			x.copy(s)
			self.squares.append(x)
Example #6
0
# 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()

# 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()
Example #7
0
from Classes import Rectangle, Square, Circle

rect_1 = Rectangle(3, 4)
rect_2 = Rectangle(12, 5)

print(rect_1.get_area())
print(rect_2.get_area())
print()

sq_1 = Square(5)
sq_2 = Square(10)

print(sq_1.get_area_square())
print(sq_2.get_area_square())
print()

ci_1 = Circle(6)
ci_2 = Circle(9)

print(ci_1.get_area_circle())
print(ci_2.get_area_circle())
print()

figures = [rect_1, rect_2, sq_1, sq_2, ci_1, ci_2]
for figure in figures:
    if isinstance(figure, Square):
        print(figure.get_area_square())
    elif isinstance(figure, Circle):
        print(figure.get_area_circle())
    else:
        print(figure.get_area())
Example #8
0
from Classes import Rectangle, Square, Circle

rect_1 = Rectangle(3, 4)
rect_2 = Rectangle(12, 5)

sqre_1 = Square(5)
sqre_2 = Square(10)

cirl_1 = Circle(3)
cirl_2 = Circle(7)

figures = [rect_1, rect_2, sqre_1, sqre_2, cirl_1, cirl_2]

for figure in figures:
    if isinstance(figure, Rectangle):
        print('Площадь прямоугольника:', figure.get_area_rec())
    elif isinstance(figure, Square):
        print('Площадь квадрата:', figure.get_area_sqr())
    else:
        print('Площадь круга:', figure.get_area_cir())