Giter Club home page Giter Club logo

libgdx-test-rpg's People

Contributors

juku avatar

Stargazers

 avatar

Watchers

 avatar  avatar  avatar

libgdx-test-rpg's Issues

TMX Layer no_lighting

Add support for TMX Layer no_lighting and draw black rectangles in lighting framebuffer.

Spawn projectiles

It should be possible to spawn projectiles after clicking an mouse button.

ConcurrentModificationException if removing entity on update Method

If you remove an entity in update() method of component, this will cause an ConcurrentModificationException or an NullPointerException.

Entity update() method:

public void update(BaseGame game, GameTime time) {
        //update all components
        this.updateComponentList.stream().forEach(component -> {
            component.update(game, time);
        });
    }

BaseECS update() method:

public void update (BaseGame game, GameTime time) {
        this.entityUpdateList.stream().forEach(entity -> {
            //update entity
            entity.update(game, time);
        });
    }

Stream throws an ConcurrentModificationException, if list was updated while iterating over it.

BaseECS removeEntity() method:

public void removeEntity (Entity entity) {
        if (entity == null) {
            throw new NullPointerException("entity cannot be null.");
        }

        //get entityID
        final long entityID = entity.getEntityID();

        synchronized (this.entityUpdateList) {
            //remove entity
            this.entityUpdateList.remove(entity);
        }

        synchronized (this.entityDrawList) {
            //remove entity
            this.entityDrawList.remove(entity);
        }

        synchronized (this.entityUILayerDrawList) {
            //remove entity
            this.entityUILayerDrawList.remove(entity);
        }

        this.entityMap.remove(entityID);

        //call listeners
        onEntityRemoved(entity);

        //dispose entity
        entity.dispose();
    }

To fix this problem, their are 2 possibilities:

  1. add an list with all entites to remove, add this entities in removeEntity() method and remove them before every update() and draw() method will be executed.
  2. Copy entity update list before iterating over it (or use an temporary list and add all entries every gameloop cycle / update method), so copied list will not be updated, if entity was removed.

IllegalArgumentException on shutdown

Exception Stacktrace:

Exception in thread "LWJGL Application" java.lang.IllegalArgumentException: object has to be an instance of PositionComponent to check, if equals.
	at com.jukusoft.libgdx.rpg.engine.entity.impl.component.PositionComponent.equals(PositionComponent.java:288)
	at java.util.ArrayList.remove(ArrayList.java:528)
	at com.jukusoft.libgdx.rpg.engine.entity.Entity.removeComponent(Entity.java:187)
	at com.jukusoft.libgdx.rpg.engine.entity.Entity.lambda$dispose$3(Entity.java:273)
	at java.util.ArrayList$ArrayListSpliterator.forEachRemaining(ArrayList.java:1374)
	at java.util.stream.ReferencePipeline$Head.forEach(ReferencePipeline.java:580)
	at com.jukusoft.libgdx.rpg.engine.entity.Entity.dispose(Entity.java:272)
	at com.jukusoft.libgdx.rpg.engine.entity.impl.BaseECS.removeEntity(BaseECS.java:211)
	at com.jukusoft.libgdx.rpg.engine.entity.impl.BaseECS.removeAllEntities(BaseECS.java:238)
	at com.jukusoft.libgdx.rpg.game.screen.GameScreen.onPause(GameScreen.java:172)
	at com.jukusoft.libgdx.rpg.engine.screen.impl.DefaultScreenManager.pop(DefaultScreenManager.java:91)
	at com.jukusoft.libgdx.rpg.game.screen.GameScreen.onPause(GameScreen.java:169)
	at com.jukusoft.libgdx.rpg.engine.game.ScreenBasedGame.lambda$destroyGame$2(ScreenBasedGame.java:55)
	at java.lang.Iterable.forEach(Iterable.java:75)
	at com.jukusoft.libgdx.rpg.engine.game.ScreenBasedGame.destroyGame(ScreenBasedGame.java:54)
	at com.jukusoft.libgdx.rpg.engine.game.BaseGame.dispose(BaseGame.java:382)
	at com.badlogic.gdx.backends.lwjgl.LwjglApplication.mainLoop(LwjglApplication.java:245)
	at com.badlogic.gdx.backends.lwjgl.LwjglApplication$1.run(LwjglApplication.java:126)

Add entities with name

To find an specific entity it can be an good idea to support adding entities with an unique name.

Blob Shadow

Add support for blob shadows as component.

Add HBBar over Character

Add an component for HP (min value, max value, current value) and an component to draw HP over entity.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.