zoukankan
html css js c++ java
<天弋夺宝> 核心代码(未注释)
//
---------------------------------------------------Over
var
Over
=
new
Object();
Over.Init
=
function
(e)
{
Over.ent(e);
}
;
Over.ent
=
function
(e)
{
e.onEnterFrame
=
function
()
{
if
(e.enabled)
{
if
(e.hitTest(ship_mc.hit02_mc))
{
MySound.nexts();
_root.gotoAndStop(
"
win
"
);
}
}
}
;
}
;
//
---------------------------------------------------NextLevel
var
NextLevel
=
new
Object();
NextLevel.Init
=
function
(e)
{
NextLevel.ent(e);
}
;
NextLevel.ent
=
function
(e)
{
e.onEnterFrame
=
function
()
{
if
(e.enabled)
{
if
(e.hitTest(ship_mc.hit01_mc))
{
MySound.nexts();
_root.gotoAndStop(ship.level);
ship.ReStart();
}
}
}
;
}
;
//
---------------------------------------------------PItem
var
PItem
=
new
Object();
PItem.Init
=
function
(hitarea, e)
{
PItem.ent(hitarea, e);
}
;
PItem.ent
=
function
(hitarea, e)
{
e.onEnterFrame
=
function
()
{
if
(e.enabled)
{
if
(hitarea.hitTest(ship_mc.hit02_mc))
{
ship.IsHit
=
true
;
if
(
!
ship.IsDead)
{
if
(ship.dy
>
1.800000
)
{
ship.dead();
}
else
if
(Math.abs(ship.dx)
>
0.900000
)
{
ship.dead();
}
else
{
MySound.eat();
ship_mc._x
=
ship_mc._x
+
ship.dx
*
1.500000
;
ship_mc._y
=
ship_mc._y
+
ship.dy
*
1.300000
;
ship.dy
=
0
;
ship.dx
=
0
;
e.gotoAndStop(
"
e
"
);
ship_mc.gotoAndStop(
"
stop
"
);
}
}
}
}
}
;
}
;
//
---------------------------------------------------fuelstation
var
fuelstation
=
new
Object();
fuelstation.Init
=
function
(e)
{
fuelstation.ent(e);
}
;
fuelstation.ent
=
function
(e)
{
e.onEnterFrame
=
function
()
{
if
(e.hitTest(ship_mc.hit02_mc))
{
ship.IsHit
=
true
;
if
(
!
ship.IsDead)
{
if
(ship.dy
>
1.800000
)
{
ship.dead();
}
else
if
(Math.abs(ship.dx)
>
0.900000
)
{
ship.dead();
}
else
{
MySound.adds();
ship_mc._x
=
ship_mc._x
+
ship.dx
*
1.500000
;
ship_mc._y
=
ship_mc._y
+
ship.dy
*
1.300000
;
ship.dy
=
0
;
ship.dx
=
0
;
ship.Life_add();
ship_mc.gotoAndStop(
"
stop
"
);
}
}
}
}
;
}
;
//
---------------------------------------------------life
var
life
=
new
Object();
var
life_mc
=
_root.life_mc;
life.Init
=
function
()
{
life.Num
=
4
;
life.ent();
}
;
life.ent
=
function
()
{
life_mc.onEnterFrame
=
function
()
{
life_mc.gotoAndStop(life.Num);
}
;
}
;
//
---------------------------------------------------MySound
var
MySound
=
new
Object();
MySound.l1
=
function
()
{
stopAllSounds();
var
sbg
=
new
Sound();
sbg.attachSound(
"
s01
"
);
sbg.start(
0
,
999
);
}
;
MySound.l2
=
function
()
{
stopAllSounds();
var
sbg
=
new
Sound();
sbg.attachSound(
"
s02
"
);
sbg.start(
0
,
999
);
}
;
MySound.l3
=
function
()
{
stopAllSounds();
var
sbg
=
new
Sound();
sbg.attachSound(
"
s03
"
);
sbg.start(
0
,
999
);
}
;
MySound.fly
=
function
()
{
var
s
=
new
Sound();
s.attachSound(
"
ship_fly
"
);
s.start();
}
;
MySound.bom
=
function
()
{
var
s
=
new
Sound();
s.attachSound(
"
ship_bom
"
);
s.start();
}
;
MySound.eat
=
function
()
{
var
s
=
new
Sound();
s.attachSound(
"
ship_eat
"
);
s.start();
}
;
MySound.adds
=
function
()
{
var
s
=
new
Sound();
s.attachSound(
"
ship_add
"
);
s.start();
}
;
MySound.nexts
=
function
()
{
var
s
=
new
Sound();
s.attachSound(
"
ship_next
"
);
s.start();
}
;
//
---------------------------------------------------ship
var
ship
=
new
Object();
var
ship_mc
=
_root.ship_mc;
var
gorizont_l_mc
=
_root.gorizont_l;
var
gorizont_u_mc
=
_root.gorizont_u;
var
gorizont_r_mc
=
_root.gorizont_r;
//
var fuelstation_mc = _root.fuelstation;
//
var PItem_mc = _root.PItem;
var
fuel_mc
=
_root.fuel_mc.fuel;
//
trace(fuel_mc);
var
hit_area_mc
=
_root.hit_area;
//
初始化
ship.Init
=
function
()
{
ship.level
=
"
level01
"
;
ship_mc._x
=
40
;
ship_mc._y
=
40
;
ship.dy
=
1
;
ship.dx
=
0
;
ship.IsDead
=
false
;
ship.IsHit
=
false
;
ship.benzin
=
500
;
ship.ent();
}
;
ship.ent
=
function
()
{
ship_mc.onEnterFrame
=
function
()
{
if
(Key.isDown(Key.LEFT))
{
if
(ship.benzin
>
0
)
{
ship.dx
=
ship.dx
-
0.100000
;
ship.Life_dec();
ship_mc.fire_mc.gotoAndPlay(
"
fire
"
);
MySound.fly();
}
ship_mc._xscale
=
-
100
;
}
if
(Key.isDown(Key.RIGHT))
{
if
(ship.benzin
>
0
)
{
ship.dx
=
ship.dx
+
0.100000
;
ship.Life_dec();
ship_mc.fire_mc.gotoAndPlay(
"
fire
"
);
MySound.fly();
}
ship_mc._xscale
=
100
;
}
if
(Key.isDown(Key.UP))
{
ship.IsHit
=
false
;
if
(ship.benzin
>
0
)
{
ship.dy
=
ship.dy
-
0.300000
;
ship.Life_dec();
ship_mc.fire_b_mc.gotoAndPlay(
"
fire
"
);
MySound.fly();
}
}
/**/
/*
if (ship_mc.hit02_mc.hitTest(PItem_mc.hit)) {
if (ship.dy>1.800000) {
ship.dead();
} else if (Math.abs(ship.dx)>0.900000) {
ship.dead();
} else {
ship_mc._x = ship_mc._x+ship.dx*1.500000;
ship_mc._y = ship_mc._y+ship.dy*1.300000;
ship.dy = 0;
ship.dx = 0;
PItem_mc.gotoAndStop("e");
ship_mc.gotoAndStop("stop");
}
} else if (ship_mc.hit02_mc.hitTest(fuelstation_mc)) {
if (ship.dy>1.800000) {
ship.dead();
} else if (Math.abs(ship.dx)>0.900000) {
ship.dead();
} else {
ship_mc._x = ship_mc._x+ship.dx*1.500000;
ship_mc._y = ship_mc._y+ship.dy*1.300000;
ship.dy = 0;
ship.dx = 0;
ship.Life_add();
ship_mc.gotoAndStop("stop");
}
}
*/
if
(
!
ship.IsHit)
{
ship_mc._x
=
ship_mc._x
+
ship.dx
*
1.500000
;
ship_mc._y
=
ship_mc._y
+
ship.dy
*
1.300000
;
ship.dy
=
ship.dy
+
0.070000
;
ship_mc._rotation
=
10
*
ship.dx;
ship_mc.gotoAndStop(
"
fly
"
);
ship.SetGorizontU();
ship.SetGorizontL();
ship.SetGorizontR();
}
}
;
}
;
ship.SetGorizontU
=
function
()
{
if
(ship_mc._y
<
0
)
{
gorizont_u_mc._visible
=
true
;
}
else
{
gorizont_u_mc._visible
=
false
;
}
gorizont_u_mc._x
=
ship_mc._x;
if
(gorizont_u_mc._x
>
500
)
{
gorizont_u_mc._x
=
500
;
}
if
(gorizont_u_mc._x
<
10
)
{
gorizont_u_mc._x
=
10
;
}
gorizont_u_mc.t_txt.text
=
ship_mc._y
*-
0.100000
;
}
;
ship.SetGorizontL
=
function
()
{
if
(ship_mc._x
<
0
)
{
gorizont_l_mc._visible
=
true
;
}
else
{
gorizont_l_mc._visible
=
false
;
}
gorizont_l_mc._y
=
ship_mc._y;
if
(gorizont_l_mc._y
<
10
)
{
gorizont_l_mc._y
=
10
;
}
if
(gorizont_l_mc._y
>
380
)
{
gorizont_l_mc._y
=
380
;
}
gorizont_l_mc.t_txt.text
=
ship_mc._x
*-
0.100000
;
}
;
ship.SetGorizontR
=
function
()
{
if
(ship_mc._x
>
550
)
{
gorizont_r_mc._visible
=
true
;
}
else
{
gorizont_r_mc._visible
=
false
;
}
gorizont_r_mc._y
=
ship_mc._y;
if
(gorizont_r_mc._y
<
10
)
{
gorizont_r_mc._y
=
10
;
}
if
(gorizont_r_mc._y
>
380
)
{
gorizont_r_mc._y
=
380
;
}
gorizont_r_mc.t_txt.text
=
ship_mc._x
*
0.100000
;
}
;
ship.Life_dec
=
function
()
{
ship.benzin
=
ship.benzin
-
1
;
dim
=
ship.benzin
/
500
;
fuel_mc._width
=
50
*
dim;
}
;
ship.Life_add
=
function
()
{
if
(ship.benzin
<
500
)
{
ship.benzin
=
ship.benzin
+
4
;
dim
=
ship.benzin
/
500
;
fuel_mc._width
=
50
*
dim;
}
}
;
ship.dead
=
function
()
{
ship_mc._x
=
ship_mc._x
+
ship.dx
*
1.500000
;
ship_mc._y
=
ship_mc._y
+
ship.dy
*
1.300000
;
ship.dy
=
0
;
ship.dx
=
0
;
if
(
!
ship.IsDead)
{
MySound.bom();
ship_mc.gotoAndPlay(
"
dead
"
);
ship.IsDead
=
true
;
life.Num
--
;
ship_mc.onEnterFrame
=
null
;
//
trace("dead");
}
}
;
ship.ReStart
=
function
()
{
if
(life.Num
<=
0
)
{
_root.gotoAndStop(
"
lose
"
);
}
ship_mc._x
=
40
;
ship_mc._y
=
40
;
ship.dy
=
1
;
ship.dx
=
0
;
ship.IsDead
=
false
;
ship.IsHit
=
false
;
ship.benzin
=
ship.benzin
+
200
;
if
(ship.benzin
>
500
)
{
ship.benzin
=
500
;
}
ship.ent();
}
;
相关文章:
[原创]Flash游戏《天弋夺宝》
《天弋夺宝》—01飞船的控制
查看全文
相关阅读:
MindSpore 建立神经网络
MindSpore 数据加载及处理
MindSpore 初探, 使用LeNet训练minist数据集
Ubuntu 20.04 Xrdp Black Screen Ubuntu 20.04 Xrdp 远程桌面黑屏
基于Transformer的ViT、DETR、Deformable DETR原理详解
Ubuntu 18.04 / 20.04 自定义锁屏时间
Transformer中K 、Q、V的设置以及为什么不能使用同一个值
Auto-Encoding Scene Graphs for Image Captioning
Eureka中读写锁的奇思妙想,学废了吗?
PostgreSQL-查询所有索引
原文地址:https://www.cnblogs.com/nasa/p/745875.html
最新文章
使用OBS 推流和拉流教程
搭建推流和拉流环境
CDN技术详解
mysql 常见统计方案整理汇总
Mysql group by常用操作
记录mysql函数GROUP_CONCAT用法及踩坑点
在S3上开启CORS
Koa2 之文件上传下载的示例代码
超级账本浏览器(Ledger Data Refiner)——功能更强大的区块链数据浏览查询工具
码云:You do not have permission push to this repository
热门文章
使用阿里云免费的ssl证书(DigiCert 免费版 SSL)进行部署
Promise回顾
Mongo db碰到的一些问题
model.train方法的dataset_sink_mode参数设置为False时以step作为单位打印数据——(只在mode=context.GRAPH_MODE下成立,在mode=context.PYNATIVE_MODE模式下不成立)
一款比较好用的 ssh、 ftp 服务的客户端软件 —— NxShell
(续) MindSpore 如何实现一个线性回归 —— Demo示例
MindSpore 如何实现一个线性回归 —— Demo示例
mindspore.ops.Pow()等算子不能处理float64类型的数据
【转载】 图解协程调度模型-GMP模型
MindSpore 自动微分
Copyright © 2011-2022 走看看