java魂斗罗_java 魂斗罗

1.课设课题组长: 沈宇涛组员: 唐洪俊, 蔡丰骏1.1 基于java swing开发的魂斗罗可实现的功能: 人物的移动射击以及跳跃人物武器的切换人物的死亡与重生敌人的行为设定1.2 UML设计图1.3 程序运行展示uploading-image-813493.png2.代码展示2.1 重点代码展示难度选择模块独立一个窗口控制难度, 通过线程传参启动frame窗口该部分代码运行结果如下:图像绘制模...
摘要由CSDN通过智能技术生成

1.课设课题

组长: 沈宇涛

组员: 唐洪俊, 蔡丰骏

1.1 基于java swing开发的魂斗罗

可实现的功能: 人物的移动射击以及跳跃

人物武器的切换

人物的死亡与重生

敌人的行为设定

1.2 UML设计图

50f27d2667fe0c961c49cf4c87ae42c3.png

1.3 程序运行展示

uploading-image-813493.png

aef2c91427610348c14c87106b95088d.gif

38467c49ac7f2933153e137dd4bee630.gif

2.代码展示

2.1 重点代码展示

难度选择模块

e691795204ee9509370dd7987ebbc836.png

701f7e89b2daf8cf99dbb274a8c18c9e.png

独立一个窗口控制难度, 通过线程传参启动frame窗口

该部分代码运行结果如下:

81fd9a1c0b36299ec85c4439666d65b4.png

图像绘制模块

7f8a47e802eaeac515b13f666470061a.png

349786aff46d8135b998426bf56ec995.png

绘制相关图片

键盘监听模块

77bc9fc4f7145bda35cd0eddb322a1c3.png

根据玩家操控角色的操作, 判断是否做出相应的指令

角色的移动

private void heroMove()

{

if ((this.hero.state != 4) && (this.hero.state != 5))

if ((!this.hero.jumping) && (!this.jumpDown) && (!this.leftDown) && (!this.rightDown) && (!this.upDown) && (!this.downDown))

{

this.hero.state = 0;

if (this.hero.towardsLeft)

{

this.hero.direction = 6;

}

else if (this.hero.towardsRight)

{

this.hero.direction = 2;

}

}

else if (this.hero.jumping)

{

if (this.upDown)

{

this.hero.direction = 0;

this.hero.state = 2;

if ((this.leftDown) && (!this.showBossScene))

{

this.hero.direction = 7;

this.hero.towardsLeft = true;

this.hero.towardsRight = false;

if (this.hero.position.x > 8.0F + this.mapPosition)

this.hero.position.x -= this.heroSpeed;

}

else if ((this.rightDown) && (!this.showBossScene)) {

this.hero.direction = 1;

this.hero.towardsLeft = false;

this.hero.towardsRight = true;

moveForwardToRight();

}

}

else if (this.downDown)

{

  • 1
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值