Friday, June 13, 2014

Programming Tips: Comfortably Enum

After reading Casey Muratori's great articles on programming I've been inspired to post a few things on how I program.  In the last article he talked about enums, something I didn't really start using until after Gish, which can be very useful.  However, it can be unwieldy if you try to enumerate too many types, like for example a list of textures.  Say I have 4 player types, and 4 vehicle types, I could do something like this:

enum vehiclelist

enum texturelist

Then to bind the texture for the plane I would use:


The problem I ran into was if I wanted to add more vehicle types, or support more players, I would have to change the texturelist enum.  Also the enum would start to get very long, and while there's ways to shorten it I still felt that it was getting messy.

What I came up with instead is using a simple struct that's enumerated at run-time.  So the texture enum looks like this:

  int loc;
  int player[MAXNUMOFPLAYERS];
  int vehicle[VEHICLE_END];
  } texturelist;

void setuptexturelist(void)
  int count;

  for (count=0;count<MAXNUMOFPLAYERS;count++)
  for (count=0;count<VEHICLE_END;count++)

And to bind the texture:


The advantage here is I can add or remove vehicle types without having to change the texture enum, and I can have all types of textures without having a giant enum.  The only disadvantage is you have to call the setuptexturelist function at the beginning of the program.  This is actually the cause of the sound bug in Sub Rosa, where the car crashing into something plays the gunshot sound.  I wasn't calling the setupsoundlist function in the dedicated server, so all the of the soundlist is set to 0, which is the gunshot sound.  So you do have to remember to call the functions to enumerate even if the dedicated server isn't playing any sounds or displaying any textures.

And for making it through that here's a video of boxman falling over a wall:


Tuesday, April 22, 2014

Humble Weekly Sale

The new version of the Cryptic Sea EP is now available in the Humble Weekly Sale, you can get it and some other awesome games for less than whatever you want.  There's a bunch of new features, including singleplayer mode for Skate or Don't!, and 5 new tracks and cars for Touring Car Legend.  If you already bought the game with the Humble widget you can download the new version from the Humble webpage.

I've been making good progress on the other games also, should have some updates on those soon.

Thursday, February 20, 2014

Advice for Games Journalists

A lot of games journalists ask me how to get my games on their website, so I thought I would write a few tips on finding interesting games to write about:

1.  Look for games

Don't just sit there waiting for a developer to email you; go on forums, check Youtube/Twitter, see what people are playing.  Otherwise you're missing out on a lot of interesting games and only covering the developers who spend a lot of time writing emails.

2.  Do some research

When you do see a game on Reddit or another games website, don't just paraphrase what someone else said.  Try playing it or email the developer for a build, and then form your own opinion.  Don't be afraid to go against popular opinion!

3.  Be persistent

If I don't write you back about my game it might just be because I'm busy making it, try again or contact me on Twitter.

4. Don't fall for it

Just because Sniper Elite 3 made a video explaining their "X-ray kill-cam" doesn't mean you have to post about it.  Just because a mass murderer requests a PS3 in prison doesn't mean you have to post about it.  I know it's easier just to write a couple sentences and add a link to another website, but if you want to have good content you're going to need to put some more effort into it.  The first 5 seconds of viewing your website are the most important, if I see things like that I'm going to close the browser tab.

Alex Austin is the creator of BioShoot Infinite +1 and other games you haven't heard of, such as Sub Rosa, Hockey?, the Cryptic Sea EP, A New Zero, Rocket Builder, Relativity and Somnia.

Wednesday, January 22, 2014

Omega Jam

Omega Jam is a month-long game jam where 6 teams of indie devs try to finish current projects.  My goal is to finish an alpha of Sub Rosa with all the new features.  The idea goes back to the first 7 Day FPS game jam, David Rosen and I were at the IGN Open House during that week, he made Receiver and I made the prototype for Sub Rosa.  We both accomplished a lot during that week, and thought about doing something like that but trying to finish games instead of starting new ones.  The question was how to organize it, and how long should it be.

A month seemed like the perfect amount of time, enough time to get a lot done but still having that pressure of a game jam.  A few months ago we got in touch with Double Fine who had some extra office space and were willing to let us use it, and the idea finally started to come together.  It should be interesting, it's already been useful being able to bounce ideas off each other, and having that extra motivation of working around really dedicated people.  In the end it will be the games that decide whether it's a success or not, I think there will be some really cool things that come out of it.

