ArcherFire: Duet of Aces – js13k 2018 – Part 2

JS13k 2018 has gone by! this is the second of a series of posts detailing my journey, as well as the structure of the game I built. You can play it online here!

Links to the full series: part1part3postmortem

Day 4

First thing I did was fixing the build scripts since I really needed to know how I was doing vs the 13KB limit (last year I spent a lot of time by the end of the time-frame, removing things). I figured out the build problems by checking the script for Lost of Asterion; I had to replace a dependency (gulp-uglify) with the ES6 ready version (gulp-uglify-es) since I was using ES6 features in my code (cannot live without arrow functions now). The zipped archive was 5.36KB, and I had 46 hours to go.

I created a list of priorities in Trello, as I said there was a game there already, so what was left was polishing some rough edges and add fancy stuff. The last missing core thing was making the levels consistent (that is, they should be the same every time the player plays). Of course, the trick because of the size restrictions is not having the levels hand-designed but rather using a seedable (and small) pRNG, I ended up using an implementation of  Park/Miller LCG based on this.

function LCG(s) {
  return function() {
    s = Math.imul(16807, s) | 0 % 2147483647;
    return (s & 2147483647) / 2147483648;
  }
}

I seeded it with 13312, and it’s used only for the enemy wave generation.

Another annoying thing I was pending fixing was replacing the temporary setTimeout based timers with something that relied on the game update cycle instead so that the game wouldn’t go bananas when the animation was paused (say because the game’s tab became inactive) but the timers kept running. I added a simple function to the RAF loop to keep track of a list of timers on every frame update, reducing a timeout value by the update delta, and executing a callback when it reached zero.

Next up was showing the “current wave” in the UI, so that players could have a sense of progress besides the score so they could brag about being able to reach wave X. This was also used to increase the difficulty of the waves, so the further the player is the harder the enemies and the shorter their reaction time (so they shoot more bullets)

There were some weird issues where mobs were being “killed” out of nowhere, I thought this may be due to the way they were being sliced out of the lists during the update phase which might cause the wrong mob to be deleted. I changed it so that when a mob’s update function deemed it necessary for the mob to be killed, it is marked and then all the marked mobs are deleted, instead of doing it on the spot. It seemed to work.

Also added some cosmetic changes on the explosion SFX, changing the colors so that it looked a bit darker and different when fizzling, and a scaling effect so the ships would look like they were “landing” on the game (but it didn’t look very good)

Finally, continuing with the idea of adding a music track, I asked on the js13k slack and was lucky to have Ryan Malm offer to create a track for the game, as long as I could set up SoundBox on it.  So I did that and added one of the sample tracks.

Screen Shot 2018-09-18 at 10.34.22 PM
SoundBox in action

Day 5

The final day of development was long, but not really too crazy compared to last year.

I proceeded to add more variation to the different enemy formations, adding the following:

  • Enemies coming from below
  • Horizontal row of mines
  • Vertical row of mines

I also did the best I could to enhance the appearance of the turret “platforms” and the mines.

20180913_210908
Designing the appearance for the enemies

Added some planets to the background, they are a circle filled with a gradient, their generation is tied to the wave generation so they serve as milestone markers to see how far you’ve gone (so far I have only been able to reach the second, purple planet, in my highest score)

Did some playtesting and balanced the difficulty a bit, then, since the game bootup was a bit crappy, I added a “loading” screen to cover the process of converting the soundbox script into a WAV stream, in turn, I also added a simple title screen with the name of the game, some credits, and instructions. This required adding some “mode” handling to the game and a simple state machine.

Was getting close to midnight when I got the theme song by Ryan, it was awesome! because of time constraints, it was a bit short (about 15 seconds long) but it did a great job at enhancing the atmosphere of the game.

It should be noted that this 15 seconds track, including the whole “library” to play it, is 2.5KB of compressed source code. Compared that to 361 KB for the OGG export. It’s really wonderful.

I did some work on the player bullets, changing them from red balls to missiles, using a different sound effect for them, and throttling the fire rate so it was more controlled and predictable. Also, since I still had plenty of space, added sounds for the explosion when a ship was destroyed, and a beep for starting the game.

Continued with small tweaks, removing the “ships landing” scaling effect which didn’t really look too good, changing the keybindings for the “down” key for player 2 to be “5” instead of “2”.

The game was almost ready to ship, I did some basic CSS styling for the containing page (black background, centered canvas), but more importantly scaling the canvas to 100% height so that it looked good on most horizontal display cases.

I hesitated a lot, but in the end, decided to jump into allowing the player to restart the game without having to refresh the page when dying. Anyone who has participated in a jam knows how tricky it can be to reset the game state, especially if you didn’t design for that in advance. But I went ahead and did it, and I think being able to restart quickly  became an important part of the game (and makes it look much more polished)

