Jump to content

Headless Panda.js for multiplayer game


rosancoderian
 Share

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.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...