Centipede Game

Centipede is a classic video game created by AtariCorp? in 1981.


It's similar to SpaceInvaders?, in which the player pilots a ship that fires up in a straight line, and essentially destroy anything on the screen that moves. The ship may move in any direction, to anywhere within the bottom third of the playfield. The entire playfield is scattered with mushrooms.

Here are the things you can shoot.

This is one of those games that has been ported to just about every game system, personal computer, operating system, and keychain game case out there. It can even be found on some of those touch-screen LonelyGuyMachines? they have in bars, though the touch-screen interface isn't as nice as the original trackball. It was also remade and rereleased by Hasbro, kind of like FroggerGame? was.

It is also said to be one of those games that appeals equally to men and women, like PacMan and TetrisGame.


Pretty good ShockWave implementation: http://www.arcademachine.com/go/shockwave/preview/S0051.tam or http://www.tripletsrus.com/80s/80s_games/centipede.htm or http://www.planetgameroom.com/planetgameroom/shockwave/centipede.asp

Related Java games: http://www.arcadepod.com/games/searchgame.asp?search=centipede&submit=Search+Games&sc=g-shoot.asp (Detailed in the following list.)


Example of a Centipede Game

This page was originally created in response to a request for ideas for a learning-to-program project. Warning: The original page (BoyThisStuffMakesMeFeelStupid) was about learning OO principles... This implementation is not.

If you are a Windows kinda person, download this:

http://www.btinternet.com/~daniel_earwicker/daniel/centipede.zip

It contains centipede.exe. Run it and you will get the idea! Hint: click anywhere on the window to fire from that location. I haven't implemented a proper sprite for the player. I just borrowed the mouse pointer. There is currently no way for the player to lose a life, but it's oddly satisfying to zap stuff anyway.

It uses standard Windows API stuff, no Direct X. The sprites are just 32x32 icons. It's a little flickery, but it doesn't seem to get any slower on my P3 500, however long the centipede gets!

I also payed no attention to those optimization ideas I mentioned below. In fact I didn't consider how to make it fast at any point. There's no need, these days... it's a shame really! Instead, I went for choices that would tend to make it correct first time, instead of risky stuff.

I've included the source in that zip, so if you have Visual C++ 6.0 then you can compile it and add features (scoring? spiders? a proper player sprite?) Most of the files in there was wizard generated and haven't been changed. To turn it into a centipede game, only the ChildView?.h and ChildView?.cpp files were modified.

I should add some comments! Else how is anyone supposed to learn from it? Also some kind of discussion of how I decided to put which things in which classes. So far all I've done is just hack together the working program for the fun of it.

Maybe someone would like to write some unit tests for it? Not that there are any bugs in it, of course. :)


Optimization in Text Mode

Strictly speaking, I don't necessarily mean text mode. I mean what you might call cell mode, where all sprites have the same size (e.g. 16x16 pixels) and they are always positioned in a cell somewhere in a rectangular grid (so in 640x480 resolution, the grid would be 40x30 cells.

Anyway, this means that when you draw a centipede...

oooooooo

... moving along by one step, all you have to do is erase the tail...

ooooooo

and draw the new head...

oooooooo

Like so. This saves a lot of drawing. Technically, the centipede is just a queue. (Hey, we're learning stuff!)

But that was 1983 and these days I'm sure such optimizations are totally unnecessary, as you can have the individual segments flowing around the screen in 3D with texture mapping. Still, it's nice to remember the old days.


Splitting the Centipede

A key part of how the game gets more exciting is that when you shoot a segment of the centipede, the hit segment turns into a mushroom:

ooooMooo

So the next few frames look like this:

1)

oooM ooo
o

2)
ooM  ooo
oo

3)
oMooo
ooo

4)
Mooo
oooo

5)
Mooo
oooo

Note how the left half immediately "collides" with the new mushroom and so (in accordance with the rules) has to change direction horizontally and go down one line.

This splitting behaviour has an important parallel with Asteroids. When you shoot a rock, it breaks into little rocks. And so on. This heightens the tension because you can feel things getting out of control, as if your actions are making things worse before they make them better.

That's why a common strategy in AsteroidsGame? is to destroy the smallest asteroids as soon as they appear. Same for Centipede; it's annoying when you have a dozen disembodied heads zooming around.

With Asteroids, there is no way to avoid the small rocks. Every big rock has small rocks hiding inside it so it's not really the player's fault. With Centipede, you can avoid making short ones by only shooting the head or last segment. What's more, you can shoot the head and then shoot and destroy the mushroom it turns into, before the new head bounces off. Then the new head moves into the position of the old head and you can destroy that the same way. An entire centipede can be dispatched in this fashion, very rapidly. It only works low down the screen (because of the travel time of bullets and because you only get 1 bullet at time) so if it goes wrong, you're screwed. When it goes right, it's exhilarating. Players discover it by accident early on, then get hooked on repeating the experience (usually getting it wrong). -- DaveHarris

I've recently discovered the marvelous MameEmulator and so naturally I've been playing Asteroids quite a bit. I've discovered a way to avoid the small rocks! Or at least avoid some of them. You just shoot without discrimination until the screen is almost full and the code reaches a hard limit on the number of vector "sprites" it can cope with. Then when you hit a large rock, it simply changes into a single smaller rock rather than splitting into several. Of course, this doesn't make the game any easier, on balance. -- DanielEarwicker


Fascinating concept that the game is fun because the player generates the additional tension as they try to apply a solution. Any other games use this technique? Most of the current crop seem to be all game-supplied tension. --AndyPierce

When writing the above, I made myself laugh by imagining the idea taken to extremes - basically a little alien that doubles in size every time you fire at it and miss. When you hit it, it gets smaller and eventually shrinks to nothing, ending the round. Interesting thing is that there would be a sort of equilibrium point where it would get so large that you could hardly avoid hitting it. Not sure if it would become a good game or not - you have to try these things. -- DanielEarwicker

There are several "sneaker" type games where the guards are quiet when you arrive, and will sound the alarm if they notice you. For example, DeusExGame? and IgiGame?. Sounding the alarm summons more guards, rather like splitting a centipede or asteroid. -- DaveHarris

I was trying to think how you could add even more of that element to centipede. One idea was that every time you hit a bit of centipede, it would explode and throw off a few chunks of debris that would then fall down the screen, and obviously you'd have to dodge them. This modified version of the rough demo (see above) shows what I mean. It actually has a double effect: shooting the centipede is even more satisfying!

http://www.btinternet.com/~daniel_earwicker/daniel/centipede2.zip

(I had to make it use DirectX to make it fast enough. It needs DirectX 7 which you should already have if you're running Windows 2000.)

Oh, I forgot, the keys are:

Joystick support?! Huh??

This probably doesn't give the idea:

The yellowy bits are the debris flying off... doesn't really work in a still picture, does it?


CRC cards for Centipede objects, anyone?


Looking for Centipede in SanDiego

I recently (February 2003) rediscovered Centipede when I walked by Belmont Park (the mall-like thing with the rollercoaster just south of Mission Beach). I had a blast for a while and actually beat 200,000 for the first time. But the fire button contact is flaky and one of the bearings on the trackball seems to be worn: it often ignores downward motion of the ball. Does anyone know of another Centipede game in SanDiego? (The original arcade version, not a home version. I gots to have the controls.) -- BenKovitz


CategoryGame


EditText of this page (last edited October 11, 2006) or FindPage with title or text search