SFML community forums
General => SFML projects => Topic started by: imekon on November 04, 2015, 01:40:32 pm
-
I've been poking around GameMaker Studio, Construct 2 and Clickteam Fusion 2.5 and started wondering how hard it would be to make a 2d game engine.
My reason for doing this was all of the above engines are fine, but they get in the way a bit, as I'd rather write code than visually program. GameMaker is unique in that it has a script language. Fusion has JavaScript for plugins.
I looked briefly at SDL but chose to use SFML instead (classes not C functions). I bolted a Lua interpreter on at first, but after reading "why everyone should learn javascript" (http://blog.monitor.us/2014/08/why-everyone-should-learn-javascript/), I thought, why not?
I got hold of duktape, a JavaScript engine and swapped out Lua. Now Lua is fine, but JavaScript is better (IMHO) as it's more C/C++ like.
I added Box2d physics and created my first couple of demos: a simple block game (http://imgur.com/a/z7IrB) and a physics demo.
So where am I going with this? Am I trying to make a game? I'm interested in Match3 type games and procedural generation... so that's why I'm doing this.
Oh yeah, and writing code like this is fun.
-
Can you elaborate a bit on how your "bridge" to JavaScript looks like and what you can do solely in JavaScript?
-
I used duktape (duktape.org) to provide the embedded JavaScript. I originally used Lua but switched to duktape (JavaScript) as it's more C/C++ like. In fact, duktape is very similar to Lua in the C code.
The JavaScript behind each 'game' has at least two functions - initialise and run that get called by the engine.
I keep time consuming operations in C++ but let the JavaScript do the higher level stuff, like creation etc.
To create a box (32 x 32) with physics, you'd do something like
function initialise()
{
box = GameObject.textureObject(1); // create a sprite with texture index 1
box.setOrigin(16, 16); // important for Box2D physics
box.setPosition(100, 100); // set the position
Physics.createDynamicBox(box, { density: 1, friction: 0.6 });
}
-
This is quite nice, and I haven't heard of Duktape yet. Would be nice to the code, if this is by any chance open.
-
It's not open source yet, but could be - if I can work out how to bring together SFML, Box2D, Duktape and the rest into one Git project.
SFGUI - maybe I should replace my crude console implementation with that for logging...
-
It's not open source yet, but could be - if I can work out how to bring together SFML, Box2D, Duktape and the rest into one Git project
One option would be git submodule :
https://git-scm.com/book/en/v2/Git-Tools-Submodules
https://git-scm.com/docs/git-submodule
-
Now Lua is fine, but JavaScript is better (IMHO) as it's more C/C++ like.
Squirrel and AngelScript (and maybe a few others) are meant to fill the role of "more C++ like Lua like scripting", not JavaScript.
-
I've been poking around GameMaker Studio, Construct 2 and Clickteam Fusion 2.5 and started wondering how hard it would be to make a 2d game engine.
You've completely underestimated the complexity of those engines.
Squirrel and AngelScript (and maybe a few others) are meant to fill the role of "more C++ like Lua like scripting", not JavaScript.
I wouldn't make a game relying mostly on Squirrel or Angelscript, though. Neither have a large community or has a proven JIT compiler available for it.
-
And starting with ECMAScript2015 the language is indeed getting better. :P
-
And starting with ECMAScript2015 the language is indeed getting better. :P
Duktape is V5 with some bits of V6... :-[
-
Hello.
Progress? Why not implement berkelium?
I found with links but i don't try it yet..
https://github.com/Yours3lf/gl_browser_gui (https://github.com/Yours3lf/gl_browser_gui)
https://github.com/ThomasColliers/glexp-gui (https://github.com/ThomasColliers/glexp-gui)
Sorry for bad english