Beispiel #1
0
class HorizonBattery1(EnemyBase):
	def __init__(self, t):
		super(__class__, self).__init__()
		pos = gcommon.mapPosToScreenPos(t[2], t[3])
		self.x = pos[0]
		self.y = pos[1]
		self.moveTable = t[4]
		self.left = 8
		self.top = 2
		self.right = 15
		self.bottom = 23-2
		self.layer = gcommon.C_LAYER_GRD
		self.hp = 200
		self.hitCheck = True
		self.shotHitCheck = True
		self.enemyShotCollision = False
		self.ground = True
		self.score = 200
		self.mover = CountMover(self, self.moveTable, True)

	def update(self):
		if self.x < -16:
			self.remove()
			return
		self.mover.update()
		if self.cnt % 25 == 0:
			enemy_shot(self.x, self.y +12, 3, 0)

	def draw(self):
		pyxel.blt(self.x, self.y, 2, 0, 24, 26, 24, 3)
Beispiel #2
0
class Fighter4(EnemyBase):
    def __init__(self, t):
        super(Fighter4, self).__init__()
        self.x = t[2]
        self.y = t[3]
        self.moveTable = t[4]
        self.shotFirst = t[5]
        self.left = 4
        self.top = 4
        self.right = 13
        self.bottom = 13
        self.layer = gcommon.C_LAYER_SKY
        self.hp = 1
        self.hitCheck = True
        self.shotHitCheck = True
        self.enemyShotCollision = False
        self.mover = CountMover(self, self.moveTable, False)
        self.score = 100

    def update(self):
        self.mover.update()
        #gcommon.debugPrint("x = " + str(self.x) + " y = " + str(self.y))
        if self.x < -16 or self.x > gcommon.SCREEN_MAX_X + 16:
            self.remove()
            return
        if self.cnt == self.shotFirst:
            enemy.enemy_shot(self.x + 10, self.y + 10, 2, 0)

    def draw(self):
        n = 0
        width = 16
        # if self.mover.tableIndex == 1:
        #     if self.mover.cnt <= 20:
        #         n = 1
        #     elif self.mover.cnt <= 60:
        #         n = 2
        #     else:
        #         n = 1
        #         width = -16
        # elif self.mover.tableIndex > 1:
        #     n = 0
        #     width = -16
        if abs(self.mover.dx) < 0.5:
            n = 2
        elif abs(self.mover.dx) < 1.0:
            n = 1
        if self.mover.dx < 0:
            width = 16
        else:
            width = -16
        if self.cnt & 2 == 0:
            pyxel.blt(self.x, self.y, 2, 0 + n * 16, 0, width, 16, 0)
        else:
            pyxel.blt(self.x, self.y, 2, 48 + n * 16, 0, width, 16, 0)
Beispiel #3
0
class Fighter6(EnemyBase):
    imageTable = [[0, -1, 1], [1, -1, -1], [2, -1, -1], [3, -1, -1],
                  [4, 1, -1], [3, 1, -1], [2, 1, -1], [1, 1, -1], [0, 1, 1],
                  [1, 1, 1], [2, 1, 1], [3, 1, 1], [4, 1, 1], [3, -1, 1],
                  [2, -1, 1], [1, -1, 1]]

    def __init__(self, t):
        super(__class__, self).__init__()
        pos = gcommon.mapPosToScreenPos(t[2], t[3])
        self.x = pos[0] + 7.5
        self.y = pos[1] + 7.5
        self.moveTable = t[4]
        self.left = -7
        self.top = -7
        self.right = 7
        self.bottom = 7
        self.layer = gcommon.C_LAYER_SKY
        self.hp = 200
        self.ground = True
        self.hitCheck = True
        self.shotHitCheck = True
        self.enemyShotCollision = False
        self.score = 300
        self.mover = CountMover(self, self.moveTable, False)
        self.startTimer = str(gcommon.game_timer)

    def update(self):
        self.mover.update()
        if self.x < -32 or self.x >= (gcommon.SCREEN_MAX_X +
                                      32) or self.y < -32 or self.y >= (
                                          gcommon.SCREEN_MAX_Y + 32):
            self.remove()

    def draw(self):
        deg = gcommon.degNormalize(self.mover.deg + 11.25)
        n = int(deg / 22.5)
        t = __class__.imageTable[n]
        pyxel.blt(gcommon.sint(self.x - 15.5), gcommon.sint(self.y - 15.5), 2,
                  t[0] * 32, 48, 32 * t[1], 32 * t[2], 3)
        if gcommon.DebugMode:
            pyxel.text(self.x + 16, self.y - 16, self.startTimer, 7)

    def broken(self):
        super().broken()
        if GameSession.difficulty == gcommon.DIFFICULTY_HARD:
            enemy.enemy_shot(self.x, self.y, 2, 0)
