Array loading problem!

This forum is currently in read-only mode.
  • I'm not good at array loading.

    http://upload.namelezz.net/downloader.p ... LawnB1.rar

    ^ This is the game

    Basically to see the problem extract "LawnMowerB1" and start it. Then press the "Start" button.

    The loading misses some tiles

    I've included also the editor...

    Please help!

  • The problem is the way you have it looping through the array to load the level. Instead of using nested loops, simply use the "For Each Cell" loop in the array object. For checking the current cell value, simply use compare under the System object and use "Array.CurrentValue." Finally, to position the objects, use "Array.CurrentX * 21" and "Array.CurrentY * 21." I could upload the modified CAP if you want.

    Hope that helps.

    EDIT: By the way, I couldn't get the editor to load anything. I think you should think about using the common dialog object to get a proper save/load box.

  • O-oh. Thank you. I will now try as you said

  • I can't do that, because I use 13x13 as the Author field and 14x14 and 15x15 as the player X,Y starting location. The array loop loops through them, and creates additional squares.

  • In that case, you can make the default cell value -1. This will make it to where all cells where you don't specify a value will be left blank.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • In that case, you can make the default cell value -1. This will make it to where all cells where you don't specify a value will be left blank.

    Can you show me an example?

    Is there any way I can do a "controlled" for each between x;y and x;y?

  • I can't really make an example since I don't have access to your level editor code, and I couldn't seem to modify my own to work with it. But all you really have to do is this:

    In the level editor, at the start of the layout, have the array clear all of it's values to -1(or some other number that doesn't interfere with anything). This means that the base value of the the map will be - 1, so anything you don't fill with another tile will be left blank. Then, just fill the 13x13 grid that contains the level, and all should work fine. Hope this helps.

  • I can't really make an example since I don't have access to your level editor code, and I couldn't seem to modify my own to work with it. But all you really have to do is this:

    In the level editor, at the start of the layout, have the array clear all of it's values to -1(or some other number that doesn't interfere with anything). This means that the base value of the the map will be - 1, so anything you don't fill with another tile will be left blank. Then, just fill the 13x13 grid that contains the level, and all should work fine. Hope this helps.

    But I need 2 other array values for the author of the puzzle and the player starting coordinates... I don't really want to have 2 arrays for each level

  • What I'm suggesting means you can still have a 16x16 grid to store additionaly information -- such as the author and player starting coordinates -- Basically, the -1 values wouldn't be recognized as a piece, so the spaces with -1 as the value wouldn't have any tiles. There would still be plenty of space for author name and starting coordinates. Example array to illustrate the point:

    2222222222222BBB

    2111111111112BBB

    2111111111112BBB

    2111111111112BBB

    2111111111112BBB

    2111111111112BBB

    2111111111112BBB

    2111111111112BBB

    2111111111112BBB

    2111111111112BBB

    2111111111112BBB

    2111111111112BBB

    2222222222222BBB

    BBBBBBBBBBBBBBBB

    BBBBBBBBBBBBBBBB

    BBBBBBBBBBBBBBAP

    2 = Wall

    1 = Grass

    B = Blank space, represented by -1

    A = Represents author name

    P = Starting player Coordinates

    I hope that better illustrates the idea behind it.

  • What I'm suggesting means you can still have a 16x16 grid to store additionaly information -- such as the author and player starting coordinates -- Basically, the -1 values wouldn't be recognized as a piece, so the spaces with -1 as the value wouldn't have any tiles. There would still be plenty of space for author name and starting coordinates. Example array to illustrate the point:

    2222222222222BBB

    2111111111112BBB

    2111111111112BBB

    2111111111112BBB

    2111111111112BBB

    2111111111112BBB

    2111111111112BBB

    2111111111112BBB

    2111111111112BBB

    2111111111112BBB

    2111111111112BBB

    2111111111112BBB

    2222222222222BBB

    BBBBBBBBBBBBBBBB

    BBBBBBBBBBBBBBBB

    BBBBBBBBBBBBBBAP

    2 = Wall

    1 = Grass

    B = Blank space, represented by -1

    A = Represents author name

    P = Starting player Coordinates

    I hope that better illustrates the idea behind it.

    So the "B"s won't be recognized in the For each elements...

    But the A and P will always be counted, and those aren't part of the gameplay

  • The A and P would only be recognized if you wanted them to be. As you have it now, it will only create pieces if the current cell is equal to that pieces identifier. You don't have it looking for -1, so it will skip over them. Likewise with the P and A, they will only be recognized if you want it to recognize them, otherwise they are merely there to store the information you want.

  • The A and P would only be recognized if you wanted them to be. As you have it now, it will only create pieces if the current cell is equal to that pieces identifier. You don't have it looking for -1, so it will skip over them. Likewise with the P and A, they will only be recognized if you want it to recognize them, otherwise they are merely there to store the information you want.

    Then how can I exclude P and A from "For...each cell" loop?

    Anyway I'm going to sleep, if you can, could you kindly make me a example? Not based on the editor, even from scratch.

    See ya tomorrow.

  • Then how can I exclude P and A from "For...each cell" loop?

    What he's saying is, you don't need to exclude them. Yes, the loop will run, but nothing will happen when it sees the info in those cells (unless you want it to). And it's only two loops, it's not going to affect performance any.

  • Alright, I pulled together an example showing how it all works. It includes a sample level and a fairly extensive read-me. I hope this can solve your problems.

    Array Example

  • Alright, I pulled together an example showing how it all works. It includes a sample level and a fairly extensive read-me. I hope this can solve your problems.

    Array Example

    Thank you man! You solved lots of problems!

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)