I'm working on a college project using the educational Java framework Greenfoot, and as stated above we're making an r-type clone.
I've been looking at using an array of strings to populate the levels. The array contains 60 strings, filling the Y axis, each element in the array represents a y co-ordinate += 10. I use "0" to represent empty space, "1" to represent a block of terrain.
Then I use a for loop and charAt() method to create a new array representing each column along the X axis, and populate the screen this way.
I thought I was being clever by making a "block" class that checked to see if it was connected to any other blocks and adjust it's image accordingly to make the terrain look as if it's a single block/shape. However, this is now slowing down the game to a crawl as there are so many objects in it.
I've tried to add the columns as the game is scrolling and removing them once they leave the screen, but I end up with gaps in the terrain.
How are levels in these types of game normally implemented? Would I be better creating a few big objects to make the terrain and build the whole level from start to finish?
Is there some method I've completely missed?
Here is a screen shot of how it looks at the minute, each block is 22 x 10 pixels.
block
class with f.e. an enum which contains where to draw a line:TOP = 1, RIGHT = 2, BOTTOM = 4, LEFT = 8
. Add acheckBorders
method which will check against the surrounding blocks and set that bit field (only once, right after loading the level). And then let the render method check against that enum to see where it needs to draw lines. \$\endgroup\$