0

I'm trying to clone the Tetris game and already have PyGame pick a random shape and display it. I drew an array-backed grid and 'told' PyGame to draw colored squares in certain cells in order to get the cells.

def iShape(): 
    grid [0][5] = 3 
    grid [0][6] = 3
    grid [0][7] = 3
    grid [0][8] = 3
    pygame.init()

this tells the system on which cell of the grid it will draw the square in order to get the shape.

def draw():
    allShapes = ['''all Shapes that I defined''']
    pick = random.choice (allShapes)
    ... #otherstuff
    if pick == iShape: 
        if grid[row][column] == 3:
                    color = orange
                    #draw the squares

I have been trying to think of how I could let the shapes fall slowly so the player can move/rotate them before they hit the ground but none of my ideas work out. Does anyone have a suggestion?

R Nar
  • 5,465
  • 1
  • 16
  • 32
Yuki
  • 1
  • 2
  • 1
    Where is your games mainloop? Show that code. – RobertB Nov 03 '15 at 18:13
  • @RobertB That is pretty much all I have. The rest of the code is just setting the display, drawing the grid and drawing the other shapes. – Yuki Nov 03 '15 at 18:21

2 Answers2

0

try to create a def called clock or tick(anything) and have that control the drop speed. or you could youse the in built python timer by doin inport mathand there is a command to have times so you could have then drop a pice of the grid every second or something like that sry about the brightness

0

I've found a Tetris clone called Tetromino online. I can't quite say it will work as it probably uses a different code style, but you could get an idea from it. Its at the link https://inventwithpython.com/pygame/chapter7.html

Lighform
  • 13
  • 5