Beispiel #4
0
class ContainerCarrier1(EnemyBase):
	lightTable = (0, 2, 4, 8, 8, 4, 2, 0)
	def __init__(self, t):
		super(ContainerCarrier1, self).__init__()
		self.mx = t[2]
		self.my = t[3]
		pos = gcommon.mapPosToScreenPos(t[2], t[3])
		self.x = pos[0] + 3.5
		self.y = pos[1] + 3.5
		self.moveTable = t[4]
		self.left = -11
		self.top = -11
		self.right = 11
		self.bottom = 11
		self.layer = gcommon.C_LAYER_GRD
		self.hp = 50
		self.hitcolor1 = 13
		self.hitcolor2 = 15
		self.hitCheck = True
		self.shotHitCheck = True
		self.enemyShotCollision = False
		self.mover = CountMover(self, self.moveTable, False)
		self.ground = True
		self.score = 100

	def update(self):
		self.mover.update()
		if self.x <= -96 or self.x >= gcommon.SCREEN_MAX_X+96 or self.y <= -96 or self.y >= gcommon.SCREEN_MAX_Y+96:
			self.remove()
			if self.cnt < 10:
				gcommon.debugPrint("ContainerCarrier1 is ng start point (" +  str(self.mx) + ","+ str(self.my) +") (" + str(self.x) + "," + str(self.y)+"")
			return

	def draw(self):
		n = (self.cnt>>2) % len(__class__.lightTable)
		pyxel.pal(8, __class__.lightTable[n])
		pyxel.blt(gcommon.sint(self.x -11.5), gcommon.sint(self.y -11.5), 2, 24, 0, 24, 24, 3)
		pyxel.pal()
Beispiel #5
0
class Tractor1(EnemyBase):
	lightTable = (0, 2, 4, 8, 8, 4, 2, 0)
	def __init__(self, t):
		super(Tractor1, self).__init__()
		pos = gcommon.mapPosToScreenPos(t[2], t[3])
		self.x = pos[0] + 3.5
		self.y = pos[1] + 3.5
		self.moveTable = t[4]
		self.left = -11
		self.top = -11
		self.right = 11
		self.bottom = 11
		self.layer = gcommon.C_LAYER_GRD
		self.hp = 50
		self.hitCheck = True
		self.shotHitCheck = True
		self.enemyShotCollision = False
		self.mover = CountMover(self, self.moveTable, False)
		self.ground = True
		self.score = 100
		# 貨物車を追加
		obj = Freight1(self, 0, 36, 1)
		ObjMgr.addObj(obj)
		ObjMgr.addObj(Freight1(obj, 0, 48, 2))

	def update(self):
		self.mover.update()
		if self.x <= -136 or self.x >= gcommon.SCREEN_MAX_X+136 or self.y <= -136 or self.y >= gcommon.SCREEN_MAX_Y+136:
			self.remove()
			#gcommon.debugPrint("Tractor1 removed")
			return

	def draw(self):
		n = (self.cnt>>2) % len(__class__.lightTable)
		pyxel.pal(8, __class__.lightTable[n])
		pyxel.blt(self.x -11.5, self.y -11.5, 2, 48, 0, 24, 24, 3)
		pyxel.pal()
