Planetary Defense! Now with source code! (v0.02)
mpark
Posts: 1,305
In March of 1984, ANALOG Computing magazine published a game by Tom Hudson called Planetary Defense for the Atari 8-bit. (Does anyone out there remember this?) This is my take on Planetary Defense.
Here’s a teaser video www.youtube.com/watch?v=zMrPOU6-UKI
You are in charge of protecting your planet from alien attackers. Your only defense is an orbiting satellite armed with two weapons: a charged-particle gun and a missile launcher. To aim, move the targeting crosshairs with the mouse. The left mouse button fires the charged-particle gun, the right button fires missiles.
Charged-particle projectiles travel until they hit something. There is an unlimited supply of them and up to six may be in flight at a time.
Missiles explode when they reach their target (unless they hit something before then). There are 20 missiles per level and up to four can be in flight at a time.
Satellites are destroyed on contact with incoming bombs or flying saucers. You get an additional satellite every 10,000 points.
The game ends when your planet’s core (the glowing dot in the center) is destroyed.
Requirements: Hydra, NTSC TV, two-button mouse.
Installation instructions:
1. Download the attached .eeprom file.
2. Start the Propeller IDE.
3. Type Ctrl-O and open the .eeprom file you downloaded.
4. In the Object Info window, click Load RAM.
5. Defend your planet!
EDIT (attached source archive):
Here's the source. Use at own risk blah blah no warranty blah blah.
Note that I am not including NS_sound_drv_052_11khz_16bit.spin, so non-Hydra people won't be able to build the program (not with sound anyway). Non-Hydra folks, PM me if you want a build with custom clock speed, video pins, etc. and I'll see what I can do. (I assume it's all right to distribute binaries built with NS_sound_drv* -- please correct me if I'm wrong.)
A few random notes on the program:
Cog usage:
1 Spin interpreter
1 rasterizer
3 renderers
1 collision detection
1 mouse
1 sound
---
8 total
The screen is a 256 x 192 bitmap, 2 bits/pixel. The four colors are used as follows:
00 - background (black)
01 - score
10 - planet
11 - explosions
The rasterizer randomizes the explosion color every vblank and changes the planet color every scan line to create the color bands. (The rasterizer also does a whole lot of other stuff in a background task.)
Everything else on screen is a sprite. Sprites take up quite a bit of memory, being high-color (8 bits/pixel) and having a precomputed mask. I traded space for rendering complexity so that my three rendering cogs could give me the performance I wanted.
I was at a loss how to do sound until I looked through Dodgy Kong/HDMF Lite. That showed me the way. (Of course what I came up with is nowhere near HDMF, Lite or otherwise.)
EDIT
Replaced version 0.01 with v0.02 -- corrected teeny tiny boo-boo. Details in thread.
EDIT
Changed video link to YouTube.
Post Edited (mpark) : 4/4/2010 5:16:32 PM GMT
Here’s a teaser video www.youtube.com/watch?v=zMrPOU6-UKI
You are in charge of protecting your planet from alien attackers. Your only defense is an orbiting satellite armed with two weapons: a charged-particle gun and a missile launcher. To aim, move the targeting crosshairs with the mouse. The left mouse button fires the charged-particle gun, the right button fires missiles.
Charged-particle projectiles travel until they hit something. There is an unlimited supply of them and up to six may be in flight at a time.
Missiles explode when they reach their target (unless they hit something before then). There are 20 missiles per level and up to four can be in flight at a time.
Satellites are destroyed on contact with incoming bombs or flying saucers. You get an additional satellite every 10,000 points.
The game ends when your planet’s core (the glowing dot in the center) is destroyed.
Requirements: Hydra, NTSC TV, two-button mouse.
Installation instructions:
1. Download the attached .eeprom file.
2. Start the Propeller IDE.
3. Type Ctrl-O and open the .eeprom file you downloaded.
4. In the Object Info window, click Load RAM.
5. Defend your planet!
EDIT (attached source archive):
Here's the source. Use at own risk blah blah no warranty blah blah.
Note that I am not including NS_sound_drv_052_11khz_16bit.spin, so non-Hydra people won't be able to build the program (not with sound anyway). Non-Hydra folks, PM me if you want a build with custom clock speed, video pins, etc. and I'll see what I can do. (I assume it's all right to distribute binaries built with NS_sound_drv* -- please correct me if I'm wrong.)
A few random notes on the program:
Cog usage:
1 Spin interpreter
1 rasterizer
3 renderers
1 collision detection
1 mouse
1 sound
---
8 total
The screen is a 256 x 192 bitmap, 2 bits/pixel. The four colors are used as follows:
00 - background (black)
01 - score
10 - planet
11 - explosions
The rasterizer randomizes the explosion color every vblank and changes the planet color every scan line to create the color bands. (The rasterizer also does a whole lot of other stuff in a background task.)
Everything else on screen is a sprite. Sprites take up quite a bit of memory, being high-color (8 bits/pixel) and having a precomputed mask. I traded space for rendering complexity so that my three rendering cogs could give me the performance I wanted.
I was at a loss how to do sound until I looked through Dodgy Kong/HDMF Lite. That showed me the way. (Of course what I came up with is nowhere near HDMF, Lite or otherwise.)
EDIT
Replaced version 0.01 with v0.02 -- corrected teeny tiny boo-boo. Details in thread.
EDIT
Changed video link to YouTube.
Post Edited (mpark) : 4/4/2010 5:16:32 PM GMT
Comments
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Help to build the Propeller wiki - propeller.wikispaces.com
Cheers
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Paul Baker
Propeller Applications Engineer
Parallax, Inc.
Baggers --·what runs at 96MHz?
CardboardGuru -- Thanks! I always thought of the original PD as a neat variation on Missile Command and in fact added more MC-ish touches to my version.
Really great job! This is an excellent game in so many ways; very well suited to the platform, very well implemented, nice and stable, great use of sound, very good use of color, and best of all - super fun to play. I never played the original, but your version sure is a blast.
One of the things I miss about the 80's is that back then game designers were constantly seeking out new mechanics. So much of what gets made today is just the same old game with increasingly glitzy graphics. How many times can we play the same platform jumper? Yawn. This game smacks of innovation in all its 8 bit goodness (okay, arguably 32 bit goodness [noparse];)[/noparse] I love it when simple mechanisms lead to interesting emergent behaviors. The dynamics of shot timing, leading the target, waiting for line of sight, prioritizing targets, and working around the evolving shape of the planet all combine to make a spectacularly fun experience out of a small handful of objects.
Thanks for porting this gem, and for doing such a fine job of it! You've made the world a better place.
Mike
MinimumWage -- Thanks, but I don't know how much you'd learn from the source. It's pretty messed up. However, posting it was my original intention (if there was sufficient interest). Maybe I'll wait for bug reports first.
Michael
Exactly! That's why the Hydra will appeal to a lot of folks. My children have all those 'glitzy' games and they hold their attention for a few minutes at most.
I remember when getting a game you would play it till you finished it!
All the old 8 Bit game best sellers sold the most by being fun and playable not flashhy graphics.
@mpark
Please release a 96MHz version, to answer your question, a new platform the 'Hybrid' runs at that speed.
See this post for more details http://forums.parallax.com/showthread.php?p=659491
Best regards,
Coley
Coley: It's the other project that runs at 96Mhz, Hybrid is still 80Mhz [noparse]:)[/noparse] my typo originally soz. 12 should have been 10. too busy with second project.
Just one odd thing. I played it first using my WinTV card for display. Even at full screen the bullets were almost invisible. To the extent I didn't even notice they were there the fist time I played it! Trying it out on a real TV, the bullets are very clear and bright. I'd just put it down to the WinTV card, except that the bullets in Eric's Space War game are very bright on the WinTV card. Although the Space War bullets go slower, so that might contribute.
Game play wise, I didn't pick up on the missiles at first. But the missile display and count at the level end is enough to hint that there are some to be found. But when I did, I didn't find them to be a much stronger weapon than a volley of bullets. I can see that they work like Missile Command missiles, but they just didn't seem so useful here. Perhaps there could to be some small enemies that are harder to shoot with bullets that the missiles would be better for.
Perhaps the small enemies could bring a bit of Defender type action in? Moving rapidly they could steal something from the planet, and then make their escape? And something bad happens if all of the somethings are taken? You can shoot the enemies to retrieve the somethings which then fall under gravity back to the planet.
It'd be nice to have some details of how you put the game together. What graphics driver did you use? What res? How many colours? How did you produce the sound?
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Help to build the Propeller wiki - propeller.wikispaces.com
Baggers -- The Hydra is 10MHz * 8, so maybe it'll work as is. Did you try it?
Coley -- The Hybrid is your baby, isn't it? Shouldn't you know its clock speed?
CardboardGuru -- Constructive criticism is always welcome and I thank you for it.
I don't know what to tell you about the "invisible" bullets.
The MC-style missiles are my addition (I figured I should do something with the right mouse button) and smaller enemies were definitely in the plan, but I ran out of time and memory (I'm down to 1 free long). Instead, I·tried to design a few levels where you'd want to use the missiles to spray-and-pray a defensive cover of explosions, but more power to you if you can stick to the classic PD weapon and ignore missiles (and rack up the extra points).
Anyhoo, I'll post the source tonight in the hopes that
My wife's nan died last friday, and my mum had a major stroke on Sunday, so please forgive my lack of attention to detail [noparse]:)[/noparse] as you can imagine, my head is all over the place at the mo.
Again, thanks for posting the source, I'll have a play later, when I get chance.
Baggers,
lol, yes I should!
We have many things on the go at the moment and one product associated with the hybrid runs at 96MHz, sorry for the confusion.
Thanks for releasing the source, I am looking forwards to trying this one, so it's a big thank you from me.
Best regards,
Coley
Thanks for this! It plays well and is a lot of fun. Brings back lots of happy memories waiting for new issues COMPUTE!, ANALOG, Antic, Creative Computing, etc... to hit the shelves each month. What a fun time.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Propeller Wiki: Share the coolness!
Got it working, just changed the clock speeds, and modified the original mouse.spin ( added getparameters and removed bounding functions, to make it fit in memory [noparse]:)[/noparse] ) and changed mouse pins to pin 14,15.
Works great, and it's very addictive.
Well done, very nice port.
Jim.
That "8" should be a "2".
However, I also discovered that even with the correct number, the Spin compiler was computing a value that was just a little bit off. So I've replaced that whole line with this:
I discovered all this while trying to track down some interference in another program using the same video driver. I haven't noticed the interference in Planetary Defense (probably because the screen is mostly black) so it's probably not worth re-downloading, but I've replaced the binary and source in the first post with new versions (0.02).
Baggers -- My sympathies for your troubles, but I'm glad to hear you got it working.
MinimumWage -- Good luck!
Hey, just out of curiosity, are you non-Hydra people compiling it without sound, or do you have the sound driver somehow? PM me if you prefer. I don't want to bust anyone, I'm just curious.
Thanks for the sympathies. [noparse];)[/noparse]
And yeah, was just a few simple changes to get it working [noparse]:)[/noparse]
As for without sound, I have the Hydra book, for the overcharged price of £65 roughly $130 [noparse]:([/noparse] we brits always get ripped off, also I think it's one of the first revisions, as the software that came with it, wasn't complete, I'm missing at least one ( that I know of, the latest sound drivers. NS_Hydra_Sound_12, or something like that, I had to use a lower version, can't remember off hand which app it was for though ) was a little while ago that I found that out though.
Baggers.
Andre'
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Living on the planet Earth might be expensive but it includes a free trip around the sun every year...
Experience level:
[noparse][[/noparse] ] Let's connect the motor to pin 1, it's a 6V motor so it should be fine.
[noparse][[/noparse] ] OK, I got my resistors hooked up with the LEDs.
[noparse][[/noparse]X] I got the Motor hooked up with the H-bridge and the 555 is supplying the PWM.
[noparse][[/noparse] ] Now, if I can only program the BOE-BOT to interface with he Flux Capacitor.
[noparse][[/noparse] ] I dream in SX28 assembler...
/Bamse
JT Cook -- I guess you'll also have to change 80_000_000 to 80_040_000 (i.e. add 5000 * 8). That's kind of odd, though. Do you think it's your crystal or is it your TV? Anyway, good luck and let us know how it turns out.
"mouse.spin" is considerably larger than "mouse_iso_010.spin" so I had to remove the credits section
as well as shorten the POINTS announcements to get it to load with the intended sound driver.
Every ounce of memory is used with this game. [noparse]:)[/noparse]
Attached is a compilable copy with a dummy (silent) version of Nicks sound driver.
Should work perfectly for anyone with a demoboard type setup.
If you drop in the licensed copy of "NS_sound_drv_052_11khz_16bit.spin" from the Hydra Book/Kit,
you'll get full sound as well.
Great game, well worth checking out!
OBC
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
New to the Propeller?
Getting started with a Propeller Protoboard?
Check out: Introduction to the Proboard & Propeller Cookbook 1.4
Updates to the Cookbook are now posted to: Propeller.warrantyvoid.us
Got an SD card connected? - PropDOS