Define Properties() -- these are the coordinates to orbit around cx = 25 cy = 25 -- these are the x and y radii -- make them the same for a circle, different for an oval xrad = 5 yrad = 5 -- starting angle startAngle = 0 -- direction of 1 is counterclockwise -- direction of -1 is clockwise -- direction of 0 is no movement direction = 1 -- sets whether to rotate with the spin or not rotate = 1 -- orbitSpeed sets the rate at which the objects complete a full loop -- a rate of 30 means 1 second for every 10 degrees orbitSpeed = 3 end Trigger attach() -- starts the callback chain going -- we use a callback chain because then you can change the speed for the object SendTo(self, "orbit", 0, 3, 3, 3, self.startAngle) end Trigger orbit(xpos, ypos, rad, curang) -- change the target angle curang = curang + self.orbitSpeed * self.direction -- wrap a full circle if curang < self.orbitSpeed then curang = 360 - curang end if curang > 360 then curang = curang - 360 end -- find the point on the edge of the circle local xpos = self.cx+ math.sin(math.rad(curang)) * self.xrad local ypos = self.cy+ math.cos(math.rad(curang)) * self.yrad -- slide there, at the rate that fits the amount of time before the next -- callback goes off SlideObject(self, xpos, ypos, 0, self.orbitSpeed*100, 1) -- If you are set to rotating, adjust the spin if self.rotate == 1 then self.spin = -10*self.direction end -- keep on spinning! SendTo(self, "orbit", self.orbitSpeed*100, 3, 3, 3, curang) --if math.random(0, 50) == 25 then -- fb = CreateObject("fireball", self.x, self.y) -- fb.speed = 10 -- fb.vx = 1 -- fb.vy = 1 -- fb.facing = 270 -- fb.frombug = 1 -- TintSprite(fb, "none", 0, 255, 200) --end end -- external API for changing stuff after it is in movement Trigger changespeed(newspeed) self.orbitSpeed = newspeed end Trigger changecenter(cx, cy) self.cx = cx self.cy = cy end Trigger changedirection(dir) if dir < -1 then dir = -1 end if dir > 1 then dir = 1 end self.direction = dir end Trigger changeshape(xrad, yrad) self.xrad = xrad self.yrad = yrad end Trigger reset(x, y) self.cx = x self.cy = y end Trigger destroyed() db = CreateObject("deadbug", self.x, self.y) end Trigger hit_by(obstacle) if obstacle.type == "player" then --MoveObject(player, 47, 47) --obstacle.speed = obstacle.walk_speed --PathToLocation(obstacle,48, 48) DestroyObject(self) end end Trigger hit(obstacle) if obstacle.type == "player" then --MoveObject(obstacle, 47, 47, 0, 1) --obstacle.speed = obstacle.walk_speed --PathToLocation(obstacle,48, 48) DestroyObject(self) end end