You can use your favorite social network to register or link an existing account:
Or use your email address to register without a social network:
Sign in with these social networks:
Or enter your username and password
Forgot your password?
Yes, please link my existing account with for quick, secure access.
No, I would like to create a new account with my profile information.
This blog post is brought to you by Karen Cheng a Program Manager on the Excel team.
In today's post, we'll show you how the classic arcade game Missile Command was created in an Excel spreadsheet. We also explain how it's made in this video. In this game, missiles drop from the sky, attacking the city. You must click on the missiles to destroy them.
To play, you'll need -
· To download the game (here)
· To install Excel 2010, hot off the press last week. You can get a free trial here. The games use features that are new to Excel 2010, so they won't work in older versions.
When you open the file to play, don't forget to enable the macros.
The Graphics Engine
The "graphics engine" is made entirely with conditional formatting. Each cell, which represents a pixel, has a number in between 1-10 to represent a shade of grey.
You can't actually see the numbers because the cells have been shrunken down, but enlarge the cells a bit and you'll see the numbers behind the "pixels":
The numbers behind the graphics engine
The entire game runs from a macro that is triggered by clicking on Start. The macro constantly recalculates what numbers to populate the grid with.
Calculating Missile Paths
Each missile runs through this series of calculations:
1. The starting point for the missile is chosen to be somewhere at random at the top of the screen
2. Each missile will at random choose one of the remaining standing buildings to target. It chooses one cell in the general perimeter of the building
3. Based on the starting and ending cell, the slope of the path the missile is calculated, such that it travels at the correct X to Y (column to row) ratio
4. The macro then repopulates the cells in the path over and over again in a loop to "draw" the missile path
5. If the missile hits the building, the game notes which building has been destroyed. The cells around the building are redrawn to the "destroyed building" state and the missile is removed.
Destroying the Missiles
Missiles are destroyed by clicking and creating a shield, which looks like an explosion effect. If the shield and missile collide, the missile is destroyed.
1. To detect the gamer's click, the macro detects when the cell selection changes. If the new cell selection is within the playable game area, the shield is drawn.
2. To draw the shield, the macro quickly draws and redraws six frames in sequence
The shield explosion effect, frame by frame.
3. If any part of the shield and missile occupy the same cell, the missile's path is aborted and the missile is destroyed. If any part of the shield occupies a cell occupied by a standing building, that building is destroyed.
General Gameplay
When a missile is destroyed, another one is instantly created. The number of missiles on the screen at any given time corresponds to the level. So at level 5, there will be 5 missiles on the screen at once.
The progress bar indicating how far the gamer is along a level is value in a cell formatted by a data bar.
The level progress indicator
Formatted by data bars
One more thing - you can peek behind the code (and hack away to your heart's desire) by pressing Alt-F8 and clicking edit.
The code behind the scenes
Thanks for tuning into this episode of How It's Made. In the next edition, we'll show you how the classic arcade game Tower Defense is made in Excel.
Comments: (4) Collapse
seems good, doesn't fit on my screen though.
Cool! I have an Excel 2003 sheet I created that colors cells to draw the Mandelbrot fractal. You can select a range of cells and have it recalculate to zoom in. I found it amusing to "misuse" Excel by turning the cells into pixels.
I started using the technique a long time ago while developing a machine vision target finding method in VB6. I ported the code to Excel VBA and colored the cells to show the source image then I ran my macro and it colored cell borders to indicate where it thought edges were then "drew" the target on the cells. It was a bit hacky but it sure sped up development because of the high level of feedback. It's a lot easier to look at a cell data value than to poke around in 2D arrays, especially back in the VB6 days when we didn't have nice array visualizers.
Wow, great! So now you have finished creating some games for Excel, how about you get back to the work you are presumably paid for, and put back all of the useful features which you have removed?!
Thanks in advance.
Daniel: I'm guessing someone did this for fun in their spare time.
Comments: (loading) Collapse