def update(self, dt): self.move_by(0, 0, (dt * 60) / 4) self.rotate_by(0, 0, (dt * 60) * 3) result = self.world.physics.contact_test(self.solid) self.age += dt * 60 contacts = result.getContacts() if len(contacts) > 0: #self.world.scene.clear_light(self.light_node) cf = self.energy expl_color = [1, (150 / 255.0) * cf, (150 / 255.0) * cf, 1] expl_pos = self.node.get_pos(self.world.scene) expl = self.world.attach( TriangleExplosion(expl_pos, 5, size=.1, color=expl_color)) contact = contacts[0] contact.getManifoldPoint().getLocalPointB() n1_name = contact.getNode1().get_name() self.world.do_plasma_push(self, n1_name, self.energy) self.sound.stop() self.world.audio3d.detachSound(self.sound) self.world.garbage.add(self) if self.age > PLASMA_LIFESPAN: self.sound.stop() self.world.audio3d.detachSound(self.sound) self.world.garbage.add(self)
def update(self, dt): current_pos = Point3(0, self.position().get_y(), 0) pos, self.velocity = self.integrator.integrate(self.node.get_pos(), self.velocity, dt) if self.velocity.length() > 30: self.integrator.accel = Vec3(0,0,0) else: self.integrator.accel = self.world.render.get_relative_vector(self.node, Vec3(0,0,30)) self.move(self.position() + (pos - self.node.get_pos())) self.main_engines.set_color(*random.choice(ENGINE_COLORS)) self.wing_engines.set_color(*random.choice(ENGINE_COLORS)) result = self.world.physics.contact_test(self.solid) self.age += dt if len(result.getContacts()) > 0: clist = list(self.color) clist.extend([1]) expl_colors = [clist] expl_colors.extend(ENGINE_COLORS) expl_pos = self.node.get_pos(self.world.render) for c in expl_colors: self.world.attach(TriangleExplosion(expl_pos, 3, size=.1, color=c, lifetime=80)) self.world.do_explosion(self.node, 1.5, 30) self._remove_all() if self.age > MISSILE_LIFESPAN: self._remove_all()
def update(self, dt): self.inner_top.set_color(*random.choice(ENGINE_COLORS)) self.inner_bottom.set_color(*random.choice(ENGINE_COLORS)) result = self.world.physics.contact_test(self.solid) self.spin_bone.set_hpr(self.spin_bone, 0, 0, 10) contacts = result.getContacts() if len(contacts) > 0: hit_node = contacts[0].get_node1().get_name() if hit_node.endswith("_walker_cap"): return clist = list(self.color) clist.extend([1]) expl_colors = [clist] expl_colors.extend(ENGINE_COLORS) expl_pos = self.node.get_pos(self.world.scene) for c in expl_colors: self.world.attach( TriangleExplosion( expl_pos, 3, size=.1, color=c, lifetime=80, )) self.world.do_explosion(self.node, 3, 100) self.world.garbage.add(self)
def decompose(self): clist = list(self.color) clist.extend([1]) expl_colors = [clist] expl_colors.extend(ENGINE_COLORS) expl_pos = self.node.get_pos(self.world.render) for c in expl_colors: self.world.attach(TriangleExplosion(expl_pos, 1, size=.1, color=c, lifetime=40)) self.world.garbage.add(self)