I made a system player movement system that works well with a rectangle but when I change it to a circle it just stops working!
import pygame as pg
# making screen
screen = pg.display.set_mode((500, 500))
# making clock to count ticks
clock = pg.time.Clock()
# making a rectangle
rect = pg.Rect(200, 400, 100, 10)
circ = pg.draw.circle(screen, (0, 255, 0), [300, 300], 10, 0)
speed = 6
done = False
while not done:
for event in pg.event.get():
if event.type == pg.QUIT:
done = True
# moving the rectangle with player input
keys = pg.key.get_pressed()
if keys[pg.K_a] and not rect.x <= 0:
rect.x -= speed
if keys[pg.K_d] and not rect.x >= 400:
rect.x += speed
if keys[pg.K_s] and not rect.y >= 480:
rect.y += speed
if keys[pg.K_w] and not rect.y <= 320:
rect.y -= speed
if keys[pg.K_t]:
circ.y -= speed
screen.fill((40, 40, 40))
pg.draw.rect(screen, (150, 200, 20), rect)
pg.draw.circle(screen, (0, 255, 0), [300, 300], 10, 0)
pg.display.flip()
clock.tick(30)
I only want to move the circle with the 't' key