inflearn logo
강의

講義

知識共有

Python無料講義(活用編1) - 思い出の娯楽ゲームを作る(3時間)

キーボードイベント

키보드 이벤트 오류

570

jamesmoon0622

投稿した質問数 1

0

- import pygame

pygame.init()


screen_width = 480
screen_height = 640
screen = pygame.display.set_mode((screen_width, screen_height))


pygame.display.set_caption("Nado game")


background = pygame.image.load("C:/Users/james/OneDrive - YutouCat/바탕 화면/python_workspace/ppygame_basic/background.png")

character = pygame.image.load("C:/Users/james/OneDrive - YutouCat/바탕 화면/python_workspace/ppygame_basic/character.png")
character_size = character.get_rect().size
character_width = character_size[0]
character_height = character_size[1]
character_x_pos = (screen_width / 2) - (character_width / 2)
character_y_pos = screen_height - character_height

to_x = 0
to_y = 0


running = True
while running:
    for event in pygame.event.get():
        if event.type == pygame.QUIT:
            running = False

        if event.type == pygame.KEYDOWN:
            if event.key == pygame.K_LEFT:
                to_x -= 5
            elif event.key == pygame.K_RIGHT:
                to_x += 5
            elif event.key == pygame.K_UP:
                to_y -= 5
            elif event.key == pygame.K_DOWN:
                to_y += 5

        if event.type == pygame.KEAUP:
            if event.key == pygame.K_LEFT or event.key == pygame.K_RIGHT:
                to_x = 0
            elif event.key == pygame.K_UP or event.key == pygame.K_DOWN:
                to_y = 0

character_x_pos += to_x
character_y_pos += to_y

    screen.blit(background, (0, 0))

    screen.blit(character, (character_x_pos, character_y_pos))

  pygame.display.update() <--
   
pygame.quit <---
 
 
이줄이 오류나요
 
 
 
 
 
 

오류 python GUI pygame

回答 1

0

Firesh

pygame.quit ->

pygame.quit()으로 작성하시면 됩니다

pygame 설치오류

0

126

1

pip install pygame 이 실패합니다

0

206

1

pip install pygame 이 안되요

0

894

1

(4:00) linting enabled 항목이 보이지 않습니다

0

157

1

마지막 프로젝트 그림 파일들을 올려주실 수는 없을까요?

0

205

1

import pygame에서 계속 오류가 발생해요

0

3581

2

무기 Y포지션 speed 감소

0

296

1

pygame 공부

0

506

0

마지막 부분 스프라이트가 맨 왼쪽에 위치해있습니다

0

266

1

공 쪼개기 문제

0

306

0

실행시 글자가 깨집니다.

0

310

1

스크린의 높이를 680으로 설정했을 때 오류?

0

295

1

pygame.time.get_ticks() 질문있습니다.

0

535

0

캐릭터의 이동

0

330

0

적(똥)과 케릭터가 충돌했을 때 게임 오버가 뜨게 만들려고..

0

299

1

시작을 하기에 앞서...

0

389

0

이미지 배경을 투명하게 하려면?

0

375

0

파이게임이 실행은 되는데....

0

229

0

실행이 안됩니다.

0

321

0

똑같이 따라 쳤는데 오류가 생겨요

0

303

0

배경색이 안 나와요

0

331

0

import pygame 실행이 안 돼요

0

2699

1

Error

0

154

0

weapon

0

227

0