Skip to main content

Solar Sailor: semi-playable

More progress! Solar Sailor is now kinda- sorta- playable. You can't win or lose yet, but it does have all this goodness:
  • There are gates that you have to pass through.
  • There's a direction line showing you which gate you have to pass through next.
  • The NPC racers now have some basic AI and will actually try to fly through the gates instead of just drifting serenely and hoping for the best.

You can try it out yourself here!

If you can't be bothered to try it out, this is what it's looking like now:

If you do try it, I'd really appreciate any feedback - especially bug reports!


  1. Cool and once you get used to the momentum-y controls it's really good fun :-)

    I seem to lose a lot within a second or two of starting (pretty sure it's not 'coz I'm just really terrible). It may be to do with the next point.

    When I start a second (or third or so on) game, me and the NPC players start from our finishing positions of the previous game and aren't randomly distributed.

    Also, if I enable postprocessing, it just goes black.

  2. Thanks Stephen! I've just posted a new version which resets the game properly (mostly... see below) when you start over. Before it wasn't resetting anything.

    It doesn't reset the position of the racers yet because I'm just about to start designing a proper map and I'll be putting in fixed start positions for each player.

    I'll get the postprocessing fixed too... if I have time. Less than 6 hours to go. Gulp!


Post a Comment

Popular posts from this blog

How to outperform std::vector in 1 easy step

Everyone who's familiar with C++ knows that you should avoid resizing a std::vector inside a loop wherever possible. The reasoning's pretty obvious: the memory allocated for the vector doubles in size each time it fills up and that doubling is a costly operation. Have you ever wondered why it's so costly though?

It's tempting to assume that because implementations of the STL have been around for so long that they must be pretty efficient. It turns out that's a bad assumption because the problem, in this case, is the standard itself: specifically, the allocator interface.

The allocator interface provides two methods that obtain and release memory:

allocate allocates uninitialized storage
(public member function)deallocate deallocates storage
(public member function)

(taken from this page).

What's missing is away of growing an existing memory allocation in place. In C this is provided by the realloc function, but there's no equivalent in the std::allocator interfa…

Octree node identifiers

Let's say we have an octree and we want to come up with a unique integer that can identify any node in the tree - including interior nodes, not just leaf nodes. Let's also say that the octree has a maximum depth no greater than 9 levels, i.e. the level containing the leaf nodes divides space into 512 parts along each axis.

The encoding The morton encoding of a node's i,j,k coordinates within the tree lets us identify a node uniquely if we already know it's depth. Without knowing the depth, there's no way to differentiate between cells at different depths in the tree. For example, the node at depth 1 with coords 0,0,0 has exactly the same morton encoding as the node at depth 2 with coords 0,0,0.

We can fix this by appending the depth of the node to the morton encoding. If we have an octree of depth 9 then we need up to 27 bits for the morton encoding and 4 bits for the depth, which still fits nicely into a 32-bit integer. We'll shift the morton code up so that i…

Triangle bounding boxes in a single byte

Just thought of a way to store the bounding box for a single triangle in only one byte. It's not really practical or something you'd ever really want to use, but what the hell.

Assume we have some kind of indexed mesh structure with a list of vertex positions and a list of triangle indices:

  struct Mesh {
    std::vector<vec3> verts;
    std::vector<uvec3> triangles;

We can find the bounding box of a triangle by taking the min and max of all three vertices:

  vec3 Mesh::lowerBound(uint32_t tri) const {
    vec3 v0 = verts[triangles[tri].x];
    vec3 v1 = verts[triangles[tri].y];
    vec3 v2 = verts[triangles[tri].z];
    return min(min(v0, v1), v2);

  vec3 Mesh::upperBound(uint32_t tri) const {
    vec3 v0 = verts[triangles[tri].x];
    vec3 v1 = verts[triangles[tri].y];
    vec3 v2 = verts[triangles[tri].z];
    return max(max(v0, v1), v2);

This is nice and simple and probably way better than what I'm about to suggest.

We can store a byte that tells us which of …