Gravity Wars Redux

Published 9 years, 6 months past

Over the past few weeks, I’ve been writing a remake of/homage to a game I last played somewhere around 1990: Gravity Wars.  I gave this personal project a few hours here and there each day, or more usually each evening, slowly resurrecting a little piece of my past and putting my own spin on it.  You can check it out for yourself, if you like: Gravity Wars Redux.

There are a few things I changed from the version I played all those years ago, besides the change of colors.  First of all, instead of taking turns, in my version the ships fire simultaneously, meaning a no-survivors tie is possible.  Second, the shot preview paths weren’t part of the original game.  Third, the “Gravimetric display” wasn’t a thing in the original game either.  That and the shot previews are leftovers from my development testing that I decided to keep around, either because I thought they added something to the game or because I just liked them too much to dump.

In fact, most of the code in there is accreted leftovers from the experimentation and development process.  Looking at it now, I can see all the things I should have done.  It just got to a point, as with most coding projects, where I could add another scoop or two of spaghetti to the existing mound and ship it, or I could start over and try to make the lasagna properly this time.  I decided to ship it.

I have to admit the point of all this wasn’t actually to recreate Gravity Wars, as much as I like the game and am glad to have a working copy of it.  It was instead to teach myself about the canvas API, and also to try to get a handle on some JS features that have never quite made sense to me.  I think I did okay on the both fronts, in my own idiosyncratic way.

At this point in a JS-related post, I usually throw in a disclaimer about being a JS newb whose code should never be inspected by anybody.  That’s probably still true, but I know I’ve advanced quite a bit from where I was, which pleases me.  I can see that not just in that the code I’m publishing today, which is convoluted and clumsy but still better than what I’ve written in the past.  I can also tell I’ve gotten better simply because I can see better approaches, as a result of what I learned along the way.

This may be where I end the project, or I may go back and take another crack at making lasagna.  We’ll see.  The carrot for me in doing that is it would let me add some other fun features and useful improvements pretty cheaply, not to mention I could fix some things that aren’t quite what they should be (like the placement of planets and ships, which should be a little less random).  The stick is of course having to rewrite code I already wrote.  I mean, lasagna is nice and all, but I like spaghetti too.

Anyway, I enjoyed writing it and learning as I coded, so if slinging missiles around planetary limbs sounds like your idea of a good time, please enjoy.


I’m indebted to Sohrab Ismail-Beigi, whose 1989 PASCAL source code I studied and in some cases directly ported; and to pascal-source.ru, for making that code available for download.  My thanks to both.


Comments (7)

  1. Nice! You should throw a license boilerplate on that JS code, so people know if they can fork it or not.

  2. Thanks, Kevin. I was thinking about that, but the problem is always knowing what license would be best, and asking for opinions is like asking people which is the best text editor. I dunno, is there a license that basically means “You can re-use or fork this code if you want, but given the state of the code, you really really shouldn’t”?

  3. How about Beer Ware?

  4. Heh, maybe the next version will be under that license. I was also considering MIT and good old Unlicense, but Beerware amuses me.

  5. Speaking of Javascript, over the years, I’ve found your Color Blender tool to be very useful. Today I discovered some strange behavior. It seems to have a problem with hex colors beginning with B. For example, BEECEE is converted to EECE0E. It throws away the initial B, shifts the next four characters left, and inserts a 0 in front of the final character. If both of the first two characters are B, it doesn’t even run – the input string seems not to be interpreted, and it doesn’t compute the color array. 0Bxxxx strings are fine.

    Sorry to bother you with something so trivial, but is there any way you can fix it? I’m a total JS noob myself, or I would provide a suggestion for a fix.

    http://meyerweb.com/eric/tools/color-blend/

    Your books have been helpful to me, and I appreciate the mindful, personal, and philosophical thoughts you share on this site.

    Thanks,
    Karen

  6. Thanks for the bug report, Karen. I think it’s fixed now; let me know if you find otherwise.

  7. Works great, thank you!

Add Your Thoughts

Meyerweb dot com reserves the right to edit or remove any comment, especially when abusive or irrelevant to the topic at hand.

HTML allowed: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <em> <i> <q cite=""> <s> <strong> <pre class=""> <kbd>


if you’re satisfied with it.

Comment Preview