PD LOGO

Planetary Defense

by David Rector

While searching on the internet for attractive HTML5 canvas programs, I came across Core by Hakim El Hattab. I liked both the gameplay and, more importantly, the visual style of it. Hakim is talented and I decided to take advantage of his work. Thanks to what appears to be a very liberal copyright in the code, I was able to start with his existing game and modify it to become Planetary Defense. Hopefully he will if this is not the case.

I chose to start with an existing game because this is my first attempt at writing JavaScript for the HTML5 canvas. I have written JavaScript code before but never where I needed this much organization and complexity and never with a canvas. My many thanks to Hakim for helping me past the initial learning curve of these technologies.

Original Atari Planetary Defense

Planetary Defense, as I know it, was created for the Atari game consoles back in the early 1980's as shown (left).

My memory of the game was that it worked a little bit like the arcade console game Missile Command. I remembered wrong according to this YouTube video of the original Atari version being played. In my version, your bullets will explode at the point where you targeted them. In the Atari game, a direct hit is needed. Now that I've noticed this difference, I think I like my version better.

I used the more modern and attractive style from Core while adding my own tweaks to the game.

Planetary Defense is a game where you protect your planetoid from incoming attackers. You shoot from a satellite in orbit and your projectiles explode where you shoot them. The resulting explosions will destroy incoming bombs. The explosion from an incoming bomb will also destroy other bombs. The crux of the game is in not shooting your own planetoid. When a bomb or your own projectile hit the planetoid, they will explode but they will also damage your planetoid. If it is damaged enough to be destroyed, the game is over.

See a bit of Planetary Defense is this video:

I have added second and third levels to the game. The second level is short and has missles that target your satellite. The third level is very interesting with the satellite orbiting a small moon that orbits the planetoid.

Other Features

Each shot will result in the satellite gun heating up. Or if you want to think of it another way, it's battery loses some power. In either case, if the gun reaches a critical point, it will be unable to shoot again for a short time. The recharge after each shot is fairly quick so taking shots slowly will not make it reach this critical point. There is also a shield for emergency use. Pressing the spacebar or touching with two fingers will activate the shield for a very short time. This will destroy any enemy that touches it. It will also make the gun unusable for a fairly long time.

The files for the game are listed in a manifest file. Browsers will cache them so that the game can be played offline. Although the game is not very playable on the small screen of a smart-phone, it works well on an iPad with its large screen.

I left the original copyright in the JavaScript code. If there is no copyright in a file or if the code was written by me, it is still free to use in any way by anyone.

Give it a try.