<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/atom10full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><feed xmlns="http://www.w3.org/2005/Atom" xmlns:openSearch="http://a9.com/-/spec/opensearch/1.1/" xmlns:georss="http://www.georss.org/georss" xmlns:gd="http://schemas.google.com/g/2005" xmlns:thr="http://purl.org/syndication/thread/1.0" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" gd:etag="W/&quot;D0ECQ387eSp7ImA9WhRaE0U.&quot;"><id>tag:blogger.com,1999:blog-1891129859130768227</id><updated>2012-02-16T10:47:42.101+01:00</updated><category term="images" /><category term="Random" /><category term="i/o" /><category term="points" /><category term="data type" /><category term="loop" /><category term="icons" /><category term="list" /><category term="pythagoras" /><category term="development" /><category term="picture box" /><category term="conversion" /><category term="events" /><category term="top list" /><category term="game-dev" /><category term="pause" /><category term="form" /><category term="grid" /><category term="string" /><category term="Image list" /><category term="download" /><category term="timer" /><category term="rectangle" /><category term="2D" /><category term="animation" /><category term="function" /><category term="write" /><category term="bonus" /><category term="file" /><category term="sort" /><category term="math" /><category term="speed" /><category term="level" /><category term="gameplay" /><category term="express edition" /><category term="programming" /><category term="field" /><category term="pad" /><category term="graphics" /><category term="game field" /><category term="gravity" /><category term="font" /><category term="game" /><category term="button" /><category term="properties" /><category term="visual studio" /><category term="C#" /><category term="high score" /><category term="read" /><category term="welcome" /><category term="source code" /><category term="design" /><category term="GDI+" /><category term="destroying fields" /><category term="new game" /><category term="label" /><category term="score" /><title>Game Development Tutorials</title><subtitle type="html">Game Development &amp;amp; Programming Tutorials for absolute begginers.</subtitle><link rel="http://schemas.google.com/g/2005#feed" type="application/atom+xml" href="http://create-your-game.blogspot.com/feeds/posts/default" /><link rel="alternate" type="text/html" href="http://create-your-game.blogspot.com/" /><link rel="next" type="application/atom+xml" href="http://www.blogger.com/feeds/1891129859130768227/posts/default?start-index=26&amp;max-results=25&amp;redirect=false&amp;v=2" /><author><name>Marin Malnar</name><uri>http://www.blogger.com/profile/12164590973052924670</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="26" height="32" src="http://1.bp.blogspot.com/_4WDpsfty9mg/ShhOIFmmh4I/AAAAAAAAARo/bKSb8UiTYTw/S220/drawing_biker.jpg" /></author><generator version="7.00" uri="http://www.blogger.com">Blogger</generator><openSearch:totalResults>26</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/atom+xml" href="http://feeds.feedburner.com/GameDevelopmentTutorials" /><feedburner:info uri="gamedevelopmenttutorials" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><entry gd:etag="W/&quot;DUYGQ349fyp7ImA9WxJVFEk.&quot;"><id>tag:blogger.com,1999:blog-1891129859130768227.post-7332769339390855074</id><published>2009-07-01T12:02:00.010+02:00</published><updated>2009-07-01T13:18:42.067+02:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2009-07-01T13:18:42.067+02:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="GDI+" /><category scheme="http://www.blogger.com/atom/ns#" term="images" /><category scheme="http://www.blogger.com/atom/ns#" term="animation" /><category scheme="http://www.blogger.com/atom/ns#" term="graphics" /><category scheme="http://www.blogger.com/atom/ns#" term="C#" /><category scheme="http://www.blogger.com/atom/ns#" term="pythagoras" /><category scheme="http://www.blogger.com/atom/ns#" term="math" /><title>26. Pythagoras, Firefighers and Math</title><content type="html">The last and, in my oppinion, the coolest part of this tutorial is making our doggy splash water from his fire-hose. There are a lot of ways to do this… My first idea was to make him splash a stream of water in a horizontal line… But I wasn't satisfied. Then, i figured out how to make him splash wather at an angle… But that didn't make me satisfied either. Then I decided to renew my high school math knowlege, and to force this dog to splash water to the exact point where the player would click the mouse… And, how does this look in theory? Here's a drawing…&lt;br /&gt;&lt;br /&gt; &lt;img style="display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;width: 400px; height: 297px;" src="http://4.bp.blogspot.com/_4WDpsfty9mg/Sks0qKQWHZI/AAAAAAAAAag/cV3Tv3_mMLI/s400/26_1_Splash_Theory.png" border="0" alt="" id="BLOGGER_PHOTO_ID_5353430480972029330" /&gt;&lt;br /&gt;&lt;p&gt;Here's a little legend: Point B is the point where player clicked. Point A is the starting point of the splash. So, that makes the blue line c our splash. Angle alpha is the angle of the splash. It can be positive, or negative. So, how can we figure out the lenght of the splash (c), and it's angle (alpha)??? Just a little math. Our points are defined with x and y coordinates. So, if we know the horizontal coordinate for B, and the width of our game field, then we know the lenght of the red line b. And on the same priciple, we can find the lenght of the red line a. Calculating splash lenght c is just a matter of Pythagoras. Remember that jibberish your math teacher filled your hed with? I hate to admit it, but, it came useful. So, here's the equation:&lt;/p&gt;&lt;p&gt;(Pythagoras' theorem):&lt;/p&gt;&lt;p&gt;&lt;img style="display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;width: 114px; height: 21px;" src="http://3.bp.blogspot.com/_4WDpsfty9mg/Sks8RlR_g_I/AAAAAAAAAao/6I4FURhbUwk/s400/49a65217b7d35663efc6e558c0ffdba0.png" border="0" alt="" id="BLOGGER_PHOTO_ID_5353438854822986738" /&gt;&lt;/p&gt;That's how we would write it on a peace of paper. And to make our C# understand it, we can write it like this:&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;&lt;span style="color:#3333ff;"&gt;int&lt;/span&gt; c = (&lt;span style="color:#3333ff;"&gt;int&lt;/span&gt;)&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;&lt;span style="color:#339999;"&gt;Math&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;.Sqrt(a * a + b * b); &lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;And if we have two sides of the triangle calculated, we can determine the angle with another math operation… Uff… Here's the equation:&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;img style="display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;width: 196px; height: 46px;" src="http://3.bp.blogspot.com/_4WDpsfty9mg/SktDezxulWI/AAAAAAAAAaw/gEyLWaaOJmA/s400/trig.png" border="0" alt="" id="BLOGGER_PHOTO_ID_5353446778633885026" /&gt;Again, translated into C# il would look like this:&lt;br /&gt;&lt;/p&gt;&lt;span style="font-family:courier new;"&gt;&lt;span style="color:#3333ff;"&gt;float&lt;/span&gt; alpha = (&lt;span style="color:#3333ff;"&gt;float&lt;/span&gt;)&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;&lt;span style="color:#339999;"&gt;Math&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;.Atan&lt;br /&gt;((&lt;span style="color:#3333ff;"&gt;double&lt;/span&gt;)a / (&lt;span style="color:#3333ff;"&gt;double&lt;/span&gt;)b); &lt;/span&gt;&lt;br /&gt;&lt;p&gt;&lt;/p&gt;&lt;p&gt;To rotate an image, we'll use matrix translations… More math… Ah well… So, now when we finally have everything, we can write the code. Here it is. Enjoy it, it's your last peace of code in this tutorial. &lt;/p&gt;&lt;p&gt;&lt;span style="font-family:courier new;"&gt;&lt;span style="color:#3333ff;"&gt;private void&lt;/span&gt; Splash(&lt;span style="color:#3333ff;"&gt;int&lt;/span&gt; MouseY, &lt;span style="color:#3333ff;"&gt;int&lt;/span&gt; MouseX)&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;{&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;  &lt;span style="color:#009900;"&gt;// Point A:&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;  &lt;span style="color:#339999;"&gt;Point&lt;/span&gt; pStart = &lt;span style="color:#3333ff;"&gt;new&lt;/span&gt; &lt;span style="color:#339999;"&gt;Point&lt;/span&gt;&lt;br /&gt;  (picGameField.Width - 1, 195);&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="color:#009900;"&gt;&lt;span style="font-family:courier new;"&gt;  // Calculating the lenght of the splash,&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;  // and other sides of the triangle:&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;  &lt;span style="color:#3333ff;"&gt;int&lt;/span&gt; a = (picGameField.Height - MouseX&lt;br /&gt;  - (picGameField.Height - 215));&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;  &lt;span style="color:#3333ff;"&gt;int&lt;/span&gt; b = (picGameField.Width - MouseY);&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;  &lt;span style="color:#3333ff;"&gt;int&lt;/span&gt; c = (&lt;span style="color:#3333ff;"&gt;int&lt;/span&gt;)&lt;span style="color:#339999;"&gt;Math&lt;/span&gt;.Sqrt(a * a + b * b);&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;  &lt;/span&gt;&lt;span style="font-family:courier new;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;  &lt;span style="color:#009900;"&gt;// Calculating the angle of the splash:&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;  &lt;span style="color:#3333ff;"&gt;float&lt;/span&gt; alpha = (&lt;span style="color:#3333ff;"&gt;float&lt;/span&gt;&lt;span style="color:#339999;"&gt;)Math&lt;/span&gt;.Atan&lt;br /&gt;  ((&lt;span style="color:#3333ff;"&gt;double&lt;/span&gt;)a / (&lt;span style="color:#3333ff;"&gt;double&lt;/span&gt;)b);&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;  &lt;/span&gt;&lt;span style="font-family:courier new;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;  &lt;span style="color:#009900;"&gt;// Convert from Radians to Degrees&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;  alpha = alpha * (&lt;span style="color:#3333ff;"&gt;float&lt;/span&gt;)(180.0 / &lt;span style="color:#009900;"&gt;Math&lt;/span&gt;.PI);&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;  &lt;/span&gt;&lt;span style="font-family:courier new;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;  &lt;span style="color:#3333ff;"&gt;int&lt;/span&gt; x = picGameField.Width - c;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;  &lt;span style="color:#3333ff;"&gt;int&lt;/span&gt; y = 195;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;  &lt;span style="color:#009900;"&gt;// Defining the position of our splash image:&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;  &lt;span style="color:#339999;"&gt;Rectangle&lt;/span&gt; rSplash = &lt;span style="color:#3333ff;"&gt;new&lt;/span&gt; &lt;span style="color:#339999;"&gt;Rectangle&lt;/span&gt;(x,y,c,50);&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;  &lt;span style="color:#339999;"&gt;Graphics&lt;/span&gt; gSplash = picGameField.CreateGraphics();&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;  &lt;span style="color:#009900;"&gt;// Matrix rotations:&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;  &lt;span style="color:#339999;"&gt;Matrix&lt;/span&gt; X = &lt;span style="color:#3333ff;"&gt;new&lt;/span&gt; &lt;span style="color:#339999;"&gt;Matrix&lt;/span&gt;();&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;  X.RotateAt(alpha, pStart, &lt;span style="color:#339999;"&gt;MatrixOrder&lt;/span&gt;.Append);&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;  gSplash.Transform = X;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;  &lt;/span&gt;&lt;span style="font-family:courier new;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;  &lt;span style="color:#009900;"&gt;// Drawing our image to the screen:&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;  gSplash.DrawImage(picSplash.Image, rSplash);&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;  &lt;span style="color:#009900;"&gt;// Pause for a moment:&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;  System.Threading.&lt;span style="color:#339999;"&gt;Thread&lt;/span&gt;.Sleep(100);&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;  &lt;span style="color:#009900;"&gt;// Getting rid of our splash image:&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;  gSplash.Dispose();&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;}&lt;/span&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;Obviously, we need some mouse coordinates for this code to work... In the next (probably the last) post - I'll post the whole source code for the project. With a download link... :) I know I skipped a few parts of the code, so, you'll be able to 'grab' them from actual project files! :)&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1891129859130768227-7332769339390855074?l=create-your-game.blogspot.com' alt='' /&gt;&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/GameDevelopmentTutorials/~4/flpY6S7Y3Ws" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://create-your-game.blogspot.com/feeds/7332769339390855074/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://create-your-game.blogspot.com/2009/07/26-pythagoras-firefighers-and-math.html#comment-form" title="2 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/1891129859130768227/posts/default/7332769339390855074?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/1891129859130768227/posts/default/7332769339390855074?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/GameDevelopmentTutorials/~3/flpY6S7Y3Ws/26-pythagoras-firefighers-and-math.html" title="26. Pythagoras, Firefighers and Math" /><author><name>Marin Malnar</name><uri>http://www.blogger.com/profile/12164590973052924670</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="26" height="32" src="http://1.bp.blogspot.com/_4WDpsfty9mg/ShhOIFmmh4I/AAAAAAAAARo/bKSb8UiTYTw/S220/drawing_biker.jpg" /></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://4.bp.blogspot.com/_4WDpsfty9mg/Sks0qKQWHZI/AAAAAAAAAag/cV3Tv3_mMLI/s72-c/26_1_Splash_Theory.png" height="72" width="72" /><thr:total>2</thr:total><feedburner:origLink>http://create-your-game.blogspot.com/2009/07/26-pythagoras-firefighers-and-math.html</feedburner:origLink></entry><entry gd:etag="W/&quot;CE8DSHs_eyp7ImA9WxJXF08.&quot;"><id>tag:blogger.com,1999:blog-1891129859130768227.post-4477607651082253376</id><published>2009-06-09T08:44:00.009+02:00</published><updated>2009-06-11T14:21:19.543+02:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2009-06-11T14:21:19.543+02:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="GDI+" /><category scheme="http://www.blogger.com/atom/ns#" term="icons" /><category scheme="http://www.blogger.com/atom/ns#" term="graphics" /><category scheme="http://www.blogger.com/atom/ns#" term="rectangle" /><category scheme="http://www.blogger.com/atom/ns#" term="Image list" /><category scheme="http://www.blogger.com/atom/ns#" term="grid" /><title>25. Bubble bath</title><content type="html">&lt;p&gt;Up to now, we displayed the blocks as squares filled with color. From now on, we'll display little icon images instead. If you remember, we used rectangles to define the size, and the position for each field. And that suits us just fine! So, here's a part of our code that we wrote in chapter 7:&lt;/p&gt;&lt;p&gt;(This is a part of the code from chapter 7, method &lt;span style="font-family:courier new;"&gt;DrawField()&lt;/span&gt;)&lt;/p&gt;&lt;span style="font-family:courier new;"&gt;switch (Field[v, s])&lt;br /&gt;{&lt;br /&gt;  case 0:&lt;br /&gt;    // Draw empty field...&lt;br /&gt;    break;&lt;br /&gt;  case 1:&lt;br /&gt;&lt;/span&gt;&lt;span style="color:#009900;"&gt;&lt;span style="font-family:courier new;"&gt;    // I've decided that color #1 is Blue. So, if&lt;br /&gt;    // the field holds a value of 1 – We'll color it&lt;br /&gt;    // blue. And we'll do the same for all&lt;br /&gt;    // other colors.&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;&lt;br /&gt;    gField.FillRectangle    (Brushes.Blue, rtgField);&lt;br /&gt;    break;&lt;br /&gt;  case 2:&lt;br /&gt;&lt;/span&gt;&lt;span style="color:#009900;"&gt;&lt;span style="font-family:courier new;"&gt;    // If the field contains value 2:&lt;br /&gt;    // we'll fill it red.&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt; &lt;br /&gt;    gField.FillRectangle    (Brushes.Red, rtgField);   &lt;br /&gt;    break;  &lt;br /&gt;  case 3:   &lt;br /&gt;&lt;/span&gt;&lt;span style="color:#009900;"&gt;&lt;span style="font-family:courier new;"&gt;    // If the field contains value 3:      &lt;br /&gt;    // we'll fill it green.&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;      &lt;br /&gt;    gField.FillRectangle    (Brushes.Green, rtgField); &lt;br /&gt;    break; &lt;br /&gt;  case 4:    &lt;br /&gt;&lt;/span&gt;&lt;span style="color:#009900;"&gt;&lt;span style="font-family:courier new;"&gt;    // If the field contains value 4: &lt;br /&gt;    // we'll fill it yellow.&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;  &lt;br /&gt;    gField.FillRectangle    (Brushes.Yellow, rtgField);  &lt;br /&gt;    break;        case 5:    &lt;br /&gt;&lt;/span&gt;&lt;span style="color:#009900;"&gt;&lt;span style="font-family:courier new;"&gt;    // If the field contains value 5:   &lt;br /&gt;    // we'll fill it purple.&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;&lt;br /&gt;    gField.FillRectangle    (Brushes.Purple, rtgField);&lt;br /&gt;    break;   &lt;br /&gt;  case 6:    &lt;br /&gt;&lt;/span&gt;&lt;span style="color:#009900;"&gt;&lt;span style="font-family:courier new;"&gt;    // If the field contains value 6:  &lt;br /&gt;    // we'll fill it black.&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;  &lt;br /&gt;    gField.FillRectangle    (Brushes.Black, rtgField);    &lt;br /&gt;    break;    &lt;br /&gt;  case 7: &lt;br /&gt;&lt;/span&gt;&lt;span style="color:#009900;"&gt;&lt;span style="font-family:courier new;"&gt;    // If the field contains value 7:  &lt;br /&gt;    // we'll fill it orange.&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt; &lt;br /&gt;    gField.FillRectangle    (Brushes.Orange, rtgField);   &lt;br /&gt;    break;  &lt;br /&gt;  case 8:  &lt;br /&gt;&lt;/span&gt;&lt;span style="color:#009900;"&gt;&lt;span style="font-family:courier new;"&gt;    // If the field contains value 8:  &lt;br /&gt;    // we'll fill it gray.&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;    &lt;br /&gt;    gField.FillRectangle    (Brushes.Gray, rtgField);   &lt;br /&gt;    break;   &lt;br /&gt;  case 9:    &lt;br /&gt;&lt;/span&gt;&lt;span style="color:#009900;"&gt;&lt;span style="font-family:courier new;"&gt;    // If the field contains value 9:  &lt;br /&gt;    // we'll fill it dark blue.&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;  &lt;br /&gt;    gField.FillRectangle    (Brushes.DarkBlue, rtgField); &lt;br /&gt;    break;  &lt;br /&gt;  case 10:     &lt;br /&gt;&lt;/span&gt;&lt;span style="color:#009900;"&gt;&lt;span style="font-family:courier new;"&gt;    // If the field contains value 10:    &lt;br /&gt;    // we'll fill it pink.&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;   &lt;br /&gt;    gField.FillRectangle    (Brushes.Pink, rtgField);&lt;br /&gt;    break;    &lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;&lt;span style="color:#000099;"&gt;  default&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;:   &lt;br /&gt;&lt;/span&gt;&lt;span style="color:#009900;"&gt;&lt;span style="font-family:courier new;"&gt;    // If our program comes to this     // point of the code,&lt;br /&gt;    // something's gone wrong! ;) XD&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;  &lt;br /&gt;    break;&lt;br /&gt;}&lt;/span&gt;&lt;br /&gt;&lt;p&gt;We'll replace that FillRectangle statement with a new one: DrawImage. But before we do that, we have to store our images somewhere. And, lucky us, there is a control made just for that. Go to your toolbox, and find the Components group. In there you'll find the ImageList control. Double-click it, and it will apear next to your timers. Nice. Set the properties like this:&lt;/p&gt;&lt;p&gt;&lt;strong&gt;&lt;span style="color:#009900;"&gt;ImageList&lt;/span&gt;&lt;/strong&gt;&lt;/p&gt;&lt;ul&gt;&lt;li&gt;&lt;span style="color:#ff6600;"&gt;(name):&lt;/span&gt;&lt;strong&gt;&lt;span style="color:#000000;"&gt;ilTiles&lt;/span&gt;&lt;/strong&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="color:#ff6600;"&gt;ColorDepth:  &lt;/span&gt;&lt;strong&gt;&lt;span style="color:#000000;"&gt;Depth32Bit&lt;/span&gt;&lt;/strong&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="color:#ff6600;"&gt;TransparencyColor:  &lt;/span&gt;&lt;strong&gt;&lt;span style="color:#000000;"&gt;Web &gt; Transparent&lt;/span&gt;&lt;/strong&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="color:#ff6600;"&gt;Images:  &lt;/span&gt;&lt;span style="color:#000000;"&gt;&lt;em&gt;[Load 10 different bubble images]&lt;/em&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="color:#ff6600;"&gt;ImageSize:  &lt;/span&gt;&lt;strong&gt;&lt;span style="color:#000000;"&gt;32; 32&lt;/span&gt;&lt;/strong&gt;&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;Now, add add our bubble graphics files into the list. You can reorder them however you want. After all, we'll display the right picture by calling it's index number. Ready? Ok… Here is the revised code for the Switch in the 'DrawField()' method. See the difference? Nice… How about trying it out?&lt;/p&gt;&lt;p&gt;&lt;span style="font-family:courier new;"&gt;switch (Field[v, s]) &lt;br /&gt;{         &lt;br /&gt;  case 0:      &lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;&lt;span style="color:#009900;"&gt;    //Draw empty field...&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;     &lt;br /&gt;    break;             &lt;br /&gt;  case 1:       &lt;br /&gt;    gField.DrawImage    (ilTiles.Images[0], rtgField);          &lt;br /&gt;    break;          &lt;br /&gt;  case 2:            &lt;br /&gt;    gField.DrawImage    (ilTiles.Images[1], rtgField);                 &lt;br /&gt;    break;                &lt;br /&gt;  case 3:                      &lt;br /&gt;    gField.DrawImage    (ilTiles.Images[2], rtgField);           &lt;br /&gt;    break;             &lt;br /&gt;  case 4:                    &lt;br /&gt;    gField.DrawImage    (ilTiles.Images[3], rtgField);         &lt;br /&gt;    break;                   &lt;br /&gt;  case 5:                   &lt;br /&gt;    gField.DrawImage    (ilTiles.Images[4], rtgField);          &lt;br /&gt;    break;        &lt;br /&gt;  case 6:                 &lt;br /&gt;    gField.DrawImage    (ilTiles.Images[5], rtgField);                     &lt;br /&gt;    break;                  &lt;br /&gt;  case 7:                        &lt;br /&gt;    gField.DrawImage    (ilTiles.Images[6], rtgField);              &lt;br /&gt;    break;              &lt;br /&gt;  case 8:                &lt;br /&gt;    gField.DrawImage    (ilTiles.Images[7], rtgField);          &lt;br /&gt;    break;               &lt;br /&gt;  case 9:                &lt;br /&gt;    gField.DrawImage    (ilTiles.Images[8], rtgField);                 &lt;br /&gt;    break;                 &lt;br /&gt;  case 10:         &lt;br /&gt;    gField.DrawImage    (ilTiles.Images[9], rtgField);                     &lt;br /&gt;    break;            &lt;br /&gt;  default:               &lt;br /&gt;    break;      &lt;br /&gt;}&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;It looks a lot like the screenshot from chapter 1, doesn't it? Great! So, in the next chapter, we'll add one more extremly cool feature, to complete our game. We'll make our doggy splash water. And that's it. The game will be complete, and this tutorial will be almost over. As the last topc, I'll cover packaging and distribution of your game. And that's it… ;) Finally…&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1891129859130768227-4477607651082253376?l=create-your-game.blogspot.com' alt='' /&gt;&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/GameDevelopmentTutorials/~4/3GAOxtTS0J0" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://create-your-game.blogspot.com/feeds/4477607651082253376/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://create-your-game.blogspot.com/2009/06/25-bubble-bath.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/1891129859130768227/posts/default/4477607651082253376?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/1891129859130768227/posts/default/4477607651082253376?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/GameDevelopmentTutorials/~3/3GAOxtTS0J0/25-bubble-bath.html" title="25. Bubble bath" /><author><name>Marin Malnar</name><uri>http://www.blogger.com/profile/12164590973052924670</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="26" height="32" src="http://1.bp.blogspot.com/_4WDpsfty9mg/ShhOIFmmh4I/AAAAAAAAARo/bKSb8UiTYTw/S220/drawing_biker.jpg" /></author><thr:total>0</thr:total><feedburner:origLink>http://create-your-game.blogspot.com/2009/06/25-bubble-bath.html</feedburner:origLink></entry><entry gd:etag="W/&quot;DU4ARX49fCp7ImA9WxJRGUU.&quot;"><id>tag:blogger.com,1999:blog-1891129859130768227.post-5870285925298898542</id><published>2009-05-22T11:37:00.018+02:00</published><updated>2009-05-22T12:25:44.064+02:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2009-05-22T12:25:44.064+02:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="GDI+" /><category scheme="http://www.blogger.com/atom/ns#" term="images" /><category scheme="http://www.blogger.com/atom/ns#" term="properties" /><category scheme="http://www.blogger.com/atom/ns#" term="picture box" /><category scheme="http://www.blogger.com/atom/ns#" term="form" /><category scheme="http://www.blogger.com/atom/ns#" term="font" /><category scheme="http://www.blogger.com/atom/ns#" term="graphics" /><category scheme="http://www.blogger.com/atom/ns#" term="events" /><category scheme="http://www.blogger.com/atom/ns#" term="button" /><title>24. Preparing the show-off</title><content type="html">&lt;p&gt;Right, before we add all that fancy graphics, we have to prepare our form first. We'll add some additional picture boxes to hold our images. Like the one to hold the firefighter dalmatian doggy, etc… So, add the controls, and modify their properties as shown in the following tables.&lt;/p&gt;&lt;p&gt;&lt;strong&gt;&lt;span style="color:#009900;"&gt;PictureBox&lt;/span&gt;&lt;/strong&gt;&lt;/p&gt;&lt;ul&gt;&lt;li&gt;&lt;span style="color:#ff6600;"&gt;(name):&lt;/span&gt;&lt;strong&gt;&lt;span style="color:#000000;"&gt;picDoggy&lt;/span&gt;&lt;/strong&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="color:#ff6600;"&gt;BackColor:  &lt;/span&gt;&lt;strong&gt;&lt;span style="color:#000000;"&gt;Web &gt; Transparent&lt;/span&gt;&lt;/strong&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="color:#ff6600;"&gt;Image:  &lt;/span&gt;&lt;span style="color:#000000;"&gt;&lt;em&gt;[Load firefighter doggy image]&lt;/em&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="color:#ff6600;"&gt;Location:&lt;/span&gt;&lt;strong&gt;&lt;span style="color:#000000;"&gt; 477; 186&lt;/span&gt;&lt;/strong&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="color:#ff6600;"&gt;Size:&lt;/span&gt;&lt;strong&gt;&lt;span style="color:#000000;"&gt; 131; 201&lt;/span&gt;&lt;/strong&gt;&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;&lt;strong&gt;&lt;span style="color:#009900;"&gt;PictureBox&lt;/span&gt;&lt;/strong&gt;&lt;/p&gt;&lt;ul&gt;&lt;li&gt;&lt;span style="color:#ff6600;"&gt;(name):&lt;/span&gt;&lt;strong&gt;&lt;span style="color:#000000;"&gt;picSplash&lt;/span&gt;&lt;/strong&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="color:#ff6600;"&gt;Anchor:&lt;/span&gt;&lt;strong&gt;&lt;span style="color:#000000;"&gt;Right&lt;/span&gt;&lt;/strong&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="color:#ff6600;"&gt;BackColor:  &lt;/span&gt;&lt;strong&gt;&lt;span style="color:#000000;"&gt;Web &gt; Transparent&lt;/span&gt;&lt;/strong&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="color:#ff6600;"&gt;Image:  &lt;/span&gt;&lt;span style="color:#000000;"&gt;&lt;em&gt;[Load water splash image]&lt;/em&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="color:#ff6600;"&gt;Location:&lt;/span&gt;&lt;strong&gt;&lt;span style="color:#000000;"&gt; 45; 81&lt;/span&gt;&lt;/strong&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="color:#ff6600;"&gt;Size:&lt;/span&gt;&lt;strong&gt;&lt;span style="color:#000000;"&gt; 407; 50&lt;/span&gt;&lt;/strong&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="color:#ff6600;"&gt;SizeMode:&lt;/span&gt;&lt;strong&gt;&lt;span style="color:#000000;"&gt; StretchImage&lt;/span&gt;&lt;/strong&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="color:#ff6600;"&gt;Visible:&lt;/span&gt;&lt;strong&gt;&lt;span style="color:#000000;"&gt; False&lt;/span&gt;&lt;/strong&gt;&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;And now, adjust your form's properties so it'll show the background image:&lt;/p&gt;&lt;p&gt;&lt;strong&gt;&lt;span style="color:#009900;"&gt;Form - frmMain&lt;/span&gt;&lt;/strong&gt;&lt;/p&gt;&lt;ul&gt;&lt;li&gt;&lt;span style="color:#ff6600;"&gt;BackgroundImage: &lt;/span&gt;&lt;span style="color:#000000;"&gt;&lt;em&gt;[Load background image]&lt;/em&gt;&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;If you did everything correctly, you should get your game looking quite similar to the one I've made. But we still have to replace our regular buttons with some fancy ones. If you're really going for the 'wow' effect, you can use pictureboxes combined with labels to replace the buttons. So, remove your buttons (select them and click 'Delete') add some more controls to your form: &lt;br /&gt;&lt;/p&gt;&lt;p&gt;Note: Our new picture boxes that'll replace the buttons will be called same as the buttons we're replacing. That way, we won't have to change our old code.&lt;/p&gt;&lt;p&gt;&lt;strong&gt;&lt;span style="color:#009900;"&gt;PictureBox&lt;/span&gt;&lt;/strong&gt;&lt;/p&gt;&lt;ul&gt;&lt;li&gt;&lt;span style="color:#ff6600;"&gt;(name):&lt;/span&gt;&lt;strong&gt;&lt;span style="color:#000000;"&gt;butGame&lt;/span&gt;&lt;/strong&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="color:#ff6600;"&gt;BackColor:  &lt;/span&gt;&lt;strong&gt;&lt;span style="color:#000000;"&gt;Web &gt; Transparent&lt;/span&gt;&lt;/strong&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="color:#ff6600;"&gt;Image:  &lt;/span&gt;&lt;span style="color:#000000;"&gt;&lt;em&gt;[Load cloud image]&lt;/em&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="color:#ff6600;"&gt;Location:&lt;/span&gt;&lt;strong&gt;&lt;span style="color:#000000;"&gt; 12; 6&lt;/span&gt;&lt;/strong&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="color:#ff6600;"&gt;Size:&lt;/span&gt;&lt;strong&gt;&lt;span style="color:#000000;"&gt; 126; 53&lt;/span&gt;&lt;/strong&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="color:#ff6600;"&gt;SizeMode:&lt;/span&gt;&lt;strong&gt;&lt;span style="color:#000000;"&gt; StretchImage&lt;/span&gt;&lt;/strong&gt;&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;&lt;strong&gt;&lt;span style="color:#009900;"&gt;PictureBox&lt;/span&gt;&lt;/strong&gt;&lt;/p&gt;&lt;ul&gt;&lt;li&gt;&lt;span style="color:#ff6600;"&gt;(name):&lt;/span&gt;&lt;strong&gt;&lt;span style="color:#000000;"&gt;butHighScores&lt;/span&gt;&lt;/strong&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="color:#ff6600;"&gt;BackColor:  &lt;/span&gt;&lt;strong&gt;&lt;span style="color:#000000;"&gt;Web &gt; Transparent&lt;/span&gt;&lt;/strong&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="color:#ff6600;"&gt;Image:  &lt;/span&gt;&lt;span style="color:#000000;"&gt;&lt;em&gt;[Load &lt;/em&gt;&lt;/span&gt;&lt;span style="color:#000000;"&gt;&lt;em&gt;cloud i&lt;/em&gt;&lt;/span&gt;&lt;span style="color:#000000;"&gt;&lt;em&gt;mage]&lt;/em&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="color:#ff6600;"&gt;Location:&lt;/span&gt;&lt;strong&gt;&lt;span style="color:#000000;"&gt; 144; 6&lt;/span&gt;&lt;/strong&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="color:#ff6600;"&gt;Size:&lt;/span&gt;&lt;strong&gt;&lt;span style="color:#000000;"&gt; 126; 53&lt;/span&gt;&lt;/strong&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="color:#ff6600;"&gt;SizeMode:&lt;/span&gt;&lt;strong&gt;&lt;span style="color:#000000;"&gt; StretchImage&lt;/span&gt;&lt;/strong&gt;&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;&lt;strong&gt;&lt;span style="color:#009900;"&gt;PictureBox&lt;/span&gt;&lt;/strong&gt;&lt;/p&gt;&lt;ul&gt;&lt;li&gt;&lt;span style="color:#ff6600;"&gt;(name):&lt;/span&gt;&lt;strong&gt;&lt;span style="color:#000000;"&gt;butNG&lt;/span&gt;&lt;/strong&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="color:#ff6600;"&gt;BackColor:  &lt;/span&gt;&lt;strong&gt;&lt;span style="color:#000000;"&gt;Web &gt; Transparent&lt;/span&gt;&lt;/strong&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="color:#ff6600;"&gt;Image:  &lt;/span&gt;&lt;span style="color:#000000;"&gt;&lt;em&gt;[Load  &lt;/em&gt;&lt;/span&gt;&lt;span style="color:#000000;"&gt;&lt;em&gt;cloud &lt;/em&gt;&lt;/span&gt;&lt;span style="color:#000000;"&gt;&lt;em&gt;image]&lt;/em&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="color:#ff6600;"&gt;Location:&lt;/span&gt;&lt;strong&gt;&lt;span style="color:#000000;"&gt; 276; 6&lt;/span&gt;&lt;/strong&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="color:#ff6600;"&gt;Size:&lt;/span&gt;&lt;strong&gt;&lt;span style="color:#000000;"&gt; 126; 53&lt;/span&gt;&lt;/strong&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="color:#ff6600;"&gt;SizeMode:&lt;/span&gt;&lt;strong&gt;&lt;span style="color:#000000;"&gt; StretchImage&lt;/span&gt;&lt;/strong&gt;&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;Now, we'll add some labels to our clouds: &lt;/p&gt;&lt;p&gt;&lt;p&gt;&lt;strong&gt;&lt;span style="color:#009900;"&gt;Label&lt;/span&gt;&lt;/strong&gt;&lt;/p&gt;&lt;ul&gt;&lt;li&gt;&lt;span style="color:#ff6600;"&gt;(name):&lt;/span&gt;&lt;strong&gt;&lt;span style="color:#000000;"&gt; lblGameCloud&lt;/span&gt;&lt;/strong&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="color:#ff6600;"&gt;BackColor:  &lt;/span&gt;&lt;strong&gt;&lt;span style="color:#000000;"&gt;Web &gt;White&lt;/span&gt;&lt;/strong&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="color:#ff6600;"&gt;Location:&lt;/span&gt;&lt;strong&gt;&lt;span style="color:#000000;"&gt; 23; 26&lt;/span&gt;&lt;/strong&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="color:#ff6600;"&gt;Size:&lt;/span&gt;&lt;strong&gt;&lt;span style="color:#000000;"&gt; 107; 20&lt;/span&gt;&lt;/strong&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="color:#ff6600;"&gt;Text:&lt;/span&gt;&lt;strong&gt;&lt;span style="color:#000000;"&gt; New Game&lt;/span&gt;&lt;/strong&gt;&lt;strong&gt;&lt;span style="color:#000000;"&gt;&lt;/span&gt;&lt;/strong&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="color:#ff6600;"&gt;TextAlign:&lt;/span&gt;&lt;strong&gt;&lt;span style="color:#000000;"&gt; MiddleCenter&lt;/span&gt;&lt;/strong&gt;&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;&lt;p&gt;&lt;strong&gt;&lt;span style="color:#009900;"&gt;Label&lt;/span&gt;&lt;/strong&gt;&lt;/p&gt;&lt;ul&gt;&lt;li&gt;&lt;span style="color:#ff6600;"&gt;(name):&lt;/span&gt;&lt;strong&gt;&lt;span style="color:#000000;"&gt; lblHighScore&lt;/span&gt;&lt;/strong&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="color:#ff6600;"&gt;BackColor:  &lt;/span&gt;&lt;strong&gt;&lt;span style="color:#000000;"&gt;Web &gt;White&lt;/span&gt;&lt;/strong&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="color:#ff6600;"&gt;Location: &lt;/span&gt;&lt;strong&gt;&lt;span style="color:#000000;"&gt;155; 26&lt;/span&gt;&lt;/strong&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="color:#ff6600;"&gt;Size:&lt;/span&gt;&lt;strong&gt;&lt;span style="color:#000000;"&gt; 107; 20&lt;/span&gt;&lt;/strong&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="color:#ff6600;"&gt;Text:&lt;/span&gt;&lt;strong&gt;&lt;span style="color:#000000;"&gt; High Scores&lt;/span&gt;&lt;/strong&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="color:#ff6600;"&gt;TextAlign:&lt;/span&gt;&lt;strong&gt;&lt;span style="color:#000000;"&gt; MiddleCenter&lt;/span&gt;&lt;/strong&gt;&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;&lt;p&gt;&lt;strong&gt;&lt;span style="color:#009900;"&gt;Label&lt;/span&gt;&lt;/strong&gt;&lt;/p&gt;&lt;ul&gt;&lt;li&gt;&lt;span style="color:#ff6600;"&gt;(name):&lt;/span&gt;&lt;strong&gt;&lt;span style="color:#000000;"&gt; lblNG&lt;/span&gt;&lt;/strong&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="color:#ff6600;"&gt;BackColor:  &lt;/span&gt;&lt;strong&gt;&lt;span style="color:#000000;"&gt;Web &gt;White&lt;/span&gt;&lt;/strong&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="color:#ff6600;"&gt;Location:&lt;/span&gt;&lt;strong&gt;&lt;span style="color:#000000;"&gt; 286; 26&lt;/span&gt;&lt;/strong&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="color:#ff6600;"&gt;Size:&lt;/span&gt;&lt;strong&gt;&lt;span style="color:#000000;"&gt; 107; 20&lt;/span&gt;&lt;/strong&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="color:#ff6600;"&gt;Text:&lt;/span&gt;&lt;strong&gt;&lt;span style="color:#000000;"&gt; New Game&lt;/span&gt;&lt;/strong&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="color:#ff6600;"&gt;TextAlign:&lt;/span&gt;&lt;strong&gt;&lt;span style="color:#000000;"&gt; MiddleCenter&lt;/span&gt;&lt;/strong&gt;&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;p&gt;It would be cool if the label inside the picture box would pop-up when the player moves the mouse over the picture box… Here's the code for all three buttons:&lt;/p&gt;&lt;p&gt;&lt;span style="font-family:courier new;"&gt;&lt;span style="color:#000099;"&gt;private void&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt; butGame_MouseEnter&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;(&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;&lt;span style="color:#000099;"&gt;object&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt; sender, &lt;span style="color:#339999;"&gt;EventArgs&lt;/span&gt; e)&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;{&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;  &lt;span style="color:#009900;"&gt;// Set label font to bold:&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;  lblGameCloud.Font = &lt;span style="color:#000099;"&gt;new&lt;/span&gt; &lt;span style="color:#339999;"&gt;Font&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;  (lblGameCloud.Font, &lt;span style="color:#339999;"&gt;FontStyle&lt;/span&gt;.Bold);&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;}&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;&lt;span style="color:#000099;"&gt;private void&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt; butGame_MouseLeave&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;(&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;&lt;span style="color:#000099;"&gt;object&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt; sender, &lt;span style="color:#339999;"&gt;EventArgs&lt;/span&gt; e)&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;{&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;            &lt;span style="color:#009900;"&gt;// Set label font to normal:&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;            lblGameCloud.Font = &lt;span style="color:#000099;"&gt;new&lt;/span&gt; &lt;span style="color:#339999;"&gt;Font&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;  (lblGameCloud.Font, &lt;span style="color:#339999;"&gt;FontStyle&lt;/span&gt;.Regular);&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;}&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="font-family:courier new;"&gt;&lt;span style="color:#000099;"&gt;private void&lt;/span&gt; butHighScores_MouseEnter&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;(&lt;span style="color:#000099;"&gt;object&lt;/span&gt; sender, &lt;span style="color:#339999;"&gt;EventArgs&lt;/span&gt; e)&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;{&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;            &lt;span style="color:#009900;"&gt;// Set label font to bold:&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;            lblHighScore.Font = &lt;span style="color:#000099;"&gt;new&lt;/span&gt; Font&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;                (lblHighScore.Font, &lt;span style="color:#339999;"&gt;FontStyle&lt;/span&gt;.Bold);&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;}&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;&lt;span style="color:#000099;"&gt;private void&lt;/span&gt; butHighScores_MouseLeave&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;(&lt;span style="color:#000099;"&gt;object&lt;/span&gt; sender, &lt;span style="color:#339999;"&gt;EventArgs&lt;/span&gt; e)&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;{&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;            &lt;span style="color:#009900;"&gt;// Set label font to normal:&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;            lblHighScore.Font = &lt;span style="color:#000099;"&gt;new&lt;/span&gt; &lt;span style="color:#339999;"&gt;Font&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;                (lblHighScore.Font, &lt;span style="color:#339999;"&gt;FontStyle&lt;/span&gt;.Regular);&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;}&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="font-family:courier new;"&gt;&lt;span style="color:#000099;"&gt;private void&lt;/span&gt; butNG_MouseEnter&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;(&lt;span style="color:#000099;"&gt;object&lt;/span&gt; sender, &lt;span style="color:#339999;"&gt;EventArgs&lt;/span&gt; e)&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;{&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;            &lt;span style="color:#009900;"&gt;// Set label font to bold:&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;            lblNG.Font = &lt;span style="color:#000099;"&gt;new&lt;/span&gt; &lt;span style="color:#339999;"&gt;Font&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;                (lblNG.Font, &lt;span style="color:#339999;"&gt;FontStyle&lt;/span&gt;.Bold);&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;}&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;&lt;span style="color:#000099;"&gt;private void&lt;/span&gt; butNG_MouseLeave(&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;&lt;span style="color:#000099;"&gt;object&lt;/span&gt; sender, &lt;span style="color:#339999;"&gt;EventArgs&lt;/span&gt; e)&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;{&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;  &lt;span style="color:#009900;"&gt;// Set label font to normal:&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;            lblNG.Font = &lt;span style="color:#000099;"&gt;new &lt;/span&gt;&lt;span style="color:#339999;"&gt;Font&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;                (lblNG.Font, &lt;span style="color:#339999;"&gt;FontStyle&lt;/span&gt;.Regular);&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;}&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;To make this code work, go to your form designer window, then go to your properties window, and click on the 'Events' icon (lightning) on the top of the box. Select your new controls, one by one and find events called MouseEnter and MouseLeave. Click on the little dropdown arrow and you'll see our new code method names in the list. I hope you can find and match the right ones… If not, here's a list that shows you how to match the righ stuff.&lt;br /&gt;&lt;/p&gt;&lt;ul&gt;&lt;li&gt;Control - Event - EventName&lt;/li&gt;&lt;li&gt;butGame - Click - butGame_Click&lt;/li&gt;&lt;li&gt;butGame - MouseEnter - butGame_MouseEnter&lt;/li&gt;&lt;li&gt;butGame - MouseLeave- butGame_MouseLeave&lt;/li&gt;&lt;li&gt;butHighScores - Click - butHighScores_Click&lt;/li&gt;&lt;li&gt;butHighScores - MouseEnter - butHighScores_MouseEnter&lt;/li&gt;&lt;li&gt;butHighScores - MouseLeave- butHighScores_MouseLeave&lt;/li&gt;&lt;li&gt;butNG - Click - butNG_Click&lt;/li&gt;&lt;li&gt;butNG - MouseEnter - butNG_MouseEnter&lt;/li&gt;&lt;li&gt;butNG- MouseLeave- butNG_MouseLeave&lt;/li&gt;&lt;li&gt;lblGameCloud - Click - butGame_Click&lt;/li&gt;&lt;li&gt; lblGameCloud- MouseEnter - butGame_MouseEnter&lt;/li&gt;&lt;li&gt; lblGameCloud- MouseLeave- butGame_MouseLeave&lt;/li&gt;&lt;li&gt;lblHighScore - Click - butHighScores_Click&lt;/li&gt;&lt;li&gt;lblHighScore - MouseEnter - butHighScores_MouseEnter&lt;/li&gt;&lt;li&gt;lblHighScore - MouseLeave- butHighScores_MouseLeave&lt;/li&gt;&lt;li&gt;lblNG - Click - butNG_Click&lt;/li&gt;&lt;li&gt;lblNG - MouseEnter - butNG_MouseEnter&lt;/li&gt;&lt;li&gt;lblNG- MouseLeave- butNG_MouseLeave&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;You probably noticed in the table that we added the 'Click' event to our old button code… That's a nice touch in VS.net, that spares us from retyping the code… (or c/p-ing ;) Nice… Hope you did everything right… And one other cool thing is, that we added the same code to our labels and pictureboxes... Before you try the stuff, let's finally add some graphics.&lt;br /&gt;&lt;/p&gt;Ok, what next? Obviously, we have to replace those blocks with that nice, round bubbles… So, that's next on our agenda.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1891129859130768227-5870285925298898542?l=create-your-game.blogspot.com' alt='' /&gt;&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/GameDevelopmentTutorials/~4/3ZUapKAT8SE" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://create-your-game.blogspot.com/feeds/5870285925298898542/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://create-your-game.blogspot.com/2009/05/24-preparing-show-off.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/1891129859130768227/posts/default/5870285925298898542?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/1891129859130768227/posts/default/5870285925298898542?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/GameDevelopmentTutorials/~3/3ZUapKAT8SE/24-preparing-show-off.html" title="24. Preparing the show-off" /><author><name>Marin Malnar</name><uri>http://www.blogger.com/profile/12164590973052924670</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="26" height="32" src="http://1.bp.blogspot.com/_4WDpsfty9mg/ShhOIFmmh4I/AAAAAAAAARo/bKSb8UiTYTw/S220/drawing_biker.jpg" /></author><thr:total>0</thr:total><feedburner:origLink>http://create-your-game.blogspot.com/2009/05/24-preparing-show-off.html</feedburner:origLink></entry><entry gd:etag="W/&quot;CUYAR3o4fCp7ImA9WxJRFkg.&quot;"><id>tag:blogger.com,1999:blog-1891129859130768227.post-5521841496331539336</id><published>2009-05-18T15:24:00.001+02:00</published><updated>2009-05-18T15:25:46.434+02:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2009-05-18T15:25:46.434+02:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="download" /><category scheme="http://www.blogger.com/atom/ns#" term="graphics" /><category scheme="http://www.blogger.com/atom/ns#" term="design" /><category scheme="http://www.blogger.com/atom/ns#" term="game" /><title>23. Graphics!</title><content type="html">So, we're finally here! You had enough time to design your own graphics. Hehe... I know, I know... Your dog ate the memory stick on wich you saved the files... :P Just kidding! Feel free to download the graphics i used for the game. Here's the link:&lt;br /&gt;&lt;p&gt;&lt;a href="http://www.werewolf-customs.com/downloads/graphics/TutorialGraphics01.rar"&gt;Link! (*.rar)&lt;/a&gt;&lt;/p&gt;&lt;p&gt;Everything is in there!&lt;br /&gt;&lt;/p&gt;Take a look at them, and we'll continue in a couple of days!&lt;br /&gt;&lt;br /&gt;I'm really sorry that I can't write posts more frequentley. I hope things will improve soon.&lt;br /&gt;Enjoy!&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1891129859130768227-5521841496331539336?l=create-your-game.blogspot.com' alt='' /&gt;&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/GameDevelopmentTutorials/~4/r9HJ-lJqTXU" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://create-your-game.blogspot.com/feeds/5521841496331539336/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://create-your-game.blogspot.com/2009/05/23-graphics.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/1891129859130768227/posts/default/5521841496331539336?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/1891129859130768227/posts/default/5521841496331539336?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/GameDevelopmentTutorials/~3/r9HJ-lJqTXU/23-graphics.html" title="23. Graphics!" /><author><name>Marin Malnar</name><uri>http://www.blogger.com/profile/12164590973052924670</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="26" height="32" src="http://1.bp.blogspot.com/_4WDpsfty9mg/ShhOIFmmh4I/AAAAAAAAARo/bKSb8UiTYTw/S220/drawing_biker.jpg" /></author><thr:total>0</thr:total><feedburner:origLink>http://create-your-game.blogspot.com/2009/05/23-graphics.html</feedburner:origLink></entry><entry gd:etag="W/&quot;CEQDSXo-fCp7ImA9WxJSFkQ.&quot;"><id>tag:blogger.com,1999:blog-1891129859130768227.post-8722997483605907391</id><published>2009-05-06T12:07:00.075+02:00</published><updated>2009-05-07T12:32:58.454+02:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2009-05-07T12:32:58.454+02:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="top list" /><category scheme="http://www.blogger.com/atom/ns#" term="write" /><category scheme="http://www.blogger.com/atom/ns#" term="read" /><category scheme="http://www.blogger.com/atom/ns#" term="file" /><category scheme="http://www.blogger.com/atom/ns#" term="font" /><category scheme="http://www.blogger.com/atom/ns#" term="source code" /><category scheme="http://www.blogger.com/atom/ns#" term="pad" /><category scheme="http://www.blogger.com/atom/ns#" term="list" /><category scheme="http://www.blogger.com/atom/ns#" term="string" /><category scheme="http://www.blogger.com/atom/ns#" term="i/o" /><category scheme="http://www.blogger.com/atom/ns#" term="sort" /><category scheme="http://www.blogger.com/atom/ns#" term="high score" /><title>22. Hall of fame</title><content type="html">There's nothing better than prooving to everybody that you're the best! And you certanly can't do that if your score isn't saved. We are now going to make a high score list. For it to work, we'll need a file, that we'll write the scores into. The scores will be consisted of the following: Score, Level, and Player Name. We'll need a new command button to show the list, and a new label to display the results in it. Add them to your game's form, and apply the next properties to them: &lt;p&gt;&lt;strong&gt;&lt;span style="color:#009900;"&gt;Button&lt;/span&gt;&lt;/strong&gt;&lt;/p&gt;&lt;ul&gt;&lt;li&gt;&lt;span style="color:#ff6600;"&gt;(name):&lt;/span&gt;&lt;strong&gt;&lt;span style="color:#000000;"&gt; butHighScores&lt;/span&gt;&lt;/strong&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="color:#ff6600;"&gt;Location:&lt;/span&gt; &lt;strong&gt;&lt;span style="color:#000000;"&gt;144; 6&lt;/span&gt;&lt;/strong&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="color:#ff6600;"&gt;Size:&lt;/span&gt; &lt;strong&gt;&lt;span style="color:#000000;"&gt;126; 53&lt;/span&gt;&lt;/strong&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="color:#ff6600;"&gt;Text:&lt;/span&gt;&lt;strong&gt;&lt;span style="color:#000000;"&gt; High Scores&lt;/span&gt;&lt;/strong&gt;&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;&lt;strong&gt;&lt;span style="color:#009900;"&gt;Label&lt;/span&gt;&lt;/strong&gt;&lt;/p&gt;&lt;ul&gt;&lt;li&gt;&lt;span style="color:#ff6600;"&gt;(name):&lt;/span&gt;&lt;strong&gt;&lt;span style="color:#000000;"&gt;lblHighScoreList&lt;/span&gt;&lt;/strong&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="color:#ff6600;"&gt;AutoSize:  &lt;/span&gt;&lt;strong&gt;&lt;span style="color:#000000;"&gt;True&lt;/span&gt;&lt;/strong&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="color:#ff6600;"&gt;BackColor:  &lt;/span&gt;&lt;strong&gt;&lt;span style="color:#000000;"&gt;Web &gt; Transparent&lt;/span&gt;&lt;/strong&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="color:#ff6600;"&gt;Font:  &lt;/span&gt;&lt;strong&gt;&lt;span style="color:#000000;"&gt;Courier New; 14,25pt; style=Bold&lt;/span&gt;&lt;/strong&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="color:#ff6600;"&gt;ForeColor:  &lt;/span&gt;&lt;strong&gt;&lt;span style="color:#000000;"&gt;Web &gt; OrangeRed&lt;/span&gt;&lt;/strong&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="color:#ff6600;"&gt;Location:&lt;/span&gt;&lt;strong&gt;&lt;span style="color:#000000;"&gt; 17; 81&lt;/span&gt;&lt;/strong&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="color:#ff6600;"&gt;Size:&lt;/span&gt;&lt;strong&gt;&lt;span style="color:#000000;"&gt; 0; 22&lt;/span&gt;&lt;/strong&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="color:#ff6600;"&gt;Text:&lt;/span&gt; &lt;em&gt;[BLANK]&lt;/em&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="color:#ff6600;"&gt;Visible:&lt;/span&gt;&lt;strong&gt;&lt;span style="color:#000000;"&gt; False&lt;/span&gt;&lt;/strong&gt;&lt;/li&gt;&lt;/ul&gt;Ok, and now the code for the button:&lt;p&gt;&lt;span style="color:#009900;"&gt;&lt;span style="font-family:courier new;"&gt;// If the High Score list&lt;br /&gt;// isn't visible - show it.&lt;br /&gt;// If it's visible - hide it.&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;&lt;br /&gt;&lt;span style="color:#000099;"&gt;if&lt;/span&gt; (lblHighScoreList.Visible &lt;/span&gt;&lt;span style="font-family:courier new;"&gt;== false)&lt;br /&gt;{&lt;br /&gt;&lt;/span&gt;&lt;span style="color:#009900;"&gt;&lt;span style="font-family:courier new;"&gt;  // Show High scores.&lt;br /&gt;  // We'll read the high scores,&lt;br /&gt;  // but won't try to process &lt;br /&gt;  // the current score:&lt;br /&gt;&lt;br /&gt;  // First, hide the game field:&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;&lt;br /&gt;  picGameField.Hide();&lt;br /&gt;&lt;/span&gt;&lt;span style="color:#009900;"&gt;&lt;span style="font-family:courier new;"&gt;  // Call our function that reads&lt;br /&gt;  // the high scores:&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;&lt;br /&gt;  HighScore(false);&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="font-family:courier new;"&gt;  // Reset the text in our label:&lt;br /&gt;  lblHighScoreList.Text = "";&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color:#009900;"&gt;&lt;span style="font-family:courier new;"&gt;  // This is the cool part:&lt;br /&gt;  // Strings are so fun! You can&lt;br /&gt;  // do just about anything with&lt;br /&gt;  // them in C#! Here, we format&lt;br /&gt;  // the string with PAD functions.&lt;br /&gt;  // Padding means adding characters&lt;br /&gt;  // (or spaces) in front (or back)&lt;br /&gt;  // of the string. Google for more&lt;br /&gt;  // info!&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;&lt;br /&gt;&lt;br /&gt;  // Format the header line:&lt;br /&gt;  lblHighScoreList.Text =&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;&lt;span style="color:#990000;"&gt;  "#"&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;.PadLeft(3) + &lt;/span&gt;&lt;span style="font-family:courier new;"&gt;&lt;span style="color:#990000;"&gt;" "&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt; +&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;&lt;span style="color:#990000;"&gt;  "Score"&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;.PadRight(8) + " " +&lt;br /&gt;  "Level".PadLeft(5) + " " +&lt;br /&gt;  "Name".PadRight(22) + " " +&lt;br /&gt;  "\n\r"; //New line&lt;br /&gt;&lt;br /&gt;  //Read all highscores from the list:&lt;br /&gt;  &lt;span style="color:#000099;"&gt;for&lt;/span&gt; (&lt;span style="color:#000099;"&gt;int&lt;/span&gt; h = 0; h &lt; ScoreList.Count; h++)&lt;br /&gt;  {&lt;br /&gt;    &lt;span style="color:#000099;"&gt;int&lt;/span&gt; p = h + 1;&lt;br /&gt;    lblHighScoreList.Text +=&lt;br /&gt;    p.ToString().PadLeft    (3) + " " +&lt;br /&gt;    ScoreList[h].iScore    .ToString().PadLeft&lt;br /&gt;    (8, &lt;span style="color:#990000;"&gt;'0'&lt;/span&gt;) + &lt;span style="color:#990000;"&gt;" "&lt;/span&gt; +&lt;br /&gt;    ScoreList[h].iLevel    .ToString().PadLeft&lt;br /&gt;    (5) + &lt;/span&gt;&lt;span style="font-family:courier new;"&gt;&lt;span style="color:#990000;"&gt;" "&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;&lt;span style="color:#990000;"&gt; &lt;/span&gt;+&lt;br /&gt;    ScoreList[h].sName.PadRight&lt;br /&gt;    (22) + &lt;span style="color:#990000;"&gt;" "&lt;/span&gt; +&lt;br /&gt;    &lt;span style="color:#990000;"&gt;"\n\r"&lt;/span&gt;; //New line&lt;br /&gt;  }&lt;br /&gt;  &lt;span style="color:#009900;"&gt;// Show the filled label:&lt;/span&gt;&lt;br /&gt;  lblHighScoreList.Visible = &lt;span style="color:#000099;"&gt;true&lt;/span&gt;;&lt;br /&gt;}&lt;br /&gt;&lt;span style="color:#000099;"&gt;else&lt;/span&gt;&lt;br /&gt;{&lt;br /&gt;&lt;/span&gt;&lt;span style="color:#009900;"&gt;&lt;span style="font-family:courier new;"&gt;  // Hide the High Score list,&lt;br /&gt;  // and show the game field:&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;&lt;br /&gt;  picGameField.Show();&lt;br /&gt;  lblHighScoreList.Visible = &lt;span style="color:#000099;"&gt;false&lt;/span&gt;;&lt;br /&gt;  picGameField.Refresh();&lt;br /&gt;}&lt;/span&gt;&lt;/p&gt;&lt;p&gt;But, we're not done yet. We have to give our player some way to input his name, assuming he made it into the top ten... So, add the next controls, and change their properties as shown:&lt;/p&gt;&lt;p&gt;&lt;strong&gt;&lt;span style="color:#009900;"&gt;Panel&lt;/span&gt;&lt;/strong&gt;&lt;/p&gt;&lt;ul&gt;&lt;li&gt;&lt;span style="color:#ff6600;"&gt;(name):&lt;/span&gt;&lt;strong&gt;&lt;span style="color:#000000;"&gt; IOBox&lt;/span&gt;&lt;/strong&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="color:#ff6600;"&gt;BackColor:  &lt;/span&gt;&lt;strong&gt;&lt;span style="color:#000000;"&gt;Web &gt; Transparent&lt;/span&gt;&lt;/strong&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="color:#ff6600;"&gt;BorderStyle:  &lt;/span&gt;&lt;strong&gt;&lt;span style="color:#000000;"&gt;FixedSingle&lt;/span&gt;&lt;/strong&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="color:#ff6600;"&gt;Location:&lt;/span&gt;&lt;strong&gt;&lt;span style="color:#000000;"&gt; 301; 6&lt;/span&gt;&lt;/strong&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="color:#ff6600;"&gt;Size:&lt;/span&gt;&lt;strong&gt;&lt;span style="color:#000000;"&gt; 311; 53&lt;/span&gt;&lt;/strong&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="color:#ff6600;"&gt;Visible:&lt;/span&gt;&lt;strong&gt;&lt;span style="color:#000000;"&gt; False&lt;/span&gt;&lt;/strong&gt;&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;&lt;strong&gt;&lt;span style="color:#009900;"&gt;Text Box  &lt;/span&gt;&lt;/strong&gt;&lt;strong&gt;&lt;span style="color:#ff0000;"&gt;!!! PUT IT INSIDE IOBox Panel !!!&lt;/span&gt;&lt;/strong&gt;&lt;/p&gt;&lt;ul&gt;&lt;li&gt;&lt;span style="color:#ff6600;"&gt;(name):&lt;/span&gt;&lt;strong&gt;&lt;span style="color:#000000;"&gt;txtHS&lt;/span&gt;&lt;/strong&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="color:#ff6600;"&gt;BackColor:  &lt;/span&gt;&lt;strong&gt;&lt;span style="color:#000000;"&gt;Web &gt; Tan&lt;/span&gt;&lt;/strong&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="color:#ff6600;"&gt;BorderStyle:  &lt;/span&gt;&lt;strong&gt;&lt;span style="color:#000000;"&gt;FixedSingle&lt;/span&gt;&lt;/strong&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="color:#ff6600;"&gt;Font:  &lt;/span&gt;&lt;strong&gt;&lt;span style="color:#000000;"&gt;Microsoft Sans Serif; 12pt; style=Bold&lt;/span&gt;&lt;/strong&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="color:#ff6600;"&gt;ForeColor:  &lt;/span&gt;&lt;strong&gt;&lt;span style="color:#000000;"&gt;Web &gt;Green&lt;/span&gt;&lt;/strong&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="color:#ff6600;"&gt;Location:&lt;/span&gt;&lt;strong&gt;&lt;span style="color:#000000;"&gt; 3; 22&lt;/span&gt;&lt;/strong&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="color:#ff6600;"&gt;MaxLenght:&lt;/span&gt;&lt;strong&gt;&lt;span style="color:#000000;"&gt; 20&lt;/span&gt;&lt;/strong&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="color:#ff6600;"&gt;Size:&lt;/span&gt;&lt;strong&gt;&lt;span style="color:#000000;"&gt;199; 26&lt;/span&gt;&lt;/strong&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="color:#ff6600;"&gt;Visible:&lt;/span&gt;&lt;strong&gt;&lt;span style="color:#000000;"&gt; False&lt;/span&gt;&lt;/strong&gt;&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;&lt;strong&gt;&lt;span style="color:#009900;"&gt;Button &lt;/span&gt;&lt;/strong&gt;&lt;strong&gt;&lt;span style="color:#009900;"&gt; &lt;/span&gt;&lt;/strong&gt;&lt;strong&gt;&lt;span style="color:#ff0000;"&gt;!!! PUT IT INSIDE IOBox Panel !!!&lt;/span&gt;&lt;/strong&gt;&lt;/p&gt;&lt;ul&gt;&lt;li&gt;&lt;span style="color:#ff6600;"&gt;(name):&lt;/span&gt;&lt;strong&gt;&lt;span style="color:#000000;"&gt; butIO&lt;/span&gt;&lt;/strong&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="color:#ff6600;"&gt;Location:&lt;/span&gt;&lt;strong&gt;&lt;span style="color:#000000;"&gt; 208; 22&lt;/span&gt;&lt;/strong&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="color:#ff6600;"&gt;Size: &lt;/span&gt;&lt;strong&gt;&lt;span style="color:#000000;"&gt;100; 26&lt;/span&gt;&lt;/strong&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="color:#ff6600;"&gt;Text:&lt;/span&gt;&lt;strong&gt;&lt;span style="color:#000000;"&gt; Yea!&lt;/span&gt;&lt;/strong&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="color:#ff6600;"&gt;Visible:&lt;/span&gt;&lt;strong&gt;&lt;span style="color:#000000;"&gt; False&lt;/span&gt;&lt;/strong&gt;&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;&lt;strong&gt;&lt;span style="color:#009900;"&gt;Label &lt;/span&gt;&lt;/strong&gt;&lt;strong&gt;&lt;span style="color:#009900;"&gt; &lt;/span&gt;&lt;/strong&gt;&lt;strong&gt;&lt;span style="color:#ff0000;"&gt;!!! PUT IT INSIDE IOBox Panel !!!&lt;/span&gt;&lt;/strong&gt;&lt;/p&gt;&lt;ul&gt;&lt;li&gt;&lt;span style="color:#ff6600;"&gt;(name):&lt;/span&gt;&lt;strong&gt;&lt;span style="color:#000000;"&gt; lblHS&lt;/span&gt;&lt;/strong&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="color:#ff6600;"&gt;Autosize: &lt;/span&gt;&lt;strong&gt;&lt;span style="color:#000000;"&gt;True&lt;/span&gt;&lt;/strong&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="color:#ff6600;"&gt;Font:  &lt;/span&gt;&lt;strong&gt;&lt;span style="color:#000000;"&gt;Microsoft Sans Serif; 9pt; style=Bold&lt;/span&gt;&lt;/strong&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="color:#ff6600;"&gt;Location:&lt;/span&gt;&lt;strong&gt;&lt;span style="color:#000000;"&gt; 0; -1&lt;/span&gt;&lt;/strong&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="color:#ff6600;"&gt;Size: &lt;/span&gt;&lt;strong&gt;&lt;span style="color:#000000;"&gt;312; 15&lt;/span&gt;&lt;/strong&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="color:#ff6600;"&gt;Text:&lt;/span&gt;&lt;strong&gt;&lt;span style="color:#000000;"&gt; You have a high score! Please enter your name:&lt;br /&gt;&lt;/span&gt;&lt;/strong&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="color:#ff6600;"&gt;TextAlign: &lt;/span&gt;&lt;strong&gt;&lt;span style="color:#000000;"&gt;TopCenter&lt;/span&gt;&lt;/strong&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="color:#ff6600;"&gt;Visible:&lt;/span&gt;&lt;strong&gt;&lt;span style="color:#000000;"&gt; False&lt;/span&gt;&lt;/strong&gt;&lt;/li&gt;&lt;/ul&gt;Ok, and now the rest of the code - put it in private void HighScore(bool bCalculate)!&lt;br /&gt;&lt;p&gt;&lt;span style="font-family:courier new;"&gt;// Clear the score list:&lt;br /&gt;ScoreList.Clear();&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color:#009900;"&gt;/&lt;span style="font-family:courier new;"&gt;/ Read High scores from file:&lt;br /&gt;// We'll use a file named "wGames.hs".&lt;br /&gt;// It's basicaly a normal text file.&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;&lt;br /&gt;FileStream fileR = &lt;br /&gt;new FileStream&lt;br /&gt;("wGames.hs", FileMode.OpenOrCreate);&lt;br /&gt;StreamReader reader =&lt;br /&gt;new &lt;/span&gt;&lt;span style="font-family:courier new;"&gt;&lt;span style="color:#339999;"&gt;StreamReader&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;(fileR);&lt;br /&gt;&lt;br /&gt;string sRead;&lt;br /&gt;while ((sRead = reader.ReadLine()) != null)&lt;br /&gt;{&lt;br /&gt;&lt;/span&gt;&lt;span style="color:#009900;"&gt;&lt;span style="font-family:courier new;"&gt;  // Read the file line by line.&lt;br /&gt;  // The scores in the file are&lt;br /&gt;  // ordered from the highest to&lt;br /&gt;  // the lowest. A line in the file&lt;br /&gt;  // is in the next form:&lt;br /&gt;  // SCORE;LEVEL;NAME&lt;br /&gt;&lt;br /&gt;  // Declare an array of strings,&lt;br /&gt;  // and fill it with the parts&lt;br /&gt;  // of the high-score line,&lt;br /&gt;  // wich we split with the C#&lt;br /&gt;  // built in Split() function!&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;&lt;br /&gt;  string[] aRead =   sRead.Split(';');&lt;br /&gt;  &lt;br /&gt;&lt;/span&gt;&lt;span style="color:#009900;"&gt;&lt;span style="font-family:courier new;"&gt;  // Let's write our scores in a&lt;br /&gt;  // struct.&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;&lt;br /&gt;  stScores ScoreStruct =&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;&lt;span style="color:#000099;"&gt;  new&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt; stScores();&lt;br /&gt;  ScoreStruct.iLevel =   int.Parse(aRead[1]);&lt;br /&gt;  ScoreStruct.iScore =   int.Parse(aRead[0]);&lt;br /&gt;  ScoreStruct.sName =   aRead[2];&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color:#009900;"&gt;&lt;span style="font-family:courier new;"&gt;  // And add the struct to the&lt;br /&gt;  // ScoreList:&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;&lt;br /&gt;  ScoreList.Add(&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;&lt;span style="color:#000000;"&gt;ScoreStruct&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;);&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color:#009900;"&gt;&lt;span style="font-family:courier new;"&gt;  // Now, we can sort the Score&lt;br /&gt;  // List:&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;&lt;br /&gt;  ScoreList.Sort(delegate&lt;br /&gt;  (stScores s1, stScores s2)&lt;br /&gt;  { return s2.iScore.CompareTo&lt;br /&gt;  (s1.iScore); });&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;// Close the file:&lt;br /&gt;reader.Dispose();&lt;br /&gt;fileR.Dispose();&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color:#009900;"&gt;&lt;span style="font-family:courier new;"&gt;// This code checks if we need&lt;br /&gt;// to process the current score,&lt;br /&gt;// because we use this function&lt;br /&gt;// for both, processing, and just&lt;br /&gt;// showing the high score.&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;&lt;br /&gt;if (bCalculate == true)&lt;br /&gt;{&lt;br /&gt;&lt;/span&gt;&lt;span style="color:#009900;"&gt;&lt;span style="font-family:courier new;"&gt;  // If the list contains less than&lt;br /&gt;  // ten scores, we add the current&lt;br /&gt;  // score in the list automatically.&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;&lt;br /&gt;  &lt;/span&gt;&lt;span style="font-family:courier new;"&gt;&lt;span style="color:#000099;"&gt;if &lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;(ScoreList.Count &gt; 9)&lt;br /&gt;  {&lt;br /&gt;&lt;/span&gt;&lt;span style="color:#009900;"&gt;&lt;span style="font-family:courier new;"&gt;    // If the list contains ten or&lt;br /&gt;    // more scores, we have to check&lt;br /&gt;    // if the current score is high&lt;br /&gt;    // enough.&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;&lt;br /&gt;    &lt;span style="color:#000099;"&gt;if&lt;/span&gt; (ScoreList[9].iScore&lt;br /&gt;    &lt; iScore)&lt;br /&gt;    {&lt;br /&gt;&lt;/span&gt;&lt;span style="color:#009900;"&gt;&lt;span style="font-family:courier new;"&gt;      // We display the HighScore&lt;br /&gt;      // entry controls!&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;&lt;br /&gt;      IOBox.Visible = &lt;span style="color:#000099;"&gt;true&lt;/span&gt;;&lt;br /&gt;      lblHS.Visible = &lt;span style="color:#000099;"&gt;true&lt;/span&gt;;&lt;br /&gt;      txtHS.Visible = &lt;span style="color:#000099;"&gt;true&lt;/span&gt;;&lt;br /&gt;      butIO.Visible = &lt;span style="color:#000099;"&gt;true&lt;/span&gt;;&lt;br /&gt;    }&lt;br /&gt;  }&lt;br /&gt;  &lt;span style="color:#000099;"&gt;else&lt;/span&gt;&lt;br /&gt;  {&lt;br /&gt;&lt;/span&gt;&lt;span style="color:#009900;"&gt;&lt;span style="font-family:courier new;"&gt;    // We don't show the controls&lt;br /&gt;    // for high score entry!&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;&lt;br /&gt;    IOBox.Visible = &lt;span style="color:#000099;"&gt;true&lt;/span&gt;;&lt;br /&gt;    lblHS.Visible = &lt;span style="color:#000099;"&gt;true&lt;/span&gt;;&lt;br /&gt;    txtHS.Visible = &lt;span style="color:#000099;"&gt;true&lt;/span&gt;;&lt;br /&gt;    butIO.Visible = &lt;span style="color:#000099;"&gt;true&lt;/span&gt;;&lt;br /&gt;  }&lt;br /&gt;}&lt;/span&gt;&lt;/p&gt;&lt;p&gt;And now, add this code to the butIO's click method:&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="color:#009900;"&gt;&lt;span style="font-family:courier new;"&gt;// Put the current score and&lt;br /&gt;// level number in a struct:&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;&lt;br /&gt;stScores NewScore = new stScores();&lt;br /&gt;NewScore.iScore = iScore;&lt;br /&gt;NewScore.iLevel = iLevel;&lt;br /&gt;&lt;/span&gt;&lt;span style="color:#009900;"&gt;&lt;span style="font-family:courier new;"&gt;// Also, put the player name&lt;br /&gt;// in the same struct. If the&lt;br /&gt;// Player didn't enter a name,&lt;br /&gt;// just call him 'J. Doe'.&lt;br /&gt;// (we don't know if J. stands&lt;br /&gt;// for John or Jane :)&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;&lt;br /&gt;if (txtHS.Text.Trim().Length == 0)&lt;br /&gt;{&lt;br /&gt;  NewScore.sName = "J. Doe";&lt;br /&gt;}&lt;br /&gt;else&lt;br /&gt;{&lt;br /&gt;&lt;/span&gt;&lt;span style="color:#009900;"&gt;&lt;span style="font-family:courier new;"&gt;  // We use ; as a delimiter in&lt;br /&gt;  // our high score file. So, if &lt;br /&gt;  // the user would enter it in&lt;br /&gt;  // the text box - it would crash&lt;br /&gt;  // our game. That's why we'll&lt;br /&gt;  // replace all the ; with commas.&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;&lt;br /&gt;  txtHS.Text.Replace(';', ',');&lt;br /&gt;  NewScore.sName =   txtHS.Text.Trim();&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;// Add the struct to the list:&lt;br /&gt;ScoreList.Add(NewScore);&lt;br /&gt;&lt;br /&gt;// Sort the list:&lt;br /&gt;ScoreList.Sort(delegate&lt;br /&gt;(stScores s1, stScores s2) &lt;br /&gt;{ return s2.iScore.CompareTo&lt;br /&gt;(s1.iScore); });&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color:#009900;"&gt;&lt;span style="font-family:courier new;"&gt;// Write the list back into the &lt;br /&gt;// file. We'll overwrite the old&lt;br /&gt;// file.&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;&lt;br /&gt;StreamWriter writer = new StreamWriter("wGames.hs", false);&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color:#009900;"&gt;&lt;span style="font-family:courier new;"&gt;// See how many scores we have&lt;br /&gt;// to save to the file. If we&lt;br /&gt;// have more than ten scores&lt;br /&gt;// (full list + new score),&lt;br /&gt;// then save just the top&lt;br /&gt;// ten scores!&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;&lt;br /&gt;int lc = ScoreList.Count;&lt;br /&gt;if (lc &gt; 10) lc = 10;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color:#009900;"&gt;&lt;span style="font-family:courier new;"&gt;// Write scores to the file,&lt;br /&gt;// line by line!&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;&lt;br /&gt;&lt;span style="color:#000099;"&gt;for&lt;/span&gt; (&lt;span style="color:#000099;"&gt;int &lt;/span&gt;w = 0; w &lt; lc; w++)&lt;br /&gt;{&lt;br /&gt;  writer.WriteLine&lt;br /&gt;  (ScoreList[w].iScore.ToString()&lt;br /&gt;  + &lt;span style="color:#990000;"&gt;";"&lt;/span&gt; +&lt;br /&gt;  ScoreList[w].iLevel.ToString()&lt;br /&gt;  + &lt;span style="color:#990000;"&gt;";"&lt;/span&gt; +&lt;br /&gt;  ScoreList[w].sName);&lt;br /&gt;}&lt;br /&gt;writer.Dispose();&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color:#009900;"&gt;&lt;span style="font-family:courier new;"&gt;// And hide the dialog after&lt;br /&gt;// saving the score:&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;&lt;br /&gt;lblHS.Visible = &lt;span style="color:#000099;"&gt;false&lt;/span&gt;;&lt;br /&gt;txtHS.Visible = &lt;span style="color:#000099;"&gt;false&lt;/span&gt;;&lt;br /&gt;butIO.Visible = &lt;span style="color:#000099;"&gt;false&lt;/span&gt;;&lt;br /&gt;IOBox.Visible = &lt;span style="color:#000099;"&gt;false&lt;/span&gt;;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;And to make this work, we'll have to add a couple of global variables and stuff...( Look at the top of your code, remember?)&lt;/p&gt;&lt;p&gt;&lt;span style="font-family:courier new;"&gt;&lt;span style="color:#009900;"&gt;//List that holds score structs&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;&lt;span style="color:#339999;"&gt;List&lt;/span&gt;&lt;/span&gt;&lt;stscores&gt;&lt;span style="font-family:courier new;"&gt;&lt;&lt;span style="color:#339999;"&gt;stScores&lt;/span&gt;&gt; &lt;/span&gt;&lt;stscores&gt;&lt;span style="font-family:courier new;"&gt;&lt;span style="color:#000000;"&gt;ScoreList&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/stscores&gt;&lt;stscores&gt;&lt;span style="font-family:courier new;"&gt; = &lt;span style="color:#000099;"&gt;new &lt;/span&gt;&lt;/span&gt;&lt;/stscores&gt;&lt;stscores&gt;&lt;span style="font-family:courier new;"&gt;&lt;span style="color:#339999;"&gt;List&lt;/span&gt;&lt;/span&gt;&lt;/stscores&gt;&lt;stscores&gt;&lt;span style="font-family:courier new;"&gt;&lt;span style="color:#000000;"&gt;&lt;&lt;/span&gt;&lt;/span&gt;&lt;/stscores&gt;&lt;stscores&gt;&lt;span style="font-family:courier new;"&gt;&lt;span style="color:#339999;"&gt;stScores&lt;/span&gt;&lt;/span&gt;&lt;/stscores&gt;&lt;stscores&gt;&lt;span style="font-family:courier new;"&gt;&lt;span style="color:#000000;"&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/stscores&gt;&lt;stscores&gt;&lt;stscores&gt;&lt;span style="font-family:courier new;"&gt;();&lt;/p&gt;&lt;/span&gt;&lt;p&gt;&lt;span style="font-family:courier new;"&gt;&lt;span style="color:#009900;"&gt;//Struct that holds scores&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;&lt;span style="color:#000099;"&gt;struct&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt; stScores&lt;br /&gt;{&lt;br /&gt;  public int iScore;&lt;br /&gt;  public int iLevel;&lt;br /&gt;  public string sName;&lt;br /&gt;}&lt;/span&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;Cool? Ok, test your game. It might just work! ;o)&lt;/p&gt;&lt;p&gt;Right! The game's fully functional now (= I hope =). And now comes the 'fun' part - design! :) (as I later found out - not so fun, because I'm 100% graphically challenged)... :c)&lt;br /&gt;&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;/stscores&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1891129859130768227-8722997483605907391?l=create-your-game.blogspot.com' alt='' /&gt;&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/GameDevelopmentTutorials/~4/WMpFfCg4wio" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://create-your-game.blogspot.com/feeds/8722997483605907391/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://create-your-game.blogspot.com/2009/05/22-hall-of-fame.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/1891129859130768227/posts/default/8722997483605907391?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/1891129859130768227/posts/default/8722997483605907391?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/GameDevelopmentTutorials/~3/WMpFfCg4wio/22-hall-of-fame.html" title="22. Hall of fame" /><author><name>Marin Malnar</name><uri>http://www.blogger.com/profile/12164590973052924670</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="26" height="32" src="http://1.bp.blogspot.com/_4WDpsfty9mg/ShhOIFmmh4I/AAAAAAAAARo/bKSb8UiTYTw/S220/drawing_biker.jpg" /></author><thr:total>0</thr:total><feedburner:origLink>http://create-your-game.blogspot.com/2009/05/22-hall-of-fame.html</feedburner:origLink></entry><entry gd:etag="W/&quot;DkQGRH07fSp7ImA9WxJSFk0.&quot;"><id>tag:blogger.com,1999:blog-1891129859130768227.post-2782380979465821346</id><published>2009-04-30T10:22:00.017+02:00</published><updated>2009-05-06T12:05:25.305+02:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2009-05-06T12:05:25.305+02:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="gameplay" /><category scheme="http://www.blogger.com/atom/ns#" term="speed" /><category scheme="http://www.blogger.com/atom/ns#" term="level" /><category scheme="http://www.blogger.com/atom/ns#" term="new game" /><category scheme="http://www.blogger.com/atom/ns#" term="source code" /><category scheme="http://www.blogger.com/atom/ns#" term="pause" /><title>21. Time for a coffe break</title><content type="html">&lt;p&gt;Ok, we programmed almost everything that I wanted to see in our gameplay. But this tutorial is far from over. You remember the game screenshot from the first chapter? Our game doesn't look anything like that... In the next few chapters we'll add some practical functions to our game, like 'Pause' button, 'High Score' list, and then we'll move on to the decoration!&lt;br /&gt;&lt;/p&gt;&lt;p&gt;Almos every game has a 'Pause' button. It's almost normal that you can't play any game without interuption. Maybe your wife sends you to the store to fetch some ingredients for lunch, or your two-year-old starts pulling the mouse out of your hand, or something else comes in your way... In every case, you don't want your game to go on... So, to satisfy our players, we'll add a pause button. Well, not actualy add - we'll just use our existing 'New Game' button, and programatically make it a multifunctional 'gadget'.&lt;br /&gt;Ok, now, we'll update our code to give our game/pause button the funcionality that it needs. Basically, we'll just stop our timer when the user clicks on the button, and start it again when the user clicks 'Continue'. We won't add a new button for the 'Continue' command. We'll use our current 'Pause' button to do this...&lt;/p&gt;&lt;p&gt;Here's the code:&lt;br /&gt;(overwrite your existing 'GameButton_Click' code!)&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="font-family:courier new;"&gt;&lt;span style="color:#000099;"&gt;if&lt;/span&gt; (butGame == &lt;span style="color:#990000;"&gt;"New Game"&lt;/span&gt;)&lt;br /&gt;{&lt;br /&gt;                &lt;span style="color:#009900;"&gt;//NEW GAME&lt;/span&gt;&lt;br /&gt;                picGameField.Show();&lt;br /&gt;                picGameField.Refresh();&lt;br /&gt;                NewGame();&lt;br /&gt;                butGame.Text = &lt;span style="color:#990000;"&gt;"Pause"&lt;/span&gt;;&lt;br /&gt;}&lt;br /&gt;&lt;span style="color:#000099;"&gt;else if &lt;/span&gt;(butGame.Text == &lt;span style="color:#990000;"&gt;"Pause"&lt;/span&gt;)&lt;br /&gt;{&lt;br /&gt;                &lt;span style="color:#009900;"&gt;//GAME PAUSED&lt;/span&gt;&lt;br /&gt;                Game.Stop();&lt;br /&gt;                picGameField.Visible = &lt;span style="color:#000099;"&gt;false&lt;/span&gt;;&lt;br /&gt;                lblDisplay.Text = &lt;span style="color:#990000;"&gt;"Game Paused"&lt;/span&gt;;&lt;br /&gt;                lblDisplay.Visible = &lt;span style="color:#000099;"&gt;true&lt;/span&gt;;&lt;br /&gt;                butGame.Text = &lt;span style="color:#990000;"&gt;"Continue"&lt;/span&gt;;&lt;br /&gt;}&lt;br /&gt;&lt;span style="color:#000099;"&gt;else&lt;/span&gt;&lt;br /&gt;{&lt;br /&gt;                &lt;span style="color:#009900;"&gt;//CONTINUE GAME&lt;/span&gt;&lt;br /&gt;                picGameField.Show();&lt;br /&gt;                butGame.Text = &lt;/span&gt;&lt;span style="font-family:courier new;"&gt;&lt;span style="color:#990000;"&gt;"Pause"&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;;&lt;br /&gt;                picGameField.Visible = &lt;span style="color:#000099;"&gt;true&lt;/span&gt;;&lt;br /&gt;                Game.Start();&lt;br /&gt;                butNG.Visible = &lt;span style="color:#000099;"&gt;false&lt;/span&gt;;&lt;br /&gt;}&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;You probably noticed that we hide the game field when the player clickes 'Pause'. That's because we don't want our players to cheat, and have extra time to plan their moves... Wicked, right? ;) &lt;/p&gt;&lt;p&gt;Now, add another button to the game, and apply it's properties:&lt;/p&gt;&lt;p&gt;&lt;strong&gt;&lt;span style="color:#009900;"&gt;Button&lt;/span&gt;&lt;/strong&gt;&lt;/p&gt;&lt;p&gt;&lt;ul&gt;&lt;li&gt;&lt;span style="color:#ff6600;"&gt;(name):&lt;/span&gt;&lt;strong&gt;&lt;span style="color:#000000;"&gt; butNG&lt;/span&gt;&lt;/strong&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="color:#ff6600;"&gt;Location:&lt;/span&gt; &lt;strong&gt;&lt;span style="color:#000000;"&gt;276; 6&lt;/span&gt;&lt;/strong&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="color:#ff6600;"&gt;Size:&lt;/span&gt; &lt;strong&gt;&lt;span style="color:#000000;"&gt;126; 53&lt;/span&gt;&lt;/strong&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="color:#ff6600;"&gt;Text:&lt;/span&gt; &lt;strong&gt;&lt;span style="color:#000000;"&gt;New Game&lt;/span&gt;&lt;/strong&gt;&lt;/li&gt;&lt;/ul&gt;&lt;br /&gt;This one is going to offer our player the possibility to start a new game. Let's add some code to it. Double click on the new button, and put this code there: &lt;p&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="font-family:courier new;"&gt;&lt;span style="color:#009900;"&gt;//NEW GAME&lt;/span&gt;&lt;br /&gt;picGameField.Show();&lt;br /&gt;picGameField.Refresh();&lt;br /&gt;NewGame();&lt;br /&gt;butGame.Text = &lt;span style="color:#990000;"&gt;"Pause"&lt;/span&gt;;&lt;br /&gt;butNG.Visible = &lt;span style="color:#000099;"&gt;false&lt;/span&gt;;&lt;/span&gt;&lt;br /&gt; &lt;/p&gt;&lt;p&gt;Ok, let's go on - in the next chapter we'll add a High Scores list to our game. Just so our players can brag about their achievements, and to give them a little bit of motivation for playing the game (if they don't hold the #1 spot on the list!). :)&lt;br /&gt;&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1891129859130768227-2782380979465821346?l=create-your-game.blogspot.com' alt='' /&gt;&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/GameDevelopmentTutorials/~4/y9T36-aG12A" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://create-your-game.blogspot.com/feeds/2782380979465821346/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://create-your-game.blogspot.com/2009/04/22-time-for-coffe-break.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/1891129859130768227/posts/default/2782380979465821346?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/1891129859130768227/posts/default/2782380979465821346?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/GameDevelopmentTutorials/~3/y9T36-aG12A/22-time-for-coffe-break.html" title="21. Time for a coffe break" /><author><name>Marin Malnar</name><uri>http://www.blogger.com/profile/12164590973052924670</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="26" height="32" src="http://1.bp.blogspot.com/_4WDpsfty9mg/ShhOIFmmh4I/AAAAAAAAARo/bKSb8UiTYTw/S220/drawing_biker.jpg" /></author><thr:total>0</thr:total><feedburner:origLink>http://create-your-game.blogspot.com/2009/04/22-time-for-coffe-break.html</feedburner:origLink></entry><entry gd:etag="W/&quot;CUAFQXc9fSp7ImA9WxJTGUw.&quot;"><id>tag:blogger.com,1999:blog-1891129859130768227.post-1646004973231488410</id><published>2009-04-24T09:30:00.004+02:00</published><updated>2009-04-28T12:15:10.965+02:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2009-04-28T12:15:10.965+02:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="points" /><category scheme="http://www.blogger.com/atom/ns#" term="level" /><category scheme="http://www.blogger.com/atom/ns#" term="source code" /><category scheme="http://www.blogger.com/atom/ns#" term="bonus" /><title>20. How about a raise?</title><content type="html">&lt;p&gt;To make things a little interesting, we'll give the player bonuses after he completes each level. I've thought of two bonuses: One that is awarded for empty columns, and one that is awarded on top, if there are no blocks left on the game field. To calculate the 'Empty Column Bonus' I used this formula: Level * # of Empty Columns * 100. For the second bonus, I used this formula: Level * 1000. So, If a player manages to clear all block in level 4, he would recieve (4*15*100) 6000 points from the Empty Column Bonus, and additional (4*1000) points from the Cleared Level Bonus. That's 10000 points! Nice! To show the player how many points he was awarded, we'll use our existing label (lblDisplay). And we'll pause the game for a few seconds between the levels. In the end, we'll create a method to switch us between levels. Ok, enough talking. &lt;/p&gt;&lt;p&gt;Let's start coding!This is the code that goes into the LevelScore() method:&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="color:#009900;"&gt;&lt;span style="font-family:courier new;"&gt;// A variable for holding&lt;br /&gt;// TEMPORARY empty column&lt;br /&gt;// bonus:&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;&lt;br /&gt;&lt;span style="color:#000099;"&gt;int&lt;/span&gt; iColBonus = 0;&lt;br /&gt;&lt;span style="color:#009900;"&gt;//Stop the game play...&lt;/span&gt;&lt;br /&gt;Game.Stop();&lt;br /&gt;&lt;/span&gt;&lt;span style="color:#009900;"&gt;&lt;span style="font-family:courier new;"&gt;// Calculate the bonus &lt;br /&gt;// for empty columns&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color:#009900;"&gt;// Go trough all columns:&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#000099;"&gt;for&lt;/span&gt; (&lt;span style="color:#000099;"&gt;int&lt;/span&gt; c = 0; c &lt; iWidth; c++)&lt;br /&gt;{&lt;br /&gt;&lt;/span&gt;&lt;span style="color:#009900;"&gt;&lt;span style="font-family:courier new;"&gt;  // If the column is empty, &lt;br /&gt;  // increase empty column&lt;br /&gt;  // bonus. The column is&lt;br /&gt;  // empty whene there's no&lt;br /&gt;  // block in the lowest field.&lt;br /&gt;  // (Since we have gravity)&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;&lt;br /&gt;  &lt;span style="color:#000099;"&gt;if&lt;/span&gt; (Field[iHeight - 1, c] == 0)&lt;br /&gt;  {&lt;br /&gt;&lt;/span&gt;&lt;span style="color:#009900;"&gt;&lt;span style="font-family:courier new;"&gt;    // You can play with this&lt;br /&gt;    // code to adjust how many&lt;br /&gt;    // points are awarded for&lt;br /&gt;    // every empty column:&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;&lt;br /&gt;    iColBonus += (100 * iLevel);&lt;br /&gt;  }&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color:#009900;"&gt;&lt;span style="font-family:courier new;"&gt;// Add the empty column&lt;br /&gt;// bonus to the total&lt;br /&gt;// score, and show it:&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;&lt;br /&gt;iScore += iColBonus;&lt;br /&gt;lblScore.Text = iScore.ToString();&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color:#009900;"&gt;&lt;span style="font-family:courier new;"&gt;// Calculate the bonus for&lt;br /&gt;// cleared level :)&lt;br /&gt;// (Mission impossible)&lt;br /&gt;&lt;br /&gt;// Temporary variable:&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;&lt;br /&gt;&lt;span style="color:#000099;"&gt;int&lt;/span&gt; iLvlClrBonus = 0;&lt;br /&gt;&lt;span style="color:#000099;"&gt;if&lt;/span&gt; (iColBonus ==&lt;br /&gt;iWidth * (100 * iLevel))&lt;br /&gt;{&lt;br /&gt;&lt;/span&gt;&lt;span style="color:#009900;"&gt;&lt;span style="font-family:courier new;"&gt;  // Code that defines&lt;br /&gt;  // and shows the bonus:&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;&lt;br /&gt;  iLvlClrBonus = iLevel * 1000;&lt;br /&gt;  iScore += iLvlClrBonus;&lt;br /&gt;  lblScore.Text = iScore.ToString();&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color:#009900;"&gt;&lt;span style="font-family:courier new;"&gt;// Inform the user that &lt;br /&gt;// the level is over.&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;&lt;br /&gt;lblDisplay.Text = &lt;span style="color:#990000;"&gt;"Level Complete!"&lt;/span&gt;;&lt;br /&gt;lblDisplay.Visible = &lt;span style="color:#000099;"&gt;true&lt;/span&gt;;&lt;br /&gt;&lt;span style="color:#000099;"&gt;this&lt;/span&gt;.Refresh();&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color:#009900;"&gt;&lt;span style="font-family:courier new;"&gt;// Show bonuses, &lt;br /&gt;// if they exist:&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;&lt;br /&gt;&lt;span style="color:#000099;"&gt;if&lt;/span&gt; (iColBonus &gt; 0)&lt;br /&gt;{&lt;br /&gt;  &lt;/span&gt;&lt;span style="font-family:courier new;"&gt;&lt;span style="color:#009900;"&gt;// Pause 2 seconds:&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;&lt;br /&gt;  System.Threading.&lt;span style="color:#339999;"&gt;Thread&lt;/span&gt;.Sleep(2000);&lt;br /&gt;  &lt;span style="color:#009900;"&gt;// Display first bonus:&lt;/span&gt;&lt;br /&gt;  lblDisplay.Text = &lt;span style="color:#990000;"&gt;"Empty Column Bonus: "&lt;/span&gt;&lt;br /&gt;  + iColBonus.ToString();&lt;br /&gt;  &lt;span style="color:#000099;"&gt;this&lt;/span&gt;.Refresh();&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;span style="color:#000099;"&gt;if&lt;/span&gt; (iLvlClrBonus &gt; 0)&lt;br /&gt;{&lt;br /&gt;  &lt;span style="color:#009900;"&gt;// Pause 2 seconds:&lt;/span&gt;&lt;br /&gt;  System.Threading.&lt;span style="color:#339999;"&gt;Thread&lt;/span&gt;.Sleep(2000);&lt;br /&gt;  &lt;span style="color:#009900;"&gt;// Display second bonus:&lt;/span&gt;&lt;br /&gt;  lblDisplay.Text = &lt;span style="color:#990000;"&gt;"Clear Level Bonus: "&lt;/span&gt;&lt;br /&gt;  + iLvlClrBonus.ToString();&lt;br /&gt;  &lt;span style="color:#000099;"&gt;this&lt;/span&gt;.Refresh();&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;span style="color:#009900;"&gt;// Pause 2 seconds:&lt;/span&gt;&lt;br /&gt;System.Threading.&lt;span style="color:#339999;"&gt;Thread&lt;/span&gt;.Sleep(2000);&lt;br /&gt;&lt;/span&gt;&lt;span style="color:#009900;"&gt;&lt;span style="font-family:courier new;"&gt;// Reset the display&lt;br /&gt;// label, and hide it.&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;&lt;br /&gt;lblDisplay.Visible = &lt;span style="color:#000099;"&gt;false&lt;/span&gt;;&lt;br /&gt;lblDisplay.Text = &lt;/span&gt;&lt;span style="font-family:courier new;"&gt;&lt;span style="color:#990000;"&gt;"GAME OVER!"&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;So, let's move to the next chapter and see how we can play with the parameters of our gameplay to make things more interesting.&lt;/p&gt;&lt;p&gt;&lt;strong&gt;&lt;span style="color:#cc33cc;"&gt;Update: I finally managed to sort out the feed for this site. (Before, the feed for this site was copyed from my other blog... uh...)&lt;/span&gt;&lt;/strong&gt;&lt;br /&gt;&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1891129859130768227-1646004973231488410?l=create-your-game.blogspot.com' alt='' /&gt;&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/GameDevelopmentTutorials/~4/QU86GdKG9RM" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://create-your-game.blogspot.com/feeds/1646004973231488410/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://create-your-game.blogspot.com/2009/04/20-how-about-raise.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/1891129859130768227/posts/default/1646004973231488410?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/1891129859130768227/posts/default/1646004973231488410?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/GameDevelopmentTutorials/~3/QU86GdKG9RM/20-how-about-raise.html" title="20. How about a raise?" /><author><name>Marin Malnar</name><uri>http://www.blogger.com/profile/12164590973052924670</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="26" height="32" src="http://1.bp.blogspot.com/_4WDpsfty9mg/ShhOIFmmh4I/AAAAAAAAARo/bKSb8UiTYTw/S220/drawing_biker.jpg" /></author><thr:total>0</thr:total><feedburner:origLink>http://create-your-game.blogspot.com/2009/04/20-how-about-raise.html</feedburner:origLink></entry><entry gd:etag="W/&quot;CEQCQX84cCp7ImA9WxJTE0Q.&quot;"><id>tag:blogger.com,1999:blog-1891129859130768227.post-7889458369114046721</id><published>2009-04-22T09:30:00.014+02:00</published><updated>2009-04-22T11:26:00.138+02:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2009-04-22T11:26:00.138+02:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="gameplay" /><category scheme="http://www.blogger.com/atom/ns#" term="level" /><category scheme="http://www.blogger.com/atom/ns#" term="source code" /><category scheme="http://www.blogger.com/atom/ns#" term="label" /><title>19. How to get a promotion</title><content type="html">&lt;p&gt;Almost all games have levels. As the player advances, the game becomes more and more difficult. We'll do just that. We'll speed up our gameplay from level to level, and add a new color to the blocks every three or four levels... That should spice things up nicely... Uh! Oh! Another idea: let's increase the number of columns from level to level! So, that would mean that the player needs to survive 15 columns in the first level to move on, 16 in the second, and so on... Our game will not have a finall level. If the player is skilled enough, he could play trough an infinite number of levels. But hey, that's almost impossible. Reaching level 10 will be almost like winning in a lottery ;) Hehe...&lt;/p&gt;&lt;p&gt;So, when the player starts a new game we should reset the level count, score, speed, colors.. So we'll fill our 'NewGame' method.&lt;/p&gt;&lt;p&gt;&lt;span style="color:#009900;"&gt;&lt;span style="font-family:courier new;"&gt;// Reset the level and&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;// score value, and the&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;// number of colors in the game:&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;iLevel = 0;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;lblLevel.Text = iLevel.ToString();&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;iScore = 0;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;lblScore.Text = iScore.ToString();&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;iColor = 3;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;iColors = 0;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;&lt;span style="color:#009900;"&gt;// Reset the game speed&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;Game.Interval = 4000;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="color:#009900;"&gt;&lt;span style="font-family:courier new;"&gt;// We don't have the IOBox yet,&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;// so, the next line is commented&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;// out:&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;// IOBox.Visible = false;&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;lblDisplay.Visible = &lt;span style="color:#000099;"&gt;false&lt;/span&gt;;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;NewLevel();&lt;/span&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;Now, add a new label to the form. Here are the settings:&lt;/p&gt;&lt;p&gt;&lt;p&gt;&lt;strong&gt;&lt;span style="color:#009900;"&gt;Label&lt;/span&gt;&lt;/strong&gt;&lt;/p&gt;&lt;ul&gt;&lt;li&gt;&lt;span style="color:#ff6600;"&gt;(name):&lt;/span&gt;&lt;strong&gt;&lt;span style="color:#000000;"&gt; lblLevel&lt;/span&gt;&lt;/strong&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="color:#ff6600;"&gt;BackgroundColor:&lt;/span&gt; &lt;strong&gt;&lt;span style="color:#000000;"&gt;Web &gt; Transparent&lt;/span&gt;&lt;/strong&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="color:#ff6600;"&gt;Location:&lt;/span&gt; &lt;strong&gt;&lt;span style="color:#000000;"&gt;555;81&lt;/span&gt;&lt;/strong&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="color:#ff6600;"&gt;Font: &lt;/span&gt;&lt;strong&gt;&lt;span style="color:#000000;"&gt;Microsoft Sans Serif; 9,75pt; style=Bold&lt;/span&gt;&lt;/strong&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="color:#ff6600;"&gt;Text:&lt;/span&gt;&lt;strong&gt;&lt;span style="color:#000000;"&gt;1&lt;/span&gt;&lt;/strong&gt;&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;&lt;/p&gt;&lt;p&gt;And here's the code for going from level to level.&lt;br /&gt;(Put it in the NewLevel() method)&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="font-family:courier new;"&gt;&lt;span style="color:#009900;"&gt;//Increase the level number.&lt;/span&gt;&lt;br /&gt;iLevel++;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color:#009900;"&gt;&lt;span style="font-family:courier new;"&gt;// Increase the number of &lt;br /&gt;// columns needed to complete&lt;br /&gt;// the level. You can play&lt;br /&gt;// with this code to make the&lt;br /&gt;// game harder or easier.&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;&lt;br /&gt;iColumns = iWidth - 1 + iLevel;&lt;br /&gt;&lt;br /&gt;&lt;span style="color:#009900;"&gt;// Reset the column count.&lt;/span&gt;&lt;br /&gt;iColumn = 0;&lt;br /&gt;&lt;br /&gt;&lt;span style="color:#009900;"&gt;// Increase the number of colors.&lt;br /&gt;// But only to 10. (because we&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="color:#009900;"&gt;&lt;span style="font-family:courier new;"&gt;// didn't prepare more colours in&lt;br /&gt;// our DrawField method)&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;&lt;br /&gt;&lt;span style="color:#000099;"&gt;if&lt;/span&gt; (iColor &lt; 10)&lt;br /&gt;{&lt;br /&gt;&lt;/span&gt;&lt;span style="color:#009900;"&gt;&lt;span style="font-family:courier new;"&gt;  // Do it every three levels...&lt;br /&gt;  // The number '3' in the next &lt;br /&gt;  // line tells the game how&lt;br /&gt;  // many levels to skip before&lt;br /&gt;  // adding a new color:&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;&lt;br /&gt;  &lt;span style="color:#000099;"&gt;if&lt;/span&gt; (iColors == 3)&lt;br /&gt;  {&lt;br /&gt;    iColor++;&lt;br /&gt;    iColors = 0;&lt;br /&gt;  }&lt;br /&gt;  &lt;span style="color:#000099;"&gt;else&lt;/span&gt;&lt;br /&gt;  {&lt;br /&gt;    iColors++;&lt;br /&gt;  }&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color:#009900;"&gt;&lt;span style="font-family:courier new;"&gt;// Speed up the game.&lt;br /&gt;// We speed it up for 50 &lt;br /&gt;// miliseconds from level&lt;br /&gt;// to level. This, probably,&lt;br /&gt;// will stay unnoticed by&lt;br /&gt;// the player. But you can&lt;br /&gt;// change this to increase&lt;br /&gt;// the difficulty.&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;&lt;br /&gt;&lt;span style="color:#000099;"&gt;if&lt;/span&gt;(iLevel &gt; 1 &amp;amp;&amp;amp;&lt;br /&gt;Game.Interval &gt; 1500)&lt;br /&gt;{&lt;br /&gt;Game.Interval =&lt;br /&gt;Game.Interval - 50;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;span style="color:#009900;"&gt;// Display level text&lt;/span&gt;&lt;br /&gt;lblLevel.Text =&lt;br /&gt;iLevel.ToString();&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color:#009900;"&gt;&lt;span style="font-family:courier new;"&gt;// Create our new level's&lt;br /&gt;// game field (empty):&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;&lt;br /&gt;CreateField();&lt;br /&gt;&lt;span style="color:#009900;"&gt;// And the first column:&lt;/span&gt;&lt;br /&gt;CreateNewColumn();&lt;br /&gt;&lt;br /&gt;&lt;span style="color:#009900;"&gt;// Show it on the screen:&lt;/span&gt;&lt;br /&gt;Redraw();&lt;br /&gt;&lt;br /&gt;&lt;span style="color:#009900;"&gt;// Start the game:&lt;/span&gt;&lt;br /&gt;Game.Start();&lt;/span&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;And the last thing is to change your 'New Game' button's code to this:&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="font-family:courier new;"&gt;NewGame()&lt;/span&gt;&lt;/p&gt;&lt;p&gt;In the next chapter, we'll add some nice bonuses, that'll show between levels, and give the player to 'breathe' for a second or two... Ok, moving on!&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1891129859130768227-7889458369114046721?l=create-your-game.blogspot.com' alt='' /&gt;&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/GameDevelopmentTutorials/~4/jMuXExpDehE" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://create-your-game.blogspot.com/feeds/7889458369114046721/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://create-your-game.blogspot.com/2009/04/19-how-to-get-promotion.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/1891129859130768227/posts/default/7889458369114046721?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/1891129859130768227/posts/default/7889458369114046721?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/GameDevelopmentTutorials/~3/jMuXExpDehE/19-how-to-get-promotion.html" title="19. How to get a promotion" /><author><name>Marin Malnar</name><uri>http://www.blogger.com/profile/12164590973052924670</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="26" height="32" src="http://1.bp.blogspot.com/_4WDpsfty9mg/ShhOIFmmh4I/AAAAAAAAARo/bKSb8UiTYTw/S220/drawing_biker.jpg" /></author><thr:total>0</thr:total><feedburner:origLink>http://create-your-game.blogspot.com/2009/04/19-how-to-get-promotion.html</feedburner:origLink></entry><entry gd:etag="W/&quot;C08DSX4-cSp7ImA9WxJTE00.&quot;"><id>tag:blogger.com,1999:blog-1891129859130768227.post-4182639390830509557</id><published>2009-04-21T10:00:00.014+02:00</published><updated>2009-04-21T10:17:58.059+02:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2009-04-21T10:17:58.059+02:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="source code" /><category scheme="http://www.blogger.com/atom/ns#" term="label" /><category scheme="http://www.blogger.com/atom/ns#" term="math" /><category scheme="http://www.blogger.com/atom/ns#" term="score" /><title>18. Keeping score</title><content type="html">Every game has a way to put a value to the player's effort. In racing games that's done with time (in most cases). In tycoon games, that would be done with money. In our game, we'll just use numbers. So how should we evaluate our players effort? First of all, we have to give him points for every block he destroys. We could make our game give him more points with every new level, and some extra points for the number of different block colors for that level. And some extra scoring math: We could make every block color more valuable... So, let's start with adding a new label to our form, so we could display the score to the player.&lt;br /&gt;&lt;p&gt;The score label properties:&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;p&gt;&lt;strong&gt;&lt;span style="color:#009900;"&gt;Label&lt;/span&gt;&lt;/strong&gt;&lt;/p&gt;&lt;ul&gt;&lt;li&gt;&lt;span style="color:#ff6600;"&gt;(name):&lt;/span&gt;&lt;strong&gt;&lt;span style="color:#000000;"&gt; lblScore&lt;/span&gt;&lt;/strong&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="color:#ff6600;"&gt;BackgroundColor:&lt;/span&gt; &lt;strong&gt;&lt;span style="color:#000000;"&gt;Web &gt; Transparent&lt;/span&gt;&lt;/strong&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="color:#ff6600;"&gt;Location:&lt;/span&gt; &lt;strong&gt;&lt;span style="color:#000000;"&gt;555;65&lt;/span&gt;&lt;/strong&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="color:#ff6600;"&gt;Font: &lt;/span&gt;&lt;strong&gt;&lt;span style="color:#000000;"&gt;Microsoft Sans Serif; 9,75pt; style=Bold&lt;/span&gt;&lt;/strong&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="color:#ff6600;"&gt;Text:&lt;/span&gt;&lt;strong&gt;&lt;span style="color:#000000;"&gt; 0&lt;/span&gt;&lt;/strong&gt;&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;&lt;/p&gt;&lt;p&gt;Then, add this code to your project:&lt;br /&gt;(put it in the DoTheScoreMath() method.)&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="color:#009900;"&gt;&lt;span style="font-family:courier new;"&gt;// We'll process the score only&lt;br /&gt;// if there's multiple blocks&lt;br /&gt;// in the 'Connected List'.&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;&lt;br /&gt;&lt;span style="color:#000099;"&gt;if&lt;/span&gt; (ConnectedList.Count &gt; 1)&lt;br /&gt;{&lt;br /&gt;&lt;/span&gt;&lt;span style="color:#009900;"&gt;&lt;span style="font-family:courier new;"&gt;  // I've declared some&lt;br /&gt;  // variables to hold&lt;br /&gt;  // some values I intend&lt;br /&gt;  // on using to calculate&lt;br /&gt;  // the score.&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;&lt;br /&gt;&lt;span style="color:#000099;"&gt;  int&lt;/span&gt; a = ConnectedList.Count;&lt;br /&gt;&lt;span style="color:#000099;"&gt;  int&lt;/span&gt; b = iLevel;&lt;br /&gt;&lt;span style="color:#000099;"&gt;  int&lt;/span&gt; c = iColor;&lt;br /&gt;&lt;span style="color:#000099;"&gt;  int &lt;/span&gt;d = ConnectedList[0].iFieldColor;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color:#009900;"&gt;&lt;span style="font-family:courier new;"&gt;  // Scoring formula...&lt;br /&gt;  // You can play with it&lt;br /&gt;  // as you like :)&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;&lt;br /&gt;&lt;span style="color:#000099;"&gt;  int&lt;/span&gt; e = a * (b + c) * d;&lt;br /&gt;  &lt;br /&gt;&lt;/span&gt;&lt;span style="color:#009900;"&gt;&lt;span style="font-family:courier new;"&gt;  // Just don't forget to&lt;br /&gt;  // add it to the total&lt;br /&gt;  // score:&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;&lt;br /&gt;  iScore += e;&lt;br /&gt;}&lt;br /&gt;&lt;/span&gt;&lt;span style="color:#009900;"&gt;&lt;span style="font-family:courier new;"&gt;// Oh, and to be a little&lt;br /&gt;// naughty, we'll substract&lt;br /&gt;// a point for every click&lt;br /&gt;// the user makes...&lt;br /&gt;// BUAHAAHAAHHAAAAA!&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;&lt;br /&gt;iScore--;&lt;br /&gt;&lt;br /&gt;&lt;span style="color:#009900;"&gt;// Display the total score:&lt;/span&gt;&lt;br /&gt;lblScore.Text = iScore.ToString();&lt;/span&gt;&lt;/p&gt;&lt;p&gt;Now, add the call in the 'picGF_MouseClick' method, after the existing code:&lt;/p&gt;&lt;p&gt;&lt;span style="font-family:courier new;"&gt;DoTheScoreMath()&lt;/span&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;Done? Cool! Ok, what now? Levels would be cool... Right, then! Next chapter: Levels!&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1891129859130768227-4182639390830509557?l=create-your-game.blogspot.com' alt='' /&gt;&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/GameDevelopmentTutorials/~4/BXUTg58p7mI" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://create-your-game.blogspot.com/feeds/4182639390830509557/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://create-your-game.blogspot.com/2009/04/18-keeping-score.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/1891129859130768227/posts/default/4182639390830509557?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/1891129859130768227/posts/default/4182639390830509557?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/GameDevelopmentTutorials/~3/BXUTg58p7mI/18-keeping-score.html" title="18. Keeping score" /><author><name>Marin Malnar</name><uri>http://www.blogger.com/profile/12164590973052924670</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="26" height="32" src="http://1.bp.blogspot.com/_4WDpsfty9mg/ShhOIFmmh4I/AAAAAAAAARo/bKSb8UiTYTw/S220/drawing_biker.jpg" /></author><thr:total>0</thr:total><feedburner:origLink>http://create-your-game.blogspot.com/2009/04/18-keeping-score.html</feedburner:origLink></entry><entry gd:etag="W/&quot;CEUMRX8zfCp7ImA9WxJTEkw.&quot;"><id>tag:blogger.com,1999:blog-1891129859130768227.post-690156346243948063</id><published>2009-04-20T09:12:00.009+02:00</published><updated>2009-04-20T09:24:44.184+02:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2009-04-20T09:24:44.184+02:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="gameplay" /><category scheme="http://www.blogger.com/atom/ns#" term="source code" /><category scheme="http://www.blogger.com/atom/ns#" term="C#" /><category scheme="http://www.blogger.com/atom/ns#" term="Random" /><title>17. To help, or not to help</title><content type="html">&lt;p&gt;So, our game is almost playable… Well, it is, but there's a lot of stuff to add… Like, random blocks appearing on the game field. The game I 'borrowed' the idea from, had these blocks apearing at radnom time intervals and random places on the game field… And those fields were cool, because, sometimes, they helped to clear you some additional blocks, and sometimes, they filled that valuable empty columns… Ok, back to the drawing board. Litteraly. Here are two examples, first one that shows when the block is helpful, and another one wich shows when it's not that helpful.&lt;/p&gt;&lt;p align="center"&gt;&lt;img style="cursor:pointer; cursor:hand;width: 320px; height: 189px;" src="http://2.bp.blogspot.com/_4WDpsfty9mg/SewhJzG4nNI/AAAAAAAAAHQ/MBvXdFAWK1Y/s320/17_1_Help_or_Not.png" border="0" alt="" id="BLOGGER_PHOTO_ID_5326668911494077650" /&gt;&lt;/p&gt;&lt;p&gt;Take a look at the picture. The player has only two empty columns left. Let's think about the next situaion:  &lt;br /&gt;&lt;br /&gt;a) Let's imagine that in this moment, our game 'spawns' a red field at [4,5]. That would help the player, since he would be able to clear that red field, and the field one block to the right. (the one under [5,4]). The result would be - three empty columns.&lt;/p&gt;&lt;p&gt;b) If we would spawn a blue field at [4,5] - that wouldn't affect the player a lot - he would clear the field, and the blue one on the left. The result would be the same: Two empty columns.&lt;br /&gt; &lt;br /&gt;c) If we wolud spawn a green field at that location, that would be the worst case scenario for the player. He would be stuck with only one empty column.&lt;br /&gt; &lt;br /&gt;Looking at the Field[5,4], the best thing for the player would be, if we created a red block there. In that case, he could empty the #5 column. Spawning a green block wouldn't make a big difference. When the columns would be moved to the right, the green fields could be cleared. Creating a blue field there would be the worst thing for the player, but that wouldn't mean any disadvantages for him. The empty column count would stay the same.&lt;br /&gt;&lt;br /&gt;So, the code for creating a 'random' block:(Put it in the DropBlock() method)&lt;/p&gt;&lt;p&gt;&lt;span style="color:#009900;"&gt;&lt;span style="font-family:courier new;"&gt;// Once again, we'll use the&lt;br /&gt;// random function. We'll&lt;br /&gt;// generate a random color,&lt;br /&gt;// and a random position for&lt;br /&gt;// our new block.&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;&lt;br /&gt;&lt;span style="color:#339999;"&gt;Random&lt;/span&gt; Rndm = &lt;span style="color:#000099;"&gt;new&lt;/span&gt; &lt;span style="color:#339999;"&gt;Random&lt;/span&gt;();&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color:#009900;"&gt;&lt;span style="font-family:courier new;"&gt;// Increasing the random range&lt;br /&gt;// decreases the chance to drop&lt;br /&gt;// the block.&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;&lt;br /&gt;&lt;span style="color:#000099;"&gt;int&lt;/span&gt; R = Rndm.Next(1, 3);&lt;br /&gt;&lt;br /&gt;&lt;span style="color:#000099;"&gt;switch&lt;/span&gt; (R)&lt;br /&gt;{&lt;br /&gt;&lt;span style="color:#000099;"&gt;  case&lt;/span&gt; 1:&lt;br /&gt;&lt;/span&gt;&lt;span style="color:#009900;"&gt;&lt;span style="font-family:courier new;"&gt;    // Drop the block!&lt;br /&gt;    // Generate the position:&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;&lt;br /&gt;&lt;span style="color:#000099;"&gt;    int&lt;/span&gt; RX = Rndm.Next(iHeight - 1);&lt;br /&gt;&lt;span style="color:#000099;"&gt;    int&lt;/span&gt; RY = Rndm.Next(iWidth - 2);&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color:#009900;"&gt;&lt;span style="font-family:courier new;"&gt;    // We dont allow the new block to&lt;br /&gt;    // spawn in the last column - so&lt;br /&gt;    // we don't cause possible gameover's ;)&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color:#009900;"&gt;&lt;span style="font-family:courier new;"&gt;    // We have to see if the field is empty...&lt;br /&gt;    // So we don't overwrite some other field.&lt;br /&gt;    // This also affects the possibility&lt;br /&gt;    // of creating a random block...&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;&lt;br /&gt;&lt;span style="color:#000099;"&gt;    if&lt;/span&gt; (Field[RX, RY] == 0)&lt;br /&gt;    {&lt;br /&gt;&lt;/span&gt;&lt;span style="color:#009900;"&gt;&lt;span style="font-family:courier new;"&gt;      // Fill the block with a random&lt;br /&gt;      // color;&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;&lt;br /&gt;      Field[RX, RY] =&lt;br /&gt;      Rndm.Next(1, iColor + 1);&lt;br /&gt;&lt;span style="color:#009900;"&gt;      // Make it fall down...&lt;/span&gt;&lt;br /&gt;      GoGravity();&lt;br /&gt;    }&lt;br /&gt;&lt;span style="color:#000099;"&gt;    break&lt;/span&gt;;&lt;br /&gt;&lt;br /&gt;&lt;span style="color:#000099;"&gt;    default&lt;/span&gt;:&lt;br /&gt;&lt;span style="color:#000099;"&gt;      break&lt;/span&gt;;&lt;/span&gt;&lt;br /&gt; &lt;br /&gt;In the next chapter, we'll make a score method, so we can let the player know how succesful he was...&lt;br /&gt;&lt;br /&gt;&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1891129859130768227-690156346243948063?l=create-your-game.blogspot.com' alt='' /&gt;&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/GameDevelopmentTutorials/~4/lHvL-yNIfmI" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://create-your-game.blogspot.com/feeds/690156346243948063/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://create-your-game.blogspot.com/2009/04/17-to-help-or-not-to-help.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/1891129859130768227/posts/default/690156346243948063?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/1891129859130768227/posts/default/690156346243948063?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/GameDevelopmentTutorials/~3/lHvL-yNIfmI/17-to-help-or-not-to-help.html" title="17. To help, or not to help" /><author><name>Marin Malnar</name><uri>http://www.blogger.com/profile/12164590973052924670</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="26" height="32" src="http://1.bp.blogspot.com/_4WDpsfty9mg/ShhOIFmmh4I/AAAAAAAAARo/bKSb8UiTYTw/S220/drawing_biker.jpg" /></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://2.bp.blogspot.com/_4WDpsfty9mg/SewhJzG4nNI/AAAAAAAAAHQ/MBvXdFAWK1Y/s72-c/17_1_Help_or_Not.png" height="72" width="72" /><thr:total>0</thr:total><feedburner:origLink>http://create-your-game.blogspot.com/2009/04/17-to-help-or-not-to-help.html</feedburner:origLink></entry><entry gd:etag="W/&quot;CEcHQH0yfSp7ImA9WxVaGUg.&quot;"><id>tag:blogger.com,1999:blog-1891129859130768227.post-3960137350328767054</id><published>2009-04-17T08:42:00.015+02:00</published><updated>2009-04-17T09:07:11.395+02:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2009-04-17T09:07:11.395+02:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="loop" /><category scheme="http://www.blogger.com/atom/ns#" term="source code" /><category scheme="http://www.blogger.com/atom/ns#" term="gravity" /><category scheme="http://www.blogger.com/atom/ns#" term="grid" /><title>16. Thing that makes apples fall</title><content type="html">&lt;p&gt;Uhm, I admit – I lost a whole day to figure this stupid stuff out. And in the end, i ended up with just a few lines of code. It's true that simplicity is the best way. And after writing, like, fifty lines of code that didn't work, i decided to delete it, and to start over. Basically, I took every single block in the game, and checked if it's floating. If it was, I moved it down… This would be the result:&lt;/p&gt;&lt;p align="center"&gt;&lt;img style="cursor:pointer; cursor:hand;width: 212px; height: 212px;" src="http://4.bp.blogspot.com/_4WDpsfty9mg/SegmNmyz-aI/AAAAAAAAAFw/4wn_pQxyPo0/s320/16_1_After_Gravity.png" border="0" alt="" id="BLOGGER_PHOTO_ID_5325548574559435170" /&gt;&lt;/p&gt;&lt;p align="left"&gt;This is the code that goes in the GoGravity() method:&lt;/p&gt;&lt;p align="left"&gt;&lt;span style="color:#009900;"&gt;&lt;span style="font-family:courier new;"&gt;// So, bassicaly, i just use &lt;br /&gt;// a couple of loops to go trough &lt;br /&gt;// all the fields.&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;&lt;span style="color:#009900;"&gt;// Looping through columns:&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;&lt;span style="color:#000099;"&gt;for&lt;/span&gt; (&lt;span style="color:#000099;"&gt;int&lt;/span&gt; s = 0; s &lt; iWidth; s++)&lt;br /&gt;{&lt;br /&gt;  &lt;span style="color:#009900;"&gt;// Looping through rows:&lt;/span&gt;&lt;br /&gt;  &lt;span style="color:#000099;"&gt;for&lt;/span&gt; (&lt;span style="color:#000099;"&gt;int&lt;/span&gt; l = 0; l &lt; iHeight; l++)&lt;br /&gt;  {&lt;br /&gt;      &lt;span style="color:#000099;"&gt;for&lt;/span&gt; (&lt;span style="color:#000099;"&gt;int&lt;/span&gt; v = iHeight - 1; v &gt; 0; v--)&lt;br /&gt;      {&lt;br /&gt;&lt;/span&gt;&lt;span style="color:#009900;"&gt;&lt;span style="font-family:courier new;"&gt;          // In every column, I start  &lt;br /&gt;          // checking from the bottom.&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;&lt;br /&gt;          &lt;span style="color:#000099;"&gt;if &lt;/span&gt;(Field[v, s] == 0)&lt;br /&gt;          {&lt;br /&gt;&lt;/span&gt;&lt;span style="color:#009900;"&gt;&lt;span style="font-family:courier new;"&gt;              // If the field is empty, I  &lt;br /&gt;              // drop the field above it &lt;br /&gt;              // down one block.&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;&lt;br /&gt;              Field[v, s] = Field[v - 1, s];&lt;br /&gt;              Field[v - 1, s] = 0;&lt;br /&gt;          }&lt;br /&gt;      }&lt;br /&gt;  }&lt;br /&gt;}&lt;br /&gt;&lt;/span&gt;&lt;span style="color:#009900;"&gt;&lt;span style="font-family:courier new;"&gt;// And to show the changes, &lt;br /&gt;// I call the Redraw() method:&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;&lt;br /&gt;Redraw();&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;/p&gt;&lt;p align="left"&gt;And this is the code that goes into the Redraw() method:&lt;/p&gt;&lt;p align="left"&gt;&lt;span style="font-family:courier new;"&gt;&lt;span style="color:#009900;"&gt;//Drawing our field and grid:&lt;/span&gt;&lt;br /&gt;DrawGrid()&lt;br /&gt;DrawField()&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1891129859130768227-3960137350328767054?l=create-your-game.blogspot.com' alt='' /&gt;&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/GameDevelopmentTutorials/~4/yHZ8b22GB9M" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://create-your-game.blogspot.com/feeds/3960137350328767054/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://create-your-game.blogspot.com/2009/04/16-thing-that-makes-apples-fall.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/1891129859130768227/posts/default/3960137350328767054?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/1891129859130768227/posts/default/3960137350328767054?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/GameDevelopmentTutorials/~3/yHZ8b22GB9M/16-thing-that-makes-apples-fall.html" title="16. Thing that makes apples fall" /><author><name>Marin Malnar</name><uri>http://www.blogger.com/profile/12164590973052924670</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="26" height="32" src="http://1.bp.blogspot.com/_4WDpsfty9mg/ShhOIFmmh4I/AAAAAAAAARo/bKSb8UiTYTw/S220/drawing_biker.jpg" /></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://4.bp.blogspot.com/_4WDpsfty9mg/SegmNmyz-aI/AAAAAAAAAFw/4wn_pQxyPo0/s72-c/16_1_After_Gravity.png" height="72" width="72" /><thr:total>0</thr:total><feedburner:origLink>http://create-your-game.blogspot.com/2009/04/16-thing-that-makes-apples-fall.html</feedburner:origLink></entry><entry gd:etag="W/&quot;D0IASHg7eSp7ImA9WxVaGEs.&quot;"><id>tag:blogger.com,1999:blog-1891129859130768227.post-2872226025695205616</id><published>2009-04-16T08:35:00.004+02:00</published><updated>2009-04-16T09:05:49.601+02:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2009-04-16T09:05:49.601+02:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="game field" /><category scheme="http://www.blogger.com/atom/ns#" term="destroying fields" /><title>15. Destroying the blocks</title><content type="html">&lt;p&gt;Like I said, this is going to be pretty straight-forward chapter. To destroy the blocks, all we need to do is set their value to 0. And, since we have a list of blocks to destroy, we'll just use a simple FOR loop. The only thing we have to check is that the list contains more than one field. If not, the user clicked on a field that is not connected to any fields of the same color. Nothing fancy here. Here's the code (put it in your &lt;span style="font-family:courier new;"&gt;DestroyBlocks()&lt;/span&gt; method!):&lt;/p&gt;&lt;p&gt;&lt;span style="color:#009900;"&gt;&lt;span style="font-family:courier new;"&gt;// First, we'll check if the&lt;br /&gt;// List contains more than&lt;br /&gt;// one block. If it does, we&lt;br /&gt;// destroy all the fields in&lt;br /&gt;// it by setting their value&lt;br /&gt;// to 0.&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;&lt;br /&gt;&lt;span style="color:#000099;"&gt;if&lt;/span&gt; (ConnectedList.Count &gt; 1)&lt;br /&gt;{&lt;br /&gt;&lt;span style="color:#000099;"&gt;  for&lt;/span&gt; (&lt;span style="color:#000099;"&gt;int&lt;/span&gt; d = 0;&lt;br /&gt;  d &lt; ConnectedList.Count;&lt;br /&gt;  d++)&lt;br /&gt;  {&lt;br /&gt;    Field[ConnectedList[d].iXcoordinate,&lt;br /&gt;    ConnectedList[d].iYcoordinate] = 0;&lt;br /&gt;  }&lt;br /&gt;}&lt;/span&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;Simple, right?  So, if you remember the picture from the last chapter – here's how that field would look now, after destroying the selected blocks:&lt;/p&gt;&lt;p align="center"&gt;&lt;img style="cursor:pointer; cursor:hand;width: 212px; height: 212px;" src="http://4.bp.blogspot.com/_4WDpsfty9mg/SebShbjmHMI/AAAAAAAAAFQ/kQvlR4sn5Fs/s320/15_1_After_Destroying.png" border="0" alt="" id="BLOGGER_PHOTO_ID_5325175081186761922" /&gt;&lt;/p&gt;&lt;p&gt;In the next chapter, we'll create some gravity. Gravity will force all those floating blocks to fall down. See the floating blocks? (Hint: Field[0,0], Field[0,1] and Field[1,0]). And after that, our game will be almost playable. When we finish gravity, we'll start working on different 'bonus' stuff, levels (like promissed), scoring (and high score lists), design and graphics, and a little 'Drop Block' feature wich will randomly create a single block somewhere in our game field… So, click on, and discover the secrets of Gravity!&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1891129859130768227-2872226025695205616?l=create-your-game.blogspot.com' alt='' /&gt;&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/GameDevelopmentTutorials/~4/flMpLm4MjMM" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://create-your-game.blogspot.com/feeds/2872226025695205616/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://create-your-game.blogspot.com/2009/04/15-destroying-blocks.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/1891129859130768227/posts/default/2872226025695205616?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/1891129859130768227/posts/default/2872226025695205616?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/GameDevelopmentTutorials/~3/flMpLm4MjMM/15-destroying-blocks.html" title="15. Destroying the blocks" /><author><name>Marin Malnar</name><uri>http://www.blogger.com/profile/12164590973052924670</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="26" height="32" src="http://1.bp.blogspot.com/_4WDpsfty9mg/ShhOIFmmh4I/AAAAAAAAARo/bKSb8UiTYTw/S220/drawing_biker.jpg" /></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://4.bp.blogspot.com/_4WDpsfty9mg/SebShbjmHMI/AAAAAAAAAFQ/kQvlR4sn5Fs/s72-c/15_1_After_Destroying.png" height="72" width="72" /><thr:total>0</thr:total><feedburner:origLink>http://create-your-game.blogspot.com/2009/04/15-destroying-blocks.html</feedburner:origLink></entry><entry gd:etag="W/&quot;D0QEQno7cSp7ImA9WxVaGEs.&quot;"><id>tag:blogger.com,1999:blog-1891129859130768227.post-1862613782040268551</id><published>2009-04-09T08:05:00.049+02:00</published><updated>2009-04-16T09:01:43.409+02:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2009-04-16T09:01:43.409+02:00</app:edited><title>14. Connections make the world spin</title><content type="html">&lt;p&gt;So, to explain what we need to do – I've drawn an image:&lt;/p&gt;&lt;p align="center"&gt;&lt;img style="cursor:pointer; cursor:hand;width: 212px; height: 212px;" src="http://2.bp.blogspot.com/_4WDpsfty9mg/SebTAVJYrMI/AAAAAAAAAFg/tB5j878eg0k/s320/14_1_Checking_Connections.png" border="0" alt="" id="BLOGGER_PHOTO_ID_5325175612042161346" /&gt;&lt;/p&gt;&lt;p&gt;Let's say that the player clicks on the Field[1,1]. Our game should detect that the [1,1] field is connected to two more blue fields (Field[2,1] and Field[2,0]). In our game, the rule will be that fields are connected horizontal and vertical, but not diagonal. How do we do this? First of all, we'll create a list of connected fields. We'll put in the field user clicked. And then, we'll check fields above it, below, to the right and to the left to see if they hold the same (color) value. If they do, we'll put them too in our list. And then we'll go trough our list, field by field, searching for connections for every field in our list. If we find any connections, we'll check if they are already in the list. If no, we'll add them. Sounds complicated. Even I can't understand what I just wrote. :o) I'll try to write this as a step by step list:&lt;/p&gt;&lt;ol&gt;&lt;li&gt;&lt;br /&gt;Player clicks Field[1,1]&lt;/li&gt;&lt;li&gt;We add Filed[1,1] to our list&lt;/li&gt;&lt;li&gt;We check the field above it (Field[0,1]) to see if it's the same color. Since it's not, we ignore it.&lt;/li&gt;&lt;li&gt;We check the field below if (Field[2,1]) to see if it's the same color. It is, so we add it to the list.&lt;/li&gt;&lt;li&gt;We check the field on the left (Field[1,0]) – it's not the same color, so we ignore it.&lt;/li&gt;&lt;li&gt;We check the field on the right (Field[1,2]) – it's not the same color, so we, once again, ignore it.&lt;/li&gt;&lt;li&gt;We move to the next item (Field[2,1]) in our list, and repeat the steps for it…&lt;/li&gt;&lt;li&gt;We check the field above it (Field[1,1]), but we ignore it since it's already in our list…&lt;/li&gt;&lt;li&gt;Eventualy we find the Field[2,0], add it to our list, and that's it…&lt;br /&gt;&lt;/li&gt;&lt;/ol&gt;&lt;p&gt;So, how does this look like, code wise? First we'll have to declare our list, and then create a couple of methods for checking connections: A method that goes up, down, left and right, another one that cheks if the field is already in our list, and another one that makes sure that we check connections for every field from the list. There's one new thing here, thoug – structs. Think of them as some sort of containers that can hold a lot of different variables… So, first declare our struct. Put the declaration on top of the code, where you have your other public declarations.&lt;/p&gt;&lt;p&gt;&lt;span style="font-family:courier new;"&gt;&lt;span style="color:#009900;"&gt;// Struct for our  connected&lt;br /&gt;// fields.&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;&lt;span style="color:#000099;"&gt;struct&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt; stField&lt;br /&gt;{&lt;br /&gt;public int iFieldColor;&lt;br /&gt;public int iXcoordinate;&lt;br /&gt;public int iYcoordinate;&lt;br /&gt;}&lt;/span&gt;&lt;/p&gt;&lt;p&gt;And then declare the list to hold the connected fields:&lt;/p&gt;&lt;p&gt;&lt;span style="font-family:courier new;"&gt;&lt;span style="color:#009900;"&gt;// List of our connected fields.&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;&lt;br /&gt;&lt;span style="color:#339999;"&gt;List&lt;/span&gt;&lt;&lt;span style="color:#339999;"&gt;stField&lt;/span&gt;&gt; ConnectedList =&lt;br /&gt;&lt;span style="color:#000099;"&gt;new&lt;/span&gt; &lt;/span&gt;&lt;span style="font-family:courier new;"&gt;&lt;span style="color:#339999;"&gt;List&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;&lt;&lt;span style="color:#339999;"&gt;stField&lt;/span&gt;&gt;();&lt;/span&gt;&lt;stfield&gt;&lt;stfield&gt;&lt;/p&gt;&lt;p&gt;Right. Now, check the code - the method &amp;amp; function declarations are a little different... So, be careful :)&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="font-family:courier new;"&gt;&lt;span style="color:#000099;"&gt;private void&lt;/span&gt; CheckConnected&lt;br /&gt;(&lt;span style="color:#000099;"&gt;int&lt;/span&gt; Xpos, &lt;span style="color:#000099;"&gt;int&lt;/span&gt; Ypos, &lt;span style="color:#000099;"&gt;bool&lt;/span&gt; bClick)&lt;br /&gt;{&lt;br /&gt;&lt;/span&gt;&lt;span style="color:#009900;"&gt;&lt;span style="font-family:courier new;"&gt;// This is the struct that will hold the&lt;br /&gt;// Connected field position and value.&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;&lt;br /&gt;&lt;span style="color:#339999;"&gt;stField&lt;/span&gt; stField = &lt;span style="color:#000099;"&gt;new&lt;/span&gt; &lt;span style="color:#339999;"&gt;stField&lt;/span&gt;();&lt;br /&gt;stField.iFieldColor = Field[Xpos, Ypos];&lt;br /&gt;stField.iXcoordinate = Xpos;&lt;br /&gt;stField.iYcoordinate = Ypos;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color:#009900;"&gt;&lt;span style="font-family:courier new;"&gt;// bClick actualy means that the field&lt;br /&gt;// was clicked on by player, so we add&lt;br /&gt;// it to the list automatically.&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;&lt;br /&gt;&lt;span style="color:#000099;"&gt;if&lt;/span&gt; (bClick == &lt;span style="color:#000099;"&gt;true&lt;/span&gt;)&lt;br /&gt;{&lt;br /&gt;&lt;/span&gt;&lt;span style="color:#009900;"&gt;&lt;span style="font-family:courier new;"&gt;// So, we add the field to our list,&lt;br /&gt;// we check if it's already in the list,&lt;br /&gt;// and we add it if not. This isn't&lt;br /&gt;// necesary here, since logic thinking&lt;br /&gt;// tells us that the list is empty at&lt;br /&gt;// this point. But, just to be safe...&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;&lt;br /&gt;&lt;span style="color:#000099;"&gt;if&lt;/span&gt; (CheckIfInList&lt;br /&gt;(stField.iXcoordinate, &lt;br /&gt;stField.iYcoordinate) == &lt;/span&gt;&lt;span style="font-family:courier new;"&gt;&lt;span style="color:#000099;"&gt;false&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;)&lt;br /&gt;{&lt;br /&gt;ConnectedList.Add(stField);&lt;br /&gt;}&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color:#009900;"&gt;&lt;span style="font-family:courier new;"&gt;//Checks fields up and down from &lt;br /&gt;//the desired field.&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;&lt;br /&gt;&lt;span style="color:#000099;"&gt;if &lt;/span&gt;(stField.iXcoordinate &gt; 0)&lt;br /&gt;{&lt;br /&gt;&lt;span style="color:#000099;"&gt;if&lt;/span&gt; (Field[stField.iXcoordinate - 1,&lt;br /&gt;stField.iYcoordinate] == &lt;br /&gt;Field[stField.iXcoordinate, &lt;br /&gt;stField.iYcoordinate])&lt;br /&gt;{&lt;br /&gt;&lt;/span&gt;&lt;span style="color:#009900;"&gt;&lt;span style="font-family:courier new;"&gt;// Field above has the same value(color).&lt;br /&gt;// We add it to the list.&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;&lt;br /&gt;stField.iXcoordinate = &lt;br /&gt;stField.iXcoordinate - 1;&lt;br /&gt;&lt;span style="color:#000099;"&gt;if&lt;/span&gt; (CheckIfInList(stField.iXcoordinate,&lt;br /&gt;stField.iYcoordinate) == &lt;span style="color:#000099;"&gt;false&lt;/span&gt;)&lt;br /&gt;{&lt;br /&gt;ConnectedList.Add(stField);&lt;br /&gt;}&lt;br /&gt;stField.iXcoordinate = &lt;br /&gt;stField.iXcoordinate + 1;&lt;br /&gt;}&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;span style="color:#000099;"&gt;if&lt;/span&gt; (stField.iXcoordinate &lt; iHeight - 1)&lt;br /&gt;{&lt;br /&gt;&lt;span style="color:#000099;"&gt;if&lt;/span&gt; (Field[stField.iXcoordinate + 1,&lt;br /&gt;stField.iYcoordinate] == &lt;br /&gt;Field[stField.iXcoordinate, &lt;br /&gt;stField.iYcoordinate])&lt;br /&gt;{&lt;br /&gt;&lt;/span&gt;&lt;span style="color:#009900;"&gt;&lt;span style="font-family:courier new;"&gt;// Field below has the same value(color).&lt;br /&gt;// We add it to the list.&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;&lt;br /&gt;stField.iXcoordinate = &lt;br /&gt;stField.iXcoordinate + 1;&lt;br /&gt;&lt;span style="color:#000099;"&gt;if&lt;/span&gt; (CheckIfInList(stField.iXcoordinate,&lt;br /&gt;stField.iYcoordinate) == &lt;span style="color:#000099;"&gt;false&lt;/span&gt;)&lt;br /&gt;{&lt;br /&gt;ConnectedList.Add(stField);&lt;br /&gt;}&lt;br /&gt;stField.iXcoordinate = &lt;br /&gt;stField.iXcoordinate - 1;&lt;br /&gt;}&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color:#009900;"&gt;&lt;span style="font-family:courier new;"&gt;//Checks fields left and right&lt;br /&gt;//from the desired field.&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;&lt;br /&gt;&lt;span style="color:#000099;"&gt;if&lt;/span&gt; (stField.iYcoordinate &gt; 0)&lt;br /&gt;{&lt;br /&gt;&lt;span style="color:#000099;"&gt;if&lt;/span&gt; (Field[stField.iXcoordinate,&lt;br /&gt;stField.iYcoordinate - 1] ==&lt;br /&gt;Field[stField.iXcoordinate,&lt;br /&gt;stField.iYcoordinate])&lt;br /&gt;{&lt;br /&gt;&lt;/span&gt;&lt;span style="color:#009900;"&gt;&lt;span style="font-family:courier new;"&gt;// Field to the left has the same&lt;br /&gt;// value(color). We add it to the list.&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;&lt;br /&gt;stField.iYcoordinate = &lt;br /&gt;stField.iYcoordinate - 1;&lt;br /&gt;&lt;span style="color:#000099;"&gt;if &lt;/span&gt;(CheckIfInList(stField.iXcoordinate, &lt;br /&gt;stField.iYcoordinate) == &lt;span style="color:#000099;"&gt;false&lt;/span&gt;)&lt;br /&gt;{&lt;br /&gt;ConnectedList.Add(stField);&lt;br /&gt;}&lt;br /&gt;stField.iYcoordinate = &lt;br /&gt;stField.iYcoordinate + 1;&lt;br /&gt;}&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;span style="color:#000099;"&gt;if &lt;/span&gt;(stField.iYcoordinate &lt; iWidth - 1)&lt;br /&gt;{&lt;br /&gt;&lt;span style="color:#000099;"&gt;if&lt;/span&gt; (Field[stField.iXcoordinate, &lt;br /&gt;stField.iYcoordinate + 1] ==&lt;br /&gt;Field[stField.iXcoordinate,&lt;br /&gt;stField.iYcoordinate])&lt;br /&gt;{&lt;br /&gt;&lt;/span&gt;&lt;span style="color:#009900;"&gt;&lt;span style="font-family:courier new;"&gt;// Field to the right has the same &lt;br /&gt;// value(color). We add it to the list.&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;&lt;br /&gt;stField.iYcoordinate = &lt;br /&gt;stField.iYcoordinate + 1;&lt;br /&gt;&lt;span style="color:#000099;"&gt;if&lt;/span&gt; (CheckIfInList(stField.iXcoordinate, &lt;br /&gt;stField.iYcoordinate) == &lt;span style="color:#000099;"&gt;false&lt;/span&gt;)&lt;br /&gt;{&lt;br /&gt;ConnectedList.Add(stField);&lt;br /&gt;}&lt;br /&gt;stField.iYcoordinate = &lt;br /&gt;stField.iYcoordinate - 1;&lt;br /&gt;}&lt;br /&gt;}&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;span style="color:#000099;"&gt;private void&lt;/span&gt; CheckAll()&lt;br /&gt;{&lt;br /&gt;&lt;/span&gt;&lt;span style="color:#009900;"&gt;&lt;span style="font-family:courier new;"&gt;// This method goes trough the list,&lt;br /&gt;// and re-checks connections for&lt;br /&gt;// every field in it.&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;&lt;br /&gt;&lt;span style="color:#000099;"&gt;if&lt;/span&gt; (ConnectedList.Count &gt; 1)&lt;br /&gt;{&lt;br /&gt;&lt;span style="color:#000099;"&gt;for &lt;/span&gt;(&lt;span style="color:#000099;"&gt;int&lt;/span&gt; l = 0; l &lt; &lt;br /&gt;ConnectedList.Count; l++)&lt;br /&gt;{&lt;br /&gt;CheckConnected&lt;br /&gt;(ConnectedList[l].iXcoordinate,&lt;br /&gt;ConnectedList[l].iYcoordinate, &lt;br /&gt;&lt;span style="color:#000099;"&gt;false&lt;/span&gt;);&lt;br /&gt;}&lt;br /&gt;}&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;span style="color:#000099;"&gt;private bool&lt;/span&gt; CheckIfInList&lt;br /&gt;(&lt;span style="color:#000099;"&gt;int&lt;/span&gt; PXpos, &lt;span style="color:#000099;"&gt;int&lt;/span&gt; PYpos)&lt;br /&gt;{&lt;br /&gt;&lt;/span&gt;&lt;span style="color:#009900;"&gt;&lt;span style="font-family:courier new;"&gt;// This function checks if the&lt;br /&gt;// field is in the list or not.&lt;br /&gt;// If the field is in the list,&lt;br /&gt;// the function returns boolean&lt;br /&gt;// 'TRUE'. If not, it returns&lt;br /&gt;// boolean 'FALSE'.&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color:#000099;"&gt;for&lt;/span&gt; (&lt;span style="color:#000099;"&gt;int&lt;/span&gt; l = 0; &lt;br /&gt;l &lt; ConnectedList.Count; l++)&lt;br /&gt;{&lt;br /&gt;&lt;span style="color:#000099;"&gt;if&lt;/span&gt; (ConnectedList[l].iXcoordinate &lt;br /&gt;== PXpos &amp;amp;&amp;amp; ConnectedList[l].iYcoordinate&lt;br /&gt;== PYpos)&lt;br /&gt;{&lt;br /&gt;&lt;span style="color:#009900;"&gt;// The field is in the list:&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#000099;"&gt;return true&lt;/span&gt;;&lt;br /&gt;}&lt;br /&gt;}&lt;br /&gt;&lt;span style="color:#009900;"&gt;// The field is not in the list:&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#000099;"&gt;return false&lt;/span&gt;;&lt;br /&gt;}&lt;/span&gt;&lt;span &gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span &gt;Right. Hope this works… So, now we know what the user clicked. And if there are more than one blocks connected, we should destroy them. That's going to be easy. After destroying the blocks, we'll have to make the gravity. So we don't wind up with floating blocks… Moving on…&lt;/span&gt;&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1891129859130768227-1862613782040268551?l=create-your-game.blogspot.com' alt='' /&gt;&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/GameDevelopmentTutorials/~4/-_2Nc7bOMnc" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://create-your-game.blogspot.com/feeds/1862613782040268551/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://create-your-game.blogspot.com/2009/04/14-connections-make-world-spin.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/1891129859130768227/posts/default/1862613782040268551?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/1891129859130768227/posts/default/1862613782040268551?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/GameDevelopmentTutorials/~3/-_2Nc7bOMnc/14-connections-make-world-spin.html" title="14. Connections make the world spin" /><author><name>Marin Malnar</name><uri>http://www.blogger.com/profile/12164590973052924670</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="26" height="32" src="http://1.bp.blogspot.com/_4WDpsfty9mg/ShhOIFmmh4I/AAAAAAAAARo/bKSb8UiTYTw/S220/drawing_biker.jpg" /></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://2.bp.blogspot.com/_4WDpsfty9mg/SebTAVJYrMI/AAAAAAAAAFg/tB5j878eg0k/s72-c/14_1_Checking_Connections.png" height="72" width="72" /><thr:total>0</thr:total><feedburner:origLink>http://create-your-game.blogspot.com/2009/04/14-connections-make-world-spin.html</feedburner:origLink></entry><entry gd:etag="W/&quot;DkQAR3szfip7ImA9WxVaEUo.&quot;"><id>tag:blogger.com,1999:blog-1891129859130768227.post-4806089597056413842</id><published>2009-04-08T08:58:00.011+02:00</published><updated>2009-04-08T09:05:46.586+02:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2009-04-08T09:05:46.586+02:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="conversion" /><category scheme="http://www.blogger.com/atom/ns#" term="data type" /><category scheme="http://www.blogger.com/atom/ns#" term="source code" /><category scheme="http://www.blogger.com/atom/ns#" term="C#" /><category scheme="http://www.blogger.com/atom/ns#" term="math" /><title>13. Chasing the mouse</title><content type="html">&lt;p&gt;In our game, we'll use the mouse as an input device. Player will be able to click anywhere in the game field, and we'll have to figure out if he clicked a block, or an empty field. If the player clicks on the block, we'll have to check if it's connected with any other block of the same color, and we'll have to destroy the blocks if so. And to add a little feature, we'll take away one point for every mouse click. (Wich reminds me… We'll have to make a score counter, real soon.) So, how the hell can we find out where the user clicked? Lucky for us, the Picture Box in wich we draw our game field, has a MouseClick event. So, we'll use it to see if the user clicked anywhere on the game field. But how to find out on what block the user clicked? A little basic math will help us solve this problem. We already have defined that the block field is 32 pixels in width/height. And lucky for us, VS.net can give us the coordinates of the mouse pointer on the screen, and in relation to the clicked object. That means, that VS will give us the distance from the top and left borders of the picture box, measured in pixels. So, those are the ingreedients. Let's mix them all together and see how they work. First of all, go to your design window, select the Picture Box, and then, go to your Properties window. Just above the properties list ther is a little icon of lightning. Click on it, and you'll see the events list. Find the MouseClick event, and double-click on it's name. This should give you the code editor window with the method already in place. Here's the code for it:&lt;/p&gt;&lt;p&gt;&lt;span style="color:#009900;"&gt;&lt;span style="font-family:courier new;"&gt;// We find the X and the Y coordinate of &lt;br /&gt;// the mouse using the mouse event arguments&lt;br /&gt;// (called 'e'). We'll store them into some &lt;br /&gt;// variables. Note, how we switched X and Y's &lt;br /&gt;// place – that's because we declared our game&lt;br /&gt;// field in the opposite way – X for height &lt;br /&gt;// and Y for width. I know… Goofy…&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;&lt;span style="color:#000099;"&gt;int&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt; mx = e.Location.Y;&lt;br /&gt;&lt;span style="color:#000099;"&gt;int&lt;/span&gt; my = e.Location.X;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color:#009900;"&gt;&lt;span style="font-family:courier new;"&gt;// The next step is to divide the mouse &lt;br /&gt;// coordinates with the block/field size,&lt;br /&gt;// so we'll get the coordinates of our field.&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;&lt;br /&gt;&lt;span style="color:#000099;"&gt;decimal&lt;/span&gt; x = mx / iFieldSize;&lt;br /&gt;&lt;span style="color:#000099;"&gt;decimal&lt;/span&gt; y = my / iFieldSize;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color:#009900;"&gt;&lt;span style="font-family:courier new;"&gt;/ And to round them up (since they came &lt;br /&gt;// back as numbers with decimals) we &lt;br /&gt;// convert them right back into intigers.&lt;br /&gt;// Not to mention that we need them as &lt;br /&gt;// integers, to define our fields.&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;&lt;br /&gt;&lt;span style="color:#000099;"&gt;int&lt;/span&gt; ix = (&lt;span style="color:#000099;"&gt;int&lt;/span&gt;)x;&lt;br /&gt;&lt;span style="color:#000099;"&gt;int&lt;/span&gt; iy = (&lt;span style="color:#000099;"&gt;int&lt;/span&gt;)y;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;This code will give you exact coordinates of the block player clicked. Ok, what's next? Obviously, we'll have to see if the block player clicked, is actualy connected to other blocks of the same color. And we'll do just that – in the next chapter.&lt;br /&gt;&lt;br /&gt;&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1891129859130768227-4806089597056413842?l=create-your-game.blogspot.com' alt='' /&gt;&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/GameDevelopmentTutorials/~4/uj1a9ZXC7GE" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://create-your-game.blogspot.com/feeds/4806089597056413842/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://create-your-game.blogspot.com/2009/04/13-trying-to-catch-mouse-in-our-field.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/1891129859130768227/posts/default/4806089597056413842?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/1891129859130768227/posts/default/4806089597056413842?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/GameDevelopmentTutorials/~3/uj1a9ZXC7GE/13-trying-to-catch-mouse-in-our-field.html" title="13. Chasing the mouse" /><author><name>Marin Malnar</name><uri>http://www.blogger.com/profile/12164590973052924670</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="26" height="32" src="http://1.bp.blogspot.com/_4WDpsfty9mg/ShhOIFmmh4I/AAAAAAAAARo/bKSb8UiTYTw/S220/drawing_biker.jpg" /></author><thr:total>0</thr:total><feedburner:origLink>http://create-your-game.blogspot.com/2009/04/13-trying-to-catch-mouse-in-our-field.html</feedburner:origLink></entry><entry gd:etag="W/&quot;A0YDSXY_eCp7ImA9WxVbGUQ.&quot;"><id>tag:blogger.com,1999:blog-1891129859130768227.post-1409179374320528437</id><published>2009-04-06T08:13:00.007+02:00</published><updated>2009-04-06T08:26:18.840+02:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2009-04-06T08:26:18.840+02:00</app:edited><title>12. NOOOOO! Game Over!?</title><content type="html">&lt;p&gt;This chapter will be a short one. When the game detects that conditions for GameOver are met, we basicaly have to stop the game play, and let the user know it's over. This would be a good time to process the score, and see if the player made it to the hall of fame… I know, I know… We don't have a High Score list. Not yet! We'll come to it somewere near the end of this tutorial. So, I'll just put the code for the GameOver() method here, so we could move on to another fun part of the tutorial – Chasing the mouse over the field.&lt;/p&gt;&lt;p&gt;&lt;span style="color:#009900;"&gt;&lt;span style="font-family:courier new;"&gt;// First, we stop the game play&lt;br /&gt;// by stopping the Game timer.&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;&lt;br /&gt;Game.Enabled = &lt;span style="color:#000099;"&gt;false&lt;/span&gt;;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color:#009900;"&gt;&lt;span style="font-family:courier new;"&gt;// Then we display the Game Over&lt;br /&gt;// message.&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;&lt;br /&gt;lblDisplay.Visible = &lt;span style="color:#000099;"&gt;true&lt;/span&gt;;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;I hope you didn't try to run your program yet. I forgot to tell you: You need another label on your form. So, back to the design view, add a label, and adjust it to meet these specifications:&lt;/p&gt;&lt;p&gt;&lt;strong&gt;&lt;span style="color:#009900;"&gt;Label&lt;/span&gt;&lt;/strong&gt;&lt;/p&gt;&lt;ul&gt;&lt;li&gt;&lt;span style="color:#ff6600;"&gt;(name): &lt;/span&gt;&lt;strong&gt;&lt;span style="color:#000000;"&gt;lblDisplay&lt;/span&gt;&lt;/strong&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="color:#ff6600;"&gt;Autosize:&lt;/span&gt; &lt;strong&gt;&lt;span style="color:#000000;"&gt;False&lt;/span&gt;&lt;/strong&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="color:#ff6600;"&gt;BackColor:&lt;/span&gt;&lt;strong&gt;&lt;span style="color:#000000;"&gt; Web &gt; Transparent&lt;/span&gt;&lt;/strong&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="color:#ff6600;"&gt;Font: &lt;/span&gt;&lt;strong&gt;&lt;span style="color:#000000;"&gt;Arial Black; 27,75pt; style=Bold&lt;/span&gt;&lt;/strong&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="color:#ff6600;"&gt;Forecolor: &lt;/span&gt;&lt;strong&gt;&lt;span style="color:#000000;"&gt;Web &gt; Red&lt;/span&gt;&lt;/strong&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="color:#ff6600;"&gt;Location:&lt;/span&gt;&lt;strong&gt;&lt;span style="color:#000000;"&gt; 12; 388&lt;/span&gt;&lt;/strong&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="color:#ff6600;"&gt;Size:&lt;/span&gt; &lt;strong&gt;&lt;span style="color:#000000;"&gt;600; 52&lt;/span&gt;&lt;/strong&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="color:#ff6600;"&gt;Text: &lt;/span&gt;&lt;strong&gt;&lt;span style="color:#000000;"&gt;GAME OVER!&lt;/span&gt;&lt;/strong&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="color:#ff6600;"&gt;TextAlign: &lt;/span&gt;&lt;strong&gt;&lt;span style="color:#000000;"&gt;TopCenter&lt;/span&gt;&lt;/strong&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="color:#ff6600;"&gt;Visible: &lt;/span&gt;&lt;strong&gt;&lt;span style="color:#000000;"&gt;False&lt;/span&gt;&lt;/strong&gt;&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;&lt;span style="color:#000000;"&gt;Right. Now we're ready to test our game. It should show the 'Game Over' message when the game field fills with columns. Here's a screenshot of how the game should look at this stage: (Huh, notice that I forgot to select the 'Show Grid' check box)&lt;/span&gt;&lt;/p&gt;&lt;p align="center"&gt;&lt;img style="cursor:pointer; cursor:hand;width: 320px; height: 238px;" src="http://2.bp.blogspot.com/_4WDpsfty9mg/SdmgdOpKkrI/AAAAAAAAAFI/lms13VxIQE0/s320/12_1_Game_Over.png" border="0" alt="" id="BLOGGER_PHOTO_ID_5321460858722357938" /&gt;&lt;span style="color:#000000;"&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="color:#000000;"&gt;Next:&lt;br /&gt;&lt;/span&gt;&lt;span style="color:#000000;"&gt;Heeeeereeee mousey! Heeere mousey… I'll catch you this time… Just wait and see… ;o) &lt;/span&gt;&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1891129859130768227-1409179374320528437?l=create-your-game.blogspot.com' alt='' /&gt;&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/GameDevelopmentTutorials/~4/alHyg3by-x0" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://create-your-game.blogspot.com/feeds/1409179374320528437/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://create-your-game.blogspot.com/2009/04/12-nooooo-game-over.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/1891129859130768227/posts/default/1409179374320528437?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/1891129859130768227/posts/default/1409179374320528437?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/GameDevelopmentTutorials/~3/alHyg3by-x0/12-nooooo-game-over.html" title="12. NOOOOO! Game Over!?" /><author><name>Marin Malnar</name><uri>http://www.blogger.com/profile/12164590973052924670</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="26" height="32" src="http://1.bp.blogspot.com/_4WDpsfty9mg/ShhOIFmmh4I/AAAAAAAAARo/bKSb8UiTYTw/S220/drawing_biker.jpg" /></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://2.bp.blogspot.com/_4WDpsfty9mg/SdmgdOpKkrI/AAAAAAAAAFI/lms13VxIQE0/s72-c/12_1_Game_Over.png" height="72" width="72" /><thr:total>0</thr:total><feedburner:origLink>http://create-your-game.blogspot.com/2009/04/12-nooooo-game-over.html</feedburner:origLink></entry><entry gd:etag="W/&quot;CEQNSHw-cCp7ImA9WxVbF0k.&quot;"><id>tag:blogger.com,1999:blog-1891129859130768227.post-1536088509961910432</id><published>2009-04-03T08:37:00.044+02:00</published><updated>2009-04-03T09:06:39.258+02:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2009-04-03T09:06:39.258+02:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="game field" /><category scheme="http://www.blogger.com/atom/ns#" term="timer" /><title>11. Move it! Mooove it!</title><content type="html">This is the fun part. We have to move every column to the right. So, the idea is this: Player starts every new level with an empty game field. Before we give him a new column, we check if there's any space on the game field. If there's no space – it's Game Over! We try to push all of the columns one space to the right. We don't move empty columns. Oh, well, let me draw it:&lt;p align="center"&gt;&lt;img style="cursor:pointer; cursor:hand;width: 320px; height: 196px;" src="http://2.bp.blogspot.com/_4WDpsfty9mg/SdWxAoVEbOI/AAAAAAAAAEY/vxd2XZQAOAA/s320/11_1_Moving_Right.png" border="0" alt="" id="BLOGGER_PHOTO_ID_5320353159192014050" /&gt;&lt;/p&gt;&lt;p&gt;So, this picture shows 15 columns. The white ones are empty. Colored ones contain at least one block. So, in this case, before we create and insert a new column, we have to move the green columns one space to the right. The blue and yellow columns will not be affected this time. Ok, one more:&lt;/p&gt;&lt;p align="center"&gt;&lt;img style="cursor:pointer; cursor:hand;width: 320px; height: 195px;" src="http://2.bp.blogspot.com/_4WDpsfty9mg/SdWxBXIdCaI/AAAAAAAAAEg/tIr6rg1CW6U/s320/11_2_Moving_Right.png" border="0" alt="" id="BLOGGER_PHOTO_ID_5320353171755567522" /&gt;&lt;/p&gt;&lt;p&gt;The red column is the one we created after we moved the green columns to the right. In this example, before we could create a new column, we would have to moove all six columns to the right (I mean, blue ones, green ones, and the red one). And the finall product would look something like this (note, that the yellow columns were, once again, not moved):&lt;/p&gt;&lt;p align="center"&gt;&lt;img style="cursor:pointer; cursor:hand;width: 320px; height: 179px;" src="http://1.bp.blogspot.com/_4WDpsfty9mg/SdWxB_1WRZI/AAAAAAAAAEo/tHhyBBvKxbY/s320/11_3_Moving_Right.png" border="0" alt="" id="BLOGGER_PHOTO_ID_5320353182681286034" /&gt;&lt;/p&gt;&lt;p&gt;I hope you get the idea now. To do this in our game, we'll have to look for the left-most empty column, and them move all preceeding columns one space right. To check if a column is empty, we'll just check the bottom block, since we'll add some gravity to the game at a later stage – meaning, no block could 'fly'. Ok, onto the code:&lt;/p&gt;&lt;p&gt;&lt;span style="font-family:courier new;"&gt;&lt;span style="color:#009900;"&gt;// Declare an integer that will hold&lt;br /&gt;// the empty column number. We set it's&lt;br /&gt;// value to –1, wich means there is NO&lt;br /&gt;// empty columns. If we find an empty &lt;br /&gt;// column, we'll change this value. We&lt;br /&gt;// didn't use 0 to show that there's no &lt;br /&gt;// empty columns, because 0 actualy refers &lt;br /&gt;// to the FIRST column in our game field.&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;&lt;span style="color:#000099;"&gt;int&lt;/span&gt; iEmptyColumn = -1;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;&lt;span style="color:#009900;"&gt;// Using a FOR loop to go trough all &lt;br /&gt;// columns looking for an empty block.&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;&lt;br /&gt;&lt;/span&gt;for (int s = 0; s &lt; iWidth; s++)&lt;br /&gt;&lt;span style="color:#009900;"&gt;&lt;span style="font-family:courier new;"&gt;  // Checking if the block is empty:&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;                &lt;span style="color:#000099;"&gt;if&lt;/span&gt; (Field[iHeight - 1, s] == 0)&lt;br /&gt;                {&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#009900;"&gt;&lt;span style="font-family:courier new;"&gt;                      // We found the empty block. Write&lt;br /&gt;                      // the column number into our&lt;br /&gt;                      // integer variable.&lt;br /&gt;                      &lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;&lt;span style="color:#000000;"&gt;&lt;span&gt;&lt;span&gt;iEmptyColumn = s;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="color:#009900;"&gt;&lt;span style="font-family:courier new;"&gt;&lt;br /&gt;                      // Exit the loop, we don't need to&lt;br /&gt;                      // look any longer, since we already&lt;br /&gt;                      // found an empty column:&lt;br /&gt;&lt;/span&gt;&lt;/span&gt; &lt;span style="font-family:courier new;"&gt;                      &lt;span style="color:#000099;"&gt;break&lt;/span&gt;;&lt;br /&gt;  }&lt;br /&gt;}&lt;/span&gt;  &lt;/p&gt;&lt;p&gt;&lt;span style="font-family:courier new;"&gt;&lt;span style="color:#000099;"&gt;if&lt;/span&gt; (iEmptyColumn == -1)&lt;br /&gt;{&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#009900;"&gt;&lt;span style="font-family:courier new;"&gt;                // So, if there's no empty columns,&lt;br /&gt;                // we can't create any new ones, so&lt;br /&gt;                // we'll call the game over method.&lt;br /&gt;&lt;/span&gt;&lt;/span&gt; &lt;span style="font-family:courier new;"&gt;                GameOver();&lt;br /&gt;}&lt;br /&gt;&lt;span style="color:#000099;"&gt;else&lt;/span&gt;&lt;br /&gt;{&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;&lt;span style="color:#009900;"&gt;                // If we found an empty column, move all&lt;br /&gt;                // preeceding columns for one space to the&lt;br /&gt;                // right. We use two loops in this code&lt;br /&gt;                // because we have to move all blocks in&lt;br /&gt;                // the column (height wise), and all the&lt;br /&gt;                // collumns preeceding the empty one).&lt;br /&gt;&lt;/span&gt;&lt;/span&gt; &lt;span style="font-family:courier new;"&gt;                &lt;span style="color:#000099;"&gt;for&lt;/span&gt; (&lt;span style="color:#000099;"&gt;int&lt;/span&gt; x = iEmptyColumn; x &gt; 0; x--)&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;&lt;br /&gt;&lt;/span&gt; &lt;span style="font-family:courier new;"&gt; {&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;    &lt;span style="color:#000099;"&gt;for&lt;/span&gt; (&lt;span style="color:#000099;"&gt;int&lt;/span&gt; v = 0; v &lt;&gt;&lt;span style="font-family:courier new;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;                       {&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;       Field[v, x] = Field[v, x - 1];&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;                                 Field[v, x - 1] = 0;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;                       }&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;                 }&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;  &lt;/span&gt;&lt;span style="color:#009900;"&gt;&lt;span style="font-family:courier new;"&gt;                // So, we moved our field, we can now&lt;br /&gt;                // create a new column...&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;                 CreateNewColumn();&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;                 &lt;span style="color:#009900;"&gt;// ...and add a random block&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;&lt;span style="color:#009900;"&gt;  // (you'll see...) :)&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;                 DropBlock();&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;                 &lt;span style="color:#000099;"&gt;return&lt;/span&gt;;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt; }&lt;br /&gt;&lt;/p&gt;&lt;/span&gt;&lt;p&gt;&lt;span style="font-family:georgia;"&gt;What a progress! One of the last things is to put this stuff into our Timer's Tick event. Find the code for the game_tick event, and put this line there:&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="font-family:courier new;"&gt;MoveRight();&lt;/span&gt;&lt;/p&gt;&lt;/span&gt;&lt;p&gt;&lt;span &gt;Oh, yea, remove the line that we placed there earlier. (The one that called CreateNewColumn() method.) We don't need it, because now, we call the CreateNewColumn() method from our new MoveRight() method. In the next chapter we'll create the GameOver() method. And after that, we'll move to do some user (player) interaction stuff. I guess we'll be chasing the mouse all over the field… ;-P  LOL, that's funny.&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span &gt;&lt;/p&gt;Try it out! You should see something like this:&lt;/span&gt;&lt;p&gt;&lt;/p&gt;&lt;span face="courier new"&gt;&lt;p align="center"&gt;&lt;img style="cursor:pointer; cursor:hand;width: 320px; height: 238px;" src="http://3.bp.blogspot.com/_4WDpsfty9mg/SdWxB9fo6SI/AAAAAAAAAEw/tm9EPkESMp8/s320/11_4_Full_Field.png" border="0" alt="" id="BLOGGER_PHOTO_ID_5320353182053361954" /&gt;&lt;/p&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1891129859130768227-1536088509961910432?l=create-your-game.blogspot.com' alt='' /&gt;&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/GameDevelopmentTutorials/~4/0RE7TyU2UPs" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://create-your-game.blogspot.com/feeds/1536088509961910432/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://create-your-game.blogspot.com/2009/04/11-move-it-mooove-it.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/1891129859130768227/posts/default/1536088509961910432?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/1891129859130768227/posts/default/1536088509961910432?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/GameDevelopmentTutorials/~3/0RE7TyU2UPs/11-move-it-mooove-it.html" title="11. Move it! Mooove it!" /><author><name>Marin Malnar</name><uri>http://www.blogger.com/profile/12164590973052924670</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="26" height="32" src="http://1.bp.blogspot.com/_4WDpsfty9mg/ShhOIFmmh4I/AAAAAAAAARo/bKSb8UiTYTw/S220/drawing_biker.jpg" /></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://2.bp.blogspot.com/_4WDpsfty9mg/SdWxAoVEbOI/AAAAAAAAAEY/vxd2XZQAOAA/s72-c/11_1_Moving_Right.png" height="72" width="72" /><thr:total>0</thr:total><feedburner:origLink>http://create-your-game.blogspot.com/2009/04/11-move-it-mooove-it.html</feedburner:origLink></entry><entry gd:etag="W/&quot;DEEAQn47cSp7ImA9WxVbFkg.&quot;"><id>tag:blogger.com,1999:blog-1891129859130768227.post-6825856459115203730</id><published>2009-04-02T08:58:00.024+02:00</published><updated>2009-04-02T09:17:23.009+02:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2009-04-02T09:17:23.009+02:00</app:edited><title>10. Timing is crutial</title><content type="html">We've made it to a break-point in our game's development. In this chapter we'll automate our game, so it will create new columns every second. And after that, we'll make our existing colums move to the right. We'll also check, if the conditions for Game Over, or New Level are met. The first step in this part is to add a timer to the form. You can find it in your ToolBox, under the 'Components' section. And when you double-click it, it won't be placed to the form. It will be placed in a new toolbar under your Form Designer window. Here's a screenshot:&lt;p align="center"&gt;&lt;img style="cursor:pointer; cursor:hand;width: 320px; height: 198px;" src="http://1.bp.blogspot.com/_4WDpsfty9mg/SdRl7F-GjDI/AAAAAAAAAEI/aWH_rjrG4Sw/s320/10_2_Timer.png" border="0" alt="" id="BLOGGER_PHOTO_ID_5319989125720738866" /&gt;&lt;/p&gt;&lt;p&gt;So, click the timer in the components toolbar, and set it's properties like shown in the next table:&lt;/p&gt;&lt;p&gt;&lt;strong&gt;&lt;span style="color:#009900;"&gt;Timer&lt;/span&gt;&lt;/strong&gt;&lt;/p&gt;&lt;ul&gt;&lt;li&gt;&lt;span style="color:#ff6600;"&gt;(name): &lt;/span&gt;&lt;strong&gt;&lt;span style="color:#000000;"&gt;Game&lt;/span&gt;&lt;/strong&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="color:#ff6600;"&gt;Interval: &lt;/span&gt;&lt;strong&gt;&lt;span style="color:#000000;"&gt;1000&lt;/span&gt;&lt;/strong&gt;&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;&lt;span style="color:#000000;"&gt;Obviously, the timer has a 'Interval' property. That tells the timer the 'lenght' of the pauses between repeating all of the commands writen in it's Tick method. The interval is defined in miliseconds. That means, if you want your timer to repeat it's code every second, you'll have to enter '1000' in it's interval property. And if you want it to repeat it's code every two and a half seconds – enter 2500. And so on, and so on, and … ;o)&lt;br /&gt;&lt;br /&gt;So, now, we have the timer set – let's try it out. Double click on it in your components toolbar, and you'll see the code for it's Tick method. Add next lines of code in it's method:&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="font-family:courier new;"&gt;&lt;span style="color:#009900;"&gt;// Call to our function responsible&lt;br /&gt;// for creating new columns:&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;&lt;span style="color:#000000;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color:#000000;"&gt;CreateNewColumn();&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="color:#009900;"&gt;&lt;span style="font-family:courier new;"&gt;// Call our two 'draw' functions...&lt;br /&gt;// So we can see when the new&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;// columns are created.&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;&lt;span style="color:#000000;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color:#000000;"&gt;DrawField();&lt;br /&gt;DrawGrid();&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="color:#000000;"&gt;Ok, that'll do the trick. But, we have to tell our timer when to start 'ticking', and we'll do this with our 'New Game' button. So, go to the code for your button, and add this line of code after the existing lines:&lt;/span&gt;&lt;span style="color:#000000;"&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;&lt;span style="color:#009900;"&gt;// Telling our game timer to&lt;br /&gt;// start ticking:&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;&lt;span style="color:#000000;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color:#000000;"&gt;Game.Start();&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="color:#000000;"&gt;Oh, and before moving on, remove, or comment out (check your C# toolbar for a button that does that) the code wich we used to test our field:&lt;/span&gt;&lt;strong&gt;&lt;span style="color:#000000;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/strong&gt;&lt;span style="font-family:courier new;"&gt;&lt;span style="color:#000000;"&gt; &lt;br /&gt;Field[0,0] = 1;&lt;br /&gt;Field[4,8] = 2;&lt;br /&gt;Field[2,12] = 3;&lt;br /&gt;Field[9,14] = 4;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="color:#000000;"&gt;Don't worry, we don't need that code any more. Our blocks will be filled automaticaly, frow now on. Cool, heh? But wait untill you see this stuff in action! :o) Run your game, click on the button and enjoy the fireworks! H&lt;/span&gt;&lt;span style="color:#000000;"&gt;ere's what you should see after 15 seconds (and after 15 column changes):&lt;/span&gt;&lt;/p&gt;&lt;p align="center"&gt;&lt;img style="cursor:pointer; cursor:hand;width: 320px; height: 238px;" src="http://3.bp.blogspot.com/_4WDpsfty9mg/SdRl7Zvrn-I/AAAAAAAAAEQ/NnvNqKbV_3w/s320/10_1_New_Column_Created.png" border="0" alt="" id="BLOGGER_PHOTO_ID_5319989131028963298" /&gt;&lt;span style="color:#000000;"&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="color:#000000;"&gt;Moooooving on! As promised, we'll move all existing colums to the right. But that's the story from our next chapter.&lt;/span&gt;&lt;span style="color:#000000;"&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1891129859130768227-6825856459115203730?l=create-your-game.blogspot.com' alt='' /&gt;&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/GameDevelopmentTutorials/~4/xlToruDE42c" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://create-your-game.blogspot.com/feeds/6825856459115203730/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://create-your-game.blogspot.com/2009/04/10-timing-is-crutial.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/1891129859130768227/posts/default/6825856459115203730?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/1891129859130768227/posts/default/6825856459115203730?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/GameDevelopmentTutorials/~3/xlToruDE42c/10-timing-is-crutial.html" title="10. Timing is crutial" /><author><name>Marin Malnar</name><uri>http://www.blogger.com/profile/12164590973052924670</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="26" height="32" src="http://1.bp.blogspot.com/_4WDpsfty9mg/ShhOIFmmh4I/AAAAAAAAARo/bKSb8UiTYTw/S220/drawing_biker.jpg" /></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://1.bp.blogspot.com/_4WDpsfty9mg/SdRl7F-GjDI/AAAAAAAAAEI/aWH_rjrG4Sw/s72-c/10_2_Timer.png" height="72" width="72" /><thr:total>0</thr:total><feedburner:origLink>http://create-your-game.blogspot.com/2009/04/10-timing-is-crutial.html</feedburner:origLink></entry><entry gd:etag="W/&quot;AkUDRXc5cSp7ImA9WxVbFUs.&quot;"><id>tag:blogger.com,1999:blog-1891129859130768227.post-6521983693799275737</id><published>2009-04-01T08:09:00.033+02:00</published><updated>2009-04-01T08:44:34.929+02:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2009-04-01T08:44:34.929+02:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="function" /><category scheme="http://www.blogger.com/atom/ns#" term="C#" /><category scheme="http://www.blogger.com/atom/ns#" term="Random" /><title>9. Our first gameplay stuff</title><content type="html">&lt;p&gt;One of the rules of our gameplay is the one saying that the game sends in new columns of blocks from the left. And it does so until the player runs out of empty columns… We'll divide this into three basic steps. And later on, we'll add a timer to our game. A timer will make sure that a new column will be created every time at a specified interval. These are the steps for our basic gameplay:&lt;/p&gt;&lt;ol&gt;&lt;li&gt;Create new column with random colors&lt;/li&gt;&lt;li&gt;Move existing columns to the right to make some room for the new column&lt;/li&gt;&lt;li&gt;If we can't move any columns – Game Over!&lt;/li&gt;&lt;li&gt;If the player cleared a certain ammount of columns – move him to a new level&lt;/li&gt;&lt;/ol&gt;&lt;p&gt;And to make this work we'll declare some more variables – like the number of different colors allowed in the new column. By increasing this number, the game becomes more difficult to play. And one other way to make the game more difficult to play is by shortening the time interval between new column creation. The third way to make our game harder is to increase the number of columns needed to be cleared in a level. Later on, we'll incorporate all this stuff in our game. So, our game will become more and more difficult – from level to level.&lt;/p&gt;&lt;p&gt;Back to the code – here's what we need to add to our declarations:&lt;/p&gt;&lt;p&gt;&lt;span style="font-family:courier new;"&gt;&lt;span style="color:#009900;"&gt;// Declare the number of different colors&lt;br /&gt;// that are used in the current level.&lt;br /&gt;// We'll set it to 4 - for now:&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;&lt;br /&gt;&lt;/span&gt;int iColor = 4;&lt;span style="font-family:courier new;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;&lt;span style="color:#009900;"&gt;// Declare the counter that we'll use&lt;br /&gt;// for changing colors every X levels.&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;&lt;br /&gt;&lt;/span&gt;int iColors;&lt;span style="font-family:courier new;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="font-family:courier new;"&gt;&lt;span style="color:#009900;"&gt;// Declare the  integer that will hold&lt;br /&gt;// the number of columns created  in&lt;br /&gt;// the current level:&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;&lt;br /&gt;&lt;/span&gt;int iColumn;&lt;span style="font-family:courier new;"&gt;&lt;span style="color:#009900;"&gt;// Declare the integer that will hold&lt;br /&gt;// the total number of columns in&lt;br /&gt;// the current level.&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;&lt;br /&gt;&lt;/span&gt;int iColumns;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;Add these lines of code right under the Game Field Height, Width, and Field Size declarations. Before moving on, we have to add a label to our form. So, add a label to the form, and then set it's properties like shown in the next list:&lt;/p&gt;&lt;p&gt;&lt;p&gt;&lt;strong&gt;&lt;span style="color:#009900;"&gt;Label&lt;/span&gt;&lt;/strong&gt;&lt;/p&gt;&lt;ul&gt;&lt;li&gt;&lt;span style="color:#ff6600;"&gt;(name):&lt;/span&gt;&lt;strong&gt;&lt;span style="color:#000000;"&gt; lblColumn&lt;/span&gt;&lt;/strong&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="color:#ff6600;"&gt;BackgroundColor:&lt;/span&gt; &lt;strong&gt;&lt;span style="color:#000000;"&gt;Web &gt; Transparent&lt;/span&gt;&lt;/strong&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="color:#ff6600;"&gt;Location:&lt;/span&gt; &lt;strong&gt;&lt;span style="color:#000000;"&gt;555; 97&lt;/span&gt;&lt;/strong&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="color:#ff6600;"&gt;Font: &lt;/span&gt;&lt;strong&gt;&lt;span style="color:#000000;"&gt;Microsoft Sans Serif; 9,75pt; style=Bold&lt;/span&gt;&lt;/strong&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="color:#ff6600;"&gt;Text:&lt;/span&gt;&lt;strong&gt;&lt;span style="color:#000000;"&gt; 0/0&lt;/span&gt;&lt;/strong&gt;&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;&lt;span style="color:#000000;"&gt;Finally, the code that will create our new column. Put it in your CreateNewColumn() function.&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="font-family:courier new;"&gt;&lt;span style="color:#000099;"&gt;if&lt;/span&gt;&lt;span style="color:#000000;"&gt; (iColumn &lt;/span&gt;&lt;span style="color:#000000;"&gt;&lt; iColumns)&lt;br /&gt;{&lt;br /&gt;                &lt;/span&gt;&lt;span style="color:#009900;"&gt;// Initializing the random function.&lt;br /&gt;&lt;/span&gt;&lt;span style="color:#000000;"&gt;  &lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;&lt;span style="color:#009900;"&gt;// It will come up with random  &lt;br /&gt;  // numbers every time we call it.&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;&lt;span style="color:#000000;"&gt;&lt;br /&gt;                &lt;/span&gt;&lt;span style="color:#339999;"&gt;Random&lt;/span&gt;&lt;span style="color:#000000;"&gt; Rnd = &lt;/span&gt;&lt;span style="color:#000099;"&gt;new&lt;/span&gt;&lt;span style="color:#000000;"&gt; &lt;/span&gt;&lt;span style="color:#339999;"&gt;Random&lt;/span&gt;&lt;span style="color:#000000;"&gt;();&lt;br /&gt;&lt;br /&gt;  &lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;&lt;span style="color:#009900;"&gt;// We have to create 10 new fields.&lt;br /&gt;  // (Our column is 10 fields high.)&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;&lt;span style="color:#000099;"&gt;&lt;br /&gt;  for&lt;/span&gt;&lt;span style="color:#000000;"&gt; (&lt;/span&gt;&lt;span style="color:#000099;"&gt;int&lt;/span&gt;&lt;span style="color:#000000;"&gt; p = 0; p &lt; iHeight; p++)&lt;br /&gt;                {&lt;br /&gt;                      &lt;/span&gt;&lt;span style="color:#009900;"&gt;// We set the random function in&lt;br /&gt;    // a way, so it couldn't return&lt;br /&gt;    // a value larger than we declared&lt;br /&gt;    // it in the beginning, and it&lt;br /&gt;    // couldn't return 0 (wich means –&lt;br /&gt;    // empty field).&lt;br /&gt;&lt;/span&gt;&lt;span style="color:#000000;"&gt;                      Field[p, 0] = Rnd.Next(1, iColor + 1);&lt;br /&gt;                }&lt;br /&gt;&lt;br /&gt;                &lt;/span&gt;&lt;span style="color:#009900;"&gt;// Increase the number of columns created&lt;/span&gt;&lt;span style="color:#000000;"&gt;&lt;br /&gt;                iColumn++;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;&lt;span style="color:#009900;"&gt;  // Display the column count in the new&lt;br /&gt;  // label on our form.&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;&lt;span style="color:#000000;"&gt;&lt;br /&gt;                lblColumn.Text = iColumn.ToString() +&lt;br /&gt;  "/" + iColumns.ToString();&lt;br /&gt;}&lt;br /&gt;&lt;/span&gt;&lt;span style="color:#000099;"&gt;else&lt;/span&gt;&lt;span style="color:#000000;"&gt;&lt;br /&gt;{&lt;br /&gt;&lt;/span&gt;&lt;span style="color:#009900;"&gt;  // The level is over when the number&lt;br /&gt;  // of columns created in the current&lt;/span&gt;&lt;/span&gt;&lt;span style="color:#009900;"&gt;&lt;span style="font-family:courier new;"&gt;&lt;br /&gt;  // level is equal to the total number&lt;br /&gt;  // of columns predicted for that level.&lt;br /&gt;  // When the level is over, we call our&lt;br /&gt;  // methods for counting bonus points&lt;br /&gt;  // and switching to a new level.&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;&lt;span style="color:#000000;"&gt;&lt;br /&gt;                LevelScore();&lt;br /&gt;                NewLevel();&lt;br /&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="color:#000000;"&gt;&lt;/span&gt;&lt;span style="color:#000000;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color:#000000;"&gt;That's it for this chapter. In the next one, we'll add a timer to our game, and add some code to make it create new colums every second. We'll also start talking about moving all existing colums to the right.&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1891129859130768227-6521983693799275737?l=create-your-game.blogspot.com' alt='' /&gt;&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/GameDevelopmentTutorials/~4/64ahu6E9RKU" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://create-your-game.blogspot.com/feeds/6521983693799275737/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://create-your-game.blogspot.com/2009/04/9-our-first-gameplay-stuff.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/1891129859130768227/posts/default/6521983693799275737?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/1891129859130768227/posts/default/6521983693799275737?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/GameDevelopmentTutorials/~3/64ahu6E9RKU/9-our-first-gameplay-stuff.html" title="9. Our first gameplay stuff" /><author><name>Marin Malnar</name><uri>http://www.blogger.com/profile/12164590973052924670</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="26" height="32" src="http://1.bp.blogspot.com/_4WDpsfty9mg/ShhOIFmmh4I/AAAAAAAAARo/bKSb8UiTYTw/S220/drawing_biker.jpg" /></author><thr:total>0</thr:total><feedburner:origLink>http://create-your-game.blogspot.com/2009/04/9-our-first-gameplay-stuff.html</feedburner:origLink></entry><entry gd:etag="W/&quot;CEQCSXk6cSp7ImA9WxVaF0U.&quot;"><id>tag:blogger.com,1999:blog-1891129859130768227.post-3624207844172837059</id><published>2009-03-31T10:37:00.038+02:00</published><updated>2009-04-15T09:59:28.719+02:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2009-04-15T09:59:28.719+02:00</app:edited><title>8. Grids, and experiments</title><content type="html">Ok, you finally got to see some results, but how can you be sure that that our field is indeed made of small blocks, and that all this code didn't just produce a big blue rectangle? Easy. In this chapter, we'll add some code that'll display a grid on our field, and then we'll try to change the color values in our blocks. Just to be sure everything works. We'll add another control to our form. A check box that we'll use to show or hide the grid. To add it to the form, double click on the 'Check Box' control in your Tool Box, and then set it's Properties like shown in the next table: &lt;p&gt;&lt;strong&gt;&lt;span style="color:#009900;"&gt;CheckBox&lt;/span&gt;&lt;/strong&gt;&lt;/p&gt;&lt;ul&gt;&lt;li&gt;&lt;span style="color:#ff6600;"&gt;(name): cbGrid&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="color:#ff6600;"&gt;BackColor:&lt;/span&gt; &lt;strong&gt;&lt;span style="color:#000000;"&gt;Web &gt; Transparent&lt;/span&gt;&lt;/strong&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="color:#ff6600;"&gt;Location:&lt;/span&gt; &lt;strong&gt;&lt;span style="color:#000000;"&gt;490;116&lt;/span&gt;&lt;/strong&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="color:#ff6600;"&gt;Text:&lt;/span&gt;&lt;strong&gt;&lt;span style="color:#000000;"&gt; Show Grid&lt;/span&gt;&lt;/strong&gt;&lt;/li&gt;&lt;/ul&gt;&lt;br /&gt;Since we've already added a 'using' statement for Drawing2D library, we'll be able to define our custom pens in our code for displaying the grid. Again, go trough the code, type it on your own, and read the comments. (I hope you're not retyping all of my comments ;) – write your own – in a way that you'll understand.)&lt;p&gt;This is the code that you have to put inside the &lt;span style="font-family:courier new;"&gt;DrawGrid()&lt;/span&gt; function:&lt;/p&gt;&lt;p&gt;&lt;span style="font-family:courier new;"&gt;&lt;span style="color:#009900;"&gt;// Checking if the check box&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;&lt;span style="color:#009900;"&gt;// is checked or not. If the&lt;br /&gt;// checkbox is checked – then&lt;br /&gt;// we'll display the grid.&lt;br /&gt;// The grid is made up from 9&lt;br /&gt;// horizontal and 14 vertical lines.&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#000099;"&gt;if&lt;/span&gt; (cbGrid.Checked == &lt;span style="color:#000099;"&gt;true&lt;/span&gt;)&lt;br /&gt;{&lt;br /&gt;&lt;span style="color:#339999;"&gt;  Graphics&lt;/span&gt; gGrid = picGameField.CreateGraphics();&lt;br /&gt;&lt;span style="color:#009900;"&gt;  // We'll create our custom PENS:&lt;br /&gt;  // Pens hold the information about&lt;br /&gt;  // color, line style and other&lt;br /&gt;  // graphical properties that are&lt;br /&gt;  // usefull for drawing shapes.&lt;br /&gt;  // Pen that we'll use for horizontal lines:&lt;br /&gt;  // Here we define our pen as 'Sky Blue',&lt;br /&gt;  // and that the line drawn will be&lt;br /&gt;  // 1 pixel in width:&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;&lt;span style="color:#339999;"&gt;  Pen&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt; pLineH = &lt;span style="color:#000099;"&gt;new&lt;/span&gt; &lt;span style="color:#339999;"&gt;Pen&lt;/span&gt;(&lt;span style="color:#339999;"&gt;Color&lt;/span&gt;.SkyBlue,1);&lt;br /&gt;&lt;span style="color:#009900;"&gt;  // Here we define that the line will be&lt;br /&gt;  // drawn with a series of little dashes:&lt;/span&gt;&lt;br /&gt;  pLineH.DashStyle = &lt;span style="color:#339999;"&gt;DashStyle&lt;/span&gt;.Dash;&lt;br /&gt;&lt;span style="color:#009900;"&gt;  // Next, the code for our Pen that we'll&lt;br /&gt;  // use for our vertical lines.&lt;br /&gt;  // Note, that we could use the same pen&lt;br /&gt;  // for both horizontal, and vertical&lt;br /&gt;  // lines, but that would mean that, they&lt;br /&gt;  // would have the same color and style.&lt;br /&gt;  // To spice things up, I've decided to&lt;br /&gt;  // make them a little different.&lt;br /&gt;  // So once again:&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#339999;"&gt;  Pen&lt;/span&gt; pLineV = &lt;span style="color:#000099;"&gt;new&lt;/span&gt; &lt;span style="color:#339999;"&gt;Pen&lt;/span&gt;(&lt;span style="color:#339999;"&gt;Color&lt;/span&gt;.DeepSkyBlue, 1);&lt;br /&gt;&lt;span style="color:#009900;"&gt;  // This pen will draw line with a&lt;br /&gt;  // series of small dots:&lt;/span&gt;&lt;br /&gt;  pLineV.DashStyle = &lt;span style="color:#339999;"&gt;DashStyle&lt;/span&gt;.Dot;&lt;br /&gt;&lt;span style="color:#009900;"&gt;  // Finally, let's draw our vertical lines:&lt;br /&gt;  // Again, we'll draw them in a loop,&lt;br /&gt;  // so we don't have to write 13 almost the&lt;br /&gt;  // same lines of code.&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#000099;"&gt;  for&lt;/span&gt; (&lt;span style="color:#000099;"&gt;int&lt;/span&gt; a = iFieldSize; a &lt; (iFieldSize * iWidth); a = a + iFieldSize)   {     gGrid.DrawLine(pLineV, a, 0, a, iHeight * iFieldSize);   } &lt;span style="color:#009900;"&gt; &lt;br /&gt;  // And horizontal lines:&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#000099;"&gt;  for&lt;/span&gt; (&lt;span style="color:#000099;"&gt;int&lt;/span&gt; b = &lt;/span&gt;&lt;span style="font-family:courier new;"&gt;iFieldSize&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;; b &lt; (iFieldSize * iHeight); b = b + iFieldSize)   {     gGrid.DrawLine(pLineH, 0, b, iWidth* iFieldSize, b);   }&lt;/span&gt;&lt;/p&gt;&lt;p&gt;Now, scroll to the &lt;span style="font-family:courier new;"&gt;butGame_Click&lt;/span&gt; method, and this code there:&lt;br /&gt;(Add it before the call to the &lt;span style="font-family:courier new;"&gt;DrawField()&lt;/span&gt; method.)&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="color:#009900;"&gt;&lt;span style="font-family:courier new;"&gt;// Defining a block: &lt;br /&gt;// Field[vertical, horizontal] = color&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;&lt;br /&gt;Field[0,0] = 1;&lt;br /&gt;Field[4,8] = 2;&lt;br /&gt;Field[2,12] = 3;&lt;br /&gt;&lt;/span&gt;&lt;span style="color:#009900;"&gt;&lt;span style="font-family:courier new;"&gt;// You can add some of your own here…&lt;br /&gt;// Just be sure that the field&lt;br /&gt;// coordinates are not out of range.&lt;br /&gt;// This is the block with the maximum&lt;br /&gt;// range (bottom right field):&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;&lt;br /&gt;Field[9,14] = 4;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span&gt;And, add this code after the &lt;/span&gt;&lt;span style="font-family:courier new;"&gt;DrawField()&lt;/span&gt;&lt;span&gt; call:&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="font-family:courier new;"&gt;&lt;span style="color:#009900;"&gt;//Draw the grid:&lt;/span&gt;&lt;br /&gt;DrawGrid();&lt;/span&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;span&gt;After running the program, selecting the 'Show Grid' check box and clicking on the 'New Game' button, you should see something like this:&lt;/span&gt;&lt;/p&gt;&lt;p align="center"&gt;&lt;img style="cursor:pointer; cursor:hand;width: 320px; height: 239px;" src="http://4.bp.blogspot.com/_4WDpsfty9mg/SdHaZ0DhH7I/AAAAAAAAACY/MDj1MdBjxgQ/s320/8_1_Grid_And_Test_Blocks.png" border="0" alt="" id="BLOGGER_PHOTO_ID_5319272771906248626" /&gt;&lt;/p&gt;&lt;p align="left"&gt;&lt;span&gt;So, this is it for this chapter. In the next chapter we'll try to create a column full of new blocks, with randomly selected colors, and then show it in the first column on our game field.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1891129859130768227-3624207844172837059?l=create-your-game.blogspot.com' alt='' /&gt;&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/GameDevelopmentTutorials/~4/3a0G-_dDGHc" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://create-your-game.blogspot.com/feeds/3624207844172837059/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://create-your-game.blogspot.com/2009/03/8-grids-and-experiments.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/1891129859130768227/posts/default/3624207844172837059?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/1891129859130768227/posts/default/3624207844172837059?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/GameDevelopmentTutorials/~3/3a0G-_dDGHc/8-grids-and-experiments.html" title="8. Grids, and experiments" /><author><name>Marin Malnar</name><uri>http://www.blogger.com/profile/12164590973052924670</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="26" height="32" src="http://1.bp.blogspot.com/_4WDpsfty9mg/ShhOIFmmh4I/AAAAAAAAARo/bKSb8UiTYTw/S220/drawing_biker.jpg" /></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://4.bp.blogspot.com/_4WDpsfty9mg/SdHaZ0DhH7I/AAAAAAAAACY/MDj1MdBjxgQ/s72-c/8_1_Grid_And_Test_Blocks.png" height="72" width="72" /><thr:total>0</thr:total><feedburner:origLink>http://create-your-game.blogspot.com/2009/03/8-grids-and-experiments.html</feedburner:origLink></entry><entry gd:etag="W/&quot;CEYGQ3gzcCp7ImA9WxVbFEw.&quot;"><id>tag:blogger.com,1999:blog-1891129859130768227.post-7885161784290132682</id><published>2009-03-30T12:38:00.045+02:00</published><updated>2009-03-30T13:22:02.688+02:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2009-03-30T13:22:02.688+02:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="GDI+" /><category scheme="http://www.blogger.com/atom/ns#" term="development" /><category scheme="http://www.blogger.com/atom/ns#" term="source code" /><category scheme="http://www.blogger.com/atom/ns#" term="programming" /><category scheme="http://www.blogger.com/atom/ns#" term="C#" /><category scheme="http://www.blogger.com/atom/ns#" term="game" /><category scheme="http://www.blogger.com/atom/ns#" term="2D" /><category scheme="http://www.blogger.com/atom/ns#" term="field" /><title>7. Showing our field</title><content type="html">When we wrote the code for our CreateField() method, we didn't write any code for displaying the field to the user. We'll do it in this chapter. We'll take a look at graphic programming, GDI+…  So, let's fill our DrawField() method. Here's the code – go trough it, read the comments (the green stuff), and hopefully, you'll get it. :) I did write a lot of comments. I hope they help.&lt;p align="left"&gt;&lt;span style="color:#009900;"&gt;&lt;span style="font-family:courier new;"&gt;// Define a Brush – an object that will&lt;br /&gt;// hold the color value for our Game &lt;br /&gt;// Field background.&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;&lt;br /&gt;&lt;span style="color:#339999;"&gt;Brush&lt;/span&gt; Background = &lt;span style="color:#339999;"&gt;Brushes&lt;/span&gt;.PowderBlue;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color:#009900;"&gt;&lt;span style="font-family:courier new;"&gt;// We want to show our field inside the &lt;br /&gt;// Picture Box, so we create a graphich &lt;br /&gt;// object inside our Picture Box.&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;&lt;br /&gt;&lt;span style="color:#339999;"&gt;Graphics&lt;/span&gt; gField = picGameField.CreateGraphics();&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color:#009900;"&gt;&lt;span style="font-family:courier new;"&gt;// We'll go trough all of our fields, and we'll &lt;br /&gt;// display them one by one (taking into consideration&lt;br /&gt;// the color value each field contains). We have 150 &lt;br /&gt;// fields, so, we'll do this with the help of two loops.&lt;br /&gt;// It woud be painfull to do it manually.&lt;br /&gt;&lt;br /&gt;// First loop that is going trough every line.&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;&lt;br /&gt;&lt;span style="color:#000099;"&gt;for&lt;/span&gt; (&lt;span style="color:#000099;"&gt;int&lt;/span&gt; v = 0; v &lt;&gt;&lt;span style="font-family:courier new;"&gt;&lt;br /&gt;{&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;&lt;span style="color:#009900;"&gt;  // Second loop – this one is going&lt;br /&gt;  // trough every column.&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#000099;"&gt;  for&lt;/span&gt; (&lt;span style="color:#000099;"&gt;int&lt;/span&gt; s = 0; s &lt; iWidth; s++)&lt;br /&gt;  { &lt;/span&gt;&lt;span style="color:#009900;"&gt;&lt;span style="font-family:courier new;"&gt;        // We define a small rectangle, for&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="color:#009900;"&gt;&lt;span style="font-family:courier new;"&gt;    // every field in our game field. We'll&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="color:#009900;"&gt;&lt;span style="font-family:courier new;"&gt;    // use the variable that contains the&lt;br /&gt;    // rectangle's width/height. If you&lt;br /&gt;    // remember, we defined it in our first&lt;br /&gt;    // lines of code.&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;&lt;br /&gt;&lt;span style="color:#339999;"&gt;    Rectangle&lt;/span&gt; rtgField = &lt;span style="color:#000099;"&gt;new&lt;/span&gt; &lt;span style="color:#339999;"&gt;Rectangle&lt;br /&gt;&lt;/span&gt;    (s * iFieldSize, v * iFieldSize,&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;&lt;br /&gt;     FieldSize, iFieldSize);&lt;br /&gt;  &lt;br /&gt;&lt;/span&gt;&lt;span style="color:#009900;"&gt;&lt;span style="font-family:courier new;"&gt;    // First of all, we'll fill our rectangles &lt;br /&gt;    // with our background color.&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;&lt;br /&gt;    gField.FillRectangle(Background, rtgField);&lt;br /&gt;   &lt;br /&gt;&lt;/span&gt;&lt;span style="color:#009900;"&gt;&lt;span style="font-family:courier new;"&gt;    // And now, we'll fill the field with the color &lt;br /&gt;    // that is defined with the fields value.&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;&lt;br /&gt;&lt;span style="color:#000099;"&gt;    switch&lt;/span&gt; (Field[v, s])&lt;br /&gt;    {&lt;br /&gt;&lt;span style="color:#000099;"&gt;      case&lt;/span&gt; 0:&lt;br /&gt;&lt;span style="color:#009900;"&gt;        // Draw empty field...&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#000099;"&gt;        break&lt;/span&gt;;&lt;br /&gt;&lt;span style="color:#000099;"&gt;      case&lt;/span&gt; 1:&lt;br /&gt;&lt;/span&gt;&lt;span style="color:#009900;"&gt;&lt;span style="font-family:courier new;"&gt;        // I've decided that color #1 is Blue. So, if &lt;br /&gt;        // the field holds a value of 1 – We'll color it &lt;br /&gt;        // blue. And we'll do the same for all&lt;br /&gt;        // other colors.&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;&lt;br /&gt;        gField.FillRectangle(Brushes.Blue, rtgField);&lt;br /&gt;&lt;span style="color:#000099;"&gt;        break&lt;/span&gt;;&lt;br /&gt;&lt;span style="color:#000099;"&gt;      case&lt;/span&gt; 2:&lt;br /&gt;&lt;span style="color:#009900;"&gt;        // If the field contains value 2:&lt;br /&gt;        // we'll fill it red.&lt;/span&gt;&lt;br /&gt;        gField.FillRectangle(Brushes.Red, rtgField);&lt;br /&gt;&lt;span style="color:#000099;"&gt;        break&lt;/span&gt;;&lt;br /&gt;&lt;span style="color:#000099;"&gt;      case&lt;/span&gt; 3:&lt;br /&gt;&lt;span style="color:#009900;"&gt;        // If the field contains value 3:&lt;br /&gt;        // we'll fill it green.&lt;/span&gt;&lt;br /&gt;        gField.FillRectangle(Brushes.Green, rtgField);&lt;br /&gt;&lt;span style="color:#000099;"&gt;        break&lt;/span&gt;;&lt;br /&gt;&lt;span style="color:#000099;"&gt;      case&lt;/span&gt; 4:&lt;br /&gt;&lt;span style="color:#009900;"&gt;        // If the field contains value 4:&lt;br /&gt;        // we'll fill it yellow.&lt;/span&gt;&lt;br /&gt;        gField.FillRectangle(Brushes.Yellow, rtgField);&lt;br /&gt;&lt;span style="color:#000099;"&gt;        break&lt;/span&gt;;&lt;br /&gt;&lt;span style="color:#000099;"&gt;      case&lt;/span&gt; 5:&lt;br /&gt;&lt;span style="color:#009900;"&gt;        // If the field contains value 5:&lt;br /&gt;        // we'll fill it purple.&lt;/span&gt;&lt;br /&gt;        gField.FillRectangle(Brushes.Purple, rtgField);&lt;br /&gt;&lt;span style="color:#000099;"&gt;        break&lt;/span&gt;;&lt;br /&gt;&lt;span style="color:#000099;"&gt;      case&lt;/span&gt; 6:&lt;br /&gt;&lt;span style="color:#009900;"&gt;        // If the field contains value 6:&lt;br /&gt;        // we'll fill it black.&lt;/span&gt;&lt;br /&gt;        gField.FillRectangle(Brushes.Black, rtgField);&lt;br /&gt;&lt;span style="color:#000099;"&gt;        break&lt;/span&gt;;&lt;br /&gt;&lt;span style="color:#000099;"&gt;      case&lt;/span&gt; 7:&lt;br /&gt;&lt;span style="color:#009900;"&gt;        // If the field contains value 7:&lt;br /&gt;        // we'll fill it orange.&lt;/span&gt;&lt;br /&gt;        gField.FillRectangle(Brushes.Orange, rtgField);&lt;br /&gt;&lt;span style="color:#000099;"&gt;        break&lt;/span&gt;;&lt;br /&gt;&lt;span style="color:#000099;"&gt;      case&lt;/span&gt; 8:&lt;br /&gt;&lt;span style="color:#009900;"&gt;        // If the field contains value 8:&lt;br /&gt;        // we'll fill it gray.&lt;/span&gt;&lt;br /&gt;        gField.FillRectangle(Brushes.Gray, rtgField);&lt;br /&gt;&lt;span style="color:#000099;"&gt;        break&lt;/span&gt;;&lt;br /&gt;&lt;span style="color:#000099;"&gt;      case&lt;/span&gt; 9:&lt;br /&gt;&lt;span style="color:#009900;"&gt;        // If the field contains value 9:&lt;br /&gt;        // we'll fill it dark blue.&lt;/span&gt;&lt;br /&gt;        gField.FillRectangle(Brushes.DarkBlue, rtgField);&lt;br /&gt;&lt;span style="color:#000099;"&gt;        break&lt;/span&gt;;&lt;br /&gt;&lt;span style="color:#000099;"&gt;      case&lt;/span&gt; 10:&lt;br /&gt;&lt;span style="color:#009900;"&gt;        // If the field contains value 10:&lt;br /&gt;        // we'll fill it pink.&lt;/span&gt;&lt;br /&gt;        gField.FillRectangle(Brushes.Pink, rtgField);&lt;br /&gt;&lt;span style="color:#000099;"&gt;        break&lt;/span&gt;;&lt;br /&gt;&lt;span style="color:#000099;"&gt;      default&lt;/span&gt;:&lt;br /&gt;&lt;/span&gt;&lt;span style="color:#009900;"&gt;&lt;span style="font-family:courier new;"&gt;        // If our program comes to this point of the code,&lt;br /&gt;        // something's gone wrong! ;) XD&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;&lt;br /&gt;&lt;span style="color:#000099;"&gt;        break&lt;/span&gt;;&lt;br /&gt;    }&lt;br /&gt;  }&lt;br /&gt;}&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Now, you're just a few steps away from seeing it on the screen. Go back to your Design View by clicking the tab 'frmMain.cs [design]' on top of the code window. Double click on the 'New Game' button, and you should wind up right back in the 'code' window. But, this time, you'll see some extra lines of code that were generated by the VS.net. The new lines are:&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="font-family:courier new;"&gt;&lt;span style="color:#000099;"&gt;private void&lt;/span&gt; butGame_Click(&lt;span style="color:#000099;"&gt;object&lt;/span&gt; sender, &lt;span style="color:#339999;"&gt;EventArgs&lt;/span&gt; e)&lt;br /&gt;{&lt;br /&gt;}&lt;/span&gt;&lt;/p&gt;&lt;p&gt;Add this line of code in between the two curly brackets:&lt;br /&gt;&lt;/p&gt;&lt;p align="left"&gt;&lt;span face="courier new"&gt;DrawField();&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;And run your game! (Click on the green 'Play' button in your toolbar). Click on the button, and you should see this:&lt;/p&gt;&lt;p align="center"&gt;&lt;br /&gt;&lt;img style="cursor:pointer; cursor:hand;width: 320px; height: 238px;" src="http://4.bp.blogspot.com/_4WDpsfty9mg/SdCnohyfeVI/AAAAAAAAABM/k5kJoUWY-Es/s320/7_1_Empty_Field.png" border="0" alt="" id="BLOGGER_PHOTO_ID_5318935474631309650" /&gt;&lt;br /&gt;&lt;/p&gt;&lt;p align="left"&gt;In the next chapter: We'll fill our CreateGrid() function, and play a little with our blocks... :)&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1891129859130768227-7885161784290132682?l=create-your-game.blogspot.com' alt='' /&gt;&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/GameDevelopmentTutorials/~4/7XZCuqyloGk" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://create-your-game.blogspot.com/feeds/7885161784290132682/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://create-your-game.blogspot.com/2009/03/7-showing-our-field.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/1891129859130768227/posts/default/7885161784290132682?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/1891129859130768227/posts/default/7885161784290132682?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/GameDevelopmentTutorials/~3/7XZCuqyloGk/7-showing-our-field.html" title="7. Showing our field" /><author><name>Marin Malnar</name><uri>http://www.blogger.com/profile/12164590973052924670</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="26" height="32" src="http://1.bp.blogspot.com/_4WDpsfty9mg/ShhOIFmmh4I/AAAAAAAAARo/bKSb8UiTYTw/S220/drawing_biker.jpg" /></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://4.bp.blogspot.com/_4WDpsfty9mg/SdCnohyfeVI/AAAAAAAAABM/k5kJoUWY-Es/s72-c/7_1_Empty_Field.png" height="72" width="72" /><thr:total>0</thr:total><feedburner:origLink>http://create-your-game.blogspot.com/2009/03/7-showing-our-field.html</feedburner:origLink></entry><entry gd:etag="W/&quot;DUECRX8-cCp7ImA9WxVbFE0.&quot;"><id>tag:blogger.com,1999:blog-1891129859130768227.post-7898887940758792076</id><published>2009-03-30T11:31:00.022+02:00</published><updated>2009-03-30T12:07:44.158+02:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2009-03-30T12:07:44.158+02:00</app:edited><title>6. Let's write some code</title><content type="html">&lt;p&gt;For me, writing code is the best part of a game development process. Some people like crossword puzzles, I like writing code. So, to start writing code, we have to find the code editor. Easy. Go to your Solution Explorer window, right-click on the '&lt;strong&gt;frmMain.cs&lt;/strong&gt;' and select '&lt;strong&gt;View Code&lt;/strong&gt;'. That should show you the code editor. And, it's not empty! ;)&lt;/p&gt;&lt;p align="center"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_4WDpsfty9mg/SdCRuIrIsAI/AAAAAAAAABE/tzPhTlrruS8/s1600-h/6_1_Code_Editor.png"&gt;&lt;img style="cursor:pointer; cursor:hand;width: 400px; height: 288px;" src="http://3.bp.blogspot.com/_4WDpsfty9mg/SdCRuIrIsAI/AAAAAAAAABE/tzPhTlrruS8/s400/6_1_Code_Editor.png" border="0" alt="" id="BLOGGER_PHOTO_ID_5318911381712973826" /&gt;&lt;/a&gt;&lt;/p&gt;&lt;p&gt;Note:&lt;br /&gt;&lt;em&gt;TestApp&lt;/em&gt; is the application name I wrote in the new project dialog. &lt;br /&gt;&lt;/p&gt;&lt;p&gt;I won't get into explaining what's all this stuff. For now. I hope you'll figure it out trough the course of this tutorial. Right here in the beginning, we'll create some empty functions. Later on, we'll fill these functions with code. We'll also put in a couple of extra using statements. Just so we don't forget them later on... So, go to the top of your code window, and add the next 'using' statements there:&lt;/p&gt;&lt;p&gt;&lt;span style="font-family:courier new;"&gt;&lt;span style="color:#000099;"&gt;using&lt;/span&gt; System.IO;&lt;br /&gt;&lt;span style="color:#000099;"&gt;using&lt;/span&gt; System.Drawing.Drawing2D&lt;/span&gt;&lt;/p&gt;&lt;p&gt;This will let us read and write files from the hard drive, and let us play with some nice graphic features, later in the project. Be careful, C# is a case sensitive language (unlike Visual Basic, for example), so make sure you watch that shift key of your's. ;) Now, let's add all those functions that we'll need. We'll put them inside of the &lt;span style="font-family:courier new;"&gt;&lt;span style="color:#000099;"&gt;public partial class&lt;/span&gt; &lt;span style="color:#339999;"&gt;frmMain&lt;/span&gt; : &lt;span style="color:#339999;"&gt;Form&lt;/span&gt;&lt;/span&gt;. You can see that there's already one in there: &lt;span style="font-family:courier new;"&gt;&lt;span style="color:#000099;"&gt;public&lt;/span&gt; frmMain(). &lt;/span&gt;&lt;span &gt;Every function has an opening bracket {, and a closing bracket }. The function's code comes in between those brackets. So, move your cursor after the frmMain()'s closing bracket, and add new functions like this:&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="font-family:courier new;"&gt;&lt;span style="color:#000099;"&gt;public void&lt;/span&gt; CreateField()&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;{&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;}&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="font-family:courier new;"&gt;&lt;span style="color:#000099;"&gt;public void&lt;/span&gt; CreateNewColumn()&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;{&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;}&lt;/span&gt;&lt;/p&gt;&lt;p&gt;In the same way add the next functions. (don't forget the curly brackets). ;)&lt;/p&gt;&lt;p&gt;&lt;span style="font-family:courier new;"&gt;&lt;span style="color:#000099;"&gt;private void&lt;/span&gt; MoveRight()&lt;br /&gt;&lt;span style="color:#000099;"&gt;private void&lt;/span&gt; GameOver()&lt;br /&gt;&lt;span style="color:#000099;"&gt;private void&lt;/span&gt; DrawField()&lt;br /&gt;&lt;span style="color:#000099;"&gt;private void&lt;/span&gt; DrawGrid()&lt;br /&gt;&lt;span style="color:#000099;"&gt;private void&lt;/span&gt; CheckConnected()&lt;br /&gt;&lt;span style="color:#000099;"&gt;private void&lt;/span&gt; CheckAll()&lt;br /&gt;&lt;span style="color:#000099;"&gt;private bool&lt;/span&gt; CheckIfInList()&lt;br /&gt;&lt;span style="color:#000099;"&gt;private void&lt;/span&gt; DestroyBlocks()&lt;br /&gt;&lt;span style="color:#000099;"&gt;private void&lt;/span&gt; GoGravity()&lt;br /&gt;&lt;span style="color:#000099;"&gt;private void&lt;/span&gt; NewGame()&lt;br /&gt;&lt;span style="color:#000099;"&gt;private void&lt;/span&gt; NewLevel()&lt;br /&gt;&lt;span style="color:#000099;"&gt;private void&lt;/span&gt; DoTheScoreMath()&lt;br /&gt;&lt;span style="color:#000099;"&gt;private void&lt;/span&gt; DropBlock()&lt;br /&gt;&lt;span style="color:#000099;"&gt;private void&lt;/span&gt; LevelScore()&lt;br /&gt;&lt;span style="color:#000099;"&gt;private void&lt;/span&gt; HighScore()&lt;br /&gt;&lt;span style="color:#000099;"&gt;private void&lt;/span&gt; Redraw()&lt;br /&gt;&lt;span style="color:#000099;"&gt;private void&lt;/span&gt; Splash()&lt;/span&gt;&lt;/p&gt;&lt;p&gt;So, let's start off with our Game Field code. First of all, we need to tell the computer that we want a field of 15 columns with 10 rows. Ok. Let's write some code that will declare a couple of variables:&lt;/p&gt;&lt;p&gt;&lt;span style="font-family:courier new;"&gt;&lt;span style="color:#009900;"&gt;// Variable declarations:&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color:#000099;"&gt;static int&lt;/span&gt; iHeight = 10;   &lt;span style="color:#009900;"&gt;// Game field Height&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#000099;"&gt;static int&lt;/span&gt; iWidth = 15;    &lt;/span&gt;&lt;span style="font-family:courier new;"&gt;&lt;span style="color:#009900;"&gt;// Game field Width&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;&lt;br /&gt;&lt;span style="color:#000099;"&gt;static int&lt;/span&gt; iFieldSize = 32;&lt;span style="color:#009900;"&gt;// Block size, in pixels&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;This code will define our game field width, game field height and the size of every little field (block) in the game field. But, where to put this code?&lt;/p&gt;&lt;p&gt;&lt;em&gt;Put it between:&lt;/em&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="font-family:courier new;"&gt;&lt;span style="color:#000099;"&gt;public partial class&lt;/span&gt; &lt;span style="color:#339999;"&gt;frmMain&lt;/span&gt; : &lt;span style="color:#339999;"&gt;Form&lt;/span&gt;&lt;br /&gt;{&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;em&gt;and:&lt;/em&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="font-family:courier new;"&gt;&lt;span style="color:#000099;"&gt;public&lt;/span&gt; frmMain()&lt;/span&gt;&lt;/p&gt;&lt;p&gt;I would suggest that you don't just copy and paste the code. Writing it on your own will help you understand it, and you'll see how Visual Studio helps you with auto-complete dropdown. You probably noticed the green part of the code - the double slashes let our compiler know that lines starting with them are actually comments, and they do not affect our program execution. &lt;/p&gt;&lt;p&gt;Ok, so, we declared the width, the height, and field size. But that doesn't tell our program much. So, we'll declare our fields now. (Remember the drawing in chapter 4?) So, here's two more lines of code - put them after the lines you just wrote.&lt;/p&gt;&lt;p&gt;&lt;span style="color:#009900;"&gt;//Declare Fields as an 2D array&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#000099;"&gt;int&lt;/span&gt;[,] Field = &lt;span style="color:#000099;"&gt;new int&lt;/span&gt;[iHeight, iWidth];&lt;/p&gt;&lt;p&gt;This line actualy tells the application that we'll be using Field[x,y] format to work with our blocks. We can now add values to every field. And the next step is to create a function that will fill all of the fields with value 0. Zero means that the field is empty. This is the code we need to put in the CreateField() function (between the function's opening and closing curly brackets):&lt;/p&gt;&lt;p&gt;&lt;span style="color:#009900;"&gt;&lt;span style="font-family:courier new;"&gt;// Function that clears the game field.&lt;br /&gt;// Do this for all rows&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;&lt;br /&gt;&lt;span style="color:#000099;"&gt;for&lt;/span&gt; (&lt;span style="color:#000099;"&gt;int&lt;/span&gt; x = 0; x &lt; iHeight; x++)&lt;br /&gt;{&lt;br /&gt;&lt;span style="color:#009900;"&gt;    //Do this for all columns&lt;/span&gt;&lt;br /&gt;    &lt;span style="color:#000099;"&gt;for&lt;/span&gt; (&lt;span style="color:#000099;"&gt;int&lt;/span&gt; y = 0; y &lt; iWidth; y++)&lt;br /&gt;    {&lt;br /&gt;&lt;span style="color:#009900;"&gt;        //Clear the fields:&lt;/span&gt;&lt;br /&gt;        Field[x, y] = 0;&lt;br /&gt;    }&lt;br /&gt;}&lt;/span&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;Ok, we have the code that creates an empty game field now… But, our game field is hidden somewere in our computers memory. In the next chapter, we'll make our application show us our game field on the form we created.&lt;br /&gt;&lt;br /&gt;&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1891129859130768227-7898887940758792076?l=create-your-game.blogspot.com' alt='' /&gt;&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/GameDevelopmentTutorials/~4/qSlbfumjpyw" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://create-your-game.blogspot.com/feeds/7898887940758792076/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://create-your-game.blogspot.com/2009/03/6-lets-write-some-code.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/1891129859130768227/posts/default/7898887940758792076?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/1891129859130768227/posts/default/7898887940758792076?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/GameDevelopmentTutorials/~3/qSlbfumjpyw/6-lets-write-some-code.html" title="6. Let's write some code" /><author><name>Marin Malnar</name><uri>http://www.blogger.com/profile/12164590973052924670</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="26" height="32" src="http://1.bp.blogspot.com/_4WDpsfty9mg/ShhOIFmmh4I/AAAAAAAAARo/bKSb8UiTYTw/S220/drawing_biker.jpg" /></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://3.bp.blogspot.com/_4WDpsfty9mg/SdCRuIrIsAI/AAAAAAAAABE/tzPhTlrruS8/s72-c/6_1_Code_Editor.png" height="72" width="72" /><thr:total>0</thr:total><feedburner:origLink>http://create-your-game.blogspot.com/2009/03/6-lets-write-some-code.html</feedburner:origLink></entry><entry gd:etag="W/&quot;DUcEQXw6eSp7ImA9WxVbFUs.&quot;"><id>tag:blogger.com,1999:blog-1891129859130768227.post-4044722401145768532</id><published>2009-03-30T10:17:00.013+02:00</published><updated>2009-04-01T08:23:20.211+02:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2009-04-01T08:23:20.211+02:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="game field" /><category scheme="http://www.blogger.com/atom/ns#" term="picture box" /><category scheme="http://www.blogger.com/atom/ns#" term="form" /><category scheme="http://www.blogger.com/atom/ns#" term="grid" /><category scheme="http://www.blogger.com/atom/ns#" term="button" /><title>5. Finally, some real stuff!</title><content type="html">&lt;strong&gt;Game Field!&lt;/strong&gt;&lt;p&gt;If you would buy a game of Monopoly in the 'real' world, you'd probably get a box, some playing figures, dice, bonus cards,property cards, game money, rule book and a game board. A lot of the similar stuff, like dice and game board, can be found in other 'regular' games. So, it would be logical to assume that computer games need similar 'components' to work. Yes, we'll make some of this stuff in our PC game. The first thing is to make a game board, or a game field, as I call it. Our game will use a big game field made of small fields. We'll create a field 15x10 in size. 15 columns and 10 rows. Each of the small game field blocks will hold one Block, Bubble, Baloon, whatever...&lt;/p&gt;&lt;p&gt;Here's the idea:&lt;/p&gt;&lt;p align="center"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_4WDpsfty9mg/SdCAn3GvvgI/AAAAAAAAAA0/DbMwxBMtGcA/s1600-h/5_1_Game_Field.png"&gt;&lt;img style="cursor:pointer; cursor:hand;width: 320px; height: 267px;" src="http://1.bp.blogspot.com/_4WDpsfty9mg/SdCAn3GvvgI/AAAAAAAAAA0/DbMwxBMtGcA/s320/5_1_Game_Field.png" border="0" alt="" id="BLOGGER_PHOTO_ID_5318892582220054018" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;Ok, you probably get the idea now. Our game field is, basically, a bunch of blocks. Each block is defined with it's coordinates and a value (in this case, representing a speific color). So, how to make our empty form show something like this?&lt;br /&gt;&lt;/p&gt;&lt;p&gt;First add the next controls to the form:&lt;br /&gt;&lt;span style="font-size:85%;"&gt;(You can drag them from the tool box onto the empty form)&lt;/span&gt;&lt;/p&gt;&lt;ol&gt;&lt;li&gt;&lt;span style="font-size:100%;"&gt;Picture Box&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="font-size:100%;"&gt;Button&lt;/span&gt;&lt;/li&gt;&lt;/ol&gt;&lt;p&gt;Now we'll fine-tune some properties for our new controls. In the Properties window, on the left, there is a huge list of properties you can adjust. Click on your Form and and tweak the properties to the values shown in the next list:&lt;/p&gt;&lt;p&gt;&lt;strong&gt;&lt;span style="color:#009900;"&gt;Form - frmMain&lt;/span&gt;&lt;/strong&gt;&lt;/p&gt;&lt;ul&gt;&lt;li&gt;&lt;span style="color:#ff6600;"&gt;FormBorderStyle: &lt;/span&gt;&lt;strong&gt;&lt;span style="color:#000000;"&gt;FixedSingle&lt;/span&gt;&lt;/strong&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="color:#ff6600;"&gt;MaximizeBox:&lt;/span&gt; &lt;strong&gt;&lt;span style="color:#000000;"&gt;False&lt;/span&gt;&lt;/strong&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="color:#ff6600;"&gt;Size:&lt;/span&gt; &lt;strong&gt;&lt;span style="color:#000000;"&gt;630; 470&lt;/span&gt;&lt;/strong&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="color:#ff6600;"&gt;StartPosition:&lt;/span&gt; &lt;strong&gt;&lt;span style="color:#000000;"&gt;CenterScreen&lt;/span&gt;&lt;/strong&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="color:#ff6600;"&gt;Text:&lt;/span&gt; &lt;strong&gt;&lt;span style="color:#000000;"&gt;My First Game&lt;/span&gt;&lt;/strong&gt;&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;This will disable resizing of your form, set it's size and start position, and write 'My First Game' in the title bar. Ok, moving on - select the button, and set it's properties:&lt;/p&gt;&lt;p&gt;&lt;p&gt;&lt;strong&gt;&lt;span style="color:#009900;"&gt;Button&lt;/span&gt;&lt;/strong&gt;&lt;/p&gt;&lt;ul&gt;&lt;li&gt;&lt;span style="color:#ff6600;"&gt;(name):&lt;/span&gt;&lt;strong&gt;&lt;span style="color:#000000;"&gt; butGame&lt;/span&gt;&lt;/strong&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="color:#ff6600;"&gt;Location:&lt;/span&gt; &lt;strong&gt;&lt;span style="color:#000000;"&gt;12; 6&lt;/span&gt;&lt;/strong&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="color:#ff6600;"&gt;Size:&lt;/span&gt; &lt;strong&gt;&lt;span style="color:#000000;"&gt;126; 53&lt;/span&gt;&lt;/strong&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="color:#ff6600;"&gt;Text:&lt;/span&gt; &lt;strong&gt;&lt;span style="color:#000000;"&gt;New Game&lt;/span&gt;&lt;/strong&gt;&lt;/li&gt;&lt;/ul&gt;And for the end, select the picture box and, again, set it's properties:&lt;p&gt;&lt;/p&gt;&lt;p&gt;&lt;p&gt;&lt;strong&gt;&lt;span style="color:#009900;"&gt;Picture Box&lt;/span&gt;&lt;/strong&gt;&lt;/p&gt;&lt;ul&gt;&lt;li&gt;&lt;span style="color:#ff6600;"&gt;(name): &lt;/span&gt;&lt;strong&gt;&lt;span style="color:#000000;"&gt;picGameField&lt;/span&gt;&lt;/strong&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="color:#ff6600;"&gt;BackColor:&lt;/span&gt; &lt;strong&gt;&lt;span style="color:#000000;"&gt;Web&gt;Transparent&lt;/span&gt;&lt;/strong&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="color:#ff6600;"&gt;Location:&lt;/span&gt; &lt;strong&gt;&lt;span style="color:#000000;"&gt;0; 65&lt;/span&gt;&lt;/strong&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="color:#ff6600;"&gt;Size:&lt;/span&gt; &lt;strong&gt;&lt;span style="color:#000000;"&gt;480; 320&lt;/span&gt;&lt;/strong&gt;&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;&lt;strong&gt;&lt;span style="color:#000000;"&gt;&lt;/span&gt;&lt;/strong&gt;&lt;/p&gt;&lt;div align="left"&gt;Your form should now look like this:&lt;/div&gt;&lt;div align="left"&gt;&lt;/div&gt;&lt;div align="left"&gt;&lt;/div&gt;&lt;div align="center"&gt;&lt;img style="cursor:pointer; cursor:hand;width: 320px; height: 240px;" src="http://2.bp.blogspot.com/_4WDpsfty9mg/SdCBBY1KJ3I/AAAAAAAAAA8/Ge7vpY-W_cM/s320/5_2_Base_Form.png" border="0" alt="" id="BLOGGER_PHOTO_ID_5318893020769822578" /&gt;&lt;br /&gt;&lt;/div&gt;&lt;div align="left"&gt;&lt;/div&gt;&lt;div align="left"&gt;Don't forget to save your work!&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1891129859130768227-4044722401145768532?l=create-your-game.blogspot.com' alt='' /&gt;&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/GameDevelopmentTutorials/~4/O9VlmsJ8tRw" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://create-your-game.blogspot.com/feeds/4044722401145768532/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://create-your-game.blogspot.com/2009/03/5-finally-some-real-stuff.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/1891129859130768227/posts/default/4044722401145768532?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/1891129859130768227/posts/default/4044722401145768532?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/GameDevelopmentTutorials/~3/O9VlmsJ8tRw/5-finally-some-real-stuff.html" title="5. Finally, some real stuff!" /><author><name>Marin Malnar</name><uri>http://www.blogger.com/profile/12164590973052924670</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="26" height="32" src="http://1.bp.blogspot.com/_4WDpsfty9mg/ShhOIFmmh4I/AAAAAAAAARo/bKSb8UiTYTw/S220/drawing_biker.jpg" /></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://1.bp.blogspot.com/_4WDpsfty9mg/SdCAn3GvvgI/AAAAAAAAAA0/DbMwxBMtGcA/s72-c/5_1_Game_Field.png" height="72" width="72" /><thr:total>0</thr:total><feedburner:origLink>http://create-your-game.blogspot.com/2009/03/5-finally-some-real-stuff.html</feedburner:origLink></entry><entry gd:etag="W/&quot;Ck4MQ38_eip7ImA9WxVbFE0.&quot;"><id>tag:blogger.com,1999:blog-1891129859130768227.post-4338468433666685761</id><published>2009-03-30T10:13:00.003+02:00</published><updated>2009-03-30T10:16:22.142+02:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2009-03-30T10:16:22.142+02:00</app:edited><title>4. Starting a new Project in C#</title><content type="html">&lt;p&gt;This section of the tutorial will show you how to create a new Project in C#, so we'll be able to start programming. You can skip this part if you already know (or figured on your own) how to do this. The procedure is fairly simple. Just follow the next few steps:&lt;/p&gt;&lt;p align="left"&gt;&lt;br /&gt;1. Open your C# 2008 Express Edition (or whatever you have installed)&lt;br /&gt;2. Click File &gt; New Project&lt;br /&gt;3. Select Windows Forms Application (or similar)&lt;br /&gt;4. Enter the Name of your new application&lt;br /&gt;5. Click Ok&lt;/p&gt;&lt;p align="center"&gt;&lt;br /&gt;&lt;em&gt;Following these steps should give you a screen similar to this one:&lt;/em&gt;&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_4WDpsfty9mg/SdB_RoaMg2I/AAAAAAAAAAs/BQE4nMt0sTM/s1600-h/4_1_VC_NewProj.png"&gt;&lt;img style="cursor:pointer; cursor:hand;width: 320px; height: 278px;" src="http://1.bp.blogspot.com/_4WDpsfty9mg/SdB_RoaMg2I/AAAAAAAAAAs/BQE4nMt0sTM/s320/4_1_VC_NewProj.png" border="0" alt="" id="BLOGGER_PHOTO_ID_5318891100806349666" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;So, let's take a quick look on the screen:&lt;br /&gt;In the center you have an empty Form. This is where you design how your application will look, and eventualy this is where you'll write your code. On the left, there is a ToolBox with various controls you can drag onto your form to give it some funcionality. On the right, you'll find the Solution Explorer and the Properties window. On the bottom of the screen you'll see your Error List / Debugging window where the studio will show you all needed information about your program. Before moving on, go to your Solution Explorer window, right click on 'Form1.cs', select Rename, and enter 'frmMain.cs'. And finally, save your project.&lt;br /&gt;&lt;br /&gt;&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1891129859130768227-4338468433666685761?l=create-your-game.blogspot.com' alt='' /&gt;&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/GameDevelopmentTutorials/~4/XLwWNChrW-M" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://create-your-game.blogspot.com/feeds/4338468433666685761/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://create-your-game.blogspot.com/2009/03/4-starting-new-project-in-c.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/1891129859130768227/posts/default/4338468433666685761?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/1891129859130768227/posts/default/4338468433666685761?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/GameDevelopmentTutorials/~3/XLwWNChrW-M/4-starting-new-project-in-c.html" title="4. Starting a new Project in C#" /><author><name>Marin Malnar</name><uri>http://www.blogger.com/profile/12164590973052924670</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="26" height="32" src="http://1.bp.blogspot.com/_4WDpsfty9mg/ShhOIFmmh4I/AAAAAAAAARo/bKSb8UiTYTw/S220/drawing_biker.jpg" /></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://1.bp.blogspot.com/_4WDpsfty9mg/SdB_RoaMg2I/AAAAAAAAAAs/BQE4nMt0sTM/s72-c/4_1_VC_NewProj.png" height="72" width="72" /><thr:total>0</thr:total><feedburner:origLink>http://create-your-game.blogspot.com/2009/03/4-starting-new-project-in-c.html</feedburner:origLink></entry><entry gd:etag="W/&quot;CkMNQ345eip7ImA9WxVbFE0.&quot;"><id>tag:blogger.com,1999:blog-1891129859130768227.post-8171736216091702087</id><published>2009-03-30T10:06:00.003+02:00</published><updated>2009-03-30T10:08:12.022+02:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2009-03-30T10:08:12.022+02:00</app:edited><title>3. Game Idea</title><content type="html">&lt;p&gt;&lt;p&gt;&lt;strong&gt;First thing's first:&lt;/strong&gt;&lt;/p&gt;&lt;p&gt;&lt;em&gt;To make a good game - you'll need a good idea.&lt;/em&gt;&lt;br /&gt;&lt;/p&gt;Ideas are best when you get them on your own. If you're not very creative - steal someone else's. :-P You'll come up with your own - eventually... :) For this tutorial I used an idea from a on-line flash game called 'Gold Strike'. The game was fun... And while playing it - I figured out that I could program a game just like that one... More or less.&lt;br /&gt;&lt;p&gt;So, here's a screenshot of the flash game 'Gold Strike':&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;p align="center"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_4WDpsfty9mg/SdB9l7IR4kI/AAAAAAAAAAk/wGUX1_zf4L4/s1600-h/3_1_Gold_Strike.png"&gt;&lt;img style="cursor:pointer; cursor:hand;width: 320px; height: 230px;" src="http://3.bp.blogspot.com/_4WDpsfty9mg/SdB9l7IR4kI/AAAAAAAAAAk/wGUX1_zf4L4/s320/3_1_Gold_Strike.png" border="0" alt="" id="BLOGGER_PHOTO_ID_5318889250405605954" /&gt;&lt;/a&gt;&lt;/p&gt;&lt;p align="left"&gt;Well, the point of the game is to destroy blocks/bubbles. They appear in the first column on the left, and move to the right. The player can destroy only those blocks that are adjanted to the blocks of the same color. Blocks can't float - because of that - we'll have to create some gravity. The game's over when the blocks reach the player, and there's no space for new columns. There are a few other additional rules... Like, levels: When to move to the next one?, What happens in the next one? Bonuses... And so on... But we'll come to this when time comes.&lt;br /&gt;&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1891129859130768227-8171736216091702087?l=create-your-game.blogspot.com' alt='' /&gt;&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/GameDevelopmentTutorials/~4/yTRfs0phOfI" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://create-your-game.blogspot.com/feeds/8171736216091702087/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://create-your-game.blogspot.com/2009/03/3-game-idea.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/1891129859130768227/posts/default/8171736216091702087?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/1891129859130768227/posts/default/8171736216091702087?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/GameDevelopmentTutorials/~3/yTRfs0phOfI/3-game-idea.html" title="3. Game Idea" /><author><name>Marin Malnar</name><uri>http://www.blogger.com/profile/12164590973052924670</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="26" height="32" src="http://1.bp.blogspot.com/_4WDpsfty9mg/ShhOIFmmh4I/AAAAAAAAARo/bKSb8UiTYTw/S220/drawing_biker.jpg" /></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://3.bp.blogspot.com/_4WDpsfty9mg/SdB9l7IR4kI/AAAAAAAAAAk/wGUX1_zf4L4/s72-c/3_1_Gold_Strike.png" height="72" width="72" /><thr:total>0</thr:total><feedburner:origLink>http://create-your-game.blogspot.com/2009/03/3-game-idea.html</feedburner:origLink></entry><entry gd:etag="W/&quot;CkUBQ345cSp7ImA9WxVbFEQ.&quot;"><id>tag:blogger.com,1999:blog-1891129859130768227.post-3396215426184913760</id><published>2009-03-30T09:41:00.005+02:00</published><updated>2009-03-31T11:04:12.029+02:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2009-03-31T11:04:12.029+02:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="visual studio" /><category scheme="http://www.blogger.com/atom/ns#" term="express edition" /><category scheme="http://www.blogger.com/atom/ns#" term="C#" /><category scheme="http://www.blogger.com/atom/ns#" term="game-dev" /><title>2. Tools of the trade</title><content type="html">&lt;div align="center"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_4WDpsfty9mg/SdB5Zz-0vCI/AAAAAAAAAAc/mefrsENpIvo/s1600-h/2_1_VC_ExEd.png"&gt;&lt;img style="display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;width: 320px; height: 226px;" src="http://2.bp.blogspot.com/_4WDpsfty9mg/SdB5Zz-0vCI/AAAAAAAAAAc/mefrsENpIvo/s320/2_1_VC_ExEd.png" border="0" alt="" id="BLOGGER_PHOTO_ID_5318884644281957410" /&gt;&lt;/a&gt;&lt;span style="font-size:85%;"&gt;A screenshot of the VC# Express ED;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;p&gt;So, what do you need to follow this tutorial?&lt;br /&gt;&lt;/p&gt;&lt;p&gt;This tutorial is based on Microsoft's Visual C#, wich is a part of Microsoft's Visual Studio. I guess that any version of C# will do. I've tried my code on two machines: One with MS VC# 2005 Proffesional Edition, and one with MS VC# 2008 Express Edition installed. And it works just fine on both of them. So, my advice to you would be to go to Microsoft's web site and download the latest C# Express Edition. Yes - It's FREE! And no, it's not a demo. It's a fully funcional development tool for personal use. Once you download and install C# - you're ready to rock!&lt;/p&gt;&lt;p&gt;&lt;span style="font-size:85%;"&gt;(the URL is &lt;a href="http://www.microsoft.com/express/vcsharp/"&gt;www.microsoft.com&lt;/a&gt; - in case you didn't know ;)&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="font-size:100%;"&gt;&lt;strong&gt;Where to begin?&lt;/strong&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="font-size:100%;"&gt;First, open that freshly installed C# and look around... Try to familiarize yourself with the interface. The next thing would be to get a notebook - an old fashioned one, and a couple of pencils... They help you organise your thoughts. ;) And that's it. We're ready to design our first game.&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="font-size:85%;"&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1891129859130768227-3396215426184913760?l=create-your-game.blogspot.com' alt='' /&gt;&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/GameDevelopmentTutorials/~4/RKbQCy46KHI" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://create-your-game.blogspot.com/feeds/3396215426184913760/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://create-your-game.blogspot.com/2009/03/2-tools-of-trade.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/1891129859130768227/posts/default/3396215426184913760?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/1891129859130768227/posts/default/3396215426184913760?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/GameDevelopmentTutorials/~3/RKbQCy46KHI/2-tools-of-trade.html" title="2. Tools of the trade" /><author><name>Marin Malnar</name><uri>http://www.blogger.com/profile/12164590973052924670</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="26" height="32" src="http://1.bp.blogspot.com/_4WDpsfty9mg/ShhOIFmmh4I/AAAAAAAAARo/bKSb8UiTYTw/S220/drawing_biker.jpg" /></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://2.bp.blogspot.com/_4WDpsfty9mg/SdB5Zz-0vCI/AAAAAAAAAAc/mefrsENpIvo/s72-c/2_1_VC_ExEd.png" height="72" width="72" /><thr:total>0</thr:total><feedburner:origLink>http://create-your-game.blogspot.com/2009/03/2-tools-of-trade.html</feedburner:origLink></entry></feed>

