1
나는 움직이는 원을 만들려고 노력하고 있지만 어떻게 작동시키는 지 모릅니다. 나는 파이 게임을 패키지로 사용하고 있습니다. 서클을 업데이트하면 제대로 작동한다고 생각하지만 어떻게해야할지 모르겠다.어떻게 파이썬에서 원을 이동합니까?
import os, sys, math, pygame, pygame.mixer
from pygame.locals import *
black = (0,0,0)
red = (255,0,0)
green = (0,255,0)
blue = (0,0,255)
white = (255,255,255)
run_me = True
screen_size = screen_width, screen_height = 600, 400
screen = pygame.display.set_mode(screen_size)
pygame.display.set_caption('ha ha ha ha ha')
clock = pygame.time.Clock()
fps_limit = 60
#circle
colorcircle = (red)
posx = 300
posy = 200
circle = pygame.draw.circle(screen, colorcircle, (posx, posy), 50)
while run_me:
clock.tick(fps_limit)
for event in pygame.event.get():
if event.type == pygame.QUIT:
run_me = False
if event.type == pygame.KEYDOWN:
if event.key == pygame.K_LEFT:
posx = posx - 10
if event.type == pygame.KEYDOWN:
if event.key == pygame.K_RIGHT:
posx = posx + 10
if event.type == pygame.KEYDOWN:
if event.key == pygame.K_UP:
posy = posy + 10
if event.type == pygame.KEYDOWN:
if event.key == pygame.K_DOWN:
posy = posy - 10
pygame.display.flip()
pygame.quit()
입력에 따라 어딘가에 서클 이동을 원합니다.
그러나 원은 아무 것도하지 않습니다!