Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

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

share|improve this question
    
It's not really clear what you're asking. If you're using the correct data structure or not depends on how you're using it, we can't answer that. And what kind of events are you talking about? What's the problem you're trying to solve? How are you doing things now and what about it isn't working? –  Byte56 Apr 29 at 13:32
    
@Byte56 What I'm asking is, what is the fastest way to store gameobjects in some sort of list and quickly call events, render, update. –  waco001 Apr 30 at 11:50
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.