Navigation

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

    TileGridSystem

    Help
    help grid tile
    4
    18
    845
    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.
    • Rxvlism
      Rxvlism last edited by Martin

      Can anyone help me recreate this or understand this for loop? I also don’t get the i++ or j++ ( means increase by one so I’m guessing i += 1 ?).

      // Resource 
      
      Var blockSize = sprite_get_width*h ( oDirt );
      
      For ( var i = 0; i < room_width / blockSize; I++ ){//Colums
          var xx = i * blockSize;
          For ( var j = 0; j < room_height / blockSize; j++ ){//Rows
              var yy = room_height - blockSize - j*blockSize;
              Instance_create ( xx, yy, oDirt );
          }
      }
      

      All the program is doing is printing a tile on a grid = to Width & Height of the screen.

      1 Reply Last reply Reply Quote 1
      • N
        Nisse5 F last edited by

        The FUZE version of the C loop would be:

        for i = 0 to room_width loop
           // do stuff
        repeat
        
        1 Reply Last reply Reply Quote 1
        • Rxvlism
          Rxvlism last edited by

          But I mean what’s ; is that to, or, +, - ?? And what about I++

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

            @Rxvlism Your first semi colon is indeed the "to", and rather than using I++ as the increment, you define a step. So, for example:

            for (int i = 0; i < 10; i += 2){
                // things
            }
            

            Becomes:

            for i = 0 to 10 step 2 loop
                // things
            repeat
            

            To count backwards:

            for i = 10 to 0 loop
                // things
            repeat
            

            Or, with a step:

            for i = 10 to 0 step -2 loop
                 // things
            repeat
            

            When incrementing upward, For loops count up to but not including the last value. When counting downward, they count down to and including the last value.

            1 Reply Last reply Reply Quote 0
            • Rxvlism
              Rxvlism last edited by

              What about instance create ? Just a setSpriteLocation

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

                @Rxvlism I'm not quite sure I understand what you're asking here! Could you elaborate?

                1 Reply Last reply Reply Quote 0
                • Rxvlism
                  Rxvlism last edited by

                  Instance_create ( xx, yy, oDirt );
                  What would this look like in Fuze ?
                  GetSpriteImage
                  DrawSprite or Image

                  I’m confused at how to call oDirt at xx and yy

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

                    Probably better to avoid using the sprite commands for the drawing of a map or background, they're intended for characters/objects/animation and make it very easy to interact with a map drawn in the Map Editor loaded with loadMap(). Depending on whether this dirt tile is from a tilesheet or is an image unto itself, you'll probably have more success with drawImage() or drawSheet(). For example:

                    // load tilesheet - let's say the dirt tile is tile no. 3
                    sheet = loadImage("filename")
                    
                    // using the tileSize function gives us a vector for the tile dimensions
                    tSize = tileSize( sheet, 3 )
                    scale = 2
                    
                    for y = 0 to gheight() step tSize.y * scale loop
                        for x = 0 to gwidth() step tSize.x * scale loop
                            drawSheet( sheet, 3, x, y, scale )
                        repeat
                    repeat     
                    

                    This gives me something like what you're describing!

                    1 Reply Last reply Reply Quote 0
                    • Rxvlism
                      Rxvlism last edited by

                      Im using my own image 16x16 pixels and when I use tileSize I get the “this image does not have tile data.” I don’t use tile sheets for this reason or I’d make one big png

                      N 1 Reply Last reply Reply Quote 0
                      • N
                        Nisse5 F @Rxvlism last edited by

                        @Rxvlism If you just use one single tile in the image, you can use drawImage()

                        1 Reply Last reply Reply Quote 0
                        • Rxvlism
                          Rxvlism last edited by

                          Finally :D you guys are the best For Loops had me going nuts for a bit there!

                          Thanks @Dave & @Nisse5

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

                            Yep - so it would look something like this:

                            // load tilesheet - let's say the dirt tile is tile no. 3
                            img = loadImage("filename")
                             
                            // using the tileSize function gives us a vector for the tile dimensions
                            tSize = imageSize( sheet )
                            scale = 2
                             
                            for y = 0 to gheight() step tSize.y * scale loop
                                for x = 0 to gwidth() step tSize.x * scale loop
                                    drawImage( sheet, x, y, scale )
                                repeat
                            repeat     
                            

                            Just in case anyone else was wondering how it looks with drawSheet.

                            1 Reply Last reply Reply Quote 0
                            • Rxvlism
                              Rxvlism last edited by

                              Is there a getPerlinNosie function in Fuze or will I have to create it ?

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

                                @Rxvlism You could always ask this person nicely!

                                Rxvlism 1 Reply Last reply Reply Quote 1
                                • Rxvlism
                                  Rxvlism @pianofire last edited by

                                  @pianofire

                                  That’s exactly what I’m looking for but 2D how would I contact them the forums ?

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

                                    @Rxvlism Not sure if they are on here but this person has the same avatar https://fuzearena.com/forum/user/minatsu

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

                                      Pretty sure that is the user on twitter. みなつ reads Minatsu in English!

                                      1 Reply Last reply Reply Quote 0
                                      • Rxvlism
                                        Rxvlism last edited by

                                        Ok I msg him/her thanks guys so much !!! <3

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