I like how you broke things down to single objects and this is a nice way to view the design code before writing anything down.
Thanks again. On 11/28/06, Jason King <[EMAIL PROTECTED]> wrote:
Ah a general OOP question that even a flash-noob like me can answer. Don't just separate functions, decompose the game and the objects should fall out. Let's use an online chess game as an example. Chess has players, moves, pieces and a board. I'd probably build a Player.as, Move.as, Piece.as and Board.as I might create descendants of Piece (e.g. King, Queen, Rook etc). As you look at each function in the game put that in the class file that it has the most to do with. Drawing the board goes in Board.as. The board probably knows where the pieces are and calls Piece to draw each piece on an occupied square. Testing for check belongs in Move.as since its not legal to put your own king in check by your move. The checktest should be public as you'll want to re-use it. Testing for checkmate probably belongs in Player as at the start of each player's turn you should test to see if s/he has lost the game. That will probably involve multiple calls to checktest to see if their king can move to a square where he's not in check. The game starts by creating 2 players and a board. while neither player is checkmated it processes one player's turn then the other's. Helmut Granda wrote: > I have a game class that is about 215 lines of code. Is not really big > but i > would like to divide this class in smaller packages so I can re-use > bits of > pieces of code for new versions of the game. > > The question is what are the best practices to break this code into > smaller > bits and pieces? As always we dont like to help without seeing what the > person is doing already. > > So here it is my idea > > MainClass > -com > --utils > ---func1 > ---func2 > ---func3 > > But some of the functions talk directly to the main class so what is the > best approach to use those extra functions? Should I pass all the > strings or > arrays that in need and let the functions spit back the information I > need? > > Help welcome... maybe a book or 2 :) > > _______________________________________________ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com
-- ...helmut helmutgranda.com _______________________________________________ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com