Data Realms Fan Forums http://45.55.195.193/ |
|
Issues with the Map Seam http://45.55.195.193/viewtopic.php?f=73&t=19032 |
Page 1 of 1 |
Author: | Petethegoat [ Sat Jun 19, 2010 10:17 pm ] |
Post subject: | Issues with the Map Seam |
I have modified Grif's warp test clone so that it can't teleport into terrain, and so that it cannot teleport into the air (that is, the teleport location is snapped to ground level). This works great, except that you immediately fall off the bottom of the map and die when attempting to cross a map seam. It uses MovePointToGround to snap to ground level. Is there any way of fixing this, short of not allowing it to teleport across map seams? |
Author: | TheLastBanana [ Sat Jun 19, 2010 11:00 pm ] |
Post subject: | Re: Issues with the Map Seam |
Post your code so we can figure out where the bug is occuring. |
Author: | Petethegoat [ Sat Jun 19, 2010 11:05 pm ] |
Post subject: | Re: Issues with the Map Seam |
Here you are: Code: function Create(self) self.presses = 0; self.pressed = 0; self.warps = 5; self.warptimer = Timer(); end function Update(self) if self:GetController():IsState(Controller.BODY_JUMP) == true then self.pressed = 1; local indic = CreateMOPixel("Warp Glow"); indic.Pos = SceneMan:MovePointToGround(Vector(self.Pos.X + 80 * math.cos(-self:GetAimAngle(true)),self.Pos.Y + 80 * math.sin(-self:GetAimAngle(true))),20,8); MovableMan:AddParticle(indic); else if self.pressed == 1 then self.pressed = 0; self.newpos = SceneMan:MovePointToGround(Vector(self.Pos.X + 80 * math.cos(-self:GetAimAngle(true)),self.Pos.Y + 80 * math.sin(-self:GetAimAngle(true))),20,8); if SceneMan:GetTerrMatter(self.newpos.X,self.newpos.Y) == 0 then if self.warps >= 1 then self.Pos = self.newpos; -- self.Vel = Vector(0,0); self:FlashWhite(50); self.warps = self.warps-1; self.warptimer:Reset(); end end elseif self.pressed == 0 then end end if self.warptimer:IsPastSimMS(10000) then if self.warps <= 4 then self.warps = 5; local part = CreateMOPixel("Warp Glow"); part.Pos = self.Pos; MovableMan:AddParticle(part); end end end |
Author: | TheLastBanana [ Sat Jun 19, 2010 11:12 pm ] |
Post subject: | Re: Issues with the Map Seam |
The issue is that you're moving a position outside of the map to the ground. Let's say you're on a 640x480 map which wraps, and you're standing on the very right (at 640), looking exactly right. Code: self.newpos = SceneMan:MovePointToGround(Vector(self.Pos.X + 80 * math.cos(-self:GetAimAngle(true)),self.Pos.Y + 80 * math.sin(-self:GetAimAngle(true))),20,8); This is going to be trying to move you to the ground position at an x-position of 720. However, the map doesn't actually go that far. Where you want to land is 720 - 640 = 80. Try this: Code: local newX = self.Pos.X + 80 * math.cos(-self:GetAimAngle(true)); newX = newX % 640; self.newpos = SceneMan:MovePointToGround(Vector(newX,self.Pos.Y + 80 * math.sin(-self:GetAimAngle(true))),20,8); What the % operator does is modulus. It gets the remainder of the number divided by the second number. Apply that to both pieces that use that piece of code and it should work. |
Author: | Petethegoat [ Sat Jun 19, 2010 11:33 pm ] |
Post subject: | Re: Issues with the Map Seam |
Wonderful. Just replaced 640 with SceneMan.SceneWidth and it works like a charm. |
Page 1 of 1 | All times are UTC [ DST ] |
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group http://www.phpbb.com/ |