Images
I have some custom made images (made in photoshop) that are 25x25px each (except for some). I'm making a Bomberman game, where each cell is 25x25px (hence the small image sizes). The bomb (which I manually animated in photoshop as a GIF) used to be larger than 25x25px (because I hadn't decided on the cell size at the time), and so did the explosion (which is 2 separate graphics as subclasses to a explosion class, for hit-detection reasons). I have since resized both images to their correct sizes, but the problem is that, though the bomb is the correct size outside of greenfoot, when it is actually used inside greenfoot, it is too big. I tried resizing it using code in greenfoot and (although I don't remember exactly what happened) it ran into an error. I doubt it's because I only resized one image of the bomb in the GIF in photoshop because I resized the layers collectively, but it is a possibility.
TL:DR: The bomb (which is a custom photoshop GIF) is 25x25px, but when in greenfoot, it becomes larger. Resizing using code caused an error.
Arrays
I don't have much experience with Java arrays. I have had experience with dictionaries/lists/arrays in other coding languages such as python, so I'm not entirely new to the concept. However, when I started this Bomberman project, it was recommended to me that I use an array to spawn the blocks and enemies etc. I think it would be easier to use a multidimensional array. But, my grid consists of 36x24 cells (each cell is 25x25px), which is a lot of dimensions in one (or more) array(s). I also am unsure how I would go about using the array to implement the actual actors into the world.
With this, I actually haven't started coding this part yet, as I am unsure of how to do it... so... no source code yet unfortunately... but this is what I am planning:
(in World)
- initialise a multidimensional array of strings {{"player", "space", "", "", "", "", etc.}, {"space", "", "", etc.}, {"", "", "unbreakable block", etc.}, etc.}
- each dimension of the array should be the y-coord storing a string. Each position equals an x-value eg. { {x1, x2, x3, x4, etc.}, {x1, etc.}, etc.}
- the Unbreakable blocks, the player, and 2+ blank spots are in set positions. Everything else should be randomly generated in the array
- anything in the array should then be inserted into the world at the corresponding x/y-coords, preferably using a for-loop, but act() works too.
Before I decided to use a multidimensional array, I tried using a for-loop to add in unbreakable blocks at x/y-coords that were 3 cells apart. The for-loop ended up spawning the first block, before it gave up (multiple times):
sigh... it went something like:]
I'm sorry this is so long but I just need suggestions these things, and I'd rather get suggestions all in one go. Kinda short on time is all.
Any and all help is appreciated, thank you.
int x = 2; int y = 2; for (i=0; i < 100; i++){ if (x > 35){ y = y + 3; x = 2; //I think I forgot this line in my old code } if (y > 24){ i = 100; } addObject(sblock, (x*25+(25/2), (y*25+(25/2)); //I had already defined sblock as the unbreakable block actor x = x + 3; }