javaScript Framework most important features?
Hey all,
I’m currently writing a 2d framework in javascript which should handle most of the repetetive stuff, that comes up.
I was wondering what would you regard as the most importantor most helpful feature?
Also I’m kind of obsessed with physics, but there is already a pretty good solution in the form of box2djs. Whats your suggestion? Should I implement my own physics or roll with box2d?
Thanks
The most important thing for me with libraries is APIs.
I don’t have much experience with box2djs, but I’d be interested in learning what you find out.
The major problems that I’ve experienced when developing JS libs are the syntax of JS and the missing of common core libraries. Here’s my corelibs project that I now use for all my JS development needs: https://github.com/STRd6/corelib . I also make use of CoffeeScript to fix the syntax and reduce common errors. Additionally if you’re into test driven development I’ve recently implemented an online code editor with built in testing: http://www.youtube.com/watch?v=JFT0Lk6iz1c
I agree with you API is key, I decided against extending core objects in my library as it really can mess up compability with other libraries, I dont’t find the js syntax to be a problem really, you just have to leave out the bad parts. I looked at coffee script but couldn’t find a good editor at that time.
I really like what you’re doing with the editor and also I am a big fan of the pixie pixel editor.
How do you handle multiplayer in ‘Shadow Laser Deathmatch Arena’ BTW?
Well.
Box2D being integrated with JavaScript.
How do you fit Box2D into JavaScript without creating odd compatibility issues with browsers or *gulp* re-writing Box2D in JS?
Oh, oops. Re-read your post. You’ve already got that one covered. My bad. ^_^;
Um… I would say an entity system of some kind with support for static terrain would be a good starting place.
Parallel processing with web workers would be awesome
There’s also the possibility of using WebGL to accelerate physics calculations
if you’re going to do image loading, i recommend an image pre-loader of some sort (particularly if using canvas). some kind of wrapper on canvas drawing is useful.
If you’re doing audio, you’ll want a sound loader, like the image loader and some wrappers on html5 audio tags that allow you to do multi channel audio
getting keyboard and mouse input centralized is also a plus depending on what you’re doing.
If you want, you can borrow any of my post-compo javascript engine code. Harvest it from:
http://bsmith555.appspot.com/10MinuteGalaxy.html
the sound only works on chrome so far, but it might just be an audio format issue with firefox. it’s also not really i.e. compatible, but that’s mostly just for not having cleaned up the event handling.
The html 5 canvas wrapper is maybe a bit heavier than necessary, but it gets the job done.
Let me know if you end up using any of it, and I’m always looking for feedback on the code.
how embarassing. apparently I broke that copy of it (I’m still cleaning up the code and working on it). a stable version is here:
http://www.stonetronix.com/brad/10MinuteGalaxyLatest/10MinuteGalaxy
Thanks for the comments so far.
@machinas
I have Image preloading and input nailed, sound preloading works good on firefox and chrome, but has no multichannel support yet. The code is nice but i didnt find any sound
@hdon
for rendering webgl is definately faster.
why would i want parrallel processes?
WebGl for physics sounds really tempting
@mrDude
An entity system is in the works but I’n not that happy with it yet.
and box2d is cool but a little too much for many games.
@Balooga03: off the top of my head, parallel processing could be used to run A* pathfinding w/out blocking the game loop.
Ah, you can’t find the audio because the version on the other page is quite a bit older. I’ve fixed the original link above (http://bsmith555.appspot.com/10MinuteGalaxy.html) and you can get the current version there.
The audio engine has multi channel support and does audio loading, but it’s not able to report when the audio is actually finished (the result is that trying to play an unloaded sound just won’t do anything). It’s not as simple as listening to onload or oncontentload. my experimentation seems to suggest that none of those work. I was poking around and it seems this is because audio tags support streaming, so there’s some other way of figuring out if they’ve loaded. Either way, it’s a solid start. if you end up building it up / fixing any issues, let me know.
Cool! I’ll look at the Multi Channel support, need to tick that off on my list.
My research has brought me to using something like this for loading:
sound.addEventListener(‘canplaythrough’, callbackfunction, true);
hope that helps.
cool. i’ll check it out if I get any time to focus on developing the libs before the competition.
The library works, even without load completion detection, it’s just that you might not get sound for a bit until things come in, or the sound’s first play may be delayed. for a LD entry, that’s probably ok
i got 128 / 240 in audio category last dare without doing any audio, ahaha, so I can only imagine having blips and bloops would do even better!