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

Example code is broken out of the box #111

Open
noxabellus opened this issue May 27, 2024 · 0 comments
Open

Example code is broken out of the box #111

noxabellus opened this issue May 27, 2024 · 0 comments

Comments

@noxabellus
Copy link

noxabellus commented May 27, 2024

git clone https://github.com/lance-gg/tinygames.git
cd tinygames/asteroids
npm i
npm run start
> [email protected] start
> node dist-server/main.js

Listening on 3000
file:///home/nox/projects/tinygames/asteroids/node_modules/lance-gg/dist/server/lance-gg.js:28931
            this.id = this.gameEngine.world.getNewId();
                                      ^

TypeError: Cannot read properties of null (reading 'world')
    at new GameObject (file:///home/nox/projects/tinygames/asteroids/node_modules/lance-gg/dist/server/lance-gg.js:28931:39)
    at new PhysicalObject2D (file:///home/nox/projects/tinygames/asteroids/node_modules/lance-gg/dist/server/lance-gg.js:29153:9)
    at new Asteroid (file:///home/nox/projects/tinygames/asteroids/dist-server/common/Asteroid.js:2:16)
    at Serializer.deserialize (file:///home/nox/projects/tinygames/asteroids/node_modules/lance-gg/dist/server/lance-gg.js:29578:19)
    at Asteroid.prunedStringsClone (file:///home/nox/projects/tinygames/asteroids/node_modules/lance-gg/dist/server/lance-gg.js:14344:33)
    at AsteroidsServerEngine.serializeUpdate (file:///home/nox/projects/tinygames/asteroids/node_modules/lance-gg/dist/server/lance-gg.js:30028:27)
    at AsteroidsServerEngine.syncStateToClients (file:///home/nox/projects/tinygames/asteroids/node_modules/lance-gg/dist/server/lance-gg.js:30004:34)
    at Array.map (<anonymous>)
    at AsteroidsServerEngine.step (file:///home/nox/projects/tinygames/asteroids/node_modules/lance-gg/dist/server/lance-gg.js:29973:33)
    at Scheduler.callTick (file:///home/nox/projects/tinygames/asteroids/node_modules/lance-gg/dist/server/lance-gg.js:29531:22)

similar results can be seen for all the example projects here; In Serializer.deserialize there is

let obj = new objectClass(null, {}, {});

and then the GameObject constructor looks like this

    constructor(gameEngine, options, props) {
        super();
        this.gameEngine = gameEngine;
        if (options && options.id)
            this.id = options.id;
        else
            this.id = this.gameEngine.world.getNewId();
        this.playerId = (props && props.playerId) ? props.playerId : 0;
        this.components = {};
    }

So with options empty, it tries to use the null gameEngine that was passed to get a new id. Beyond this I can't really understand what's happening as I'm not really familiar with all the code paths yet.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant