def update(self): if self.cnt % self.interval == 0: ObjMgr.addObj(FireBird1([0, 0, self.x, self.y])) self.cnt2 += 1 self.y += self.offset if self.cnt2 >= self.max: self.remove()
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 updateMode2(self): if self.state == 0: if self.cnt > 120: self.nextState() elif self.state == 1: # 右の画面外に移動 if self.cnt == 1: obj = enemy.Splash.appendDr(self.coreX, self.coreY -8, gcommon.C_LAYER_SKY, math.pi, math.pi/6, 20) obj.ground = True obj = enemy.Splash.appendDr(self.coreX -16, self.coreY, gcommon.C_LAYER_SKY, math.pi, math.pi/6, 20) obj.ground = True obj = enemy.Splash.appendDr(self.coreX, self.coreY +8, gcommon.C_LAYER_SKY, math.pi, math.pi/6, 20) obj.ground = True if self.coreX < 300: self.coreX += 4 if self.cnt == 120: gcommon.scroll_flag = True # ボスコアを生成 ObjMgr.addObj(BossLast1Core(self.coreX, self.coreY, self.isBossRush)) if self.isBossRush == False: ObjMgr.addObj(enemy.Delay(BossLastBaseExplosion, [], 240)) BGM.play(BGM.BOSS_LAST) if self.x <= -160: self.remove() self.rad = (self.rad + math.pi/30) % (math.pi * 2)
def update(self): if gcommon.game_timer >= self.removeTime: self.remove() return if self.cnt % 120 == 0: pos = gcommon.mapPosToScreenPos(self.mx, self.my) ObjMgr.addObj(Lift2(pos[0], pos[1], self.dy))
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
def __init__(self, t): super(Boss1, self).__init__() self.x = t[2] self.y = t[3] self.isBossRush = t[4] self.left = 16 self.top = 16 self.right = 93 self.bottom = 45 self.collisionRects = gcommon.Rect.createFromList([[1, 23, 15, 37], [16, 16, 93, 45]]) self.hp = gcommon.HP_NODAMAGE self.layer = gcommon.C_LAYER_UNDER_GRD self.score = 5000 self.subcnt = 0 self.hitcolor1 = 9 self.hitcolor2 = 10 self.brake = False self.beam = 0 self.subState = 0 self.isLeft = True self.beamTime = __class__.beamTimes[GameSession.difficulty] #gcommon.debugPrint("beam Time = " + str(self.beamTime)) self.tbl = [] self.shotFlag = False self.dy = 0.0 self.beamObj = Boss1Beam(self) ObjMgr.addObj(self.beamObj) self.timerObj = None if self.isBossRush: self.y = 36 self.state = 900
def update(self): self.x += self.speed if self.x > gcommon.SCREEN_MAX_X: self.remove() return if self.cnt % 3 == 0: obj = enemyOthers.Smoke1(self.x - 8, self.y + 3) obj.ground = True ObjMgr.addObj(obj) if self.speed < 6.0: self.speed += 0.1
def skipGameTimer(self): while (gcommon.game_timer < gcommon.START_GAME_TIMER): self.ExecuteEvent() ObjMgr.updateDrawMap0(True) ObjMgr.updateDrawMap(True) self.ExecuteStory() if gcommon.scrollController != None: gcommon.scrollController.update() gcommon.scrollController.cnt += 1 self.updateEnemy() gcommon.game_timer = gcommon.game_timer + 1
def update(self): while True: t = __class__.table[self.tableIndex] if t[0] == (self.cnt - self.prevCnt): ObjMgr.addObj(Prominence1(self.x, self.y, t[2], t[1])) self.tableIndex += 1 if self.tableIndex >= len(__class__.table): self.remove() return self.prevCnt = self.cnt else: return
def update(self): if self.state == 0: self.y += self.flag if self.cnt > 20: self.nextState() else: self.x -= 2 if self.x <= -16: self.remove() return if self.cnt % 30 == (15 + self.flag * 5): ObjMgr.addObj(BossLastBattery1Beam(self.x, self.y, 2 * self.flag))
def __init__(self, t): super(MovableBattery1, 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.firstShot = t[4] self.moveTable = t[5] 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("MovableBattery1 is ng start point (" + str(self.mx) + ","+ str(self.my) +") (" + str(self.x) + "," + str(self.y)+"") else: ObjMgr.addObj(MovableBattery1p(self.x, self.y, self.firstShot, self.moveTable)) self.remove()
def ExecuteStory(self): while True: if len(self.story) <= self.story_pos: return s = self.story[self.story_pos] if s[0] < gcommon.game_timer: pass elif s[0] != gcommon.game_timer: return else: t = s[1] # [1]はクラス型 obj = t(s) # ここでインスタンス化 ObjMgr.addObj(obj) self.story_pos = self.story_pos + 1
def __init__(self, t): super(Boss2, self).__init__() self.t = gcommon.T_BOSS1 self.isBossRush = t[4] if self.isBossRush: self.x = t[2] self.y = t[3] else: pos = gcommon.mapPosToScreenPos(t[2], t[3]) self.x = pos[0] self.y = pos[1] self.left = 16 self.top = 9 self.right = 63 self.bottom = 38 self.hp = 999999 # 破壊できない self.layer = gcommon.C_LAYER_GRD self.ground = True self.score = 7000 self.subcnt = 0 self.dx = 0.5 self.dy = 0 self.hitcolor1 = 3 self.hitcolor2 = 7 self.tblIndex = 0 self.cycleCount = 0 self.brake = False self.feelers = [] self.feelers.append(Feeler(self, 50, 29, 8, 6)) self.feelers.append(Feeler(self, 16, 29, 24, 6)) self.feelers.append(Feeler(self, 16, 8, 40, 6)) self.feelers.append(Feeler(self, 50, 8, 56, 6)) self.feelerShots = [] ObjMgr.addObj(self.feelers[0]) ObjMgr.addObj(self.feelers[1]) ObjMgr.addObj(self.feelers[2]) ObjMgr.addObj(self.feelers[3]) self.bossCells = [] self.timerObj = None if self.isBossRush: self.layer = gcommon.C_LAYER_SKY self.ground = False self.state = 900 self.x = 256 self.y = 81 else: self.bossBase = Boss2Base2(self) ObjMgr.addObj(self.bossBase)
def update(self): if self.cnt % 3 == 0: obj = ObjMgr.addObj(enemy.Explosion(32 +random.randrange(64), random.randrange(gcommon.SCREEN_MAX_Y), gcommon.C_LAYER_GRD, gcommon.C_EXPTYPE_SKY_M)) obj.particle = False if self.cnt < 120: # 120超えるとサウンドなし BGM.sound(gcommon.SOUND_MID_EXP)
def broken(self): self.setState(100) self.shotHitCheck = False enemy.removeEnemyShot() ObjMgr.objs.append(boss.BossExplosion(gcommon.getCenterX(self), gcommon.getCenterY(self), gcommon.C_LAYER_EXP_SKY)) GameSession.addScore(self.score) self.remove() 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.addObj(enemy.Delay(enemy.StageClear, None, 240))
def update(self): if self.x < -40 or self.x > gcommon.SCREEN_MAX_X + 16: self.remove() return if self.state == 0 and self.first == self.cnt: self.nextState() elif self.state == 1: if self.cnt > 180: self.nextState() return elif self.cnt % 30 == 0: ObjMgr.addObj( Cell3([ 0, 0, self.x + 12, self.y, 0.0, -1.0 + self.mirror * 2.0, 60 ]))
def addProminence(self): s = 1.0 for i in range(self.pCount): #ObjMgr.addObj(Prominence1(self.x, self.y, self.radius + (i -self.pCount/2)*3 , 1)) if i > (self.pCount >> 1): ObjMgr.addObj( Prominence2( self.x, self.y, self.radius + s * self.pCount * (self.pCount - i) / self.pCount, 1, self.direction, self.position)) else: ObjMgr.addObj( Prominence2( self.x, self.y, self.radius + s * self.pCount * (self.pCount - i) / self.pCount, 0, self.direction, self.position)) s = -1.0 if s == 1.0 else 1
def shotHomingMissile(self): if self.homingMissileFlag: if self.homingMissileCnt == 20: obj = enemy.HomingMissile1(self.x + 68, self.y + 8, 48) obj.imageSourceIndex = 1 obj.imageSourceX = 128 obj.imageSourceY = 80 ObjMgr.addObj(obj) obj = enemy.HomingMissile1(self.x + 68, self.y + 48, 16) obj.imageSourceIndex = 1 obj.imageSourceX = 128 obj.imageSourceY = 80 ObjMgr.addObj(obj) self.homingMissileCnt += 1 if self.homingMissileCnt >= self.homingMissileInterval: self.homingMissileCnt = 0
def __init__(self, t): super(BossLast1, self).__init__() self.isBossRush = t[2] self.x = 256 self.y = 0 self.left = 52 self.top = 80 self.right = 111 self.bottom = 111 self.hp = BossLast1.initHp self.layer = gcommon.C_LAYER_UNDER_GRD self.ground = True self.score = 20000 self.exptype = gcommon.C_EXPTYPE_GRD_BOSS # 破壊状態 self.brokenState = 0 self.coreBrightState = 0 self.coreBrightness = 0 self.shotType = 3 self.beamIndex = 0 self.cycleCount = 0 # 本体ビームカウント self.cycleCount2 = 0 self.beam1List = [None] * 4 self.beam2 = None self.roundBeam = None # ボスの攻撃形態 self.mode = 0 self.coreX = self.x +32+16+32 self.coreY = self.y +64+16+16 # コアの回転角度 self.rad = 0.0 self.subState = 0 self.subCnt = 0 self.arrowRad = math.pi self.omega = 0.0 self.random = gcommon.ClassicRand() self.fallShot2RadIndex = 0 pyxel.image(2).load(0,0,"assets/graslay_last-3.png") # 移動ビーム砲台発射口 ObjMgr.addObj(BossLast1Launcher(self.x, self.y, -1)) ObjMgr.addObj(BossLast1Launcher(self.x, self.y +176, 1)) self.timerObj = None if self.isBossRush: self.timerObj = enemy.Timer1.create(100)
def init(self): self.mouseManager = MouseManager() ObjMgr.init(GameSession.multipleCount) if GameSession.weaponType == gcommon.WeaponType.TYPE_A: ObjMgr.myShip = MyShipA(self) else: ObjMgr.myShip = MyShipB(self) gcommon.cur_scroll_x = 0.5 gcommon.cur_scroll_y = 0.0 gcommon.cur_map_dx = 0.0 gcommon.cur_map_dy = 0.0 gcommon.eventManager = None self.story_pos = 0 self.event_pos = 0 gcommon.drawMap = None gcommon.game_timer = 0 gcommon.map_x = 0 gcommon.map_y = 0 gcommon.scroll_flag = True self.initStory() self.initEvent() self.pauseMode = 0 # 0:ゲーム中 1:ポーズ 2:CONTINUE確認 self.pauseMenuPos = 0 self.pauseMenuRects = [ gcommon.Rect.createWH(127 - 32 + 10, 192 / 2 - 32 + 15, 80 - 8, 8), gcommon.Rect.createWH(127 - 32 + 10, 192 / 2 - 32 + 25, 80 - 8, 8), gcommon.Rect.createWH(127 - 32 + 10, 192 / 2 - 32 + 35, 80 - 8, 8), gcommon.Rect.createWH(127 - 32 + 10, 192 / 2 - 32 + 45, 80 - 8, 8) ] self.pauseMouseOnOffRects = [ gcommon.Rect.createWH(127 - 32 + 10 + 26, 192 / 2 - 32 + 26 - 1, 8, 8), gcommon.Rect.createWH(127 - 32 + 10 + 48, 192 / 2 - 32 + 26 - 1, 8, 8) ] self.pauseCnt = 0 pyxel.mouse(False) # ステージ初期化 stage.Stage.initStage(self.stage, self.restart) self.skipGameTimer()
def update(self): if self.x < -24: self.remove() return if self.state == 0 and self.first == self.cnt: self.setState(1) elif self.state == 1: if self.cnt % 12 == 0: ObjMgr.insertObj( Fire1(self.x, self.y, self.direction, int(self.life))) self.life += self.lifeDelta1 if self.cnt > self.length: self.setState(2) elif self.state == 2: if self.cnt % 12 == 0: ObjMgr.insertObj( Fire1(self.x, self.y, self.direction, int(self.life))) self.life += self.lifeDelta2 if self.life < 5.0: self.life = 10 self.setState(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): if self.cnt == 0: self.initY = __class__.initYTable[self.moveTableNo] + gcommon.map_y #gcommon.debugPrint("init y = " + str(self.initY)) if self.cnt % self.interval == 0: shotFirst = self.shotFirst if GameSession.difficulty == gcommon.DIFFICULTY_EASY: shotFirst = -1 elif GameSession.difficulty == gcommon.DIFFICULTY_NORMAL: if self.cnt2 != self.max - 1: shotFirst = -1 x = 256 if self.moveTableNo == 4: x = -16 ObjMgr.addObj( Fighter4([ 0, 0, x, self.initY - gcommon.map_y, __class__.moveTableTable[self.moveTableNo], shotFirst ])) self.cnt2 += 1 if self.cnt2 >= self.max: self.remove()
def attack0(self): if self.attackCnt % 180 == 0: # レーザー omega = math.pi / 4 if self.cnt % 360 == 0 else -math.pi / 4 if GameSession.isHard(): for i, pt in enumerate(__class__.laserPointTable): ObjMgr.addObj( boss.ChangeDirectionLaser1( self.x + pt[0], self.y + pt[1], -math.pi / 2 - math.pi / 16 + math.pi / 4 * i, omega)) else: for i, pt in enumerate(__class__.laserPointTable): if i & 1 == 0: ObjMgr.addObj( boss.ChangeDirectionLaser1( self.x + pt[0], self.y + pt[1], -math.pi / 2 - math.pi / 16 + math.pi / 4 * i, omega)) self.attackCnt += 1 if self.attackCnt >= 180: self.attackCnt = 0 self.attackState += 1
def update(self): if self.state == 0: # 上に射出 if self.dy < 4.0: self.dy += 0.060 elif self.dy > 0: # ボスから射出されるときはレイヤが後ろなので self.layer = gcommon.C_LAYER_SKY self.x += self.dx self.y += self.dy if self.y + gcommon.map_y + 8 > gcommon.waterSurface_y: enemy.WaterSplash.appendDr( self.x + 8, gcommon.waterSurface_y - gcommon.map_y, gcommon.C_LAYER_SKY, math.pi * 1.5, math.pi / 6, 30) self.nextState() elif self.state == 1: self.dx *= 0.5 self.dy -= 0.5 self.x += self.dx self.y += self.dy if self.dy < -2.0: self.nextState() elif self.state == 2: self.dx *= 0.8 self.dy *= 0.8 self.x += self.dx self.y += self.dy if abs(self.dy) < 0.1: self.nextState() elif self.state == 3: if self.cnt >= 60: self.remove() enemy.Particle2.append(self.x + 8, self.y + 8, 20) rad = math.pi * 1.25 if self.x < 112 else math.pi * 1.75 obj = Bat1a(self.parent, self.x, self.y, rad) self.parent.appendBat(obj) ObjMgr.addObj(obj)
def update(self): self.mouseManager.update() if self.pauseMode == gcommon.PAUSE_PAUSE: self.doPause() return elif self.pauseMode == gcommon.PAUSE_CONTINUE: self.doConfirmContinue() return else: if pyxel.btnp(pyxel.KEY_ESCAPE) or pyxel.btnp( pyxel.GAMEPAD_1_START): self.pauseMode = gcommon.PAUSE_PAUSE self.pauseCnt = 0 pygame.mixer.music.pause() return elif pyxel.btnp(pyxel.KEY_O): ObjMgr.debugListObj() # 星 if gcommon.scroll_flag and gcommon.draw_star: gcommon.star_pos -= 0.2 if gcommon.star_pos < 0: gcommon.star_pos += 255 self.ExecuteEvent() if gcommon.scrollController != None: gcommon.scrollController.update() gcommon.scrollController.cnt += 1 # マップ処理0 if gcommon.scroll_flag: ObjMgr.updateDrawMap0(False) # 自機移動 ObjMgr.myShip.update() # マップ処理 if gcommon.scroll_flag: ObjMgr.updateDrawMap(False) self.ExecuteStory() newShots = [] for shot in ObjMgr.shots: if shot.removeFlag == False: shot.update() if shot.removeFlag == False: newShots.append(shot) ObjMgr.shots = newShots self.updateEnemy() self.Collision() gcommon.game_timer = gcommon.game_timer + 1
def update(self): self.countMover.update() self.gun_cx = self.x + 20.0 self.gun_cy = self.y self.subCnt += 1 if abs(self.countMover.dx) > 0.025 or abs(self.countMover.dy) > 0.025: self.wheelCnt += 1 if self.state == 0: if self.countMover.tableIndex in (2, 4, 6, 8, 10): self.gunRad = gcommon.getRadToShip(self.x, self.y, self.gunRad +math.pi, math.pi/60) - math.pi elif self.countMover.tableIndex in (1, 3, 5, 7, 9, 11): self.shotMainState() if self.countMover.tableIndex == 1: if self.countMover.cnt % 45 == 0: ObjMgr.addObj(enemyBattery.MovableBattery1p(self.x -16, self.y, 30, [[100*8, 0, -1.0, 0.0]])) elif self.countMover.tableIndex == 5: if self.countMover.cnt % 45 == 0: ObjMgr.addObj(enemyBattery.MovableBattery1p(self.x -16, self.y, 30, [[0, 5, 44, self.y, 1.0],[100*8, 0, 0.0, 1.0]])) elif self.countMover.tableIndex == 9: if self.countMover.cnt % 45 == 0: ObjMgr.addObj(enemyBattery.MovableBattery1p(self.x -16, self.y, 30, [[0, 5, 44, self.y, 1.0],[100*8, 0, 0.0, -1.0]])) if self.hp < boss.BOSS_WAREHOUSE_HP/3: # 発狂モード self.state = 1 elif self.state == 1: # 発狂モード if self.gunRad < 0.75 * math.pi: self.gunRad += 0.025* math.pi else: self.nextState() elif self.state == 2: if self.cnt % self.crazyShotInterval == 0: self.shotMain() self.gunRad -= 0.025* math.pi if self.gunRad < -0.75 * math.pi: self.nextState() elif self.state == 3: if self.cnt % self.crazyShotInterval == 0: self.shotMain() self.gunRad += 0.025* math.pi if self.gunRad > 0.75 * math.pi: self.setState(1)
def attack1(self): if GameSession.isEasy(): return if self.attackCnt % 10 == 0: n = int(self.attackCnt / 10) pt = __class__.laserPointTable[n] if GameSession.isHard(): ObjMgr.addObj( boss.DelayedShotLaser1( self.x + pt[0], self.y + pt[1], -math.pi / 2 + math.pi / 4 * n + math.pi / 16)) ObjMgr.addObj( boss.DelayedShotLaser1( self.x + pt[0], self.y + pt[1], -math.pi / 2 + math.pi / 4 * n - math.pi / 16)) else: ObjMgr.addObj( boss.DelayedShotLaser1(self.x + pt[0], self.y + pt[1], -math.pi / 2 + math.pi / 4 * n)) self.attackCnt += 1 if self.attackCnt > 10 * 7: self.attackCnt = 0 self.attackState += 1
def doEffect(self, effectSound): # 跳弾表示 ObjMgr.addObj(enemy.Particle1(self.x + self.right, self.y, 0.0, 4, 50)) if effectSound: BGM.sound(gcommon.SOUND_HIT, gcommon.SOUND_CH2)
def createByPos(cls, x, y, hide=False): return ObjMgr.addObj(ScoreItem1(x, y, hide))