July 18, 2010
Time to bring the asteroids series to a conclusion. Let’s finish the game and make it a bit more interesting in this tenth and final part.
Right now when you shoot an asteroid it blows up and dissapears, but more often than not this would cause the asteroid to break into multiple fragments. Let’s modify the game and break up the asteroid into multiple parts when it gets shot.
June 27, 2010
The spaceship is armed and can blast away at the asteroids. But as it stands now, the asteroids just disappear when they are hit by a bullet. Let’s put a cool explosion effect in the game.
To make this happen we’ll have to introduce an animated sprite into the game which simulates an explosion. Download the source code for part 8, open it in Visual Studio 2010 and let’s blow some stuff up.
Time to put the last finishing touches on the collision detection algorithm that we introduced in the last part of this series. The current algorithm that is in place functions correctly but sometimes you get a feeling that something is not quite right.
At the moment each sprite has a bounding rectangle and when one sprite’s bounding rectangle intersects with another sprite’s bounding rectangle we flag it as a collission. An image says more than a thousand words, so let’s see what can go wrong with this approach.
Figure 1 – Intersecting Bounding Rectangles
As you can see the sprites bounding rectangles intersect, but the spaceship and asteroid do not actually collide with each other. Let’s see how we can improve on this design.
May 24, 2010
In the last part of this series we finally armed the spaceship. It is now able to fire bullets. However nothing happens when a bullet hits one of the asteroids or if one of the asteroids hits the spaceship. Let’s add some simple collision detection algorithm that notifies us when such crashes occur.
Let’s get started…
May 7, 2010
In the previous part we finally added some asteroids to the game. Those pesky rocks are now floating around in space, at record breaking speed, forming a major risk for our spaceship!
Time to arm the spaceship so it can defend itself. A gun loaded with high-velocity, copper-plated, hollow-point bullets will do the trick.
Just like a spaceship or an asteroid a bullet represents a sprite in the game. To weaponize the spaceship, you’ll need to follow the exact same steps as you went through earlier in part 2 and 5.
Let’s get started…
May 3, 2010
We’re already at part 5 of the Silverlight Asteroids series. This time, you’ll finally get to hurl some asteroids into space. Just like the spaceship, an asteroid is a sprite. If you remember “Part 2: Sprites“, then you’ll know that in order to add a new sprite to the game you’ve got to follow these steps:
- Add a new Silverlight User Control
- Make sure the user control implements the ISpriteDesign interface (or a descendant)
- Add a new class descending from the abstract Sprite class
- Create a new instance of the sprite and pass in the correct user control as the design of the sprite
If this does not ring a bell, have a quick peek at part 2 first. Without further talk, let’s walk through each of these steps.
May 1, 2010
In the previous part, you finally gained control over your spaceship. Using the arrow keys on the keyboard you are now able to navigate the spaceship anywhere you want.
This Silverlight application has a canvas of 1024 x 768 pixels as its RootVisual, which represents space. As it stands now, your spaceship is allowed to cross the boundaries of this canvas. In this part of the series you’ll find out how you can make the spaceship reappear on the other side of the canvas.