A blog about game development and procedural content generation.

First time here? Try the graphical archive of all posts.

Feel free to email me or Tumblr ask | FAQ | Also on Twitter @bennettor

...querying twitch.tv... http://www.twitch.tv/timetocode

v1 parallax, rotating nebula, 23 seconds

Both the stars and clouds are procedurally generated.

The star effect comes from 5 layers of the same image moving at different speeds and at slightly different zooms.

The nebula is pair of organic noise clouds rotating in opposite directions.

Both of these things were made by tweaking the code and color themes from the volcanic island generator. I plan to improve both of these techniques and make a few environments for the space game.

Here’s another nebula from the generator, and then some buggy asteroids. I wanted to take a picture before it gets fixed and the placeholder art is gone.

I applied some faux physics to the asteroids. They have elastic collisions a bit like billiards balls, no gravity, and some strange rules that keep them grouped into an asteroid belt. They’re pretty dangerous overall. The asteroids basically knock each other around until they drift out of the belt, and then some magical force will pull them back towards the belt. If the returning asteroid doesn’t happen to hit another asteroid, it’ll usually pierce through the belt and shoot out the other side, and the pattern will repeat, which looks a little like a sin curve following the circumference of a circle. Most of the time a returning asteroid will just hit another asteroid, and everything will ricochet around for a bit. Overall while the physics is crazy, I think this movement is pretty fun.

The asteroid screen capture is a section of the belt which I call “physics hell.” It is a recent development, due to an amusing math error which eventually causes the majority of the asteroids to gather together. My fake inward/outward belt forces pin the asteroids together and their perfect elasticity basically keeps them colliding forever (looks like vibration in-game).

I’ve also had good luck with parallaxing, but that’ll take a video or gif to show. Reusing a single background image of stars at different magnifications and then moving the star layers at different speeds produces some nice effects.  When a nebula cloud is in the topmost layer it looks like the ship is going to fly into a cloud — something which may end up as a special environment later on.

There have also been some AI developments, but nothing too special. I’ll upload another playable version when the AI and art are a bit further along.

The netcode, which at this point is still destined for both this game and the previous rpg/survival/sandbox thingy, is getting more and more stable as well. I’ve got all of the basic elements (interpolation, prediction, lag compensation of collisions) but there are going to be some compromises when it comes to players with low ping witnessing players with high ping in a PvE scenario. So far I’ve designed all things in favor of having responsive controls and having the player’s own experience match very closely between client and server. If an asteroid looks like it missed the player on their own computer, then it really did miss the player, regardless of latency. This makes piloting much easier and intuitive, with none of the past-era net code where you had to aim or dodge relative to your own latency. However, this emphasis on the player’s own experience is going to come at the cost of high and low latency players having identical experiences of eachother. Their own ships will behave as expected, possibly even up to 500ms of sustained lag, but I doubt a player with a good connection will be able to tell if a player with a bad connection got grazed by a fast asteroid or dodged it successfully. I still think this is the right place in the simulation to make the compromise, and it does only apply in bad lag.

SpaceGame tech demo #2

http://spacegame.timetocode.com/ Chrome/FF (has sound! possibly loud sound! adjust volume preemptively!) May work in newer IE/Safari with no sound.

This tech demo is destined to crash, but I’ve got a service that hopefully restarts it periodically. I suggest refreshing the page (give it 5 seconds) if anything freezes or if you want to respawn. It all barely works as is, so its possible that it won’t run on your browser/OS/connection yet. It’ll be more robust in future versions. It is also intended to be played in fullscreen (as in F11 true fullscreen or w/e)

Everything looks quite similar to the previous version, but everything is a bit different.

  • New controls: W / S for thrust and A / D for turning
  • There’s some faux friction to make piloting much easier
  • Asteroids now collide with one another, and follow an elastic collision physics model
  • Asteroids can merge together
  • Ship has an animated thruster
  • Regenerating way-too-good shield (can crash into a planet and survive if shield is full)
  • Some sounds, mostly annoying placeholders
  • A few types of screen shake effects for asteroids being mitigated by shields or directly hitting the hull
  • Ghosted version of the ship shows client side prediction (the solid white ship is the predicted version, the ghosty is the server state). The more of the ghost you can see, the higher your ping to this particular server. 0-50 ping : just a small edge of the ghost ship, 250 ping: about half a ship length, 500 ping: almost the entire ship
  • Asteroids and other players are smoothed/interpolated
  • No lag compensation for shots or collisions yet (this is next!)
  • All the asteroids are destroyable, but the giant ones have A LOT of hp, proportional to their volume if they were converted into spheres
  • The ship has been destroyed when all that is left is the ghostly version, refresh the page to respawn

There still isn’t really anything to do other than fly around, shoot a couple planetoids, and then crash.

Space game demo

It’s just a very quick tech demo. You appear as a little ship and can shoot asteroids (that’s all there is to do). It happens to be multiplayer, in the unlikely event that someone else connects at the same time. 

Play it here: http://spacegame.timetocode.com/