As part of the final playtesting, I added “shield” to the ships so the player can take 3 hits before dying instead of exploding instantly, and increased the acceleration so it’s easier to dodge bullets. I also fixed an issue with the Numpad not working in Safari and Firefox

afdoa

Next up, a view of the complete structure of the game, and then some final thoughts!

ArcherFire: Duet of Aces – js13k 2018 – Part 1

JS13k 2018 has gone by! this is the first of a series of posts detailing my journey, as well as the structure of the game I built. You can play it online here!

Links to the full series: part2part3postmortem

Before Coding

I wasn’t really sure what to do, I actually was wondering if I was going to be able to participate at all, but the weeks before coding I toyed in my head with several different ideas… one of them would be a mobile entry based on my Energy Radar project (which is inspired by Pokemon Go), running completely offline but allowing players to interact and capture monsters as a team. I decided against it because of it being maybe too big in scale.

20180913_210812

Another one would have been an offline life simulator, someone living on the forest, fishing, something more of an experience than a game since there would be little stress, this would have been more heavy on the graphical side so I abandoned it (more so as the deadline was getting closer)

20180913_210757

Finally, had an idea of a non-linear “Space shooter”, keeping some of the Energy Radar ideas on offline interactivity, players could fly from planet to planet; once in a planet, they would input a code from another player on the same planet, which would allow them to advance on the plot.

20180913_210742

Knowing that I may very well wound up doing something completely different, but I had to start somewhere, I went with this idea.

Day 1

At first, I tried to use source from Lost in Asterion (my js13k from 2017), but lost a lot of time. I went instead with a fresh copy of js13k boilerplate. I modified the example and was able to have a static starfield in little time.

Since this was going to be a non linear shooter, and I thought having a “lerping” camera effect would be cool, I invested a lot of time trying to make the “camera” work (again, based on Lost in Asterion). It worked, almost, since I wasn’t really tweening it but rather handling it as an object on-screen with acceleration and position, so it was hard to make it “stick” to the player once it reached him.

I also added simple keyboard input to move the “ship” around, and with the camera following it, it was a rudimentary space scene.

Screen Shot 2018-09-03 at 11.05.36 AM.png

Day 2

After giving it some thought in my head, and reading my postmortem from 2017, I decided to go on a different route. I would instead focus on making a simple arcade game, and use the 13K to add as much eye and ear candy as possible.

I ditched all the work that I had done in the camera since it was now going to be a linear game (and it wasn’t really working very well)

With a more clear vision of what the game was to be about, I implemented a lot of things,

  • Collisions between player and enemies.
  • Bullets killing enemies, increasing the player score.
  • Removing mobs when out of the screen (stars, enemies, bullets).
  • “Serial rendering” of mobs allowing potential complex representations.
  • Render score with LCD like display.

Since I needed something to test my “rendering” system, I decided to design the player ship, I based myself on the ship from the original ArcherFire made in QBasic in 2002.

Screen Shot 2018-09-13 at 9.30.34 PM
Original QBasic Archerfire, 2002

Doing vectorial art, however, is something I don’t have any experience with. I can do _some_ pixel art, but this is a different beast. Plus I had to manually input the sequence of commands to draw each shape. I did the best I could with the little time I had.

20180913_210847

In the end, this design is represented as follows in the code:

‘#eeeeee’,’p’,-2,2,-4,4,-6,0,-4,-1,-2,-4,0,-4,0,2,’f’,’o’,’#0000ff’,’p’,-3,3,-4,4,-6,4,-8,0,-6,-3,-4,-4,-5,-1,’f’,’o’,’#dddddd’,’v’,0,-6,2.2,2.2,’f’,’o’,’#888888′,’vh’,0,1,2.5,2,Math.PI,2*Math.PI,’f’,’o’,’#ff3333′,’p’,0,1,-2.5,1,-2.5,2,-1.5,3,0,3,’f’,’o’,’#000000′,’v’,0,-6,2,1.5,’f’,’o’,’#ff0000′,’vh’,0,-6,2,1.5,0.5,Math.PI-0.5,’f’,

(Note that this is meant to be only half of the ship, the other half is drawn mirrored)

Since I was already drawing a scaled version of it, I figured I’d try to include a practical 3d looking effect when turning the ship, it did look pretty good.

Tried to build the game by the end of the day to see how I was doing with the size but found out there was a problem with uglify which didn’t let me thru.

js13k2

Day 3

Since I was no longer going for the “offline social” component, I wondered how to incorporate the theme. One obvious option was to provide hotseat multiplayer, and I ended up adding that.

