def create(self): #We do this in the 'create' event so that it's only done on .ngf load, and #not deserialisation. lightPos = self.getPosition() - Ngf.Vector3(0,0.8,0) Ngf.createObject("Light", "", lightPos, Ngf.Quaternion.IDENTITY, { "colour" : "0.7 0.4 0.02", "attenuation" : "10 0.8 0.2 0.09" })
def collide(self, other): if ((not self.m_done) and other.hasFlag("Player")): #Get the message property. message = self.getProperty("message", 0, "<message>") if (message != "<message>"): #If it was given, show it. GraLL2.showMessage(message.replace("\\n", "\n"), float(self.getProperty("time", 0, "5"))) else: #Otherwise show message from messageDict. showMessageFromDict(self.getProperty("messageKey", 0, "default")) #Don't to it again. :P self.m_done = True Ngf.destroyObject(self)
def utick(self, elapsed): if (not self.m_unTouched): player = Ngf.getObject("player1") if (player): #Push him toward us. dir = self.getPosition() - player.getPosition() dir.y = 0 dist = dir.squaredLength() if (dist > 0.04): player.applyCentralForce(dir * 15) else: player.applyCentralForce(dir * 7)