Handling large playing areas
Summary
-
We have a playing area, or 'board', effectively consisting of a matrix of squares.
The board is potentially very large. (100 x 100 grid, perhaps more?!)
What possible approaches/architectures would be suitable for handling such a potentially large playing area where by each square can 'react' differently to a player 'landing' on it.
Details
-
The board itself need not actually be made of individual 'squares', but the way in which 'player pieces' are to move and be positioned on the board is on a grid-like pattern.
Each square is 1 of a number of types, and each type has different 'effect' when a player piece 'lands' on it. (each square type must look different too).
Prototype
My original prototype used a different class for each square type, and a separate instance for each individual square. Each of these classes extend javax.swing.JPanel, and contain the specific behaviour for that square type.
However, JPanel is a large class and having 100x100 or more classes in memory (for the board alone - not to mention the game and player classes etc) is an EXTREME drain on resources. In fact it is simply not possible to do this (without perhaps fiddling with the JVM memory settings).
So clearly this 'an object per square' approach simply isn't workable, but I'm unsure how to build a board consisting of various types of squares without having to have a separate square object (or some kind) for every individual square.
Any pointers for such a problem?
thanks
John
(johnsenford@hotmail.com)

