Scratch少儿编程第十一讲 飞机大战
2019-12-25 11:37
飞机大战简化版
一、导入背景和角色造型


这些角色主要分为主机、导弹、敌机,因为素材库没有我所用到的素材角色,大家可以用素材库中的其他角色代替一下。
二、主机程序编写

主机的程序主要是通过X坐标的增加和减小来控制主机的左右移动!
多笑笑
要开心
//
三、导弹的程序

导弹是和主机有关系的,我们是要让导弹从主机的顶端发射出去。而且点下旗帜时导弹是隐藏状态。当我们按下空格键时先把导弹移到主机上。

移到主机上以后我们发现了一个问题,导弹不在主机的顶端,这么办呢?

其实很好操作,我们只需要在造型里面把导弹拉到主机的上端即可!大家试一下吧!最后记得加上显示哦!
然后我们就要让导弹向上移动啦!增加Y坐标8,再加一个条件判断语句,碰到上边缘隐藏即可!
四、敌机的程序

敌机的程序分三步:
1.设置初始位置,舞台上边缘,角色换成敌机
2.向下移动,Y坐标减小
3.碰到下边缘,归位(舞台上边缘)
4.碰到导弹,换成爆炸造型并且等待0.2秒,然后归位到上边缘,换成敌机造型,并且把我的变量增加1.
5.广播消息:在敌机碰到主机时广播消息1
五、结束游戏

game over的作用就是接受敌机的广播的,用来停止游戏,当然旗帜被点击时game over是隐藏状态。
视频演示效果
声明:本文章由网友投稿作为教育分享用途,如有侵权原作者可通过邮件及时和我们联系删除:freemanzk@qq.com