Hopefully it works in your browser. I’ve only tested chrome, ff, and the latest ie on win7.

Move with WASD and left click to shoot. Reload the page (CTRL-R?) to respawn if you die or somehow get lost.

There isn’t much in the way of feedback for taking damage or dying. Damage will just reduce shields or hull, and grant a temporary half second of invulnerability.  Dying… well… the ship just disappears. It can no longer move, but it can still shoot (this is when its time to reload the page).

If you’re looking for a little bit of extra trouble, make your way to the top left and aim for the the largest of the asteroids. The asteroid spawner will go a bit crazy. All the asteroids divide into smaller and smaller rocks and decay away eventually. One large asteroid will always spawn in the top left, seeding the map with rocks — if you keep destroying it, it’ll keep respawning and spamming rocks.

Now that I’ve solved most of the logistical issues, I get to work on the actual game! I’ll repost the link and updates as I add to the project.

30 seconds vid of the space game (no sound, sorry), mixture of placeholder art and the nifty procedural cosmic background generator

It’s all very raw/early, but the movement is about how I imagined it. Visually, probably only the movement and background will live on. In a future iteration the ship is going to grow a pivoting cannon and some sort of animated engine+afterburner stuff. I’m also going to experiment with making multiple gaseous background and star layers, with some parallaxing.

Here’s the overall game idea: players engage in a ~20-45 minute (if they’re good) roguelike space-themed arcade game culminating in a boss fight. The game requires a group of players to beat, and probably quite a few deaths to even figure out how to play. Nearby players will be marked on the HUD, encouraging grouping.

The destruction of the player’s ship is permanent, but the player may respawn in a new level one ship indefinitely. There will be roughly ~10 exp levels to gain for the player’s ship, each increases the strength of the ship. If I’m feeling ambitious there will be a few types of ships. The early levels are best spent destroying asteroids (which is simply practical, given that they will destroy your ship). Middle levels are spent fighting hostile ships, and well, more asteroids.

The main boss lives in the center of each map. The map is procedurally generated w/ nifty space backgrounds, asteroids, and hopefully some hostile AI ships. Difficulty increases as players fly towards the center of the map, so it makes sense to gain a level or two periodically before travelling further inwards.

(maybe) The boss produces large asteroids which travel outwards from the center and periodically split into smaller asteroids. Each time the asteroids split, they’re reduced in size and gain a bit of a random direction. The very same asteroids that populate the newbie zone are in fact descendants of the asteroids spawned by the boss  (we’ll see if this is really feasible, I’ve only done a few small tests of this model). While asteroid movement may seem mostly random, players can deduce where the boss is by noting the general source direction of the majority of the asteroids.

I’ll try and put some sort of playable version up soon.  It’ll probably just be infinite lives + infinite asteroids initially. I’ve got a few server-crashing bugs to find first. I also have yet to make whatever types of lag compensation are appropriate for this type of game. I’m guessing it’ll be mostly similar to prior work, but there may be some complexity to do w/ how fast the ships are vs all the potential asteroid collisions. We’ll see.

woo developer art (testing pixi.js + netengine)

woo developer art (testing pixi.js + netengine)

procedurally generated outerspace background for a new game idea (I’m just gonna test out my net engine w/ an arcade-style space shooter)

procedurally generated outerspace background for a new game idea (I’m just gonna test out my net engine w/ an arcade-style space shooter)

NetEngine source code

I hit a reasonable stopping point as I rewrote the core of my game’s network code, so I bundled it up and put it on github. This was about as much as I could share without publishing a full engine or game (neither of which yet exist).


To summarize, this NetEngine allows game entities to be defined and it will automagically handle the netcode itself. In a way it’s a prototyping aid for multiplayer game programming. It also demonstrates running the same code on client and server, as well as a mixin pattern for separating special pieces of code to run on only the server or client. This separation scenario is important for keeping some implementation secrets. The whole thing is a bit of a mess imo, but I’ve had several requests for code samples, so here, have an entire functional demo!!

In the demo, the player is a red circle and a black box attached to the mouse cursor. Move the cursor around to move the player. You’ll see other circles (NPCs) moving and bouncing around. The black square represents the view of your character — think of it as being an analogy for your entire screen which only sees a small section of a much larger map. The NPCs are living out their lives, and exist regardless of whether they can be seen or not. As the player moves around new NPCs will enter the player’s field of vision, and other NPCs will drop out. The NPCs also have some strange behavior: in addition to moving, they undulate in size, and have a 1% chance of changing color every game tick. The goal of the netcode is to track all of the above changes, which are divided into 3 main categories:

  1. a full update: player encounters an NPC and needs to know everything
  2. a partial update: an NPC already in view continues to move (or undulate, or change color) and the player needs to know only about these changes
  3. an subscribe: an NPC leaves the player’s view, and the player is told to forget about it

Multiple players can connect and will be able to see each other as well as all the NPCs.

see: http://timetocode.tumblr.com/post/93970694121/volcanic-map-generation-step-by-step for images and descriptions that closely follow the code