用as3实现的坦克大战

这几天用as3实现了一个坦克大战的游戏。。完全是用纯as3实现的。。没有用到外部的资源。。下面是对这个游戏的一些截图





游戏的源码下载在我的资源里面!!!!


as3坦克大战源码 MVC框架 备注都写得很清楚, 适合学习 package { import Controllers.BasicController; import Controllers.MonsterController; import flash.display.Sprite; import flash.display.Stage; import flash.geom.Point; import flash.utils.Timer; import Objects.Base; import Objects.GameObject; import Objects.GameSounds; import Objects.Item; import Objects.Monster; import Objects.Player; import Objects.Stone; import Sence.Sence; import Controllers.KeyController; import Objects.ActionObject; import flash.events.TimerEvent; public class Main extends Sprite{ private var mapconfig:Array = [ [0, 0, 1, 1, 0, 1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 0, 0, 1, 1, 0, 0, 1, 0, 1], [0, 1, 0, 0, 0, 1, 4, 0, 0, 0, 1, 0], [0, 0, 1, 1, 0, 1, 0, 0, 0, 0, 1, 0], [0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0], [0, 0, 1, 0, 0, 0, 0, 0, 1, 1, 0, 0], [0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0], [0, 0, 1, 0, 0, 0, 0, 1, 0, 1, 1, 0], [0, 0, 1, 1, 1, 0, 0, 1, 1, 1, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3] ]; public function Main() { // constructor code var sence:Sence.MapSence = new Sence.MapSence(stage); sence.setup(mapconfig); addChild(sence); new GameSounds("open.mp3"); var timer:Timer = new Timer(10000); timer.addEventListener(TimerEvent.TIMER, createItem); timer.start(); } private function createItem(e:TimerEvent) { for each(var obj:GameObject in Global.sence.objectArray) { if (obj is Item) obj.die(obj); } //删除当前的物品 /** * 新建物品 */ var p:Point = getRandomPlace(); var item:Item = new Item(new Item_Speed()); item.x = item.width * p.x + Global.INTERVAL; item.y = item.width * p.y + Global.INTERVAL; Global.sence.addObject(item); } private function getRandomPlace():Point { var ry:uint = int(Math.random() * mapconfig.length); var rx:uint = int(Math.random() * mapconfig[0].length); if (mapconfig[ry][rx] == 0) return new Point(rx, ry); return getRandomPlace(); } } }
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值