I would like to create a connect 4 program. Everything is fine but I would like to animate the falling of the bricks.
A quick and dirty solution is working fine (Brick is falling in front of the grid) but I would like the falling of the bricks behind the grid.
I found something in the net (how to make circular surface in pygame).
import pygame
pygame.init()
window = pygame.display.set_mode((750, 750))
color = (255,255,255)
run = True
z = 20
while run:
z += 5
#print(z)
background = pygame.Surface(window.get_size())
pygame.draw.rect(background, color, (10, 10 + z, 100, 100))
size = background.get_size()
cropped_background = pygame.Surface(size, pygame.SRCALPHA)
for x in range(5):
for y in range(5):
pygame.draw.ellipse(cropped_background, (255,255,255,255), (((x*100) + (x*10) +10) , ((y*100) + (y*10) +10), 100,100))
cropped_background.blit(background, (0, 0), special_flags=pygame.BLEND_RGBA_MIN)
window.fill(255)
window.blit(cropped_background, (0, 0))
pygame.display.update()
Can someone explain me why it is going into freeze mode and have a solution for me?
But if I animate this, python is going into freeze mode after a couple of seconds.