Beispiel #6
0
class BossLabyrinth(enemy.EnemyBase):
    moveTable0 = [
        [0, CountMover.SET_POS, 256+48, 96.0],  # 0
        [104, CountMover.MOVE, -1.0, 0.0],      # 1
    ]
    moveTable1 = [
        [30, CountMover.STOP],                  # 0 開く
        [70, CountMover.MOVE, 0.0, 1.0],        # 1
        [140, CountMover.MOVE, 0.0, -1.0],       # 2
        [140, CountMover.MOVE, 0.0, 1.0],        # 3
        [0, CountMover.MOVE_TO, 54.0, CountMover.NO_MOVE, 2.0],      # 4
        [0, CountMover.MOVE_TO, 54.0, 96, 1.0],      # 5
        [70, CountMover.MOVE, 0.0, -1.0],        # 6
        [140, CountMover.MOVE, 0.0, 1.0],        # 7
        [140, CountMover.MOVE, 0.0, -1.0],       # 8
        [0, CountMover.MOVE_TO, 200.0, CountMover.NO_MOVE, 2.0],      # 9
        [0, CountMover.MOVE_TO, 200.0, 96, 1.0],      # 10
        [30, CountMover.STOP],                  # 11 閉じる
    ]
    moveTable100 = [
        [0, CountMover.STOP],
    ]
    moveTable101 = [
        [0, CountMover.MOVE_TO, 200.0, 96, 2.0],      # 10
    ]
    def __init__(self, t):
        super(__class__, self).__init__()
        self.x = t[2]
        self.y = t[3]
        self.isBossRush = t[4]
        self.left = -45
        self.top = -45
        self.right = 45
        self.bottom = 45
        self.hp = boss.BOSS_LABYRINTH_1
        self.layer = gcommon.C_LAYER_UNDER_GRD
        self.score = 5000
        self.hitcolor1 = 3
        self.hitcolor2 = 6
        # 第n形態
        self.state = 0
        self.mover = CountMover(self, self.moveTable0, False)
        self.shiftPos = 0
        self.timerObj = None
        if self.isBossRush:
            self.timerObj = enemy.Timer1.create(70)

    def update(self):
        self.mover.update()
        if self.state == 1:
            if self.mover.tableIndex == 0:
                # STOP
                self.shiftPos = (self.mover.cnt/30) * 8
            elif self.mover.tableIndex == 11:
                # STOP
                self.shiftPos = 8 -(self.mover.cnt/30) * 8
            elif self.mover.tableIndex >= 1:
                if self.mover.mode == CountMover.MOVE:
                    fx = 1
                    dr = 32
                    if self.x < ObjMgr.myShip.x:
                        fx = -1
                        dr = 0
                    if self.cnt % 60 == 0:
                        if GameSession.isEasy():
                            enemy.enemy_shot_dr_multi(self.x -48 * fx, self.y-20, 3, 0, dr, 3, 4)
                            enemy.enemy_shot_dr_multi(self.x -48 * fx, self.y+20, 3, 0, dr, 3, 4)
                        elif GameSession.isHard():
                            enemy.enemy_shot_dr_multi(self.x -48 * fx, self.y-20, 3, 0, dr, 6, 2)
                            enemy.enemy_shot_dr_multi(self.x -48 * fx, self.y+20, 3, 0, dr, 6, 2)
                        else:
                            enemy.enemy_shot_dr_multi(self.x -48 * fx, self.y-20, 3, 0, dr, 4, 3)
                            enemy.enemy_shot_dr_multi(self.x -48 * fx, self.y+20, 3, 0, dr, 4, 3)
        elif self.state == 2:
            if self.mover.tableIndex == 0:
                # STOP
                self.shiftPos = (self.mover.cnt/30) * 8
            elif self.mover.tableIndex == 11:
                # STOP
                self.shiftPos = 8 -(self.mover.cnt/30) * 8
            elif self.mover.tableIndex >= 1:
                if self.mover.mode == CountMover.MOVE:
                    fx = 1
                    if self.x < ObjMgr.myShip.x:
                        fx = -1
                    speed = -4.0
                    if self.x < ObjMgr.myShip.x:
                        speed = 4.0
                    if self.cnt % 60 == 0:
                        #enemy.enemy_shot_dr_multi(self.x -48 * fx, self.y-20, 3, 0, dr, 4, 3)
                        #enemy.enemy_shot_dr_multi(self.x -48 * fx, self.y+20, 3, 0, dr, 4, 3)
                        ObjMgr.addObj(BossLabyrinthShot1(self.x -48 * fx, self.y, speed))
                        # ObjMgr.addObj(BossLabyrinthShot1(self.x -48, self.y-20, 4))
                        # ObjMgr.addObj(BossLabyrinthShot1(self.x -48, self.y+20, 4))
                        # ObjMgr.addObj(BossLabyrinthShot1(self.x -48, self.y+20+16, 4))
                    if self.mover.cnt == 30:
                        ObjMgr.addObj(BossLabyrinthBeam1(self, 32, -32, math.pi * 1.75))
                        ObjMgr.addObj(BossLabyrinthBeam1(self, -32, -32, math.pi * 1.25))
                        ObjMgr.addObj(BossLabyrinthBeam1(self, -32, 32, math.pi * 0.75))
                        ObjMgr.addObj(BossLabyrinthBeam1(self, 32, 32, math.pi * 0.25))
        elif self.state == 100:
            # 破壊状態
            if self.cnt % 10 == 0:
                enemy.create_explosion2(self.x + random.randrange(-30, 30), self.y + random.randrange(-30, 30), self.layer, gcommon.C_EXPTYPE_SKY_M, -1)
            if self.cnt > 120:
                self.mover = CountMover(self, self.moveTable101, False)
                self.nextState()
        elif self.state == 101:
            # 破壊状態
            if self.cnt > 90:
                self.remove()
                ObjMgr.addObj(BossLabyrinth2(self.isBossRush, self.timerObj))
        if self.state < 100 and self.mover.isEnd:
            if self.state == 0:
                self.setState(1)
                self.mover = CountMover(self, self.moveTable1, False)
            elif self.state == 1:
                self.setState(2)
                self.mover = CountMover(self, self.moveTable1, False)
            elif self.state == 2:
                self.setState(1)
                self.mover = CountMover(self, self.moveTable1, False)

    def draw(self):
        if self.state == 0:
            # 上
            pyxel.bltm(self.x -47.5, self.y-15.5-32 -self.shiftPos, 0, 0, 0, 12, 4)
            # 中心
            pyxel.bltm(self.x -47.5, self.y-15.5, 0, 0, 4, 12, 4)
            # 下
            pyxel.bltm(self.x -47.5, self.y-15.5+32 +self.shiftPos, 0, 0, 8, 12, 4)
        elif self.state == 1:
            if self.shiftPos > 0:
                Drawing.blt(self.x -47.5, self.y-15.5-8, 2, 0, 40, 96, 8, 3)
                Drawing.blt(self.x -47.5, self.y-15.5+32, 2, 0, 40, 96, 8, 3)

            # 上
            Drawing.bltm(self.x -47.5, self.y-15.5-32 -self.shiftPos, 0, 0, 0, 12, 4)
            # 中心
            Drawing.bltm(self.x -47.5, self.y-15.5, 0, 0, 4, 12, 4)
            # 下
            Drawing.bltm(self.x -47.5, self.y-15.5+32 +self.shiftPos, 0, 0, 8, 12, 4)
        elif self.state == 2:
            # -○
            Drawing.blt(self.x -15.5 -24-self.shiftPos*2, self.y-7.5, 2, 0, 0, 40, 16, 3)
            # ○-
            Drawing.blt(self.x +15.5 -16+self.shiftPos*2, self.y-7.5, 2, 0, 0, -40, 16, 3)
            # ┃
            # ○
            Drawing.blt(self.x -15.5+8, self.y-15.5-24 -self.shiftPos*2, 2, 40, 0, 16, 40, 3)
            # ○
            # ┃
            Drawing.blt(self.x -15.5+8, self.y-15.5+16 +self.shiftPos*2, 2, 40, 0, 16, -40, 3)
            # 上\
            Drawing.blt(self.x -15.5 -16, self.y-15.5-16, 2, 0, 16, 24, 24, 3)
            # 上/
            Drawing.blt(self.x -15.5 +24, self.y-15.5-16, 2, 0, 16, -24, 24, 3)
            # 下\
            Drawing.blt(self.x -15.5 -16, self.y-15.5+24, 2, 0, 16, 24, -24, 3)
            # 下/
            Drawing.blt(self.x -15.5 +24, self.y-15.5+24, 2, 0, 16, -24, -24, 3)
            # 上左
            Drawing.blt(self.x -15.5-32 -self.shiftPos, self.y-15.5-32 -self.shiftPos*2, 2, 128, 0, 48, 32, 2)
            # 上右
            Drawing.blt(self.x -15.5+16 +self.shiftPos, self.y-15.5-32 -self.shiftPos*2, 2, 176, 0, 48, 32, 2)
            # 左上
            Drawing.blt(self.x -15.5-32 -self.shiftPos*2, self.y-15.5-32 -self.shiftPos, 2, 96, 0, 32, 48, 2)
            # 右上
            Drawing.blt(self.x -15.5+32 +self.shiftPos*2, self.y-15.5-32 -self.shiftPos, 2, 224, 0, 32, 48, 2)
            # 左下
            Drawing.blt(self.x -15.5-32 -self.shiftPos*2, self.y-15.5+16 +self.shiftPos, 2, 96, 48, 32, 48, 2)
            # 右下
            Drawing.blt(self.x -15.5+32 +self.shiftPos*2, self.y-15.5+16 +self.shiftPos, 2, 224, 48, 32, 48, 2)
            
            # 下左
            Drawing.blt(self.x -15.5-32 -self.shiftPos, self.y-15.5+32 +self.shiftPos*2, 2, 128, 32, 48, 32, 2)
            # 下右
            Drawing.blt(self.x -15.5+16 +self.shiftPos, self.y-15.5+32 +self.shiftPos*2, 2, 176, 32, 48, 32, 2)
                        
            # 中心
            Drawing.blt(self.x -15.5, self.y-15.5, 2, 56, 0, 32, 32, 3)
        elif self.state == 100:
            pyxel.bltm(self.x -47.5, self.y-15.5-32, 0, 0, 0, 12, 12)
            #Drawing.blt(self.x -15.5, self.y-15.5, 2, 56, 0, 32, 32)
        elif self.state == 101:
            # 中心
            Drawing.blt(self.x -15.5, self.y-15.5, 2, 56, 0, 32, 32, 3)

    def broken(self):
        self.setState(100)
        self.shotHitCheck = False
        self.hitCheck = False
        self.mover = CountMover(self, self.moveTable100, False)
        enemy.removeEnemyShot()
