Moddable Blocks Design
No replies to this topic
Members - Reputation: 201
Posted 03 January 2013 - 02:16 AM
So I have been working on a game mainly just for fun but it appears I am a bit stuck. It's mainly a design issue. First let me tell you a bit about the game and what I am trying to achieve. I am working on a game written in java. Mainly for the portability. The main focus of the game is to make a game that is extendable / moddable by a lot of users (not only programmers but also non-programmers).
The bit I am stuck in is that I would like to dynamically generate a world. The world will be voxel based (for those that do not know this is the same way worlds in minecraft look). The world consists of blocks which are either loaded from a txt file (or something similair) or compiled java class files (for the more advanced stuff).
So now for the question . The problem I am facing is how to set this up. The world generation part isn't really the problem but mainly how to create the list off all available blocks.
I personally was thinking the following. Have 1 class called BlockBlueprint which contains information both of the block types use (meaning the txt one and the class one). The BlockBlueprint would contain information like: name, minOccurenceLevel, maxOccurenceLevel, frequency, textureFile, textureCoords, etc. Then fill this information for each block type creating a list with blockBlueprints (which in it's turn can be used in world generation).
Then have a second class called BlockFactory which requires a blueprint. This factory would either invoke the BlockTxtLoader or BlockClassLoader to actually create the block (for the world). I am not quite sure what to return from both loaders (a superclass maybe with default functions, or a class which implements an interface).
What would be the best (or another way) of approaching this? Would you use a (blueprint / template / type) like class or...? Also would you use a superclass or interface?
Also as my game always runs in Server / Client mode (server hosts world and client only displays world). I would probally need to send all classes over the network to the client and have a similar setup client side. Or are there any other alternatives i should consider?
With kind regards,