亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

如何制作蟒蛇游戲,撲騰鳥的煙斗出現?

如何制作蟒蛇游戲,撲騰鳥的煙斗出現?

叮當貓咪 2022-09-13 10:09:00
我用Python構建的NEAT系統創建了一個Flappy Bird游戲,遵循YouTube上的本教程:技術與蒂姆當我完成所有代碼時,他運行它并使游戲正常運行,我的代碼沒有在屏幕上顯示管道。我的代碼如下:import pygame, neat, time, os, random##import all of the variables we'll need for AI runningpygame.font.init()##enables using fonts/text on screen.WIN_WIDTH = 500WIN_HEIGHT = 800##define the size of the window. We're working with a GUI for flappy bird AI.BIRD_IMGS = [pygame.transform.scale2x(pygame.image.load(os.path.join("imgs", "bird1.png"))), pygame.transform.scale2x(pygame.image.load(os.path.join("imgs", "bird2.png"))), pygame.transform.scale2x(pygame.image.load(os.path.join("imgs", "bird3.png")))]##import the images of the bird from the images directory. There are three as to make up the states of flapping.PIPE_IMG = pygame.transform.scale2x(pygame.image.load(os.path.join("imgs", "pipe.png")))##import the texture for the pipes from the same directory.BASE_IMG = pygame.transform.scale2x(pygame.image.load(os.path.join("imgs", "base.png")))BG_IMG = pygame.transform.scale2x(pygame.image.load(os.path.join("imgs", "bg.png")))##repeat for the ground and the background. They are seperate pieces as to allow for handling the collision with the ground being death.STAT_FONT = pygame.font.SysFont("comicsans", 50)class Bird: ##define the bird and its system as a class.    IMGS = BIRD_IMGS ##easier system for calling back to our list of bird images    MAX_ROTATION = 25    ROT_VEL = 20    ANIMATION_TIME = 5    ##some definitions to do with making sure the bird can't just start spinning around aimlessly instead of looking like it should be going forward.    def __init__(self, x, y): ##essentially telling the AI/game what the bird starts out as, and how to define each thing.        self.x = x ##the distance forward on the screen        self.y = y ##how high up on the screen the bird is        self.tilt = 0 ##the angle the bird is at        self.tick_count = 0 ##essentially handles all of the physics        self.vel = 0 ##speed. 
查看完整描述

1 回答

?
紅糖糍粑

TA貢獻1815條經驗 獲得超6個贊

你已經縮進了太多次了。它應該是pipe.move()


if pipe.x + pipe.PIPE_TOP.get_width() < 0: 

    rem.append(pipe)

pipe.move() #enable pipe movement.


查看完整回答
反對 回復 2022-09-13
  • 1 回答
  • 0 關注
  • 82 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號