Sign in to follow this  
rosancoderian

Headless Panda.js for multiplayer game

Recommended Posts

Support for headless mode has now been added to latest dev version.

Here is small example on running Panda Engine on headless mode with node:

server.js

global.game = require('./src/engine/core.js');

game.config = {
    system: {
        frameRate: 10
    }
};

game.module(
    'game.main'
)
.body(function() {
    
game.createScene('Main', {
    init: function() {
        console.log('Main scene started');
        
        var world = new game.Physics();
        
        this.body = new game.Body();
        var shape = new game.Rectangle(100);
        this.body.addShape(shape);
        this.body.addTo(world);
    },
    
    update: function() {
        console.log(this.body.position.y);
    }
});    
    
});

game.start();

Output:

$ node server.js
Main scene started
0
2.45
7.3500000000000005
14.700000000000001
24.5
36.75
51.45

Let me know if you have any issues.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.