Beispiel #7
0
class BossFire(enemy.EnemyBase):
    # x, y, dx, dy
    imageTable = [[0, 0, 1, 1], [1, 0, 1, 1], [2, 0, 1, 1], [3, 0, 1, 1],
                  [0, 1, 1, 1], [3, 0, -1, 1], [2, 0, -1, 1], [1, 0, -1, 1],
                  [0, 0, -1, 1], [1, 0, -1, -1], [2, 0, -1, -1],
                  [3, 0, -1, -1], [0, 1, 1, -1], [3, 0, 1, -1], [2, 0, 1, -1],
                  [1, 0, 1, -1]]
    moveTable0 = [
        [60, CountMover.MOVE, -1.0, 0.0],
        [90, CountMover.ROTATE_DEG2, -1.0, 1.0],
        [180, CountMover.ROTATE_DEG2, 1.0, 1.0],
        [240, CountMover.MOVE, 0.0, -1.0],  # 上に出ていく
        [90, CountMover.ROTATE_DEG2, 1.0, 1.0],
        [60, CountMover.MOVE, 1.0, 0.0],
        [90, CountMover.ROTATE_DEG2, 1.0, 1.0],
        [240, CountMover.MOVE, 0.0, 1.0],  # 上から出現
        [180, CountMover.ROTATE_DEG2, 1.0, 1.0],
        [90, CountMover.ROTATE_DEG2, -1.0, 1.0],
        [120, CountMover.MOVE, -1.0, 0.0],
        [180, CountMover.ROTATE_DEG2, -1.0, 1.0],
        [240, CountMover.MOVE, 1.0, 0.0],
        [270, CountMover.ROTATE_DEG2, -1.0, 1.0],
        [30, CountMover.MOVE, 0.0, 1.0],
        [270, CountMover.ROTATE_DEG2, 1.0, 1.0],
        [540, CountMover.MOVE, 1.0, 0.0],
        [0, CountMover.SET_POS, 256 + 32, 60],
        [0, CountMover.SET_DEG, 180]
    ]
    stateTable0 = [
        [920, 0],
        [1020, 3],
        [1140, 1],  # 待ち
        [1380, 2],  # 大量ブレス
        [1880, 3],
        [2000, 1],  # 待ち
        [2510, 2],  # 大量ブレス
        [9999, 0],
    ]
    backstateTable0 = [
        [1020, 0],
        [1140, 1],  # 待ち
        [1380, 2],  # 大量ブレス
        [1880, 3],
        [2000, 1],  # 待ち
        [2510, 2],  # 大量ブレス
        [9999, 0],
    ]
    intervaTable = (45, 30, 24)

    def __init__(self, t):
        super(__class__, self).__init__()
        self.isBossRush = t[2]
        self.x = 256 + 32
        self.y = 60
        self.moveTable = __class__.moveTable0
        self.mover = CountMover(self, self.moveTable, True)
        self.mover.deg = 180
        self.stater = enemy.CountStater(self, __class__.stateTable0, True,
                                        True)
        self.stateTable = None
        self.left = -12
        self.top = -12
        self.right = 12
        self.bottom = 12
        self.hitcolor1 = 10
        self.hitcolor2 = 7
        self.layer = gcommon.C_LAYER_GRD
        self.exptype = gcommon.C_EXPTYPE_SKY_M
        self.ground = True
        self.hitCheck = True
        self.shotHitCheck = True
        self.hp = boss.BOSS_FIRE_HP
        self.score = 15000
        self.cellCount = 13
        self.cellDelay = 30
        self.cellList = []
        self.collisionRects = []
        for i in range(self.cellCount * self.cellDelay):
            self.cellList.append([self.x, self.y, self.mover.deg])
        pyxel.image(2).load(0, 0, "assets/bossFire.png")
        self.fireInterval = __class__.intervaTable[GameSession.difficulty]
        self.timerObj = None
        if self.isBossRush:
            self.timerObj = enemy.Timer1.create(80)

    def fire(self, x, y, deg, speed):
        obj = enemyOthers.Fire2(x, y, deg)
        obj.imageSourceIndex = 2
        obj.imageSourceX = 64
        obj.imageSourceY = 64
        obj.speed = speed
        ObjMgr.addObj(obj)

    def fire2(self, x, y, deg, speed):
        obj = enemyOthers.Fire3(x, y, deg)
        ObjMgr.addObj(obj)

    def update(self):
        self.mover.update()
        if self.mover.isEnd:
            # 移動テーブル終わりで削除
            self.remove()
            return
        if self.mover.cycleFlag:
            # ループした瞬間に0に戻す
            self.cnt = 0
            self.stater.reset()
        self.stater.update()
        for c in self.cellList:
            c[0] -= gcommon.cur_scroll_x
        self.cellList.insert(0, [self.x, self.y, self.mover.deg])
        if len(self.cellList) > (self.cellCount * self.cellDelay + 1):
            self.cellList.pop()

        # 当たり判定設定
        self.collisionRects.clear()
        index = 0
        x = self.x
        y = self.y
        for i in range(self.cellCount):
            c = self.cellList[index]
            cx = c[0] - self.x
            cy = c[1] - self.y
            self.collisionRects.append(
                gcommon.Rect.create(cx - 12, cy - 12, cx + 12, cy + 12))

            #
            if c[1] > 190 and c[1] < 193:
                x = c[0] + random.randrange(-20, 20)
                enemy.Splash.appendParam(x,
                                         c[1],
                                         gcommon.C_LAYER_SKY,
                                         math.pi * 1.5,
                                         math.pi * 0.2,
                                         speed=5,
                                         lifeMin=50,
                                         lifeMax=100,
                                         count=20,
                                         ground=True,
                                         color=10)
            elif c[1] > 4 and c[1] < 10:
                x = c[0] + random.randrange(-20, 20)
                enemy.Splash.appendParam(x,
                                         c[1],
                                         gcommon.C_LAYER_SKY,
                                         math.pi * 0.5,
                                         math.pi * 0.2,
                                         speed=5,
                                         lifeMin=50,
                                         lifeMax=100,
                                         count=20,
                                         ground=True,
                                         color=10)

            index += self.cellDelay

        if self.stater.state == 0:
            if self.stater.cnt % self.fireInterval == 0:
                # 先頭部からの炎
                self.shotHead()

                if self.stater.cnt % (self.fireInterval * 2) == 0:
                    self.shotMiddle()

                # 最後部からの炎
                self.shotTail()
        elif self.stater.state == 2:
            if self.stater.cnt % 8 == 0:
                # 先頭部からの炎
                self.shotHead()
        elif self.stater.state == 3:
            if self.stater.cnt % self.fireInterval == 0:
                # 先頭部からの炎
                self.shotHead2()

                if self.stater.cnt % 60 == 0:
                    self.shotMiddle()

                # 最後部からの炎
                self.shotTail()

    def shotHead(self):
        rad = math.radians(self.mover.deg)
        ox = self.x + math.cos(rad) * 20.0
        oy = self.y + math.sin(rad) * 20.0
        self.fire(ox, oy, math.fmod(self.mover.deg + 20, 360), 3.0)
        self.fire(ox, oy, math.fmod(self.mover.deg - 20, 360), 3.0)
        self.fire(ox, oy, self.mover.deg, 3.0)

    def shotHead2(self):
        rad = math.radians(self.mover.deg)
        ox = self.x + math.cos(rad) * 20.0
        oy = self.y + math.sin(rad) * 20.0
        self.fire2(ox, oy, math.fmod(self.mover.deg + 20, 360), 3.0)
        self.fire2(ox, oy, math.fmod(self.mover.deg - 20, 360), 3.0)
        self.fire2(ox, oy, self.mover.deg, 3.0)

    def shotMiddle(self):
        index = self.cellDelay * 3
        for i in range(int(self.cellCount / 3) - 1):
            cell = self.cellList[index]
            n = int((int((cell[2] + 360 / 32) * 16 / 360) & 15) * 360 / 16)
            self.fire(cell[0], cell[1], n + 90, 1.5)
            self.fire(cell[0], cell[1], n - 90, 1.5)
            index += self.cellDelay * 3

    def shotTail(self):
        index = (self.cellCount - 1) * self.cellDelay
        cell = self.cellList[index]
        rad = math.radians(cell[2])
        ox = cell[0] - math.cos(rad) * 20.0
        oy = cell[1] - math.sin(rad) * 20.0
        self.fire(ox, oy, math.fmod(cell[2] + 180 + 20, 360), 1.5)
        self.fire(ox, oy, math.fmod(cell[2] + 180 - 20, 360), 1.5)

    def draw(self):
        length = self.cellCount
        index = 0
        drawList = []
        for i in range(length):
            if index == 0:
                drawList.append([0, index])
            elif i == length - 1:
                drawList.append([1, index])
            else:
                drawList.insert(0, [2, index])
            index += self.cellDelay
        for item in drawList:
            index = item[1]
            if item[0] == 0:
                self.drawCell(self.cellList[index][0], self.cellList[index][1],
                              self.cellList[index][2])
            elif item[0] == 1:
                self.drawCell(self.cellList[index][0], self.cellList[index][1],
                              self.cellList[index][2] + 180)
            else:
                self.drawCell2(self.cellList[index][0],
                               self.cellList[index][1],
                               self.cellList[index][2])
                if index % (self.cellDelay * 3) == 0:
                    pyxel.blt(self.cellList[index][0] - 11.5,
                              self.cellList[index][1] - 11.5, 2, 64, 88, 24,
                              24, 3)
        gcommon.Text2(200, 184, str(self.cnt), 7, 0)
        #gcommon.Text2(200, 184, str(int(self.x)) + " " + str(int(self.y)), 7, 0)

    def drawCell(self, x, y, deg):
        n = int((deg + 360 / 32) * 16 / 360) & 15
        tbl = __class__.imageTable[n]
        pyxel.blt(x - 31.5, y - 31.5, 2, tbl[0] * 64, tbl[1] * 64, 64 * tbl[2],
                  64 * tbl[3], 3)

    def drawCell2(self, x, y, deg):
        n = int((deg + 360 / 32) * 16 / 360) & 15
        tbl = __class__.imageTable[n]
        pyxel.blt(x - 31.5, y - 31.5, 2, tbl[0] * 64, 128 + tbl[1] * 64,
                  64 * tbl[2], 64 * tbl[3], 3)

    # 当たった場合の破壊処理
    # 破壊した場合True
    def doShotCollision(self, shot):
        if gcommon.check_collision(self, shot):
            self.hp -= shot.shotPower
            if self.hp <= 0:
                self.broken()
                return True
            if shot.effect and self.shotEffect:
                shot.doEffect(self.shotEffectSound)
            self.hit = True
            return False
        else:
            if shot.effect and self.shotEffect:
                shot.doEffect(self.shotEffectSound)
            self.hit = False
            return False

    # 破壊されたとき
    def broken(self):
        GameSession.addScore(self.score)

        enemy.create_explosion2(self.x + (self.right + self.left + 1) / 2,
                                self.y + (self.bottom + self.top + 1) / 2,
                                self.layer, self.exptype, self.expsound)
        self.remove()
        self.doExplosion()
        enemy.removeEnemyShot()
        if self.isBossRush:
            if self.timerObj != None:
                self.timerObj.stop()
                self.timerObj = None
            ObjMgr.objs.append(enemy.NextEvent([0, None, 120]))
        else:
            ObjMgr.objs.append(enemy.Delay(enemy.StageClear, None, 180))

    def doExplosion(self):
        index = 0
        for i in range(self.cellCount):
            ObjMgr.addObj(
                BossFireExplosion(self.cellList[index][0],
                                  self.cellList[index][1], False))
            index += self.cellDelay
