Exemplo n.º 1
0
	def __init__ (self, world, density, radius, centre, dist, angle):
		if self.img_ident == 'planet':
			self.img_ident += str(randrange(3))
		self.world = world
		pos = (centre.pos[0] + dist * cos(angle),
				centre.pos[1] + dist * sin(angle))
		freq = float(conf.GRAVITY_CONSTANT * centre.mass) / dist ** 3
		centre = centre.pos

		def get_pos (dt):
			x, y = self.pos
			cx, cy = centre
			x -= cx
			y -= cy
			angle = freq * dt
			c = cos(angle)
			s = sin(angle)
			return (cx + c * x - s * y, cy + s * x + c * y)

		self.get_pos_at_time = get_pos
		GravitySource.__init__(self, pos, density * radius ** 3, radius)
		self.graphic = mk_graphic(self)
		position_graphic(self)
Exemplo n.º 2
0
	def __init__ (self, density, radius, pos):
		GravitySource.__init__(self, pos, density * radius ** 3, radius)
		self.graphic = mk_graphic(self)
		position_graphic(self)