Navigation

    Fuze Arena Logo
    • Register
    • Login
    • Search
    • Categories
    • Recent
    • Popular
    • Users
    • Groups
    • Help
    • Discord

    New marked map area functions

    Coding
    3
    12
    621
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • pianofire
      pianofire Fuze Team last edited by pianofire

      The latest patch (0.2.14) introduced some new map functionality. It is now possible to have named areas on the map. I have done an example of this which is shown below. You will need the map as well. You can download the program using code: EVY73MNDNN

      loadMap("demo")
      image = loadImage( "Untied Games/Knight", false )
      sprite = createSprite()
      setSpriteImage( sprite, image )
      setSpriteAnimation( sprite, 8, 11, 10 )
      setSpriteLocation( sprite, 25, 30 )
      scale = 3
      setSpriteCamera( 0, 0, scale )
      centreSpriteCamera( 0, 0 )
      direction = 1
      
      loop
          clear()
          c = controls( 0 )
          printAt( 0, 0, "Press A to show collision areas" )
      
          sprite.x_speed = direction * 100   
          sprite.xscale = direction  
      
          updateSprites()
          updateMap()
        
          drawMap()
          drawSprites()
          checkCollisions( c.a )
          update()
      repeat
      
      function checkCollisions( showAreas )
          areaNames = getMapAreaNames()
          for i = 0 to len(areaNames) loop
              areaName = areaNames[i]
              area = getMapArea( areaName )
              if detectMapAreaCollision( areaName, sprite ) then
                  if areaName == "Wall1" then
                      direction = 1
                  endif
                 if areaName == "Wall2" then
                     direction = -1
                 endif
              endif
              if showAreas then
                  showArea( area, areaName )
              endif
          repeat
      return void
      
      function showArea( area, areaName )
          for i = 0 to len( area ) loop
              area[i].x = area[i].x * scale + gWidth() / 2
              area[i].y = area[i].y * scale + gHeight() / 2
          repeat
          line( area[0], area[1], red )
          line( area[1], area[2], red )   
          line( area[2], area[3], red )
          line( area[3], area[0], red )
          midy = abs( area[0].y - area[2].y ) / 2 + min( area[0].y, area[2].y )
          midx = abs( area[0].x - area[2].x ) / 2 + min( area[0].x, area[2].x )
          drawtext( midx, midy, 50, red, areaName )
      return void
      
      

      icon.png

      1 Reply Last reply Reply Quote 7
      • waldron
        waldron F last edited by

        how would i limit a button press unless i'm in a specified map area e.g c.y = false c.y= true if ....

        pianofire 1 Reply Last reply Reply Quote 0
        • pianofire
          pianofire Fuze Team @waldron last edited by

          @waldron Sorry I don't understand the question

          waldron 1 Reply Last reply Reply Quote 0
          • waldron
            waldron F @pianofire last edited by

            @pianofire sorry, say if i only want a characters state to action in certain areas.
            so in my case i have a ladder so i press up to climb it but i dont want to be able to press up and enter the state anywhere only in those areas?

            1 Reply Last reply Reply Quote 0
            • pianofire
              pianofire Fuze Team last edited by pianofire

              So if you mark your ladder collision boxes as Ladder1, Ladder2 etc you could do something like this:

              if detectMapAreaCollision( areaName, sprite ) then
                  canClimb = strBeginsWith(areaName, "Ladder") 
              

              and then:

              if (canClimb and c.y) then
                  // move sprite up
              
              Dave waldron 3 Replies Last reply Reply Quote 3
              • waldron
                waldron F last edited by

                wonderful thank you i presume i can access a lot of actions with this including getting text and sounds to play in certain areas this should keep me busy for a while

                1 Reply Last reply Reply Quote 1
                • Dave
                  Dave Fuze Team @pianofire last edited by

                  @pianofire That is awesome.

                  1 Reply Last reply Reply Quote 0
                  • waldron
                    waldron F @pianofire last edited by

                    This post is deleted!
                    1 Reply Last reply Reply Quote 0
                    • waldron
                      waldron F @pianofire last edited by

                      @pianofire i must be doing something wrong am i missing anything? variable?

                      waldron 1 Reply Last reply Reply Quote 0
                      • waldron
                        waldron F @waldron last edited by

                        @waldron said in New marked map area functions:

                        @pianofire i must be doing something wrong am i missing anything? variable?

                        OK I was missing the area name variable but still not working.

                        1 Reply Last reply Reply Quote 0
                        • pianofire
                          pianofire Fuze Team last edited by

                          @waldron sorry it was only a code snippet. Have a look at the checkCollisions function in the post at the top

                          areaNames = getMapAreaNames()
                              for i = 0 to len(areaNames) loop
                                  areaName = areaNames[i]
                                  area = getMapArea( areaName )
                                  if detectMapAreaCollision( areaName, sprite ) then
                          
                          waldron 1 Reply Last reply Reply Quote 2
                          • waldron
                            waldron F @pianofire last edited by

                            @pianofire I added that part still no joy il wait till iv got a bit more time on my hands maybe missing something silly

                            1 Reply Last reply Reply Quote 0
                            • First post
                              Last post