コード例 #1
0
    def update(self):
        if (self.__timer <= 0):
            self.gameObject().destroy()
            return
        if (self.__shape is not None):
            self.__flipclr = not self.__flipclr
            if (self.__flipclr):
                self.gameObject().position += Vector2(0.05, 0)
                self.__shape.setColor((1, 1, 1))
            else:
                self.gameObject().position -= Vector2(0.05, 0)
                self.__shape.setColor((0, 0, 0))

        dt = self.time.deltaTime()
        self.__timer -= dt
        if (self.__delayTimer <= 0):
            gobj = self.gameObject()
            for i in range(2):
                pos = gobj.position + self.__offset + Vector2(
                    random.uniform(-self.__radius, self.__radius),
                    random.uniform(-self.__radius, self.__radius))
                PlaneGameDirector.instance().explosion(pos)
            self.__delayTimer = self.__delayTime
        else:
            self.__delayTimer -= dt
コード例 #2
0
	def onStart(self):
		print("trying to load level...")
		levelnode=hou.node("/obj/plane_level") #_bosstest
		if(levelnode is None):
			print("level not found")
		else:
			nodes=[x for x in levelnode.children() if x.name().find("plane_")==0]
			nodes.sort(key=lambda x: x.position()[1])
			self.__level=[(x.position(),x) for x in nodes]
			print("level loaded")
			print(self.__level)
		
		self.__globalVel=Vector2(0,-10)
		
		self.__score=GameObject("SCORE")
		self.__score.addComponent("ScoreComponent")
		self.__score.position=Vector2(10.5,9.5)
		
		self.__playerlives=GameObject("PLIVES")
		self.__playerlives.position=Vector2(11.0,8.0)
		ssc=self.__playerlives.addComponent("StackShapesComponent")
		ssc.setBaseShape("plane_plane_8")
				
		player=self.createPlayer(Vector2(0,-8))
		
		ssc.setCount(player.getComponent("PlanePlayerControl").lives())
コード例 #3
0
    def __init__(self, gobj):
        super(AssfireComponent, self).__init__(gobj)
        self.__timer = 0
        self.__shape = None
        self.__gomeds = None
        self.__gohigs = None

        self.__bbmin = Vector2()
        self.__bbmax = Vector2()
        self.__mode = 0
        self.__ot1 = 0.0
        self.__ot2 = 0.0
コード例 #4
0
    def update(self):
        if (self.__gameover):
            self.__deathtimer += self.time.deltaTime()
            self.__scoreobject.position = Vector2(
                7 * math.sin(self.__deathtimer * 2), 0)
            return
        timepassed = self.time.time() - self.__lastfoodspawntime

        if (SnekFoodComponent.totalFoodCount() == 0
                or random.random() < timepassed * 0.001):
            self.spawnFood(
                Vector2(9.0 * 2 * (random.random() - 0.5),
                        9.0 * 2 * (random.random() - 0.5)))
            self.__lastfoodspawntime = self.time.time()
コード例 #5
0
    def grow(self):
        #assume we have nonzero tail
        gobj = self.gameObject()
        ftail = [
            x.gameObject() for x in self.__taillist if x.getHead() == gobj
        ][0]
        ftailstc = ftail.getComponent("SnekTailComponent")

        g = gameobject.GameObject()
        g.setName(ftail.getName())
        g.position = ftail.position + Vector2()
        g.angle = ftail.angle

        shp = g.addComponent("ShapeComponent")
        shp.setBaseShape("snek_torso")
        shp.setColor((0.2, 0.5, 0.15))

        g.addComponent("TrailComponent")
        stc = g.addComponent("SnekTailComponent")
        stc.setHead(gobj)
        stc.setTailOffset(ftailstc.getTailOffset())
        ftailstc.setHead(g)

        g.addComponent("BoundingBoxComponent")
        #g.addComponent("DebugBboxComponent")

        self.addControllableTailObjects([g])
コード例 #6
0
 def __init__(self, gobj):
     super(FirePuffComponent, self).__init__(gobj)
     self.__shape = None
     self.__frame = 0
     self.__timer = 0.04
     self.__vel = Vector2()
     self.__active = True
     self.__animspeed = 1.0
