Skip to content

Commit

Permalink
feat: 添加子弹类
Browse files Browse the repository at this point in the history
  • Loading branch information
Jim-shop committed May 10, 2023
1 parent 70e9632 commit db3fe6b
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package net.imshit.aircraftwar.element.bullet

import net.imshit.aircraftwar.element.AbstractFlyingObject
import net.imshit.aircraftwar.logic.Games

abstract class AbstractBullet(
game: Games, initialX: Float, initialY: Float, speedX: Float, speedY: Float, val power: Int
) : AbstractFlyingObject(
game = game, initialX = initialX, initialY = initialY, speedX = speedX, speedY = speedY
) {
override fun forward(timeMs: Int) {
super.forward(timeMs)
// 额外判定 y 轴出界
if (this.y <= 0) {
vanish()
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package net.imshit.aircraftwar.element.bullet

import net.imshit.aircraftwar.logic.Games
import net.imshit.aircraftwar.util.listener.EnemyListener
import net.imshit.aircraftwar.util.listener.GameEvents

class EnemyBullet(
game: Games, initialX: Float, initialY: Float, speedX: Float, speedY: Float, power: Int
) : AbstractBullet(
game = game,
initialX = initialX,
initialY = initialY,
speedX = speedX,
speedY = speedY,
power = power
), EnemyListener {
override val image = game.images.bulletEnemy
override fun notify(e: GameEvents) {
when (e) {
GameEvents.BOMB_ACTIVATE -> this.vanish()
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package net.imshit.aircraftwar.element.bullet

import net.imshit.aircraftwar.logic.Games

class HeroBullet(
game: Games, initialX: Float, initialY: Float, speedX: Float, speedY: Float, power: Int
) : AbstractBullet(
game = game,
initialX = initialX,
initialY = initialY,
speedX = speedX,
speedY = speedY,
power = power
) {
override val image = game.images.bulletHero
}

0 comments on commit db3fe6b

Please sign in to comment.