Menu

paths

2004-11-02
2012-12-25
  • Nobody/Anonymous

    can you make circular paths? havent tried it but would a perfect sqaure path with a platform on follow approx path do the trick?

     
    • Nobody/Anonymous

      No arc values for paths unfortionatly. Using approximate path would introduce some irregularity and may help if you try to free hand a circle.  If you want to simulate a moving teathered object/platform your best bet is probably to plug in the coordinates manually. Scripting might be a better option.

       
    • Ed

      Ed - 2004-11-03

      Here's a script to make a sprite go in circles.  This assumes that the sprite is on a two-point path.  The first point is the center of the circle, and the second point defines the radius of the circle.  Change wherever it says

      Maps("Map4").MapLayer(0).Sprite(1)

      to fit your neccessities accordingly (propper map name and propper layer and sprite index).  Also, change the If statement where it checks the map name to be the correct map name.

      Note that for a circular platform, as with "follow path exactly" platforms, the player has a tendency to fall off.  This can be remedied by manually setting the player's Y coordinate to 1 less than it is whenever they're riding the platform (which I don't know if it'll work).  Anyway, here it is.

      Option Explicit
      Dim oX, oY, cX, cY, step, radius
      Const pi = 3.1415926535898

      Sub Player_OnPlayInit()
          With ProjectObj.Maps("Map4").MapLayer(0).Sprite(1).rDef.rPath
              oX = .PointX(0)
              oy = .PointY(0)
              radius = ((.PointY(1) - .PointY(0)) ^ 2 + (.PointX(1) - .PointX(0)) ^ 2) ^ .5
          End With
          cX = oX - radius
          cY = oY
          step = 0
      End Sub

      Sub Player_OnAfterMoveSprites()   
          If ProjectObj.GamePlayer.rMap.name = "Map4" then
              cX = oX + sin(step * (pi / 180)) * radius
              cY = oY + cos(step * (pi / 180)) * radius
                  step = step + 1
                  if step >= 360 then step = 0
              With ProjectObj.Maps("Map4").MapLayer(0).Sprite(1)
                  .X = cX
                  .y = cY
              End With
          End if
      End Sub

      HostObj.SinkObjectEvents ProjectObj.GamePlayer, "Player"
      HostObj.ConnectEventsNow()
      ProjectObj.GamePlayer.Play 16

       
    • Ed

      Ed - 2004-11-03

      Oh, my bad.  It's only landing on the platform that creates a problem.  Just standing on it is fine.  And the only problem is when the movement of the platform is in a general "upward" direction (right half of the circle)

       
    • Ed

      Ed - 2004-11-03

      As a side note, the time it takes to go around the circle at the current speed is 2pi seconds (I just timed it eyeballing it with a stopwatch and got exactly 6.28 seconds!), but if you change the

      step = step + 1

      to

      step = step + (some larger or smaller number)

      the speed will increase or decrease accordingly.  Oh, and I was just looking through my script and realized that it was kinda inefficient, but hey, it works. (You could get rid of two variables and two opperations per frame, also about 64 bytes smaller script or so...however this is a negligible size)

       

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.