View unanswered posts | View active topics It is currently Fri Dec 27, 2024 8:28 am



Reply to topic  [ 5 posts ] 
 Issues with the Map Seam 
Author Message
User avatar

Joined: Mon Jun 15, 2009 4:02 pm
Posts: 905
Reply with quote
Post 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?


Sat Jun 19, 2010 10:17 pm
Profile WWW
DRL Developer
DRL Developer
User avatar

Joined: Wed Dec 13, 2006 5:27 am
Posts: 3138
Location: A little south and a lot west of Moscow
Reply with quote
Post Re: Issues with the Map Seam
Post your code so we can figure out where the bug is occuring.


Sat Jun 19, 2010 11:00 pm
Profile WWW
User avatar

Joined: Mon Jun 15, 2009 4:02 pm
Posts: 905
Reply with quote
Post 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


Sat Jun 19, 2010 11:05 pm
Profile WWW
DRL Developer
DRL Developer
User avatar

Joined: Wed Dec 13, 2006 5:27 am
Posts: 3138
Location: A little south and a lot west of Moscow
Reply with quote
Post 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.


Sat Jun 19, 2010 11:12 pm
Profile WWW
User avatar

Joined: Mon Jun 15, 2009 4:02 pm
Posts: 905
Reply with quote
Post Re: Issues with the Map Seam
Wonderful.
Just replaced 640 with SceneMan.SceneWidth and it works like a charm.


Sat Jun 19, 2010 11:33 pm
Profile WWW
Display posts from previous:  Sort by  
Reply to topic   [ 5 posts ] 

Who is online

Users browsing this forum: No registered users


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by STSoftware for PTF.
[ Time : 0.063s | 13 Queries | GZIP : Off ]