Reputation: 337
I'm trying to make a circle move based on a event (dice roll). Basically if the dice rolls a 1, the counter moves up 1 etc.
However I can't get the counter to move properly as it leaves the old counter there. I've tried taking away 55 pixels times by the dice roll to re-draw a white version of the counter to make it seem like it's gone. But it just doesn't seem to work. Here's a snippet of code:
while True:
screen.blit(moveCounter, [665, 70])
counter1 = pygame.draw.circle(screen, white, circle_pos, 15, 0)
counter1 = pygame.draw.circle(screen, red, circle_pos2, 15, 0)
pygame.display.update()
for event in pygame.event.get():
if event.type==pygame.KEYDOWN and event.key==pygame.K_SPACE:
diceRoll = random.randint(1,5)
diceAlert = font.render("You rolled a: "+str(diceRoll), True, red)
moveCounter = font.render("Please click 1 or 2 to select the counter", True, red)
if event.type==pygame.KEYDOWN and event.key==pygame.K_1:
if diceRoll == 1:
cover = int(0)
if diceRoll in (2,3):
cover = int(2)
if diceRoll == 4:
cover = int(3)
circle_pos = (250, 580-(cover*55))
Upvotes: 0
Views: 100
Reputation: 122157
You can screen.fill()
with the background colour to erase everything already on the screen; see the introductory documentation.
Upvotes: 2