欢迎来到尧图网

客户服务 关于我们

您的位置:首页 > 科技 > 名人名企 > 制作一款打飞机游戏13:状态机

制作一款打飞机游戏13:状态机

2025/9/23 11:15:34 来源:https://blog.csdn.net/wskongdesheng/article/details/147383408  浏览:    关键词:制作一款打飞机游戏13:状态机

  • 状态机‌:为了实现游戏的不同状态(如启动屏幕和游戏运行状态),我们引入了状态机。通过动态地切换drawupdate函数,我们能够根据游戏当前的状态来执行不同的操作。
  • 启动屏幕‌:制作了一个简单的启动屏幕,当玩家按下按钮时,游戏会从启动屏幕切换到实际运行状态。
  • 清除屏幕‌:移除了每次绘制前的清屏操作,因为我们总是将整个地图绘制到屏幕上,所以不需要清屏来查看各图层之间的空隙。
  • 爆炸效果‌:对爆炸效果进行了微调,使其看起来更加自然和不可预测。通过使用R&D range函数,我们为爆炸的偏移量添加了随机性。

function _init()t=0debug={}butarr=split("1,2,3,1,4,6,7,4,5,9,8,5,1,2,3,1")dirx=split("0,-1,1, 0,0, -0.7, 0.7,0.7,-0.7")diry=split("0, 0,0,-1,1, -0.7,-0.7,0.7,0.7")--★shiparr=split("65,67,69,71,73")flamearr=split("76,77,78,77")mapsegs=split("3,3,3,3,3,2,1,0,1,7,6,5,10,4,11,6,11,11,5,9,10,8,1,0,15,14,1,13,12,19,19,18,17,16,18,17,16,17,16,19,22,21,20,27,26,25,23,24,3,3")_upd=upd_menu_drw=drw_menu
endfunction startgame()px,py=64,64spd=1.4lastdir=0shipspr=0scroll=0xscroll=0mapsegi=0cursegs={}boss=falseparts={}shots={}shotwait=0muzz={}_upd=upd_game_drw=drw_game
endfunction _draw()_drw()--★cursor(4,4)color(7)for txt in all(debug) doprint(txt)end
endfunction _update60()t+=1_upd()
end-->8
--drawfunction drw_game()for seg in all(cursegs) domap(seg.x,seg.y,xscroll,scroll-seg.o,18,8)endfor p in all(parts) doif p.wait==nil thenp.draw(p)endendfor s in all(shots) do    spr(s.sani[flr(s.si)],s.x,s.y,1,s.sh)endfor m in all(muzz) do    spr(m.sani[flr(m.si)],px+m.x,py+m.y,2,2)end--shipspr(shiparr[flr(shipspr*2.4+3.5)],px,py,2,2)local fframe=flamearr[t\3%4+1]spr(fframe,px+6,py+15)spr(fframe,px+3,py+15)debug[1]=scroll
endfunction drw_menu()map(19,8)
end

版权声明:

本网仅为发布的内容提供存储空间,不对发表、转载的内容提供任何形式的保证。凡本网注明“来源:XXX网络”的作品,均转载自其它媒体,著作权归作者所有,商业转载请联系作者获得授权,非商业转载请注明出处。

我们尊重并感谢每一位作者,均已注明文章来源和作者。如因作品内容、版权或其它问题,请及时与我们联系,联系邮箱:809451989@qq.com,投稿邮箱:809451989@qq.com

热搜词