Beispiel #8
0
class FireWorm1(EnemyBase):
    imageTable = [[0, -1, 1], [1, -1, 1], [2, -1, 1], [3, -1, 1], [4, 1, 1],
                  [3, 1, 1], [2, 1, 1], [1, 1, 1], [0, 1, 1], [1, 1, -1],
                  [2, 1, -1], [3, 1, -1], [4, 1, -1], [3, -1, -1], [2, -1, -1],
                  [1, -1, -1]]

    def __init__(self, t):
        super(__class__, self).__init__()
        self.x = t[2]
        self.y = t[3]
        self.moveTable = t[5]
        self.stateTable = t[6]
        self.layer = gcommon.C_LAYER_GRD
        self.ground = True
        self.hitCheck = True
        self.shotHitCheck = True
        self.hp = gcommon.HP_UNBREAKABLE
        self.mover = CountMover(self, self.moveTable, False)
        if self.stateTable != None:
            self.stater = enemy.CountStater(self, self.stateTable)
        else:
            self.stater = None
        self.mover.deg = t[4]
        self.cellCount = 12
        self.cellDelay = 22
        self.cellList = []
        self.collisionRects = []
        for i in range(self.cellCount * self.cellDelay):
            self.cellList.append([self.x, self.y, self.mover.deg])

    def update(self):
        self.mover.update()
        if self.mover.isEnd:
            # 移動テーブル終わりで削除
            self.remove()
            return
        if self.stater != None:
            self.stater.update()
            if self.stater.state == 1:
                if self.stater.cnt % 10 == 0:
                    #enemy.enemy_shot(self.x, self.y, 3, 0)
                    ObjMgr.addObj(
                        enemyOthers.Fire2(self.x, self.y, self.mover.deg))
                    ObjMgr.addObj(
                        enemyOthers.Fire2(self.x, self.y,
                                          math.fmod(self.mover.deg + 20, 360)))
                    ObjMgr.addObj(
                        enemyOthers.Fire2(self.x, self.y,
                                          math.fmod(self.mover.deg - 20, 360)))

        for c in self.cellList:
            c[0] -= gcommon.cur_scroll_x
        self.cellList.insert(0, [self.x, self.y, self.mover.deg])
        if len(self.cellList) > (self.cellCount * self.cellDelay + 1):
            self.cellList.pop()

        self.collisionRects.clear()
        index = 0
        x = self.x
        y = self.y
        for i in range(self.cellCount):
            # 当たり判定設定
            c = self.cellList[index]
            cx = c[0] - self.x
            cy = c[1] - self.y
            self.collisionRects.append(
                gcommon.Rect.create(cx - 12, cy - 12, cx + 12, cy + 12))

            # 火の粉
            if c[1] > 190 and c[1] < 193:
                x = c[0] + random.randrange(-20, 20)
                enemy.Splash.appendParam(x,
                                         c[1],
                                         gcommon.C_LAYER_SKY,
                                         math.pi * 1.5,
                                         math.pi * 0.2,
                                         speed=5,
                                         lifeMin=50,
                                         lifeMax=100,
                                         count=20,
                                         ground=True,
                                         color=10)
            elif c[1] > 4 and c[1] < 10:
                x = c[0] + random.randrange(-20, 20)
                enemy.Splash.appendParam(x,
                                         c[1],
                                         gcommon.C_LAYER_SKY,
                                         math.pi * 0.5,
                                         math.pi * 0.2,
                                         speed=5,
                                         lifeMin=50,
                                         lifeMax=100,
                                         count=20,
                                         ground=True,
                                         color=10)

            index += self.cellDelay

    def draw(self):
        # index = self.cellCount * self.cellDelay -self.cellDelay
        # tail = True
        # for i in range(self.cellCount):
        #     if index >= 0 and index < len(self.cellList):
        #         if tail:
        #             self.drawCell(self.cellList[index][0], self.cellList[index][1], self.cellList[index][2] +180)
        #             tail = False
        #         else:
        #             self.drawCell(self.cellList[index][0], self.cellList[index][1], self.cellList[index][2])
        #         index -= self.cellDelay
        length = self.cellCount
        index = int(self.cellDelay / 2)
        for i in range(length - 1):
            pyxel.blt(self.cellList[index][0] - 19.5,
                      self.cellList[index][1] - 19.5, 2, 200, 0, 40, 40, 2)
            index += self.cellDelay
        index = 0
        for i in range(length):
            if index == 0:
                self.drawCell(self.cellList[index][0], self.cellList[index][1],
                              self.cellList[index][2])
            elif i == length - 1:
                self.drawCell(self.cellList[index][0], self.cellList[index][1],
                              self.cellList[index][2] + 180)
            else:
                self.drawCell2(self.cellList[index][0],
                               self.cellList[index][1],
                               self.cellList[index][2])
            index += self.cellDelay

    def drawCell(self, x, y, deg):
        n = int((deg + 360 / 32) * 16 / 360) & 15
        tbl = __class__.imageTable[n]
        pyxel.blt(x - 19.5, y - 19.5, 2, tbl[0] * 40, 0, 40 * tbl[1],
                  40 * tbl[2], 2)

    def drawCell2(self, x, y, deg):
        n = int((deg + 360 / 32) * 16 / 360) & 15
        tbl = __class__.imageTable[n]
        pyxel.blt(x - 19.5, y - 19.5, 2, tbl[0] * 40, 40, 40 * tbl[1],
                  40 * tbl[2], 2)