Made enemies being able to shoot at the nearest player, and added the infrastructure to be able to create enemies given a set of parameters. Also added enemies cruising from left to right of the screen, and platforms with 4 mounted turrets.

Added explosion effects, since I didn’t have any tweening library and the rendering was being done manually, had to implement the explosion animation by drawing an expanding circle which would them be “hollowed” when dissipating. Drawing a “hollow” circle in canvas context2d was not as easy as I thought! I ended up using a weird trick to compose the path to fill: Draw the outer circle clockwise and the inner one counter-clockwise. I still don’t understand how that worked.

For SFX, I included again the good old trusty jsfxr. It keeps being useful even after years of not being updated. I added sounds for the explosions and the firing of bullets.

I saw that I still had plenty of space left so I began wondering how to include music. I tried minimusic, set it up and made it work inside the game with a test melody, but was unable to come up with anything half decent (guess why, I’m not a musician!). I left it there, asking a friend to see if he could maybe device something out of it.

Also designed one of the enemy ships (again based on ArcherFire 2002). I tried to implement some way to “rotate” its rendering but after spending some time on it gave up.

Finally, I added one first version of the “wave generator”, that is the thing that puts up new enemies on the stage as the player goes thru. After putting that I found myself with a rudimentary but complete game that someone might even enjoy!

day3.5.gif

Journey onward to Day 4 and 5, and then a detailed rundown of the game’s structure and some conclusions and thoughts!

NeoArcherFire QuickBasic source code

Today I decided to try to include some of my oldest game projects into my page at http://slashie.net. A couple of them were ArcherFire and NeoArcherFire, the first games I created which included graphics.

Screen Shot 2016-08-16 at 11.45.34 PM

Bundled with the original ArcherFire, I found a file which was supposed to be its source code. I tried checking it out: it was a .BAS file so I thought it’d be a plain text file with QBasic source code… I was wrong, it was a binary file.

Then I remembered back then the version of “QBasic” I used allowed saving the source code as binary files for faster loading times. I downloaded QBasic and tried to load the file (Using DOSBox, of course). It failed, unable to read the binary contents.

I googled a bit and refreshed my mind: back then I was using QuickBasic, not QBasic.

[from wikipedia]

A subset of QuickBASIC 4.5, named QBasic, was included with MS-DOS 5 and later versions, replacing the GW-BASIC included with previous versions of MS-DOS. Compared to QuickBASIC, QBasic is limited to an interpreter only, lacks a few functions, can only handle programs of a limited size, and lacks support for separate program modules. Since it lacks a compiler, it cannot be used to produce executable files, although its program source code can still be compiled by a QuickBASIC 4.5, PDS 7.x or VBDOS 1.0 compiler, if available.

I downloaded it and was able to check the source code, finding out that it was Neo ArcherFire, the enhanced version which used DirectQB, and my final game project using any BASIC variant!

af1

I made this game back on 2003, the source code is surprisingly organised 🙂

Screen Shot 2016-08-16 at 11.31.08 PM

I exported the binary “project” to ASCII, and uploaded it to github, if you are curious you can check it out here, but I’d recommend getting MSQuickBasic so you can navigate the SUBs easily 😀

This game was powered by DirectQB, a lib released in 1999 by Angelo Mottola which greatly extended what could be done by QuickBasic, you can find more info here.

Although this wasn’t really my first game, I think it’s very unlikely for me to find any older source code, it was lost in my old 486… may be some day I’ll find a rusty diskette with it? Some of the things I miss the most are:

  • The source code of the original ArcherFire (with graphics): The only surviving compiled version has you starting with 1 hit point left, so it’s pretty hard 😀
  • The romhack for translating Final Fantasy I to Spanish, which I recall was a lot of work and was (almost?) done
  • The non-graphics versions of ArcherFire, as well as some earlier console-mode games I made including a set of “athletics” games (I recall one being about 100 meters dash), another adventure game where you could move a happy face around, and a puzzle game similar to Dr. Mario.

Archerfire 0.41

Play online!

041

Changes

  • Increase rate for Powerups
  • UFO type ships should lean forward to advance
  • Lean forward or backward automatically when climbing or diving into planets
  • Fix initial values for war status screen

Pending

  • Add intro sequence using big ships, a la Megaman
  • Less Big Ships, and change sprite for a small robot
  • Enhance torch weapon (or put it on a premium ship)
  • Make enemies lean forward and backward when changing altitude
  • Make allies smarter
  • Nerf laser enemies
  • Withstand hits before losing weapon upgrade
  • Bug: Keep music volume when looping and paused!
  • Letters don’t look good in bright planetary backgrounds.
  • Reduce SWF size (currently 8MB)
  • Reenable payments

