pythonでこのコードを入力するとエラーがでてきます
出てくるエラーはこれです```Traceback (most recent call last):
File "<stdin>", line 1, in <module>
NameError: name 'p154' is not defined
解決策を教えていただきたいですまたそのほかにこのコードで間違っているところがありましたら教えていただきたいです ```"""cave - Copyright 2016 Kenichiro Tanaka """ import sys from random import randint import pygame from pygame.locals import QUIT,Rect,KEYDOWXN,K_SPACE pygame.init() pygame.key.set_repeat(5,5) SURFACE = pygame.display.set_mode((800,600)) FPSCLOCK = pygame.time.Clock() def main(): """ メインルーチン """ walls = 80 ship_y = 250 velocity = 0 score = 0 slope = randint(1,6) sysfont = pygame.font.SysFont(None,36) ship_image = pygame.image.load("ship.png") bang_image = pygame.image.load("bang.png") holes = [] for xpos in range(walls): holes.append(Rect(xpos * 10, 100, 10, 400)) game_over = False while True: is_space_down = False for event in pygame.event.get(): if event.type == QUIT: pygame.quit() sys.exit() elit event.type == KEYDOWN: if event.key == K_SPACE: is_space_down = True #時機を移動 if not game_over: score += 10 velocity += -3 if is_space_down else 3 ship_y += velocity #洞窟をスクロール edge = holse[-1].copy() test = edge.move(0,slope) if test. top <= 0 or test.bottem >= 600: slope = randint(1,6) * (-1 if slope > 0 else 1 edge.inflate_ip(0, -20) edge.move_ip(10,slope) holes.append(edge) del holse[0] holse = [x.move(-10,0) for x in holse] #衝突? if holse[0].top > ship_y or \ holse[0].bottom <ship_y + 80: game_over = True #描画 SURFACE.fill((0, 255, 0)) for hole in holse: pygame.draw.rect(SURFACE, (0, 0, 0), hole) SURFACE.blit(ship_image, (0, ship_y)) score_image = sysfont.remder("score is {}".format(score), True, (0, 0, 225)) SURFACE.blit(score_image, (600, 20)) if game_over: SURFACE.blit(bang_image, (0, ship_y-40)) pygame.display.update() FPSCLOCK.tick(15) if __name__ == '__main__': main()
code表記を使って見やすくしてください
また、ソースコードは全文を記載してください
回答1件
あなたの回答
tips
プレビュー