The Concept of Entities -- Can't wrap my mind around it.
Hey, I've been learning java for a while, and I have some experience modding other games made in Java, and I'd like to make my own game. I feel I've learned enough to get started, but there's one thing that I can't seem to wrap my mind around:
The concept of entities.
Specifically, the concept of creating an object/entity with its data, and then saving and loading this data from a file that can't be easily edited by the user.
Does anybody know a good tutorial about this, or can help me directly?
Just to clarify, I'm talking about things like the blocks and mobs in minecraft, created by the game as it goes, and with properties that can be remembered upon re-opening the game.
Re: The Concept of Entities -- Can't wrap my mind around it.
You should read up on Object oriented programming (OOP). There are many books and papers on the topic.
Start with Wikipedia and Google for an unending list of sites to read.
Re: The Concept of Entities -- Can't wrap my mind around it.
An entity is just defined by its own object. For instance, I can't guarantee this since I haven't looked at Minecraft's source code, but I'll bet you that the creeper has its own class. Its just an object.
You can save that object using serialization. Check the java.io package of Object I/O streams.
I don't know how Notch designed his implementation with block data, but it has to be either a serialized object or just bytes/number values written to a file that the program parses.
It's all up to YOU how you want to implement the saving and loading of data. There are tons of methods to doing so. You can come up with your own file format if you want...