<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" media="screen" href="/styles/xslt/rss.xslt"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:media="http://search.yahoo.com/mrss/" xmlns:itunes="http://www.itunes.com/dtds/podcast-1.0.dtd" xmlns:c9="http://channel9.msdn.com">
<channel>
	<title>Channel 9</title>
    <atom:link rel="self" type="application/rss+xml" href="http://channel9.msdn.com/Niners/c4f.Andy/Posts/RSS"></atom:link>
    <itunes:summary></itunes:summary>
    <itunes:author>Microsoft</itunes:author>
    <itunes:subtitle></itunes:subtitle>
    <image>
      <url>http://mschnlnine.vo.llnwd.net/d1/Dev/App_Themes/C9/images/feedimage.png</url>
      <title>Channel 9</title>
      <link>http://channel9.msdn.com/Niners/c4f.Andy/Posts</link>
    </image>
    <itunes:image href=""></itunes:image>
    <itunes:category text="Technology"></itunes:category>
    <description>Channel 9 keeps you up to date with the latest news and behind the scenes info from Microsoft that developers love to keep up with. From LINQ to SilverLight – Watch videos and hear about all the cool technologies coming and the people behind them.</description>
    <link>http://channel9.msdn.com/Niners/c4f.Andy/Posts</link>
    <language>en</language>
    <pubDate>Thu, 23 May 2013 07:40:17 GMT</pubDate>
    <lastBuildDate>Thu, 23 May 2013 07:40:17 GMT</lastBuildDate>
    <generator>Rev9</generator>
    <c9:totalResults>1</c9:totalResults>
    <c9:pageCount>1</c9:pageCount>
    <c9:pageSize>25</c9:pageSize>
  <item>
      <title>Upgrade Your Game: SpaceBlitz (Visual Basic)</title>
      <description><![CDATA[<span id="c4fmetadata">
<table class="" cellspacing="0" cellpadding="1" width="100%" border="0">
<tbody>
<tr class="entry_overview">
<td class="" width="50">&nbsp;</td>
<td class=""><span class="entry_description">This article enhances Space Blitz sample application by adding new features.</span></td>
</tr>
<tr>
<td class="" colspan="2">
<div class="entry_author">The Z-man Andy Dunn</div>
<div class="entry_company"><a href="http://www.thezbuffer.com/">The Z Buffer</a></div>
<br>
<div class="entry_details"><b>Difficulty: </b><span class="entry_details_input">Intermediate</span></div>
<div class="entry_details"><b>Time Required:</b> <span class="entry_details_input">
1-3 hours</span></div>
<div class="entry_details"><b>Cost: </b><span class="entry_details_input">Free</span></div>
<div class="entry_details"><b>Software: </b><span class="entry_details_input"><a href="http://msdn.com/express/">Visual Basic or Visual C# Express Editions</a></span></div>
<div class="entry_details"><b>Hardware: </b><span class="entry_details_input"></span></div>
<div class="entry_details"><b>Download: </b>
<ul>
<li><a href="http://download.microsoft.com/download/2/d/1/2d1afc02-08ea-46d5-88e0-bbe2036b92f9/space.vsi">VB Download</a></li></ul>
</div>
</td>
</tr>
</tbody>
</table>
</span>
<p>&nbsp;</p>
<p><b>Video Demo</b></p>
<h4><a href="http://download.microsoft.com/download/3/b/a/3ba16a61-f2c1-4ab6-94b4-5a232335f95e/blitz.wmv"><img src="http://ecn.channel9.msdn.com/o9/c4fcontent/migration/916405/blitz1.gif"></a>
</h4>
<p>&nbsp;</p>
<p><a href="http://download.microsoft.com/download/3/b/a/3ba16a61-f2c1-4ab6-94b4-5a232335f95e/blitz.wmv"><img src="http://ecn.channel9.msdn.com/o9/c4fcontent/migration/916405/media6.jpg" border="0"></a>
<a href="http://download.microsoft.com/download/3/b/a/3ba16a61-f2c1-4ab6-94b4-5a232335f95e/blitz.wmv">
Download Video</a> </p>
<p><strong>Visual Basic Upgrade Your Game Series</strong></p>
<ul>
<li><a class="" href="http://msdn.microsoft.com/coding4fun/gaming/arcade/article.aspx?articleid=1727545">2D Game Primer</a>
</li><li><a href="http://msdn.microsoft.com/coding4fun/gaming/arcade/article.aspx?articleid=916341">Tiny Tennis</a>
</li><li><a href="http://msdn.microsoft.com/coding4fun/gaming/arcade/article.aspx?articleid=916405">Space Blitz</a>&nbsp;
</li><li><a href="http://msdn.microsoft.com/coding4fun/gaming/arcade/article.aspx?articleid=1044549">Crusader</a></li></ul>
<h6></h6>
<p>&nbsp;</p>
<h4>Introduction</h4>
<p>Welcome to the Upgrade Your Game series of tutorials. There are four tutorials, each covering how to write a simple computer game using Visual Studio Express products. Though the games are simple, each one teaches some game development techniques and builds
 on the last to improve your skills. The skills can be applied to more complex games including 3D games using
<a href="http://msdn.microsoft.com/directx/">Microsoft DirectX</a>. </p>
<p>You probably noticed that the animation in the previous game was not as smooth as you would have expected for such a simple game with so little going on. The main reason for this is because of my choice of picture boxes for the sprites. As I mentioned, this
 is not something that is recommended because there is a lot of overhead that comes with Windows controls. It really is overkill to use a Windows control just to draw a rectangle or any other graphic on the screen. However, it served its purpose for making
 a simple game with only a few lines of code. </p>
<p>For the third game you will take on another classic, a Space Invaders type game. Because this game has sprites that are very clearly not rectangles, and because there are a lot more of them to draw, this example will implement the sprites using bitmap graphics.
</p>
<p>Since most developers are not graphically inclined, this is the time that your game development team needs to grow. Most games these days use graphics that are far more complex than the original
<a href="http://www.klov.com/game_detail.php?letter=&amp;game_id=9662">Space Invaders</a> or
<a href="http://www.klov.com/game_detail.php?letter=&amp;game_id=10816">Pac-man</a> and it's just not realistic to create them yourself. You may be lucky enough to find some royalty-free artwork on the Internet, but if you intend to sell your game, be sure to check
 the specific licensing for that artwork. The safest thing to do, if you are not rich enough to hire someone to produce your art, is to make friends with someone who can.
</p>
<p><b>Note:</b> This documentation assumes that you have a basic knowledge of programming concepts and the Visual Basic environment. You can learn more about these topics in the product documentation by clicking
<b>Help</b> on the menu bar, and then clicking <b>Contents</b>, <b>Index</b>, or <b>
Search</b>. You can also access Help by positioning the mouse cursor on language keywords or user interface elements such as windows or dialog boxes, and pressing F1.
</p>
<h4>Getting Started</h4>
<h5>Building and running SpaceBlitz</h5>
<p>Once your project is loaded into the Visual Basic environment, you can compile and run the program in one step.
</p>
<p>To build and run SpaceBlitz: </p>
<ul>
<li>Press F5 to build and start the game under the debugger. </li></ul>
<p>The game launches and you can control the base ship using the left and right arrows. Use the spacebar to fire.
</p>
<h4>Files</h4>
<ul>
<li><b>Alien.vb<br>
</b>Inherits from Sprite. Represents a single alien. </li><li><b>Aliens.vb</b><br>
Inherits from GameObject. Represents the group of aliens. Movement of aliens is done as a group. This file also has routines that work on the whole group such as random selection of an alien to drop a bomb.
</li><li><b>Base.vb<br>
</b>Inherits from Sprite. Represents the bases you can shelter behind. Contains routine for per pixel collision and erosion of the bases.
</li><li><b>BaseShip.vb</b><br>
Inherits from Sprite. Represents the ship. Contains routines for movement controlled by the keyboard.
</li><li><b>Bomb.vb<br>
</b>Inherits from Sprite. Represents bombs. Contains code for collision detection.
</li><li><b>GameObject.vb<br>
</b>Abstract base class that represents an object that requires updating and drawing once per frame.
</li><li><b>GameState.vb</b><br>
Stores the current state of the game and controls all gameplay. </li><li><b>Keyboard.vb<br>
</b>Static class that stores the current up/down state of the control keys. </li><li><b>Missile.vb</b><br>
Inherits from Sprite. Represents missiles. Contains code for collision detection.
</li><li><b>PointFMath.vb<br>
</b>Helper routines for common PointF calculations not included in the PointF class.
</li><li><b>Saucer.vb</b><br>
Inherits from Sprite. Represent the bonus flying saucer. </li><li><b>SpaceBlitz.vb<br>
</b>The main display form. Other than UI initialization and keyboard events, little gameplay code is performed in here. Most code calls into GameState.
</li><li><b>Sprite.vb</b><br>
Inherits from GameObject. Handles basic 2D sprite manipulation and loading.</li></ul>
<h4><br>
Game Development Concepts</h4>
<p>If you are new to 2D game development, check out the <a href="http://msdn.microsoft.com/coding4fun/gamedevelopment/2DPrimervb/default.aspx">
2D Game Primer (Visual Basic)</a>. </p>
<h5><b>Bitmap Sprites</b></h5>
<p>Drawing a <a href="http://msdn2.microsoft.com/en-us/library/system.drawing.bitmap(VS.80).aspx">
bitmap</a> to the screen only requires a few lines of code. Using the code from the TinyTennis sample, you can add a new member variable to store the bitmap and a new constructor that takes the file name of the bitmap file. The
<a href="http://msdn2.microsoft.com/en-us/library/0cbhe98f(VS.80).aspx">bitmap constructor</a> takes a file name, which means it's very easy to load and store.
</p>
<pre><code></code></pre>
<pre class="csharpcode"><span class="kwrd"></span><span class="kwrd">Protected</span> _frame <span class="kwrd">As</span> Bitmap<br><span class="kwrd">Public</span> <span class="kwrd">Sub</span> <span class="kwrd">New</span>(<span class="kwrd">ByVal</span> gameState <span class="kwrd">As</span> GameState, <span class="kwrd">ByVal</span> x <span class="kwrd">As</span> <span class="kwrd">Single</span>, <span class="kwrd">ByVal</span> y <span class="kwrd">As</span> <span class="kwrd">Single</span>, <br>       <span class="kwrd">ByVal</span> filename <span class="kwrd">As</span> <span class="kwrd">String</span>)<br>    <span class="rem">'Load the bitmap</span><br>    _frame = <span class="kwrd">New</span> Bitmap(filename)<br><span class="kwrd">End</span> Sub</pre>
<style type="text/css">
<!--
.csharpcode, .csharpcode 
	{font-size:small;
	color:black;
	font-family:consolas,"Courier New",courier,monospace;
	background-color:#ffffff}
.csharpcode 
	{margin:0em}
.csharpcode .rem
	{color:#008000}
.csharpcode .kwrd
	{color:#0000ff}
.csharpcode .str
	{color:#006080}
.csharpcode .op
	{color:#0000c0}
.csharpcode .preproc
	{color:#cc6633}
.csharpcode .asp
	{background-color:#ffff00}
.csharpcode .html
	{color:#800000}
.csharpcode .attr
	{color:#ff0000}
.csharpcode .alt
	{background-color:#f4f4f4;
	width:100%;
	margin:0em}
.csharpcode .lnum
	{color:#606060}
-->
</style>
<p>Drawing the bitmap is almost as trivial. Drawing to a Windows Form is done using the GDI graphics API, which is contained in the
<a href="http://msdn2.microsoft.com/en-us/library/system.drawing.aspx">System.Drawing namespace</a>. All GDI drawing is done to a
<a href="http://msdn2.microsoft.com/en-us/library/system.drawing.graphics(VS.80).aspx">
Graphics</a> object. This means that you have to provide the graphics object to the Sprite.Draw call. Fortunately, the Paint event gets the Graphics object for the window as part of its EventArgs, so this turns out to be simple to get hold of. Drawing the bitmap
 to the graphics surface is also a single line of code using the <a href="http://msdn2.microsoft.com/en-us/library/system.drawing.graphics.drawimage(VS.80).aspx">
DrawImage</a> method. </p>
<pre><code></code></pre>
<pre class="csharpcode"><span class="kwrd">Public</span> <span class="kwrd">Overrides</span> <span class="kwrd">Sub</span> Draw(<span class="kwrd">ByVal</span> graphics <span class="kwrd">As</span> Graphics)<br>    <span class="rem">'Draw the correct frame at the current point</span><br>    graphics.DrawImage(_frame, Location.X, Location.Y, Size.Width, Size.Height)<br><span class="kwrd">End</span> Sub</pre>
<style type="text/css">
<!--
.csharpcode, .csharpcode 
	{font-size:small;
	color:black;
	font-family:consolas,"Courier New",courier,monospace;
	background-color:#ffffff}
.csharpcode 
	{margin:0em}
.csharpcode .rem
	{color:#008000}
.csharpcode .kwrd
	{color:#0000ff}
.csharpcode .str
	{color:#006080}
.csharpcode .op
	{color:#0000c0}
.csharpcode .preproc
	{color:#cc6633}
.csharpcode .asp
	{background-color:#ffff00}
.csharpcode .html
	{color:#800000}
.csharpcode .attr
	{color:#ff0000}
.csharpcode .alt
	{background-color:#f4f4f4;
	width:100%;
	margin:0em}
.csharpcode .lnum
	{color:#606060}
-->
</style>
<p>All of the movement code comes right across from the TinyTennis sample. The aliens move based on a velocity assigned to them. The base ship moves based on a velocity set by the user pressing keys on the keyboard. Once a velocity is set, the Sprite base class
 will continue to animate as time goes by. In addition, the rectangle collision code can be used to check for collisions between missile, aliens, base ships, and saucers. Reuse is great!
</p>
<h5><b>Animating Sprites by Flipping the Image</b> </h5>
<p>Animation isn't just about moving things around the screen. Our aliens need to waggle their arms, legs, and antennae. If you look in the graphics folder, you will see that the artist provided two poses for each alien. To get the animation effect, you simply
 have to draw the images one after the other. Since this game only has two frames of animation, I have created a constructor that takes the two file names and stores them in a list of bitmaps. If you are new to .NET 2.0,
<a href="http://msdn2.microsoft.com/en-us/library/system.collections.generic.aspx">
generics</a> may be new to you so you may want to go and read an <a href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnvs05/html/csharp_generics.asp">
introductory article</a>. In the Draw call a decision has to be made which frame to draw and this is done by using the CurrentFrame member variable. CurrentFrame will be set in one of the Update() methods, usually in an inherited class, depending on how fast
 or slow the animation is to be. For this game, only the aliens need image flipping animation so the member is left at its default value of 0 for all of the other sprites.
</p>
<p>Notice that just like the movement animation, the flipping speed is tied to the game time. Almost everything that happens in the Update() methods will be tied to the time, so that, no matter which machine you run on, the timing will stay exactly the same.
</p>
<pre><code></code></pre>
<pre class="csharpcode"><span class="kwrd"></span><span class="kwrd">Protected</span> _frames <span class="kwrd">As</span> List(Of Bitmap) = <span class="kwrd">New</span> List(Of Bitmap)()<br><span class="kwrd">Public</span> <span class="kwrd">Sub</span> <span class="kwrd">New</span>(<span class="kwrd">ByVal</span> gameState <span class="kwrd">As</span> GameState, <span class="kwrd">ByVal</span> x <span class="kwrd">As</span> <span class="kwrd">Single</span>, <span class="kwrd">ByVal</span> y <span class="kwrd">As</span> <span class="kwrd">Single</span>,<br>      <span class="kwrd">ByVal</span> filename1 <span class="kwrd">As</span> <span class="kwrd">String</span>, <span class="kwrd">ByVal</span> filename2 <span class="kwrd">As</span> <span class="kwrd">String</span>)<br>    <span class="rem">'Load the 2 animation frames</span><br>    _frames.Add(<span class="kwrd">New</span> Bitmap(filename1))<br>    _frames.Add(<span class="kwrd">New</span> Bitmap(filename2))<br><span class="kwrd">End</span> Sub<br><br><span class="kwrd">Public</span> <span class="kwrd">Overrides</span> <span class="kwrd">Sub</span> Draw(<span class="kwrd">ByVal</span> graphics <span class="kwrd">As</span> Graphics)<br>    <span class="rem">'Draw the correct frame at the current point</span><br>    graphics.DrawImage(_frames(CurrentFrame), Location.X, Location.Y, Size.Width, Size.Height)<br><span class="kwrd">End</span> <span class="kwrd">Sub</span> </pre>
<style type="text/css">
<!--
.csharpcode, .csharpcode 
	{font-size:small;
	color:black;
	font-family:consolas,"Courier New",courier,monospace;
	background-color:#ffffff}
.csharpcode 
	{margin:0em}
.csharpcode .rem
	{color:#008000}
.csharpcode .kwrd
	{color:#0000ff}
.csharpcode .str
	{color:#006080}
.csharpcode .op
	{color:#0000c0}
.csharpcode .preproc
	{color:#cc6633}
.csharpcode .asp
	{background-color:#ffff00}
.csharpcode .html
	{color:#800000}
.csharpcode .attr
	{color:#ff0000}
.csharpcode .alt
	{background-color:#f4f4f4;
	width:100%;
	margin:0em}
.csharpcode .lnum
	{color:#606060}
-->
</style>
<h5><b>Per Pixel Collisions</b> </h5>
<p>For the bases, checking the rectangle as you did in TinyTennis will not be sufficient because the shapes need to slowly get destroyed by the base ships' bullets and the aliens' missiles. This means that the shape to collide against becomes non-rectangular
 very quickly. In this case, it's necessary to check the bitmap itself to see if the bullet has hit a non-black pixel. For a perfect collision, you need to check every pixel of the first sprite against the second sprite which, as you can imagine, gets slow
 very quickly. So, just like the bounding shape checks were an approximation to the perfect check, you can look for other ways to approximate this kind of collision. Since you know that our bullets only move in the Y direction, there is no need to check for
 anything other than the leading edge of the bullet, which cuts the pixel checks down to 6 pixels. But what if you just check the 2 leading corner pixels? You would miss any collisions that happen between them, but that's just 4 pixels and, for this game, this
 is an acceptable performance/accuracy trade off. </p>
<pre class="csharpcode"><span class="kwrd"></span><span class="kwrd">Public</span> <span class="kwrd">Function</span> CheckPixel(<span class="kwrd">ByVal</span> point <span class="kwrd">As</span> PointF) <span class="kwrd">As</span> <span class="kwrd">Boolean</span><br>    <span class="rem">'Check this pixel and one 6 to its right (the size of missiles and bombs) to see if we have hit anything</span><br>    <span class="kwrd">Return</span> (isPixelOpaque(<span class="kwrd">CInt</span>(point.X - Location.X), <span class="kwrd">CInt</span>(point.Y - Location.Y)) _     <br>         <span class="kwrd">OrElse</span> isPixelOpaque(<span class="kwrd">CInt</span>(point.X - Location.X &#43; 6), <span class="kwrd">CInt</span>(point.Y - Location.Y)))<br><span class="kwrd">End</span> <span class="kwrd">Function</span><br><br><span class="kwrd">Private</span> <span class="kwrd">Function</span> isPixelOpaque(<span class="kwrd">ByVal</span> x <span class="kwrd">As</span> <span class="kwrd">Integer</span>, <span class="kwrd">ByVal</span> y <span class="kwrd">As</span> <span class="kwrd">Integer</span>) <span class="kwrd">As</span> <span class="kwrd">Boolean</span><br>    <span class="rem">'If the pixel is out of range that counts as black</span><br>    <span class="kwrd">If</span> x &lt; 0 <span class="kwrd">OrElse</span> x &gt; _frames(0).Width - 1 <span class="kwrd">OrElse</span> y &lt; 0 <span class="kwrd">OrElse</span> y &gt; _frames(0).Height - 1 <span class="kwrd">Then</span><br>    <span class="kwrd">Return</span> <span class="kwrd">False</span><br>    <span class="kwrd">End</span> <span class="kwrd">If</span><br>    <span class="rem">'Otherwise check for anything that is not black</span><br>    <span class="kwrd">Return</span> (_frames(0).GetPixel(x, y) &lt;&gt; Color.FromArgb(0, 0, 0))<br><span class="kwrd">End</span> Function<br><br>  [from Aliens.Update()]<br>sprite.CurrentFrame = <span class="kwrd">CInt</span>(Int(((gameTime * _speed) / 50.0F) <span class="kwrd">Mod</span> 2.0F))</pre>
<style type="text/css">
<!--
.csharpcode, .csharpcode 
	{font-size:small;
	color:black;
	font-family:consolas,"Courier New",courier,monospace;
	background-color:#ffffff}
.csharpcode 
	{margin:0em}
.csharpcode .rem
	{color:#008000}
.csharpcode .kwrd
	{color:#0000ff}
.csharpcode .str
	{color:#006080}
.csharpcode .op
	{color:#0000c0}
.csharpcode .preproc
	{color:#cc6633}
.csharpcode .asp
	{background-color:#ffff00}
.csharpcode .html
	{color:#800000}
.csharpcode .attr
	{color:#ff0000}
.csharpcode .alt
	{background-color:#f4f4f4;
	width:100%;
	margin:0em}
.csharpcode .lnum
	{color:#606060}
-->
</style>
<pre><code>.....</code></pre>
<h5><b>Destroying Bitmaps</b> </h5>
<p>Now that you can collide on a per pixel basis with the bases, the sprites need to be updated so that they appear to get damaged over time. It's important to do this not just because you draw the sprites in every frame, but because a user could switch applications
 or minimize the game. When the game is restored, you need to be able to redraw the whole screen.
</p>
<p>Since each sprite stores its own copy of the bitmap, it's possible for the Base sprite to set certain pixels within itself to black so that they slowly get removed. Setting the pixels to black means that any future missile will not pass the per pixel test.
 For this game, I have chosen to draw a black circle of a random radius at the point of collision.
</p>
<pre><code></code></pre>
<pre class="csharpcode"><span class="kwrd"></span><span class="kwrd">Public</span> <span class="kwrd">Sub</span> Erode(<span class="kwrd">ByVal</span> point <span class="kwrd">As</span> PointF)<br>    <span class="rem">'Draw a black circle in the bitmap over the point of intersection</span><br>    Using graphics <span class="kwrd">As</span> Graphics = Drawing.Graphics.FromImage(_frames(0))<br>        graphics.FillEllipse(Brushes.Black, point.X - Location.X - _sizeX / 2 &#43; 3, <br>             point.Y - Location.Y - _sizeY / 2, _sizeX, _sizeY)<br>    <span class="kwrd">End</span> Using<br><span class="kwrd">End</span> <span class="kwrd">Sub</span> </pre>
<style type="text/css">
<!--
.csharpcode, .csharpcode 
	{font-size:small;
	color:black;
	font-family:consolas,"Courier New",courier,monospace;
	background-color:#ffffff}
.csharpcode 
	{margin:0em}
.csharpcode .rem
	{color:#008000}
.csharpcode .kwrd
	{color:#0000ff}
.csharpcode .str
	{color:#006080}
.csharpcode .op
	{color:#0000c0}
.csharpcode .preproc
	{color:#cc6633}
.csharpcode .asp
	{background-color:#ffff00}
.csharpcode .html
	{color:#800000}
.csharpcode .attr
	{color:#ff0000}
.csharpcode .alt
	{background-color:#f4f4f4;
	width:100%;
	margin:0em}
.csharpcode .lnum
	{color:#606060}
-->
</style>
<h5><b>Gameplay</b> </h5>
<p>The gameplay here, though not as advanced as in any modern game, is still something that needs to be managed properly. The game needs to be able to detect when all of the aliens are destroyed and recreate a new wave of aliens; it needs to randomly select
 an alien to drop a missile; and it needs to randomly add the bonus flying saucer to the screen.
</p>
<p>If you are not careful with your code structure you will find that these sorts of tasks get randomly scattered around your code. For this game, I have chosen to encapsulate as much of this logic in one place: the GameState class. In the TinyTennis sample,
 this was used to store the scores, but in this game you will use it to store the scores, the level, whether you are currently dropping a missile, how many aliens are left, and several other things that pertain to the current state of the game.
</p>
<p>You will also remember that for the collisions in TinyTennis you had to pass in references to the bats to the Ball object. Obviously this isn't something that is scalable beyond a handful of objects, so for this game the GameState class stores collections
 of all of the game objects and is passed into each object during creation. This means any object has access to any other object if it needs to query it for collisions or any other reason.
</p>
<p>Take a look at the GameState object (there is too much code to post in the tutorial), and see how all the mechanics of the game play function.
</p>
<h4>Extending SpaceBlitz</h4>
<ul>
<li>Make some of the aliens detach themselves from the formation and fly down as in the arcade game
<a href="http://www.klov.com/game_detail.php?letter=&amp;game_id=7885">Galaxian</a> and others.
</li><li>Add a second base ship controlled by a second player for a cooperative experience.
</li><li>Go back to TinyTennis and change it to use bitmaps for the sprites rather than the Windows controls.
</li><li>Add a high-score table and save the high scores so that they are remembered next time you play.
</li></ul>
 <img src="http://m.webtrends.com/dcs1wotjh10000w0irc493s0e_6x1g/njs.gif?dcssip=channel9.msdn.com&dcsuri=http://channel9.msdn.com/Niners/c4f.Andy/Posts/RSS&WT.dl=0&WT.entryid=Entry:RSSView:9c31153d24f542c7b8179e7600da2432">]]></description>
      <comments>http://channel9.msdn.com/coding4fun/articles/Upgrade-Your-Game-SpaceBlitz-Visual-Basic</comments>
      <itunes:summary>



&amp;nbsp;
This article enhances Space Blitz sample application by adding new features.



The Z-man Andy Dunn
The Z Buffer

Difficulty: Intermediate
Time Required: 
1-3 hours
Cost: Free
Software: Visual Basic or Visual C# Express Editions
Hardware: 
Download: 

VB Download






&amp;nbsp; 
Video Demo 


&amp;nbsp; 


Download Video  
Visual Basic Upgrade Your Game Series 

2D Game Primer
Tiny Tennis
Space Blitz&amp;nbsp;
Crusader

&amp;nbsp; 
Introduction
Welcome to the Upgrade Your Game series of tutorials. There are four tutorials, each covering how to write a simple computer game using Visual Studio Express products. Though the games are simple, each one teaches some game development techniques and builds
 on the last to improve your skills. The skills can be applied to more complex games including 3D games using
Microsoft DirectX.  
You probably noticed that the animation in the previous game was not as smooth as you would have expected for such a simple game with so little going on. The main reason for this is because of my choice of picture boxes for the sprites. As I mentioned, this
 is not something that is recommended because there is a lot of overhead that comes with Windows controls. It really is overkill to use a Windows control just to draw a rectangle or any other graphic on the screen. However, it served its purpose for making
 a simple game with only a few lines of code.  
For the third game you will take on another classic, a Space Invaders type game. Because this game has sprites that are very clearly not rectangles, and because there are a lot more of them to draw, this example will implement the sprites using bitmap graphics.
 
Since most developers are not graphically inclined, this is the time that your game development team needs to grow. Most games these days use graphics that are far more complex than the original
Space Invaders or
Pac-man and it&#39;s just not realistic to create them yourself. You may be lucky enough to find some royalty-free artwork on the</itunes:summary>
      <link>http://channel9.msdn.com/coding4fun/articles/Upgrade-Your-Game-SpaceBlitz-Visual-Basic</link>
      <pubDate>Tue, 31 Oct 2006 23:14:00 GMT</pubDate>
      <guid isPermaLink="false">http://channel9.msdn.com/coding4fun/articles/Upgrade-Your-Game-SpaceBlitz-Visual-Basic</guid>
      <media:thumbnail url="http://ecn.channel9.msdn.com/o9/c4f/images/916405_100.jpg" height="75" width="100"></media:thumbnail>
      <media:thumbnail url="http://ecn.channel9.msdn.com/o9/c4f/images/916405_220.jpg" height="165" width="220"></media:thumbnail>      
      <dc:creator>Andy</dc:creator>
      <itunes:author>Andy</itunes:author>
      <slash:comments>5</slash:comments>
      <wfw:commentRss>http://channel9.msdn.com/coding4fun/articles/Upgrade-Your-Game-SpaceBlitz-Visual-Basic/RSS</wfw:commentRss>
    </item>    
</channel>
</rss>