会员可以在此提问,百战程序员老师有问必答
对大家有帮助的问答会被标记为“推荐”
看完课程过来浏览一下别人提的问题,会帮你学得更全面
截止目前,同学们一共提了 132369个问题
Python 全系列/第一阶段:Python入门/Python入门(动画版) 2836楼
Python 全系列/第十五阶段:Python 爬虫开发/爬虫反反爬 2838楼
Python 全系列/第十五阶段:Python 爬虫开发/爬虫反反爬 2839楼

屏幕截图 2023-11-29 233501.png

老师你好,我和这位同学的问题一样,找不到这个包,但是我从Project Interpreter里加号自行安装了这个包,并且又在这个项目的环境变量里添加了这个路径,还是不能编译成功然后运行,但是我直接双击turtle这个脚本文件就可以出现刚刚实现的代码。

Python 全系列/第一阶段:Python入门/Python入门(动画版) 2842楼

屏幕截图 2023-11-29 222223.png

Python 全系列/第六阶段:生产环境部署与协同开发/Linux使用操作 2843楼
Python 全系列/第二阶段:Python 深入与提高/文件处理 2844楼
Python 全系列/第十阶段:Flask百战电商后台项目/Flask百战电商后台项目 2845楼
Python 全系列/第九阶段:前端进阶-高效开发Vue框架/ES6新特性 2846楼
Python 全系列/第九阶段:前端进阶-高效开发Vue框架/Vue3 2847楼
Python 全系列/第一阶段:Python入门/Python入门(动画版) 2848楼

pygame


_display = pygame.display
color_black = pygame.Color()
color_red = pygame.Color()
version = maingame():
    window = Screen_width = Screen_height = TANK_P1 = ():
        _display.init()
        maingame.window = _display.set_mode([maingame.Screen_widthmaingame.Screen_height])
        maingame.TANK_P1 = Tank()
        _display.set_caption(+ version)
        .getTextSurface()
        :
            maingame.window.fill(color_black)
            .getEvent()
            maingame.window.blit(.getTextSurface(% )())
            maingame.TANK_P1.displayTank()
            maingame.TANK_P1.move()
            _display.update()

    ():
        eventList = pygame.event.get()
        event eventList:
            event.type == pygame.QUIT:
                .endgame()
            event.type == pygame.KEYDOWN:
                event.key == pygame.K_LEFT:
                    ()
                    maingame.TANK_P1.direction = event.key == pygame.K_RIGHT:
                    ()
                    maingame.TANK_P1.direction = event.key == pygame.K_UP:
                    ()
                    maingame.TANK_P1.direction = event.key == pygame.K_DOWN:
                    ()
                    maingame.TANK_P1.direction = event.key == pygame.K_SPACE:
                    ()

    (text=):
        pygame.font.init()
        = pygame.font.get_fonts()
        font = pygame.font.SysFont()
        textSurface = font.render(textcolor_red)
        textSurface
        (fontList)

    ():
        ()
        ()


Tank:
    TANK_P1 = (lefttop):
        .images = {
            : pygame.image.load(): pygame.image.load(): pygame.image.load(): pygame.image.load()
        }
        .direction = .image = .images[.direction]
        .rect = .image.get_rect()
        .rect.left = left
        .rect.top = top

        .speed = ():
        .image = .images[.direction]
        maingame.window.blit(.image.rect)

    ():

        .direction == :
            .rect.left > :
                .rect.left -= .speed
        .direction == :
            .rect.top > :
                .rect.top -= .speed
        .direction == :
            .rect.top + .rect.height < maingame.Screen_width:
                .rect.top += .speed
            .direction == :
                .rect.left + .rect.height < maingame.Screen_height:
                    .rect.left += .speed

    ():

为什么边界这卡不住 老师!?

Python 全系列/第二阶段:Python 深入与提高/坦克大战 2850楼

课程分类

百战程序员微信公众号

百战程序员微信小程序

©2014-2025百战汇智(北京)科技有限公司 All Rights Reserved 北京亦庄经济开发区科创十四街 赛蒂国际工业园
网站维护:百战汇智(北京)科技有限公司
京公网安备 11011402011233号    京ICP备18060230号-3    营业执照    经营许可证:京B2-20212637