Structure gameobjects and call events
Posted
by
waco001
on Game Development
See other posts from Game Development
or by waco001
Published on 2014-04-29T00:28:31Z
Indexed on
2014/08/22
16:38 UTC
Read the original article
Hit count: 351
I'm working on a 2D tile based game in which the player interacts with other game objects (chests, AI, Doors, Houses etc...). The entire map will be stored in a file which I can read. When loading the tilemap, it will find any tile with the ID that represents a gameobject and store it in a hashmap (right data structure I think?).
private static HashMap<Integer, Class<GameObject>> gameObjects = new HashMap<Integer, Class<GameObject>>();
How exactly would I go about calling, and checking for events? I figure that I would just call the update, render and input methods of each gameobject using the hashmap. Should I got towards a Minecraft/Bukkit approach (sorry only example I can think of), where the user registers an event, and it gets called whenever that event happens, and where should I go as in resources to learn about that type of programming, (Java, LWJGL).
Or should I just loop through the entire hashmap looking for an event that fits? Thanks waco
© Game Development or respective owner