コード例 #7
0
    def update(self):
        gobj = self.gameObject()
        dt = self.time.deltaTime()

        if (self.__invincibletimer > 0):
            self.__invincibletimer -= dt
        if (self.__oldClr is None):
            if (self.__invincibletimer > 0):
                self.__oldClr = self.__shape.getHouNode().color()
                self.__shape.setColor((1, 0.5, 0.5))
        else:
            self.__shape.setColor(self.__oldClr)
            self.__oldClr = None
        #keyboard check

        if (GameObject.isKeyDown(Qt.Key_Left)):
            self.__plane.setForce(-1)
            self.__speed -= self.__inertForce * dt
        elif (GameObject.isKeyDown(Qt.Key_Right)):
            self.__plane.setForce(1)
            self.__speed += self.__inertForce * dt
        else:
            self.__plane.setForce(0)
            if (self.__speed > 0):
                self.__speed -= min(self.__speed, self.__inertForce * dt)
            else:
                self.__speed += min(-self.__speed, self.__inertForce * dt)

        if (self.__reloadtimer > 0): self.__reloadtimer -= dt
        if (GameObject.isKeyDown(Qt.Key_Control) and self.__reloadtimer <= 0):
            self.__reloadtimer = 0.1
            PlaneGameDirector.instance().fireBullet(
                gobj.position + Vector2(-0.41, 0.28), 0, 15, "player")
            PlaneGameDirector.instance().fireBullet(
                gobj.position + Vector2(0.41, 0.28), 0, 15, "player")

        if (GameObject.isKeyPressed(Qt.Key_Space)):
            PlaneGameDirector.instance().explosion(Vector2(0, 0))

        self.__speed = max(min(self.__speed, self.__maxspeed),
                           -self.__maxspeed)

        gobj.position += Vector2(self.__speed * dt, 0)
        if (gobj.position[0] < -9.5): gobj.position[0] = -9.5
        elif (gobj.position[0] > 9.5): gobj.position[0] = 9.5
コード例 #8
0
 def setActive(self, active):
     self.__active = active
     if (self.__active):
         self.__shape.setColor(self.clrs[0])
         self.__frame = 0
         self.__timer = 0.04
         self.__shape.setAnimationFrame(self.__frame)
     else:
         self.gameObject().position = Vector2(-16, 0)
コード例 #9
0
    def __init__(self, gobj):
        super(BigExplosionComponent, self).__init__(gobj)

        self.__timer = 0
        self.__delayTimer = 0
        self.__delayTime = 0.02
        self.__radius = 1  #actually, not radius, but half square side for now
        self.__offset = Vector2()
        self.__shape = None
コード例 #10
0
	def explosion(self,pos,vel=None,**kwargs):
		if(vel is None):vel=Vector2()
		go=GameObject("explosion")
		go.position=pos
		shp=go.addComponent("ShapeComponent")
		shp.setBaseShape("plane_boomMain")
		shp.setAnimated(True)
		shp.setColor((0,0,0))
		go.addComponent("ExplosionComponent").setVel(vel*1)
		return go
コード例 #11
0
    def spawnFood(self, pos):
        food = gameobject.GameObject("food")
        food.position = pos
        food.addComponent("ShapeComponent").setBaseShape("snek_food")

        food.addComponent("SnekFoodComponent")

        food.addComponent("BoundingBoxComponent")

        food.addComponent("MoveSpinComponent").setVel(Vector2(), 450)
コード例 #12
0
    def onStart(self):
        #scan field for exsisting nodes
        exnodes = [
            x for x in hou.node("/obj").children()
            if abs(x.position().x()) < 10 and abs(x.position().y()) < 10
        ]
        for node in exnodes:
            exfood = gameobject.GameObject("exfood")
            exfood.position = node.position()
            exfood.addComponent("ExistingNodeShapeComponent").assignHouNode(
                node)
            exfood.addComponent("SnekFoodComponent")
            exfood.addComponent("BoundingBoxComponent").readjust("", "")

        #create head
        go = gameobject.GameObject("head")
        shp = go.addComponent("ShapeComponent")
        shp.setBaseShape("snek_head")
        shp.setColor((0.2, 0.5, 0.15))

        go.addComponent("TrailComponent")
        chead = go.addComponent("SnekHeadComponent")

        go.addComponent("BoundingBoxComponent").offsetBbox(0.175)
        go.addComponent("ActiveCollisionCheckerComponent")

        #create start body
        gp = go
        startlength = 5
        for i in range(startlength):
            gb = gameobject.GameObject("tail")
            shp = gb.addComponent("ShapeComponent")
            shp.setColor((0.2, 0.5, 0.15))
            if (i == startlength - 1): shp.setBaseShape("snek_tail")
            else: shp.setBaseShape("snek_torso")

            gb.addComponent("TrailComponent")
            stc = gb.addComponent("SnekTailComponent")
            stc.setHead(gp)
            stc.setTailOffset(0.5)

            gb.addComponent("BoundingBoxComponent")
            #gb.addComponent("DebugBboxComponent")

            chead.addControllableTailObjects([gb])

            gp = gb

        #create score
        self.__scoreobject = gameobject.GameObject("SCORE")
        self.__scoreobject.addComponent("ScoreComponent")
        self.__scoreobject.position = Vector2(11, 9.5)
