top of page

소스 코드 제출

공개·회원 52명

2025-07-25


# Example file showing a circle moving on screen
import pygame

# pygame setup
pygame.init()
screen = pygame.display.set_mode((1280, 720))
clock = pygame.time.Clock()
running = True
dt = 0

player_pos = pygame.Vector2(screen.get_width() / 2, screen.get_height() / 2)
player_pos2 = pygame.Vector2(screen.get_width() / 1.8, screen.get_height() / 2)

while running:
    # poll for events
    # pygame.QUIT event means the user clicked X to close your window
    for event in pygame.event.get():
        if event.type == pygame.QUIT:
            running = False
    a = 0
    # fill the screen with a color to wipe away anything from last frame
    screen.fill("white")
    
    pygame.draw.circle(screen, "black", player_pos, 30)
    pygame.draw.circle(screen, "blue", player_pos2, 30)

    keys = pygame.key.get_pressed()
    

    if p:
        if keys[pygame.K_w]:
            player_pos.y -= 200 * dt
        if keys[pygame.K_s]:
            player_pos.y += 200 * dt
        if keys[pygame.K_a]:
            player_pos.x -= 200 * dt
        if keys[pygame.K_d]:
            player_pos.x += 200 * dt
    else:
        if keys[pygame.K_w]:
            player_pos2.y -= 200 * dt
        if keys[pygame.K_s]:
            player_pos2.y += 200 * dt
        if keys[pygame.K_a]:
            player_pos2.x -= 200 * dt
        if keys[pygame.K_d]:
            player_pos2.x += 200 * dt

    # flip() the display to put your work on screen
    pygame.display.flip()

    # limits FPS to 60
    # dt is delta time in seconds since last frame, used for framerate-
    # independent physics.
    dt = clock.tick(60) / 1000

pygame.quit()

11회 조회
주소 : 경기도 용인시 광교중앙로 302 블루 스퀘어 602호
연락처 : 031) 216 - 1546 ,     031) 215 - 1546
사업자등록번호 : 465-92-00916
​학원 등록 제 4603호
bottom of page