Esempio n. 1
0
 def checkMyShipCollision(self):
     if gcommon.check_collision(self.body, ObjMgr.myShip):
         return True
     if gcommon.check_collision(self.anchor, ObjMgr.myShip):
         return True
     return gcommon.check_collision_list(self.x, self.y,
                                         self.collisionRects, ObjMgr.myShip)
Esempio n. 2
0
    def Collision(self):
        # shot & enemy
        for obj in gcommon.ObjMgr.objs:
            if obj.removeFlag:
                continue
            obj.hit = False
            if obj.layer != gcommon.C_LAYER_GRD and obj.layer != gcommon.C_LAYER_SKY:
                continue

            for shot in gcommon.ObjMgr.shots:
                if shot.removeFlag == False and gcommon.check_collision(
                        obj, shot):
                    obj.hp -= gcommon.SHOT_POWER
                    if obj.hp <= 0:
                        obj.broken()
                    else:
                        obj.hit = True
                    shot.removeFlag = True
                    shot.group.remove(shot)
                    if len(shot.group.shots) == 0:
                        gcommon.ObjMgr.shotGroups.remove(shot.group)

                    if obj.removeFlag:
                        break

        # my bom & enemy
        if gcommon.ObjMgr.myBom != None:
            for obj in gcommon.ObjMgr.objs:
                if obj.layer==gcommon.C_LAYER_GRD \
                 or obj.layer==gcommon.C_LAYER_SKY \
                 or obj.layer==gcommon.C_LAYER_E_SHOT:
                    if math.sqrt((obj.x+(obj.right-obj.left)/2-gcommon.ObjMgr.myBom.x)**2+	\
                     (obj.y+(obj.bottom-obj.top)/2-gcommon.ObjMgr.myBom.y)**2) <=72:
                        if obj.layer == gcommon.C_LAYER_E_SHOT:
                            obj.removeFlag = True
                        else:
                            obj.hp -= gcommon.BOM_POWER
                            if obj.hp <= 0:
                                obj.broken()
                            else:
                                obj.hit = True

        # my ship & enemy
        if gcommon.ObjMgr.myShip.sub_scene == 1:
            for obj in gcommon.ObjMgr.objs:
                if obj.layer == gcommon.C_LAYER_E_SHOT or obj.layer == gcommon.C_LAYER_SKY:
                    if gcommon.check_collision(obj, gcommon.ObjMgr.myShip):
                        self.my_broken()
                        break
                elif obj.layer == gcommon.C_LAYER_ITEM:
                    if gcommon.check_collision(obj, gcommon.ObjMgr.myShip):
                        self.catch_item(obj)
                        obj.removeFlag = True
Esempio n. 3
0
 def checkMyShipCollision(self):
     if gcommon.check_collision(self, ObjMgr.myShip):
         self.hitCheck = False
         if self.state == 0:
             # しばらくすると当たり判定
             self.setState(1)
         else:
             self.setState(3)
             GameSession.addPlayerStock()
     return False
Esempio n. 4
0
 def checkMyShipCollision(self):
     if gcommon.check_collision(self, ObjMgr.myShip):
         return True
     else:
         # 触手部の当たり判定
         for pos in self.cells:
             x = self.x + pos[0]
             y = self.y + pos[1]
             if gcommon.check_collision2(x, y, self.cellRect,
                                         ObjMgr.myShip):
                 return True
         return False
Esempio n. 5
0
 def checkMyShipCollision(self):
     if gcommon.check_collision(self, ObjMgr.myShip):
         self.hitCheck = False
         if self.state == 0:
             # しばらくすると当たり判定
             self.setState(1)
         else:
             self.setState(3)
             BGM.sound(gcommon.SOUND_ITEM_GET, gcommon.SOUND_CH2)
             if self.hide:
                 GameSession.addScore(1000)
             else:
                 GameSession.addScore(500)
     return False
Esempio n. 6
0
 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
Esempio n. 7
0
 def checkShotCollision(self, shot):
     if shot.removeFlag == False and gcommon.check_collision(self, shot):
         return True
     else:
         return False
Esempio n. 8
0
 def checkShotCollision(self, shot):
     if shot.removeFlag:
         return False
     return gcommon.check_collision(self.body, shot)