Beispiel #9
0
class MovableBattery1p(EnemyBase):
	lightTable = (0, 2, 4, 8, 8, 4, 2, 0)
	spTable = (3, 2, 1, 0, -1, 0, 1, 2)
	def __init__(self, x, y, firstShot, moveTable):
		super(MovableBattery1p, self).__init__()
		self.x = x
		self.y = y
		self.firstShot = firstShot
		self.moveTable = moveTable
		self.left = -11
		self.top = -11
		self.right = 11
		self.bottom = 11
		self.layer = gcommon.C_LAYER_GRD
		self.hitcolor1 = 13
		self.hitcolor2 = 15
		self.hp = 70
		self.shotInterval = int(120 / GameSession.enemy_shot_rate)
		self.hitCheck = True
		self.shotHitCheck = True
		self.enemyShotCollision = False
		self.mover = CountMover(self, self.moveTable, False)
		self.ground = True
		self.score = 500
		# 0 :閉じている
		# 1 :開く1
		# 2 :開く2
		# 3 :開く3
		# 4 :開く4  ショット
		# 5 :開く3
		# 6 :開く2
		# 7 :開く1
		self.shotState = 0
		self.shotCnt = 0

	def update(self):
		self.mover.update()
		if self.x <= -96 or self.x >= gcommon.SCREEN_MAX_X+96 or self.y <= -96 or self.y >= gcommon.SCREEN_MAX_Y+96:
			#gcommon.debugPrint("remove MovableBattery1p")
			self.remove()
			return
		if self.firstShot == self.cnt or (self.cnt > self.firstShot and (self.cnt - self.firstShot) % self.shotInterval == 0):
			if self.shotState == 0:
				self.shotState = 1
		if self.shotState >= 1:
			self.shotCnt += 1
			if self.shotCnt > 5:
				self.shotCnt = 0
				self.shotState += 1
				if self.shotState == 4 and gcommon.isShotMapPos(self.x, self.y):
					enemy.enemy_shot(self.x, self.y, 3, 0)
				elif self.shotState >= 8:
					self.shotState = 0

	def draw(self):
		n = (self.cnt>>2) % len(__class__.lightTable)
		pyxel.pal(8, __class__.lightTable[n])
		sp = __class__.spTable[self.shotState]
		pyxel.blt(gcommon.sint(self.x -11.5), gcommon.sint(self.y -11.5), 2, 0, 0, 24, 24, 3)
		if sp >= 0:
			pyxel.blt(gcommon.sint(self.x -11.5)+4, gcommon.sint(self.y -11.5)+4, 2, sp*16, 24, 16, 16)
		pyxel.pal()
