Should i be able to do this? (2d arrays)

I am attempting to nest a 2d array within a 2d array, the reason being because i need to access them both in detail within the same fuction. This doesnt bring up any errors, however it never renders the images.

  int[][] grid = new int[cols][rows];
  for (int i = 0; i < cols; i++) {
    for (int j = 0; j < rows; j++) {
      boolean[][] sq = new boolean[cols][rows];
      for (int k = 0; k < cols; i++) {
        for (int l = 0; l < rows; j++) {
          image(GRID, i*50, j*50);
          }
        }
      }
    }
  }
}

Answers

  • I feel that quad loop is infinite b/c neither iterators k & l are increased anywhere!!! :-t
    Neither see k or l being used to influence anything! Sorry I can't figure out what's that for! X_X

  • edited November 2013

    Ok, this program, once it is complete, will write lines of code based on gui changes. So there is a "grid", an array of images when you start the program, once you click one it will go to a new screen with buttons, you click a button and it assigns a string to that square and the code will spit out into the text file as so column,x,y,tile 0,2,5,"A STRING"

    Do you get what i mean, this program is to serve as a map editor for my game which i am making also, Which as you know is currently held up on a N P E. I will accept any advice on this 'map editor idea', this is just what first came to mind, but something tells me that if it is starting like this, its not going to get any better.

  • edited November 2013

    Lemme see... You say you got a grid of images that act like clickable buttons?
    And when 1 is chosen it goes to a GUI form screen that once filled in becomes associated to that chosen image?
    And of course, it gets back to previous gridded image screen?

    You should create a class which represents those image clickable buttons!
    Then have some methods like finding out which 1 got selected.

    Some online examples to help ya get started: =:)

    http://studio.processingtogether.com/sp/pad/export/ro.9ABG0RKl9D2Bx/latest
    http://studio.processingtogether.com/sp/pad/export/ro.9vAkI4JDuLs8s/latest

    • Why do you increment i on the k loop and j on the l loop?
    • Why do you declare a sq array in an inner loop, but never use it?
    • Actually, the inner loops are quite useless, unless you really want to redraw GRID over and over at the same places...
  • Well you see the actual problem here is that i am trying to assemble a massive 2d image map that doescnt take up massive file sizes. I hqve just figured out that it is artistically impossihle to make enough tiles. So i need a way i can assemble a map that is 4000x4000 tiles wihout making it artkstically impossible. I need ideas, would glsl be a good way to turn? I could just write the code for the different textures and apply them to different pafts of the map? Any ideas are welcome

Sign In or Register to comment.