コード例 #1
0
	def fireBullet(self,pos,angle,speed,tag,clr=(1,1,0.36)):
		#print(len(self._bulletcache))
		if(len(self._bulletcache)==0):
			go=GameObject("bullet_"+tag)
			go.position=pos*1
			go.angle=angle
			shp=go.addComponent("ShapeComponent")
			shp.setBaseShape("plane_bullet")
			shp.setColor(clr)
			go.addComponent("PlaneBullet").setConfig(speed)
			go.addComponent("BoundingBoxComponent")
		else:
			cp=self._bulletcache.pop()
			cpgo=cp.gameObject()
			cpgo.position=pos
			cpgo.angle=angle
			cpgo.setName("bullet_"+tag)
			cp.shapeShortcut().setColor(clr)
			if(random.random()<0.1):
				cp.shapeShortcut().recreateHouNode()
			cp.setConfig(speed)
			cp.setActive(True)
コード例 #2
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