JS13K

Posted by Astryl on Aug. 19, 2016, 3:19 p.m.

Nopykon's comment in Jani's Goofy4Art blog alerted me to the existence of this.

Why didn't I know this was a thing sooner?

So I'm going to start a JS13K thread. Post your development progress, tricks/workarounds and tips.

What is JS13K?

A JavaScript coding competition where the goal is to create a game based on a theme.

The twist: The final (zipped) game needs to fit within 13KB, and may not load external resources/libraries: It needs to work offline and standalone.

Of course, this severe limitation inspires creative workarounds, and you'll tend to dig deeper into the language in order to understand how to get things done.

My own goal with this is to use it as an excuse to actually learn JavaScript properly instead of putting it off and stumbling through.

Go visit the JS13K site here: http://js13kgames.com/

You should join, even if you don't plan on completing something. The fun is in the challenge.

Comments

Nopykon 8 years, 4 months ago

TIL:

-WebAudio is unstable as fuck in firefox.

-No matter how many hours you spend on error checking every single loop and

variable, unless you have 'web-audio' tab selected in the debug window (when debugging), firefox will unreliably crash, and sometimes even then; for something that worked immediately with absolutely no flaws in opera.

-Firefox is antichrist and hitler.

-Firefox is worse than IE5.

EDIT: Obviously it's not that bad.

Mairu 8 years, 3 months ago

Does anyone have recommendations for measuring JavaScript performance?

Nopykon 8 years, 3 months ago

@^ Firefox, has a built in js-profiler. With flamechars, framerate timeline and all, if that's what you're after. The other browsers have similar things. But maybe there are better ways, idk.

Sadly, jsperf is down atm. :/

For me, GC will drop framerate with regular intevals. I blame putImageData for leaking large chunks of memory every frame, forcing GC on. But not in Opera, which seem to have a not completely retarded implementation of that method. Opera is the best at running js in general from what I can tell.

Nopykon 8 years, 3 months ago

I seem to hit 60fps most of the time in firefox now, with my 1,4Ghz laptop, but I'm not sure what I did. Firefox may have gone into crazy update weirdass mode before. After letting it rest for a while, the framerate was gut. Still…

If anyone has any good links on how to optimize JavaScript, please share. And, I'm talking about real-time game code, 5000 times per frame stuff, not, "cache user data instead of using DOM".

I found this, which was pretty good, but not enough: https://github.com/petkaantonov/bluebird/wiki/Optimization-killers

Oh, this one is good: https://developers.google.com/web/updates/2012/03/Optimizing-JavaScript?hl=en EDIT: nope, pretty shit unless you're an absolute beginner.

Thanks

Astryl 8 years, 3 months ago

I just apply generalized rule-of-thumb optimizations: Save as many internal cycles as possible, and code aggressively to achieve that if necessary (take risks and do less error checking within the game loop).

Things like memory allocations, etc, all come into play.

Here's one of the articles I have saved that might help: http://www.gamedev.net/page/resources/_/technical/game-programming/writing-fast-javascript-for-games-interactive-applications-r3516

Nopykon 8 years, 3 months ago

There are some good details and tips on that page.

As for memory, nothing during the render / game cycle creates a new object. It only operates on pre-allocated memory, perhaps a few holes. :) This sort of thing , I learned in Java ~2010.

Here's all the allocations during a minute of my game running, at 60fps (opera). The blue bar at the end, is me hitting the keyboard, an event is created.

I think I'm overdoing it even. Honestly, I may have been chasing a ghost after all. It seem to be running fine in Firefox as well now. I'm going to try a reinstall of firefox and se how it fares.

Reading that page, naybe Spindermonkeys JIT compiler was slow to detect the hot stuff?

Ah, heck, IDK. Maybe I'm missing some things. Just learned from that page, doubles are apparently leaked if not intifyed when stored , (unless dst is already a double obj, I'm guessing). Dammit, "everything is a double" my ass. Everything is a potential pointer to a double. Js, is designed to sell faster computers, not to be a good language.

Oh, and btw:

Perhaps, a bit more interesting. :)

another day:

Did this, rigorously, var globalVec4=[0.,0.,0.,0.]; instead of just [0,0,0,0], (or just [] in a few place); Seem to have helped out with early slowdown.

I also tried using Float32Array(length) for all vectors, matrices and vertices, That was a lot slower in in FF. (Looking at the framerate, 60 -> 30-40 ). No noticable difference in Chrome, not sure if faster or slower.

Astryl 8 years, 3 months ago

My game's still coming along. Working on the actual game progression now:

I distilled my original idea into a doable 'multiple choice adventure game' with a fancy starfield and warp effect.

Jani_Nykanen 8 years, 3 months ago

@Mega

By the way, didn't you once say that you have no time for your personal projects, but still you are writing a game in JavaScript that is supposed to fit in 13 kilobytes…? Or is this the good ol' "I don't have time but I'm doing it nonetheless"?

Astryl 8 years, 3 months ago

Quote:
Or is this the good ol' "I don't have time but I'm doing it nonetheless"?
This. And I've also been stuck without work for a bit because of medical issues (Again).

Nopykon 8 years, 3 months ago

Not much work done over the last week. Annoyingly, I got tasked with designing folder for print, with a deadline EXACTLY the 13th. Short notice and bad timing. The design itself could be competed quickly, but there are always a million changes back and forward before everyone is happy. '<' Hopefully, I'll have enough spare time to see this through anyhow.

The little I've done, mainly gameplay and physics. A sphere that walks around and shoot rays. Got pointer-lock to work, so now there is mouse look. I tried bruting the physics, but I quickly got slowdowns. I do need half-decent collision (for the juice). And, balls bouncing around is a big part of this. I found myself implementing a bsp generator, and seriously thinking about doing sweep and prune for all the entities, before I stopped myself.

-There's not enough space-time!

I went withm a simple grid map thingy intead. A 2D array of lists with references to whatever polygons are inside whatever grid cell. Seem to have cut down the worst lag. The limitations have steered me away from wasting a lot of time. Hurrah!

If I "export" the project now, I'm down to 6k. But there are lots of code ripped away because it isn't used atm, Code that will be used in the end, so I suspect the true number is twice of that.

To be continued —->