Created
August 24, 2018 04:57
-
-
Save shiroutosan/9236d7fee5e044663ddd109c570972a0 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
while (1): | |
screen.fill((100,100,255)) # ウィンドウ内の色の設定 | |
frame += 2 | |
clock.tick(120) | |
pressed_keys = pygame.key.get_pressed() # 押されたキーを取得 | |
if pressed_keys[K_LEFT]: | |
mame.direction = 12 # プレイヤーの向きを左向きにセット | |
if mame.x > 0: # 画面左端から出ないようにブロック | |
mame.x -= vx # 座標の更新 | |
if pressed_keys[K_RIGHT]: | |
mame.direction = 4 # プレイヤーの向きを右向きにセット | |
if mame.x<400-32: # 画面右端から出ないようにブロック | |
mame.x+=vx | |
if pressed_keys[K_UP]: | |
mame.direction = 8 # プレイヤーの向きを上向きにセット | |
if mame.y>0: # 画面上端から出ないようにブロック | |
mame.y-=vy | |
if pressed_keys[K_DOWN]: | |
mame.direction = 0 # プレイヤーの向きを下(正面)向きにセット | |
if mame.y<320-32: # 画面下端から出ないようにブロック | |
mame.y+=vy | |
# 描画 | |
playerImg = mame.imagelist[int(frame / animcycle) % 4 + mame.direction] | |
screen.blit(playerImg,(mame.x,mame.y)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment