Monday, 19 September 2011

And here I was thinking of coding in Javascript for the next game...

One day a student came to Moon and said, 'I understand how to avoid using BIGNUMs! We will simply use floats!' Moon struck the student with a stick. The student was enlightened.

7 comments:

Arathalion said...

Yeah, I tried a javascript roguelike proof of concept... http://www.arathalion.com/angband/
It should still run, slowly, in a limited capacity, depending upon browser.

Simon said...

Hey, it runs perfectly smooth for me using Chrome.

It's handy that you can reach infinite negative hp without dying, since all the monsters on the level swarm you right away. :)

Nolithius said...

The ECMA spec defines it as such. AS3 adds ints and uints, which are treated as the traditional ECMA/JavaScript Number for typing purposes, but are generally much faster.

In any case, JavaScript isn't inadequate for a roguelike because of its number handling, but because it's fairly slow. Chrome renders JavaScript fairly quickly, but other browsers will give you trouble with relatively intensive tasks like writing to the canvas, or realtime raytracing for LOS/lighting. On the other hand, overcoming these limitations present an interesting challenge you might have fun with; it all depends on what you're looking to get out of the experience.

There's something to be said for pioneering the effort: even though I wasn't the first to do a Flash-based roguelike, I tried a few things that I don't think anyone had done before (in Flash, specifically). I get a lot of hits to Dance of Death with the Google keywords "flash roguelike", and I bet "html5 roguelike" would benefit from such an influx as well.

Best of luck!

Ebyan "Nolithius" Alvarez-Buylla
http://www.nolithius.com

Ondrej Zara said...

You might be interested in my JS roguelike: http://code.google.com/p/js-like/ :)

Demo installation: http://ondras.zarovi.cz/js-like/

QBRADQ said...

JavaScript does in fact have ints, you just have to be aware that it does not have integer division and modulus.

var a = 5; // This is an int, value 5
a = 5 / 2; // Now it's a float, value 2.5
a = a | 0; // Now it's an int again, value 2

While we're at it, here's my too-ambitious JavaScript roguelike: http://code.google.com/p/shambletown/

And my current project, a more traditional roguelike in JS: http://code.google.com/p/dhack/

Both have demos linked to from the main page, but are not yet in the "simple game" stage.

Andrew Doull said...

Excuse my ignorance, but what does the | operator do?

Andrew Doull said...

(Spends more than 10 seconds looking).

Ah. Bitwise or - sneaky taking advantage of the truncate operation. I use Math.floor() which I'm guessing is slower.