Friday, January 10, 2014

Local Multiplayer Proposal

Local multiplayer games are gaining popularity on PCs, with games like Samurai Gunn, Towerfall, and the hugely popular Skate or Don't!.  But what if a player is on another person's computer but still wants to have their stats saved or use their characters?  How can multiple Steam accounts connect at the same time?  Here's an idea:

When a player is going to a friend's for local mutliplayer, they request a temporary password from Steam.  This would be 6-8 digit, or perhaps a random word.  On their friends computer they enter their name and temporary password, and Player 2 is now linked to their account.  This temporary account link would only be used for saving stats, and couldn't be used to buy games or anything else.  It would also only work for a limited time, maybe a day or so.

With this method players could play local multiplayer games on their friend's computer and have their stats and characters, without having to worry about their account being hijacked.  I've thought about implementing something like this myself, but I don't have the time or money to set up a global account system yet.  Hopefully someone like Valve will implement something like this so people can play with real friends on real couches.

Wednesday, January 8, 2014

Cryptic Sea 2014 Year In Preview

I've been making good progress lately, here's an update:

Cryptic Sea EP

The main additions are for Touring Car Legend, we now have 5 tracks and 5 cars, I'll try to get the netcode in as well.  Skate or Don't! has a singleplayer mode now, with an old-school lives system.  For Volta I've mainly been working on the graphics, I do want to fix up the puzzle mode soon though.  You can still get it for $3 (I'll be raising the price for the next version) at:
New version should be ready by next week.


We've been working on getting the skating and stickhandling of the new physics up to tournament quality, it takes quite a bit of tuning since it's a whole new player/stick model.  You can pre-order the new version and try out the prototype for $8 here:

A New Zero

Two things have been holding up development, human physics and the voxel landscape.  I've made some good progress on both, so I'll hopefully have some things to show soon.  You can see in the video me trying to land a loaded cargo plane, the new flight model makes the flying a lot more interesting I think.

Sub Rosa

I have some things I'll be revealing later this month, stay tuned.

Tuesday, September 24, 2013

Tutorial Tuesday: Rotating One Vector Around Another

Tutorial Tuesday is going to be a (hopefully) weekly thing where I write a tutorial.  On Tuesday.

All drawings were made in Microsoft Paint and are crappy.

This week is how to rotate one vector around another, one of the first problems I solved when working on 3D graphics and physics.  I'm sure there's plenty of information out there on how to do this by some nerd using matrices, but I'm going to explain my process for solving it just using vectors.

First let's start with 2D, so we want to rotate the black vector a certain amount (rotation angle), to the orange vector.

One way to do this would be to take the arc tangent of the black vector, add the rotation angle to that angle, and multiply the cosine of the new angle times the length of the vector for the X, and multiply the sine times length for the Y.  But that would be slow and dumb.  Arc tangent (atan2) is slow, and calculating the square root for the length is also slow.

Instead we'll use the tangent method.  First we calculate the tangent (the green vector) of the black vector, which is simple in 2D the tangent X is negative Y, and tangent Y is X.

Now that we have the original vector and its tangent, calculating the new vector is pretty simple.  It's the original vector times the cosine of the rotation angle plus the tangent vector times the sine.

Onto 3D, we have a black vector that we want to rotate around the blue vector, which is pointing straight up because that was the easiest to draw, but could be pointing any direction.

We're going to use a similar method to the 2D version, first we'll calculate the tangent to the original vector (black vector) and the rotation axis (blue vector, which should be normalized) using a cross product, which gives us the green vector.  Next we find the vector tangent to the green vector and the rotation axis using another cross product, which gives us the yellow vector.

Now we have the two vectors we need for rotation, just like in the 2D version.  We multiply the yellow vector times the cosine of the rotation angle add that to the green vector times the sine, and we have the rotation around the rotation axis.

But we're missing something, the length of the original black vector along the rotation axis, which is just the rotation axis times the dot product of the black vector and the rotation axis.  We add that to the other vector and we now have the orange vector, which is the black vector rotated around the blue rotation axis by the rotation angle.

That's it for this week, if you liked or didn't like this tutorial consider supporting me by buying my album of games and leaving a giant developer tip.  Tune in next week when I might write another of these things about something.