def update(self): self.x = int(self.outside.x) + 48 self.y = int(self.outside.y) + 48 if self.cnt % 28 == 0: shot_cross(self.x+32, self.y-8, self.crosscnt) gcommon.sound(gcommon.SOUND_SHOT2) self.crosscnt += 3 #self.dr1 = gcommon.get_atan_no_to_ship(self.x + 67, self.y + 37) #print("dr " + str(self.dr1)) #enemy.enemy_shot_dr(self.x + 67, self.y + 37, 2, 0, self.dr1) #enemy.enemy_shot(self.x+67, self.y+37,2,0) pass if self.state == 0: if self.cnt == 1: self.dr1 = gcommon.get_atan_no_to_ship(self.x + 80, self.y + 48) if self.cnt & 7 ==7 and self.shotcnt < 4: enemy.enemy_shot_dr(self.x + 80, self.y + 48, 4, 0, self.dr1) gcommon.sound(gcommon.SOUND_SHOT2) self.shotcnt += 1 if self.cnt == 50: self.cnt = 0 self.shotcnt = 0 self.state = 1 elif self.state == 1: if self.cnt == 1: self.dr2 = gcommon.get_atan_no_to_ship(self.x -16, self.y + 48) if self.cnt & 7 ==7 and self.shotcnt < 4: enemy.enemy_shot_dr(self.x -16, self.y + 48, 4, 0, self.dr2) gcommon.sound(gcommon.SOUND_SHOT2) self.shotcnt += 1 if self.cnt == 50: self.cnt = 0 self.shotcnt = 0 self.state = 0
def __init__(self, t): super(Fighter2, self).__init__() self.t = gcommon.T_FIGHTER2 self.y = t[2] self.pos = t[3] # -1:left 1:right 0:auto if self.pos == 0: if gcommon.ObjMgr.myShip.x > 120: self.pos = -1 self.x = -24 else: self.pos = 1 self.x = 256 elif self.pos < 0: self.x = -24 else: self.x = 256 self.dr = gcommon.get_atan_no_to_ship(self.x +12, self.y + 12) self.left = 2 self.top = 2 self.right = 21 self.bottom = 21 self.hp = 5 self.layer = gcommon.C_LAYER_SKY self.score = 30 self.hitcolor1 = 5 self.hitcolor2 = 6 self.exptype = gcommon.C_EXPTYPE_SKY_S
def update(self): if self.state == 0: # 伸びる if self.cnt < 15: pass elif self.cnt % 2 == 0: tempDr = gcommon.get_atan_no_to_ship(self.x + 4, self.y + 4) rr = tempDr - self.dr if rr == 0: pass elif (tempDr - self.dr) > 0: self.dr = (self.dr + 1) & 63 else: self.dr = (self.dr - 1) & 63 self.x += gcommon.cos_table[self.dr] * 3 self.y += gcommon.sin_table[self.dr] * 3 self.cells.append([self.x, self.y]) if self.cnt > 60: self.nextState() elif self.state == 1: if self.cnt > 20: self.nextState() elif self.state == 2: del self.cells[-1] # 最後から消す if len(self.cells) == 0: self.remove() else: pos = self.cells[len(self.cells) - 1] self.x = pos[0] self.y = pos[1]
def update(self): if self.cnt & 2 == 0 and self.cnt <= 63: tempDr = gcommon.get_atan_no_to_ship(self.x +11, self.y +11) if self.dr == -1: self.dr = tempDr else: rr = tempDr - self.dr if rr == 0: pass elif (tempDr - self.dr) > 0: self.dr = (self.dr + 1) & 63 else: self.dr = (self.dr - 1) & 63 if self.cnt < 30: self.speed *= 0.97 elif self.cnt < 60 and self.speed < 5: self.speed *= 1.1 #if self.cnt & 15 == 15: # enemy.Particle1.append(self.x, self.y, gcommon.atan_table[self.dr] + math.pi) self.x += gcommon.cos_table[self.dr] * self.speed self.y += gcommon.sin_table[self.dr] * self.speed #if self.speed < 6: # self.speed += 0.05 if self.x <= -24 or self.x > gcommon.SCREEN_MAX_X: self.remove() return elif self.y <= -24 or self.y > gcommon.SCREEN_MAX_Y: self.remove() return self.updateParticle()
def update(self): if self.cnt & 2 == 0 and self.cnt <= 63: tempDr = gcommon.get_atan_no_to_ship(self.x +11, self.y +11) if self.dr == -1: self.dr = tempDr else: rr = tempDr - self.dr if rr == 0: pass elif (tempDr - self.dr) > 0: self.dr = (self.dr + 1) & 63 else: self.dr = (self.dr - 1) & 63 if self.cnt < 30: self.speed *= 0.97 elif self.cnt < 60 and self.speed < 5: self.speed *= 1.1 self.x += gcommon.cos_table[self.dr] * self.speed self.y += gcommon.sin_table[self.dr] * self.speed #if self.speed < 6: # self.speed += 0.05 if self.x <= -24 or self.x > gcommon.SCREEN_MAX_X: self.remove() elif self.y <= -24 or self.y > gcommon.SCREEN_MAX_Y: self.remove()
def update(self): if self.state == 0: if abs(self.x - ObjMgr.myShip.x) < 150 and abs( self.y - ObjMgr.myShip.y) < 50: self.nextState() elif self.state == 1: if self.cnt % 10 == 0: n = gcommon.get_atan_no_to_ship(self.x + 7, self.y + 7) self.speed += 0.1 if self.speed > 2.0: self.speed = 2.0 self.dx = gcommon.cos_table[n] * self.speed self.dy = gcommon.sin_table[n] * self.speed self.x += self.dx self.y += self.dy if self.cnt > 360: self.remove()
def update(self): self.subCnt += 1 if self.rolling: self.rad += self.omega if self.rad >= math.pi * 2: self.rad -= math.pi * 2 elif self.rad < 0.0: self.rad += math.pi * 2 if self.state == 0: if self.subState == 0: # 後ろから落下 self.x += self.dx self.y += self.dy self.dy += 0.2 if self.y > 80: # 跳ねる self.dy = -self.dy * 0.8 for i in range(3): enemy.Particle1.append(self.x + 39.5, self.y + 88, -math.pi / 4 - math.pi / 4 * i) #ObjMgr.objs.append( # enemy.Particle1(self.x +39.5, self.y +88, -math.pi/4 -math.pi/4*i)) if self.x > 280: self.dx = -self.dx # 回転を逆にする self.omega = -math.pi / 128 self.setSubState(1) elif self.subState == 1: # 右端から戻ってくる self.x += self.dx self.y += self.dy self.dy += 0.2 if self.y > 80: # 跳ねる self.dy = -self.dy for i in range(4): ObjMgr.objs.append( enemy.Particle1(self.x + 39.5, self.y + 88, -math.pi / 4 - math.pi / 4 * i, 8, 50)) if self.x <= 152: self.omega = -math.pi / 64 self.setSubState(2) elif self.subState == 2: # 規定位置まで移動 self.y -= 1 if self.y < 50: self.y = 50 if self.subCnt > 30: self.dx = 0 self.dy = -2 self.moveState = 0 # 0:上に移動 self.nextState() elif self.state == 1: if self.subState == 0: # 待ち if self.subCnt == 30: self.setSubState(1) elif self.subState == 1: # 開く self.distance += 0.5 if self.distance > 38: self.setSubState(2) elif self.subState == 2: # 開いている(攻撃) if self.stateCycle & 1 == 0: # 最初(奇数)のサイクル if self.finMode == 0: if self.subCnt & 7 == 0: # バラバラ弾 for i in range(4): enemy.enemy_shot( self.x + 39.5 + math.cos(self.rad + math.pi / 2 * i) * 32, self.y + 39.5 + math.sin(self.rad + math.pi / 2 * i) * 32, 4, 0) else: if self.subCnt % 15 == 0: for i in range(4): # 破壊可能な自動追尾泡?ショット ObjMgr.objs.append( BossFactoryShot1( self.x + 39.5 + math.cos(self.rad + math.pi / 4 + math.pi / 2 * i) * 32, self.y + 39.5 + math.sin(self.rad + math.pi / 4 + math.pi / 2 * i) * 32)) if self.subCnt == 30: self.setSubState(3) else: # 偶数サイクル if self.finMode == 0: if self.subCnt == 1: self.omega = math.pi / 64 # 卍のように撃つ if self.subCnt % __class__.roundShotInterval[ GameSession.difficulty] == 1: rr = 0 if self.finMode == 0 else math.pi / 4 for i in range(4): px = self.x + 39.5 + math.cos( self.rad + rr + math.pi / 2 * i) * 32 py = self.y + 39.5 + math.sin( self.rad + rr + math.pi / 2 * i) * 32 no = gcommon.get_atan_no( self.x + 39.5, self.y + 39.5, px, py) enemy.enemy_shot_dr(px, py, 3, 0, no) #self.omega += math.pi/2400 # 弾を少しずらすため、回転を遅くする self.omega *= 0.99 else: # 弧を描くような弾 if self.subCnt % __class__.arcShotInterval[ GameSession.difficulty] == 0: for i in range(4): px = self.x + 39.5 + math.cos( self.rad + math.pi / 4 + math.pi / 2 * i) * 32 py = self.y + 39.5 + math.sin( self.rad + math.pi / 4 + math.pi / 2 * i) * 32 ObjMgr.addObj( BossFactoryShot2( px, py, self.rad + math.pi / 4 - math.pi / 2 + math.pi / 2 * i)) if self.subCnt >= 150: self.omega = -math.pi / 64 self.setSubState(3) elif self.subState == 3: # 閉まる self.distance -= 0.5 if self.distance < 22: self.distance = 22.0 self.setSubState(0) self.finMode = (self.finMode + 1) & 1 self.subStateCycle += 1 self.firstCycle = False if self.subStateCycle > 3: self.nextState() # state:1での移動 if self.subStateCycle > 1 and self.firstCycle == False: # 最初は移動しない if self.moveState == 0: # 上に移動 self.y += self.dy if self.y < 30: self.dy += 0.05 if self.dy >= 0.0: self.dy = 0.05 self.moveState = 1 elif self.dy > -2.0: self.dy -= 0.05 else: # 下に移動 self.y += self.dy if self.y > 100: self.dy -= 0.05 if self.dy <= 0.0: self.dy = -0.05 self.moveState = 0 elif self.dy < 2.0: self.dy += 0.05 elif self.state == 2: # 拡散ビーム if self.subState == 0: # 待ち if self.centerRadius >= 1: self.centerRadius -= 1 if self.subCnt > 20: self.setSubState(1) elif self.subState == 1: # 拡散ビーム? if self.cnt & 7 == 7: rad = (self.stateCycle & 1) * 2 * math.pi / 16 for i in range(64): if i & 4 == 0: ObjMgr.objs.append( boss.BossLaserBeam1(self.x + 39.5, self.y + 39.5, rad)) rad += 2 * math.pi / 64 if self.cnt > 60: self.setSubState(2) elif self.subState == 2: # 待ち if self.centerRadius < 14: self.centerRadius += 1 if self.subCnt > 30: self.setState(3) elif self.state == 3: # 自機を追いかける if self.cnt == 1: self.speed = 0.0 self.moveDr64 = -1 if self.subState == 0: # 追いかける if self.cnt % 4 == 0 and self.cnt <= 30 * GameSession.enemy_shot_rate: tempDr = gcommon.get_atan_no_to_ship( self.x + 39.5, self.y + 39.5) # 右左を決める if self.moveDr64 == -1: self.moveDr64 = tempDr else: self.moveDr64 = (self.moveDr64 + gcommon.get_leftOrRight( self.moveDr64, tempDr)) & 63 self.speed += 0.5 if self.speed >= 3.0: self.speed = 3.0 self.x += gcommon.cos_table[self.moveDr64] * self.speed self.y += gcommon.sin_table[self.moveDr64] * self.speed #if self.x < 40 or self.y < 40 or (self.x + 40 > gcommon.SCREEN_MAX_X) or (self.y +40 > gcommon.SCREEN_MAX_Y): if self.subCnt > 120: self.setSubState(1) elif self.subState == 1: # 戻る if self.subCnt == 1: pass #print("self.subState == 1") if self.cnt & 2 == 0: # 右左を決める tempDr = gcommon.get_atan_no( self.x, self.y, 152, (gcommon.SCREEN_HEIGHT - 80) / 2) self.moveDr64 = (self.moveDr64 + gcommon.get_leftOrRight( self.moveDr64, tempDr)) & 63 self.x += gcommon.cos_table[self.moveDr64] * self.speed self.y += gcommon.sin_table[self.moveDr64] * self.speed l = math.hypot(152 - self.x, (gcommon.SCREEN_HEIGHT - 80) / 2 - self.y) if l < 4: self.stateCycle += 1 # ステート1に戻る self.setState(4) elif l < 50: self.speed -= 0.25 if self.speed < 0.5: self.speed = 0.5 elif self.state == 4: if self.subState == 0: # 開く if self.distance < 38: self.distance += 0.5 #print("rad = " + str(self.rad)) if self.distance >= 38 and abs(self.rad) <= math.pi / 64: self.rad = 0.0 #self.rolling = False self.setSubState(1) self.dr64 = -1 elif self.subState == 1: if self.subCnt % __class__.homingBeamInterval[ GameSession.difficulty] == 1: # ホーミングビーム rr = 0.0 if self.finMode == 0 else math.pi / 4 i = (int(self.subCnt / 40)) & 3 for i in range(2): px = self.x + 39.5 + math.cos(self.rad + rr + math.pi * i) * 32 py = self.y + 39.5 + math.sin(self.rad + rr + math.pi * i) * 32 dr = gcommon.atan2x(px - (self.x + 39.5), py - (self.y + 39.5)) beam = enemyShot.HomingBeam1(px, py, dr) ObjMgr.addObj(beam) if self.subCnt > 160: self.setSubState(2) elif self.subState == 2: # 閉まる self.distance -= 0.5 if self.distance < 22: self.distance = 22.0 # ステート1に戻る self.setState(1) self.rolling = True elif self.state == 900: self.x -= 1 self.y = 50 if self.x <= 152: self.setState(1) #self.xpoints1 = [] #self.xpoints2 = [] self.xpolygonsList = [] # Finの座標計算 for i in range(8): distance = 22.0 if self.finMode == 0: if i & 1 == 0: distance = self.distance else: if i & 1 == 1: distance = self.distance #self.xpoints1.append(gcommon.getAnglePoints([self.x + 39.5, self.y +39.5], # bossFactoryFin1, [15.5, -distance], self.rad + math.pi/4 *i)) #self.xpoints2.append(gcommon.getAnglePoints([self.x + 39.5, self.y +39.5], # bossFactoryFin2, [15.5, -distance], self.rad + math.pi/4 *i)) self.xpolygonsList.append( gcommon.getAnglePolygons([self.x + 39.5, self.y + 39.5], self.polygonList, [15.5, -distance], self.rad + math.pi / 4 * i))