Navigation

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

    Map Locations Demo

    Coding
    5
    28
    1318
    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

      So here is a simple demo of how you could (for example) use map locations to initially place your game sprites:

      loadMap("demo")
      
      sprites = [ ]
      
      locs = getMapLocationNames()
      for i = 0 to len( locs ) loop
          sprites[ i ] = createSprite( )
          loc = getMapLocation( locs[ i ] )
          setSpriteLocation( sprites[ i ], loc ) 
          setSpriteText( sprites[ i ], 30, red, locs[ i ] )
      repeat    
      
      scale = 1 
      setSpriteCamera( 0, 0, scale )
      centreSpriteCamera( 0, 0 )
      loop
          clear()
          drawSprites()
          update()
      repeat
      

      To run this add a map called demo and add some map locations ( Change Mode to Collision and then use X to Mark Location )

      Spacemario 1 Reply Last reply Reply Quote 6
      • xevdev
        xevdev F last edited by

        Nice, don't personally use sprites .. so looked up setspitetext().
        Neat function.
        A little video would be nice for those who can't read the code yet.

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

          Videos aren't really my area. I am sure that @Dave and @FuzeBen will be doing one on the map editor and functions at some point

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

            I'm happy to do a video if I get chance later it will only be short one but these help me to, thanks for the code pianofire

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

              @pianofire This is great, thanks so much for putting this together-- it's exactly what I was looking for!

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

                @pianofire just downloaded the game screen demo very helpful also the map location one, how would i change the setspritetext to a sprite image?

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

                  @waldron

                  locs = getMapLocationNames()
                  image = loadImage( "Untied Games/Creeper", 0 )
                  for i = 0 to len( locs ) loop
                      sprites[ i ] = createSprite( )
                      loc = getMapLocation( locs[ i ] )
                      setSpriteLocation( sprites[ i ], loc ) 
                      setSpriteImage( sprites[ i ], image )
                  repeat    
                  
                  waldron 1 Reply Last reply Reply Quote 3
                  • waldron
                    waldron F @pianofire last edited by

                    @pianofire cheers i was close i did try thankyou

                    1 Reply Last reply Reply Quote 1
                    • SteveZX81
                      SteveZX81 F last edited by

                      This is great! Thanks

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

                        Just something that came up with this. You need to give your locations unique names otherwise you will get things appearing in the same location. If you want to have locations with different types you can just add a sequential number on the end e.g. tree01, tree02 etc and rock01, rock02. Then to find the type of a location you can use strBeginsWIth e.g. if strBeginsWith(locs[i], "tree") then

                        1 Reply Last reply Reply Quote 3
                        • Spacemario
                          Spacemario F last edited by Spacemario

                          @pianofire, @waldron Have you-- or anyone else really-- tried this with the latest patch? I have essentially your exact code:

                          • One third of the time it works: my sprite is showing up in the game world, at the correct spot.
                          • One third of the time I get a run-time error "Incorrect type struct for parameter one: expected string" on the "getMapLocation()" call.
                          • One third of the time Fuze crashes (the Switch's OS-level "quits unexpectedly" error we're all familiar with).

                          This is the first time I've ever used map locations, so I can't say whether it worked before the patch. I don't think it's a problem with my code: I'm almost verbatim using your above snippet. I'll go take another look to be sure.

                          Thanks in advance!

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

                            @Spacemario glad you mentioned it, all my games with this code crashes fuze post patch no error code nothing if i comment out the namemaparea code my program runs or if I leave it in and comment out collidemap it runs so I think there is a problem with namemaparea() and collidemap() running together. I'v had to resort to using collidemaparea instead which sucks as a sprite collides with it and doesn't pass through it.

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

                              @waldron Fascinating, thanks for bringing this up! We'll let @pianofire chime in, but it sounds like a bug may have been introduced into the latest Fuze patch related to the map-related functions, since we're both experiencing similar issues in two completely different programs.

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

                                @Spacemario yeah I did mention it but I'm always in 2 minds with issues like this as I'm never sure if it's the way I code or fuze but all my games with this code now crash and I have been experiencing lots of graphical glitches but again not sure if it's down to my code although I haven't had them before the patch.

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

                                  just realized this is getmaplocation where as my problems have been with namemaparea so maybe maps in general and locations have gone a bit pete tong

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

                                    @waldron I bet "under the hood", these different map functions share a lot of the same code-- so there may be some kind of memory or pointer-related bug, which is impacting multiple map functions.

                                    For now, I've gone back to defining all of my actors in a giant array like I did for "Skatey-Cat": I was really hoping to avoid that approach and use map markers this time, but doesn't look like that'll be possible.

                                    Oh well, it was a nice idea anyway :)

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

                                      @Spacemario i'l have a test later maybe the spritecamera map position patch has caused it as was working fine before il create a test program later and share it in hopes there is a workaround or at least the true cause

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

                                        Found the cause ! I had areaNames = getmapareanames() in the main loop which worked before the patch so I'v moved that part outside the loop and now works without crashing

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

                                          I'v tried the sprite placement code but not really used it before so I was unable to test that

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

                                            @waldron When you say "in the main loop" do you mean not inside a function?

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