Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: JSGameClient: JavaScript and SFML game development environment  (Read 2821 times)

0 Members and 1 Guest are viewing this topic.

StevenC

  • Newbie
  • *
  • Posts: 40
    • View Profile
    • Corona Soft Development Blog
Greetings,

I just wanted to let everyone know that I've made significant progress toward creating an environment that will allow developers who want the ability to write desktop games using JavaScript as the primary development language.

JSGameClient is a no-frills JavaScript environment that combines Chrome's V8 JavaScript engine with Physics FS, SFML and Texus' TGUI. The project is part of a series of open source projects I am working on to create a fully modable and open source game development system with all major components licensed under a permissive license that makes it usable by closed and open source developers alike.

Developers that wish to contribute are invited to do so provided that they license their work under a compatible license. Message me if you are interested. I am committed to maintaining this project for the next few years eventually expecting to reach version 1.0 and have a reference engine that can be used to speed up development.

-----

Current Needs:

1. Testing and improvement to support building on Mac.
2. Code to prevent privileged execution of the JSGameClient - given the JSGameClient is intended for writing games there is no good reason to allow it to run as elevated administrator or root.

-----

Website: http://github.com/StevenChristy/JSGameClient
Documentation available through the readme.md and the docs/index.html

-----

Status:

Version 0.3.2 - Added support for setTimeout, clearTimeout, setInterval, clearInterval, and sleep methods. Added additional documentation including some steps for building under Linux.

Version 0.3.1 - The build system was improved and building on Linux has been tested and works well.

Version 0.3.0 - This is a work in progress and is not ready for production use. SFML and Physics FS (readonly) and a few essential commands.

The latest version fixes numerous bugs and supports building for VS 2010 and MinGW 32-bit.

-----

Development: To debug JavaScript applications it is recommended that one use Eclipse. By linking in the JS files in the jsdocs subfolder one can have context sensitive help while writing JavaScript code under Eclipse. Use the Chrome Developer Tools to try and debug the app as a Standalone V8 application. Uncaught exceptions will generate a full call-stack and the risk of crashing should be minimal. In the event that the application does crash I recommend debugging under Visual Studio 2010 to find the source or you could submit a sample that reproduces the issue and I will chase it down.

-Steven
« Last Edit: October 20, 2012, 05:49:42 am by StevenC »

StevenC

  • Newbie
  • *
  • Posts: 40
    • View Profile
    • Corona Soft Development Blog
Re: JSGameClient - V8 JavaScript + SFML + PhysFS standalone
« Reply #1 on: July 08, 2012, 11:40:05 pm »
I've included an example using the box2dweb library. To run the example download the latest source and rebuild (or use the pre-compiled Windows binaries).

To run the example execute:
jsgame --start Examples/box2dtest.js

From the bin directory.

StevenC

  • Newbie
  • *
  • Posts: 40
    • View Profile
    • Corona Soft Development Blog
Version 0.3.2 Released
« Reply #2 on: October 20, 2012, 06:02:59 am »
Updates to JSGameClient have been released. The important details are:

  • Added Project Goals Listing
  • Added more documentation
  • Added an additional example
  • JSGameClient now provides supports an event driven model and includes setInterval/setTimeout functions that work the same as in a web browser.

var text = new sf.Text(new sf.String("Hello World"));
var window = new sf.RenderWindow(new sf.VideoMode(1024, 768), "Game Client");
var event = new sf.Event();
var cnt = 0;

var loopid = time.setInterval(function() {
        cnt += 1;
        text.setString(new sf.String("Hello World: " + cnt));
        if ( window.isOpen() ) {
                window.clear();
                window.draw(text);
                window.display();
                while ( window.pollEvent(event) ) {
                        if ( event.type == sf.Event.Closed ) {
                                window.close();
                        } else if ( event.type == sf.Event.KeyPressed ) {
                                if ( event.key.code == sf.Keyboard.I ) {
                                }
                        }
                }
        } else {
                log("Clearing interval");
                time.clearInterval(loopid);
        }
}, 50);
 

The above is an event driven alternative to something like:

var text = new sf.Text(new sf.String("Hello World"));
var window = new sf.RenderWindow(new sf.VideoMode(1024, 768), "Game Client");
var event = new sf.Event();
var cnt = 0;

while (window.isOpen())
{
    window.clear();
    window.draw(text);
    window.display();
    while ( window.pollEvent(event) )
    {
        if ( event.type == sf.Event.Closed ) {
            window.close();
        }
    }
}
 

I personally prefer the second example, but the two approaches can be combined as:

var text = new sf.Text(new sf.String("Hello World"));
var window = new sf.RenderWindow(new sf.VideoMode(1024, 768), "Game Client");
var event = new sf.Event();
var cnt = 0;

var loopid = time.setInterval('cnt += 50; text.setString(new sf.String("Hello World: " + cnt));', 50);

while (window.isOpen())
{
    time.yield(); // Without this, the interval code will not be called.
    window.clear();
    window.draw(text);
    window.display();
    while ( window.pollEvent(event) )
    {
        if ( event.type == sf.Event.Closed ) {
            window.close();
        }
    }
}

time.clearInterval(loopid);
 

Like in the browser the setInterval/setTimeout can use a function or a string containing JavaScript code.

 

anything