I am trying to make a physics simulation using pygame but the collision is having problems. It gets shaky whenever there is a collision with another block because gravity is applied, but Rect collision only works when it is a pixel or more. I tried to make it so gravity = 0 for every block when it collides at a slow enough velocity, but that causes the blocks to hover due to certain collisions. Sorry for the whole file I do not even know where to start to fix my problem. import pygame import math # pygame setup pygame.init() screen = pygame.display.set_mode((1280, 720)) clock = pygame.time.Clock() running = True dt = 0 swap = 1 enemy_rect = pygame.Rect(500,500,20,20) objects= [[600,300,20,20,0,1.57,10,'blue',.2]] object=pygame.draw.rect(screen, 'blue', (600,300,20,20)) walls= [[0,700,1300,99999,0,0,99999]]#,[200,300,100,200]] while running: # poll for events # pygame.QUIT event means the user clicked X to close your window for event in pygame.event.get():...
A site where you can share knowledge