2014-01-25 2 views
0

이벤트 (주사위 굴림)를 기반으로 서클 이동을하려고합니다. 기본적으로 주사위가 1을 굴리는 경우 카운터가 1 위로 올라갑니다.pygame - 이벤트를 기반으로 서클을 다시 그리십시오.

그러나 카운터가 제대로 작동하려면 이전 카운터가 그대로 남아 있습니다. 저는 주사위 굴림으로 55 픽셀 시간을 없애고 카운터의 흰색 버전을 다시 그려서 사라진 것처럼 보이게했습니다. 그러나 그것은 단지 작동하지 않는 것 같습니다. 여기에 코드 조각입니다 : 당신은 배경색으로 screen.fill() 이미 화면에 모든 것을 지울 수

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)) 
+0

[파이 게임 - 주사위 굴림을 기반으로 원을 만드는 방법?] (http://stackoverflow.com/questions/21341927/pygame-how-to-make-a-circle-move-based) -on-a-dice-roll) –

+0

@ BartlomiejLewandowski가 말한 것의 복제본이라고 생각합니다. 하지만 새로운 서클 집합을 그리기 전에'screen.fill()'을 실행하면 이전 인스턴스가 제거되고 새로운 서클로 교체되어야합니다. – PythonNovice

답변

관련 문제