Beispiel #10
0
class MovableWall(EnemyBase):
    posTable = [
        [2, 2],  # 0
    ]
    sizeTable = [
        [12, 12],  # 0
    ]
    MoveTable = [
        [  # 0  下に12移動
            [96, enemy.CountMover.MOVE, 0.0, 1.0],
        ],
        [  # 1  上に12移動
            [96, enemy.CountMover.MOVE, 0.0, -1.0],
        ],
        [  # 2  右に12移動
            [96, enemy.CountMover.MOVE, 1.0, 0.0],
        ],
        [  # 3  左に12移動
            [96, enemy.CountMover.MOVE, -1.0, 0.0],
        ],
        [  # 4  左、右に移動
            [48, enemy.CountMover.MOVE, -1.0, 0.0],
            [120, enemy.CountMover.STOP],
            [48, enemy.CountMover.MOVE, 1.0, 0.0],
        ],
        [  # 5  下に6移動
            [48, enemy.CountMover.MOVE, 0.0, 1.0],
        ],
        [  # 6  上に6移動
            [48, enemy.CountMover.MOVE, 0.0, -1.0],
        ],
        [  # 7  右に6移動
            [48, enemy.CountMover.MOVE, 1.0, 0.0],
        ],
        [  # 8  左に6移動
            [48, enemy.CountMover.MOVE, -1.0, 0.0],
        ],
        [  # 9  下に6移動、上に12移動
            [48, enemy.CountMover.MOVE, 0.0, 1.0],
            [120, enemy.CountMover.STOP],
            [96, enemy.CountMover.MOVE, 0.0, -1.0],
        ],
        [  # 10  上に6移動、下に6移動、上に6移動
            [48, enemy.CountMover.MOVE, 0.0, -1.0],
            [60, enemy.CountMover.STOP],
            [48, enemy.CountMover.MOVE, 0.0, 1.0],
            [60, enemy.CountMover.STOP],
            [48, enemy.CountMover.MOVE, 0.0, -1.0],
        ],
        [  # 11  下に6移動、上に6移動、下に6移動
            [48, enemy.CountMover.MOVE, 0.0, 1.0],
            [60, enemy.CountMover.STOP],
            [48, enemy.CountMover.MOVE, 0.0, -1.0],
            [60, enemy.CountMover.STOP],
            [48, enemy.CountMover.MOVE, 0.0, 1.0],
        ],
        [  # 12  左に24移動、上に4移動
            [48, enemy.CountMover.MOVE, -2.0, 0.0],
            [60, enemy.CountMover.STOP],
            [96, enemy.CountMover.MOVE, 0.0, -0.25],
        ],
        [  # 13  左に24移動、下に4移動
            [48, enemy.CountMover.MOVE, -2.0, 0.0],
            [60, enemy.CountMover.STOP],
            [96, enemy.CountMover.MOVE, 0.0, 0.25],
        ],
        [  # 14  左に24移動、下に4移動、上に8移動
            [48, enemy.CountMover.MOVE, -2.0, 0.0],
            [30, enemy.CountMover.STOP],
            [48, enemy.CountMover.MOVE, 0.0, 0.5],
            [15, enemy.CountMover.STOP],
            [96, enemy.CountMover.MOVE, 0.0, -0.5],
        ],
    ]

    def __init__(self, mx, my, patternNo, startCount, moveNo):
        super(__class__, self).__init__()
        pos = gcommon.mapPosToScreenPos(mx, my)
        self.x = pos[0]
        self.y = pos[1]
        self.patternNo = patternNo
        self.moveNo = moveNo
        self.startCount = startCount
        self.left = 2
        self.top = 2
        self.tablePos = __class__.posTable[patternNo]
        self.tableSize = __class__.sizeTable[patternNo]
        self.right = self.tableSize[0] * 8 - 2
        self.bottom = self.tableSize[1] * 8 - 2
        self.layer = gcommon.C_LAYER_GRD
        self.hp = gcommon.HP_UNBREAKABLE
        self.ground = True
        self.hitCheck = True
        self.shotHitCheck = True
        self.enemyShotCollision = True
        self.shotEffect = False
        self.mover = CountMover(self, __class__.MoveTable[moveNo], False)

    def update(self):
        if self.state == 0:
            if self.cnt == self.startCount:
                self.nextState()
        else:
            self.mover.update()
        if self.x < -12 * 10:
            self.remove()

    def draw(self):
        pyxel.bltm(gcommon.sint(self.x), gcommon.sint(self.y), 1,
                   self.tablePos[0], self.tablePos[1], self.tableSize[0],
                   self.tableSize[1], 2)