快速业务通道

飞机游戏

作者 佚名技术 来源 服务器技术 浏览 发布时间 2012-07-10


点击浏览该文件
方向键 控制上下左右 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<=mc._width/2) {
mc._x = mc._width/2;
}
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._y<=mc._height/2) {
mc._y = mc._height/2;
}
}
function shoot(arg) {
if (fly != undefined) {
bulletSpeed = 10;
if (Key.isDown(Key.CONTROL)) {
if (i>40) {
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; k<=11; k++) {
if (this.hitTest(_root["enemy"+k])) {
hit_num++;
h_num.text = "击倒"+hit_num;
h_num.setTextFormat(num_format);
Fire = _root.attachMovie("fire", "fire"+fire_num, 2000+fire_num);
if (fire>100) {
fire = 1;
}
Fire._x = this._x;
Fire._y = this._y;
_root["enemy"+k].removeMovieClip();
this.removeMovieClip();
delete this.onEnterFrame;
}
}
if (this._y<0 or this._x<0 or this._x>stage_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;

凌众科技专业提供服务器租用、服务器托管、企业邮局、虚拟主机等服务,公司网站:http://www.lingzhong.cn 为了给广大客户了解更多的技术信息,本技术文章收集来源于网络,凌众科技尊重文章作者的版权,如果有涉及你的版权有必要删除你的文章,请和我们联系。以上信息与文章正文是不可分割的一部分,如果您要转载本文章,请保留以上信息,谢谢!

分享到: 更多

Copyright ©1999-2011 厦门凌众科技有限公司 厦门优通互联科技开发有限公司 All rights reserved

地址(ADD):厦门软件园二期望海路63号701E(东南融通旁) 邮编(ZIP):361008

电话:0592-5908028 传真:0592-5908039 咨询信箱:web@lingzhong.cn 咨询OICQ:173723134

《中华人民共和国增值电信业务经营许可证》闽B2-20100024  ICP备案:闽ICP备05037997号