error2-2 知识性错误 alien invasion飞船无法发射子弹--语句执行顺序问题

编码的泥泞路对于我这个学习能力不是很强的真的不是很好走,一步一个坑...QAQ

这一次我又不能发子弹了,对着随书源代码(我的其他博客有介绍下载随书的成品源文件)排了一遍错误,发现是因为语句顺序错了!

错误:

正确:

错误分析:

【pygame.display.flip() :

Update the full display Surface to the screen

flip() -> None

This will update the contents of the entire display. If your display mode is using the flags pygame.HWSURFACE and pygame.DOUBLEBUF, this will wait for a vertical retrace and swap the surfaces. If you are using a different type of display mode, it will simply update the entire contents of the surface.

When using an pygame.OPENGL display mode this will perform a gl buffer swap.】

(以上来源于pygame documentation:http://www.pygame.org/docs/index.html

即,它是把整个屏幕给更新了

如果我把他放在bullet的上面,那么就看不到更新的bullet了

总结:语句顺序会导致错误,治本的办法是搞清楚语句的含义(不是要求背诵,而是看到语句关联上一个运行状态)

           总是会遇到各种各样的错误...解决它,然后就能进步了

            学习的时候最好跟着教程做,在教程的基础上进行小幅度改动并及时写反馈,不然错误一个加一个真的会崩溃!(我已经成了个照着敲的Ctrl-C&V了2333,然而还是不断地遇到错误!)

peace & love

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值