Monthly Archives: October 2013

Update on One

its_not_all_impactI’ve been very distracted over the last few days and my sleep schedule is getting pretty messed up thanks to a game called Academagia which a friend pointed out to me after seeing Travelogue, but at least we were pretty productive last weekend before I got my hands on it. Here’s the highlights:

Jeff and I managed to put a lot of new objects into One. There are now unstable planetessimals that detonate, sending you flying across space (at a significant portion of the speed of light before we tweaked things down a bit), asteroids that change course erratically due to releasing jets of vapor from cracks in their surface, and dense, spikey asteroids that are particularly dangerous and can damage you.

There’s also a whole bunch of 3D ‘medals’ for the achievements now rather than my little 2D placeholder icons, which slide into place, rotate, zoom, etc when you hover over them in the UI. No, they’re not all impact achievements, but thats just the one icon we have for now. Among the ones on there are achievements for breaking multiple objects in a row, going fast, growing quickly, going way too fast, eating stuff every couple seconds for a long time, and changing direction shortly before slamming into something.

One gameplay thing we’re playing with right now is a ‘density’ system, where when you eat denser things you can build up density and find it easier to retain more mass from the things you collide with, as well as making it easier to break objects and draw them in with your gravity. Of course if you then eat a lot of low density stuff like dust clouds, you lose those advantages, so you have to balance your rate of growth with managing your density.

Next on the list of big things that need to be done is audio. This is a big problem because of the various levels of support for HTML5 audio across the different platforms (not to mention WebGL, but there’s not much helping that). Currently it looks like our solution will work on desktop and in Node-Webkit just fine, but its going to have some problems on Android due to the fact that it seems like you can only play one channel of audio at a time with HTML5 on Android, so its sort of ‘sound effects or music, not both’ which really sucks. I’m looking into Web Audio as an alternative, but early investigations suggest that it will have the same problems.

Things are coming along nicely with One With Everything (aka ‘the space game’). We’ve got a few more objects in, and added health and the necessary code to handle achievements and upgrades. The basic idea is that there are ‘dynamic achievements’ that give you points you can use to activate upgrades – these are things you can always in principle do better: what is your best time, biggest size, fastest speed, etc. Then there are ‘static achievements’ such as ‘break 3 objects in a row’ or ‘eat a gas giant’ that unlock new upgrades when you get them. Currently the only upgrades are the basic speed/health/etc type, and a ‘identify friend from foe’ system that color-codes objects based on whether or not you can absorb them or if they’ll damage you.

I’ve also made a little video of the current gameplay to share, check it out!

Shader retrofits

Work continues on the space game. It’s now possible to play from about 1 meter in size to somewhere around 1000km and continue to encounter new objects to absorb – planetesimals, moons, gas giants, etc.

Part of doing this has involved a somewhat tedious adaptation of Three.JS’s generic phong material. The problem is basically that you can’t easily ‘add an effect on top’  for the material, you almost have to reimplement the entire shader. I didn’t have to go quite that far, but I did have to print the shader code into the console, copy-paste it into my code, and tweak it from there. The entire thing is something like 600 lines long, and has a bunch of tricksy things you have to do to get it to work (setting defines on the material to enable features that are normally automatically configured by the WebGLRenderer).

The entire experience has made me want to make something like Blender’s node-based materials editor for shaders. If you want a glow on top of a phong material? No problem. Add an electron microscope effect too if you like, and a cartoon shader on top of the whole thing. It’d be a pretty involved project, so its not going to happen for the space game, but it seems a natural tool to have.

Anyhow, the reason for rebuilding Three.JS’s shader? We wanted to add ‘rim lights’ around objects. This effect basically just lights the material when the surface normal is near-perpendicular to the view vector (something like (1-(normal dot view))^4). It turns out that putting this on the ice shard models turns them from looking like kind of purple rocks into really looking like ice. I think its going to do wonders for planetary rims as well.

It was a bit of a slow week for game development for me with having to get some papers polished up for my physics day job, but this weekend Jeff and I have been working on the space game (now tentatively titled ‘One With Everything’). Mostly the focus has been, how do we do ‘stage transitions’ between scales that are smooth?

The game is supposed to cover about 15 orders of magnitude in scale when all is said and done. Thats enough that floating point problems could raise their ugly head. We could just cut things off every 3-4 orders of magnitude and make a new stage, but that feels artificial and abrupt. So instead the idea is to ‘curate’ position and scale every so often, re-centering the game on the player and rescaling everything to keep it in a numerically stable zone. That should take care of things up until about the planetary scale.

The problem at the planetary scale is, we want to have the player start zoomed in among a debris field and then eventually get big enough that they can start noticing their ‘orbit’. Once the player is big enough, they can either reach escape velocity (in which case the game zooms out, everything vanishes, and then it zooms in placing them in orbit around a different randomly generated object appropriate to their size) or absorb the thing they’re orbitting around, in which case they start to orbit around a new object one ‘tier’ higher (absorb a moon, you’re now orbiting a planet; absorb a planet, you’re now orbiting the sun, etc).

That means spawning an object that might be 100-10000 times bigger than the player in order to have it there (so if you go inwards in the orbit far enough you encounter it and get gobbled up). For example, in the current demo when the player is 10 meters in size, we place a planetoid 3km away that is itself maybe 1km in radius. However there’s a noticeable amount of glitching when you’re close to the planetoid – objects tend to graphically jump around on the sub-meter scale during their orbits, like they’re suffering noticeable round-off errors. The actual velocities involved aren’t that large and the orbits appear stable, so I don’t think its the numerical integrator, and it looks like the objects actually do change position when they ‘jump’, so its not just lag bursts from generating new chunks. At this point I’m not really sure what it is.

The game is playable with it though, so I’m going to give it a rest and move on to another element of the game – the progression system. The way One With Everything is set up is that you have a certain amount of time to absorb things and grow before everything disintegrates around you. This time is going to be fairly easy to maintain at the early levels, but it will get very rough at later levels. However, as you do crazy things like bounce off of objects at half the speed of light, do tight gravity assists around heavy objects, etc, you unlock achievements. These aren’t just for show – they’re the ‘currency’ for the game’s upgrade shop. Every (couple) achievements, you can buy an upgrade to your speed, maneuverability, ability to break objects, etc. You can then choose to leave these upgrades on and get their benefits, or turn them off to get a bonus to your score multiplier.

The idea is that as you play the game, yes you have to repeat the early stages, but at the same time there will still be new things you can earn during those early stages so you aren’t just retreading old ground. Hopefully that will make for a fresh and interesting take on this kind of repeated-play/progression game.