コード例 #13
0
	def update(self):
		dt=self.time.deltaTime()
		self.__timer+=dt
		if(self.__gameover):
			self.__score.position=Vector2(7*math.sin(self.__timer*2),0)
		else:
			if(len(self.__level)==0 and len(self.__levelinstances)==0):
				print("--------------------")
				print("--CONGRATULATIONS!--")
				print("--------------------")
				print("YOU ARE THE WINRAR!!")
				print("--------------------")
				self.__score.sendMessage("addScore",self.getPlayer().getComponent("PlanePlayerControl").lives()*500)
				self.__gameover=True
			if(self.__level is not None):
				while(len(self.__level)>0 and self.__level[0][0][1]<self.__timer*10):
					entry=self.__level.pop(0)
					pos=entry[0]
					node=entry[1]
					#print(node.name())
					go=None
					if(node.name().find("plane_small")==0):
						go=self.createEnemySimple("plane_evil01","s",Vector2(pos[0],9.9),Vector2(node.evalParm("velx"),node.evalParm("vely")),node.evalParm("sinAmp"),node.evalParm("sinFreq"),node.evalParm("sinOffset"),destroyCallback=self.explosion)
					elif(node.name().find("plane_big")==0):
						go=self.createEnemySimple("plane_evil02","m",Vector2(pos[0],9.9),Vector2(node.evalParm("velx"),node.evalParm("vely")),node.evalParm("sinAmp"),node.evalParm("sinFreq"),node.evalParm("sinOffset"),node.evalParm("lives"),node.evalParm("shooting"),node.evalParm("shootRowCount"),node.evalParm("projectilesCount"),node.evalParm("spreadHalfangle"),node.evalParm("shootRowDelay"),node.evalParm("shootReloadTime"),node.evalParm("shootAngle"),self.bigExplosion)
					elif(node.name().find("plane_boss_type1")==0):
						go=self.createBoss(Vector2(pos[0],9.9))
					if(go is not None):
						self.__levelinstances.append(go)
		
		if(len(self.__neds)>0):
			needsort=False
			if(random.random()<0.7*dt):
				self.__clouds.append(self.__genCloud(1,20,1,20,1,10))
				needsort=True
			if(random.random()<0.35*dt):
				self.__clouds.append(self.__genCloud(2,4,2,4.5,1,1.25))
				needsort=True	
			if(needsort):
				self.__clouds.sort(key=lambda x:x[4],reverse=True)
				
			shapelist=[]
			removelist=[]
			for cloud in self.__clouds:
				cloud[0]+=self.__globalVel[0]*dt/cloud[4]
				cloud[1]+=self.__globalVel[1]*dt/cloud[4]
				if(cloud[1]+cloud[3]*0.5 < -10):
					removelist.append(cloud)
				else:
					clr=cloud[5]
					shapelist.append(hou.NetworkShapeBox(hou.BoundingRect(cloud[0]-cloud[2]*0.5,cloud[1]-cloud[3]*0.5,cloud[0]+cloud[2]*0.5,cloud[1]+cloud[3]*0.5),color=hou.Color((clr,clr,clr)),alpha=0.9,screen_space=False))
			for item in removelist:
				self.__clouds.remove(item)
			
			for ne in self.__neds:	
				ne.setShapes(shapelist)
		self.__playerCached=None #to update in case player was killed or shit
