Difference between revisions of "Developing a Sphere-compatible engine"

From Spherical
Jump to: navigation, search
(Added input comments)
(List of Sphere-compatible engine implementations: fill)
Line 40: Line 40:
 
==List of Sphere-compatible engine implementations==
 
==List of Sphere-compatible engine implementations==
 
===Complete or in-progress===
 
===Complete or in-progress===
* vanilla Sphere
+
* vanilla Sphere (stable: 1.5, unstable: 1.6 beta 4, inactive: 1.7) ([https://github.com/sphere-group/sphere source])
* TurboSphere(!)
+
** JavaScript: [https://developer.mozilla.org/en-US/docs/SpiderMonkey SpiderMonkey]
* unnamed Sphere clone in SDL
+
** Video: configurable
* sphere-sfml
+
** Audio: configurable
 +
** Input: configurable
 +
* TurboSphere ([https://github.com/FlyingJester/TurboSphere source], [http://forums.spheredev.org/index.php/topic,13.0.html thread])
 +
** JavaScript: [https://code.google.com/p/v8/ V8]
 +
** Video: SDL2
 +
** Audio: SDL2
 +
** Input: SDL2
 +
* unnamed Sphere clone in SDL ([https://github.com/postcasio/sphereclone source], [http://forums.spheredev.org/index.php/topic,72.0.html thread])
 +
** JavaScript: [https://code.google.com/p/v8/ V8]
 +
** Video: SDL
 +
** Audio: SDL
 +
** Input: SDL
 +
* sphere-sfml ([https://github.com/Radnen/sphere-sfml source], [http://forums.spheredev.org/index.php/topic,137.0.html thread])
 +
** JavaScript: [http://jurassic.codeplex.com/ Jurassic]
 +
** Video: SFML
 +
** Audio: SFML
 +
** Input: SFML
 +
* web-sphere ([https://github.com/sphere-group/web-sphere source], [http://forums.spheredev.org/index.php/topic,154.0.html thread])
 +
** JavaScript: browser via pixi.js, three.js
 +
** Video: browser via pixi.js, three.js
 +
** Audio: browser via pixi.js, three.js
 +
** Input: browser via pixi.js, three.js
  
 
(!) Although some engines are listed as compatible they will need a wrapper script to complete Sphere's API. For example, LoadImage may indeed return the correct image format by using a different API such as <tt>return new Image()</tt>.
 
(!) Although some engines are listed as compatible they will need a wrapper script to complete Sphere's API. For example, LoadImage may indeed return the correct image format by using a different API such as <tt>return new Image()</tt>.
 +
(TODO: convert above to table?)
  
  

Revision as of 20:54, 16 July 2013

Note.svg

Notice

This tutorial article is incomplete, but it is also important. Do not edit it unless you've been given permission, thanks.


This article aims to provide a checklist and resources for developing a JavaScript-powered game engine that is compatible with Sphere's JavaScript API.

Introduction

Throughout this article, the original Sphere implementation shall be referred to as "vanilla" Sphere.

(TODO: list possible media frameworks?) (TODO: more)

Input

GetKey() must be able to block the sphere engine. If your key queue is zero, go into a loop that just updates the game screen.

SFML

If you are using SFML, you need to handle the key pressed and released events. It's a good idea to use a static array for all of the keys, mouse, and joystick buttons. The array's index corresponds with a key, mouse, and joystick code with a true/false value indicating IsPressed. In order to support more than one joystick you may need to bump up that joystick array to a 2D array, where 'x' is the joystick id and 'y' is the button code.

For the key queue, just use a queue data structure. Enqueue keys on the released state, and dequeue keys with GetKey.

Key Constant Mapping

In SDL, SFML, and other game libraries the key codes may differ from Sphere's. In order to get the correct key mapping you might need to implement a very large structure that says "this key" = "that key". This does not have to happen as it is optional so long as you keep to the same key naming conventions. What this will do is fix it so that if you saved a game with key mappings from vanilla sphere, other sphere engines can use those same codes.

See key constants: (KEY_ESCAPE = 1, KEY_F1 = 2, ... etc). https://github.com/sphere-group/sphere/blob/v1.6/sphere/docs/development/keys.txt


(keyboard, mouse, joystick, touch-screen?)

Output

Video

(TODO: more) (TODO: multi-monitor?) (TODO: touch-screen?)

Audio

List of Sphere-compatible engine implementations

Complete or in-progress

  • vanilla Sphere (stable: 1.5, unstable: 1.6 beta 4, inactive: 1.7) (source)
    • JavaScript: SpiderMonkey
    • Video: configurable
    • Audio: configurable
    • Input: configurable
  • TurboSphere (source, thread)
    • JavaScript: V8
    • Video: SDL2
    • Audio: SDL2
    • Input: SDL2
  • unnamed Sphere clone in SDL (source, thread)
    • JavaScript: V8
    • Video: SDL
    • Audio: SDL
    • Input: SDL
  • sphere-sfml (source, thread)
    • JavaScript: Jurassic
    • Video: SFML
    • Audio: SFML
    • Input: SFML
  • web-sphere (source, thread)
    • JavaScript: browser via pixi.js, three.js
    • Video: browser via pixi.js, three.js
    • Audio: browser via pixi.js, three.js
    • Input: browser via pixi.js, three.js

(!) Although some engines are listed as compatible they will need a wrapper script to complete Sphere's API. For example, LoadImage may indeed return the correct image format by using a different API such as return new Image(). (TODO: convert above to table?)


Discontinued or abandoned

(TODO)

See also

(TODO)