Archerfire 0.40 released

This is a MAJOR release from last one 🙂 PLAY ONLINE

Version 0.40
New version 0.40

It’s been almost a year, last one was August 15 2013… thousands of things have happened.

What can I say, I decided to shoot to finish it and made some hard choices in order to take it into the shipability route. It’s a completely different game!

Here’s a gameplay vid:

I have stripped a lot of functionality that was either incomplete or burdened the user experience, say goodbye to:

  • Custom Player Creation – Was overly complex and offered little return for the player
  • Weapon and Pilot Selection – Now they are tied to the ships, so you can jump quicker into the game.
  • Wingmen – This was unfortunately not polished enough, it might go back into the game soon.
  • Difficulty level selection – To streamline the game and make it easier to balance (balancing 5 difficulty levels was not fun and was a nuisance for players as well)
  • Missions Mode – Was incomplete, buggy, unbalanced and unfun.
  • Items Shop and consumable powerups and Batteries – They were not really useful in-game, plus I don’t like them as a monetization model.
  • Experience Points: Not useful
  • And many more other things
Previous version, note the screen size and additional data
Previous version, note the screen size and additional data

I also added two new tracks for the Title and GameOver screens, and changed resolution to 800×480 (was 900×650)

Additionally I debugged and reworked critical portions of the code

  • Enemy AI modules
  • Enemy spawning structures
  • Sound Management

Ship purchases are currently broken since facebook seems to have completely changed how that works since it was functional last year; that might require a fair bit of work to get up and running again.

Pending tweaks:

  • Less N00b enemies, more smart ships
  • Increase rate for Powerups
  • Add intro sequence using big ships, a la Megaman
  • Less Big Ships, and change sprite for a small robot
  • Make enemies Lean forward and backward when changing altitude
  • UFO type ships should lean forward to advance
  • Lean forward or backward automatically when climbing or diving into planets
  • Make allies smarter
  • Bug: Keep music volume when looping and paused!
  • Letters don’t look good in bright planetary backgrounds.
  • Reduce SWF size (currently 8MB)
  • Fix initial values for war status screen

ArcherFire continued cleanup

Done some further work on Archerfire, refactored sound effects management, slowed down enemies a bit.

ScreenShot029

Still not time to deploy  a new version tho.

ToDo:

  • Make enemies spawn closer to the edge of the screen
  • Fix “RANDOM” AI
  • Check out ALL the AI modules, and ALL the formations and tweak them
  • Increase the rate of ally waves
  • Check correlation between mines and ally waves
  • Add weapon names to each ship on Ship Selection Screen
  • Make big ships move vertically
  • Fix music on/off message
  • Improve UI yet even more? check out NES games
  • Change DOS font for a NES font

Worked a bit on Archerfire

Added the 2 new tracks for title and gameover, while reestructuring the whole music management code.

Also started tying the weapons to the selected ships, got into refactoring as well and ended up in a mess… gotta finish adjusting the ship selection part next time.

Also should note that the current public version is broken: Both because of an expired SSL certificate that won’t let it run inside the facebook canvas, as well as some changes in facebook in app purchases policies..

Removal

Getting Cleaner
Getting Cleaner

Removed:

  • Missions Mode
  • “Energy”
  • Experience Points
  • Difficulty Level Selection
  • Pilot / Wingman Selection
  • Pilot Personalization
  • Shop
  • Items (Bomb / Shield / Radio)
  • Weapon Selection (Will be tied to the ship)
  • Time, Kills and Shoots counters

TODO:

  • Play some shooters to get ideas for gameplay
  • Change resolution to 800×480 (Low Tablet)
  • Tie weapons to selected ship
  • Remove coins
  • Remove slower than ship bullets (Including big ship bullets)
  • Enhance enemy generation, cap number of enemies per wave
  • Reduce the length of the screen shaking animation
  • Balance music and sfx volume
  • Mute SFX on Music Off

ArcherFire, lots of things to remove

Note: I let the SSL certificate expire, in the meantime you gotta access http://games.slashware.net/archerfire/game.php directly.

List of things to blow up:

  • Missions Mode
  • “Energy”
  • Experience Points
  • Difficulty Level Selection
  • Pilot / Wingman Selection
  • Pilot Personalization
  • Shop
  • Items (Bomb / Shield / Radio)
  • Weapon Selection (Will be tied to the ship)
  • Time, Kills and Shoots counters
  • Coins

Other enhancements

  • Remove slower than ship bullets (Including big ship bullets)
  • Enhance enemy generation, cap number of enemies per wave
  • Reduce the length of the screen shaking animation
  • Balance music and sfx volume
  • Mute SFX