コード例 #14
0
    def onStart(self):
        gobj = self.gameObject()
        self.__shape = gobj.getComponent("ShapeComponent")
        if (self.__shape is None):
            self.__shape = gobj.addComponent("ShapeComponent")
        self.__shape.setBaseShape("big_boss_assfirelow")
        self.__shape.setAnimated(True)

        gm = GameObject("killzone_enemy_m")
        gm.transform.setParent(gobj.transform, False)
        gm.transform.localPosition = Vector2((0, -50))
        self.__gomeds = gm.addComponent("ShapeComponent")
        self.__gomeds.setBaseShape("big_boss_assfiremed")
        self.__gomeds.setAnimated(True)
        gm.addComponent("BoundingBoxComponent").readjust("0", "0")

        gh = GameObject("killzone_enemy_h")
        gh.transform.setParent(gobj.transform, False)
        gh.transform.localPosition = Vector2((0, -50))
        self.__gohigs = gh.addComponent("ShapeComponent")
        self.__gohigs.setBaseShape("big_boss_assfirehig")
        self.__gohigs.setAnimated(True)
        gh.addComponent("BoundingBoxComponent").readjust("0", "0")

        #self.__shapem=self.gameObject().addComponent("ShapeComponent")
        #self.__shapem.setBaseShape("big_boss_assfirelow")
        #self.__shapem.setAnimated(True)

        #self.__shapeh=self.gameObject().addComponent("ShapeComponent")
        #self.__shapeh.setBaseShape("big_boss_assfirelow")
        #self.__shapeh.setAnimated(True)

        bbx = self.gameObject().getComponent("BoundingBoxComponent")
        if (bbx is None):
            bbx = self.gameObject().addComponent("BoundingBoxComponent")
        bbx.readjust("0", "0")
        (self.__bbmin, self.__bbmax) = bbx.getInitBBox()
コード例 #15
0
    def __init__(self, gobj):
        super(PlaneEvilSimple, self).__init__(gobj)
        self.__linearVel = Vector2()
        self.__actualVel = Vector2()
        self.__sinAmp = 0
        self.__sinFreq = 0
        self.__sinOffset = 0

        self.__plane = None
        self.__timer = 0
        self.__lives = 1
        self.__shooting = False
        self.__shootRowCount = 1
        self.__shootProjectilesCount = 1
        self.__shootSpreadHalfangle = 20
        self.__shootRowDelay = 0.1
        self.__shootReloadTime = 4
        self.__shootAngle = 180
        self.__reloadTimer = self.__shootReloadTime
        self.__rowCounter = 0

        self.__shape = None
        self.__oldClr = None
        self.__destroyCallback = None
コード例 #16
0
    def update(self):
        gobj = self.gameObject()
        if (self.__oldClr is not None):
            self.__shape.setColor(self.__oldClr)
            self.__oldClr = None

        if (PlaneGameDirector.instance().isOutOfGameArea(gobj.position)):
            gobj.destroy()
            return

        dt = self.time.deltaTime()
        self.__timer += dt

        if (self.__shooting):
            if (self.__reloadTimer > 0): self.__reloadTimer -= dt
            else:
                baseangle = self.__shootAngle
                if (baseangle == -1):
                    pass
                    #means we are targeting player
                    #TODO: do
                if (self.__shootProjectilesCount == 1):
                    PlaneGameDirector.instance().fireBullet(
                        gobj.position, baseangle, 10, "enemy", (1, 0.35, 0.35))
                else:
                    angstep = 2 * self.__shootSpreadHalfangle / (
                        self.__shootProjectilesCount - 1)
                    for i in range(self.__shootProjectilesCount):
                        PlaneGameDirector.instance().fireBullet(
                            gobj.position, baseangle -
                            self.__shootSpreadHalfangle + i * angstep, 10,
                            "enemy", (1, 0.35, 0.35))
                #do shoot here
                self.__rowCounter += 1
                if (self.__rowCounter >= self.__shootRowCount):
                    self.__reloadTimer = self.__shootReloadTime
                    self.__rowCounter = 0
                else:
                    self.__reloadTimer += self.__shootRowDelay

        sid = self.__sinFreq * cos(self.__sinFreq * self.__timer +
                                   self.__sinOffset)

        self.__actualVel = (Vector2(self.__sinAmp * sid, 0) + self.__linearVel)
        gobj.position += self.__actualVel * dt
        self.__plane.setForce(sid)
コード例 #17
0
    def __init__(self, gobj):
        super(BossCoreComponent, self).__init__(gobj)
        self.__parts = {}

        self.__state = "goto"
        self.__nextState = "stage1"
        self.__targetpos = Vector2((0, 15))

        self.__assfire = None
        self.__stage1_timer = 0
        self.__stage1_c = 0
        self.__stage2_timer = 0
        self.__stage2_spawntimer = 0
        self.__stage2_c = 0
        self.__stage3_timer = 0
        self.__stage3_c = 0
        self.__stage3_speed = 0
        self.__stage3_timer = 0
コード例 #18
0
	def __init__(self,gobj):
		super(PlaneGameDirector,self).__init__(gobj)
		self.__globalVel=Vector2()
		self.__level=None
		self.__timer=0
		self._bulletcache=[]
		self._firepuffcache=[]
		if(PlaneGameDirector.__instance is not None):raise Exception("TOO MANY DIRECTORS!!")
		PlaneGameDirector.__instance=self
		
		self.__clouds=[] #(px,py,sx,sy,depth)
		self.__neds=[]
		
		self.__playerCached=None
		self.__score=None
		self.__playerlives=None
		
		self.__levelinstances=[]
		self.__gameover=False
