This site requires JavaScript, please enable it in your browser!
Greenfoot back
444Jam444
444Jam444 wrote ...

2019/7/19

My images are larger than they are supposed to be. Also, using multidimensional arrays and for-loops to put actors into the world.

1
2
3
danpost danpost

2019/8/8

#
You could have used single characters to represent the cell content (like: "p" for player; " " for empty cells; "s" for spaces; "x" for solidblocks; and "b" for breakbricks Then code the grid as follows:
String[] grid =
{
    "psb                                ",
    "sx x x x x x x x x x x x x x x x x ",
    "b                                  ",
    " x x x x x x x x x x x x x x x x x ",
    "                                   ",
    " x x x x x x x x x x x x x x x x x ",
    "                                   ",
    " x x x x x x x x x x x x x x x x x ",
    "                                   ",
    " x x x x x x x x x x x x x x x x x ",
    "                                   ",
    " x x x x x x x x x x x x x x x x x ",
    "                                   ",
    " x x x x x x x x x x x x x x x x x ",
    "                                   ",
    " x x x x x x x x x x x x x x x x x ",
    "                                   ",
    " x x x x x x x x x x x x x x x x x ",
    "                                   ",
    " x x x x x x x x x x x x x x x x x ",
    "                                   ",
    " x x x x x x x x x x x x x x x x x ",
    "                                   "
};
This is easy enough to iterate through to prepare the layout of the world and, as an added benefit, displays in the editor like the layout.
444Jam444 444Jam444

2019/8/15

#
It wasn't letting me do that, unfortunately. It was throwing an error as soon as I used more than 1 line for initialising the grid. Once again, appreciate the help.
444Jam444 444Jam444

2019/8/15

#
I do have fully annotated and updated code, but it is much more tedious for me to post that here.
danpost danpost

2019/8/15

#
In your MyWorld class, remove the main method (lines 184 to 189).
444Jam444 wrote...
I do have fully annotated and updated code, but it is much more tedious for me to post that here.
You do not have to show all of it again. Just show how you iterate through myGrid now.
444Jam444 444Jam444

2019/8/15

#
danpost wrote...
Just show how you iterate through myGrid now.
That has not been updated. I was referring more to minor bug fixes, minor corrections, etc. I should have said that, sorry. To be honest, I might not patch the bruteforced code until I feel the need to. The project is over, so this might not happen...
444Jam444 444Jam444

2019/8/15

#
danpost wrote...
In your MyWorld class, remove the main method (lines 184 to 189).
This is more what I mean by 'updated'. Just small things. Removing unnecessary (unused) code, etc.
You need to login to post a reply.
1
2
3