Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make game object loading configurable #217

Open
punchcafe opened this issue Apr 4, 2020 · 1 comment
Open

Make game object loading configurable #217

punchcafe opened this issue Apr 4, 2020 · 1 comment
Labels
🍃 improvement 🗺 tmx TiledMap editor issues
Projects

Comments

@punchcafe
Copy link

punchcafe commented Apr 4, 2020

This ticket is a WIP

Motivation

Diving in to developing a game, when I want to create a new entity in the game, I have to create a model to represent it, set up listeners to make sure it is instantiated properly, manually set it to the physics manager etc... Realistically, I should be able to define a class which implements a Model interface, and then be able to create objects in TMX with the same type, and it should appear.

For example:

interface GameObjectModel<T> {
  void initialize(ModelConfig<T> someMap){ default imp }; // This would be injected from the values provided in tiled, and the method would have default behaviour for nulls.
}

Also, behaviour resolution between two objects should be handled without having to know about game objects. Something like:

interface BehaviourStrategy<SubjectType> {
  BiConsumer<SubjectType,Object> getBehaviourStrategy(Class anyClass){
    // returns the correct method for resolving collision
  }
}

Ideally, I feel like we don't need to ever handle game objects. This means we can build entire Java models, and everything else is abstracted away

@bitbrain bitbrain changed the title Abstraction of Game Object Make game object loading configurable Apr 11, 2020
@bitbrain bitbrain added this to Icebox in Core via automation Apr 11, 2020
@bitbrain bitbrain added 🍃 improvement 🗺 tmx TiledMap editor issues labels Apr 11, 2020
@bitbrain
Copy link
Owner

I like the idea! I have reworded the ticket since we can make this very generic, however then use this e.g. in the TiledMapManager to load game objects based on a given configuration.

Currently, I am facing the same issue, where I manually need to decorate/initialise objects based on type (not very nice):

// AFTER tiledmap has been loaded
for (GameObject object : gameWorld.getObjects()) {
   if ("PLAYER".equals(object.getType()) {
      // initialise player here
   }
}

This approach is very cumbersome, error-prone and inflexible, since we have to do always changes in multiple places, check for types etc.

Instead, we can do the following:

  1. implement a set of rules how game objects should be initialised
  2. define objects and attributes e.g. in tiled
  3. objects get automatically loaded and assigned to their e.g. behaviors etc.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🍃 improvement 🗺 tmx TiledMap editor issues
Projects
Core
  
Icebox
Development

No branches or pull requests

2 participants