コード例 #19
0
    def update(self):
        gobj = self.gameObject()
        dt = self.time.deltaTime()
        self.__timer += dt

        af = round(self.__timer / 0.04) % 6
        self.__shape.setAnimationFrame(af)
        self.__gomeds.setAnimationFrame(af)
        self.__gohigs.setAnimationFrame(af)

        t = self.time.time() * 2

        self.__shape.setColor(self.__getColor(t))
        self.__gomeds.setColor(self.__getColor(self.__ot1, -0.2))
        self.__gohigs.setColor(self.__getColor(self.__ot2, -0.4))
        self.__ot2 = self.__ot1
        self.__ot1 = t

        for i in range(2):
            pos = Vector2((random.uniform(self.__bbmin[0], self.__bbmax[0]),
                           random.uniform(self.__bbmin[1],
                                          self.__bbmax[1]))) + gobj.position
            PlaneGameDirector.instance().firePuff(pos, random.uniform(0, 360))
コード例 #20
0
	def firePuff(self,pos,angle,vel=None,fwdShift=0,animSpeed=1):
		if(vel is None):vel=Vector2()
		if(len(self._firepuffcache)==0):
			go=GameObject("puff")
			go.angle=angle
			go.position=pos+go.fwd()*fwdShift
			shp=go.addComponent("ShapeComponent")
			shp.setBaseShape("plane_boomWhisp")
			shp.setAnimated(True)
			fpf=go.addComponent("FirePuffComponent")
			fpf.setVel(vel*1)
			fpf.setAnimSpeed(animSpeed)
			return go
		else:
			cp=self._firepuffcache.pop(0)
			cpgo=cp.gameObject()
			cpgo.angle=angle
			cpgo.position=pos+cpgo.fwd()*fwdShift
			cp.setActive(True)
			if(random.random()<0.1):
				cp.shapeShortcut().recreateHouNode()
			cp.setVel(vel)
			cp.setAnimSpeed(animSpeed)
			return cpgo
コード例 #21
0
 def setFlameMode(self, mode):
     if (self.__gomeds is None or type(mode) is not int
             or mode == self.__mode or mode < 0 or mode > 3):
         return
     if (mode == 0):
         self.__gomeds.gameObject().transform.localPosition = Vector2(
             (0, -50))
         self.__gohigs.gameObject().transform.localPosition = Vector2(
             (0, -50))
     elif (mode == 1):
         self.__gomeds.gameObject().transform.localPosition = Vector2(
             (0, 0))
         self.__gohigs.gameObject().transform.localPosition = Vector2(
             (0, -50))
     elif (mode == 2):
         self.__gomeds.gameObject().transform.localPosition = Vector2(
             (0, 0))
         self.__gohigs.gameObject().transform.localPosition = Vector2(
             (0, 0))
     self.__mode = mode
コード例 #22
0
ファイル: vector2.py プロジェクト: beesperester/houdini-diff
def serialize_as_dict(vector2: hou.Vector2) -> Dict[str, float]:
    return {"x": vector2.x(), "y": vector2.y()}
