Example #1
0
 def draw_figure(x, y, game_field, position):
     i = int(y / 30)
     j = int(x / 30)
     if position == 1:
         Rectangle.draw_rectangle_purple(x, y)
         Rectangle.draw_rectangle_purple(x + 30, y)
         Rectangle.draw_rectangle_purple(x + 60, y)
         Rectangle.draw_rectangle_purple(x + 30, y - 30)
         game_field[i][j] = 4
         game_field[i][j + 1] = 4
         game_field[i][j + 2] = 4
         game_field[i - 1][j + 1] = 4
     elif position == 2:
         Rectangle.draw_rectangle_purple(x, y - 30)
         Rectangle.draw_rectangle_purple(x + 30, y)
         Rectangle.draw_rectangle_purple(x + 30, y - 30)
         Rectangle.draw_rectangle_purple(x + 30, y - 60)
         game_field[i - 1][j] = 4
         game_field[i][j + 1] = 4
         game_field[i - 1][j + 1] = 4
         game_field[i - 2][j + 1] = 4
     elif position == 3:
         Rectangle.draw_rectangle_purple(x, y - 30)
         Rectangle.draw_rectangle_purple(x + 30, y)
         Rectangle.draw_rectangle_purple(x + 60, y - 30)
         Rectangle.draw_rectangle_purple(x + 30, y - 30)
         game_field[i - 1][j] = 4
         game_field[i][j + 1] = 4
         game_field[i - 1][j + 2] = 4
         game_field[i - 1][j + 1] = 4
     elif position == 4:
         Rectangle.draw_rectangle_purple(x + 60, y - 30)
         Rectangle.draw_rectangle_purple(x + 30, y)
         Rectangle.draw_rectangle_purple(x + 30, y - 30)
         Rectangle.draw_rectangle_purple(x + 30, y - 60)
         game_field[i - 1][j + 2] = 4
         game_field[i][j + 1] = 4
         game_field[i - 1][j + 1] = 4
         game_field[i - 2][j + 1] = 4
Example #2
0
 def draw_if_next(x, y):
     Rectangle.draw_rectangle_purple(x, y)
     Rectangle.draw_rectangle_purple(x + 30, y)
     Rectangle.draw_rectangle_purple(x + 60, y)
     Rectangle.draw_rectangle_purple(x + 30, y - 30)
Example #3
0
File: app.py Project: kveron/tetris
 clock.tick(FPS)
 if TIMER == 0 and (int(time.time() - timing)) % 20 == 0:
     if SPEED <= 3:
         SPEED = 3
     SPEED -= 1
 for i in range(30, 540, 30):
     for j in range(30, 320, 30):
         if game_field[int(i / 30)][int(j / 30)] == 0:
             Rectangle.draw_rectangle_background(j, i)
         # после сдвига цвет у фигур останется тем же
         elif game_field[int(i / 30)][int(j / 30)] == 2:
             Rectangle.draw_rectangle_blue(j + 15, i + 15)
         elif game_field[int(i / 30)][int(j / 30)] == 3:
             Rectangle.draw_rectangle_yellow(j + 15, i + 15)
         elif game_field[int(i / 30)][int(j / 30)] == 4:
             Rectangle.draw_rectangle_purple(j + 15, i + 15)
         elif game_field[int(i / 30)][int(j / 30)] == 5:
             Rectangle.draw_rectangle_red(j + 15, i + 15)
         elif game_field[int(i / 30)][int(j / 30)] == 6:
             Rectangle.draw_rectangle_orange(j + 15, i + 15)
         elif game_field[int(i / 30)][int(j / 30)] == 7:
             Rectangle.draw_rectangle_green(j + 15, i + 15)
         elif game_field[int(i / 30)][int(j / 30)] == 8:
             Rectangle.draw_rectangle_light_blue(j + 15, i + 15)
 pygame.draw.rect(background, (200, 200, 200), (390, 200, 150, 200), 1)
 pygame.draw.rect(background, BACKGROUND_COLOR, (391, 201, 148, 198))
 if figure == 1:
     IFigure.IFigure.draw_figure(x, y, game_field, position)
 elif figure == 2:
     OFigure.OFigure.draw_figure(x, y, game_field)
 elif figure == 3: