def update(self): if self.state == 0: # 落下中 if gcommon.isMapFreePos(self.x + self.dx, self.y + 2) == False: self.state = 1 self.dx = 2 self.dy = 0 else: if gcommon.isMapFreePos(self.x + self.dx, self.y + 2): self.state = 0 self.dx = 2 self.dy = 2 self.x += self.dx self.y += self.dy if self.state == 1: self.y += gcommon.cur_map_dy if self.x <= -8 or self.x >= 256: self.remove() return elif self.y <= -8 or self.y >= 192: self.remove() return else: if gcommon.isMapFreePos(self.x, self.y) == False: self.remove() return if self.state == 0: self.splash()
def update(self): if self.state == 0: # 落下中 if self.cnt < 15: self.dx *= 0.9 else: self.dx = 0 self.x += self.dx self.y += self.dy if abs(self.dy) <= 3.0: self.dy *= 1.05 if self.x <= -8 or self.x >= 256: self.remove() return elif self.y <= -8 or self.y >= 192: self.remove() return else: if gcommon.isMapFreePos(self.x, self.y) == False: # 爆発形態へ self.setExplosion() self.splash() else: # 爆発中 if self.cnt > 30: self.remove() self.cnt += 1
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 update(self): self.x = self.x + self.dx self.y = self.y + self.dy if self.x <= -8 or self.x >= 256: self.remove() return elif self.y <= -8 or self.y >= 192: self.remove() return else: if abs(self.dy) <= 6: self.dy *= 1.05 if gcommon.isMapFreePos(self.x, self.y) == False: self.remove() return self.splash()
def Collision(self): # 壁との当たり判定 if ObjMgr.myShip.sub_scene == 1 and \ gcommon.isMapFreePos(ObjMgr.myShip.x+ 9, ObjMgr.myShip.y +7) == False: self.my_broken() return # shot & enemy for obj in ObjMgr.objs: if obj.removeFlag: continue obj.hit = False #if obj.layer!=gcommon.C_LAYER_GRD and obj.layer!=gcommon.C_LAYER_SKY: if obj.shotHitCheck == False: continue for shot in ObjMgr.shots: if obj.checkShotCollision(shot): broken = obj.doShotCollision(shot) shot.hit(obj, broken) if broken or obj.removeFlag: break # enemy shot and wallObj for wallObj in ObjMgr.objs: if wallObj.removeFlag: continue if wallObj.enemyShotCollision == False: continue for shot in ObjMgr.objs: if shot.removeFlag: continue if shot.layer != gcommon.C_LAYER_E_SHOT: continue if wallObj.checkEnemyShotCollision(shot): shot.removeFlag = True break # my ship & enemy for obj in ObjMgr.objs: if obj.removeFlag == False and obj.hitCheck: if obj.checkMyShipCollision() and ObjMgr.myShip.sub_scene == 1: self.my_broken() break
def update(self): if self.state == 0: if self.cnt < 10: self.y += 0.5 else: self.x = self.x + self.dx if self.x <= -8 or self.x >= 256: self.remove() elif self.y <= -8 or self.y >= 192: self.remove() else: if abs(self.dx) <= 8: self.dx *= 1.05 if gcommon.isMapFreePos(self.x, self.y) == False: # 爆発形態へ self.setExplosion() else: # 爆発中 if self.cnt > 6: self.remove() self.cnt += 1
def update(self): if self.state == 0: self.x = self.x + self.dx self.y = self.y + self.dy if self.x <= -8 or self.x >= 256: self.remove() return elif self.y <= -8 or self.y >= 192: self.remove() return else: if abs(self.dy) <= 6: self.dy *= 1.05 if gcommon.isMapFreePos(self.x, self.y) == False: # 爆発形態へ self.setExplotion() else: # 爆発中 if self.cnt > 3: self.remove() return self.splash() self.cnt += 1
def update(self): #self.radOffset -= math.pi * 0.05 #if self.radOffset < 0: # self.radOffset += 2 * math.pi self.radOffset += math.pi * 0.02 if self.radOffset > 2 * math.pi: self.radOffset -= 2 * math.pi if self.state == 0: if self.limit >= -10: self.limit -= 2 else: self.nextState() elif self.state == 1: if self.cnt > 40: self.nextState() self.beamRadStart = 0.0 elif self.state == 2: if self.beamRadDelta > -math.pi/120: self.beamRadDelta -= (math.pi/120/30) if self.beamRadStart < math.pi*0.35: self.beamRadStart += math.pi/200 if self.cnt > 150: self.nextState() elif self.state == 3: if self.beamRadDelta < math.pi/120: self.beamRadDelta += (math.pi/120/30) if self.beamRadStart > -math.pi*0.35: self.beamRadStart -= math.pi/200 if self.cnt > 150: self.stateCycle += 1 if self.stateCycle == 3: self.setState(10) else: self.setState(2) elif self.state == 10: if self.beamRadDelta > 0: self.beamRadDelta -= (math.pi/120/30) self.beamRadStart += math.pi/200 if self.beamRadStart >= 0: self.nextState() elif self.state == 11: if self.limit < 240: self.limit += 2 else: self.remove() # 描画準備 rad = self.radOffset x2 = self.x r = 0 beamRad = self.beamRadStart px = self.x py = self.y count = 0 for i in range(len(self.listArray)): self.listArray[i] = [] while(x2 > self.limit and count < 50): #y2 = py - math.sin(rad) * r pos = gcommon.getAngle(0, - math.sin(rad) * r, beamRad) x2 = px + pos[0] y2 = py + pos[1] n = int(rad / (math.pi/6)) % 12 #print(str(n)) if gcommon.isMapFreePos(x2, y2) == False and self.cnt & 3 == 0: enemy.create_explosion(x2, y2, gcommon.C_LAYER_GRD, gcommon.C_EXPTYPE_GRD_S) self.listArray[n].append([x2, y2]) # 奥から描画するために反転する if n in (8,9): self.listArray[n].reverse() rad += math.pi/4 if rad > math.pi*2: rad -= math.pi*2 if r < 40: r += 2 px += (math.cos(beamRad)* -8) py += (math.sin(beamRad)* -8) beamRad += self.beamRadDelta count += 1
def update(self): if self.moveIndex >= len(__class__.moveTable): pass else: t = __class__.moveTable[self.moveIndex] cmd = t[1] if cmd == __class__.STOP: # 停止 pass elif cmd == __class__.MOVE_LEFT: # 左に移動 self.dx = 1 elif cmd == __class__.MOVE_RIGHT: # 右に移動 self.dx = -1 self.moveCnt += 1 if self.moveCnt >= t[0]: self.moveIndex += 1 self.moveCnt = 0 if self.state == 0: # ボディ部の移動 self.x -= self.speed * self.dx self.foregroundLegX += self.speed * self.dx self.backgroundLegX += self.speed * self.dx if (self.dx == 1 and self.foregroundLegX >= 0) or \ (self.dx == -1 and self.foregroundLegX <= 0): self.nextState() elif self.state == 1: # 奥側の脚を縮める nextFlag = 0 for i in range(4): if self.backgroundLegYArray[i] > 0: self.backgroundLegYArray[i] -= 1 else: nextFlag |= (1 << i) # 4ビット全部が立ったら if nextFlag == 15: self.nextState() elif self.state == 2: # 奥側の脚を進める self.backgroundLegX -= self.speed * self.dx if (self.dx == 1 and self.backgroundLegX <= -6 * 8) or \ (self.dx == -1 and self.backgroundLegX >= 6 * 8): self.nextState() elif self.state == 3: # 奥側の脚を伸ばす nextFlag = 0 for i in range(4): x = self.x + self.backgroundLegX + self.legXOffsetArray[i] + 8 if i in (0, 1): y = self.y - 32 - self.backgroundLegYArray[i] - 1 else: y = self.y + 64 + self.backgroundLegYArray[i] if gcommon.isMapFreePos(x, y): self.backgroundLegYArray[i] += 1 else: nextFlag |= (1 << i) # 4ビット全部が立ったら if nextFlag == 15: self.nextState() elif self.state == 4: # ボディ部の移動 self.x -= self.speed * self.dx self.foregroundLegX += self.speed * self.dx self.backgroundLegX += self.speed * self.dx if (self.dx == 1 and self.backgroundLegX >= 0) or \ (self.dx == -1 and self.backgroundLegX <= 0): self.nextState() elif self.state == 5: # 手前の脚を上げる nextFlag = 0 for i in range(4): if self.foregroundLegYArray[i] > 0: self.foregroundLegYArray[i] -= 1 else: nextFlag |= (1 << i) # 4ビット全部が立ったら if nextFlag == 15: self.nextState() # for i in range(4): # self.foregroundLegYArray[i] -= 1 # if self.foregroundLegYArray[i] == 0: # self.nextState() elif self.state == 6: # 手前の脚を進める self.foregroundLegX -= self.speed * self.dx if (self.dx == 1 and self.foregroundLegX <= -6 * 8) or \ (self.dx == -1 and self.foregroundLegX >= 6 * 8): self.nextState() elif self.state == 7: # 手前の脚を下げる nextFlag = 0 for i in range(4): x = self.x + self.foregroundLegX + self.legXOffsetArray[i] + 8 if i in (0, 1): y = self.y - 32 - self.foregroundLegYArray[i] - 1 else: y = self.y + 64 + self.foregroundLegYArray[i] if gcommon.isMapFreePos(x, y): self.foregroundLegYArray[i] += 1 else: nextFlag |= (1 << i) # 4ビット全部が立ったら if nextFlag == 15: self.setState(0) # for i in range(4): # self.foregroundLegYArray[i] += 1 # if self.foregroundLegYArray[i] == 5 * 8: # self.setState(0) # コリジョン更新 rects = [] rects.append(gcommon.Rect.create(5, 2, 79 - 5, 31 - 2)) # バー rects.append( gcommon.Rect.createWH(self.backgroundLegX - 16, -8, 112, 8)) rects.append( gcommon.Rect.createWH(self.backgroundLegX - 16, +32, 112, 8)) rects.append( gcommon.Rect.createWH(self.foregroundLegX - 16, -8, 112, 8)) rects.append( gcommon.Rect.createWH(self.foregroundLegX - 16, +32, 112, 8)) # シリンダー rects.append( gcommon.Rect.createWH(self.backgroundLegX - 16 + 4, -32 - self.backgroundLegYArray[0], 8, self.backgroundLegYArray[0] + 24)) rects.append( gcommon.Rect.createWH(self.backgroundLegX + 80 + 4, -32 - self.backgroundLegYArray[1], 8, self.backgroundLegYArray[1] + 24)) rects.append( gcommon.Rect.createWH(self.backgroundLegX - 16 + 4, 40, 8, self.backgroundLegYArray[2] + 24)) rects.append( gcommon.Rect.createWH(self.backgroundLegX + 80 + 4, 40, 8, self.backgroundLegYArray[3] + 24)) rects.append( gcommon.Rect.createWH(self.foregroundLegX - 16 + 4, -32 - self.foregroundLegYArray[0], 8, self.foregroundLegYArray[0] + 24)) rects.append( gcommon.Rect.createWH(self.foregroundLegX + 80 + 4, -32 - self.foregroundLegYArray[1], 8, self.foregroundLegYArray[1] + 24)) rects.append( gcommon.Rect.createWH(self.foregroundLegX - 16 + 4, 40, 8, self.foregroundLegYArray[2] + 24)) rects.append( gcommon.Rect.createWH(self.foregroundLegX + 80 + 4, 40, 8, self.foregroundLegYArray[3] + 24)) self.collisionRects = rects if self.x < -160: self.remove()