1.课设课题
组长: 沈宇涛
组员: 唐洪俊, 蔡丰骏
1.1 基于java swing开发的魂斗罗
可实现的功能: 人物的移动射击以及跳跃
人物武器的切换
人物的死亡与重生
敌人的行为设定
1.2 UML设计图
1.3 程序运行展示
uploading-image-813493.png
2.代码展示
2.1 重点代码展示
难度选择模块
独立一个窗口控制难度, 通过线程传参启动frame窗口
该部分代码运行结果如下:
图像绘制模块
绘制相关图片
键盘监听模块
根据玩家操控角色的操作, 判断是否做出相应的指令
角色的移动
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)
{