Skip to main content

News

Recent Posts

81
Engine Development / Re: miniSphere 5.3b1 (stable: 5.2.13)
Last post by Fat Cerberus -
So when I said above that from queries would be blazing fast, I meant it, and to prove it I've done a quick benchmark of other similar solutions:
Code: (javascript) [Select]
let fromQuery = new Query()
.where(it => it % 2 === 0)
.take(10000)
.select(it => it + 1)
.reduce((a, it) => a + it, 0);
Code: [Select]
 event                    count   time (us)   % run  avg (us)    % avg |
------------------------------------------------------------------------
 Array method chain       1,001   3,605,798  34.1 %     3,602   34.3 % |
 Underscore chain         1,001   2,065,016  19.5 %     2,062   19.6 % |
 Lodash chain             1,001   1,168,390  11.0 %     1,167   11.1 % |
 from.js 1.0              1,001     903,805   8.5 %       902    8.6 % |
 from.ts (Oozaru)         1,001     875,786   8.3 %       874    8.3 % |
 Link.js query            1,001     475,447   4.5 %       474    4.5 % |
 Link.js query (NR)       1,001     325,084   3.1 %       324    3.1 % |
 from.js 2.0              1,001     319,423   3.0 %       319    3.0 % |
 Lazy.js sequence         1,001     270,130   2.6 %       269    2.6 % |
 Sphere from() query      1,001     205,757   1.9 %       205    2.0 % |
 Sphere Query object      1,001     188,966   1.8 %       188    1.8 % |
 handwritten 'for' loop   1,001     119,092   1.1 %       118    1.1 % |

Sphere from() query and Sphere Query object is us!  All timings are for running a chain equivalent to the above query 1,000 times with the respective library over an array of 100,000 random integers between 0 and 1000.

Special thanks to @Radnen for (indirectly) giving me the idea - Link.js was touted as a replacement for writing repetitive for loops, which got me to thinking... what if I just compile the query to an actual for loop...

This is really incredible that I was able to get so close to native loop performance and is a big win for code readability.  Query chains remain understandable even with 10+ query operators chained together, but throw together a couple filters and mappings plus a sort (or two!) and the set of for loops you need to write to match it can get pretty gnarly.  Lodash is proof people are willing to sacrifice a great deal of performance to get more readable code (see benchmark results above), even in tight loops where it matters most, but it's even better if you don't have to. :smiley_cat:
82
Engine Development / Re: miniSphere 5.3b1 (stable: 5.2.13)
Last post by Fat Cerberus -
Starting in miniSphere 5.3, from() will be built into the Core API without the need to import the "from" module.  Like @Radnen 's Link.js library that came before it, from() queries are often incredibly useful in battle engines, and now I've written some code in the engine to compile these queries directly to JS for super-fast performance.

Code: (JavaScript) [Select]
let dinnerAmount = from(worldPopulation)
    .where(it => pig.isHungryFor(it))
    .besides(it => pig.devour(it))
    .reduce((a, it) => a + it.weight, 0);
SSj.log(`the pig just gained ${dinnerAmount} lbs.`);
83
Spherical News / Re: Forum updates thread
Last post by Rukiri -
I'm not the most active guy around here, but this is going to blind a few people in the morning :P
84
Game Development / Re: The Screenshot Thread
Last post by Eggbertx -
I haven't mentioned it until now since it's a very low priority project that may never even get finished, but I figured I may as well post a screenshot for interest. The blocks that comprise each letter are actually one image copied to multiple locations as determined by a per-character array of JS object literals with x/y coordinates.
85
Editor Development / Re: QtSphere IDE 0.6.0
Last post by Eggbertx -
And now the map editor is (slowly) starting to look like a map editor! Thanks @Fat Cerberus for helping with the weird tileset quirk.
86
Editor Development / Re: QtSphere IDE 0.2.5
Last post by Eggbertx -
This thread is in desperate need of an update since QtSphere IDE is still in development even though it isn't my main project. I'm currently working on the map editor, and even though it's still far from completion, it fully loads map files, and this is what the editor itself looks like so far:

It might end up being able to display the first frame of each entity as a preview, rather than a generic icon. I haven't decided yet.
87
Engine Development / Re: Oozaru: Sphere for the Web
Last post by Fat Cerberus -
I finally got SoundStream working today!  It took me forever to get it right and in the process I had to learn how to do sample rate conversion, but now Oozaru can run the sphere-mp3 demo (with a couple small code tweaks to accommodate for the lack of synchronous file loading).

Next I'm going to see about getting this thing to work in other browsers besides just Chrome.  This isn't the late 90s/early 2000s after all. :P
88
Engine Development / Re: Oozaru: Sphere for the Web
Last post by Fat Cerberus -
What kind of functions do you have in mind?
89
Engine Development / Re: Oozaru: Sphere for the Web
Last post by Eggbertx -
I wonder if it would be possible to add Oozaru-only (for now) API functions and objects to make games for mobile browsers.
90
Engine Development / Re: Oozaru: Sphere for the Web
Last post by Fat Cerberus -
It's funny you say that because a big part of why I shelved Oozaru for a while is that, a year ago, the Web technology wasn't quite there yet.  WebGL was a thing (which I didn't realize at the time--Canvas2D is an awful API to use for game development), but the missing piece, ES module support, wasn't actually a feasible option since browser makers were only just starting to implement it.  I would have had to use a require() shim, which didn't seem ideal since you don't really want to be blocking your code while loading things on the web.  The user will hate you for it, and most likely so will the browser.  And I was just starting to push use of ES modules for Sphere at that point too, so forcing require() for Oozaru felt like a step backwards.

But now that stuff I need is finally widely available, Oozaru will finally see the light of day!  Or, well, the light of a full moon, as the case may be...