コード例 #23
0
    def onStart(self):
        #here we create the boss himself
        gobj = self.gameObject()
        b1 = GameObject("enemy_BOSS_HEAD")
        b1.transform.setParent(gobj.transform, False)
        shp = b1.addComponent("ShapeComponent")
        shp.setBaseShape("big_boss_body1")
        shp.setColor((0.6, 0.6, 0.65))
        b1.addComponent("BoundingBoxComponent")
        b1.addComponent("ActiveCollisionCheckerComponent").setCollisionMask(
            "bullet_player")
        b1.addComponent("BossPartComponent").setLives(40)

        b2 = GameObject("enemy_BOSS_CENTER")
        b2.transform.setParent(gobj.transform, False)
        shp = b2.addComponent("ShapeComponent")
        shp.setBaseShape("big_boss_body2")
        shp.setColor((0.6, 0.6, 0.65))
        b2.addComponent("BoundingBoxComponent")
        b2.addComponent("ActiveCollisionCheckerComponent").setCollisionMask(
            "bullet_player")
        b2.addComponent("BossPartComponent").setLives(30)

        b3 = GameObject("enemy_BOSS_BODY")
        b3.transform.setParent(gobj.transform, False)
        shp = b3.addComponent("ShapeComponent")
        shp.setColor((0.6, 0.6, 0.65))
        shp.setBaseShape("big_boss_body3")
        b3.addComponent("BoundingBoxComponent")
        b3.addComponent("ActiveCollisionCheckerComponent").setCollisionMask(
            "bullet_player")
        b3.addComponent("BossPartComponent").setLives(70)

        b4 = GameObject("enemy_BOSS_TAIL")
        b4.transform.setParent(gobj.transform, False)
        shp = b4.addComponent("ShapeComponent")
        shp.setBaseShape("big_boss_body4")
        shp.setColor((0.6, 0.6, 0.65))
        b4.addComponent("BoundingBoxComponent")
        b4.addComponent("ActiveCollisionCheckerComponent").setCollisionMask(
            "bullet_player")
        b4.addComponent("BossPartComponent").setLives(70)

        wl = GameObject("enemy_BOSS_WINDL")
        wl.transform.setParent(gobj.transform, False)
        shp = wl.addComponent("ShapeComponent")
        shp.setBaseShape("big_boss_wingl")
        shp.setColor((0.6, 0.6, 0.65))
        wl.addComponent("BoundingBoxComponent")
        wl.addComponent("ActiveCollisionCheckerComponent").setCollisionMask(
            "bullet_player")
        wl.addComponent("BossPartComponent").setLives(200)

        wr = GameObject("enemy_BOSS_WINDR")
        wr.transform.setParent(gobj.transform, False)
        shp = wr.addComponent("ShapeComponent")
        shp.setBaseShape("big_boss_wingr")
        shp.setColor((0.6, 0.6, 0.65))
        wr.addComponent("BoundingBoxComponent")
        wr.addComponent("ActiveCollisionCheckerComponent").setCollisionMask(
            "bullet_player")
        wr.addComponent("BossPartComponent").setLives(200)

        tl = GameObject("enemy_BOSS_TAILL")
        tl.transform.setParent(gobj.transform, False)
        shp = tl.addComponent("ShapeComponent")
        shp.setBaseShape("big_boss_taill")
        shp.setColor((0.6, 0.6, 0.65))
        tl.addComponent("BoundingBoxComponent")
        tl.addComponent("ActiveCollisionCheckerComponent").setCollisionMask(
            "bullet_player")
        tl.addComponent("BossPartComponent").setLives(70)

        tr = GameObject("enemy_BOSS_TAILR")
        tr.transform.setParent(gobj.transform, False)
        shp = tr.addComponent("ShapeComponent")
        shp.setBaseShape("big_boss_tailr")
        shp.setColor((0.6, 0.6, 0.65))
        tr.addComponent("BoundingBoxComponent")
        tr.addComponent("ActiveCollisionCheckerComponent").setCollisionMask(
            "bullet_player")
        tr.addComponent("BossPartComponent").setLives(70)

        trtt = GameObject("enemy_TRturret")
        trtt.transform.setParent(tr.transform, False)
        trtt.transform.localPosition = Vector2((4.3, -10.0))
        trtt.transform.localAngle = 180
        shp = trtt.addComponent("ShapeComponent")
        shp.setBaseShape("turret")
        shp.setColor((0.3, 0.3, 0.35))
        trtt.addComponent("TurretComponent").setActive(False)

        tltt = GameObject("enemy_TLturret")
        tltt.transform.setParent(tl.transform, False)
        tltt.transform.localPosition = Vector2((-4.3, -10.0))
        tltt.transform.localAngle = 180
        shp = tltt.addComponent("ShapeComponent")
        shp.setBaseShape("turret")
        shp.setColor((0.3, 0.3, 0.35))
        tltt.addComponent("TurretComponent").setActive(False)

        b4tt = GameObject("enemy_B4turret")
        b4tt.transform.setParent(b4.transform, False)
        b4tt.transform.localPosition = Vector2((0, -9.0))
        b4tt.transform.localAngle = 180
        shp = b4tt.addComponent("ShapeComponent")
        shp.setBaseShape("turret")
        shp.setColor((0.3, 0.3, 0.35))
        b4tt.addComponent("TurretComponent").setActive(False)

        wltt = GameObject("enemy_WLturret")
        wltt.transform.setParent(wl.transform, False)
        wltt.transform.localPosition = Vector2((-9.0, -1.26))
        wltt.transform.localAngle = 180
        shp = wltt.addComponent("ShapeComponent")
        shp.setBaseShape("turret")
        shp.setColor((0.3, 0.3, 0.35))
        wltt.addComponent("TurretComponent").setActive(False)

        wrtt = GameObject("enemy_WRturret")
        wrtt.transform.setParent(wr.transform, False)
        wrtt.transform.localPosition = Vector2((9.0, -1.26))
        wrtt.transform.localAngle = 180
        shp = wrtt.addComponent("ShapeComponent")
        shp.setBaseShape("turret")
        shp.setColor((0.3, 0.3, 0.35))
        wrtt.addComponent("TurretComponent").setActive(False)

        self.__parts = {
            "b1": b1,
            "b2": b2,
            "b3": b3,
            "b4": b4,
            "wingl": wl,
            "wingr": wr,
            "taill": tl,
            "tailr": tr
        }
