flash飞机游戏

方向键 控制上下左右 ctrl-----发射键 dead后,按SPACE(空格键)重新开始。
-------------如果转载请注明“寒冰制作”----------
--------------虽然很垃圾,但是也是我的心血
//以下是游戏中所有的代码,就一针,至于元件都是自己涂的。元件都在库中,分别是子弹,飞机,敌人,火花。
init();function init() {
black.swapDepths(4000);
Var();
set_fly();
Trans();
key_col();
}
function Var() {
stage_width = 300;
stage_height = 300;
_root.createTextField("h_num", 1000, 5, 25, 100, 20);
num_format = new TextFormat();
num_format.color = 0xb8e0f0;
h_num.text = "击倒"+0;
h_num.type = "dynamic";
h_num.border = true;
h_num.borderColor = 0xffffff;
h_num.color = 0xffffff;
h_num.setTextFormat(num_format);
h_num.autoSize = "left";
i = 1;
fire_num = 1;
hit_num = 0;
life._xscale = 100;
}
function set_fly() {
_root.attachMovie("fly", "fly", 0);//调库中的飞机
fly._xscale = fly._yscale=150;
fly._x = 150;
fly._y = 250;
}
function control() {
if (Key.isDown(Key.LEFT)) {
fly._x -= 5;
}
if (Key.isDown(Key.UP)) {
fly._y -= 5;
}
if (Key.isDown(Key.RIGHT)) {
fly._x += 5;
}
if (Key.isDown(Key.DOWN)) {
fly._y += 5;
}
}
function Range(mc) {
if (mc._x=stage_width-mc._width/2) {
mc._x = stage_width-mc._width/2;
}
if (mc._y>=stage_height-mc._height/2) {
mc._y = stage_height-mc._height/2;
}
if (mc._y40) {
i = 1;
}
down = 1;
Bullet = _root.attachMovie("bullet", "bullet"+i, i++);//调库中的子弹
Bullet._x = fly._x;
Bullet._y = fly._y-20;
Bullet._rotation = 90-arg;
arg = arg/180*Math.PI;
Bullet.xinc = Math.cos(arg)*bulletSpeed;
Bullet.yinc = Math.sin(arg)*bulletSpeed;
Bullet.onEnterFrame = function() {
for (k=1; k100) {
fire = 1;
}
Fire._x = this._x;
Fire._y = this._y;
_root["enemy"+k].removeMovieClip();
this.removeMovieClip();
delete this.onEnterFrame;
}
}
if (this._ystage_width) {
removeMovieClip(this);
delete this.onEnterFrame;
}
this._x += this.xinc;
this._y -= this.yinc;
};
}
}
}
function Trans() {
interval = 1;
enemy_num = 1;
enemy_speed = 5;
enemy_time = 0;
onEnterFrame = function () {
control();
Range(fly);
if (++enemy_time>15) {
enemy_time = 0;
if (enemy_num>10) {
enemy_num = 1;
}
Enemy = _root.attachMovie("enemy", "enemy"+enemy_num, 400+enemy_num++); //调库中的敌人
temp_fly_x = fly._x;
temp_fly_y = fly._y;
aa = x_y_random();
Enemy._x = aa[0];
Enemy._y = aa[1];
if (fly == undefined) {
Enemy.radia = Math.atan2(300-Enemy._y, random(300)-Enemy._x);
} else {
Enemy.radia = Math.atan2(temp_fly_y-Enemy._y, temp_fly_x-Enemy._x);
}
Enemy.onEnterFrame = function() {
this._rotation += 20;
if (this.hitTest(fly.f_fly._fly)) {
Fire = _root.attachMovie("fire", "fire"+fire_num, 500+fire_num);//调库中的火花
Fire._xscale = Fire._yscale=50;
Fire._x = this._x;
Fire._y = this._y;
this.removeMovieClip();
life._xscale -= 4;
if (life._xscalestage_width or this._y>stage_height or this._y10) {
interval = 1;
j = 50;
while ((j += 15)
本文转自:http://www.5uflash.com/flashjiaocheng/Flashyingyongkaifa/851.html
  • 1
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值