I’m having so much fun with Asteroids that I thought I’d look at the old Space Invaders game. I’m sure I’ll learn something.
OK, are you back? Let’s move on. I’ve been having so much fun writing Asteroids, and found so many lessons in it, that I’ve decided to take a look at the old game of Space Invaders. This game comes from 1978, about the time of Asteroids, and was at least as iconic as Asteroids at the time.
The game has ranks of space invaders at the top of the screen, moving from side to side and inexorably downward, dropping missiles at the hapless player, represented by a sort of cannon that can move from side to side and fire missiles up at the invaders. There are some bunkers to hide behind, but these are damaged and ultimately destroyed by either the invaders’ shots or your own.
I’ve found the source code for the program, in some kind of assembly language, and there are other resources that I’ll refer to as we go forward. My purpose today is to introduce the project and to think a bit about how we’ll go about it.
My plan, such as it is, has two components that I feel strongly that I’ll do.
- Copy Mary Rose Cook’s Game
- I’ll start with something close to the simplicity of Mary Rose Cook’s example, and evolve it until it becomes no longer interesting. This will be another exploration of how we can keep a program “shippable” while improving it in very short steps.
- Follow the Bitmap Style
- Space Invaders seems to have been written on a bit-mapped screen, as opposed to the vector screen of Asteroids. The invaders and other objects are represented as arrays of bits, and these are displayed on the screen, basically by copying those bits into video memory and voila! the display displays the pixels.
This will be amusing, because Codea’s screen model is definitely not bit-mapped, and we’ll have to jump through a few hoops to get close to the look and feel of the old game.
The Space Invaders screen was 224 by 256. Or 256 by 224. I’m not dead certain yet which way is vertical. In contrast, this iPad is 1366 by 1024, according to Codea, with a real resolution of 2732 by 2048. So we’re going to need to do some fun scaling.
The Space Invaders screen was monochrome. The orange at the top and green at the bottom was accomplished with red and green transparencies pasted on the glass. I’m not sure if I’ll try to match that or not. Aspects of that might be tricky.
Today, I’m just starting to see what can be done about bitmap display.
The Bitmap Issue
On a bitmapped display, you typically have two buffers. One is displayed, you work in the other. When you set the other to display, its bits are then displayed on the screen, like a sort of typewriter picture:
**** ****** * * * ****** **
The closest Codea can get to that is the “sprite”, which is a digital bitmap picture, like any random picture file you might find on line. Codea can display such a thing at any location on the screen, scale it, rotate it, and so on.
What it can’t do very well at all is manipulate those bits directly. Codea can draw a line or a rectangle or an ellipse. It can even project those things in perspective. But literally move that row of bits over and down? Not in the cards. Blit a bunch of memory into a buffer and display it? Nope, not interested. You can set one bit in a time in an image, or draw those rectangles and ellipses. And that’s about it.
But Space Invaders was so slow that it couldn’t even move all the invaders at once. Watch a game video and observe how they sort of ripple across and downward rather than just all move at once. And the way it gets faster and more menacing? That’s happening because with fewer invaders to display, it can step faster. Apparently they found that such a nice feature that they didn’t put in a delay to keep the pace constant.
Frankly it would be easier to create some sprites and move them along in a sensible sort of way. We’ll probably do that in an early article, along the lines that Mary Rose Cook showed us. But to really match that look at all well may be a lot trickier than it was to match the Asteroids look.
We’ll see. I’ll keep you posted, stay tuned!