コード例 #24
0
 def __init__(self, gobj):
     super(MoveSpinComponent, self).__init__(gobj)
     self.__lvel = Vector2()
     self.__avel = 0
コード例 #25
0
    def update(self):
        gobj = self.gameObject()
        dt = self.time.deltaTime()

        if (self.__state == "goto"):
            d = self.__targetpos - gobj.position
            speed = 2
            dl = d.length()
            if (dl <= 0.00001):
                self.__state = self.__nextState
                self.__nextState = ""
                return
            d = min(dl, speed * dt) * d / dl
            gobj.position += d
        elif (self.__state == "stage1"):  #STATE STAGE1
            #init
            if (self.__nextState == ""):
                self.__nextState = "stage1_tailremain"
                self.__parts["taill"].sendMessage("setActive", True)
                self.__parts["tailr"].sendMessage("setActive", True)
            #do stuff
            self.__stage1_timer += dt
            gobj.position[0] += 0.2 * cos(self.__stage1_timer)
            if (self.__parts["taill"] is None and self.__stage1_c % 2 == 0):
                self.__stage1_c += 1
                #fire up the ass a bit
                af = GameObject("assfire")
                af.transform.setParent(self.__parts["b4"].transform)
                af.transform.localPosition = Vector2((-1.351, -9.179))
                af.transform.localAngle = 107
                af.addComponent("BurningComponent").setConfig(
                    length=2, intensity=1, angleVariation=90)
            if (self.__parts["tailr"] is None
                    and (self.__stage1_c / 2) % 2 == 0):
                self.__stage1_c += 2
                #fire up the ass a bit
                af = GameObject("assfire")
                af.transform.setParent(self.__parts["b4"].transform)
                af.transform.localPosition = Vector2((1.351, -9.179))
                af.transform.localAngle = 253
                af.addComponent("BurningComponent").setConfig(
                    length=2, intensity=1, angleVariation=90)

            #translate
            if (self.__parts["taill"] is None
                    and self.__parts["tailr"] is None):
                self.__targetpos = Vector2(0, 15)
                self.__state = "goto"
                return
        elif (self.__state == "stage1_tailremain"):
            #init
            if (self.__nextState == ""):
                self.__nextState = "stage2"
                self.__parts["b4"].sendMessage("setActive", True)
            #do stuff
            self.__stage1_timer += dt
            gobj.position[0] += 0.4 * cos(self.__stage1_timer * 2)
            #translate
            if (self.__parts["b4"] is None):
                self.__targetpos = Vector2(9, 9)
                self.__state = "goto"

                #fire up the ass a bit
                af = GameObject("assfire")
                af.transform.setParent(self.__parts["b3"].transform)
                af.transform.localPosition = Vector2((0, -7.18))
                af.transform.localAngle = 180
                af.addComponent("BurningComponent").setConfig(length=4,
                                                              intensity=0.5)

                if (self.__assfire is None):
                    goass = GameObject("killzone_enemy")
                    goass.transform.setParent(self.__parts["b3"].transform,
                                              False)
                    self.__assfire = goass.addComponent("AssfireComponent")

        elif (self.__state == "stage2"):  #STATE STAGE2
            #init
            if (self.__nextState == ""):
                self.__nextState = "stage3"
                self.__parts["wingl"].sendMessage("setActive", True)
                self.__parts["wingr"].sendMessage("setActive", True)

            #do stuff
            self.__stage2_timer += dt
            x = self.__stage2_timer * 0.2
            x = (0.5 + 0.5 * cos(x))**(20**(-cos(x)))
            gobj.position[0] = 2 * (x - 0.5) * 9
            if (x < 0.05 or x > 0.95):
                self.__stage2_spawntimer += dt
                if (self.__stage2_spawntimer >= 0.7):
                    self.__stage2_spawntimer = 0
                    PlaneGameDirector.instance().createEnemySimple(
                        "plane_evil01",
                        "s",
                        Vector2((0, 9.9)),
                        Vector2((0, -4)),
                        2,
                        2,
                        0,
                        destroyCallback=PlaneGameDirector.instance().explosion)
                    #PlaneGameDirector.instance().createEnemySimple("plane_evil01","s", Vector2((4,9.9)), Vector2((0,-4)),2,2,0)
            self.__assfire.setFlameMode(
                int(1.5 + 1.5 * sin(self.__stage2_timer - radians(90))))

            if (self.__parts["wingl"] is None and self.__stage2_c % 2 == 0):
                self.__stage2_c += 1
                #fire up the ass a bit
                af = GameObject("assfire")
                af.transform.setParent(self.__parts["b2"].transform)
                af.transform.localPosition = Vector2((-1.803, -0.045))
                af.transform.localAngle = 90
                af.addComponent("BurningComponent").setConfig(
                    length=5, intensity=1, angleVariation=90)
            if (self.__parts["wingr"] is None
                    and (self.__stage2_c / 2) % 2 == 0):
                self.__stage2_c += 2
                #fire up the ass a bit
                af = GameObject("assfire")
                af.transform.setParent(self.__parts["b2"].transform)
                af.transform.localPosition = Vector2((1.803, -0.045))
                af.transform.localAngle = 270
                af.addComponent("BurningComponent").setConfig(
                    length=5, intensity=1, angleVariation=90)

            #translate
            if (self.__parts["wingl"] is None
                    and self.__parts["wingr"] is None):
                self.__targetpos = Vector2((0, 6))
                self.__assfire.setFlameMode(0)
                self.__state = "goto"
        elif (self.__state == "stage3"):  #STATE STAGE3
            #init
            if (self.__nextState == ""):
                self.__nextState = "destroy"
                self.__parts["b3"].sendMessage("setActive", True)
            #do stuff
            if (self.__parts["b3"] is None and self.__stage3_c == 0):
                self.__stage3_c = 1
                self.__parts["b2"].sendMessage("setActive", True)
                #fire up the ass a bit
                af = GameObject("assfire")
                af.transform.setParent(self.__parts["b2"].transform)
                af.transform.localPosition = Vector2((0, -3.0))
                af.transform.localAngle = 180
                af.addComponent("BurningComponent").setConfig(length=4,
                                                              intensity=1.5)
            if (self.__parts["b2"] is None and self.__stage3_c == 1):
                self.__stage3_c = 2
                self.__parts["b1"].sendMessage("setActive", True)
                #fire up the ass a bit
                af = GameObject("assfire")
                af.transform.setParent(self.__parts["b1"].transform)
                af.transform.localPosition = Vector2((0, 3.0))
                af.transform.localAngle = 180
                af.addComponent("BurningComponent").setConfig(length=4,
                                                              intensity=2)

            mult = 1 + self.__stage3_c * 0.5
            self.__stage3_timer += dt * mult
            if (self.__stage3_timer > 1.5):
                self.__stage3_speed = min(self.__stage3_speed + 3 * dt * mult,
                                          7)
                if (gobj.position[1] > 25):
                    self.__stage3_speed = 0
                    player = PlaneGameDirector.instance().getPlayer()
                    ppx = 0
                    if (player is not None): ppx = player.position[0]
                    gobj.position = Vector2((ppx, -16))
                    self.__stage3_timer = 0
            gobj.position += Vector2((0, self.__stage3_speed * dt))

            #translate
            if (self.__parts["b1"] is None):
                self.__targetpos = Vector2((0, 5))
                self.__state = "desetroy"
                PlaneGameDirector.instance().stuffWasDestroyed(
                    self.gameObject(), True)
                gobj.destroy()
                PlaneGameDirector.instance().bigExplosion(Vector2((0, 0)),
                                                          time=5,
                                                          radius=8)
コード例 #26
0
 def __init__(self, gobj):
     super(ExplosionComponent, self).__init__(gobj)
     self.__shape = None
     self.__frame = 0
     self.__timer = 0.00
     self.__vel = Vector2()
コード例 #27
0
	def createBoss(self,pos):
		go=GameObject("enemy_BOSS")
		go.position=pos+Vector2(0,20)
		go.addComponent("BossCoreComponent")
		
		return go
コード例 #28
0
 def setActive(self, active):
     self.__active = active
     if (not self.__active):
         self.gameObject().position = Vector2(-15, 0)
コード例 #29
0
 def __init__(self, gobj):
     super(StackShapesComponent, self).__init__(gobj)
     self.__shapeObjs = []
     self.__offset = Vector2((0.2, 0))
     self.__shapeBaseName = ""
     self.__count = 0