def broken(self): for feeler in self.feelers: feeler.remove() for feelerShot in self.feelerShots: feelerShot.remove() for cell in self.bossCells: if cell.removeFlag == False: cell.remove() self.remove() enemy.removeEnemyShot() ObjMgr.objs.append( boss.BossExplosion(gcommon.getCenterX(self), gcommon.getCenterY(self), gcommon.C_LAYER_EXP_SKY)) GameSession.addScore(self.score) BGM.sound(gcommon.SOUND_LARGE_EXP) enemy.Splash.append(gcommon.getCenterX(self), gcommon.getCenterY(self), gcommon.C_LAYER_EXP_SKY) if self.isBossRush: gcommon.debugPrint("Boss2 call NextEvent") if self.timerObj != None: self.timerObj.stop() self.timerObj = None ObjMgr.objs.append(enemy.NextEvent([0, None, 240])) else: ObjMgr.objs.append(enemy.Delay(enemy.StageClear, None, 240))
def broken(self): enemy.create_explosion(gcommon.getCenterX(self), gcommon.getCenterY(self), gcommon.C_LAYER_EXP_SKY, gcommon.C_EXPTYPE_SKY_L) #gcommon.ObjMgr.objs.append(Boss3Explosion(gcommon.getCenterX(self), gcommon.getCenterY(self), gcommon.C_LAYER_EXP_GRD)) gcommon.ObjMgr.objs.append(Boss3B(gcommon.getCenterX(self), self.y + 50)) enemy.Splash.append(gcommon.getCenterX(self), gcommon.getCenterY(self), gcommon.C_LAYER_EXP_SKY) self.remove() self.outside.setState(100) gcommon.score+=10000
def broken(self): self.remove() enemy.removeEnemyShot() ObjMgr.objs.append(boss.BossExplosion(gcommon.getCenterX(self), gcommon.getCenterY(self), gcommon.C_LAYER_EXP_SKY)) GameSession.addScore(self.score) BGM.sound(gcommon.SOUND_LARGE_EXP) enemy.Splash.append(gcommon.getCenterX(self), gcommon.getCenterY(self), gcommon.C_LAYER_EXP_SKY) 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, 240))
def update(self): self.x -= self.speed if self.x <= -24 or self.x >= gcommon.SCREEN_MAX_X or self.y < -16 or self.y >= gcommon.SCREEN_MAX_Y: self.removeFlag = True if gcommon.isMapFreePos(gcommon.getCenterX(self), gcommon.getCenterY(self)) == False: self.removeFlag = True
def broken(self): self.mode = 2 self.setState(0) self.hitCheck = False self.shotHitCheck = False self.removeAllShot() enemy.removeEnemyShot() BGM.sound(gcommon.SOUND_LARGE_EXP) enemy.Splash.append(gcommon.getCenterX(self), gcommon.getCenterY(self), gcommon.C_LAYER_EXP_SKY) GameSession.addScore(self.score) if self.isBossRush: if self.timerObj != None: self.timerObj.stop() self.timerObj = None
def checkShotCollision(self, shot): if shot.removeFlag: return False # pos = gcommon.getCenterPos(shot) # return math.hypot(self.x+39.5-pos[0], self.y+39.5 -pos[1]) <40 y = gcommon.getCenterY(shot) if math.hypot(self.x + 39.5 - shot.x - shot.left, self.y + 39.5 - y) < 40: return True elif math.hypot(self.x + 39.5 - shot.x - shot.right, self.y + 39.5 - y) < 40: return True else: return False
def update(self): if self.state == 0: self.x -= 1 if self.x <= 256 - 88: self.nextState() self.body.x = self.x + 20 self.anchor.x = self.body.x - 8 self.anchor.y = self.body.y + 16 elif self.state == 1: if self.cnt > 30: self.nextState() elif self.state == 2: if self.mode == 0: # 上に移動 self.body.y -= 2 if self.body.y < self.body_min_y: self.body.y = self.body_min_y self.setMode(1) elif self.mode == 1: # 下に移動 self.body.y += 2 if self.body.y > self.body_max_y: self.body.y = self.body_max_y self.nextState() self.setBodyAnchorPos() elif self.state == 3: # 下端からショットを打ちながら上端まで移動 self.body.y -= 1 if self.body.y < self.body_min_y: self.body.y = self.body_min_y self.nextState() elif self.cnt % self.mainShotCycle == 0: ObjMgr.addObj(Boss3Shot(self.x, self.body.y + 12, 4)) ObjMgr.addObj(Boss3Shot(self.x, self.body.y + 37, 4)) enemyOthers.Spark1.create(self.body, 2, 12, gcommon.C_LAYER_E_SHOT) enemyOthers.Spark1.create(self.body, 2, 37, gcommon.C_LAYER_E_SHOT) BGM.sound(gcommon.SOUND_SHOT3) self.setBodyAnchorPos() elif self.state == 4: cy = gcommon.getCenterY(ObjMgr.myShip) if cy > self.body.y + 25: self.body.y += 1 if self.body.y > self.body_max_y: self.body.y = self.body_max_y elif cy < self.body.y + 23: self.body.y -= 1 if self.body.y < self.body_min_y: self.body.y = self.body_min_y self.setBodyAnchorPos() if self.cnt % self.shotCycle == 0: enemy.enemy_shot_multi(self.x + 20, self.y + 27, 2, 0, 5, 5) enemyOthers.Spark1.create2(self.x + 20, self.y + 27, gcommon.C_LAYER_E_SHOT) enemy.enemy_shot_multi(self.x + 20, self.y + 176 - 27, 2, 0, 5, 5) enemyOthers.Spark1.create2(self.x + 20, self.y + 176 - 27, gcommon.C_LAYER_E_SHOT) BGM.sound(gcommon.SOUND_SHOT2) if self.cnt > 180: self.nextState() elif self.state == 5: if self.mode == 0: # アンカーが伸びる if self.modeCnt == 0: BGM.sound(gcommon.SOUND_BOSS3_ANCHOR) self.anchor.x -= 8 if self.anchor.x <= 0: self.anchor.x = 0 self.nextMode() elif self.mode == 1: # アンカーが伸びきった if self.modeCnt > 30: self.nextMode() else: self.modeCnt += 1 elif self.mode == 2: # アンカーが縮む self.anchor.x += 4 if self.anchor.x >= self.body.x - 8: self.anchor.x = self.body.x - 8 self.nextMode() elif self.mode == 3: if self.modeCnt > 30: self.nextState() else: self.modeCnt += 1 elif self.state == 6: # 上に移動 self.body.y -= 2 if self.body.y < self.body_min_y: self.body.y = self.body_min_y self.nextState() self.setBodyAnchorPos() elif self.state == 7: # 上端からショットを打ちながら下端まで移動 self.body.y += 1 if self.body.y > self.body_max_y: self.body.y = self.body_max_y self.nextState() elif self.cnt % self.mainShotCycle == 0: ObjMgr.addObj(Boss3Shot(self.x, self.body.y + 12, 4)) ObjMgr.addObj(Boss3Shot(self.x, self.body.y + 37, 4)) enemyOthers.Spark1.create(self.body, 2, 12, gcommon.C_LAYER_E_SHOT) enemyOthers.Spark1.create(self.body, 2, 37, gcommon.C_LAYER_E_SHOT) BGM.sound(gcommon.SOUND_SHOT2) self.setBodyAnchorPos() elif self.state == 8: # 中心に移動 self.body.y -= 1 if self.body.y < 72: self.body.y = 72 self.nextState() self.setBodyAnchorPos() elif self.state == 9: # 体当たり・戻る if self.mode == 0: # 体当たり self.x -= 4 if self.x <= -8: self.x = -8 self.nextMode() elif self.mode == 1: # 左端まで移動した後の停止状態 if self.modeCnt > 30: self.nextMode() else: self.modeCnt += 1 elif self.mode == 2: # 戻る self.x += 2 if self.x >= 256 - 88: self.x = 256 - 88 self.setState(2) self.cycleCount += 1 self.setBodyAnchorPos() r = random.randrange(0, 15) if r == 0: enemy.Splash.appendParam(self.x + 16, self.y, gcommon.C_LAYER_GRD, math.pi - math.pi / 32, math.pi / 16, speed=6.0, lifeMin=20, lifeMax=50, count=10, color=10) elif r == 5: enemy.Splash.appendParam(self.x + 16, self.y + 176, gcommon.C_LAYER_GRD, math.pi + math.pi / 32, math.pi / 16, speed=6.0, lifeMin=20, lifeMax=50, count=10, color=10) # マップループ if gcommon.map_x >= 6800 + 256: gcommon.map_x -= 8 * 4
def shotMissle(self): if self.subState == 0: cy = gcommon.getCenterY(ObjMgr.myShip) if cy > self.y + 30: self.y += 1 if self.y > 140: self.y = 140 elif cy < self.y + 28: self.y -= 1 if self.y < 8: self.y = 8 if self.subState == 0: # ミサイル発射準備 if self.subCnt == 0: # ここでミサイルを決定する for i in range(3): mt = missileTable[self.missileIndex][i] if mt == 0: self.missileObj[i] = enemy.Missile1( self.x, self.y + 16, 0) else: self.missileObj[i] = enemy.Missile2( self.x, self.y + 16, 0) # else: # self.missileObj[i] = enemy.Missile1(self.x, self.y +16, 0) self.missileIndex += 1 if self.missileIndex >= len(missileTable): self.missileIndex = 0 self.subCnt += 1 elif self.subCnt == 20: # ミサイル発射中へ self.nextSubState() self.missileState = 0 else: self.subCnt += 1 elif self.subState == 1: # ミサイル発射中 if self.subCnt == 0: # ミサイル発射 m = self.missileObj[self.missileState] m.x = self.x m.y = self.y + 16 + self.missileState * 8 m.layer = gcommon.C_LAYER_GRD ObjMgr.addObj(m) # インクリメント self.missileState += 1 if self.missileState == 3: self.missileObj[0] = None self.missileObj[1] = None self.missileObj[2] = None self.nextSubState() return self.subCnt += 1 if self.subCnt == 10: self.subCnt = 0 elif self.subState == 2: # 待ち if self.subCnt == 30: self.setSubState(0) self.nextState() return self.subCnt += 1
def update(self): if self.state == 0: if self.cnt == 600: gcommon.ObjMgr.objs.append(Boss3Body(self)) self.nextState() if self.state in (0,1): self.x += self.dx self.y += self.dy mode = boss3tbl[self.tblIndex][2] if mode == 1: if self.x < boss3tbl[self.tblIndex][3]: self.dx *= 0.95 self.dy *= 0.95 if abs(self.dx) < 0.01: self.nextTbl() else: self.addDxDy() elif mode == 2: if self.x > boss3tbl[self.tblIndex][3]: self.dx *= 0.95 self.dy *= 0.95 if abs(self.dx) < 0.01: self.nextTbl() else: self.addDxDy() elif mode == 3: # 上制限(上移動) if self.y < boss3tbl[self.tblIndex][3]: self.dx *= 0.95 self.dy *= 0.95 if abs(self.dy) <=0.01: self.nextTbl() else: self.addDxDy() elif mode == 4: # 下制限(下移動) if self.y > boss3tbl[self.tblIndex][3]: self.dx *= 0.95 self.dy *= 0.95 if abs(self.dy) <= 0.01: self.nextTbl() else: self.addDxDy() elif self.state == 100: # broken self.dx = 0 self.dy = 0 if self.cnt == 80: self.nextState() elif self.state == 101: self.y += gcommon.cur_scroll if self.cnt == 40: self.nextState() elif self.state == 102: self.y += gcommon.cur_scroll if self.cnt % 10 == 0: enemy.create_explosion( self.x+(self.right-self.left)/2 +random.randrange(80)-40, self.y+(self.bottom-self.top)/2 +random.randrange(80)-30, self.layer,gcommon.C_EXPTYPE_GRD_M) if self.cnt == 120: gcommon.ObjMgr.objs.append(Boss3Explosion(gcommon.getCenterX(self), gcommon.getCenterY(self), gcommon.C_LAYER_EXP_GRD)) self.nextState() elif self.state == 103: self.y += gcommon.cur_scroll if self.cnt == 120: self.remove()
def broken(self): self.setState(100) # 当たり判定がないレイヤに移動しないと何度もbrokenが呼ばれてしまう self.layer = gcommon.C_LAYER_HIDE_GRD enemy.Splash.append(gcommon.getCenterX(self), gcommon.getCenterY(self), gcommon.C_LAYER_EXP_SKY) gcommon.sound(gcommon.SOUND_LARGE_EXP)
def update(self): if self.state == 0: # 格納庫 if self.cnt == 80: self.nextState() elif self.state == 1: # 初期位置まで移動 if abs(self.firstY - self.y) < 1 and abs(self.firstX - self.x) < 1: self.nextState() self.dx = 0 self.dy = 0 else: r = math.atan2(self.firstY - self.y, self.firstX - self.x) self.dx = math.cos(r) * 1 self.dy = math.sin(r) * 1 self.x += self.dx self.y += self.dy elif self.state == 2: self.brake = False if self.cnt == 60: self.nextState() elif self.state == 3: self.x += self.dx self.y += self.dy self.brake = False mode = boss3Btbl[self.tblIndex][0] if mode == 0: if self.subcnt == boss3Btbl[self.tblIndex][3]: self.nextTbl() elif mode == 1: if self.x < boss3Btbl[self.tblIndex][3]: self.dx *= 0.95 self.dy *= 0.95 self.brake = True if abs(self.dx) < 0.01: self.nextTbl() else: self.addDxDy() elif mode == 2: if self.x > boss3Btbl[self.tblIndex][3]: self.dx *= 0.95 self.dy *= 0.95 self.brake = True if abs(self.dx) < 0.01: self.nextTbl() else: self.addDxDy() elif mode == 3: # 上制限(上移動) if self.y < boss3Btbl[self.tblIndex][3]: self.dx *= 0.95 self.dy *= 0.95 self.brake = True if abs(self.dy) <=0.01: self.nextTbl() else: self.addDxDy() elif mode == 4: # 下制限(下移動) if self.y > boss3Btbl[self.tblIndex][3]: self.dx *= 0.95 self.dy *= 0.95 self.brake = True if abs(self.dy) <= 0.01: self.nextTbl() else: self.addDxDy() attack = boss3Btbl[self.tblIndex][4] if attack == 1: # 全体攻撃 if self.subcnt & 7 == 0: enemy.enemy_shot_dr(self.x +24, self.y + 18, 6, 1, 49 + (self.subcnt>>3)*2) enemy.enemy_shot_dr(self.x +24, self.y + 18, 6, 1, 47 - (self.subcnt>>3)*2) gcommon.sound(gcommon.SOUND_SHOT2) elif attack == 2: # 正面攻撃 if self.subcnt & 15 == 0: enemy.enemy_shot_dr(self.x +24 +16, self.y + 32, 4, 1, 16) enemy.enemy_shot_dr(self.x +24 -16, self.y + 32, 4, 1, 16) gcommon.sound(gcommon.SOUND_SHOT2) elif attack == 3: # 波状攻撃 if self.subcnt & 15 == 0: if self.subcnt & 31 == 0: for i in range(1,6): enemy.enemy_shot_offset(self.x+24, self.y+18, 2*2,1, -(i-2)*2) gcommon.sound(gcommon.SOUND_SHOT2) else: for i in range(1,6): enemy.enemy_shot_offset(self.x+24, self.y+18, 2*2,1, (i-2)*2) gcommon.sound(gcommon.SOUND_SHOT2) elif attack == 4: # 時計回り攻撃 if self.subcnt & 7 == 0: enemy.enemy_shot_dr(self.x +24, self.y + 18, 5, 1, (self.subcnt>>3)+2) enemy.enemy_shot_dr(self.x +24, self.y + 18, 6, 1, (self.subcnt>>3)-2) gcommon.sound(gcommon.SOUND_SHOT2) elif attack == 5: # 反時計回り攻撃 if self.subcnt & 7 == 0: enemy.enemy_shot_dr(self.x +24, self.y + 18, 6, 1, (34 -(self.subcnt>>3))) enemy.enemy_shot_dr(self.x +24, self.y + 18, 5, 1, (30 -(self.subcnt>>3))) gcommon.sound(gcommon.SOUND_SHOT2) self.subcnt+=1 elif self.state == 100: # broken self.dx = 0 self.dy = 0 self.subcnt = 0 if self.cnt > 120: gcommon.ObjMgr.objs.append(Boss3Explosion(gcommon.getCenterX(self), gcommon.getCenterY(self), gcommon.C_LAYER_EXP_GRD)) gcommon.score+=self.score self.nextState() elif self.state == 101: if self.cnt > 300: self.nextState() elif self.state == 102: gcommon.ObjMgr.objs.append(enemy.StageClearText(3)) if self.cnt > 240: self.nextState() elif self.state == 103: self.remove() gcommon.app.startGameClear()