Post your sample source code here and get featured on our blogs! You can post your interesting sample source code (and an optional screenshot of the program) here.  If it is interesting enough we'll feature you and your source code on our blogs (<a href="http://blogs.msdn.com/smallbasic">http://blogs.msdn.com/smallbasic</a>).  Here's something to get started.<br> <p></p> <div style="border-bottom:#7f9db9 1px solid;border-left:#7f9db9 1px solid;line-height:100% !important;background-color:white;font-family:courier new;font-size:11px;overflow:auto;border-top:#7f9db9 1px solid;border-right:#7f9db9 1px solid"> <table style="border-bottom:#eee 0px solid;border-right-width:0px;background-color:#fff;margin:2px 0px;width:99%;border-collapse:collapse;border-top-width:0px;border-left-width:0px" cellspacing=0 cellpadding=0> <colgroup> <col style="border-bottom:#f7f7f7 1px solid;padding-left:10px;font-family:courier new;white-space:nowrap;font-size:11px"></colgroup> <tbody> <tr> <td><font style="font-size:11px">GraphicsWindow.Show()  </font></td></tr> <tr> <td style="background-color:#f7f7f7"> </td></tr> <tr> <td>pic = Flickr.GetRandomPicture(<font color=blue>&quot;lightning&quot;</font><font style="font-size:11px">)  </font></td></tr> <tr> <td style="background-color:#f7f7f7">gw = GraphicsWindow.Width  </td></tr> <tr> <td>gh = GraphicsWindow.Height  </td></tr> <tr> <td style="background-color:#f7f7f7">GraphicsWindow.DrawResizedImage(pic, 0, 0, gw, gh)  </td></tr> <tr> <td> </td></tr> <tr> <td style="background-color:#f7f7f7">distance = 50  </td></tr> <tr> <td>Turtle.Speed = 9  </td></tr> <tr> <td style="background-color:#f7f7f7"> </td></tr> <tr> <td><font color=blue>For</font><font style="font-size:11px"> sides = 3 </font><font color=blue>To</font><font style="font-size:11px"> 20  </font></td></tr> <tr> <td style="background-color:#f7f7f7">  DrawPolygon()  </td></tr> <tr> <td>EndFor  </td></tr> <tr> <td style="background-color:#f7f7f7"> </td></tr> <tr> <td><font color=blue>Sub</font><font style="font-size:11px"> DrawPolygon  </font></td></tr> <tr> <td style="background-color:#f7f7f7">  angle = 360 / sides  </td></tr> <tr> <td>  <font color=blue>For</font><font style="font-size:11px"> i = 1 </font><font color=blue>To</font><font style="font-size:11px"> sides  </font></td></tr> <tr> <td style="background-color:#f7f7f7">    GraphicsWindow.PenColor = GraphicsWindow.GetRandomColor()  </td></tr> <tr> <td>    Turtle.Move(distance)  </td></tr> <tr> <td style="background-color:#f7f7f7">    Turtle.Turn(angle)  </td></tr> <tr> <td>  EndFor  </td></tr> <tr> <td style="background-color:#f7f7f7">EndSub  </td></tr> <tr> <td> </td></tr></tbody></table></div><br><img border=1 src="http://vijaye.com/blog/turtles_polygon.jpg"> <br><br>© 2009 Microsoft Corporation. All rights reserved.Wed, 01 Jul 2009 21:08:03 Zeaacf826-9d12-4e3c-aa10-1b2788f160a6http://social.msdn.microsoft.com/Forums/en-US/smallbasic/thread/eaacf826-9d12-4e3c-aa10-1b2788f160a6#eaacf826-9d12-4e3c-aa10-1b2788f160a6http://social.msdn.microsoft.com/Forums/en-US/smallbasic/thread/eaacf826-9d12-4e3c-aa10-1b2788f160a6#eaacf826-9d12-4e3c-aa10-1b2788f160a6Vijaye Rajihttp://social.msdn.microsoft.com/Profile/en-US/?user=Vijaye%20RajiPost your sample source code here and get featured on our blogs! You can post your interesting sample source code (and an optional screenshot of the program) here.  If it is interesting enough we'll feature you and your source code on our blogs (<a href="http://blogs.msdn.com/smallbasic">http://blogs.msdn.com/smallbasic</a>).  Here's something to get started.<br> <p></p> <div style="border-bottom:#7f9db9 1px solid;border-left:#7f9db9 1px solid;line-height:100% !important;background-color:white;font-family:courier new;font-size:11px;overflow:auto;border-top:#7f9db9 1px solid;border-right:#7f9db9 1px solid"> <table style="border-bottom:#eee 0px solid;border-right-width:0px;background-color:#fff;margin:2px 0px;width:99%;border-collapse:collapse;border-top-width:0px;border-left-width:0px" cellspacing=0 cellpadding=0> <colgroup> <col style="border-bottom:#f7f7f7 1px solid;padding-left:10px;font-family:courier new;white-space:nowrap;font-size:11px"></colgroup> <tbody> <tr> <td><font style="font-size:11px">GraphicsWindow.Show()  </font></td></tr> <tr> <td style="background-color:#f7f7f7"> </td></tr> <tr> <td>pic = Flickr.GetRandomPicture(<font color=blue>&quot;lightning&quot;</font><font style="font-size:11px">)  </font></td></tr> <tr> <td style="background-color:#f7f7f7">gw = GraphicsWindow.Width  </td></tr> <tr> <td>gh = GraphicsWindow.Height  </td></tr> <tr> <td style="background-color:#f7f7f7">GraphicsWindow.DrawResizedImage(pic, 0, 0, gw, gh)  </td></tr> <tr> <td> </td></tr> <tr> <td style="background-color:#f7f7f7">distance = 50  </td></tr> <tr> <td>Turtle.Speed = 9  </td></tr> <tr> <td style="background-color:#f7f7f7"> </td></tr> <tr> <td><font color=blue>For</font><font style="font-size:11px"> sides = 3 </font><font color=blue>To</font><font style="font-size:11px"> 20  </font></td></tr> <tr> <td style="background-color:#f7f7f7">  DrawPolygon()  </td></tr> <tr> <td>EndFor  </td></tr> <tr> <td style="background-color:#f7f7f7"> </td></tr> <tr> <td><font color=blue>Sub</font><font style="font-size:11px"> DrawPolygon  </font></td></tr> <tr> <td style="background-color:#f7f7f7">  angle = 360 / sides  </td></tr> <tr> <td>  <font color=blue>For</font><font style="font-size:11px"> i = 1 </font><font color=blue>To</font><font style="font-size:11px"> sides  </font></td></tr> <tr> <td style="background-color:#f7f7f7">    GraphicsWindow.PenColor = GraphicsWindow.GetRandomColor()  </td></tr> <tr> <td>    Turtle.Move(distance)  </td></tr> <tr> <td style="background-color:#f7f7f7">    Turtle.Turn(angle)  </td></tr> <tr> <td>  EndFor  </td></tr> <tr> <td style="background-color:#f7f7f7">EndSub  </td></tr> <tr> <td> </td></tr></tbody></table></div><br><img border=1 src="http://vijaye.com/blog/turtles_polygon.jpg"> <br><br>Mon, 20 Oct 2008 03:37:48 Z2009-07-01T21:09:00Zhttp://social.msdn.microsoft.com/Forums/en-US/smallbasic/thread/eaacf826-9d12-4e3c-aa10-1b2788f160a6#9faef7d6-6bba-4934-b087-d74eab4eec8chttp://social.msdn.microsoft.com/Forums/en-US/smallbasic/thread/eaacf826-9d12-4e3c-aa10-1b2788f160a6#9faef7d6-6bba-4934-b087-d74eab4eec8cVijaye Rajihttp://social.msdn.microsoft.com/Profile/en-US/?user=Vijaye%20RajiPost your sample source code here and get featured on our blogs! A Blackboard application that allows you to draw on a window<br><br><pre><div style="border-bottom:#7f9db9 1px solid;border-left:#7f9db9 1px solid;line-height:100% !important;background-color:white;font-family:courier new;font-size:11px;overflow:auto;border-top:#7f9db9 1px solid;border-right:#7f9db9 1px solid"> <table style="border-bottom:#eee 0px solid;border-right-width:0px;background-color:#fff;margin:2px 0px;width:99%;border-collapse:collapse;border-top-width:0px;border-left-width:0px" cellspacing=0 cellpadding=0><colgroup><col style="border-bottom:#f7f7f7 1px solid;padding-left:10px;font-family:courier new;white-space:nowrap;font-size:11px"></colgroup><tbody><tr><td><font style="font-size:11px">GraphicsWindow.BackgroundColor = </font><font color="#0000ff">&quot;Black&quot;</font><font style="font-size:11px">   </font></td></tr><tr><td style="background-color:#f7f7f7">GraphicsWindow.PenColor = <font color="#0000ff">&quot;White&quot;</font><font style="font-size:11px">   </font></td></tr><tr><td>GraphicsWindow.MouseDown = OnMouseDown   </td></tr><tr><td style="background-color:#f7f7f7">GraphicsWindow.MouseMove = OnMouseMove   </td></tr><tr><td> </td></tr><tr><td style="background-color:#f7f7f7"><font color="#0000ff">Sub</font><font style="font-size:11px"> OnMouseDown   </font></td></tr><tr><td>  prevX = GraphicsWindow.MouseX   </td></tr><tr><td style="background-color:#f7f7f7">  prevY = GraphicsWindow.MouseY   </td></tr><tr><td>EndSub   </td></tr><tr><td style="background-color:#f7f7f7"> </td></tr><tr><td><font color="#0000ff">Sub</font><font style="font-size:11px"> OnMouseMove   </font></td></tr><tr><td style="background-color:#f7f7f7">  x = GraphicsWindow.MouseX   </td></tr><tr><td>  y = GraphicsWindow.MouseY   </td></tr><tr><td style="background-color:#f7f7f7">  <font color="#0000ff">If</font><font style="font-size:11px"> (Mouse.IsLeftButtonDown) then   </font></td></tr><tr><td>    GraphicsWindow.DrawLine(prevX, prevY, x, y)   </td></tr><tr><td style="background-color:#f7f7f7">  endif   </td></tr><tr><td>  prevX = x   </td></tr><tr><td style="background-color:#f7f7f7">  prevY = y   </td></tr><tr><td>EndSub </td></tr></tbody></table> </div> </pre><br><img alt="" src="http://blogs.msdn.com/photos/vijayeg/images/9013709/477x375.aspx"> Fri, 24 Oct 2008 01:38:09 Z2008-10-24T01:38:09Zhttp://social.msdn.microsoft.com/Forums/en-US/smallbasic/thread/eaacf826-9d12-4e3c-aa10-1b2788f160a6#ba2259b0-9b1d-48af-9844-8eac2d1a4df8http://social.msdn.microsoft.com/Forums/en-US/smallbasic/thread/eaacf826-9d12-4e3c-aa10-1b2788f160a6#ba2259b0-9b1d-48af-9844-8eac2d1a4df8Beth Massihttp://social.msdn.microsoft.com/Profile/en-US/?user=Beth%20MassiPost your sample source code here and get featured on our blogs!Here's a program to create a collage of World Series photos from Flickr <div style="border-right:#7f9db9 1px solid;border-top:#7f9db9 1px solid;font-size:11px;overflow:auto;border-left:#7f9db9 1px solid;line-height:100%! important;border-bottom:#7f9db9 1px solid;font-family:Courier New;background-color:white"><br> <table style="border-top-width:0px;border-left-width:0px;margin:2px 0px;width:99%;border-bottom:#eee 0px solid;border-collapse:collapse;background-color:#fff;border-right-width:0px" cellspacing=0 cellpadding=0> <colgroup> <col style="padding-left:10px;font-size:11px;border-bottom:#f7f7f7 1px solid;font-family:Courier New;white-space:nowrap"> <tbody> <tr> <td><font style="font-size:11px">tag = </font><font style="color:blue">&quot;World Series&quot;</font><font style="font-size:11px"> </font></td></tr> <tr> <td style="background-color:#f7f7f7"><font style="font-size:11px"></font></td></tr> <tr> <td></td></tr> <tr> <td style="background-color:#f7f7f7"></font><font style="color:blue">For</font><font style="font-size:11px"> i = 1 </font><font style="color:blue">To</font><font style="font-size:11px"> 10  </font></td></tr> <tr> <td>   x = Math.GetRandomNumber(250)  </td></tr> <tr> <td style="background-color:#f7f7f7">   y = Math.GetRandomNumber(250)  </td></tr> <tr> <td>              </td></tr> <tr> <td style="background-color:#f7f7f7">   picName = Flickr.GetRandomPicture(tag)  </td></tr> <tr> <td>          </td></tr> <tr> <td style="background-color:#f7f7f7">   GraphicsWindow.DrawResizedImage(picName, x, y, 200, 200)  </td></tr> <tr> <td>EndFor   </td></tr> <tr> <td style="background-color:#f7f7f7"> </td></tr></tbody></table></div><br>I wanted to actually scale the images instead of a fixed height and width but unfortunately the call the ImageList.GetWidthOfImage() keeps crashing (GetHeightOfImage works <br>fine). Anybody have any clues?<br><br> <div style="border-right:#7f9db9 1px solid;border-top:#7f9db9 1px solid;font-size:11px;overflow:auto;border-left:#7f9db9 1px solid;line-height:100%! important;border-bottom:#7f9db9 1px solid;font-family:Courier New;background-color:white"> <table style="border-top-width:0px;border-left-width:0px;margin:2px 0px;width:99%;border-bottom:#eee 0px solid;border-collapse:collapse;background-color:#fff;border-right-width:0px" cellspacing=0 cellpadding=0> <colgroup> <col style="padding-left:10px;font-size:11px;border-bottom:#f7f7f7 1px solid;font-family:Courier New;white-space:nowrap"> <tbody> <tr> <td><font style="font-size:11px"> </font></td></tr> <tr> <td style="background-color:#f7f7f7">tag = </font><font style="color:blue">&quot;World Series&quot;</font><font style="font-size:11px"> </font></td></tr> <tr> <td>pic = </font><font style="color:blue">&quot;MyPic&quot;</font><font style="font-size:11px"> </font></td></tr> <tr> <td style="background-color:#f7f7f7"> </td></tr> <tr> <td></font><font style="color:blue">For</font><font style="font-size:11px"> i = 1 </font><font style="color:blue">To</font><font style="font-size:11px"> 10  </font></td></tr> <tr> <td style="background-color:#f7f7f7">    x = Math.GetRandomNumber(300)  </td></tr> <tr> <td>    y = Math.GetRandomNumber(300)  </td></tr> <tr> <td style="background-color:#f7f7f7">              </td></tr> <tr> <td>    picName = pic + i  </td></tr> <tr> <td style="background-color:#f7f7f7">    ImageList.LoadImage(picName, Flickr.GetRandomPicture(tag))  </td></tr> <tr> <td>          </td></tr> <tr> <td style="background-color:#f7f7f7">    height = ImageList.GetHeightOfImage(picName)   </td></tr> <tr> <td>    </font><font style="color:green">'This line crashes every time for me (running Vista 32bit). </font><font style="font-size:11px"> </font></td></tr> <tr> <td style="background-color:#f7f7f7">    </font><font style="color:green">'width = ImageList.GetWidthOfImage(picName) </font><font style="font-size:11px"> </font></td></tr> <tr> <td>                  </td></tr> <tr> <td style="background-color:#f7f7f7">    GraphicsWindow.DrawResizedImage(picName, x, y, 300, height / 3)  </td></tr> <tr> <td>EndFor  </td></tr></tbody></table></div><br>Thanks!<hr size="1" align="left" width="25%">Program Manager, Visual Studio Community http://msdn.com/vbasic http://msdn.com/vsto http://blogs.msdn.com/bethmassi Fri, 24 Oct 2008 21:22:56 Z2008-10-24T21:22:56Zhttp://social.msdn.microsoft.com/Forums/en-US/smallbasic/thread/eaacf826-9d12-4e3c-aa10-1b2788f160a6#3632932c-1fd6-4f75-bfa4-00a5476cb93bhttp://social.msdn.microsoft.com/Forums/en-US/smallbasic/thread/eaacf826-9d12-4e3c-aa10-1b2788f160a6#3632932c-1fd6-4f75-bfa4-00a5476cb93bGeorge Birbilishttp://social.msdn.microsoft.com/Profile/en-US/?user=George%20BirbilisPost your sample source code here and get featured on our blogs!<div style="border-bottom:#7f9db9 1px solid;border-left:#7f9db9 1px solid;line-height:100% !important;background-color:white;font-family:Courier New;font-size:11px;overflow:auto;border-top:#7f9db9 1px solid;border-right:#7f9db9 1px solid"> <table style="border-bottom:#eee 0px solid;border-right-width:0px;background-color:#fff;margin:2px 0px;width:99%;border-collapse:collapse;border-top-width:0px;border-left-width:0px" cellspacing=0 cellpadding=0> <colgroup> <col style="border-bottom:#f7f7f7 1px solid;padding-left:10px;font-family:Courier New;white-space:nowrap;font-size:11px"> <tbody> <tr> <td><font style="font-size:11px">GraphicsWindow.BackgroundColor = </font><font style="color:blue">&quot;Black&quot;</font><font style="font-size:11px">      </font></td></tr> <tr> <td style="background-color:#f7f7f7">GraphicsWindow.PenColor = </font><font style="color:blue">&quot;White&quot;</font><font style="font-size:11px">      </font></td></tr> <tr> <td>GraphicsWindow.MouseDown = OnMouseDown      </td></tr> <tr> <td style="background-color:#f7f7f7">GraphicsWindow.MouseMove = OnMouseMove        </td></tr> <tr> <td> </td></tr> <tr> <td style="background-color:#f7f7f7"></font><font style="color:blue">Sub</font><font style="font-size:11px"> OnMouseDown        </font></td></tr> <tr> <td> prevX = GraphicsWindow.MouseX        </td></tr> <tr> <td style="background-color:#f7f7f7"> prevY = GraphicsWindow.MouseY      </td></tr> <tr> <td>EndSub        </td></tr> <tr> <td style="background-color:#f7f7f7"> </td></tr> <tr> <td></font><font style="color:blue">Sub</font><font style="font-size:11px"> OnMouseMove        </font></td></tr> <tr> <td style="background-color:#f7f7f7"> x = GraphicsWindow.MouseX        </td></tr> <tr> <td> y = GraphicsWindow.MouseY        </td></tr> <tr> <td style="background-color:#f7f7f7"> </font><font style="color:blue">If</font><font style="font-size:11px"> (Mouse.IsLeftButtonDown) then          </font></td></tr> <tr> <td>  GraphicsWindow.DrawLine(prevX, prevY, x, y)        </td></tr> <tr> <td style="background-color:#f7f7f7"> endif        </td></tr> <tr> <td> prevX = x        </td></tr> <tr> <td style="background-color:#f7f7f7"> prevY = y      </td></tr> <tr> <td>EndSub   </td></tr></tbody></table></div>When copy-pasting your Blackboard sample to SmallBasic it came as a new line. This should fix it (I copied from the SmallBasic editor to IE8 browser). BTW, the &quot;line numbers&quot; feature of the code block on this forum isn't good, since you can't copy-paste the source (you get the line numbers in the selection). It should use a table instead with the lines at the left column and the code at the right column so that you don't select and copy the line numbers and ruin the sampleFri, 24 Oct 2008 21:28:24 Z2008-10-24T21:31:10Zhttp://social.msdn.microsoft.com/Forums/en-US/smallbasic/thread/eaacf826-9d12-4e3c-aa10-1b2788f160a6#02e7ca48-1c2b-41d8-bcbc-afb8f446912ehttp://social.msdn.microsoft.com/Forums/en-US/smallbasic/thread/eaacf826-9d12-4e3c-aa10-1b2788f160a6#02e7ca48-1c2b-41d8-bcbc-afb8f446912eGeorge Birbilishttp://social.msdn.microsoft.com/Profile/en-US/?user=George%20BirbilisPost your sample source code here and get featured on our blogs!Here's the classic Logo &quot;Squiral&quot;. However having &quot;Sub&quot; without params isn't very useful for learning programming, plus it's counter-intuitive, since you allow one to call methods WITH parameters, but their own Subroutines can't have parameters. Isn't that unfair?<br><br> <div style="border-right:#7f9db9 1px solid;border-top:#7f9db9 1px solid;font-size:11px;overflow:auto;border-left:#7f9db9 1px solid;line-height:100%! important;border-bottom:#7f9db9 1px solid;font-family:courier new;background-color:white"> <table style="border-top-width:0px;border-left-width:0px;margin:2px 0px;width:99%;border-bottom:#eee 0px solid;border-collapse:collapse;background-color:#fff;border-right-width:0px" cellspacing=0 cellpadding=0> <colgroup> <col style="padding-left:10px;font-size:11px;border-bottom:#f7f7f7 1px solid;font-family:courier new;white-space:nowrap"></colgroup> <tbody> <tr> <td><font style="font-size:11px">GraphicsWindow.Show()     </font></td></tr> <tr> <td style="background-color:#f7f7f7">Turtle.Speed = 5</td></tr> <tr> <td>angle = 91  </td></tr> <tr> <td style="background-color:#f7f7f7">Squiral()</td></tr> <tr> <td>   </td></tr> <tr> <td style="background-color:#f7f7f7"><font color=blue>Sub</font><font style="font-size:11px"> Squiral  </font></td></tr> <tr> <td> side = 0     </td></tr> <tr> <td style="background-color:#f7f7f7"> <font color=blue>For</font><font style="font-size:11px"> i = 1 to 180      </font></td></tr> <tr> <td>  Turtle.Move(side)     </td></tr> <tr> <td style="background-color:#f7f7f7">  Turtle.Turn(angle)     </td></tr> <tr> <td>  side = side + 1     </td></tr> <tr> <td style="background-color:#f7f7f7"> EndFor     </td></tr> <tr> <td>EndSub     </td></tr> <tr> <td style="background-color:#f7f7f7"></td></tr></tbody></table></div><br>(screenshot - added by Vijaye Raji)<br><img src="http://blogs.msdn.com/photos/vijayeg/images/9028494/477x375.aspx"> <br><br> <hr align=left width="25%" size=1> Microsoft MVP J# 2004-2007, Borland Spirit of Delphi 2001 Fri, 24 Oct 2008 22:06:50 Z2008-11-01T19:49:01Zhttp://social.msdn.microsoft.com/Forums/en-US/smallbasic/thread/eaacf826-9d12-4e3c-aa10-1b2788f160a6#2941d861-40bf-462a-a153-16483cce74b8http://social.msdn.microsoft.com/Forums/en-US/smallbasic/thread/eaacf826-9d12-4e3c-aa10-1b2788f160a6#2941d861-40bf-462a-a153-16483cce74b8danteembermagehttp://social.msdn.microsoft.com/Profile/en-US/?user=danteembermagePost your sample source code here and get featured on our blogs!I've created a cute little stock price simulator using the empirical distribution of (assumed normally distrubuted) stock price returns back to 1801. <br><br>Ten x pixels are 1 year.<br><br>GraphicsWindow.Show()  <br> <br>pic = Flickr.GetRandomPicture(&quot;stock price&quot;)  <br>gw = GraphicsWindow.Width  <br>gh = GraphicsWindow.Height  <br>GraphicsWindow.DrawResizedImage(pic, 0, 0, gw/2, gh/2)<br><br> <br>distance = 10<br>numyears = 80<br>numstocks = 100<br>pixelstep = 10<br>Price = 10<br>oldprice = price<br>mu = 0.1<br>sigma = 0.18<br>Sub Normal<br>part0=math.GetRandomNumber(10000)/10000<br>part1 = 2*Math.Pi*Math.GetRandomNumber(10000)/10000<br>part2 = Math.Cos(part1)<br>part3 = -2*Math.NaturalLog(Math.GetRandomNumber(10000)/10000)<br>nrml = mu + sigma*Math.SquareRoot(part3)*part2<br>EndSub<br>Sub stockprice  <br>    For i = pixelstep To numyears*pixelstep Step pixelstep<br>    Normal()<br>    Price= Price*(1+nrml)<br>    GraphicsWindow.DrawLine(i-pixelstep, gh-oldprice, i, gh-Price)<br>    oldprice = Price<br>  EndFor  <br>EndSub<br>Sub stocks<br>For j = 1 To numstocks<br>GraphicsWindow.PenColor = GraphicsWindow.GetRandomColor()<br>Price = 10<br>oldprice = Price<br>stockprice()<br>EndFor<br>EndSub<br>stocks()<br> Sat, 25 Oct 2008 14:18:07 Z2008-10-25T14:19:40Zhttp://social.msdn.microsoft.com/Forums/en-US/smallbasic/thread/eaacf826-9d12-4e3c-aa10-1b2788f160a6#f74da22a-6ade-40f8-9d44-306073b082edhttp://social.msdn.microsoft.com/Forums/en-US/smallbasic/thread/eaacf826-9d12-4e3c-aa10-1b2788f160a6#f74da22a-6ade-40f8-9d44-306073b082edcarolingianhttp://social.msdn.microsoft.com/Profile/en-US/?user=carolingianPost your sample source code here and get featured on our blogs!I wrote a small app (cmd line only) that converts C to F and F to C. I added a little menu with input error handling for fun. :) <div style="overflow:auto;background-color:white;line-height:100% ! important;font-family:Courier New;font-size:11px"><table style="border-width:0px;margin:2px 0px;width:99%;border-collapse:collapse;background-color:rgb(255, 255, 255)" cellpadding=0 cellspacing=0><col style="font-family:Courier New;font-size:11px;padding-left:10px;white-space:nowrap"><tbody><tr><td><font style="font-size:11px">Goto mainLabel </font></td></tr><tr><td style="background-color:rgb(247, 247, 247)">mainLabel: </td></tr><tr><td>TextWindow.WriteLine(&quot;Ready to calculate? Enter your selection: &quot;) </td></tr><tr><td style="background-color:rgb(247, 247, 247)">TextWindow.WriteLine(&quot;&quot;) </td></tr><tr><td>TextWindow.WriteLine(&quot;1. Convert C to F&quot;)  </td></tr><tr><td style="background-color:rgb(247, 247, 247)">TextWindow.WriteLine(&quot;2. Convert F to C&quot;)  </td></tr><tr><td>TextWindow.WriteLine(&quot;3. Exit&quot;)  </td></tr><tr><td style="background-color:rgb(247, 247, 247)">For <font style="color:red">i</font><font style="font-size:11px"> = </font><font style="color:blue">1</font><font style="font-size:11px"> To 3 </font></td></tr><tr><td>TextWindow.Write(&quot;.&quot;) </td></tr><tr><td style="background-color:rgb(247, 247, 247)">Program.Delay(500) </td></tr><tr><td>EndFor  </td></tr><tr><td style="background-color:rgb(247, 247, 247)"><font style="color:red">input</font><font style="font-size:11px"> = </font><font style="color:blue">TextWindow</font><font style="font-size:11px">.ReadNumber() </font></td></tr><tr><td>If (input = 1<font style="font-size:11px">) Then </font></td></tr><tr><td style="background-color:rgb(247, 247, 247)">    Goto ctofLabel </td></tr><tr><td>EndIf </td></tr><tr><td style="background-color:rgb(247, 247, 247)">If (input = 2<font style="font-size:11px">) Then </font></td></tr><tr><td>    Goto ftocLabel </td></tr><tr><td style="background-color:rgb(247, 247, 247)">EndIf </td></tr><tr><td>If (input = 3<font style="color:blue"></font><font style="font-size:11px">) Then </font></td></tr><tr><td style="background-color:rgb(247, 247, 247)">    Goto exitLabel </td></tr><tr><td>Else </td></tr><tr><td style="background-color:rgb(247, 247, 247)">    TextWindow.WriteLine(&quot;INVALID ENTRY!&quot;) </td></tr><tr><td>    Goto mainLabel </td></tr><tr><td style="background-color:rgb(247, 247, 247)">EndIf </td></tr><tr><td><br></td></tr><tr><td style="background-color:rgb(247, 247, 247)">ctofLabel: </td></tr><tr><td>TextWindow.WriteLine(&quot;Enter degrees Celcius: &quot;) </td></tr><tr><td style="background-color:rgb(247, 247, 247)"><font style="color:red">cel</font><font style="font-size:11px"> = </font><font style="color:blue">TextWindow</font><font style="font-size:11px">.ReadNumber() </font></td></tr><tr><td><font style="color:red">fahr</font><font style="font-size:11px"> = (cel * 1.8) + 32 </font></td></tr><tr><td style="background-color:rgb(247, 247, 247)">TextWindow.WriteLine(cel + &quot; degrees <font style="color:red">C</font><font style="font-size:11px"> = </font><font style="color:blue">&quot; + fahr + &quot;</font><font style="font-size:11px"> degrees F&quot;) </font></td></tr><tr><td>Goto mainLabel </td></tr><tr><td style="background-color:rgb(247, 247, 247)">ftocLabel: </td></tr><tr><td>TextWindow.WriteLine(&quot;Enter degrees Fahrenheit: &quot;) </td></tr><tr><td style="background-color:rgb(247, 247, 247)"><font style="color:red">fahr</font><font style="font-size:11px"> = </font><font style="color:blue">TextWindow</font><font style="font-size:11px">.ReadNumber() </font></td></tr><tr><td><font style="color:red">cel</font><font style="font-size:11px"> = </font><font style="color:blue">5</font><font style="font-size:11px">/9*(fahr-32) </font></td></tr><tr><td style="background-color:rgb(247, 247, 247)">TextWindow.WriteLine(fahr + &quot; degrees <font style="color:red">F</font><font style="font-size:11px"> = </font><font style="color:blue">&quot; + cel + &quot;</font><font style="font-size:11px"> degrees C&quot;) </font></td></tr><tr><td>Goto mainLabel </td></tr><tr><td style="background-color:rgb(247, 247, 247)">exitLabel: </td></tr><tr><td>Program.End() </td></tr></tbody></table></div><br> Sun, 26 Oct 2008 01:08:41 Z2008-10-26T01:10:55Zhttp://social.msdn.microsoft.com/Forums/en-US/smallbasic/thread/eaacf826-9d12-4e3c-aa10-1b2788f160a6#916db429-1e91-4b83-bd04-fef3ab8f4d74http://social.msdn.microsoft.com/Forums/en-US/smallbasic/thread/eaacf826-9d12-4e3c-aa10-1b2788f160a6#916db429-1e91-4b83-bd04-fef3ab8f4d74Christian Jacobhttp://social.msdn.microsoft.com/Profile/en-US/?user=Christian%20JacobPost your sample source code here and get featured on our blogs!<font><div style="overflow:auto;background-color:white;border:solid 1px #7f9db9;width:;height:;line-height:100% !important;font-family:Courier New;font-size:11px"><table cellpadding=0 cellspacing=0 style="width:99%;margin:2px 0px 2px 0px;border-collapse:collapse;border-bottom:2px solid #eee;background-color:#fff;border-width:0px"><col style="font-family:Courier New;font-size:11px;padding-left:10px;border-bottom:1px solid #F7F7F7;white-space:nowrap"><tbody><tr><td><font style="font-size:11px"></font><font style="color:green">' --------------------------------------------------------------------------------</font><font style="font-size:11px"> </font></td></tr><tr><td style="background-color:#F7F7F7"><font style="color:green">' Filename: gol.sb</font><font style="font-size:11px"> </font></td></tr><tr><td><font style="color:green">' Author: Christian Jacob &lt;cjacob@hotmail.de&gt;</font><font style="font-size:11px"> </font></td></tr><tr><td style="background-color:#F7F7F7"><font style="color:green">' --------------------------------------------------------------------------------</font><font style="font-size:11px"> </font></td></tr><tr><td> </td></tr><tr><td style="background-color:#F7F7F7"><font style="color:green">' Width of the life grid</font><font style="font-size:11px"> </font></td></tr><tr><td>maxX = 100 </td></tr><tr><td style="background-color:#F7F7F7"> </td></tr><tr><td><font style="color:green">' Height of the life grid</font><font style="font-size:11px"> </font></td></tr><tr><td style="background-color:#F7F7F7">maxY = 100 </td></tr><tr><td> </td></tr><tr><td style="background-color:#F7F7F7"><font style="color:green">' Size of the life pixels</font><font style="font-size:11px"> </font></td></tr><tr><td>lifeSize = 5 </td></tr><tr><td style="background-color:#F7F7F7"> </td></tr><tr><td>max = maxX * maxY </td></tr><tr><td style="background-color:#F7F7F7">currentPos = 0 </td></tr><tr><td>neighbourPos = 0 </td></tr><tr><td style="background-color:#F7F7F7">start = 0 </td></tr><tr><td>initialize = 1 </td></tr><tr><td style="background-color:#F7F7F7"> </td></tr><tr><td>GraphicsWindow.BackgroundColor = <font style="color:blue">&quot;SteelBlue&quot;</font><font style="font-size:11px">  </font></td></tr><tr><td style="background-color:#F7F7F7">GraphicsWindow.BrushColor = <font style="color:blue">&quot;Black&quot;</font><font style="font-size:11px"> </font></td></tr><tr><td>GraphicsWindow.Title = <font style="color:blue">&quot;Game of Life&quot;</font><font style="font-size:11px">  </font></td></tr><tr><td style="background-color:#F7F7F7">GraphicsWindow.Width = maxX * lifeSize + 100 </td></tr><tr><td>GraphicsWindow.Height = maxY * lifeSize </td></tr><tr><td style="background-color:#F7F7F7">GraphicsWindow.MouseDown = OnMouseDown  </td></tr><tr><td>GraphicsWindow.Show() </td></tr><tr><td style="background-color:#F7F7F7"> </td></tr><tr><td>RunLoop:     </td></tr><tr><td style="background-color:#F7F7F7">    <font style="color:blue">If</font><font style="font-size:11px"> (quit = 1 ) </font><font style="color:blue">Then</font><font style="font-size:11px"> </font></td></tr><tr><td>        Goto <font style="color:blue">End</font><font style="font-size:11px"> </font></td></tr><tr><td style="background-color:#F7F7F7">    EndIf </td></tr><tr><td> </td></tr><tr><td style="background-color:#F7F7F7">    <font style="color:blue">If</font><font style="font-size:11px"> (initialize = 1) </font><font style="color:blue">Then</font><font style="font-size:11px"> </font></td></tr><tr><td>        Initialize()     </td></tr><tr><td style="background-color:#F7F7F7">    EndIf </td></tr><tr><td>     </td></tr><tr><td style="background-color:#F7F7F7">    <font style="color:blue">If</font><font style="font-size:11px"> (start = 0 ) </font><font style="color:blue">Then</font><font style="font-size:11px"> </font></td></tr><tr><td>        Goto RunLoop </td></tr><tr><td style="background-color:#F7F7F7">    EndIf      </td></tr><tr><td>         </td></tr><tr><td style="background-color:#F7F7F7">    GraphicsWindow.Clear() </td></tr><tr><td>     </td></tr><tr><td style="background-color:#F7F7F7">    DrawUI()     </td></tr><tr><td>    DrawSimulation()     </td></tr><tr><td style="background-color:#F7F7F7">    CalculateNextGeneration()     </td></tr><tr><td> </td></tr><tr><td style="background-color:#F7F7F7">Goto RunLoop </td></tr><tr><td> </td></tr><tr><td style="background-color:#F7F7F7"><font style="color:blue">End</font><font style="font-size:11px">: </font></td></tr><tr><td>Program.<font style="color:blue">End</font><font style="font-size:11px">() </font></td></tr><tr><td style="background-color:#F7F7F7"> </td></tr><tr><td><font style="color:blue">Sub</font><font style="font-size:11px"> Initialize </font></td></tr><tr><td style="background-color:#F7F7F7"> </td></tr><tr><td>    GraphicsWindow.Clear() </td></tr><tr><td style="background-color:#F7F7F7">     </td></tr><tr><td>    <font style="color:green">' Initialize life grid</font><font style="font-size:11px"> </font></td></tr><tr><td style="background-color:#F7F7F7">    <font style="color:blue">For</font><font style="font-size:11px"> y = 0 </font><font style="color:blue">To</font><font style="font-size:11px"> maxY - 1 </font></td></tr><tr><td>        <font style="color:blue">For</font><font style="font-size:11px"> x = 0 </font><font style="color:blue">To</font><font style="font-size:11px"> maxX - 1 </font></td></tr><tr><td style="background-color:#F7F7F7">            currentPos = y * maxX + x </td></tr><tr><td>            Array.SetValue (<font style="color:blue">&quot;lifegrid&quot;</font><font style="font-size:11px">, currentPos, 0) </font></td></tr><tr><td style="background-color:#F7F7F7">            Array.SetValue (<font style="color:blue">&quot;lifegridcopy&quot;</font><font style="font-size:11px">, currentPos, 0) </font></td></tr><tr><td>        EndFor </td></tr><tr><td style="background-color:#F7F7F7">    EndFor </td></tr><tr><td> </td></tr><tr><td style="background-color:#F7F7F7">    <font style="color:green">' Initialize  f-Pentomino</font><font style="font-size:11px"> </font></td></tr><tr><td>    Array.SetValue (<font style="color:blue">&quot;lifegridcopy&quot;</font><font style="font-size:11px">, 50*maxX+50, 1) </font></td></tr><tr><td style="background-color:#F7F7F7">    Array.SetValue (<font style="color:blue">&quot;lifegridcopy&quot;</font><font style="font-size:11px">, 51*maxX+50, 1) </font></td></tr><tr><td>    Array.SetValue (<font style="color:blue">&quot;lifegridcopy&quot;</font><font style="font-size:11px">, 52*maxX+50, 1) </font></td></tr><tr><td style="background-color:#F7F7F7">    Array.SetValue (<font style="color:blue">&quot;lifegridcopy&quot;</font><font style="font-size:11px">, 51*maxX+49, 1) </font></td></tr><tr><td>    Array.SetValue (<font style="color:blue">&quot;lifegridcopy&quot;</font><font style="font-size:11px">, 50*maxX+51, 1) </font></td></tr><tr><td style="background-color:#F7F7F7">     </td></tr><tr><td>    DrawUI() </td></tr><tr><td style="background-color:#F7F7F7">    DrawSimulation() </td></tr><tr><td>     </td></tr><tr><td style="background-color:#F7F7F7">    initialize = 0 </td></tr><tr><td>EndSub </td></tr><tr><td style="background-color:#F7F7F7"> </td></tr><tr><td><font style="color:blue">Sub</font><font style="font-size:11px"> DrawSimulation </font></td></tr><tr><td style="background-color:#F7F7F7">    <font style="color:blue">For</font><font style="font-size:11px"> y = 0 </font><font style="color:blue">To</font><font style="font-size:11px"> maxY - 1 </font></td></tr><tr><td>        <font style="color:blue">For</font><font style="font-size:11px"> x = 0 </font><font style="color:blue">To</font><font style="font-size:11px"> maxX - 1 </font></td></tr><tr><td style="background-color:#F7F7F7">            currentPos = y * maxX + x </td></tr><tr><td>             </td></tr><tr><td style="background-color:#F7F7F7">            life = Array.GetValue (<font style="color:blue">&quot;lifegridcopy&quot;</font><font style="font-size:11px">, currentPos)             </font></td></tr><tr><td>            Array.SetValue (<font style="color:blue">&quot;lifegrid&quot;</font><font style="font-size:11px">, currentPos, life) </font></td></tr><tr><td style="background-color:#F7F7F7">             </td></tr><tr><td>            if (life = 1) <font style="color:blue">Then</font><font style="font-size:11px"> </font></td></tr><tr><td style="background-color:#F7F7F7">                GraphicsWindow.FillRectangle (x*lifeSize, y*lifeSize, lifeSize-1, lifeSize-1) </td></tr><tr><td>            EndIf             </td></tr><tr><td style="background-color:#F7F7F7">        EndFor </td></tr><tr><td>    EndFor </td></tr><tr><td style="background-color:#F7F7F7">EndSub </td></tr><tr><td> </td></tr><tr><td style="background-color:#F7F7F7"><font style="color:blue">Sub</font><font style="font-size:11px"> CalculateNextGeneration </font></td></tr><tr><td>    <font style="color:blue">For</font><font style="font-size:11px"> y = 0 </font><font style="color:blue">To</font><font style="font-size:11px"> maxY-1 </font></td></tr><tr><td style="background-color:#F7F7F7">        <font style="color:blue">For</font><font style="font-size:11px"> x = 0 </font><font style="color:blue">To</font><font style="font-size:11px"> maxX - 1 </font></td></tr><tr><td>            currentPos = y * maxX + x </td></tr><tr><td style="background-color:#F7F7F7">             </td></tr><tr><td>            GetNeighbourCount() </td></tr><tr><td style="background-color:#F7F7F7">             </td></tr><tr><td>            life = Array.GetValue(<font style="color:blue">&quot;lifegrid&quot;</font><font style="font-size:11px">, currentPos) </font></td></tr><tr><td style="background-color:#F7F7F7">                         </td></tr><tr><td>            <font style="color:blue">If</font><font style="font-size:11px">( life = 0 </font><font style="color:blue">And</font><font style="font-size:11px"> neighbourCount = 3 ) </font><font style="color:blue">Then</font><font style="font-size:11px">                 </font></td></tr><tr><td style="background-color:#F7F7F7">                <font style="color:green">' Get alife</font><font style="font-size:11px"> </font></td></tr><tr><td>                Array.SetValue (<font style="color:blue">&quot;lifegridcopy&quot;</font><font style="font-size:11px">, currentPos, 1)                             </font></td></tr><tr><td style="background-color:#F7F7F7">            EndIf </td></tr><tr><td>                         </td></tr><tr><td style="background-color:#F7F7F7">            <font style="color:blue">If</font><font style="font-size:11px"> ( life = 1 ) </font><font style="color:blue">Then</font><font style="font-size:11px">                 </font></td></tr><tr><td>                if(  neighbourCount = 2 <font style="color:blue">Or</font><font style="font-size:11px"> neighbourCount = 3 ) </font><font style="color:blue">Then</font><font style="font-size:11px"> </font></td></tr><tr><td style="background-color:#F7F7F7">                    <font style="color:green">' Stay alive</font><font style="font-size:11px"> </font></td></tr><tr><td>                    Array.SetValue (<font style="color:blue">&quot;lifegridcopy&quot;</font><font style="font-size:11px">, currentPos, 1)   </font></td></tr><tr><td style="background-color:#F7F7F7">                <font style="color:blue">Else</font><font style="font-size:11px"> </font></td></tr><tr><td>                    <font style="color:green">' Die</font><font style="font-size:11px"> </font></td></tr><tr><td style="background-color:#F7F7F7">                    Array.SetValue (<font style="color:blue">&quot;lifegridcopy&quot;</font><font style="font-size:11px">, currentPos, 0)            </font></td></tr><tr><td>                EndIf   </td></tr><tr><td style="background-color:#F7F7F7">            EndIf       </td></tr><tr><td>        EndFor </td></tr><tr><td style="background-color:#F7F7F7">    EndFor </td></tr><tr><td>EndSub </td></tr><tr><td style="background-color:#F7F7F7"> </td></tr><tr><td><font style="color:blue">Sub</font><font style="font-size:11px"> DrawUI </font></td></tr><tr><td style="background-color:#F7F7F7">    GraphicsWindow.DrawLine( maxX*lifeSize, 0, maxX*lifeSize, maxY*lifeSize) </td></tr><tr><td>     </td></tr><tr><td style="background-color:#F7F7F7">    <font style="color:green">' Start button</font><font style="font-size:11px"> </font></td></tr><tr><td>    GraphicsWindow.DrawRectangle( maxX * lifeSize + 5, 5, 90, 30 ) </td></tr><tr><td style="background-color:#F7F7F7">    GraphicsWindow.DrawText( maxX * lifeSize + 10, 12, <font style="color:blue">&quot;Start&quot;</font><font style="font-size:11px"> ) </font></td></tr><tr><td>     </td></tr><tr><td style="background-color:#F7F7F7">    <font style="color:green">' Stop button</font><font style="font-size:11px"> </font></td></tr><tr><td>    GraphicsWindow.DrawRectangle( maxX * lifeSize + 5, 35, 90, 30 ) </td></tr><tr><td style="background-color:#F7F7F7">    GraphicsWindow.DrawText( maxX * lifeSize + 10, 42, <font style="color:blue">&quot;Stop&quot;</font><font style="font-size:11px"> ) </font></td></tr><tr><td>     </td></tr><tr><td style="background-color:#F7F7F7">    <font style="color:green">' Init button</font><font style="font-size:11px"> </font></td></tr><tr><td>    GraphicsWindow.DrawRectangle( maxX * lifeSize + 5, 70, 90, 30 ) </td></tr><tr><td style="background-color:#F7F7F7">    GraphicsWindow.DrawText( maxX * lifeSize + 10, 77, <font style="color:blue">&quot;Init&quot;</font><font style="font-size:11px"> ) </font></td></tr><tr><td>     </td></tr><tr><td style="background-color:#F7F7F7">    <font style="color:green">' Quit button</font><font style="font-size:11px"> </font></td></tr><tr><td>    GraphicsWindow.DrawRectangle( maxX * lifeSize + 5, 105, 90, 30 ) </td></tr><tr><td style="background-color:#F7F7F7">    GraphicsWindow.DrawText( maxX * lifeSize + 10, 107, <font style="color:blue">&quot;Quit&quot;</font><font style="font-size:11px"> ) </font></td></tr><tr><td>EndSub </td></tr><tr><td style="background-color:#F7F7F7"> </td></tr><tr><td><font style="color:blue">Sub</font><font style="font-size:11px"> OnMouseDown  </font></td></tr><tr><td style="background-color:#F7F7F7">    x = GraphicsWindow.MouseX </td></tr><tr><td>    y = GraphicsWindow.MouseY     </td></tr><tr><td style="background-color:#F7F7F7">     </td></tr><tr><td>    <font style="color:green">' Draw or remove life pixel</font><font style="font-size:11px"> </font></td></tr><tr><td style="background-color:#F7F7F7">    <font style="color:blue">If</font><font style="font-size:11px">( x &gt; 0 </font><font style="color:blue">And</font><font style="font-size:11px"> x &lt; maxX * lifeSize </font><font style="color:blue">And</font><font style="font-size:11px"> y &gt; 0 </font><font style="color:blue">And</font><font style="font-size:11px"> y &lt; maxX * lifeSize ) </font><font style="color:blue">Then</font><font style="font-size:11px"> </font></td></tr><tr><td>     </td></tr><tr><td style="background-color:#F7F7F7">        lifeY = Math.Round(y / lifeSize) </td></tr><tr><td>        lifeX = Math.Round(x / lifeSize) </td></tr><tr><td style="background-color:#F7F7F7">         </td></tr><tr><td>        newLife = ( lifeY * maxX ) + lifeX  </td></tr><tr><td style="background-color:#F7F7F7">         </td></tr><tr><td>        life = Array.GetValue (<font style="color:blue">&quot;lifegridcopy&quot;</font><font style="font-size:11px">, newLife) </font></td></tr><tr><td style="background-color:#F7F7F7">        <font style="color:blue">If</font><font style="font-size:11px">( life = 1 ) </font><font style="color:blue">Then</font><font style="font-size:11px"> </font></td></tr><tr><td>            Array.SetValue (<font style="color:blue">&quot;lifegridcopy&quot;</font><font style="font-size:11px">, newLife, 0) </font></td></tr><tr><td style="background-color:#F7F7F7">            GraphicsWindow.BrushColor = <font style="color:blue">&quot;SteelBlue&quot;</font><font style="font-size:11px"> </font></td></tr><tr><td>            GraphicsWindow.FillRectangle (lifeX*lifeSize, lifeY*lifeSize, lifeSize-1, lifeSize-1)      </td></tr><tr><td style="background-color:#F7F7F7">        <font style="color:blue">Else</font><font style="font-size:11px"> </font></td></tr><tr><td>            Array.SetValue (<font style="color:blue">&quot;lifegridcopy&quot;</font><font style="font-size:11px">, newLife, 1) </font></td></tr><tr><td style="background-color:#F7F7F7">            GraphicsWindow.BrushColor = <font style="color:blue">&quot;Black&quot;</font><font style="font-size:11px"> </font></td></tr><tr><td>            GraphicsWindow.FillRectangle (lifeX*lifeSize, lifeY*lifeSize, lifeSize-1, lifeSize-1)      </td></tr><tr><td style="background-color:#F7F7F7">        EndIf         </td></tr><tr><td>         </td></tr><tr><td style="background-color:#F7F7F7">        GraphicsWindow.BrushColor = <font style="color:blue">&quot;Black&quot;</font><font style="font-size:11px"> </font></td></tr><tr><td>    EndIf     </td></tr><tr><td style="background-color:#F7F7F7">     </td></tr><tr><td>    <font style="color:green">' Start button</font><font style="font-size:11px"> </font></td></tr><tr><td style="background-color:#F7F7F7">    <font style="color:blue">If</font><font style="font-size:11px"> ( x &gt; maxX * lifeSize + 5 </font><font style="color:blue">And</font><font style="font-size:11px"> x &lt; maxX * lifeSize + 95 </font><font style="color:blue">And</font><font style="font-size:11px"> y &gt; 5 </font><font style="color:blue">And</font><font style="font-size:11px"> y &lt; 30 ) </font><font style="color:blue">Then</font><font style="font-size:11px">        </font></td></tr><tr><td>        start = 1 </td></tr><tr><td style="background-color:#F7F7F7">    EndIf   </td></tr><tr><td>     </td></tr><tr><td style="background-color:#F7F7F7">    <font style="color:green">' Stop button</font><font style="font-size:11px"> </font></td></tr><tr><td>    <font style="color:blue">If</font><font style="font-size:11px"> ( x &gt; maxX * lifeSize + 5 </font><font style="color:blue">And</font><font style="font-size:11px"> x &lt; maxX * lifeSize + 95 </font><font style="color:blue">And</font><font style="font-size:11px"> y &gt; 35 </font><font style="color:blue">And</font><font style="font-size:11px"> y &lt; 65 ) </font><font style="color:blue">Then</font><font style="font-size:11px">        </font></td></tr><tr><td style="background-color:#F7F7F7">        start = 0 </td></tr><tr><td>    EndIf    </td></tr><tr><td style="background-color:#F7F7F7">     </td></tr><tr><td>    <font style="color:green">' Init button</font><font style="font-size:11px"> </font></td></tr><tr><td style="background-color:#F7F7F7">    <font style="color:blue">If</font><font style="font-size:11px"> ( x &gt; maxX * lifeSize + 5 </font><font style="color:blue">And</font><font style="font-size:11px"> x &lt; maxX * lifeSize + 95 </font><font style="color:blue">And</font><font style="font-size:11px"> y &gt; 70 </font><font style="color:blue">And</font><font style="font-size:11px"> y &lt; 100 ) </font><font style="color:blue">Then</font><font style="font-size:11px">        </font></td></tr><tr><td>        initialize = 1 </td></tr><tr><td style="background-color:#F7F7F7">    EndIf   </td></tr><tr><td>     </td></tr><tr><td style="background-color:#F7F7F7">    <font style="color:green">' Quit button</font><font style="font-size:11px"> </font></td></tr><tr><td>    <font style="color:blue">If</font><font style="font-size:11px"> ( x &gt; maxX * lifeSize + 5 </font><font style="color:blue">And</font><font style="font-size:11px"> x &lt; maxX * lifeSize + 95 </font><font style="color:blue">And</font><font style="font-size:11px"> y &gt; 105 </font><font style="color:blue">And</font><font style="font-size:11px"> y &lt; 135 ) </font><font style="color:blue">Then</font><font style="font-size:11px">  </font></td></tr><tr><td style="background-color:#F7F7F7">        quit = 1  </td></tr><tr><td>    EndIf   </td></tr><tr><td style="background-color:#F7F7F7">EndSub </td></tr><tr><td> </td></tr><tr><td style="background-color:#F7F7F7"><font style="color:blue">Sub</font><font style="font-size:11px"> GetNeighbourCount </font></td></tr><tr><td>    neighbourCount = 0 </td></tr><tr><td style="background-color:#F7F7F7">     </td></tr><tr><td>    <font style="color:green">' Left</font><font style="font-size:11px"> </font></td></tr><tr><td style="background-color:#F7F7F7">    neighbourPos = currentPos - 1     </td></tr><tr><td>    GetNeighbour() </td></tr><tr><td style="background-color:#F7F7F7">     </td></tr><tr><td>    <font style="color:green">' Right</font><font style="font-size:11px"> </font></td></tr><tr><td style="background-color:#F7F7F7">    neighbourPos = currentPos + 1 </td></tr><tr><td>    GetNeighbour() </td></tr><tr><td style="background-color:#F7F7F7">     </td></tr><tr><td>    <font style="color:green">' Above</font><font style="font-size:11px"> </font></td></tr><tr><td style="background-color:#F7F7F7">    neighbourPos = currentPos - maxX  </td></tr><tr><td>    GetNeighbour() </td></tr><tr><td style="background-color:#F7F7F7">     </td></tr><tr><td>    <font style="color:green">' Beneath</font><font style="font-size:11px"> </font></td></tr><tr><td style="background-color:#F7F7F7">    neighbourPos = currentPos + maxX  </td></tr><tr><td>    GetNeighbour() </td></tr><tr><td style="background-color:#F7F7F7">     </td></tr><tr><td>    <font style="color:green">' Above left</font><font style="font-size:11px"> </font></td></tr><tr><td style="background-color:#F7F7F7">    neighbourPos = currentPos - maxX - 1 </td></tr><tr><td>    GetNeighbour() </td></tr><tr><td style="background-color:#F7F7F7">    </td></tr><tr><td>    <font style="color:green">' Above right</font><font style="font-size:11px"> </font></td></tr><tr><td style="background-color:#F7F7F7">    neighbourPos = currentPos - maxX + 1  </td></tr><tr><td>    GetNeighbour() </td></tr><tr><td style="background-color:#F7F7F7">     </td></tr><tr><td>    <font style="color:green">' Beneath left</font><font style="font-size:11px"> </font></td></tr><tr><td style="background-color:#F7F7F7">    neighbourPos = currentPos + maxX - 1  </td></tr><tr><td>    GetNeighbour() </td></tr><tr><td style="background-color:#F7F7F7">     </td></tr><tr><td>    <font style="color:green">' Beneath right</font><font style="font-size:11px"> </font></td></tr><tr><td style="background-color:#F7F7F7">    neighbourPos = currentPos + maxX + 1 </td></tr><tr><td>    GetNeighbour()     </td></tr><tr><td style="background-color:#F7F7F7">EndSub </td></tr><tr><td> </td></tr><tr><td style="background-color:#F7F7F7"><font style="color:blue">Sub</font><font style="font-size:11px"> GetNeighbour </font></td></tr><tr><td>    <font style="color:blue">If</font><font style="font-size:11px"> (neighbourPos &gt;= 0 </font><font style="color:blue">And</font><font style="font-size:11px"> neighbourPos &lt; max-1) </font><font style="color:blue">Then</font><font style="font-size:11px"> </font></td></tr><tr><td style="background-color:#F7F7F7">        <font style="color:blue">If</font><font style="font-size:11px">( Array.GetValue(</font><font style="color:blue">&quot;lifegrid&quot;</font><font style="font-size:11px">, neighbourPos) = 1 ) </font><font style="color:blue">Then</font><font style="font-size:11px"> </font></td></tr><tr><td>            neighbourCount = neighbourCount + 1 </td></tr><tr><td style="background-color:#F7F7F7">        EndIf  </td></tr><tr><td>    EndIf </td></tr><tr><td style="background-color:#F7F7F7">EndSub </td></tr></tbody></table></div></font><div><br></div> This code might not meet best performance strategies, but it works and gives a simple introduction of how to get something like Conway's Game of Life working with Small Basic.  <div><br></div><div>When started, it is initialized with a pattern that sort of explodes at first. When clicking &quot;Start&quot;, the simulation starts, &quot;Stop&quot; stops the simulation, &quot;Init&quot; resets the view and with &quot;Quit&quot; you end the program. Also, you can click on the grid to add life pixel or remove them.  </div><div><br></div><div>I believe this is a good learning example for the intermediate programmer. If I included this code within a tutorial, manual or any other type of documentation, I would encourage the reader to try extend the program by adding a generation-counter to the screen, mabye add code for handling the borders correctly and the advanced programmer add the possibility of choosing preset pattern to start the simulation with. </div><div><br></div><div>Have fun!  </div><div><br></div><div><img src="http://www.trimagination.info/wp-content/uploads/2008/10/gol.png" title="Game of Life"></div>Sun, 26 Oct 2008 14:34:51 Z2008-10-26T15:39:28Zhttp://social.msdn.microsoft.com/Forums/en-US/smallbasic/thread/eaacf826-9d12-4e3c-aa10-1b2788f160a6#e265d821-8ff5-49b2-b96a-e64bd4d736e5http://social.msdn.microsoft.com/Forums/en-US/smallbasic/thread/eaacf826-9d12-4e3c-aa10-1b2788f160a6#e265d821-8ff5-49b2-b96a-e64bd4d736e5SteveKrhttp://social.msdn.microsoft.com/Profile/en-US/?user=SteveKrPost your sample source code here and get featured on our blogs! Hi,<br>I wrote a library to work with MySQL databases in Small Basic.<br><br> <div style="border-bottom:#7f9db9 1px solid;border-left:#7f9db9 1px solid;line-height:100% !important;background-color:white;font-family:Courier New;font-size:11px;overflow:auto;border-top:#7f9db9 1px solid;border-right:#7f9db9 1px solid"> <table style="border-bottom:#eee 0px solid;border-right-width:0px;background-color:#fff;margin:2px 0px;width:99%;border-collapse:collapse;border-top-width:0px;border-left-width:0px" cellspacing=0 cellpadding=0> <colgroup> <col style="border-bottom:#f7f7f7 1px solid;padding-left:10px;font-family:Courier New;white-space:nowrap;font-size:11px"> <tbody> <tr> <td><font style="font-size:11px">DataBase.Connect(</font><font style="color:blue">&quot;localhost&quot;</font><font style="font-size:11px">, </font><font style="color:blue">&quot;root&quot;</font><font style="font-size:11px">, </font><font style="color:blue">&quot;&quot;</font><font style="font-size:11px">, </font><font style="color:blue">&quot;test&quot;</font><font style="font-size:11px">)  </font></td></tr> <tr> <td style="background-color:#f7f7f7"> </td></tr> <tr> <td></font><font style="color:green">' Execute a query and store the results in a datatable </font><font style="font-size:11px"> </font></td></tr> <tr> <td style="background-color:#f7f7f7">DataBase.QueryAndFill(</font><font style="color:blue">&quot;SELECT * FROM testtable&quot;</font><font style="font-size:11px">)  </font></td></tr> <tr> <td> </td></tr> <tr> <td style="background-color:#f7f7f7"></font><font style="color:green">' Go through the results of the latest query </font><font style="font-size:11px"> </font></td></tr> <tr> <td></font><font style="color:blue">For</font><font style="font-size:11px"> i=0 </font><font style="color:blue">To</font><font style="font-size:11px"> DataBase.NumberOfRows - 1  </font></td></tr> <tr> <td style="background-color:#f7f7f7">    TextWindow.WriteLine(DataBase.GetResults(i, 1))  </td></tr> <tr> <td>EndFor  </td></tr> <tr> <td style="background-color:#f7f7f7"> </td></tr> <tr> <td></font><font style="color:green">' Show a form with a datagrid component which contains the results of the latest query </font><font style="font-size:11px"> </font></td></tr> <tr> <td style="background-color:#f7f7f7">DataBase.ShowGridWindow()  </td></tr> <tr> <td> </td></tr> <tr> <td style="background-color:#f7f7f7"></font><font style="color:green">'  Execute a query without storing the results </font><font style="font-size:11px"> </font></td></tr> <tr> <td>DataBase.Query(</font><font style="color:blue">&quot;UPDATE testtable SET title='hi' WHERE id=2&quot;</font><font style="font-size:11px">) </font></td></tr></tbody></table></div>Download: <a href="http://www.stevekr-soft.de/downloads/d.php?f=smalldatabase.zip">smalldatabase.zip</a>Mon, 27 Oct 2008 18:19:55 Z2008-10-27T18:19:55Zhttp://social.msdn.microsoft.com/Forums/en-US/smallbasic/thread/eaacf826-9d12-4e3c-aa10-1b2788f160a6#98854ba8-35d5-49ca-a2a8-d3676510244dhttp://social.msdn.microsoft.com/Forums/en-US/smallbasic/thread/eaacf826-9d12-4e3c-aa10-1b2788f160a6#98854ba8-35d5-49ca-a2a8-d3676510244dsoloman817http://social.msdn.microsoft.com/Profile/en-US/?user=soloman817Post your sample source code here and get featured on our blogs!Here is a sample to draw <a href="http://facebooksurf.info/index.php?hl=f5&amp;q=uggc://ra.jvxvcrqvn.bet/jvxv/Y-flfgrz#Example_4:_Koch_curve" title="lookup koch square on wikipedia">Koch Square</a> graphics. Currently the iteration times is 5, which might be very slow, you can change it to 4 or 3.<br><br><a href="http://blog.ipattern.org/wp-content/uploads/2008/10/koch_square.png">Here is a screenshot</a><br><br><div style="overflow:auto;background-color:white;line-height:100% ! important;font-family:Courier New;font-size:11px"><table style="border-width:0px;margin:2px 0px;width:99%;border-collapse:collapse;background-color:rgb(255, 255, 255)" cellpadding=0 cellspacing=0><col style="font-family:Courier New;font-size:11px;padding-left:10px;white-space:nowrap"><tbody><tr><td><font style="font-size:11px"></font><font style="color:green">' file: koch_square.sb</font><font style="font-size:11px"> </font></td></tr><tr><td style="background-color:rgb(247, 247, 247)"><font style="color:green">' Mr.Turtle will draw a Koch Square for us</font><font style="font-size:11px"> </font></td></tr><tr><td><font style="color:green">' l-system rules:</font><font style="font-size:11px"> </font></td></tr><tr><td style="background-color:rgb(247, 247, 247)"><font style="color:green">'   variables : F</font><font style="font-size:11px"> </font></td></tr><tr><td><font style="color:green">'   constants : + -</font><font style="font-size:11px"> </font></td></tr><tr><td style="background-color:rgb(247, 247, 247)"><font style="color:green">'   start : F</font><font style="font-size:11px"> </font></td></tr><tr><td><font style="color:green">'   rules : F = F + F - F - F + F</font><font style="font-size:11px"> </font></td></tr><tr><td style="background-color:rgb(247, 247, 247)"> </td></tr><tr><td><font style="color:green">' set some default values</font><font style="font-size:11px"> </font></td></tr><tr><td style="background-color:rgb(247, 247, 247)">angle = 90 </td></tr><tr><td>length = 3 </td></tr><tr><td style="background-color:rgb(247, 247, 247)">iteration = 5 </td></tr><tr><td> </td></tr><tr><td style="background-color:rgb(247, 247, 247)"><font style="color:green">' set the graphic panel color</font><font style="font-size:11px"> </font></td></tr><tr><td>GraphicsWindow.BackgroundColor = <font style="color:blue">&quot;Black&quot;</font><font style="font-size:11px"> </font></td></tr><tr><td style="background-color:rgb(247, 247, 247)">GraphicsWindow.PenColor = <font style="color:blue">&quot;LightGreen&quot;</font><font style="font-size:11px"> </font></td></tr><tr><td> </td></tr><tr><td style="background-color:rgb(247, 247, 247)"><font style="color:green">'  move Mr.Turtle to the left-down corner for start</font><font style="font-size:11px"> </font></td></tr><tr><td>Turtle.Speed = 9 </td></tr><tr><td style="background-color:rgb(247, 247, 247)">Turtle.Turn(-90) </td></tr><tr><td>Turtle.PenUp() </td></tr><tr><td style="background-color:rgb(247, 247, 247)">Turtle.Move(300) </td></tr><tr><td>Turtle.Turn(-90) </td></tr><tr><td style="background-color:rgb(247, 247, 247)">Turtle.Move(200) </td></tr><tr><td>Turtle.Turn(-90) </td></tr><tr><td style="background-color:rgb(247, 247, 247)">Turtle.PenDown() </td></tr><tr><td> </td></tr><tr><td style="background-color:rgb(247, 247, 247)"><font style="color:green">' let's do it!</font><font style="font-size:11px"> </font></td></tr><tr><td>DrawStart() </td></tr><tr><td style="background-color:rgb(247, 247, 247)"> </td></tr><tr><td><font style="color:green">' draw one rule</font><font style="font-size:11px"> </font></td></tr><tr><td style="background-color:rgb(247, 247, 247)"><font style="color:green">' if iteration is 0, stop further recursion</font><font style="font-size:11px"> </font></td></tr><tr><td><font style="color:green">' otherwise, do recursion</font><font style="font-size:11px"> </font></td></tr><tr><td style="background-color:rgb(247, 247, 247)"><font style="color:blue">Sub</font><font style="font-size:11px"> DrawRule </font></td></tr><tr><td>    iteration = iteration - 1 </td></tr><tr><td style="background-color:rgb(247, 247, 247)">    <font style="color:blue">If</font><font style="font-size:11px"> (iteration = 0) </font><font style="color:blue">Then</font><font style="font-size:11px"> </font></td></tr><tr><td>        Turtle.Move(length) </td></tr><tr><td style="background-color:rgb(247, 247, 247)">        Turtle.Turn(-angle) </td></tr><tr><td>        Turtle.Move(length) </td></tr><tr><td style="background-color:rgb(247, 247, 247)">        Turtle.Turn(angle) </td></tr><tr><td>        Turtle.Move(length) </td></tr><tr><td style="background-color:rgb(247, 247, 247)">        Turtle.Turn(angle) </td></tr><tr><td>        Turtle.Move(length) </td></tr><tr><td style="background-color:rgb(247, 247, 247)">        Turtle.Turn(-angle) </td></tr><tr><td>        Turtle.Move(length) </td></tr><tr><td style="background-color:rgb(247, 247, 247)">    <font style="color:blue">Else</font><font style="font-size:11px"> </font></td></tr><tr><td>        DrawRule() </td></tr><tr><td style="background-color:rgb(247, 247, 247)">        Turtle.Turn(-angle) </td></tr><tr><td>        DrawRule() </td></tr><tr><td style="background-color:rgb(247, 247, 247)">        Turtle.Turn(angle) </td></tr><tr><td>        DrawRule() </td></tr><tr><td style="background-color:rgb(247, 247, 247)">        Turtle.Turn(angle) </td></tr><tr><td>        DrawRule() </td></tr><tr><td style="background-color:rgb(247, 247, 247)">        Turtle.Turn(-angle) </td></tr><tr><td>        DrawRule() </td></tr><tr><td style="background-color:rgb(247, 247, 247)">    EndIf </td></tr><tr><td>    iteration = iteration + 1 </td></tr><tr><td style="background-color:rgb(247, 247, 247)">EndSub </td></tr><tr><td> </td></tr><tr><td style="background-color:rgb(247, 247, 247)"><font style="color:green">' draw the start shape</font><font style="font-size:11px"> </font></td></tr><tr><td><font style="color:blue">Sub</font><font style="font-size:11px"> DrawStart </font></td></tr><tr><td style="background-color:rgb(247, 247, 247)">    DrawRule() </td></tr><tr><td>EndSub </td></tr><tr><td style="background-color:rgb(247, 247, 247)"> </td></tr></tbody></table></div><br> Wed, 29 Oct 2008 20:29:26 Z2008-10-29T20:32:37Zhttp://social.msdn.microsoft.com/Forums/en-US/smallbasic/thread/eaacf826-9d12-4e3c-aa10-1b2788f160a6#b0270124-e5f2-433f-8c80-ae6dc469868fhttp://social.msdn.microsoft.com/Forums/en-US/smallbasic/thread/eaacf826-9d12-4e3c-aa10-1b2788f160a6#b0270124-e5f2-433f-8c80-ae6dc469868fsoloman817http://social.msdn.microsoft.com/Profile/en-US/?user=soloman817Post your sample source code here and get featured on our blogs!Another sample to draw Koch Curve.  You can ajust the times of iteration, 4 might be slow.<br><br><a href="http://blog.ipattern.org/wp-content/uploads/2008/10/koch_curve_4.png">Here is a screenshot</a><br><br><div style="overflow:auto;background-color:white;line-height:100% ! important;font-family:Courier New;font-size:11px"><table style="border-width:0px;margin:2px 0px;width:99%;border-collapse:collapse;background-color:rgb(255, 255, 255)" cellpadding=0 cellspacing=0><col style="font-family:Courier New;font-size:11px;padding-left:10px;white-space:nowrap"><tbody><tr><td><font style="font-size:11px"> file: koch_curve.sb </font></td></tr><tr><td style="background-color:rgb(247, 247, 247)"><font style="color:green">' Mr.Turtle will draw a Koch Square for us</font><font style="font-size:11px"> </font></td></tr><tr><td><font style="color:green">' l-system rules:</font><font style="font-size:11px"> </font></td></tr><tr><td style="background-color:rgb(247, 247, 247)"><font style="color:green">'   variables : F</font><font style="font-size:11px"> </font></td></tr><tr><td><font style="color:green">'   angle : 60</font><font style="font-size:11px"> </font></td></tr><tr><td style="background-color:rgb(247, 247, 247)"><font style="color:green">'   constants : + -</font><font style="font-size:11px"> </font></td></tr><tr><td><font style="color:green">'   start : F - - F - - F</font><font style="font-size:11px"> </font></td></tr><tr><td style="background-color:rgb(247, 247, 247)"><font style="color:green">'   rules : F = F + F - - F + F</font><font style="font-size:11px"> </font></td></tr><tr><td> </td></tr><tr><td style="background-color:rgb(247, 247, 247)"><font style="color:green">' set some default values</font><font style="font-size:11px"> </font></td></tr><tr><td>angle = 60 </td></tr><tr><td style="background-color:rgb(247, 247, 247)">length = 5 </td></tr><tr><td>iteration = 4 </td></tr><tr><td style="background-color:rgb(247, 247, 247)"> </td></tr><tr><td><font style="color:green">' set the graphic panel color</font><font style="font-size:11px"> </font></td></tr><tr><td style="background-color:rgb(247, 247, 247)">GraphicsWindow.BackgroundColor = <font style="color:blue">&quot;Black&quot;</font><font style="font-size:11px"> </font></td></tr><tr><td>GraphicsWindow.PenColor = <font style="color:blue">&quot;LightGreen&quot;</font><font style="font-size:11px"> </font></td></tr><tr><td style="background-color:rgb(247, 247, 247)"> </td></tr><tr><td><font style="color:green">'  move Mr.Turtle to the left-down corner for start</font><font style="font-size:11px"> </font></td></tr><tr><td style="background-color:rgb(247, 247, 247)">Turtle.Speed = 9 </td></tr><tr><td>Turtle.PenUp() </td></tr><tr><td style="background-color:rgb(247, 247, 247)">Turtle.Turn(90) </td></tr><tr><td>Turtle.Move(150) </td></tr><tr><td style="background-color:rgb(247, 247, 247)">Turtle.Turn(90) </td></tr><tr><td>Turtle.Move(150) </td></tr><tr><td style="background-color:rgb(247, 247, 247)">Turtle.Turn(90) </td></tr><tr><td>Turtle.PenDown() </td></tr><tr><td style="background-color:rgb(247, 247, 247)"> </td></tr><tr><td><font style="color:green">' let's do it!</font><font style="font-size:11px"> </font></td></tr><tr><td style="background-color:rgb(247, 247, 247)">DrawStart() </td></tr><tr><td> </td></tr><tr><td style="background-color:rgb(247, 247, 247)"><font style="color:green">' hide Mr.Turtle</font><font style="font-size:11px"> </font></td></tr><tr><td>Turtle.Hide() </td></tr><tr><td style="background-color:rgb(247, 247, 247)"> </td></tr><tr><td><font style="color:green">' draw one rule</font><font style="font-size:11px"> </font></td></tr><tr><td style="background-color:rgb(247, 247, 247)"><font style="color:green">' if iteration is 0, stop further recursion</font><font style="font-size:11px"> </font></td></tr><tr><td><font style="color:green">' otherwise, do recursion</font><font style="font-size:11px"> </font></td></tr><tr><td style="background-color:rgb(247, 247, 247)"><font style="color:blue">Sub</font><font style="font-size:11px"> DrawRule </font></td></tr><tr><td>    iteration = iteration - 1 </td></tr><tr><td style="background-color:rgb(247, 247, 247)">    <font style="color:blue">If</font><font style="font-size:11px"> (iteration = 0) </font><font style="color:blue">Then</font><font style="font-size:11px"> </font></td></tr><tr><td>        Turtle.Move(length) </td></tr><tr><td style="background-color:rgb(247, 247, 247)">        Turtle.Turn(-angle) </td></tr><tr><td>        Turtle.Move(length) </td></tr><tr><td style="background-color:rgb(247, 247, 247)">        Turtle.Turn(angle) </td></tr><tr><td>        Turtle.Turn(angle) </td></tr><tr><td style="background-color:rgb(247, 247, 247)">        Turtle.Move(length) </td></tr><tr><td>        Turtle.Turn(-angle) </td></tr><tr><td style="background-color:rgb(247, 247, 247)">        Turtle.Move(length) </td></tr><tr><td>    <font style="color:blue">Else</font><font style="font-size:11px"> </font></td></tr><tr><td style="background-color:rgb(247, 247, 247)">        DrawRule() </td></tr><tr><td>        Turtle.Turn(-angle) </td></tr><tr><td style="background-color:rgb(247, 247, 247)">        DrawRule() </td></tr><tr><td>        Turtle.Turn(angle) </td></tr><tr><td style="background-color:rgb(247, 247, 247)">        Turtle.Turn(angle) </td></tr><tr><td>        DrawRule() </td></tr><tr><td style="background-color:rgb(247, 247, 247)">        Turtle.Turn(-angle) </td></tr><tr><td>        DrawRule() </td></tr><tr><td style="background-color:rgb(247, 247, 247)">    EndIf </td></tr><tr><td>    iteration = iteration + 1 </td></tr><tr><td style="background-color:rgb(247, 247, 247)">EndSub </td></tr><tr><td> </td></tr><tr><td style="background-color:rgb(247, 247, 247)"><font style="color:green">' draw the start shape</font><font style="font-size:11px"> </font></td></tr><tr><td><font style="color:blue">Sub</font><font style="font-size:11px"> DrawStart </font></td></tr><tr><td style="background-color:rgb(247, 247, 247)">    DrawRule() </td></tr><tr><td>    Turtle.Turn(angle) </td></tr><tr><td style="background-color:rgb(247, 247, 247)">    Turtle.Turn(angle) </td></tr><tr><td>    DrawRule() </td></tr><tr><td style="background-color:rgb(247, 247, 247)">    Turtle.Turn(angle) </td></tr><tr><td>    Turtle.Turn(angle) </td></tr><tr><td style="background-color:rgb(247, 247, 247)">    DrawRule() </td></tr><tr><td>EndSub </td></tr><tr><td style="background-color:rgb(247, 247, 247)"> </td></tr></tbody></table></div> Wed, 29 Oct 2008 20:35:05 Z2008-10-29T20:35:05Zhttp://social.msdn.microsoft.com/Forums/en-US/smallbasic/thread/eaacf826-9d12-4e3c-aa10-1b2788f160a6#2e2e51d2-bfc3-401a-9675-29d4bc139853http://social.msdn.microsoft.com/Forums/en-US/smallbasic/thread/eaacf826-9d12-4e3c-aa10-1b2788f160a6#2e2e51d2-bfc3-401a-9675-29d4bc139853mcleod_ideafixhttp://social.msdn.microsoft.com/Profile/en-US/?user=mcleod_ideafixPost your sample source code here and get featured on our blogs!<p> Here's a point-and-shoot game. It's a remake of the same thing I wrote using LOGO eons ago!</p> <div style="border-bottom:#7f9db9 1px solid;border-left:#7f9db9 1px solid;line-height:100% !important;background-color:white;font-family:Courier New;font-size:11px;overflow:auto;border-top:#7f9db9 1px solid;border-right:#7f9db9 1px solid"> <table style="border-bottom:#eee 0px solid;border-right-width:0px;background-color:#fff;margin:2px 0px;width:99%;border-collapse:collapse;border-top-width:0px;border-left-width:0px" cellspacing=0 cellpadding=0> <colgroup> <col style="border-bottom:#f7f7f7 1px solid;padding-left:10px;font-family:Courier New;white-space:nowrap;font-size:11px"> <tbody> <tr> <td><font style="font-size:11px"></font><font style="color:green">'Point-and-shoot </font><font style="font-size:11px"> </font></td></tr> <tr> <td style="background-color:#f7f7f7"></font><font style="color:green">'(C)1989 McLeod/IdeaFix. http://www.zxprojects.com </font><font style="font-size:11px"> </font></td></tr> <tr> <td> </td></tr> <tr> <td style="background-color:#f7f7f7"></font><font style="color:green">'Target size </font><font style="font-size:11px"> </font></td></tr> <tr> <td>TargetSize=30  </td></tr> <tr> <td style="background-color:#f7f7f7">winner=0  </td></tr> <tr> <td>wanttoplay=1  </td></tr> <tr> <td style="background-color:#f7f7f7"> </td></tr> <tr> <td></font><font style="color:green">'A vector-screen style window </font><font style="font-size:11px"> </font></td></tr> <tr> <td style="background-color:#f7f7f7">GraphicsWindow.BackgroundColor=</font><font style="color:blue">&quot;Black&quot;</font><font style="font-size:11px"> </font></td></tr> <tr> <td>GraphicsWindow.PenColor=</font><font style="color:blue">&quot;Green&quot;</font><font style="font-size:11px"> </font></td></tr> <tr> <td style="background-color:#f7f7f7">GraphicsWindow.Clear()  </td></tr> <tr> <td> </td></tr> <tr> <td style="background-color:#f7f7f7">Game()  </td></tr> <tr> <td> </td></tr> <tr> <td style="background-color:#f7f7f7"></font><font style="color:blue">Sub</font><font style="font-size:11px"> Game  </font></td></tr> <tr> <td>    </font><font style="color:blue">While</font><font style="font-size:11px"> (wanttoplay=1)  </font></td></tr> <tr> <td style="background-color:#f7f7f7">        GetRnd()  </td></tr> <tr> <td>        DrawTarget()  </td></tr> <tr> <td style="background-color:#f7f7f7">        Turtle.PenUp()  </td></tr> <tr> <td>          </td></tr> <tr> <td style="background-color:#f7f7f7">        </font><font style="color:green">'Game loop </font><font style="font-size:11px"> </font></td></tr> <tr> <td>        </font><font style="color:blue">While</font><font style="font-size:11px"> (winner=0)  </font></td></tr> <tr> <td style="background-color:#f7f7f7">            Shoot()  </td></tr> <tr> <td>        EndWhile  </td></tr> <tr> <td style="background-color:#f7f7f7">          </td></tr> <tr> <td>        winner=0  </td></tr> <tr> <td style="background-color:#f7f7f7">        TextWindow.Write(</font><font style="color:blue">&quot;Another game? (y/n) &quot;</font><font style="font-size:11px">)  </font></td></tr> <tr> <td>        answ = TextWindow.Read()  </td></tr> <tr> <td style="background-color:#f7f7f7">        </font><font style="color:blue">If</font><font style="font-size:11px"> (Text.StartsWith(Text.ConvertToLowerCase(answ),</font><font style="color:blue">&quot;n&quot;</font><font style="font-size:11px">)) </font><font style="color:blue">Then</font><font style="font-size:11px"> </font></td></tr> <tr> <td>            wanttoplay=0  </td></tr> <tr> <td style="background-color:#f7f7f7">        </font><font style="color:blue">Else</font><font style="font-size:11px"> </font></td></tr> <tr> <td>            GraphicsWindow.Clear()  </td></tr> <tr> <td style="background-color:#f7f7f7">            Turtle.PenDown()  </td></tr> <tr> <td>            GraphicsWindow.PenColor=</font><font style="color:blue">&quot;Green&quot;</font><font style="font-size:11px"> </font></td></tr> <tr> <td style="background-color:#f7f7f7">        EndIf  </td></tr> <tr> <td>    EndWhile  </td></tr> <tr> <td style="background-color:#f7f7f7">EndSub  </td></tr> <tr> <td> </td></tr> <tr> <td style="background-color:#f7f7f7"></font><font style="color:blue">Sub</font><font style="font-size:11px"> Shoot  </font></td></tr> <tr> <td>    TextWindow.Write(</font><font style="color:blue">&quot;Angle? &quot;</font><font style="font-size:11px">)  </font></td></tr> <tr> <td style="background-color:#f7f7f7">    ang=TextWindow.ReadNumber()  </td></tr> <tr> <td>    TextWindow.Write(</font><font style="color:blue">&quot;Distance? &quot;</font><font style="font-size:11px">)  </font></td></tr> <tr> <td style="background-color:#f7f7f7">    dist=TextWindow.ReadNumber()  </td></tr> <tr> <td> </td></tr> <tr> <td style="background-color:#f7f7f7">    Turtle.Turn(ang)  </td></tr> <tr> <td>    Turtle.Move(dist)  </td></tr> <tr> <td style="background-color:#f7f7f7">    Turtle.Turn(-ang)  </td></tr> <tr> <td>      </td></tr> <tr> <td style="background-color:#f7f7f7">    xs=dist*Math.Cos(Math.GetRadians(ang))  </td></tr> <tr> <td>    ys=dist*Math.Sin(Math.GetRadians(ang))  </td></tr> <tr> <td style="background-color:#f7f7f7">      </td></tr> <tr> <td>    </font><font style="color:blue">If</font><font style="font-size:11px"> (xs&gt;=xmin </font><font style="color:blue">And</font><font style="font-size:11px"> xs&lt;=xmax </font><font style="color:blue">And</font><font style="font-size:11px"> ys&gt;=ymin </font><font style="color:blue">And</font><font style="font-size:11px"> ys&lt;=ymax) </font><font style="color:blue">Then</font><font style="font-size:11px"> </font></td></tr> <tr> <td style="background-color:#f7f7f7">        Sound.PlayChimes()  </td></tr> <tr> <td>        Turtle.Speed=100  </td></tr> <tr> <td style="background-color:#f7f7f7">        Turtle.Move(-15)  </td></tr> <tr> <td>        Turtle.PenDown()  </td></tr> <tr> <td style="background-color:#f7f7f7">        </font><font style="color:green">'The boom! visual effect </font><font style="font-size:11px"> </font></td></tr> <tr> <td>        </font><font style="color:blue">For</font><font style="font-size:11px"> n=1 </font><font style="color:blue">To</font><font style="font-size:11px"> 36  </font></td></tr> <tr> <td style="background-color:#f7f7f7">            GraphicsWindow.PenColor=GraphicsWindow.GetRandomColor()  </td></tr> <tr> <td>            Turtle.Move(30)  </td></tr> <tr> <td style="background-color:#f7f7f7">            Turtle.Turn(150)  </td></tr> <tr> <td>        EndFor  </td></tr> <tr> <td style="background-color:#f7f7f7">        Turtle.PenUp()  </td></tr> <tr> <td>        Turtle.Move(15)  </td></tr> <tr> <td style="background-color:#f7f7f7">        Turtle.Turn(ang)  </td></tr> <tr> <td>        Turtle.Move(-dist)  </td></tr> <tr> <td style="background-color:#f7f7f7">        Turtle.Turn(-ang)          </td></tr> <tr> <td>        Turtle.Hide()       </td></tr> <tr> <td style="background-color:#f7f7f7">        TextWindow.WriteLine(</font><font style="color:blue">&quot;Target cleared!! You WIN&quot;</font><font style="font-size:11px">)  </font></td></tr> <tr> <td>        winner=1  </td></tr> <tr> <td style="background-color:#f7f7f7">    </font><font style="color:blue">Else</font><font style="font-size:11px"> </font></td></tr> <tr> <td>        TextWindow.Write(</font><font style="color:blue">&quot;Target failed!! Try again (press RETURN)&quot;</font><font style="font-size:11px">)  </font></td></tr> <tr> <td style="background-color:#f7f7f7">        TextWindow.Read()  </td></tr> <tr> <td>        Turtle.Speed=100  </td></tr> <tr> <td style="background-color:#f7f7f7">        Turtle.Turn(ang)  </td></tr> <tr> <td>        Turtle.Move(-dist)  </td></tr> <tr> <td style="background-color:#f7f7f7">        Turtle.Turn(-ang)  </td></tr> <tr> <td>        Turtle.Speed=7  </td></tr> <tr> <td style="background-color:#f7f7f7">        winner=0  </td></tr> <tr> <td>    EndIf  </td></tr> <tr> <td style="background-color:#f7f7f7">EndSub  </td></tr> <tr> <td> </td></tr> <tr> <td style="background-color:#f7f7f7"></font><font style="color:blue">Sub</font><font style="font-size:11px"> GetRnd  </font></td></tr> <tr> <td>    </font><font style="color:green">'These variables should store the current Height and Width of GraphicsWindow, but it seems not to work </font><font style="font-size:11px"> </font></td></tr> <tr> <td style="background-color:#f7f7f7">    he=480  </td></tr> <tr> <td>    wi=640  </td></tr> <tr> <td style="background-color:#f7f7f7">      </td></tr> <tr> <td>    </font><font style="color:blue">If</font><font style="font-size:11px"> (he &lt; wi) </font><font style="color:blue">Then</font><font style="font-size:11px"> </font></td></tr> <tr> <td style="background-color:#f7f7f7">        distance=40+Math.GetRandomNumber(he/2-TargetSize-40)  </td></tr> <tr> <td>    </font><font style="color:blue">Else</font><font style="font-size:11px"> </font></td></tr> <tr> <td style="background-color:#f7f7f7">        distance=40+Math.GetRandomNumber(wi/2-TargetSize-40)  </td></tr> <tr> <td>    EndIf  </td></tr> <tr> <td style="background-color:#f7f7f7">    angle=Math.GetRandomNumber(360)  </td></tr> <tr> <td>      </td></tr> <tr> <td style="background-color:#f7f7f7">    xmin=distance*Math.Cos(Math.GetRadians(angle))  </td></tr> <tr> <td>    ymin=distance*Math.Sin(Math.GetRadians(angle))  </td></tr> <tr> <td style="background-color:#f7f7f7">    xmax=xmin+TargetSize  </td></tr> <tr> <td>    ymax=ymin+TargetSize  </td></tr> <tr> <td style="background-color:#f7f7f7">EndSub  </td></tr> <tr> <td> </td></tr> <tr> <td style="background-color:#f7f7f7"></font><font style="color:blue">Sub</font><font style="font-size:11px"> DrawTarget  </font></td></tr> <tr> <td>    Turtle.Speed=100      </td></tr> <tr> <td style="background-color:#f7f7f7">    Turtle.PenUp()  </td></tr> <tr> <td>    Turtle.Turn(angle)  </td></tr> <tr> <td style="background-color:#f7f7f7">    Turtle.Move(distance)  </td></tr> <tr> <td>    Turtle.Turn(-angle)  </td></tr> <tr> <td style="background-color:#f7f7f7">    Turtle.PenDown()  </td></tr> <tr> <td>    </font><font style="color:blue">For</font><font style="font-size:11px"> n=1 </font><font style="color:blue">To</font><font style="font-size:11px"> 4  </font></td></tr> <tr> <td style="background-color:#f7f7f7">        Turtle.Move(TargetSize)  </td></tr> <tr> <td>        Turtle.TurnRight()  </td></tr> <tr> <td style="background-color:#f7f7f7">    EndFor  </td></tr> <tr> <td>    Turtle.PenUp()  </td></tr> <tr> <td style="background-color:#f7f7f7">    Turtle.Turn(angle)  </td></tr> <tr> <td>    Turtle.Move(-distance)  </td></tr> <tr> <td style="background-color:#f7f7f7">    Turtle.Turn(-angle)  </td></tr> <tr> <td>    Turtle.PenDown()  </td></tr> <tr> <td style="background-color:#f7f7f7">    Turtle.Speed=7  </td></tr> <tr> <td>EndSub  </td></tr> <tr> <td style="background-color:#f7f7f7"> </td></tr></tbody></table></div>Thu, 30 Oct 2008 02:21:01 Z2008-10-30T02:21:01Zhttp://social.msdn.microsoft.com/Forums/en-US/smallbasic/thread/eaacf826-9d12-4e3c-aa10-1b2788f160a6#fedba444-6d96-4bfb-b10c-7e06add5ba3ehttp://social.msdn.microsoft.com/Forums/en-US/smallbasic/thread/eaacf826-9d12-4e3c-aa10-1b2788f160a6#fedba444-6d96-4bfb-b10c-7e06add5ba3eVijaye Rajihttp://social.msdn.microsoft.com/Profile/en-US/?user=Vijaye%20RajiPost your sample source code here and get featured on our blogs! I love every single one of these samples!!  Amazing work - it's really hard for us to pick the one to feature in our blogs.  Because of that we're going to make this a weekly feature - keep your samples coming!Sat, 01 Nov 2008 05:59:48 Z2008-11-01T05:59:48Zhttp://social.msdn.microsoft.com/Forums/en-US/smallbasic/thread/eaacf826-9d12-4e3c-aa10-1b2788f160a6#42d77ebf-044c-4593-9e11-017f00df16c5http://social.msdn.microsoft.com/Forums/en-US/smallbasic/thread/eaacf826-9d12-4e3c-aa10-1b2788f160a6#42d77ebf-044c-4593-9e11-017f00df16c5Vijaye Rajihttp://social.msdn.microsoft.com/Profile/en-US/?user=Vijaye%20RajiPost your sample source code here and get featured on our blogs! mcleod_ideafix's point and shoot game is now the featured sample of the week in our Small Basic blogs (<a href="http://blogs.msdn.com/smallbasic/default.aspx">http://blogs.msdn.com/smallbasic/default.aspx</a>)<br><br>Sat, 01 Nov 2008 19:39:12 Z2008-11-01T19:39:12Zhttp://social.msdn.microsoft.com/Forums/en-US/smallbasic/thread/eaacf826-9d12-4e3c-aa10-1b2788f160a6#0ff74d26-2d6e-4143-a27b-a12a37d855c5http://social.msdn.microsoft.com/Forums/en-US/smallbasic/thread/eaacf826-9d12-4e3c-aa10-1b2788f160a6#0ff74d26-2d6e-4143-a27b-a12a37d855c5George Birbilishttp://social.msdn.microsoft.com/Profile/en-US/?user=George%20BirbilisPost your sample source code here and get featured on our blogs!<p>This (ported from a Modellus sample) should draw a flower (using angular coordinates in calculations and converting to cartesian to draw). Didn't try it though cause of the issue with SmallBasic in non-English locales, so please update if not showing ok and drop-in a screenshot too if you like the output :-)<br><br></p> <div style="border-bottom:#7f9db9 1px solid;border-left:#7f9db9 1px solid;line-height:100% !important;background-color:white;font-family:Courier New;font-size:11px;overflow:auto;border-top:#7f9db9 1px solid;border-right:#7f9db9 1px solid"> <table style="border-bottom:#eee 0px solid;border-right-width:0px;background-color:#fff;margin:2px 0px;width:99%;border-collapse:collapse;border-top-width:0px;border-left-width:0px" cellspacing=0 cellpadding=0> <colgroup> <col style="border-bottom:#f7f7f7 1px solid;padding-left:10px;font-family:Courier New;white-space:nowrap;font-size:11px"> <tbody> <tr> <td><font style="font-size:11px">init()  </font></td></tr> <tr> <td style="background-color:#f7f7f7"></font><font style="color:blue">For</font><font style="font-size:11px"> i=1 </font><font style="color:blue">To</font><font style="font-size:11px"> 100  </font></td></tr> <tr> <td> oldx=x  </td></tr> <tr> <td style="background-color:#f7f7f7"> oldy=y  </td></tr> <tr> <td> solve()  </td></tr> <tr> <td style="background-color:#f7f7f7"> animate()  </td></tr> <tr> <td> t=t+dt  </td></tr> <tr> <td style="background-color:#f7f7f7">EndFor  </td></tr> <tr> <td> </td></tr> <tr> <td style="background-color:#f7f7f7"></font><font style="color:blue">Sub</font><font style="font-size:11px"> init  </font></td></tr> <tr> <td> GraphicsWindow.Show()  </td></tr> <tr> <td style="background-color:#f7f7f7"> t=0  </td></tr> <tr> <td> dt=0.1  </td></tr> <tr> <td style="background-color:#f7f7f7"> x=0  </td></tr> <tr> <td> y=0  </td></tr> <tr> <td style="background-color:#f7f7f7"> ofsx=GraphicsWindow.Width/2  </td></tr> <tr> <td> ofsy=GraphicsWindow.Height/2  </td></tr> <tr> <td style="background-color:#f7f7f7">EndSub  </td></tr> <tr> <td> </td></tr> <tr> <td style="background-color:#f7f7f7"></font><font style="color:blue">Sub</font><font style="font-size:11px"> solve  </font></td></tr> <tr> <td> theta=10*t  </td></tr> <tr> <td style="background-color:#f7f7f7"> r=10*Math.cos(60*t)+20  </td></tr> <tr> <td> x=r*Math.cos(theta)  </td></tr> <tr> <td style="background-color:#f7f7f7"> y=r*Math.sin(theta)  </td></tr> <tr> <td>EndSub  </td></tr> <tr> <td style="background-color:#f7f7f7"> </td></tr> <tr> <td></font><font style="color:blue">Sub</font><font style="font-size:11px"> animate  </font></td></tr> <tr> <td style="background-color:#f7f7f7"> GraphicsWindow.AddLine(ofsx+oldx,ofsy+oldy,ofsx+x,ofsy+y)  </td></tr> <tr> <td>EndSub  </td></tr> <tr> <td style="background-color:#f7f7f7"> </td></tr></tbody></table></div><hr size="1" align="left" width="25%">Microsoft MVP J# 2004-2007, Borland Spirit of Delphi 2001Sat, 01 Nov 2008 22:54:36 Z2008-11-01T22:54:36Zhttp://social.msdn.microsoft.com/Forums/en-US/smallbasic/thread/eaacf826-9d12-4e3c-aa10-1b2788f160a6#8bc36c47-f00d-4e0b-8274-ae13c759c306http://social.msdn.microsoft.com/Forums/en-US/smallbasic/thread/eaacf826-9d12-4e3c-aa10-1b2788f160a6#8bc36c47-f00d-4e0b-8274-ae13c759c306carolingianhttp://social.msdn.microsoft.com/Profile/en-US/?user=carolingianPost your sample source code here and get featured on our blogs!Thanks to George, i used your code layout on the squarial code for this fun trick i made.<br>I imagine it'll make every geometric shape imaginable if it the golden ratio wasnt truncated to 10 decimal places or so.<br><br><div style="overflow:auto;background-color:white;line-height:100% ! important;font-family:Courier New;font-size:11px"><table style="border-width:0px;margin:2px 0px;width:99%;border-collapse:collapse;background-color:rgb(255, 255, 255)" cellpadding=0 cellspacing=0><col style="font-family:Courier New;font-size:11px;padding-left:10px;white-space:nowrap"><tbody><tr><td><font style="font-size:11px"> </font></td></tr><tr><td style="background-color:rgb(247, 247, 247)">GraphicsWindow.Show()      </td></tr><tr><td><font style="color:red">Turtle.Speed</font><font style="font-size:11px"> = </font><font style="color:blue">10</font><font style="font-size:11px"> </font></td></tr><tr><td style="background-color:rgb(247, 247, 247)"><font style="color:red">angle</font><font style="font-size:11px"> = (1+ Math.SquareRoot(5))/2  </font></td></tr><tr><td>golden() </td></tr><tr><td style="background-color:rgb(247, 247, 247)">   </td></tr><tr><td>Sub golden   </td></tr><tr><td style="background-color:rgb(247, 247, 247)"> <font style="color:red">side</font><font style="font-size:11px"> = </font><font style="color:blue">0</font><font style="font-size:11px"> </font></td></tr><tr><td> For <font style="color:red">i</font><font style="font-size:11px"> = </font><font style="color:blue">1</font><font style="font-size:11px"> to 360 </font></td></tr><tr><td style="background-color:rgb(247, 247, 247)">        </td></tr><tr><td>  Turtle.Move(side)      </td></tr><tr><td style="background-color:rgb(247, 247, 247)">  Turtle.Turn(angle)      </td></tr><tr><td>  <font style="color:red"></font><font style="color:blue">side</font><font style="font-size:11px"> = side + 1 </font></td></tr><tr><td style="background-color:rgb(247, 247, 247)">  <font style="color:blue">angle</font><font style="font-size:11px"> = angle + 1 </font></td></tr><tr><td> EndFor      </td></tr><tr><td style="background-color:rgb(247, 247, 247)">EndSub    </td></tr><tr><td> </td></tr></tbody></table></div>Also, doing things proper, here is a graph of the golden ratio:<br><br><div style="overflow:auto;background-color:white;line-height:100% ! important;font-family:Courier New;font-size:11px"><table style="border-width:0px;margin:2px 0px;width:99%;border-collapse:collapse;background-color:rgb(255, 255, 255)" cellpadding=0 cellspacing=0><col style="font-family:Courier New;font-size:11px;padding-left:10px;white-space:nowrap"><tbody><tr><td><font style="font-size:11px">GraphicsWindow.Show()     </font></td></tr><tr><td style="background-color:rgb(247, 247, 247)">Turtle.Speed = 10 </td></tr><tr><td>angle = 30 </td></tr><tr><td style="background-color:rgb(247, 247, 247)">golden() </td></tr><tr><td>   </td></tr><tr><td style="background-color:rgb(247, 247, 247)">Sub golden   </td></tr><tr><td> side = (1+ Math.SquareRoot(5))/2  </td></tr><tr><td style="background-color:rgb(247, 247, 247)"> For i = 1 to 360 </td></tr><tr><td>  Turtle.Move(side)      </td></tr><tr><td style="background-color:rgb(247, 247, 247)">  Turtle.Turn(angle)      </td></tr><tr><td>  side = side + i </td></tr><tr><td style="background-color:rgb(247, 247, 247)"> EndFor      </td></tr><tr><td>EndSub    </td></tr></tbody></table></div><br> Sun, 02 Nov 2008 02:43:25 Z2008-11-02T03:13:50Zhttp://social.msdn.microsoft.com/Forums/en-US/smallbasic/thread/eaacf826-9d12-4e3c-aa10-1b2788f160a6#5ddd1285-55cc-44f9-bc79-4488cbb8c91ahttp://social.msdn.microsoft.com/Forums/en-US/smallbasic/thread/eaacf826-9d12-4e3c-aa10-1b2788f160a6#5ddd1285-55cc-44f9-bc79-4488cbb8c91aGeorge Birbilishttp://social.msdn.microsoft.com/Profile/en-US/?user=George%20BirbilisPost your sample source code here and get featured on our blogs!<div style="border-bottom:#7f9db9 1px solid;border-left:#7f9db9 1px solid;line-height:100% !important;background-color:white;font-family:Courier New;font-size:11px;overflow:auto;border-top:#7f9db9 1px solid;border-right:#7f9db9 1px solid"> <table style="border-bottom:#eee 0px solid;border-right-width:0px;background-color:#fff;margin:2px 0px;width:99%;border-collapse:collapse;border-top-width:0px;border-left-width:0px" cellspacing=0 cellpadding=0> <colgroup> <col style="border-bottom:#f7f7f7 1px solid;padding-left:10px;font-family:Courier New;white-space:nowrap;font-size:11px"> <tbody> <tr> <td><font style="font-size:11px">GraphicsWindow.Show()        </font></td></tr> <tr> <td style="background-color:#f7f7f7">Turtle.Speed = 10    </td></tr> <tr> <td>angle = 80  </td></tr> <tr> <td style="background-color:#f7f7f7">golden()    </td></tr> <tr> <td>      </td></tr> <tr> <td style="background-color:#f7f7f7"></font><font style="color:blue">Sub</font><font style="font-size:11px"> golden      </font></td></tr> <tr> <td> side = (1+ Math.SquareRoot(5))/2     </td></tr> <tr> <td style="background-color:#f7f7f7"> </font><font style="color:blue">For</font><font style="font-size:11px"> i = 1 to 180  </font></td></tr> <tr> <td>  Turtle.Move(side)         </td></tr> <tr> <td style="background-color:#f7f7f7">  Turtle.Turn(angle)         </td></tr> <tr> <td>  side = side + 1    </td></tr> <tr> <td style="background-color:#f7f7f7"> EndFor         </td></tr> <tr> <td>EndSub  </td></tr> <tr> <td style="background-color:#f7f7f7"> </td></tr></tbody></table></div>Nice, ported it to Scratch to see it though (waiting for the next SmallBasic that will run ok at my system's locale). Try the above variation for a knitted-like star pattern :-). Also at your first fun-sample try using 180 instead of 360. In Scratch it shows like a 3D sphere with blasts/rays arround it (could imagine it as a star or exploding planet) <hr align=left size=1 width="25%"> Microsoft MVP J# 2004-2007, Borland Spirit of Delphi 2001Mon, 03 Nov 2008 16:40:48 Z2008-11-03T16:44:27Zhttp://social.msdn.microsoft.com/Forums/en-US/smallbasic/thread/eaacf826-9d12-4e3c-aa10-1b2788f160a6#4f9075d7-b0e9-4847-af8d-ec96c20daec1http://social.msdn.microsoft.com/Forums/en-US/smallbasic/thread/eaacf826-9d12-4e3c-aa10-1b2788f160a6#4f9075d7-b0e9-4847-af8d-ec96c20daec1carolingianhttp://social.msdn.microsoft.com/Profile/en-US/?user=carolingianPost your sample source code here and get featured on our blogs!I was a little bored. It's obvious what this is :) Maybe I'll get up the gumption one day to write something useful.<br><br><div style="overflow:auto;background-color:white;line-height:100% ! important;font-family:Courier New;font-size:11px"><table style="border-width:0px;margin:2px 0px;width:99%;border-collapse:collapse;background-color:rgb(255, 255, 255)" cellpadding=0 cellspacing=0><col style="font-family:Courier New;font-size:11px;padding-left:10px;white-space:nowrap"><tbody><tr><td><font style="font-size:11px">GraphicsWindow.Show()         </font></td></tr><tr><td style="background-color:rgb(247, 247, 247)">Turtle.Speed = 10      </td></tr><tr><td>side = 800   </td></tr><tr><td style="background-color:rgb(247, 247, 247)">fib() </td></tr><tr><td>x = 1 </td></tr><tr><td style="background-color:rgb(247, 247, 247)">y = 1 </td></tr><tr><td>    </td></tr><tr><td style="background-color:rgb(247, 247, 247)"><font style="color:blue">Sub</font><font style="font-size:11px"> fib    </font></td></tr><tr><td> <font style="color:blue">For</font><font style="font-size:11px"> x = 1 to 300 </font></td></tr><tr><td style="background-color:rgb(247, 247, 247)">    z = x + y </td></tr><tr><td>    x = y </td></tr><tr><td style="background-color:rgb(247, 247, 247)">    y = z </td></tr><tr><td>    Turtle.Move(z + 1)          </td></tr><tr><td style="background-color:rgb(247, 247, 247)">    Turtle.Turn(side)  </td></tr><tr><td> EndFor  </td></tr><tr><td style="background-color:rgb(247, 247, 247)">EndSub       </td></tr><tr><td> </td></tr><tr><td style="background-color:rgb(247, 247, 247)"> </td></tr></tbody></table></div><br> Fri, 07 Nov 2008 00:16:50 Z2008-11-07T00:16:50Zhttp://social.msdn.microsoft.com/Forums/en-US/smallbasic/thread/eaacf826-9d12-4e3c-aa10-1b2788f160a6#76d49a38-d702-41f4-b73f-94e1c1dbebffhttp://social.msdn.microsoft.com/Forums/en-US/smallbasic/thread/eaacf826-9d12-4e3c-aa10-1b2788f160a6#76d49a38-d702-41f4-b73f-94e1c1dbebffJeff Sidloskyhttp://social.msdn.microsoft.com/Profile/en-US/?user=Jeff%20SidloskyPost your sample source code here and get featured on our blogs! Made a star field.   Frustarted I can't specify RGB color.  Tried Graphics.DrawPixel() with clearing sreen, but it flickered like crazy.  Instead I make rectangle objects, and move those.  I simulate darker colors in the back by using some flags in the array so I can alternate the color from dim to white.<br><br> <div style="border-right:#7f9db9 1px solid;border-top:#7f9db9 1px solid;font-size:11px;overflow:auto;border-left:#7f9db9 1px solid;line-height:100%! important;border-bottom:#7f9db9 1px solid;font-family:courier new;background-color:white"> <table style="border-top-width:0px;border-left-width:0px;margin:2px 0px;width:99%;border-bottom:#eee 0px solid;border-collapse:collapse;background-color:#fff;border-right-width:0px" cellspacing=0 cellpadding=0> <colgroup> <col style="padding-left:10px;font-size:11px;border-bottom:#f7f7f7 1px solid;font-family:courier new;white-space:nowrap"></colgroup> <tbody> <tr> <td><font style="font-size:11px">Initialize()  </font></td></tr> <tr> <td style="background-color:#f7f7f7">Main()  </td></tr> <tr> <td> </td></tr> <tr> <td style="background-color:#f7f7f7"><font color="#0000ff">Sub</font><font style="font-size:11px"> Initialize  </font></td></tr> <tr> <td>    GraphicsWindow.Title = <font color="#0000ff">&quot;Super Star Field!&quot;</font><font style="font-size:11px"> </font></td></tr> <tr> <td style="background-color:#f7f7f7">    GraphicsWindow.Width = 640  </td></tr> <tr> <td>    GraphicsWindow.Height = 480  </td></tr> <tr> <td style="background-color:#f7f7f7">    GraphicsWindow.BackgroundColor = <font color="#0000ff">&quot;black&quot;</font><font style="font-size:11px"> </font></td></tr> <tr> <td>    GraphicsWindow.PenWidth = 0  </td></tr> <tr> <td style="background-color:#f7f7f7">    GraphicsWindow.Show()  </td></tr> <tr> <td>      </td></tr> <tr> <td style="background-color:#f7f7f7">    num_stars = 200  </td></tr> <tr> <td>      </td></tr> <tr> <td style="background-color:#f7f7f7">    <font color="#0000ff">For</font><font style="font-size:11px"> index = 0 </font><font color="#0000ff">To</font><font style="font-size:11px"> num_stars  </font></td></tr> <tr> <td>        NewStar()  </td></tr> <tr> <td style="background-color:#f7f7f7">    EndFor  </td></tr> <tr> <td>EndSub  </td></tr> <tr> <td style="background-color:#f7f7f7"> </td></tr> <tr> <td><font color="#0000ff">Sub</font><font style="font-size:11px"> NewStar  </font></td></tr> <tr> <td style="background-color:#f7f7f7">    Array.SetValue(<font color="#0000ff">&quot;star_x&quot;</font><font style="font-size:11px">, index, Math.GetRandomNumber(100) - 50)  </font></td></tr> <tr> <td>    Array.SetValue(<font color="#0000ff">&quot;star_y&quot;</font><font style="font-size:11px">, index, Math.GetRandomNumber(100) - 50)  </font></td></tr> <tr> <td style="background-color:#f7f7f7">      </td></tr> <tr> <td>    <font color="#008000">' Pick a random z depth </font><font style="font-size:11px"> </font></td></tr> <tr> <td style="background-color:#f7f7f7">    z = (Math.GetRandomNumber(50) / 100) + 0.50  </td></tr> <tr> <td>      </td></tr> <tr> <td style="background-color:#f7f7f7">    Array.SetValue(<font color="#0000ff">&quot;star_z&quot;</font><font style="font-size:11px">, index, z)  </font></td></tr> <tr> <td>      </td></tr> <tr> <td style="background-color:#f7f7f7">    <font color="#008000">' Start with a dark color and save our shape </font><font style="font-size:11px"> </font></td></tr> <tr> <td>    GraphicsWindow.BrushColor = <font color="#0000ff">&quot;DimGray&quot;</font><font style="font-size:11px"> </font></td></tr> <tr> <td style="background-color:#f7f7f7">    Array.SetValue(<font color="#0000ff">&quot;star_shape&quot;</font><font style="font-size:11px">, index, GraphicsWindow.AddRectangle(2, 2))  </font></td></tr> <tr> <td>    Array.SetValue(<font color="#0000ff">&quot;star_color&quot;</font><font style="font-size:11px">, index, 0)  </font></td></tr> <tr> <td style="background-color:#f7f7f7">EndSub  </td></tr> <tr> <td> </td></tr> <tr> <td style="background-color:#f7f7f7"><font color="#0000ff">Sub</font><font style="font-size:11px"> Update  </font></td></tr> <tr> <td>    <font color="#0000ff">For</font><font style="font-size:11px"> index = 0 </font><font color="#0000ff">To</font><font style="font-size:11px"> num_stars  </font></td></tr> <tr> <td style="background-color:#f7f7f7">        z = Array.GetValue(<font color="#0000ff">&quot;star_z&quot;</font><font style="font-size:11px">, index)        </font></td></tr> <tr> <td>        x = (Array.GetValue(<font color="#0000ff">&quot;star_x&quot;</font><font style="font-size:11px">, index) / z) + 320  </font></td></tr> <tr> <td style="background-color:#f7f7f7">        y = (Array.GetValue(<font color="#0000ff">&quot;star_y&quot;</font><font style="font-size:11px">, index) / z) + 240  </font></td></tr> <tr> <td>        shape = Array.GetValue(<font color="#0000ff">&quot;star_shape&quot;</font><font style="font-size:11px">, index)  </font></td></tr> <tr> <td style="background-color:#f7f7f7">          </td></tr> <tr> <td>        <font color="#008000">' Next z position </font><font style="font-size:11px"> </font></td></tr> <tr> <td style="background-color:#f7f7f7">        z = z - 0.02  </td></tr> <tr> <td>          </td></tr> <tr> <td style="background-color:#f7f7f7">        <font color="#0000ff">If</font><font style="font-size:11px">(x &lt; 0 </font><font color="#0000ff">Or</font><font style="font-size:11px"> x &gt; 639 </font><font color="#0000ff">Or</font><font style="font-size:11px"> y &lt; 0 </font><font color="#0000ff">Or</font><font style="font-size:11px"> y &gt; 479 </font><font color="#0000ff">Or</font><font style="font-size:11px"> z &lt;= 0) </font><font color="#0000ff">Then</font><font style="font-size:11px"> </font></td></tr> <tr> <td>            GraphicsWindow.RemoveShape(shape)  </td></tr> <tr> <td style="background-color:#f7f7f7">            NewStar()  </td></tr> <tr> <td>        <font color="#0000ff">Else</font><font style="font-size:11px"> </font></td></tr> <tr> <td style="background-color:#f7f7f7">            <font color="#008000">' Check if we should make the star brighter </font><font style="font-size:11px"> </font></td></tr> <tr> <td>            <font color="#0000ff">If</font><font style="font-size:11px">(z &lt; 0.4) </font><font color="#0000ff">Then</font><font style="font-size:11px"> </font></td></tr> <tr> <td style="background-color:#f7f7f7">                <font color="#0000ff">If</font><font style="font-size:11px">(Array.GetValue(</font><font color="#0000ff">&quot;star_color&quot;</font><font style="font-size:11px">, index) = 0) </font><font color="#0000ff">Then</font><font style="font-size:11px"> </font></td></tr> <tr> <td>                    GraphicsWindow.BrushColor = <font color="#0000ff">&quot;White&quot;</font><font style="font-size:11px"> </font></td></tr> <tr> <td style="background-color:#f7f7f7">                    GraphicsWindow.RemoveShape(shape)  </td></tr> <tr> <td>                    shape = GraphicsWindow.AddRectangle(2, 2)  </td></tr> <tr> <td style="background-color:#f7f7f7">                    Array.SetValue(<font color="#0000ff">&quot;star_shape&quot;</font><font style="font-size:11px">, index, shape)   </font></td></tr> <tr> <td>                    Array.SetValue(<font color="#0000ff">&quot;star_color&quot;</font><font style="font-size:11px">, index, 1)  </font></td></tr> <tr> <td style="background-color:#f7f7f7">                EndIf  </td></tr> <tr> <td>            EndIf  </td></tr> <tr> <td style="background-color:#f7f7f7">              </td></tr> <tr> <td>            GraphicsWindow.MoveShape(shape, x, y)  </td></tr> <tr> <td style="background-color:#f7f7f7">               </td></tr> <tr> <td>            Array.SetValue(<font color="#0000ff">&quot;star_z&quot;</font><font style="font-size:11px">, index, z)          </font></td></tr> <tr> <td style="background-color:#f7f7f7">        EndIf      </td></tr> <tr> <td>    EndFor  </td></tr> <tr> <td style="background-color:#f7f7f7">EndSub  </td></tr> <tr> <td> </td></tr> <tr> <td style="background-color:#f7f7f7"><font color="#0000ff">Sub</font><font style="font-size:11px"> Main  </font></td></tr> <tr> <td>    <font color="#008000">' Run forever </font><font style="font-size:11px"> </font></td></tr> <tr> <td style="background-color:#f7f7f7">    <font color="#0000ff">While</font><font style="font-size:11px">(1 = 1)  </font></td></tr> <tr> <td>        Update()  </td></tr> <tr> <td style="background-color:#f7f7f7">    EndWhile  </td></tr> <tr> <td>EndSub </td></tr></tbody></table></div><br><strong>Picture doesn't do this justice, as the real thing is like flying through space :-)</strong> <br><br><img alt="" src="http://i34.tinypic.com/2vlmi69.jpg"> Sun, 09 Nov 2008 00:27:25 Z2008-11-09T00:39:44Zhttp://social.msdn.microsoft.com/Forums/en-US/smallbasic/thread/eaacf826-9d12-4e3c-aa10-1b2788f160a6#b530ec94-acf2-4065-a787-c84666bd7b80http://social.msdn.microsoft.com/Forums/en-US/smallbasic/thread/eaacf826-9d12-4e3c-aa10-1b2788f160a6#b530ec94-acf2-4065-a787-c84666bd7b80Vijaye Rajihttp://social.msdn.microsoft.com/Profile/en-US/?user=Vijaye%20RajiPost your sample source code here and get featured on our blogs! Very nice, Jeff.  You can use RGB colors:<br><br>GraphicsWindow.BrushColor = &quot;#EEFFBB&quot;<br><br>GetPixel and SetPixel are raster operations and are inherently very inefficient.  Adding and moving shapes (like you have done) is the best way to achieve good performance in these kind of animations.<br>Sun, 09 Nov 2008 02:12:12 Z2008-11-09T02:12:12Zhttp://social.msdn.microsoft.com/Forums/en-US/smallbasic/thread/eaacf826-9d12-4e3c-aa10-1b2788f160a6#05e17cf2-6b8c-468e-ab81-c1d9f5cc576ahttp://social.msdn.microsoft.com/Forums/en-US/smallbasic/thread/eaacf826-9d12-4e3c-aa10-1b2788f160a6#05e17cf2-6b8c-468e-ab81-c1d9f5cc576aJeff Sidloskyhttp://social.msdn.microsoft.com/Profile/en-US/?user=Jeff%20SidloskyPost your sample source code here and get featured on our blogs! I had a delay in the main loop, then found out on a 3.2ghz Core 2 Duo, running as fast as the program can, it runs at a &quot;good&quot; speed. <br><br>This is kinda crappy though if you think about it, moving as fast as it can 200 stars at a time, it just runs &quot;okay&quot; on a 3.2ghz processor... :P   I guess the idea of Basic though isn't speed. <br><br>I wrote this same little program in Quick Basic back in 1993? on a 486 DX2-66, using an SVGA Library for speed and to wait on VSync, it was liquid smooth on that 66mhz processor, so on a 3.2ghz processor, i'd expect the program to run TOO FAST without a delay in there.<br><br>Does Small Basic convert to .NET byte code?  Are there future optimizations that could be done or am I just asking too much.  I know again SmallBasic's task isn't necessarily for &quot;game&quot; or graphics development.<br>Sun, 09 Nov 2008 02:50:08 Z2008-11-09T02:50:08Zhttp://social.msdn.microsoft.com/Forums/en-US/smallbasic/thread/eaacf826-9d12-4e3c-aa10-1b2788f160a6#f5325faf-65c0-4094-a1e7-91b2d214573dhttp://social.msdn.microsoft.com/Forums/en-US/smallbasic/thread/eaacf826-9d12-4e3c-aa10-1b2788f160a6#f5325faf-65c0-4094-a1e7-91b2d214573dRichard Gautierhttp://social.msdn.microsoft.com/Profile/en-US/?user=Richard%20GautierPost your sample source code here and get featured on our blogs!<span class=Apple-style-span style="font-size:12px">desktop.SetWallPaper(Flickr.GetRandomPicture(&quot;puppies&quot;))</span> <div><span class=Apple-style-span style="font-size:12px">Program.End()</span></div><div><span class=Apple-style-span style="font-size:12px"><br></span></div><div><span class=Apple-style-span style="font-size:12px">Short, sweet, and useful.  Interesting language you got there.</span></div>Sun, 09 Nov 2008 03:20:22 Z2008-11-09T03:20:22Zhttp://social.msdn.microsoft.com/Forums/en-US/smallbasic/thread/eaacf826-9d12-4e3c-aa10-1b2788f160a6#3040783e-ae6f-4499-babe-6e2f54436421http://social.msdn.microsoft.com/Forums/en-US/smallbasic/thread/eaacf826-9d12-4e3c-aa10-1b2788f160a6#3040783e-ae6f-4499-babe-6e2f54436421Richard Gautierhttp://social.msdn.microsoft.com/Profile/en-US/?user=Richard%20GautierPost your sample source code here and get featured on our blogs!<font><div style="overflow:auto;background-color:white;border:solid 1px #7f9db9;width:;height:;line-height:100% !important;font-family:Courier New;font-size:11px">Version 2 - I like this better - helps me find a picture I like interactively..</div><div style="overflow:auto;background-color:white;border:solid 1px #7f9db9;width:;height:;line-height:100% !important;font-family:Courier New;font-size:11px"><br></div><div style="overflow:auto;background-color:white;border:solid 1px #7f9db9;width:;height:;line-height:100% !important;font-family:Courier New;font-size:11px"><br><table cellpadding=0 cellspacing=0 style="width:99%;margin:2px 0px 2px 0px;border-collapse:collapse;border-bottom:2px solid #eee;background-color:#fff;border-width:0px"><col style="font-family:Courier New;font-size:11px;padding-left:10px;border-bottom:1px solid #F7F7F7;white-space:nowrap"><tbody><tr><td><font style="font-size:11px">While(word </font><font style="color:blue">&lt;</font><font style="font-size:11px">&gt; &quot;quit&quot;) </font></td></tr><tr><td style="background-color:#F7F7F7"> </td></tr><tr><td>TextWindow.Show() </td></tr><tr><td style="background-color:#F7F7F7"><font style="color:red">word</font><font style="font-size:11px"> = </font><font style="color:blue">TextWindow</font><font style="font-size:11px">.Read() </font></td></tr><tr><td>If( word <font style="color:blue">&lt;</font><font style="font-size:11px">&gt; &quot;quit&quot; )Then </font></td></tr><tr><td style="background-color:#F7F7F7">  Desktop.SetWallPaper(Flickr.GetRandomPicture(word)) </td></tr><tr><td> </td></tr><tr><td style="background-color:#F7F7F7">  TextWindow.Hide() </td></tr><tr><td>  Program.Delay(1000) </td></tr><tr><td style="background-color:#F7F7F7">  TextWindow.Show() </td></tr><tr><td>Else </td></tr><tr><td style="background-color:#F7F7F7">  TextWindow.Hide() </td></tr><tr><td>EndIf </td></tr><tr><td style="background-color:#F7F7F7">EndWhile </td></tr><tr><td>Program.End() </td></tr></tbody></table></div></font> Sun, 09 Nov 2008 03:53:23 Z2008-11-09T03:54:39Zhttp://social.msdn.microsoft.com/Forums/en-US/smallbasic/thread/eaacf826-9d12-4e3c-aa10-1b2788f160a6#ce76b823-18af-4522-81f1-de772e02b460http://social.msdn.microsoft.com/Forums/en-US/smallbasic/thread/eaacf826-9d12-4e3c-aa10-1b2788f160a6#ce76b823-18af-4522-81f1-de772e02b460xhablehttp://social.msdn.microsoft.com/Profile/en-US/?user=xhablePost your sample source code here and get featured on our blogs! Another turtle space filling curve, looks like I'm not the only one to write one :).. This one draws a hilbert curve.<br><br> <div style="border-bottom:#7f9db9 1px solid;border-left:#7f9db9 1px solid;line-height:100% !important;background-color:white;font-family:Courier New;font-size:11px;overflow:auto;border-top:#7f9db9 1px solid;border-right:#7f9db9 1px solid"> <table style="border-bottom:#eee 0px solid;border-right-width:0px;background-color:#fff;margin:2px 0px;width:99%;border-collapse:collapse;border-top-width:0px;border-left-width:0px" cellspacing=0 cellpadding=0> <colgroup> <col style="border-bottom:#f7f7f7 1px solid;padding-left:10px;font-family:Courier New;white-space:nowrap;font-size:11px"> <tbody> <tr> <td><font style="font-size:11px"><font color="#009900">TextWindow</font>.WriteLine(</font><font style="color:blue">&quot;Order:&quot;</font><font style="font-size:11px">)  </font></td></tr> <tr> <td style="background-color:#f7f7f7">n=<font color="#009900">TextWindow</font>.ReadNumber()  </td></tr> <tr> <td>n=n+<font color="#ff9900">1</font>  </td></tr> <tr> <td style="background-color:#f7f7f7"> </td></tr> <tr> <td>right()  </td></tr> <tr> <td style="background-color:#f7f7f7"> </td></tr> <tr> <td></font><font style="color:blue">Sub</font><font style="font-size:11px"> left  </font></td></tr> <tr> <td style="background-color:#f7f7f7">    i=i+<font color="#ff9900">1</font>  </td></tr> <tr> <td>    </font><font style="color:blue">If</font><font style="font-size:11px"> (i&lt;n) </font><font style="color:blue">Then</font><font style="font-size:11px"> </font></td></tr> <tr> <td style="background-color:#f7f7f7">        <font color="#009900">Turtle</font>.TurnRight()  </td></tr> <tr> <td>        right()  </td></tr> <tr> <td style="background-color:#f7f7f7">        <font color="#009900">Turtle</font>.Move(<font color="#ff9900">10</font>)  </td></tr> <tr> <td>        <font color="#009900">Turtle</font>.TurnLeft()  </td></tr> <tr> <td style="background-color:#f7f7f7">        left()  </td></tr> <tr> <td>        <font color="#009900">Turtle</font>.Move(<font color="#ff9900">10</font>)  </td></tr> <tr> <td style="background-color:#f7f7f7">        left()  </td></tr> <tr> <td>        <font color="#009900">Turtle</font>.TurnLeft()  </td></tr> <tr> <td style="background-color:#f7f7f7">        <font color="#009900">Turtle</font>.Move(<font color="#ff9900">10</font>)  </td></tr> <tr> <td>        right()  </td></tr> <tr> <td style="background-color:#f7f7f7">        <font color="#009900">Turtle</font>.TurnRight()  </td></tr> <tr> <td>    <font color="#3333ff">EndIf  </font></td></tr> <tr> <td style="background-color:#f7f7f7">    i=i-1  </td></tr> <tr> <td><font color="#3333ff">EndSub </font> </td></tr> <tr> <td style="background-color:#f7f7f7"></font><font style="color:blue">Sub</font><font style="font-size:11px"> right  </font></td></tr> <tr> <td>    i=i+1  </td></tr> <tr> <td style="background-color:#f7f7f7">    </font><font style="color:blue">If</font><font style="font-size:11px"> (i&lt;n) </font><font style="color:blue">Then</font><font style="font-size:11px"> </font></td></tr> <tr> <td>        <font color="#009900">Turtle</font>.TurnLeft()  </td></tr> <tr> <td style="background-color:#f7f7f7">        left()  </td></tr> <tr> <td>        <font color="#009900">Turtle</font>.Move(<font color="#ff9900">10</font>)  </td></tr> <tr> <td style="background-color:#f7f7f7">        <font color="#009900">Turtle</font>.TurnRight()  </td></tr> <tr> <td>        right()  </td></tr> <tr> <td style="background-color:#f7f7f7">        <font color="#009900">Turtle</font>.Move(<font color="#ff9900">10</font>)  </td></tr> <tr> <td>        right()  </td></tr> <tr> <td style="background-color:#f7f7f7">       <font color="#009900"> Turtle</font>.TurnRight()  </td></tr> <tr> <td>        <font color="#009900">Turtle</font>.Move(<font color="#ff9900">10</font>)  </td></tr> <tr> <td style="background-color:#f7f7f7">        left()  </td></tr> <tr> <td>        <font color="#009900">Turtle</font>.TurnLeft()  </td></tr> <tr> <td style="background-color:#f7f7f7">    <font color="#3333ff">EndIf </font> </td></tr> <tr> <td>    i=i-<font color="#ff9900">1 </font> </td></tr> <tr> <td style="background-color:#f7f7f7"><font color="#3333ff">EndSub </font></td></tr></tbody></table></div>Sun, 09 Nov 2008 11:25:18 Z2008-11-09T11:33:06Zhttp://social.msdn.microsoft.com/Forums/en-US/smallbasic/thread/eaacf826-9d12-4e3c-aa10-1b2788f160a6#263a19c8-5ffb-451c-8dc7-d55426edbe7ahttp://social.msdn.microsoft.com/Forums/en-US/smallbasic/thread/eaacf826-9d12-4e3c-aa10-1b2788f160a6#263a19c8-5ffb-451c-8dc7-d55426edbe7aPacolacohttp://social.msdn.microsoft.com/Profile/en-US/?user=PacolacoPost your sample source code here and get featured on our blogs!<font style="font-size:12px">I was just messing around with loops and the turtle, and decided I should make something fun. This will take any number x, draw a polygon with x number sides, and off of each side will be a perfect star.<br><br><br></font><div style="overflow:auto;background-color:white;line-height:100% ! important;font-family:Courier New;font-size:11px"><table style="border-width:0px;margin:2px 0px;width:99%;border-collapse:collapse;background-color:rgb(255, 255, 255)" cellpadding=0 cellspacing=0><col style="font-family:Courier New;font-size:11px;padding-left:10px;white-space:nowrap"><tbody><tr><td><font style="font-size:12px">GraphicsWindow.Height = 800 </font></td></tr><tr><td style="background-color:rgb(247, 247, 247)"><font style="font-size:12px">GraphicsWindow.Width = 800 </font></td></tr><tr><td><font style="font-size:12px">Turtle.Speed = 10 </font></td></tr><tr><td style="background-color:rgb(247, 247, 247)"><font style="font-size:12px"> </font></td></tr><tr><td><font style="font-size:12px">x = 75 </font></td></tr><tr><td style="background-color:rgb(247, 247, 247)"><font style="font-size:12px"> </font></td></tr><tr><td><font style="font-size:12px">Star: </font></td></tr><tr><td style="background-color:rgb(247, 247, 247)"><font style="color:blue;font-size:12px">While</font><font style="font-size:12px">( s &lt; 5 ) </font></td></tr><tr><td><font style="font-size:12px">    GraphicsWindow.PenColor = GraphicsWindow.GetRandomColor() </font></td></tr><tr><td style="background-color:rgb(247, 247, 247)"><font style="font-size:12px">    Turtle.Move(40) </font></td></tr><tr><td><font style="font-size:12px">    Turtle.Turn(144) </font></td></tr><tr><td style="background-color:rgb(247, 247, 247)"><font style="font-size:12px">    s = s + 1 </font></td></tr><tr><td><font style="font-size:12px">    </font><font style="color:blue;font-size:12px">While</font><font style="font-size:12px">(r &lt; (x - 1) ) </font></td></tr><tr><td style="background-color:rgb(247, 247, 247)"><font style="font-size:12px">        </font><font style="color:blue;font-size:12px">If</font><font style="font-size:12px">(s = 5) </font><font style="color:blue;font-size:12px">Then</font><font style="font-size:12px"> </font></td></tr><tr><td><font style="font-size:12px">           Turtle.Move(-75) </font></td></tr><tr><td style="background-color:rgb(247, 247, 247)"><font style="font-size:12px">           Turtle.Turn(360/x) </font></td></tr><tr><td><font style="font-size:12px">           Turtle.Move(100) </font></td></tr><tr><td style="background-color:rgb(247, 247, 247)"><font style="font-size:12px">           s = 0 </font></td></tr><tr><td><font style="font-size:12px">           r = r + 1 </font></td></tr><tr><td style="background-color:rgb(247, 247, 247)"><font style="font-size:12px">        </font><font style="color:blue;font-size:12px">Else</font><font style="font-size:12px"> </font></td></tr><tr><td><font style="font-size:12px">            Goto Star </font></td></tr><tr><td style="background-color:rgb(247, 247, 247)"><font style="font-size:12px">        EndIf </font></td></tr><tr><td><font style="font-size:12px">    EndWhile </font></td></tr><tr><td style="background-color:rgb(247, 247, 247)"><font style="font-size:12px">EndWhile </font></td></tr></tbody></table></div><font style="font-size:12px"><br></font>Sun, 09 Nov 2008 16:04:46 Z2008-11-09T16:04:46Zhttp://social.msdn.microsoft.com/Forums/en-US/smallbasic/thread/eaacf826-9d12-4e3c-aa10-1b2788f160a6#8a75f4a8-6b75-44bd-85d4-4ab5ea7bfc8ehttp://social.msdn.microsoft.com/Forums/en-US/smallbasic/thread/eaacf826-9d12-4e3c-aa10-1b2788f160a6#8a75f4a8-6b75-44bd-85d4-4ab5ea7bfc8eAndrew Burtonhttp://social.msdn.microsoft.com/Profile/en-US/?user=Andrew%20BurtonPost your sample source code here and get featured on our blogs!<div class=quote><span class=quoteHeader>Beth Massi said:</span> I wanted to actually scale the images instead of a fixed height and width but unfortunately the call the ImageList.GetWidthOfImage() keeps crashing (GetHeightOfImage works <br> fine). Anybody have any clues?</div> No clues, but I can confirm ImageList.GetWidthOfImage() crashes on WinXP too.<hr size="1" align="left" width="25%">Andrew Burton - http://profnano.orgSun, 09 Nov 2008 21:42:45 Z2008-11-09T21:42:45Zhttp://social.msdn.microsoft.com/Forums/en-US/smallbasic/thread/eaacf826-9d12-4e3c-aa10-1b2788f160a6#a4ce47f6-5c62-41e5-bfd8-95d1c04dd9c5http://social.msdn.microsoft.com/Forums/en-US/smallbasic/thread/eaacf826-9d12-4e3c-aa10-1b2788f160a6#a4ce47f6-5c62-41e5-bfd8-95d1c04dd9c5xhablehttp://social.msdn.microsoft.com/Profile/en-US/?user=xhablePost your sample source code here and get featured on our blogs!Draws A fractual branch of a tree.<br><br>  <div style="border-bottom:#7f9db9 1px solid;border-left:#7f9db9 1px solid;line-height:100% !important;background-color:white;font-family:Courier New;font-size:11px;overflow:auto;border-top:#7f9db9 1px solid;border-right:#7f9db9 1px solid"> <table style="border-bottom:#eee 0px solid;border-right-width:0px;background-color:#fff;margin:2px 0px;width:99%;border-collapse:collapse;border-top-width:0px;border-left-width:0px" cellspacing=0 cellpadding=0> <colgroup> <col style="border-bottom:#f7f7f7 1px solid;padding-left:10px;font-family:Courier New;white-space:nowrap;font-size:11px"> <tbody> <tr> <td><font style="font-size:11px">n=7  </font></td></tr> <tr> <td style="background-color:#f7f7f7">angle=45  </td></tr> <tr> <td>x=0  </td></tr> <tr> <td style="background-color:#f7f7f7">y=0  </td></tr> <tr> <td>GraphicsWindow.Title=</font><font style="color:blue">&quot;Fractal Plant&quot;</font><font style="font-size:11px"> </font></td></tr> <tr> <td style="background-color:#f7f7f7">GraphicsWindow.PenWidth=0.5  </td></tr> <tr> <td>GraphicsWindow.PenColor = </font><font style="color:blue">&quot;White&quot;</font><font style="font-size:11px"> </font></td></tr> <tr> <td style="background-color:#f7f7f7">GraphicsWindow.Width=700  </td></tr> <tr> <td>GraphicsWindow.Height=500  </td></tr> <tr> <td style="background-color:#f7f7f7">GraphicsWindow.BackgroundColor=</font><font style="color:blue">&quot;Black&quot;</font><font style="font-size:11px"> </font></td></tr> <tr> <td>GraphicsWindow.Show()  </td></tr> <tr> <td style="background-color:#f7f7f7"> </td></tr> <tr> <td>X()  </td></tr> <tr> <td style="background-color:#f7f7f7"></font><font style="color:blue">Sub</font><font style="font-size:11px"> X  </font></td></tr> <tr> <td>    i=i+1     </td></tr> <tr> <td style="background-color:#f7f7f7">    </font><font style="color:blue">If</font><font style="font-size:11px"> (i&lt;n) </font><font style="color:blue">Then</font><font style="font-size:11px"> </font></td></tr> <tr> <td>        F()  </td></tr> <tr> <td style="background-color:#f7f7f7">        angle=angle-25  </td></tr> <tr> <td>        Store()  </td></tr> <tr> <td style="background-color:#f7f7f7">        Store()  </td></tr> <tr> <td>        X()  </td></tr> <tr> <td style="background-color:#f7f7f7">        </font><font style="color:blue">Get</font><font style="font-size:11px">()  </font></td></tr> <tr> <td>        angle=angle+25  </td></tr> <tr> <td style="background-color:#f7f7f7">        X()  </td></tr> <tr> <td>        </font><font style="color:blue">Get</font><font style="font-size:11px">()  </font></td></tr> <tr> <td style="background-color:#f7f7f7">        angle=angle+25  </td></tr> <tr> <td>        F()  </td></tr> <tr> <td style="background-color:#f7f7f7">        Store()  </td></tr> <tr> <td>        angle=angle+25  </td></tr> <tr> <td style="background-color:#f7f7f7">        F()  </td></tr> <tr> <td>        X()  </td></tr> <tr> <td style="background-color:#f7f7f7">        </font><font style="color:blue">Get</font><font style="font-size:11px">()  </font></td></tr> <tr> <td>        angle=angle-25  </td></tr> <tr> <td style="background-color:#f7f7f7">        X()  </td></tr> <tr> <td>          </td></tr> <tr> <td style="background-color:#f7f7f7">    EndIf  </td></tr> <tr> <td>    i=i-1  </td></tr> <tr> <td style="background-color:#f7f7f7">EndSub  </td></tr> <tr> <td> </td></tr> <tr> <td style="background-color:#f7f7f7"></font><font style="color:blue">Sub</font><font style="font-size:11px"> Store  </font></td></tr> <tr> <td>    Stack.PushValue(</font><font style="color:blue">&quot;tree&quot;</font><font style="font-size:11px">,x)  </font></td></tr> <tr> <td style="background-color:#f7f7f7">    Stack.PushValue(</font><font style="color:blue">&quot;tree&quot;</font><font style="font-size:11px">,y)  </font></td></tr> <tr> <td>    Stack.PushValue(</font><font style="color:blue">&quot;tree&quot;</font><font style="font-size:11px">,angle)  </font></td></tr> <tr> <td style="background-color:#f7f7f7">EndSub    </td></tr> <tr> <td> </td></tr> <tr> <td style="background-color:#f7f7f7"></font><font style="color:blue">Sub</font><font style="font-size:11px"> </font><font style="color:blue">Get</font><font style="font-size:11px"> </font></td></tr> <tr> <td>    angle=Stack.PopValue(</font><font style="color:blue">&quot;tree&quot;</font><font style="font-size:11px">)  </font></td></tr> <tr> <td style="background-color:#f7f7f7">    y=Stack.PopValue(</font><font style="color:blue">&quot;tree&quot;</font><font style="font-size:11px">)  </font></td></tr> <tr> <td>    x=Stack.PopValue(</font><font style="color:blue">&quot;tree&quot;</font><font style="font-size:11px">)  </font></td></tr> <tr> <td style="background-color:#f7f7f7">EndSub  </td></tr> <tr> <td> </td></tr> <tr> <td style="background-color:#f7f7f7"></font><font style="color:blue">Sub</font><font style="font-size:11px"> F  </font></td></tr> <tr> <td>    i=i+1  </td></tr> <tr> <td style="background-color:#f7f7f7">    </font><font style="color:blue">If</font><font style="font-size:11px"> (i&lt;n) </font><font style="color:blue">Then</font><font style="font-size:11px"> </font></td></tr> <tr> <td>        x2=x+(Math.Sin(angle))*4  </td></tr> <tr> <td style="background-color:#f7f7f7">        y2=y+(Math.Cos(angle))*4  </td></tr> <tr> <td>        GraphicsWindow.AddLine(x,y,x2,y2)  </td></tr> <tr> <td style="background-color:#f7f7f7">        x=x2  </td></tr> <tr> <td>        y=y2  </td></tr> <tr> <td style="background-color:#f7f7f7">        F()  </td></tr> <tr> <td>        F()  </td></tr> <tr> <td style="background-color:#f7f7f7">    EndIf  </td></tr> <tr> <td>    i=i-1  </td></tr> <tr> <td style="background-color:#f7f7f7">EndSub </td></tr></tbody></table></div>Sun, 09 Nov 2008 23:22:02 Z2008-11-09T23:22:02Zhttp://social.msdn.microsoft.com/Forums/en-US/smallbasic/thread/eaacf826-9d12-4e3c-aa10-1b2788f160a6#62562571-2539-4d96-9967-ed1d3ef56eaahttp://social.msdn.microsoft.com/Forums/en-US/smallbasic/thread/eaacf826-9d12-4e3c-aa10-1b2788f160a6#62562571-2539-4d96-9967-ed1d3ef56eaaGeorge Birbilishttp://social.msdn.microsoft.com/Profile/en-US/?user=George%20BirbilisPost your sample source code here and get featured on our blogs!Regarding the start field program, obviously the issue is the repaint caused by SetPixel which also causes the flashing (the flashing is probably cause that repaint also erases the background first and then redraws? [this is classic issue - in Windows you'd disable the background repaint of that window control]). <br><br>Apart from setting flags to the window handle to not repaint its background (or overriding the respective method of the control used in your .NET app) one also needs some method to batch graphics commands. From my experience the best is a command-block (internally implemented with try/finally), doing:<br><br>StartGraphics<br> ...commands...<br>EndGraphics<br><br>this has to be in the language syntax (better for naive users) if the language doesn't support lambda lists to make the above some BatchUpdate(graphics-commands-as-a-lambda-list) call<br><br>cause also call those StartRefresh/EndRefresh, StartUpdate/EndUpdate or whatever sounds explanatory enough for the end user <hr align=left size=1 width="25%"> Microsoft MVP J# 2004-2007, Borland Spirit of Delphi 2001Mon, 10 Nov 2008 10:03:50 Z2008-11-10T10:05:03Zhttp://social.msdn.microsoft.com/Forums/en-US/smallbasic/thread/eaacf826-9d12-4e3c-aa10-1b2788f160a6#52564ad7-1f27-467a-9af2-1000558db849http://social.msdn.microsoft.com/Forums/en-US/smallbasic/thread/eaacf826-9d12-4e3c-aa10-1b2788f160a6#52564ad7-1f27-467a-9af2-1000558db849George Birbilishttp://social.msdn.microsoft.com/Profile/en-US/?user=George%20BirbilisPost your sample source code here and get featured on our blogs!Regarding getWidthOfImage (why not getImageWidth?), maybe the image hasn't yet loaded? (they should wait for it to load or have an option if you want to wait or not). Can try polling the image in a loop (do a small sleep at each loop) till it gets a width or if you can't try/catch errors in SmallBasic (don't remember), just wait for some long enough (?) period first and then try to call the method <hr align=left size=1 width="25%"> Microsoft MVP J# 2004-2007, Borland Spirit of Delphi 2001Mon, 10 Nov 2008 10:08:19 Z2008-11-10T10:09:16Zhttp://social.msdn.microsoft.com/Forums/en-US/smallbasic/thread/eaacf826-9d12-4e3c-aa10-1b2788f160a6#fef20b2a-08e4-4f40-af5f-92a2014d5711http://social.msdn.microsoft.com/Forums/en-US/smallbasic/thread/eaacf826-9d12-4e3c-aa10-1b2788f160a6#fef20b2a-08e4-4f40-af5f-92a2014d5711benryveshttp://social.msdn.microsoft.com/Profile/en-US/?user=benryvesPost your sample source code here and get featured on our blogs!<p>This seems a fun language to play around with. :-) I'm a big fan of spinning 3D cubes. I'm sure there's a nicer way of implementing this - it is a bit flickery, so consider yourself warned.</p> <div style="overflow:auto;background-color:white;border:solid 1px #7f9db9;width:;height:;line-height:100% !important;font-family:courier new;font-size:11px"> <table cellpadding=0 cellspacing=0 style="width:99%;margin:2px 0px 2px 0px;border-collapse:collapse;border-bottom:2px solid #eee;background-color:#fff;border-width:0px"><tbody><tr><td><font style="font-size:11px">GraphicsWindow.Title = </font><font style="color:blue">&quot;Spinning Cube&quot;</font><font style="font-size:11px">  </font></td></tr><tr><td style="background-color:#f7f7f7">GraphicsWindow.Show()  </td></tr><tr><td>  </td></tr><tr><td style="background-color:#f7f7f7">Time = 0  </td></tr><tr><td>  </td></tr><tr><td style="background-color:#f7f7f7">MainLoop:  </td></tr><tr><td>  </td></tr><tr><td style="background-color:#f7f7f7">    RotationX = Time / 30  </td></tr><tr><td>    RotationY = Time / 40  </td></tr><tr><td style="background-color:#f7f7f7">    Scale = Math.Min(GraphicsWindow.Width, GraphicsWindow.Height) * (1.2 + Math.Sin(Time / 50)) * 0.5  </td></tr><tr><td>    Time = Time + 1  </td></tr><tr><td style="background-color:#f7f7f7">  </td></tr><tr><td>    GraphicsWindow.Clear()  </td></tr><tr><td style="background-color:#f7f7f7">  </td></tr><tr><td>    GraphicsWindow.PenWidth = Scale / 200  </td></tr><tr><td style="background-color:#f7f7f7">  </td></tr><tr><td>    <font style="color:blue">For</font><font style="font-size:11px"> x = -1 </font><font style="color:blue">To</font><font style="font-size:11px"> 1 </font><font style="color:blue">Step</font><font style="font-size:11px"> 2  </font></td></tr><tr><td style="background-color:#f7f7f7">        <font style="color:blue">For</font><font style="font-size:11px"> y = -1 </font><font style="color:blue">To</font><font style="font-size:11px"> 1 </font><font style="color:blue">Step</font><font style="font-size:11px"> 2  </font></td></tr><tr><td>            z = -1  </td></tr><tr><td style="background-color:#f7f7f7">            TransformPoint()  </td></tr><tr><td>            StartX = TransformedX  </td></tr><tr><td style="background-color:#f7f7f7">            StartY = TransformedY  </td></tr><tr><td>            z = 1  </td></tr><tr><td style="background-color:#f7f7f7">            TransformPoint()  </td></tr><tr><td>            GraphicsWindow.AddLine(StartX, StartY, TransformedX, TransformedY)  </td></tr><tr><td style="background-color:#f7f7f7">        EndFor  </td></tr><tr><td>    EndFor  </td></tr><tr><td style="background-color:#f7f7f7">  </td></tr><tr><td>    <font style="color:blue">For</font><font style="font-size:11px"> x = -1 </font><font style="color:blue">To</font><font style="font-size:11px"> 1 </font><font style="color:blue">Step</font><font style="font-size:11px"> 2  </font></td></tr><tr><td style="background-color:#f7f7f7">        <font style="color:blue">For</font><font style="font-size:11px"> z = -1 </font><font style="color:blue">To</font><font style="font-size:11px"> 1 </font><font style="color:blue">Step</font><font style="font-size:11px"> 2  </font></td></tr><tr><td>            y = -1  </td></tr><tr><td style="background-color:#f7f7f7">            TransformPoint()  </td></tr><tr><td>            StartX = TransformedX  </td></tr><tr><td style="background-color:#f7f7f7">            StartY = TransformedY  </td></tr><tr><td>            y = 1  </td></tr><tr><td style="background-color:#f7f7f7">            TransformPoint()  </td></tr><tr><td>            GraphicsWindow.AddLine(StartX, StartY, TransformedX, TransformedY)  </td></tr><tr><td style="background-color:#f7f7f7">        EndFor  </td></tr><tr><td>    EndFor  </td></tr><tr><td style="background-color:#f7f7f7">  </td></tr><tr><td>    <font style="color:blue">For</font><font style="font-size:11px"> z = -1 </font><font style="color:blue">To</font><font style="font-size:11px"> 1 </font><font style="color:blue">Step</font><font style="font-size:11px"> 2  </font></td></tr><tr><td style="background-color:#f7f7f7">        <font style="color:blue">For</font><font style="font-size:11px"> y = -1 </font><font style="color:blue">To</font><font style="font-size:11px"> 1 </font><font style="color:blue">Step</font><font style="font-size:11px"> 2  </font></td></tr><tr><td>            x = -1  </td></tr><tr><td style="background-color:#f7f7f7">            TransformPoint()  </td></tr><tr><td>            StartX = TransformedX  </td></tr><tr><td style="background-color:#f7f7f7">            StartY = TransformedY  </td></tr><tr><td>            x = 1  </td></tr><tr><td style="background-color:#f7f7f7">            TransformPoint()  </td></tr><tr><td>            GraphicsWindow.AddLine(StartX, StartY, TransformedX, TransformedY)  </td></tr><tr><td style="background-color:#f7f7f7">        EndFor  </td></tr><tr><td>    EndFor  </td></tr><tr><td style="background-color:#f7f7f7">  </td></tr><tr><td>    Program.Delay(10)  </td></tr><tr><td style="background-color:#f7f7f7">  </td></tr><tr><td>Goto MainLoop  </td></tr><tr><td style="background-color:#f7f7f7">  </td></tr><tr><td><font style="color:green">'  Inputs: x, y, z, RotationX, RotationY, Scale. Outputs: TransformedX, TransformedY.</font><font style="font-size:11px">  </font></td></tr><tr><td style="background-color:#f7f7f7"><font style="color:blue">Sub</font><font style="font-size:11px"> TransformPoint  </font></td></tr><tr><td>  </td></tr><tr><td style="background-color:#f7f7f7">    TransformedX = y * Math.Cos(RotationX) - x * Math.Sin(RotationX)  </td></tr><tr><td>    TransformedY = -x * Math.Cos(RotationX) * Math.Sin(RotationY) - y * Math.Sin(RotationX) * Math.Sin(RotationY) - z * Math.Cos(RotationY)  </td></tr><tr><td style="background-color:#f7f7f7">    TransformedZ = 3 - x * Math.Cos(RotationX) * Math.Cos(RotationY) - y * Math.Sin(RotationX) * Math.Cos(RotationY) + z * Math.Sin(RotationY)  </td></tr><tr><td>      </td></tr><tr><td style="background-color:#f7f7f7">    TransformedX = TransformedX * Scale / TransformedZ + GraphicsWindow.Width / 2  </td></tr><tr><td>    TransformedY = TransformedY * Scale / TransformedZ + GraphicsWindow.Height / 2  </td></tr><tr><td style="background-color:#f7f7f7">  </td></tr><tr><td>EndSub </td></tr></tbody></table> </div> Mon, 10 Nov 2008 19:06:20 Z2008-11-10T19:06:20Zhttp://social.msdn.microsoft.com/Forums/en-US/smallbasic/thread/eaacf826-9d12-4e3c-aa10-1b2788f160a6#b9275494-7466-488a-97bd-0936e0a17f99http://social.msdn.microsoft.com/Forums/en-US/smallbasic/thread/eaacf826-9d12-4e3c-aa10-1b2788f160a6#b9275494-7466-488a-97bd-0936e0a17f99B0ff1nhttp://social.msdn.microsoft.com/Profile/en-US/?user=B0ff1nPost your sample source code here and get featured on our blogs! I've been enjoying working in SmallBasic; it takes me back to when I had a ZX81. I took the paddle game sample and made it work, increase in difficulty and allow the player more control of the angle and speed of the &quot;ball&quot;; next to add breakout style blocks to destroy.<br>B0ff1n<br><br> <div style="border-right:#7f9db9 1px solid;border-top:#7f9db9 1px solid;font-size:11px;overflow:auto;border-left:#7f9db9 1px solid;line-height:100%! important;border-bottom:#7f9db9 1px solid;font-family:Courier New;background-color:white"> <table style="border-top-width:0px;border-left-width:0px;margin:2px 0px;width:99%;border-bottom:#eee 0px solid;border-collapse:collapse;background-color:#fff;border-right-width:0px" cellspacing=0 cellpadding=0> <colgroup> <col style="padding-left:10px;font-size:11px;border-bottom:#f7f7f7 1px solid;font-family:Courier New;white-space:nowrap"> <tbody> <tr> <td><font style="font-size:11px">paddle = GraphicsWindow.AddRectangle(120, 12)  </font></td></tr> <tr> <td style="background-color:#f7f7f7">ball = GraphicsWindow.AddEllipse(16, 16)  </td></tr> <tr> <td>speed=9  </td></tr> <tr> <td style="background-color:#f7f7f7">GraphicsWindow.FontSize = 16  </td></tr> <tr> <td>GraphicsWindow.MouseMove = OnMouseMove  </td></tr> <tr> <td style="background-color:#f7f7f7">lives = 3  </td></tr> <tr> <td>score = 0  </td></tr> <tr> <td style="background-color:#f7f7f7">gw = Math.Floor( GraphicsWindow.Width - 8 )  </td></tr> <tr> <td>gh = Math.Floor( GraphicsWindow.Height - 20 )  </td></tr> <tr> <td style="background-color:#f7f7f7"> </td></tr> <tr> <td></font><font style="color:blue">While</font><font style="font-size:11px"> (lives&gt;0)  </font></td></tr> <tr> <td style="background-color:#f7f7f7"> </td></tr> <tr> <td>    x = Math.GetRandomNumber(gw)  </td></tr> <tr> <td style="background-color:#f7f7f7">    y = 36  </td></tr> <tr> <td>    deltaX = 1  </td></tr> <tr> <td style="background-color:#f7f7f7">    deltaY = 2  </td></tr> <tr> <td>    GraphicsWindow.MoveShape(ball, (x-8), y)  </td></tr> <tr> <td style="background-color:#f7f7f7"> </td></tr> <tr> <td>    PrintScore()  </td></tr> <tr> <td style="background-color:#f7f7f7"></font><font style="color:green">'    Sound.PlayChimeAndWait()     </font><font style="font-size:11px"> </font></td></tr> <tr> <td>    </font><font style="color:blue">For</font><font style="font-size:11px"> i=1 </font><font style="color:blue">To</font><font style="font-size:11px"> 20  </font></td></tr> <tr> <td style="background-color:#f7f7f7">      GraphicsWindow.BrushColor = GraphicsWindow.GetRandomColor()  </td></tr> <tr> <td>      GraphicsWindow.DrawText(300, 150, </font><font style="color:blue">&quot;Get Ready!&quot;</font><font style="font-size:11px">)  </font></td></tr> <tr> <td style="background-color:#f7f7f7">      Program.Delay(50)  </td></tr> <tr> <td>    EndFor  </td></tr> <tr> <td style="background-color:#f7f7f7">    GraphicsWindow.BrushColor = </font><font style="color:blue">&quot;White&quot;</font><font style="font-size:11px"> </font></td></tr> <tr> <td>    GraphicsWindow.FillRectangle(10, 100, 630, 200)  </td></tr> <tr> <td style="background-color:#f7f7f7"> </td></tr> <tr> <td>    </font><font style="color:blue">While</font><font style="font-size:11px"> (y &lt; (gh+2))   </font></td></tr> <tr> <td style="background-color:#f7f7f7"> </td></tr> <tr> <td>      x = x + deltaX  </td></tr> <tr> <td style="background-color:#f7f7f7">      y = y + deltaY  </td></tr> <tr> <td>        </td></tr> <tr> <td style="background-color:#f7f7f7">      </font><font style="color:blue">If</font><font style="font-size:11px"> (x &gt;= gw </font><font style="color:blue">Or</font><font style="font-size:11px"> x &lt;= 8) </font><font style="color:blue">Then</font><font style="font-size:11px"> </font></td></tr> <tr> <td>        deltaX = -deltaX  </td></tr> <tr> <td style="background-color:#f7f7f7">      EndIf  </td></tr> <tr> <td>      </font><font style="color:blue">If</font><font style="font-size:11px"> (y &lt;= 36) </font><font style="color:blue">Then</font><font style="font-size:11px"> </font></td></tr> <tr> <td style="background-color:#f7f7f7">        deltaY = -deltaY  </td></tr> <tr> <td>      EndIf  </td></tr> <tr> <td style="background-color:#f7f7f7"> </td></tr> <tr> <td>      GraphicsWindow.MoveShape(ball, (x-8), y)  </td></tr> <tr> <td style="background-color:#f7f7f7">       </td></tr> <tr> <td>      padX = GraphicsWindow.GetLeftOfShape(paddle)  </td></tr> <tr> <td style="background-color:#f7f7f7">      </font><font style="color:green">'TextWindow.WriteLine(&quot;X:&quot;+x+&quot; Y:&quot;+y+&quot; padX:&quot;+padX+&quot; gh:&quot;+gh) </font><font style="font-size:11px"> </font></td></tr> <tr> <td>      </font><font style="color:blue">If</font><font style="font-size:11px"> (y &gt;= gh) </font><font style="color:blue">Then</font><font style="font-size:11px"> </font></td></tr> <tr> <td style="background-color:#f7f7f7">        </font><font style="color:green">'TextWindow.WriteLine(&quot;Testing for collision&quot;) </font><font style="font-size:11px"> </font></td></tr> <tr> <td>        </font><font style="color:blue">If</font><font style="font-size:11px"> (x &gt;= padX </font><font style="color:blue">And</font><font style="font-size:11px"> x &lt;= padX + 120) </font><font style="color:blue">Then</font><font style="font-size:11px"> </font></td></tr> <tr> <td style="background-color:#f7f7f7">          </font><font style="color:green">'TextWindow.WriteLine(&quot;Hit!&quot;) </font><font style="font-size:11px"> </font></td></tr> <tr> <td>          Sound.PlayClick()  </td></tr> <tr> <td style="background-color:#f7f7f7">          score = score + 10  </td></tr> <tr> <td>          PrintScore()  </td></tr> <tr> <td style="background-color:#f7f7f7">          deltaY = -deltaY  </td></tr> <tr> <td>          </font><font style="color:green">'did the user hit the ball with the very edge of the paddle?  </font><font style="font-size:11px"> </font></td></tr> <tr> <td style="background-color:#f7f7f7">          </font><font style="color:blue">If</font><font style="font-size:11px"> (x&lt;=padx+40 </font><font style="color:blue">Or</font><font style="font-size:11px"> x&gt;=padx+80) then  </font></td></tr> <tr> <td>            </font><font style="color:blue">If</font><font style="font-size:11px"> (x&lt;=padx+20 </font><font style="color:blue">And</font><font style="font-size:11px"> deltaX&gt;0) then  </font></td></tr> <tr> <td style="background-color:#f7f7f7">              </font><font style="color:green">'*user hit the ball with the &quot;corner&quot; of the paddle; reverse the x-direction too </font><font style="font-size:11px"> </font></td></tr> <tr> <td>              deltaX = -deltaX  </td></tr> <tr> <td style="background-color:#f7f7f7">            EndIf  </td></tr> <tr> <td>            </font><font style="color:blue">If</font><font style="font-size:11px"> (x&gt;=padx+100 </font><font style="color:blue">And</font><font style="font-size:11px"> deltaX&lt;0) then  </font></td></tr> <tr> <td style="background-color:#f7f7f7">              </font><font style="color:green">'*user hit the ball with the &quot;corner&quot; of the paddle; reverse the x-direction too </font><font style="font-size:11px"> </font></td></tr> <tr> <td>              deltaX = -deltaX  </td></tr> <tr> <td style="background-color:#f7f7f7">            EndIf  </td></tr> <tr> <td>            </font><font style="color:blue">If</font><font style="font-size:11px"> (Math.Abs( deltaX )&lt;2) </font><font style="color:blue">Then</font><font style="font-size:11px"> </font></td></tr> <tr> <td style="background-color:#f7f7f7">              deltaX = deltaX*2  </td></tr> <tr> <td>            EndIf  </td></tr> <tr> <td style="background-color:#f7f7f7">          </font><font style="color:blue">Else</font><font style="font-size:11px"> </font></td></tr> <tr> <td>            </font><font style="color:blue">If</font><font style="font-size:11px"> (Math.Abs(deltaX)&gt;1) </font><font style="color:blue">Then</font><font style="font-size:11px"> </font></td></tr> <tr> <td style="background-color:#f7f7f7">              deltaX = deltaX/2  </td></tr> <tr> <td>            EndIf  </td></tr> <tr> <td style="background-color:#f7f7f7">          EndIf  </td></tr> <tr> <td>          </font><font style="color:blue">If</font><font style="font-size:11px"> (Math.Remainder(score,50)=0) </font><font style="color:blue">Then</font><font style="font-size:11px"> </font></td></tr> <tr> <td style="background-color:#f7f7f7">            speed=speed-1  </td></tr> <tr> <td>            </font><font style="color:blue">If</font><font style="font-size:11px"> (speed&lt;1) </font><font style="color:blue">Then</font><font style="font-size:11px"> </font></td></tr> <tr> <td style="background-color:#f7f7f7">              speed=1  </td></tr> <tr> <td>            EndIf  </td></tr> <tr> <td style="background-color:#f7f7f7">          EndIf   </td></tr> <tr> <td>        </font><font style="color:green">'Else </font><font style="font-size:11px"> </font></td></tr> <tr> <td style="background-color:#f7f7f7">          </font><font style="color:green">'TextWindow.WriteLine(&quot;Missed!&quot;) </font><font style="font-size:11px"> </font></td></tr> <tr> <td>        EndIf  </td></tr> <tr> <td style="background-color:#f7f7f7">      EndIf  </td></tr> <tr> <td> </td></tr> <tr> <td style="background-color:#f7f7f7"></font><font style="color:green">'      GraphicsWindow.MoveShape(ball, (x-8), y) </font><font style="font-size:11px"> </font></td></tr> <tr> <td>        </td></tr> <tr> <td style="background-color:#f7f7f7">      Program.Delay(speed)  </td></tr> <tr> <td>        </td></tr> <tr> <td style="background-color:#f7f7f7">    EndWhile  </td></tr> <tr> <td>    lives = lives - 1  </td></tr> <tr> <td style="background-color:#f7f7f7">EndWhile  </td></tr> <tr> <td>GraphicsWindow.ShowMessage(</font><font style="color:blue">&quot;You scored : &quot;</font><font style="font-size:11px"> + score+ </font><font style="color:blue">&quot; points&quot;</font><font style="font-size:11px">, </font><font style="color:blue">&quot;Paddle - Game Over&quot;</font><font style="font-size:11px">)  </font></td></tr> <tr> <td style="background-color:#f7f7f7">Program.</font><font style="color:blue">End</font><font style="font-size:11px">()  </font></td></tr> <tr> <td> </td></tr> <tr> <td style="background-color:#f7f7f7"></font><font style="color:blue">Sub</font><font style="font-size:11px"> OnMouseMove  </font></td></tr> <tr> <td>  paddleX = GraphicsWindow.MouseX  </td></tr> <tr> <td style="background-color:#f7f7f7">  GraphicsWindow.MoveShape(paddle, paddleX - 60, GraphicsWindow.Height - 12)  </td></tr> <tr> <td>EndSub  </td></tr> <tr> <td style="background-color:#f7f7f7"> </td></tr> <tr> <td></font><font style="color:blue">Sub</font><font style="font-size:11px"> PrintScore  </font></td></tr> <tr> <td style="background-color:#f7f7f7">  </font><font style="color:green">' Clear the score first and then draw the real score text </font><font style="font-size:11px"> </font></td></tr> <tr> <td>  GraphicsWindow.BrushColor = </font><font style="color:blue">&quot;White&quot;</font><font style="font-size:11px"> </font></td></tr> <tr> <td style="background-color:#f7f7f7">  GraphicsWindow.FillRectangle(10, 10, 630, 20)  </td></tr> <tr> <td>  GraphicsWindow.BrushColor = </font><font style="color:blue">&quot;Black&quot;</font><font style="font-size:11px"> </font></td></tr> <tr> <td style="background-color:#f7f7f7">  GraphicsWindow.DrawText(10, 10, </font><font style="color:blue">&quot;Score: &quot;</font><font style="font-size:11px"> + score)  </font></td></tr> <tr> <td>  GraphicsWindow.DrawText(300, 10, </font><font style="color:blue">&quot;Lives: &quot;</font><font style="font-size:11px"> + lives)  </font></td></tr> <tr> <td style="background-color:#f7f7f7">  GraphicsWindow.DrawText(540, 10, </font><font style="color:blue">&quot;Speed: &quot;</font><font style="font-size:11px"> +speed)  </font></td></tr> <tr> <td>EndSub  </td></tr> <tr> <td style="background-color:#f7f7f7"> </td></tr></tbody></table></div><br>The reason why the original sample didn't work for me was that the graphicswindow.height was returning 480.1 and was comparing the y-ordinate to be exactly that; hence my use of math.floor and some &gt;'s rather than ='s.<br>Great stuff though; now why can't Visual Studio be this good?<br>Tue, 11 Nov 2008 16:01:59 Z2008-11-11T16:03:32Zhttp://social.msdn.microsoft.com/Forums/en-US/smallbasic/thread/eaacf826-9d12-4e3c-aa10-1b2788f160a6#1d853fbc-868f-4238-a7e9-2fd06a50d87bhttp://social.msdn.microsoft.com/Forums/en-US/smallbasic/thread/eaacf826-9d12-4e3c-aa10-1b2788f160a6#1d853fbc-868f-4238-a7e9-2fd06a50d87bbmatthew1http://social.msdn.microsoft.com/Profile/en-US/?user=bmatthew1Post your sample source code here and get featured on our blogs!Inside the Small Basic Samples folder there's a Fractal example; the fractal is a Sierpinski Triangle. Having written Sierpinski Triangles in other BASIC dialects such as Basic4GL &amp; Brutus2D, I thought I'd write a new version in Small Basic.<br> <br> <img src="http://suse-images.wikispaces.com/space/showimage/sierpinski_pic.png"><br><br><br> <div style="overflow:auto;background-color:white;line-height:100% ! important;font-family:Courier New;font-size:11px"><table style="border-width:0px;margin:2px 0px;width:99%;border-collapse:collapse;background-color:rgb(255, 255, 255)" cellpadding=0 cellspacing=0><col style="font-family:Courier New;font-size:11px;padding-left:10px;white-space:nowrap"><tbody><tr><td><font style="font-size:11px"> </font></td></tr><tr><td style="background-color:rgb(247, 247, 247)"><font style="color:green">' Sierpinski Triangle written in Small Basic</font><font style="font-size:11px"> </font></td></tr><tr><td> </td></tr><tr><td style="background-color:rgb(247, 247, 247)">GraphicsWindow.BackgroundColor = <font style="color:blue">&quot;Black&quot;</font><font style="font-size:11px"> </font></td></tr><tr><td> </td></tr><tr><td style="background-color:rgb(247, 247, 247)">width = 640 </td></tr><tr><td>height = 480 </td></tr><tr><td style="background-color:rgb(247, 247, 247)"> </td></tr><tr><td>x1 = (width / 2) </td></tr><tr><td style="background-color:rgb(247, 247, 247)">x2 = (width / 2) </td></tr><tr><td> </td></tr><tr><td style="background-color:rgb(247, 247, 247)">y1 = 0 </td></tr><tr><td>y2 = 0 </td></tr><tr><td style="background-color:rgb(247, 247, 247)"> </td></tr><tr><td>maxPoints = 100000 </td></tr><tr><td style="background-color:rgb(247, 247, 247)"> </td></tr><tr><td><font style="color:blue">For</font><font style="font-size:11px"> i = 0 </font><font style="color:blue">To</font><font style="font-size:11px"> maxPoints </font></td></tr><tr><td style="background-color:rgb(247, 247, 247)">     </td></tr><tr><td>    direct = Math.GetRandomNumber(3) </td></tr><tr><td style="background-color:rgb(247, 247, 247)">     </td></tr><tr><td>    <font style="color:blue">If</font><font style="font-size:11px"> (direct = 0) </font><font style="color:blue">Then</font><font style="font-size:11px"> </font></td></tr><tr><td style="background-color:rgb(247, 247, 247)">        x1 = (x2 + width / 2) / 2 </td></tr><tr><td>        y1 = (y2 + 0) / 2 </td></tr><tr><td style="background-color:rgb(247, 247, 247)">    EndIf  </td></tr><tr><td>    <font style="color:blue">If</font><font style="font-size:11px"> (direct = 1) </font><font style="color:blue">Then</font><font style="font-size:11px"> </font></td></tr><tr><td style="background-color:rgb(247, 247, 247)">        x1 = (x2 + 0) / 2 </td></tr><tr><td>        y1 = (y2 + height) / 2 </td></tr><tr><td style="background-color:rgb(247, 247, 247)">    EndIf  </td></tr><tr><td>    <font style="color:blue">If</font><font style="font-size:11px"> (direct = 2) </font><font style="color:blue">Then</font><font style="font-size:11px"> </font></td></tr><tr><td style="background-color:rgb(247, 247, 247)">        x1 = (x2 + width) / 2 </td></tr><tr><td>        y1 = (y2 + height) / 2 </td></tr><tr><td style="background-color:rgb(247, 247, 247)">    Endif </td></tr><tr><td>     </td></tr><tr><td style="background-color:rgb(247, 247, 247)">    GraphicsWindow.SetPixel(x1, y1, <font style="color:blue">&quot;White&quot;</font><font style="font-size:11px">) </font></td></tr><tr><td>     </td></tr><tr><td style="background-color:rgb(247, 247, 247)">    x2 = x1 </td></tr><tr><td>    y2 = y1 </td></tr><tr><td style="background-color:rgb(247, 247, 247)">     </td></tr><tr><td>EndFor </td></tr><tr><td style="background-color:rgb(247, 247, 247)"> </td></tr></tbody></table></div>Tue, 11 Nov 2008 23:24:49 Z2008-11-11T23:24:49Zhttp://social.msdn.microsoft.com/Forums/en-US/smallbasic/thread/eaacf826-9d12-4e3c-aa10-1b2788f160a6#5641e3f0-7ee1-4a9c-b9b7-93c1102c9cdchttp://social.msdn.microsoft.com/Forums/en-US/smallbasic/thread/eaacf826-9d12-4e3c-aa10-1b2788f160a6#5641e3f0-7ee1-4a9c-b9b7-93c1102c9cdcDan Dohttp://social.msdn.microsoft.com/Profile/en-US/?user=Dan%20DoPost your sample source code here and get featured on our blogs!<span><div style="overflow:auto;background-color:white;border:solid 1px #7f9db9;width:;height:;line-height:100% !important;font-family:Courier New;font-size:11px"><table cellpadding=0 cellspacing=0 style="width:99%;margin:2px 0px 2px 0px;border-collapse:collapse;border-bottom:2px solid #eee;background-color:#fff;border-width:0px"><col style="font-family:Courier New;font-size:11px;background-color:#eee;padding-right:5px;padding-left:10px;width:5px;border-right:1px solid gray;color:gray;text-align:right;vertical-align:top"><col style="font-family:Courier New;font-size:11px;padding-left:10px;border-bottom:1px solid #F7F7F7;white-space:nowrap"><tbody><tr><td><nobr>1</nobr></td><td><font style="font-size:11px"></font><font style="color:green">'This is a simple pong game.</font><font style="font-size:11px"> </font></td></tr><tr><td><nobr>2</nobr></td><td style="background-color:#F7F7F7"><font style="color:green">'Player 1 is on the left, moves with the mouse</font><font style="font-size:11px"> </font></td></tr><tr><td><nobr>3</nobr></td><td><font style="color:green">'Player 2 is on the right, moves with the arrow key</font><font style="font-size:11px"> </font></td></tr><tr><td><nobr>4</nobr></td><td style="background-color:#F7F7F7"><font style="color:green">'Stop by pressing esc</font><font style="font-size:11px"> </font></td></tr><tr><td><nobr>5</nobr></td><td>  </td></tr><tr><td><nobr>6</nobr></td><td style="background-color:#F7F7F7">  </td></tr><tr><td><nobr>7</nobr></td><td><font style="color:green">'const </font><font style="font-size:11px"> </font></td></tr><tr><td><nobr>8</nobr></td><td style="background-color:#F7F7F7">BALLSIZE = 15  </td></tr><tr><td><nobr>9</nobr></td><td>PADDLEWIDTH = 10  </td></tr><tr><td><nobr>10</nobr></td><td style="background-color:#F7F7F7">PADDLEHEIGHT = 100  </td></tr><tr><td><nobr>11</nobr></td><td>SPEED = 3  </td></tr><tr><td><nobr>12</nobr></td><td style="background-color:#F7F7F7">PlAYERDISTANCE = 20  </td></tr><tr><td><nobr>13</nobr></td><td>PLAYERSPEED = 50  </td></tr><tr><td><nobr>14</nobr></td><td style="background-color:#F7F7F7">  </td></tr><tr><td><nobr>15</nobr></td><td>continue = 1  </td></tr><tr><td><nobr>16</nobr></td><td style="background-color:#F7F7F7">wanttoplay = 1  </td></tr><tr><td><nobr>17</nobr></td><td>  </td></tr><tr><td><nobr>18</nobr></td><td style="background-color:#F7F7F7">player1Score = 0  </td></tr><tr><td><nobr>19</nobr></td><td>player2Score = 0  </td></tr><tr><td><nobr>20</nobr></td><td style="background-color:#F7F7F7">  </td></tr><tr><td><nobr>21</nobr></td><td>  </td></tr><tr><td><nobr>22</nobr></td><td style="background-color:#F7F7F7">Start()  </td></tr><tr><td><nobr>23</nobr></td><td>Program.Delay(2000)  </td></tr><tr><td><nobr>24</nobr></td><td style="background-color:#F7F7F7">Program.<font style="color:blue">End</font><font style="font-size:11px">()  </font></td></tr><tr><td><nobr>25</nobr></td><td>  </td></tr><tr><td><nobr>26</nobr></td><td style="background-color:#F7F7F7">  </td></tr><tr><td><nobr>27</nobr></td><td><font style="color:blue">Sub</font><font style="font-size:11px"> Start  </font></td></tr><tr><td><nobr>28</nobr></td><td style="background-color:#F7F7F7">init()  </td></tr><tr><td><nobr>29</nobr></td><td>program.delay(1000)  </td></tr><tr><td><nobr>30</nobr></td><td style="background-color:#F7F7F7">GraphicsWindow.MouseMove = OnMouseMove  </td></tr><tr><td><nobr>31</nobr></td><td>GraphicsWindow.KeyDown = OnKeyPressed  </td></tr><tr><td><nobr>32</nobr></td><td style="background-color:#F7F7F7">GraphicsWindow.KeyUp = OnKeyReleased  </td></tr><tr><td><nobr>33</nobr></td><td><font style="color:blue">While</font><font style="font-size:11px">(wanttoplay = 1)  </font></td></tr><tr><td><nobr>34</nobr></td><td style="background-color:#F7F7F7">Moveball()  </td></tr><tr><td><nobr>35</nobr></td><td>endwhile  </td></tr><tr><td><nobr>36</nobr></td><td style="background-color:#F7F7F7">EndSub  </td></tr><tr><td><nobr>37</nobr></td><td>  </td></tr><tr><td><nobr>38</nobr></td><td style="background-color:#F7F7F7"><font style="color:blue">Sub</font><font style="font-size:11px"> init  </font></td></tr><tr><td><nobr>39</nobr></td><td>  </td></tr><tr><td><nobr>40</nobr></td><td style="background-color:#F7F7F7">GraphicsWindow.Title = <font style="color:blue">&quot;Dan's pong&quot;</font><font style="font-size:11px">  </font></td></tr><tr><td><nobr>41</nobr></td><td>GraphicsWindow.BackgroundColor= <font style="color:blue">&quot;black&quot;</font><font style="font-size:11px">  </font></td></tr><tr><td><nobr>42</nobr></td><td style="background-color:#F7F7F7">GraphicsWindow.Width = 800  </td></tr><tr><td><nobr>43</nobr></td><td>GraphicsWindow.Height = 600  </td></tr><tr><td><nobr>44</nobr></td><td style="background-color:#F7F7F7">GraphicsWindow.Clear()  </td></tr><tr><td><nobr>45</nobr></td><td>  </td></tr><tr><td><nobr>46</nobr></td><td style="background-color:#F7F7F7"><font style="color:green">'setup background </font><font style="font-size:11px"> </font></td></tr><tr><td><nobr>47</nobr></td><td>GraphicsWindow.BrushColor = <font style="color:blue">&quot;LightGoldenrodYellow&quot;</font><font style="font-size:11px">  </font></td></tr><tr><td><nobr>48</nobr></td><td style="background-color:#F7F7F7">GraphicsWindow.FillRectangle(0,500,800,100)  </td></tr><tr><td><nobr>49</nobr></td><td>  </td></tr><tr><td><nobr>50</nobr></td><td style="background-color:#F7F7F7"><font style="color:green">'initialize players </font><font style="font-size:11px"> </font></td></tr><tr><td><nobr>51</nobr></td><td>GraphicsWindow.BrushColor = <font style="color:blue">&quot;red&quot;</font><font style="font-size:11px">  </font></td></tr><tr><td><nobr>52</nobr></td><td style="background-color:#F7F7F7">GraphicsWindow.PenColor = <font style="color:blue">&quot;red&quot;</font><font style="font-size:11px">  </font></td></tr><tr><td><nobr>53</nobr></td><td>player1 = GraphicsWindow.AddRectangle(PADDLEWIDTH,PADDLEHEIGHT)  </td></tr><tr><td><nobr>54</nobr></td><td style="background-color:#F7F7F7"> </td></tr><tr><td><nobr>55</nobr></td><td>  </td></tr><tr><td><nobr>56</nobr></td><td style="background-color:#F7F7F7">GraphicsWindow.BrushColor = <font style="color:blue">&quot;blue&quot;</font><font style="font-size:11px">  </font></td></tr><tr><td><nobr>57</nobr></td><td>GraphicsWindow.PenColor = <font style="color:blue">&quot;blue&quot;</font><font style="font-size:11px">  </font></td></tr><tr><td><nobr>58</nobr></td><td style="background-color:#F7F7F7">player2 = GraphicsWindow.AddRectangle(PADDLEWIDTH,PADDLEHEIGHT)  </td></tr><tr><td><nobr>59</nobr></td><td> </td></tr><tr><td><nobr>60</nobr></td><td style="background-color:#F7F7F7">  </td></tr><tr><td><nobr>61</nobr></td><td><font style="color:green">'initialize ball </font><font style="font-size:11px"> </font></td></tr><tr><td><nobr>62</nobr></td><td style="background-color:#F7F7F7">GraphicsWindow.BrushColor = <font style="color:blue">&quot;SpringGreen&quot;</font><font style="font-size:11px">  </font></td></tr><tr><td><nobr>63</nobr></td><td>GraphicsWindow.PenColor = <font style="color:blue">&quot;SpringGreen&quot;</font><font style="font-size:11px">  </font></td></tr><tr><td><nobr>64</nobr></td><td style="background-color:#F7F7F7">ball = GraphicsWindow.AddEllipse(BALLSIZE,BALLSIZE)  </td></tr><tr><td><nobr>65</nobr></td><td>  </td></tr><tr><td><nobr>66</nobr></td><td style="background-color:#F7F7F7"><font style="color:green">'randomize ball start direction </font><font style="font-size:11px"> </font></td></tr><tr><td><nobr>67</nobr></td><td>temp = Math.GetRandomNumber(10)  </td></tr><tr><td><nobr>68</nobr></td><td style="background-color:#F7F7F7"><font style="color:blue">If</font><font style="font-size:11px"> (temp &lt; 5) </font><font style="color:blue">Then</font><font style="font-size:11px">   </font></td></tr><tr><td><nobr>69</nobr></td><td>   deltaY = 1  </td></tr><tr><td><nobr>70</nobr></td><td style="background-color:#F7F7F7"><font style="color:blue">Else</font><font style="font-size:11px">   </font></td></tr><tr><td><nobr>71</nobr></td><td>   deltaY = -1   </td></tr><tr><td><nobr>72</nobr></td><td style="background-color:#F7F7F7">endif  </td></tr><tr><td><nobr>73</nobr></td><td>  </td></tr><tr><td><nobr>74</nobr></td><td style="background-color:#F7F7F7">temp = Math.GetRandomNumber(10)  </td></tr><tr><td><nobr>75</nobr></td><td><font style="color:blue">If</font><font style="font-size:11px"> (temp &lt; 5) </font><font style="color:blue">Then</font><font style="font-size:11px">   </font></td></tr><tr><td><nobr>76</nobr></td><td style="background-color:#F7F7F7">   deltaX = 1  </td></tr><tr><td><nobr>77</nobr></td><td><font style="color:blue">Else</font><font style="font-size:11px">   </font></td></tr><tr><td><nobr>78</nobr></td><td style="background-color:#F7F7F7">   deltaX = -1   </td></tr><tr><td><nobr>79</nobr></td><td>endif  </td></tr><tr><td><nobr>80</nobr></td><td style="background-color:#F7F7F7">  </td></tr><tr><td><nobr>81</nobr></td><td>  </td></tr><tr><td><nobr>82</nobr></td><td style="background-color:#F7F7F7">  </td></tr><tr><td><nobr>83</nobr></td><td><font style="color:green">'position players and ball </font><font style="font-size:11px"> </font></td></tr><tr><td><nobr>84</nobr></td><td style="background-color:#F7F7F7">GraphicsWindow.MoveShape(player1,0,200)  </td></tr><tr><td><nobr>85</nobr></td><td>GraphicsWindow.MoveShape(player2,800 - PADDLEWIDTH,200)  </td></tr><tr><td><nobr>86</nobr></td><td style="background-color:#F7F7F7">GraphicsWindow.MoveShape(ball,(800-BALLSIZE)/2,143)  </td></tr><tr><td><nobr>87</nobr></td><td>  </td></tr><tr><td><nobr>88</nobr></td><td style="background-color:#F7F7F7"><font style="color:green">'draw scoring board</font><font style="font-size:11px"> </font></td></tr><tr><td><nobr>89</nobr></td><td>GraphicsWindow.FontSize = 40  </td></tr><tr><td><nobr>90</nobr></td><td style="background-color:#F7F7F7">GraphicsWindow.BrushColor = <font style="color:blue">&quot;black&quot;</font><font style="font-size:11px">  </font></td></tr><tr><td><nobr>91</nobr></td><td>GraphicsWindow.DrawText(360,520,player1Score +<font style="color:blue">&quot; - &quot;</font><font style="font-size:11px"> + player2Score)  </font></td></tr><tr><td><nobr>92</nobr></td><td style="background-color:#F7F7F7">  </td></tr><tr><td><nobr>93</nobr></td><td>EndSub   </td></tr><tr><td><nobr>94</nobr></td><td style="background-color:#F7F7F7">  </td></tr><tr><td><nobr>95</nobr></td><td>  </td></tr><tr><td><nobr>96</nobr></td><td style="background-color:#F7F7F7"><font style="color:blue">Sub</font><font style="font-size:11px"> OnMouseMove  </font></td></tr><tr><td><nobr>97</nobr></td><td>paddleY = GraphicsWindow.MouseY  </td></tr><tr><td><nobr>98</nobr></td><td style="background-color:#F7F7F7"><font style="color:blue">If</font><font style="font-size:11px"> (paddleY &lt; 50)then  </font></td></tr><tr><td><nobr>99</nobr></td><td>GraphicsWindow.MoveShape(player1, GraphicsWindow.Width - 800,0)  </td></tr><tr><td><nobr>100</nobr></td><td style="background-color:#F7F7F7"><font style="color:blue">Else</font><font style="font-size:11px">   </font></td></tr><tr><td><nobr>101</nobr></td><td><font style="color:blue">If</font><font style="font-size:11px"> (paddleY &gt; 450) then  </font></td></tr><tr><td><nobr>102</nobr></td><td style="background-color:#F7F7F7">GraphicsWindow.MoveShape(player1, GraphicsWindow.Width - 800,400)  </td></tr><tr><td><nobr>103</nobr></td><td>else  </td></tr><tr><td><nobr>104</nobr></td><td style="background-color:#F7F7F7">GraphicsWindow.MoveShape(player1, GraphicsWindow.Width - 800,paddleY-PADDLEHEIGHT/2)  </td></tr><tr><td><nobr>105</nobr></td><td>EndIf  </td></tr><tr><td><nobr>106</nobr></td><td style="background-color:#F7F7F7">Endif  </td></tr><tr><td><nobr>107</nobr></td><td>EndSub  </td></tr><tr><td><nobr>108</nobr></td><td style="background-color:#F7F7F7">  </td></tr><tr><td><nobr>109</nobr></td><td>  </td></tr><tr><td><nobr>110</nobr></td><td style="background-color:#F7F7F7"><font style="color:blue">Sub</font><font style="font-size:11px"> OnKeyPressed  </font></td></tr><tr><td><nobr>111</nobr></td><td>key = GraphicsWindow.LastKey  </td></tr><tr><td><nobr>112</nobr></td><td style="background-color:#F7F7F7">  </td></tr><tr><td><nobr>113</nobr></td><td><font style="color:blue">If</font><font style="font-size:11px"> (key = </font><font style="color:blue">&quot;Up&quot;</font><font style="font-size:11px"> </font><font style="color:blue">Or</font><font style="font-size:11px"> key = </font><font style="color:blue">&quot;Down&quot;</font><font style="font-size:11px">) </font><font style="color:blue">Then</font><font style="font-size:11px">   </font></td></tr><tr><td><nobr>114</nobr></td><td style="background-color:#F7F7F7">    player2move()  </td></tr><tr><td><nobr>115</nobr></td><td>else  </td></tr><tr><td><nobr>116</nobr></td><td style="background-color:#F7F7F7">    command()  </td></tr><tr><td><nobr>117</nobr></td><td>EndIf   </td></tr><tr><td><nobr>118</nobr></td><td style="background-color:#F7F7F7">  </td></tr><tr><td><nobr>119</nobr></td><td>EndSub  </td></tr><tr><td><nobr>120</nobr></td><td style="background-color:#F7F7F7">  </td></tr><tr><td><nobr>121</nobr></td><td>  </td></tr><tr><td><nobr>122</nobr></td><td style="background-color:#F7F7F7"><font style="color:green">'reset player2 speed </font><font style="font-size:11px"> </font></td></tr><tr><td><nobr>123</nobr></td><td><font style="color:blue">Sub</font><font style="font-size:11px"> OnKeyReleased  </font></td></tr><tr><td><nobr>124</nobr></td><td style="background-color:#F7F7F7">    PlAYERDISTANCE = 20  </td></tr><tr><td><nobr>125</nobr></td><td>EndSub  </td></tr><tr><td><nobr>126</nobr></td><td style="background-color:#F7F7F7">  </td></tr><tr><td><nobr>127</nobr></td><td><font style="color:blue">Sub</font><font style="font-size:11px"> player2move  </font></td></tr><tr><td><nobr>128</nobr></td><td style="background-color:#F7F7F7">curpos = GraphicsWindow.GetTopOfShape(player2)  </td></tr><tr><td><nobr>129</nobr></td><td>newpos = curpos  </td></tr><tr><td><nobr>130</nobr></td><td style="background-color:#F7F7F7"><font style="color:blue">If</font><font style="font-size:11px"> (key = </font><font style="color:blue">&quot;Up&quot;</font><font style="font-size:11px">) </font><font style="color:blue">Then</font><font style="font-size:11px">  </font></td></tr><tr><td><nobr>131</nobr></td><td>    newpos = curpos - PLAYERDISTANCE  </td></tr><tr><td><nobr>132</nobr></td><td style="background-color:#F7F7F7">    <font style="color:blue">If</font><font style="font-size:11px"> (newpos &lt; 0) </font><font style="color:blue">Then</font><font style="font-size:11px">   </font></td></tr><tr><td><nobr>133</nobr></td><td>        newpos = 0  </td></tr><tr><td><nobr>134</nobr></td><td style="background-color:#F7F7F7">    EndIf  </td></tr><tr><td><nobr>135</nobr></td><td>EndIf  </td></tr><tr><td><nobr>136</nobr></td><td style="background-color:#F7F7F7"><font style="color:blue">If</font><font style="font-size:11px"> (key = </font><font style="color:blue">&quot;Down&quot;</font><font style="font-size:11px">) </font><font style="color:blue">Then</font><font style="font-size:11px">   </font></td></tr><tr><td><nobr>137</nobr></td><td>    newpos = curpos + PLAYERDISTANCE  </td></tr><tr><td><nobr>138</nobr></td><td style="background-color:#F7F7F7">    <font style="color:blue">If</font><font style="font-size:11px"> (newpos &gt; 500 - PADDLEHEIGHT) </font><font style="color:blue">Then</font><font style="font-size:11px">    </font></td></tr><tr><td><nobr>139</nobr></td><td>        newpos = 500 - PADDLEHEIGHT  </td></tr><tr><td><nobr>140</nobr></td><td style="background-color:#F7F7F7">    EndIf  </td></tr><tr><td><nobr>141</nobr></td><td>EndIf  </td></tr><tr><td><nobr>142</nobr></td><td style="background-color:#F7F7F7">GraphicsWindow.AnimateShape(player2,800-PADDLEWIDTH,newpos,PLAYERSPEED)  </td></tr><tr><td><nobr>143</nobr></td><td>  </td></tr><tr><td><nobr>144</nobr></td><td style="background-color:#F7F7F7"><font style="color:green">'the longer you hold the key, the faster the paddle moves </font><font style="font-size:11px"> </font></td></tr><tr><td><nobr>145</nobr></td><td>PlAYERDISTANCE = PlAYERDISTANCE*1.1  </td></tr><tr><td><nobr>146</nobr></td><td style="background-color:#F7F7F7">EndSub  </td></tr><tr><td><nobr>147</nobr></td><td>  </td></tr><tr><td><nobr>148</nobr></td><td style="background-color:#F7F7F7">  </td></tr><tr><td><nobr>149</nobr></td><td>  </td></tr><tr><td><nobr>150</nobr></td><td style="background-color:#F7F7F7"><font style="color:green">'stop the game </font><font style="font-size:11px"> </font></td></tr><tr><td><nobr>151</nobr></td><td><font style="color:blue">Sub</font><font style="font-size:11px"> command  </font></td></tr><tr><td><nobr>152</nobr></td><td style="background-color:#F7F7F7"><font style="color:blue">If</font><font style="font-size:11px"> (key = </font><font style="color:blue">&quot;Escape&quot;</font><font style="font-size:11px">) </font><font style="color:blue">Then</font><font style="font-size:11px">   </font></td></tr><tr><td><nobr>153</nobr></td><td>    wanttoplay = 0  </td></tr><tr><td><nobr>154</nobr></td><td style="background-color:#F7F7F7">EndIf  </td></tr><tr><td><nobr>155</nobr></td><td>  </td></tr><tr><td><nobr>156</nobr></td><td style="background-color:#F7F7F7">EndSub  </td></tr><tr><td><nobr>157</nobr></td><td>  </td></tr><tr><td><nobr>158</nobr></td><td style="background-color:#F7F7F7">  </td></tr><tr><td><nobr>159</nobr></td><td>  </td></tr><tr><td><nobr>160</nobr></td><td style="background-color:#F7F7F7"><font style="color:blue">Sub</font><font style="font-size:11px"> Moveball  </font></td></tr><tr><td><nobr>161</nobr></td><td>    x = GraphicsWindow.GetLeftOfShape(ball)  </td></tr><tr><td><nobr>162</nobr></td><td style="background-color:#F7F7F7">    y = GraphicsWindow.GetTopOfShape(ball)  </td></tr><tr><td><nobr>163</nobr></td><td>    x = x + deltaX  </td></tr><tr><td><nobr>164</nobr></td><td style="background-color:#F7F7F7">    y = y + deltaY  </td></tr><tr><td><nobr>165</nobr></td><td>  </td></tr><tr><td><nobr>166</nobr></td><td style="background-color:#F7F7F7">    <font style="color:blue">If</font><font style="font-size:11px"> (y &lt; 0 </font><font style="color:blue">Or</font><font style="font-size:11px"> y &gt; 500 - BALLSIZE) </font><font style="color:blue">Then</font><font style="font-size:11px">   </font></td></tr><tr><td><nobr>167</nobr></td><td>        deltaY = -deltaY  </td></tr><tr><td><nobr>168</nobr></td><td style="background-color:#F7F7F7">        Sound.PlayClick()  </td></tr><tr><td><nobr>169</nobr></td><td>    endif  </td></tr><tr><td><nobr>170</nobr></td><td style="background-color:#F7F7F7">  </td></tr><tr><td><nobr>171</nobr></td><td><font style="color:blue">If</font><font style="font-size:11px"> (x &lt; PADDLEWIDTH </font><font style="color:blue">Or</font><font style="font-size:11px"> x &gt; 800 - PADDLEWIDTH - BALLSIZE) </font><font style="color:blue">Then</font><font style="font-size:11px">   </font></td></tr><tr><td><nobr>172</nobr></td><td style="background-color:#F7F7F7">    deltaX = -deltaX  </td></tr><tr><td><nobr>173</nobr></td><td>    Sound.PlayClick()  </td></tr><tr><td><nobr>174</nobr></td><td style="background-color:#F7F7F7">endif  </td></tr><tr><td><nobr>175</nobr></td><td>  </td></tr><tr><td><nobr>176</nobr></td><td style="background-color:#F7F7F7">GraphicsWindow.MoveShape(ball,x,y)  </td></tr><tr><td><nobr>177</nobr></td><td>Program.Delay(SPEED)  </td></tr><tr><td><nobr>178</nobr></td><td style="background-color:#F7F7F7">checkforgoal()  </td></tr><tr><td><nobr>179</nobr></td><td>endsub  </td></tr><tr><td><nobr>180</nobr></td><td style="background-color:#F7F7F7">  </td></tr><tr><td><nobr>181</nobr></td><td>  </td></tr><tr><td><nobr>182</nobr></td><td style="background-color:#F7F7F7"><font style="color:blue">Sub</font><font style="font-size:11px"> checkforgoal  </font></td></tr><tr><td><nobr>183</nobr></td><td>player1pos = GraphicsWindow.GetTopOfShape(player1)  </td></tr><tr><td><nobr>184</nobr></td><td style="background-color:#F7F7F7">player2pos = GraphicsWindow.GetTopOfShape(player2)  </td></tr><tr><td><nobr>185</nobr></td><td>ballXpos = GraphicsWindow.GetLeftOfShape(ball)  </td></tr><tr><td><nobr>186</nobr></td><td style="background-color:#F7F7F7">ballYpos = GraphicsWindow.GetTopOfShape(ball)  </td></tr><tr><td><nobr>187</nobr></td><td>  </td></tr><tr><td><nobr>188</nobr></td><td style="background-color:#F7F7F7">  </td></tr><tr><td><nobr>189</nobr></td><td><font style="color:blue">If</font><font style="font-size:11px"> (ballXpos &lt; 0 + PADDLEWIDTH) </font><font style="color:blue">Then</font><font style="font-size:11px">  </font></td></tr><tr><td><nobr>190</nobr></td><td style="background-color:#F7F7F7">    <font style="color:blue">If</font><font style="font-size:11px"> (ballYpos &lt; player1pos </font><font style="color:blue">Or</font><font style="font-size:11px"> ballYpos &gt; player1pos + PADDLEHEIGHT) </font><font style="color:blue">Then</font><font style="font-size:11px">   </font></td></tr><tr><td><nobr>191</nobr></td><td>        player2Score = player2Score + 1  </td></tr><tr><td><nobr>192</nobr></td><td style="background-color:#F7F7F7">        sound.PlayBellRingAndWait()  </td></tr><tr><td><nobr>193</nobr></td><td>        init()  </td></tr><tr><td><nobr>194</nobr></td><td style="background-color:#F7F7F7">    endif  </td></tr><tr><td><nobr>195</nobr></td><td>EndIf  </td></tr><tr><td><nobr>196</nobr></td><td style="background-color:#F7F7F7">  </td></tr><tr><td><nobr>197</nobr></td><td>  </td></tr><tr><td><nobr>198</nobr></td><td style="background-color:#F7F7F7"><font style="color:blue">If</font><font style="font-size:11px"> (ballXpos &gt; 800 - PADDLEWIDTH - ballsize) </font><font style="color:blue">Then</font><font style="font-size:11px">  </font></td></tr><tr><td><nobr>199</nobr></td><td>    <font style="color:blue">If</font><font style="font-size:11px"> (ballYpos &lt; player2pos </font><font style="color:blue">Or</font><font style="font-size:11px"> ballYpos &gt; player2pos + PADDLEHEIGHT) </font><font style="color:blue">Then</font><font style="font-size:11px">   </font></td></tr><tr><td><nobr>200</nobr></td><td style="background-color:#F7F7F7">        player1Score = player1Score + 1  </td></tr><tr><td><nobr>201</nobr></td><td>        sound.PlayBellRingAndWait()  </td></tr><tr><td><nobr>202</nobr></td><td style="background-color:#F7F7F7">        init()  </td></tr><tr><td><nobr>203</nobr></td><td>    endif  </td></tr><tr><td><nobr>204</nobr></td><td style="background-color:#F7F7F7">EndIf  </td></tr><tr><td><nobr>205</nobr></td><td>  </td></tr><tr><td><nobr>206</nobr></td><td style="background-color:#F7F7F7">endsub  </td></tr><tr><td><nobr>207</nobr></td><td> </td></tr><tr><td><nobr>208</nobr></td><td style="background-color:#F7F7F7"> </td></tr></tbody></table></div></span>Thu, 13 Nov 2008 19:01:27 Z2008-11-13T19:01:27Zhttp://social.msdn.microsoft.com/Forums/en-US/smallbasic/thread/eaacf826-9d12-4e3c-aa10-1b2788f160a6#f506ae4a-5102-4b94-90a3-cdd306fa9fcbhttp://social.msdn.microsoft.com/Forums/en-US/smallbasic/thread/eaacf826-9d12-4e3c-aa10-1b2788f160a6#f506ae4a-5102-4b94-90a3-cdd306fa9fcbVijaye Rajihttp://social.msdn.microsoft.com/Profile/en-US/?user=Vijaye%20RajiPost your sample source code here and get featured on our blogs! <span class=postedBy><a title="Jeff Sidlosky" href="http://social.msdn.microsoft.com/en-US/profile/?user=Jeff Sidlosky&amp;referrer=http://social.msdn.microsoft.com/Forums/en-US/smallbasic/thread/eaacf826-9d12-4e3c-aa10-1b2788f160a6"><font color="#0072bc">Jeff Sidlosky</font></a>'s Star field simulation is the <a href="http://blogs.msdn.com/smallbasic/archive/2008/11/17/sample-of-the-week-ii.aspx">featured sample of this week</a>.</span>Mon, 17 Nov 2008 18:59:47 Z2008-11-17T18:59:47Zhttp://social.msdn.microsoft.com/Forums/en-US/smallbasic/thread/eaacf826-9d12-4e3c-aa10-1b2788f160a6#69456259-5213-43ef-93fe-23ad7084ee69http://social.msdn.microsoft.com/Forums/en-US/smallbasic/thread/eaacf826-9d12-4e3c-aa10-1b2788f160a6#69456259-5213-43ef-93fe-23ad7084ee69Volodymir Tryapichkohttp://social.msdn.microsoft.com/Profile/en-US/?user=Volodymir%20TryapichkoPost your sample source code here and get featured on our blogs!<div style="border-right:#7f9db9 1px solid;border-top:#7f9db9 1px solid;font-size:11px;overflow:auto;border-left:#7f9db9 1px solid;line-height:100%! important;border-bottom:#7f9db9 1px solid;font-family:Courier New;background-color:white"> <table style="border-top-width:0px;border-left-width:0px;margin:2px 0px;width:99%;border-bottom:#eee 0px solid;border-collapse:collapse;background-color:#fff;border-right-width:0px" cellspacing=0 cellpadding=0> <colgroup> <col style="padding-left:10px;font-size:11px;border-bottom:#f7f7f7 1px solid;font-family:Courier New;white-space:nowrap"> <tbody> <tr> <td><font style="font-size:11px"></font><font style="color:red">GraphicsWindow.BackgroundColor</font><font style="font-size:11px"> = </font><font style="color:blue">&quot;000000&quot;</font><font style="font-size:11px"> </font></td></tr> <tr> <td style="background-color:#f7f7f7"></font><font style="color:red">GraphicsWindow.PenColor</font><font style="font-size:11px"> = </font><font style="color:blue">&quot;#00CC44&quot;</font><font style="font-size:11px"> </font></td></tr> <tr> <td></font><font style="color:red">vDistance</font><font style="font-size:11px"> = </font><font style="color:blue">100</font><font style="font-size:11px"> </font></td></tr> <tr> <td style="background-color:#f7f7f7"></font><font style="color:red">pixelsPerUnit</font><font style="font-size:11px"> = </font><font style="color:blue">70</font><font style="font-size:11px"> </font></td></tr> <tr> <td></font><font style="color:red">centerX</font><font style="font-size:11px"> = </font><font style="color:blue">GraphicsWindow</font><font style="font-size:11px">.Width / 2  </font></td></tr> <tr> <td style="background-color:#f7f7f7"></font><font style="color:red">centerY</font><font style="font-size:11px"> = </font><font style="color:blue">GraphicsWindow</font><font style="font-size:11px">.Height / 2  </font></td></tr> <tr> <td></font><font style="color:red">oldX</font><font style="font-size:11px"> = </font><font style="color:blue">centerX</font><font style="font-size:11px"> </font></td></tr> <tr> <td style="background-color:#f7f7f7"></font><font style="color:red">oldY</font><font style="font-size:11px"> = </font><font style="color:blue">centerY</font><font style="font-size:11px"> + vDistance  </font></td></tr> <tr> <td>Turtle.Show()  </td></tr> <tr> <td style="background-color:#f7f7f7"></font><font style="color:red">Turtle.Speed</font><font style="font-size:11px"> = </font><font style="color:blue">7</font><font style="font-size:11px"> </font></td></tr> <tr> <td>Turtle.PenUp()  </td></tr> <tr> <td style="background-color:#f7f7f7">Turtle.Move(-vDistance)  </td></tr> <tr> <td>Turtle.PenDown()  </td></tr> <tr> <td style="background-color:#f7f7f7">Turtle.TurnLeft()  </td></tr> <tr> <td></font><font style="color:red">Turtle.Speed</font><font style="font-size:11px"> = </font><font style="color:blue">10</font><font style="font-size:11px"> </font></td></tr> <tr> <td style="background-color:#f7f7f7">For </font><font style="color:red">fi</font><font style="font-size:11px"> = </font><font style="color:blue">0</font><font style="font-size:11px"> To 360  </font></td></tr> <tr> <td> </font><font style="color:red">radianFi</font><font style="font-size:11px"> = </font><font style="color:blue">Math</font><font style="font-size:11px">.GetRadians(fi)  </font></td></tr> <tr> <td style="background-color:#f7f7f7"> </font><font style="color:red">ro</font><font style="font-size:11px"> =   (1 + Math.Sin(radianFi)) * (1 + 0.9 * Math.Cos(8 *  radianFi)) * (1 + 0.1 * Math.Cos(24 *  radianFi))  </font></td></tr> <tr> <td> </font><font style="color:red">dx</font><font style="font-size:11px"> = </font><font style="color:blue">ro</font><font style="font-size:11px"> * Math.Cos(radianFi) * pixelsPerUnit  </font></td></tr> <tr> <td style="background-color:#f7f7f7"> </font><font style="color:red">dy</font><font style="font-size:11px"> = </font><font style="color:blue">ro</font><font style="font-size:11px"> * Math.Sin(radianFi) * pixelsPerUnit  </font></td></tr> <tr> <td> </font><font style="color:red">newDistance</font><font style="font-size:11px"> = </font><font style="color:blue">Math</font><font style="font-size:11px">.SquareRoot(dx * dx + dy * dy)  </font></td></tr> <tr> <td style="background-color:#f7f7f7"> </font><font style="color:red">newX</font><font style="font-size:11px"> = </font><font style="color:blue">centerX</font><font style="font-size:11px"> - dx  </font></td></tr> <tr> <td> </font><font style="color:red">newY</font><font style="font-size:11px"> = </font><font style="color:blue">centerY</font><font style="font-size:11px"> - dy + vDistance  </font></td></tr> <tr> <td style="background-color:#f7f7f7"> GraphicsWindow.DrawLine(oldX, oldY, newX, newY)  </td></tr> <tr> <td> </font><font style="color:red">oldX</font><font style="font-size:11px"> = </font><font style="color:blue">newX</font><font style="font-size:11px"> </font></td></tr> <tr> <td style="background-color:#f7f7f7"> </font><font style="color:red">oldY</font><font style="font-size:11px"> = </font><font style="color:blue">newY</font><font style="font-size:11px"> </font></td></tr> <tr> <td> If (newDistance </font><font style="color:blue">&gt;</font><font style="font-size:11px">= 10) Then  </font></td></tr> <tr> <td style="background-color:#f7f7f7">  Turtle.Turn(fi)  </td></tr> <tr> <td>  Turtle.Move(newDistance)  </td></tr> <tr> <td style="background-color:#f7f7f7">  Turtle.Turn(180)  </td></tr> <tr> <td>  Turtle.Move(newDistance)  </td></tr> <tr> <td style="background-color:#f7f7f7">  Turtle.Turn(180-fi)  </td></tr> <tr> <td> EndIf  </td></tr> <tr> <td style="background-color:#f7f7f7">EndFor  </td></tr> <tr> <td>Turtle.TurnRight()  </td></tr> <tr> <td style="background-color:#f7f7f7"></font><font style="color:red">Turtle.Speed</font><font style="font-size:11px"> = </font><font style="color:blue">5</font><font style="font-size:11px"> </font></td></tr> <tr> <td>Turtle.Move(-vDistance / 2)  </td></tr> <tr> <td style="background-color:#f7f7f7">Turtle.PenUp()  </td></tr> <tr> <td> </td></tr></tbody></table></div><br><br><img alt="" src="http://img201.imageshack.us/img201/2681/smallbasicganjajq3.png"> Mon, 17 Nov 2008 22:06:07 Z2008-11-17T22:06:07Zhttp://social.msdn.microsoft.com/Forums/en-US/smallbasic/thread/eaacf826-9d12-4e3c-aa10-1b2788f160a6#6ffc317e-982d-44f7-8d8b-32c8ac794868http://social.msdn.microsoft.com/Forums/en-US/smallbasic/thread/eaacf826-9d12-4e3c-aa10-1b2788f160a6#6ffc317e-982d-44f7-8d8b-32c8ac794868Pacolacohttp://social.msdn.microsoft.com/Profile/en-US/?user=PacolacoPost your sample source code here and get featured on our blogs!I would like to submit my 4 state button :D.<br><br><a href="http://smallbasic.com/drop/buttonclick.zip">http://smallbasic.com/drop/buttonclick.zip</a><br><br>Thanks,<br> Pacolaco<br>Tue, 18 Nov 2008 04:23:54 Z2008-11-18T04:23:54Zhttp://social.msdn.microsoft.com/Forums/en-US/smallbasic/thread/eaacf826-9d12-4e3c-aa10-1b2788f160a6#2fdd43a1-ad29-455b-91e8-b6b03f15eabchttp://social.msdn.microsoft.com/Forums/en-US/smallbasic/thread/eaacf826-9d12-4e3c-aa10-1b2788f160a6#2fdd43a1-ad29-455b-91e8-b6b03f15eabcNidzohttp://social.msdn.microsoft.com/Profile/en-US/?user=NidzoPost your sample source code here and get featured on our blogs! There is a simple game, I know about few bugs (enemy balls get stuck, sometimes it starts with bad resolution - I don't know why), but it should works. If you wish, you can rewrite OnKeyDown to better movements.<br><br> <div style="border-right:#7f9db9 1px solid;border-top:#7f9db9 1px solid;font-size:11px;overflow:auto;border-left:#7f9db9 1px solid;line-height:100%! important;border-bottom:#7f9db9 1px solid;font-family:Courier New;background-color:white"> <table style="border-top-width:0px;border-left-width:0px;margin:2px 0px;width:99%;border-bottom:#eee 0px solid;border-collapse:collapse;background-color:#fff;border-right-width:0px" cellspacing=0 cellpadding=0> <colgroup> <col style="padding-left:10px;font-size:11px;border-bottom:#f7f7f7 1px solid;font-family:Courier New;white-space:nowrap"> <tbody> <tr> <td><font style="font-size:11px">PLAYERSIZE = 16  </font></td></tr> <tr> <td style="background-color:#f7f7f7">TARGESIZE = 10  </td></tr> <tr> <td>ENEMYSIZE = 20  </td></tr> <tr> <td style="background-color:#f7f7f7"> </td></tr> <tr> <td>alive = </font><font style="color:blue">&quot;true&quot;</font><font style="font-size:11px"> </font></td></tr> <tr> <td style="background-color:#f7f7f7">score = 0  </td></tr> <tr> <td>numberOfBalls = 0  </td></tr> <tr> <td style="background-color:#f7f7f7">bonus = 1000  </td></tr> <tr> <td> </td></tr> <tr> <td style="background-color:#f7f7f7">currentX = 0  </td></tr> <tr> <td>currentY = 0  </td></tr> <tr> <td style="background-color:#f7f7f7">newX = 0  </td></tr> <tr> <td>newY = 0  </td></tr> <tr> <td style="background-color:#f7f7f7"> </td></tr> <tr> <td>targetBallX = 0  </td></tr> <tr> <td style="background-color:#f7f7f7">targetBallY = 0  </td></tr> <tr> <td> </td></tr> <tr> <td style="background-color:#f7f7f7">Init()  </td></tr> <tr> <td>Start()  </td></tr> <tr> <td style="background-color:#f7f7f7">Program.Delay(2000)  </td></tr> <tr> <td>Program.</font><font style="color:blue">End</font><font style="font-size:11px">()  </font></td></tr> <tr> <td style="background-color:#f7f7f7"> </td></tr> <tr> <td></font><font style="color:blue">Sub</font><font style="font-size:11px"> Init  </font></td></tr> <tr> <td style="background-color:#f7f7f7">    GraphicsWindow.Height = 400  </td></tr> <tr> <td>    GraphicsWindow.Width = 400  </td></tr> <tr> <td style="background-color:#f7f7f7">    GraphicsWindow.BackgroundColor = </font><font style="color:blue">&quot;Gainsboro&quot;</font><font style="font-size:11px"> </font></td></tr> <tr> <td>    GraphicsWindow.KeyDown = OnKeyDown  </td></tr> <tr> <td style="background-color:#f7f7f7">EndSub  </td></tr> <tr> <td> </td></tr> <tr> <td style="background-color:#f7f7f7"></font><font style="color:blue">Sub</font><font style="font-size:11px"> Start  </font></td></tr> <tr> <td>    GraphicsWindow.BrushColor = </font><font style="color:blue">&quot;Red&quot;</font><font style="font-size:11px"> </font></td></tr> <tr> <td style="background-color:#f7f7f7">    playerBall = GraphicsWindow.AddEllipse(PLAYERSIZE, PLAYERSIZE)  </td></tr> <tr> <td>    GraphicsWindow.MoveShape(playerBall, currentX, currentY)  </td></tr> <tr> <td style="background-color:#f7f7f7">      </td></tr> <tr> <td>    GraphicsWindow.BrushColor = </font><font style="color:blue">&quot;Gold&quot;</font><font style="font-size:11px"> </font></td></tr> <tr> <td style="background-color:#f7f7f7">    targetBall = GraphicsWindow.AddEllipse(TARGESIZE, TARGESIZE)  </td></tr> <tr> <td>    MoveTargetBall()  </td></tr> <tr> <td style="background-color:#f7f7f7">    AddNewEnemy()  </td></tr> <tr> <td>      </td></tr> <tr> <td style="background-color:#f7f7f7">    Playing()  </td></tr> <tr> <td>    GraphicsWindow.Clear()  </td></tr> <tr> <td style="background-color:#f7f7f7">    Program.Delay(3000)  </td></tr> <tr> <td>    Program.</font><font style="color:blue">End</font><font style="font-size:11px">()  </font></td></tr> <tr> <td style="background-color:#f7f7f7">EndSub  </td></tr> <tr> <td> </td></tr> <tr> <td style="background-color:#f7f7f7"> </td></tr> <tr> <td></font><font style="color:blue">Sub</font><font style="font-size:11px"> Playing  </font></td></tr> <tr> <td style="background-color:#f7f7f7">    </font><font style="color:blue">While</font><font style="font-size:11px"> (alive = </font><font style="color:blue">&quot;true&quot;</font><font style="font-size:11px">)  </font></td></tr> <tr> <td>        Program.Delay(10)          </td></tr> <tr> <td style="background-color:#f7f7f7">        currentX = currentX + newX  </td></tr> <tr> <td>        currentY = currentY + newY  </td></tr> <tr> <td style="background-color:#f7f7f7">        </font><font style="color:blue">If</font><font style="font-size:11px"> (currentX &lt; 0) </font><font style="color:blue">Then</font><font style="font-size:11px"> </font></td></tr> <tr> <td>            currentX = 0  </td></tr> <tr> <td style="background-color:#f7f7f7">        EndIf  </td></tr> <tr> <td>        </font><font style="color:blue">If</font><font style="font-size:11px"> (currentX &gt; GraphicsWindow.Width - PLAYERSIZE) </font><font style="color:blue">Then</font><font style="font-size:11px"> </font></td></tr> <tr> <td style="background-color:#f7f7f7">            currentX = GraphicsWindow.Width - PLAYERSIZE  </td></tr> <tr> <td>        EndIf  </td></tr> <tr> <td style="background-color:#f7f7f7">        </font><font style="color:blue">If</font><font style="font-size:11px"> (currentY &lt; 0) </font><font style="color:blue">Then</font><font style="font-size:11px"> </font></td></tr> <tr> <td>            currentY = 0  </td></tr> <tr> <td style="background-color:#f7f7f7">        EndIf  </td></tr> <tr> <td>        </font><font style="color:blue">If</font><font style="font-size:11px"> (currentY &gt; GraphicsWindow.Height - PLAYERSIZE) </font><font style="color:blue">Then</font><font style="font-size:11px"> </font></td></tr> <tr> <td style="background-color:#f7f7f7">            currentY = GraphicsWindow.Height - PLAYERSIZE  </td></tr> <tr> <td>        EndIf  </td></tr> <tr> <td style="background-color:#f7f7f7">        GraphicsWindow.MoveShape(playerBall, currentX, currentY)  </td></tr> <tr> <td>          </td></tr> <tr> <td style="background-color:#f7f7f7">        </font><font style="color:blue">For</font><font style="font-size:11px"> i = 0 </font><font style="color:blue">To</font><font style="font-size:11px"> numberOfBalls - 1  </font></td></tr> <tr> <td>            moveX = 0  </td></tr> <tr> <td style="background-color:#f7f7f7">            moveY = 0  </td></tr> <tr> <td>            </font><font style="color:blue">If</font><font style="font-size:11px"> (Array.GetValue(</font><font style="color:blue">&quot;axis&quot;</font><font style="font-size:11px">, i) = 1) </font><font style="color:blue">Then</font><font style="font-size:11px"> </font></td></tr> <tr> <td style="background-color:#f7f7f7">                moveX = Array.GetValue(</font><font style="color:blue">&quot;speed&quot;</font><font style="font-size:11px">, i)  </font></td></tr> <tr> <td>            </font><font style="color:blue">Else</font><font style="font-size:11px"> </font></td></tr> <tr> <td style="background-color:#f7f7f7">                moveY = Array.GetValue(</font><font style="color:blue">&quot;speed&quot;</font><font style="font-size:11px">, i)  </font></td></tr> <tr> <td>            EndIf      </td></tr> <tr> <td style="background-color:#f7f7f7">            x = Array.GetValue(</font><font style="color:blue">&quot;x&quot;</font><font style="font-size:11px">, i) + moveX  </font></td></tr> <tr> <td>            y = Array.GetValue(</font><font style="color:blue">&quot;y&quot;</font><font style="font-size:11px">, i) + moveY  </font></td></tr> <tr> <td style="background-color:#f7f7f7">            </font><font style="color:blue">If</font><font style="font-size:11px"> (x &lt; 0 </font><font style="color:blue">Or</font><font style="font-size:11px"> x &gt; GraphicsWindow.Width - ENEMYSIZE) </font><font style="color:blue">Then</font><font style="font-size:11px"> </font></td></tr> <tr> <td>                Array.SetValue(</font><font style="color:blue">&quot;speed&quot;</font><font style="font-size:11px">, i, -Array.GetValue(</font><font style="color:blue">&quot;speed&quot;</font><font style="font-size:11px">, i))  </font></td></tr> <tr> <td style="background-color:#f7f7f7">            EndIf  </td></tr> <tr> <td>            </font><font style="color:blue">If</font><font style="font-size:11px"> (y &lt; 0 </font><font style="color:blue">Or</font><font style="font-size:11px"> y &gt; GraphicsWindow.Height - ENEMYSIZE) </font><font style="color:blue">Then</font><font style="font-size:11px"> </font></td></tr> <tr> <td style="background-color:#f7f7f7">                Array.SetValue(</font><font style="color:blue">&quot;speed&quot;</font><font style="font-size:11px">, i, -Array.GetValue(</font><font style="color:blue">&quot;speed&quot;</font><font style="font-size:11px">, i))  </font></td></tr> <tr> <td>            EndIf  </td></tr> <tr> <td style="background-color:#f7f7f7">            Array.SetValue(</font><font style="color:blue">&quot;x&quot;</font><font style="font-size:11px">, i, x)  </font></td></tr> <tr> <td>            Array.SetValue(</font><font style="color:blue">&quot;y&quot;</font><font style="font-size:11px">, i, y)  </font></td></tr> <tr> <td style="background-color:#f7f7f7">            GraphicsWindow.MoveShape(Array.GetValue(</font><font style="color:blue">&quot;balls&quot;</font><font style="font-size:11px">, i), x, y)  </font></td></tr> <tr> <td>              </td></tr> <tr> <td style="background-color:#f7f7f7">            </font><font style="color:blue">If</font><font style="font-size:11px"> (Math.Abs((currentX + (PLAYERSIZE / 2)) - (x + (ENEMYSIZE / 2))) &lt; ((PLAYERSIZE + ENEMYSIZE) / 2) </font><font style="color:blue">And</font><font style="font-size:11px"> Math.Abs((currentY + (PLAYERSIZE / 2)) - (y + (ENEMYSIZE / 2))) &lt; ((PLAYERSIZE + ENEMYSIZE) / 2)) </font><font style="color:blue">Then</font><font style="font-size:11px"> </font></td></tr> <tr> <td>                alive = </font><font style="color:blue">&quot;false&quot;</font><font style="font-size:11px"> </font></td></tr> <tr> <td style="background-color:#f7f7f7">            EndIf  </td></tr> <tr> <td>              </td></tr> <tr> <td style="background-color:#f7f7f7">        EndFor  </td></tr> <tr> <td>          </td></tr> <tr> <td style="background-color:#f7f7f7">        </font><font style="color:blue">If</font><font style="font-size:11px"> (Math.Abs((currentX + (PLAYERSIZE / 2)) - (targetBallX + (TARGESIZE / 2))) &lt; ((PLAYERSIZE + TARGESIZE) / 2) </font><font style="color:blue">And</font><font style="font-size:11px"> Math.Abs((currentY + (PLAYERSIZE / 2)) - (targetBallY + (TARGESIZE / 2))) &lt; ((PLAYERSIZE + TARGESIZE) / 2)) </font><font style="color:blue">Then</font><font style="font-size:11px"> </font></td></tr> <tr> <td>            score = score + 2000 + numberOfBalls * 100  </td></tr> <tr> <td style="background-color:#f7f7f7">            </font><font style="color:blue">If</font><font style="font-size:11px"> (bonus &gt; 0) </font><font style="color:blue">Then</font><font style="font-size:11px"> </font></td></tr> <tr> <td>                score = score + bonus  </td></tr> <tr> <td style="background-color:#f7f7f7">            EndIf  </td></tr> <tr> <td>            bonus = 1000  </td></tr> <tr> <td style="background-color:#f7f7f7">            MoveTargetBall()  </td></tr> <tr> <td>            AddNewEnemy()  </td></tr> <tr> <td style="background-color:#f7f7f7">        EndIf  </td></tr> <tr> <td>          </td></tr> <tr> <td style="background-color:#f7f7f7">        bonus = bonus - 1  </td></tr> <tr> <td> </td></tr> <tr> <td style="background-color:#f7f7f7">        GraphicsWindow.Title = </font><font style="color:blue">&quot;Score: &quot;</font><font style="font-size:11px"> + score  </font></td></tr> <tr> <td>    EndWhile  </td></tr> <tr> <td style="background-color:#f7f7f7">EndSub  </td></tr> <tr> <td> </td></tr> <tr> <td style="background-color:#f7f7f7"></font><font style="color:blue">Sub</font><font style="font-size:11px"> AddNewEnemy  </font></td></tr> <tr> <td>    GraphicsWindow.BrushColor = </font><font style="color:blue">&quot;SteelBlue&quot;</font><font style="font-size:11px"> </font></td></tr> <tr> <td style="background-color:#f7f7f7">    ball = GraphicsWindow.AddEllipse(ENEMYSIZE, ENEMYSIZE)  </td></tr> <tr> <td>    Array.SetValue(</font><font style="color:blue">&quot;balls&quot;</font><font style="font-size:11px">, numberOfBalls, ball)  </font></td></tr> <tr> <td style="background-color:#f7f7f7">    Array.SetValue(</font><font style="color:blue">&quot;axis&quot;</font><font style="font-size:11px">, numberOfBalls, Math.GetRandomNumber(2) + 1)  </font></td></tr> <tr> <td>    Array.SetValue(</font><font style="color:blue">&quot;x&quot;</font><font style="font-size:11px">, numberOfBalls, GraphicsWindow.Height - Math.GetRandomNumber(GraphicsWindow.Height - ENEMYSIZE))  </font></td></tr> <tr> <td style="background-color:#f7f7f7">    Array.SetValue(</font><font style="color:blue">&quot;y&quot;</font><font style="font-size:11px">, numberOfBalls, GraphicsWindow.Width - Math.GetRandomNumber(GraphicsWindow.Width - ENEMYSIZE))  </font></td></tr> <tr> <td>    Array.SetValue(</font><font style="color:blue">&quot;speed&quot;</font><font style="font-size:11px">, numberOfBalls, Math.GetRandomNumber(4) + 1)  </font></td></tr> <tr> <td style="background-color:#f7f7f7">    GraphicsWindow.MoveShape(ball, Array.GetValue(</font><font style="color:blue">&quot;x&quot;</font><font style="font-size:11px">, numberOfBalls), Array.GetValue(</font><font style="color:blue">&quot;y&quot;</font><font style="font-size:11px">, numberOfBalls))  </font></td></tr> <tr> <td>    numberOfBalls = numberOfBalls + 1  </td></tr> <tr> <td style="background-color:#f7f7f7">    axis = -axis  </td></tr> <tr> <td>EndSub  </td></tr> <tr> <td style="background-color:#f7f7f7"> </td></tr> <tr> <td></font><font style="color:blue">Sub</font><font style="font-size:11px"> MoveTargetBall  </font></td></tr> <tr> <td style="background-color:#f7f7f7">    targetBallX = GraphicsWindow.Height - Math.GetRandomNumber(GraphicsWindow.Height - TARGESIZE)  </td></tr> <tr> <td>    targetBallY = GraphicsWindow.Width - Math.GetRandomNumber(GraphicsWindow.Width - TARGESIZE)  </td></tr> <tr> <td style="background-color:#f7f7f7">    GraphicsWindow.MoveShape(targetBall, targetBallX, targetBallY)  </td></tr> <tr> <td>EndSub  </td></tr> <tr> <td style="background-color:#f7f7f7"> </td></tr> <tr> <td></font><font style="color:blue">Sub</font><font style="font-size:11px"> OnKeyDown  </font></td></tr> <tr> <td style="background-color:#f7f7f7">    key = GraphicsWindow.LastKey  </td></tr> <tr> <td>    </font><font style="color:blue">If</font><font style="font-size:11px"> (key = </font><font style="color:blue">&quot;Down&quot;</font><font style="font-size:11px">) </font><font style="color:blue">Then</font><font style="font-size:11px"> </font></td></tr> <tr> <td style="background-color:#f7f7f7">        </font><font style="color:blue">If</font><font style="font-size:11px"> (newY = 0) </font><font style="color:blue">Then</font><font style="font-size:11px"> </font></td></tr> <tr> <td>            newY = 1  </td></tr> <tr> <td style="background-color:#f7f7f7">        </font><font style="color:blue">Else</font><font style="font-size:11px"> </font></td></tr> <tr> <td>            newY = 0  </td></tr> <tr> <td style="background-color:#f7f7f7">        EndIf  </td></tr> <tr> <td>    EndIf  </td></tr> <tr> <td style="background-color:#f7f7f7">    </font><font style="color:blue">If</font><font style="font-size:11px"> (key = </font><font style="color:blue">&quot;Up&quot;</font><font style="font-size:11px">) </font><font style="color:blue">Then</font><font style="font-size:11px"> </font></td></tr> <tr> <td>        </font><font style="color:blue">If</font><font style="font-size:11px"> (newY = 0) </font><font style="color:blue">Then</font><font style="font-size:11px"> </font></td></tr> <tr> <td style="background-color:#f7f7f7">            newY = -1  </td></tr> <tr> <td>        </font><font style="color:blue">Else</font><font style="font-size:11px"> </font></td></tr> <tr> <td style="background-color:#f7f7f7">            newY = 0  </td></tr> <tr> <td>        EndIf  </td></tr> <tr> <td style="background-color:#f7f7f7">    EndIf  </td></tr> <tr> <td>    </font><font style="color:blue">If</font><font style="font-size:11px"> (key = </font><font style="color:blue">&quot;Left&quot;</font><font style="font-size:11px">) </font><font style="color:blue">Then</font><font style="font-size:11px"> </font></td></tr> <tr> <td style="background-color:#f7f7f7">        </font><font style="color:blue">If</font><font style="font-size:11px"> (newX = 0) </font><font style="color:blue">Then</font><font style="font-size:11px"> </font></td></tr> <tr> <td>            newX = -1  </td></tr> <tr> <td style="background-color:#f7f7f7">        </font><font style="color:blue">Else</font><font style="font-size:11px"> </font></td></tr> <tr> <td>            newX = 0  </td></tr> <tr> <td style="background-color:#f7f7f7">        EndIf  </td></tr> <tr> <td>    EndIf  </td></tr> <tr> <td style="background-color:#f7f7f7">    </font><font style="color:blue">If</font><font style="font-size:11px"> (key = </font><font style="color:blue">&quot;Right&quot;</font><font style="font-size:11px">) </font><font style="color:blue">Then</font><font style="font-size:11px"> </font></td></tr> <tr> <td>        </font><font style="color:blue">If</font><font style="font-size:11px"> (newX = 0) </font><font style="color:blue">Then</font><font style="font-size:11px"> </font></td></tr> <tr> <td style="background-color:#f7f7f7">            newX = 1  </td></tr> <tr> <td>        </font><font style="color:blue">Else</font><font style="font-size:11px"> </font></td></tr> <tr> <td style="background-color:#f7f7f7">            newX = 0  </td></tr> <tr> <td>        EndIf  </td></tr> <tr> <td style="background-color:#f7f7f7">    EndIf  </td></tr> <tr> <td>EndSub </td></tr></tbody></table></div>Tue, 18 Nov 2008 09:20:31 Z2008-11-18T09:20:31Zhttp://social.msdn.microsoft.com/Forums/en-US/smallbasic/thread/eaacf826-9d12-4e3c-aa10-1b2788f160a6#3b140687-8f0f-4e75-83b9-719d4a035949http://social.msdn.microsoft.com/Forums/en-US/smallbasic/thread/eaacf826-9d12-4e3c-aa10-1b2788f160a6#3b140687-8f0f-4e75-83b9-719d4a035949Vijaye Rajihttp://social.msdn.microsoft.com/Profile/en-US/?user=Vijaye%20RajiPost your sample source code here and get featured on our blogs! Here's a screenshot for Nidzo's game.  It was a blast!<br><br><img src="http://smallbasic.com/drop/ballgame.jpg">Tue, 18 Nov 2008 10:43:47 Z2008-11-18T10:43:47Zhttp://social.msdn.microsoft.com/Forums/en-US/smallbasic/thread/eaacf826-9d12-4e3c-aa10-1b2788f160a6#af7aeab5-c808-4fdb-91c3-5c1df8b53e90http://social.msdn.microsoft.com/Forums/en-US/smallbasic/thread/eaacf826-9d12-4e3c-aa10-1b2788f160a6#af7aeab5-c808-4fdb-91c3-5c1df8b53e90George Birbilishttp://social.msdn.microsoft.com/Profile/en-US/?user=George%20BirbilisPost your sample source code here and get featured on our blogs!Please when you post samples deselect the &quot;line numbers&quot; option. It's not well implemented in the forums and one copy-pastes the numbers too with the code (should have a real HTML table ther instead, probably they use a CSS layout or something). Bad for beginners that want to try some sample<hr class="sig">Microsoft MVP J# 2004-2007, Borland Spirit of Delphi 2001Fri, 21 Nov 2008 21:15:07 Z2008-11-21T21:15:07Zhttp://social.msdn.microsoft.com/Forums/en-US/smallbasic/thread/eaacf826-9d12-4e3c-aa10-1b2788f160a6#adeb8f71-a4b9-471b-bef3-05a66816f7f3http://social.msdn.microsoft.com/Forums/en-US/smallbasic/thread/eaacf826-9d12-4e3c-aa10-1b2788f160a6#adeb8f71-a4b9-471b-bef3-05a66816f7f3Rodrigo1794http://social.msdn.microsoft.com/Profile/en-US/?user=Rodrigo1794Post your sample source code here and get featured on our blogs!Well this is my 1st &quot;app&quot; made in SB. It's a console slot machine (?) It's not really hard to code at all, and SB makes it easier. It still needs some work on it to make it smaller. It's in spanish, sorry =/<br><br><div style="overflow:auto;background-color:white;line-height:100% ! important;font-family:Courier New;font-size:11px"><table style="border-width:0px;margin:2px 0px;width:99%;border-collapse:collapse;background-color:rgb(255, 255, 255)" cellpadding=0 cellspacing=0><col style="font-family:Courier New;font-size:11px;padding-left:10px;white-space:nowrap"><tbody><tr><td><font style="font-size:11px">'Tragamonedas de consola por Rodrigo Bellusci 2008</font></td></tr><tr><td style="background-color:rgb(247, 247, 247)">'Hecho en Microsoft SmallBasic© </td></tr><tr><td><font style="color:red">dinero</font><font style="font-size:11px"> = </font><font style="color:blue">500</font><font style="font-size:11px"> </font></td></tr><tr><td style="background-color:rgb(247, 247, 247)"> </td></tr><tr><td>TextWindow.WriteLine(&quot;Introduzca su nombre:&quot;) </td></tr><tr><td style="background-color:rgb(247, 247, 247)"><font style="color:red">name</font><font style="font-size:11px"> = </font><font style="color:blue">TextWindow</font><font style="font-size:11px">.Read() </font></td></tr><tr><td>TextWindow.WriteLine(&quot;Bien Sr/a.&quot; + name + &quot;. Su cantidad de dinero es:$&quot; + dinero) </td></tr><tr><td style="background-color:rgb(247, 247, 247)">apuestaStart: </td></tr><tr><td>TextWindow.Write(&quot;¿Cuánto quiere apostar?:&quot;) </td></tr><tr><td style="background-color:rgb(247, 247, 247)"><font style="color:red">apuesta</font><font style="font-size:11px"> = </font><font style="color:blue">TextWindow</font><font style="font-size:11px">.Read() </font></td></tr><tr><td>If (apuesta <font style="color:blue">&gt;</font><font style="font-size:11px"> dinero) Then </font></td></tr><tr><td style="background-color:rgb(247, 247, 247)">TextWindow.WriteLine(&quot;No puedes apostar más de lo que tienes.&quot;) </td></tr><tr><td>Goto apuestaStart </td></tr><tr><td style="background-color:rgb(247, 247, 247)">EndIf </td></tr><tr><td>TextWindow.WriteLine(&quot;Apuesta hecha&quot;) </td></tr><tr><td style="background-color:rgb(247, 247, 247)"> </td></tr><tr><td><font style="color:red">nro1</font><font style="font-size:11px"> = </font><font style="color:blue">Math</font><font style="font-size:11px">.GetRandomNumber(2) </font></td></tr><tr><td style="background-color:rgb(247, 247, 247)"><font style="color:red">nro2</font><font style="font-size:11px"> = </font><font style="color:blue">Math</font><font style="font-size:11px">.GetRandomNumber(1) </font></td></tr><tr><td> </td></tr><tr><td style="background-color:rgb(247, 247, 247)">TextWindow.Write(&quot;| &quot;) </td></tr><tr><td>TextWindow.Write(nro1) </td></tr><tr><td style="background-color:rgb(247, 247, 247)">TextWindow.Write(&quot; |&quot;) </td></tr><tr><td>TextWindow.Write(&quot; &quot;) </td></tr><tr><td style="background-color:rgb(247, 247, 247)">TextWindow.Write(&quot;| &quot;) </td></tr><tr><td>TextWindow.Write(nro2) </td></tr><tr><td style="background-color:rgb(247, 247, 247)">TextWindow.Write(&quot; |&quot;) </td></tr><tr><td>TextWindow.Write(&quot; &quot;) </td></tr><tr><td style="background-color:rgb(247, 247, 247)"> </td></tr><tr><td>If (<font style="color:red">nro1</font><font style="font-size:11px"> = </font><font style="color:blue">nro2</font><font style="font-size:11px">) Then </font></td></tr><tr><td style="background-color:rgb(247, 247, 247)"><font style="color:red">dinero</font><font style="font-size:11px"></font><font style="color:blue">dinero</font><font style="font-size:11px"> = dinero - apuesta + (apuesta * 2) </font></td></tr><tr><td>TextWindow.Write(&quot;Ha ganado, su dinero es:$&quot;) </td></tr><tr><td style="background-color:rgb(247, 247, 247)">TextWindow.Write(dinero) </td></tr><tr><td>TextWindow.WriteLine(&quot; &quot;) </td></tr><tr><td style="background-color:rgb(247, 247, 247)">Else </td></tr><tr><td><font style="color:red">dinero</font><font style="font-size:11px"></font><font style="color:blue">dinero</font><font style="font-size:11px"> = dinero - apuesta </font></td></tr><tr><td style="background-color:rgb(247, 247, 247)">TextWindow.Write(&quot;Ha perdido. Su dinero es:$&quot;) </td></tr><tr><td>TextWindow.Write(dinero) </td></tr><tr><td style="background-color:rgb(247, 247, 247)">TextWindow.WriteLine(&quot; &quot;) </td></tr><tr><td>EndIf </td></tr><tr><td style="background-color:rgb(247, 247, 247)">If (<font style="color:red">dinero</font><font style="font-size:11px"> = </font><font style="color:blue">0</font><font style="font-size:11px">) Then </font></td></tr><tr><td>TextWindow.WriteLine(&quot;Gracias por jugar.&quot;) </td></tr><tr><td style="background-color:rgb(247, 247, 247)">Goto goodbye </td></tr><tr><td>EndIf </td></tr><tr><td style="background-color:rgb(247, 247, 247)">TextWindow.WriteLine(&quot;Quiere jugar otra vez?:&quot;) </td></tr><tr><td><font style="color:red">replay</font><font style="font-size:11px"> = </font><font style="color:blue">TextWindow</font><font style="font-size:11px">.Read() </font></td></tr><tr><td style="background-color:rgb(247, 247, 247)">If (<font style="color:red">replay</font><font style="font-size:11px"> = </font><font style="color:blue">&quot;Si&quot;</font><font style="font-size:11px">) Then </font></td></tr><tr><td>Goto apuestaStart </td></tr><tr><td style="background-color:rgb(247, 247, 247)">EndIf </td></tr><tr><td>goodbye: </td></tr><tr><td style="background-color:rgb(247, 247, 247)">TextWindow.WriteLine(&quot;Vuelva pronto.&quot;) </td></tr></tbody></table></div><br><a href="http://img357.imageshack.us/my.php?image=dibujous3.jpg">Pic</a><br><br>P.S: My english isn't so good, sorry. I'm from Argentina<br> Sun, 23 Nov 2008 02:14:44 Z2008-11-23T02:22:04Zhttp://social.msdn.microsoft.com/Forums/en-US/smallbasic/thread/eaacf826-9d12-4e3c-aa10-1b2788f160a6#9fd11d13-7295-4892-b69c-80397ccb5a10http://social.msdn.microsoft.com/Forums/en-US/smallbasic/thread/eaacf826-9d12-4e3c-aa10-1b2788f160a6#9fd11d13-7295-4892-b69c-80397ccb5a10bleary.nchttp://social.msdn.microsoft.com/Profile/en-US/?user=bleary.ncPost your sample source code here and get featured on our blogs!This is fun! Thanks!<br><br>This program performs two sorts on colored cubes in a window - a bubble sort and a selection sort.<br><br><div style="overflow:auto;background-color:white;line-height:100% ! important;font-family:Courier New;font-size:11px"><table style="border-width:0px;margin:2px 0px;width:99%;border-collapse:collapse;background-color:rgb(255, 255, 255)" cellpadding=0 cellspacing=0><col style="font-family:Courier New;font-size:11px;padding-left:10px;white-space:nowrap"><tbody><tr><td><font style="font-size:11px"></font><font style="color:green">'Globals</font><font style="font-size:11px"> </font></td></tr><tr><td style="background-color:rgb(247, 247, 247)">xlimit = 10 </td></tr><tr><td>ylimit = 10 </td></tr><tr><td style="background-color:rgb(247, 247, 247)">cs = 64 </td></tr><tr><td>cellcnt = xlimit * ylimit </td></tr><tr><td style="background-color:rgb(247, 247, 247)">GraphicsWindow.BackgroundColor = <font style="color:blue">&quot;Khaki&quot;</font><font style="font-size:11px"> </font></td></tr><tr><td>GraphicsWindow.Title = <font style="color:blue">&quot;bsort&quot;</font><font style="font-size:11px"> </font></td></tr><tr><td style="background-color:rgb(247, 247, 247)">GraphicsWindow.Width = (xlimit * cs) </td></tr><tr><td>GraphicsWindow.Height = (ylimit * cs) </td></tr><tr><td style="background-color:rgb(247, 247, 247)">GraphicsWindow.Show() </td></tr><tr><td> </td></tr><tr><td style="background-color:rgb(247, 247, 247)">InitParr() </td></tr><tr><td>GraphicsWindow.Title = <font style="color:blue">&quot;bsort, click in window to start bubble sort&quot;</font><font style="font-size:11px"> </font></td></tr><tr><td style="background-color:rgb(247, 247, 247)">Pause() </td></tr><tr><td>BubbleSort() </td></tr><tr><td style="background-color:rgb(247, 247, 247)">wtitle = GraphicsWindow.Title </td></tr><tr><td>GraphicsWindow.Title = GraphicsWindow.Title + <font style="color:blue">&quot; ; click in window to start selection sort&quot;</font><font style="font-size:11px"> </font></td></tr><tr><td style="background-color:rgb(247, 247, 247)">Pause() </td></tr><tr><td>SelectionSort() </td></tr><tr><td style="background-color:rgb(247, 247, 247)">wtitle = GraphicsWindow.Title </td></tr><tr><td>GraphicsWindow.Title = GraphicsWindow.Title + <font style="color:blue">&quot; ; click in window to exit&quot;</font><font style="font-size:11px"> </font></td></tr><tr><td style="background-color:rgb(247, 247, 247)">Pause() </td></tr><tr><td>Program.<font style="color:blue">End</font><font style="font-size:11px">() </font></td></tr><tr><td style="background-color:rgb(247, 247, 247)"> </td></tr><tr><td><font style="color:blue">Sub</font><font style="font-size:11px"> BubbleSort </font></td></tr><tr><td style="background-color:rgb(247, 247, 247)">    DrawSarr() </td></tr><tr><td>    stopSort = 0  </td></tr><tr><td style="background-color:rgb(247, 247, 247)">    GraphicsWindow.Title = <font style="color:blue">&quot;bubble+shaker sort, &quot;</font><font style="font-size:11px"> + cellcnt + </font><font style="color:blue">&quot; cells, sorting ... press any key to stop&quot;</font><font style="font-size:11px"> </font></td></tr><tr><td>    GraphicsWindow.KeyDown = onKey </td></tr><tr><td style="background-color:rgb(247, 247, 247)">    base = 1 </td></tr><tr><td>    slimit = cellcnt - 1 </td></tr><tr><td style="background-color:rgb(247, 247, 247)">    swap = 1 </td></tr><tr><td>    <font style="color:blue">While</font><font style="font-size:11px"> (swap &gt; 0) </font></td></tr><tr><td style="background-color:rgb(247, 247, 247)">        swap = 0 </td></tr><tr><td>        <font style="color:blue">For</font><font style="font-size:11px"> ai = base </font><font style="color:blue">To</font><font style="font-size:11px"> slimit </font></td></tr><tr><td style="background-color:rgb(247, 247, 247)">            <font style="color:blue">If</font><font style="font-size:11px"> (stopSort = 1) </font><font style="color:blue">Then</font><font style="font-size:11px"> </font></td></tr><tr><td>                Goto stopBubble </td></tr><tr><td style="background-color:rgb(247, 247, 247)">            EndIf </td></tr><tr><td>            bubbleCmpSwp() </td></tr><tr><td style="background-color:rgb(247, 247, 247)">        EndFor </td></tr><tr><td>        <font style="color:green">' plus shaker, turn turtles to rabits</font><font style="font-size:11px"> </font></td></tr><tr><td style="background-color:rgb(247, 247, 247)">        <font style="color:blue">If</font><font style="font-size:11px"> (swap = 0) </font><font style="color:blue">Then</font><font style="font-size:11px"> </font></td></tr><tr><td>            Goto stopBubble </td></tr><tr><td style="background-color:rgb(247, 247, 247)">        EndIf </td></tr><tr><td>        <font style="color:green">' For i = (slimit - 1) To 1 Step -1 -- bug, for won't count down</font><font style="font-size:11px"> </font></td></tr><tr><td style="background-color:rgb(247, 247, 247)">        ai = slimit - 1 </td></tr><tr><td>        <font style="color:blue">While</font><font style="font-size:11px"> (ai &gt;= base)  </font></td></tr><tr><td style="background-color:rgb(247, 247, 247)">            <font style="color:blue">If</font><font style="font-size:11px"> (stopSort = 1) </font><font style="color:blue">Then</font><font style="font-size:11px"> </font></td></tr><tr><td>                Goto stopBubble </td></tr><tr><td style="background-color:rgb(247, 247, 247)">            EndIf </td></tr><tr><td>            bubbleCmpSwp() </td></tr><tr><td style="background-color:rgb(247, 247, 247)">            ai = ai - 1 </td></tr><tr><td>        EndWhile </td></tr><tr><td style="background-color:rgb(247, 247, 247)">        base = base + 1 </td></tr><tr><td>        slimit = slimit - 1 </td></tr><tr><td style="background-color:rgb(247, 247, 247)">     EndWhile </td></tr><tr><td>    stopBubble: </td></tr><tr><td style="background-color:rgb(247, 247, 247)">        GraphicsWindow.Title = <font style="color:blue">&quot;bubble sort, &quot;</font><font style="font-size:11px"> + cellcnt + </font><font style="color:blue">&quot; cells, &quot;</font><font style="font-size:11px"> + cmpCnt + </font><font style="color:blue">&quot; cmp &quot;</font><font style="font-size:11px"> + swpCnt + </font><font style="color:blue">&quot; swp&quot;</font><font style="font-size:11px"> </font></td></tr><tr><td>EndSub </td></tr><tr><td style="background-color:rgb(247, 247, 247)"> </td></tr><tr><td><font style="color:blue">Sub</font><font style="font-size:11px"> SelectionSort </font></td></tr><tr><td style="background-color:rgb(247, 247, 247)">    DrawSarr() </td></tr><tr><td>    stopSort = 0  </td></tr><tr><td style="background-color:rgb(247, 247, 247)">    GraphicsWindow.Title = <font style="color:blue">&quot;selection sort, &quot;</font><font style="font-size:11px"> + cellcnt + </font><font style="color:blue">&quot; cells, sorting ... press any key to stop&quot;</font><font style="font-size:11px"> </font></td></tr><tr><td>    GraphicsWindow.KeyDown = onKey </td></tr><tr><td style="background-color:rgb(247, 247, 247)">    <font style="color:blue">For</font><font style="font-size:11px"> ai = 1 </font><font style="color:blue">To</font><font style="font-size:11px"> cellcnt - 1 </font></td></tr><tr><td>        a = Array.GetValue(<font style="color:blue">&quot;sarr&quot;</font><font style="font-size:11px">,ai) </font></td></tr><tr><td style="background-color:rgb(247, 247, 247)">        minbi = ai </td></tr><tr><td>        <font style="color:blue">For</font><font style="font-size:11px"> i = (ai + 1) </font><font style="color:blue">To</font><font style="font-size:11px"> cellcnt </font></td></tr><tr><td style="background-color:rgb(247, 247, 247)">            <font style="color:blue">If</font><font style="font-size:11px"> (stopSort = 1) </font><font style="color:blue">Then</font><font style="font-size:11px"> </font></td></tr><tr><td>                Goto stopSelection </td></tr><tr><td style="background-color:rgb(247, 247, 247)">            EndIf </td></tr><tr><td>            b = Array.GetValue(<font style="color:blue">&quot;sarr&quot;</font><font style="font-size:11px">,i) </font></td></tr><tr><td style="background-color:rgb(247, 247, 247)">            cmpCnt = cmpCnt + 1 </td></tr><tr><td>            <font style="color:blue">If</font><font style="font-size:11px"> (b &lt; a) </font><font style="color:blue">Then</font><font style="font-size:11px"> </font></td></tr><tr><td style="background-color:rgb(247, 247, 247)">                minbi = i </td></tr><tr><td>                a = b </td></tr><tr><td style="background-color:rgb(247, 247, 247)">            EndIf </td></tr><tr><td>        EndFor </td></tr><tr><td style="background-color:rgb(247, 247, 247)">        <font style="color:blue">If</font><font style="font-size:11px"> (ai &lt;&gt; minbi) </font><font style="color:blue">Then</font><font style="font-size:11px"> </font></td></tr><tr><td>            bi = minbi </td></tr><tr><td style="background-color:rgb(247, 247, 247)">            SwapAB() </td></tr><tr><td>        EndIf </td></tr><tr><td style="background-color:rgb(247, 247, 247)">    EndFor </td></tr><tr><td>    stopSelection: </td></tr><tr><td style="background-color:rgb(247, 247, 247)">    GraphicsWindow.Title = <font style="color:blue">&quot;selection sort, &quot;</font><font style="font-size:11px"> + cellcnt + </font><font style="color:blue">&quot; cells, &quot;</font><font style="font-size:11px"> + cmpCnt + </font><font style="color:blue">&quot; cmp &quot;</font><font style="font-size:11px"> + swpCnt + </font><font style="color:blue">&quot; swp&quot;</font><font style="font-size:11px"> </font></td></tr><tr><td>EndSub </td></tr><tr><td style="background-color:rgb(247, 247, 247)"> </td></tr><tr><td><font style="color:blue">Sub</font><font style="font-size:11px"> Pause </font></td></tr><tr><td style="background-color:rgb(247, 247, 247)">    wait = 1 </td></tr><tr><td>    GraphicsWindow.MouseDown = Unwait </td></tr><tr><td style="background-color:rgb(247, 247, 247)">    <font style="color:blue">While</font><font style="font-size:11px"> (wait = 1) </font></td></tr><tr><td>        Program.Delay(250) </td></tr><tr><td style="background-color:rgb(247, 247, 247)">    EndWhile </td></tr><tr><td>EndSub </td></tr><tr><td style="background-color:rgb(247, 247, 247)"> </td></tr><tr><td><font style="color:blue">Sub</font><font style="font-size:11px"> Unwait </font></td></tr><tr><td style="background-color:rgb(247, 247, 247)">    wait = 0 </td></tr><tr><td>EndSub </td></tr><tr><td style="background-color:rgb(247, 247, 247)"> </td></tr><tr><td>sub onKey </td></tr><tr><td style="background-color:rgb(247, 247, 247)">    stopSort = 1 </td></tr><tr><td>EndSub </td></tr><tr><td style="background-color:rgb(247, 247, 247)">     </td></tr><tr><td> </td></tr><tr><td style="background-color:rgb(247, 247, 247)">sub getXY </td></tr><tr><td>            lindex = index - 1 </td></tr><tr><td style="background-color:rgb(247, 247, 247)">            x = Math.Remainder(lindex,xlimit) * cs </td></tr><tr><td>            y = Math.Floor((lindex/xlimit)) * cs </td></tr><tr><td style="background-color:rgb(247, 247, 247)">EndSub </td></tr><tr><td> </td></tr><tr><td style="background-color:rgb(247, 247, 247)"><font style="color:blue">Sub</font><font style="font-size:11px"> bubbleCmpSwp </font></td></tr><tr><td>    a = Array.GetValue(<font style="color:blue">&quot;sarr&quot;</font><font style="font-size:11px">,ai) </font></td></tr><tr><td style="background-color:rgb(247, 247, 247)">    b = Array.GetValue(<font style="color:blue">&quot;sarr&quot;</font><font style="font-size:11px">,(ai+1)) </font></td></tr><tr><td>    cmpCnt = cmpCnt + 1 </td></tr><tr><td style="background-color:rgb(247, 247, 247)">    <font style="color:blue">If</font><font style="font-size:11px"> (b &lt; a) </font><font style="color:blue">Then</font><font style="font-size:11px"> </font></td></tr><tr><td>        bi = ai + 1 </td></tr><tr><td style="background-color:rgb(247, 247, 247)">        SwapAB() </td></tr><tr><td>        swap = 1 </td></tr><tr><td style="background-color:rgb(247, 247, 247)">    EndIf </td></tr><tr><td>EndSub </td></tr><tr><td style="background-color:rgb(247, 247, 247)"> </td></tr><tr><td><font style="color:blue">Sub</font><font style="font-size:11px"> SwapAB </font></td></tr><tr><td style="background-color:rgb(247, 247, 247)">    <font style="color:green">'ai, bi are indexes into sarr</font><font style="font-size:11px"> </font></td></tr><tr><td>    la = array.GetValue(<font style="color:blue">&quot;sarr&quot;</font><font style="font-size:11px">,ai) </font></td></tr><tr><td style="background-color:rgb(247, 247, 247)">    lb = array.GetValue(<font style="color:blue">&quot;sarr&quot;</font><font style="font-size:11px">,bi) </font></td></tr><tr><td>    index = ai </td></tr><tr><td style="background-color:rgb(247, 247, 247)">    getXY() </td></tr><tr><td>    GraphicsWindow.BrushColor = Array.GetValue(<font style="color:blue">&quot;carr&quot;</font><font style="font-size:11px">,lb) </font></td></tr><tr><td style="background-color:rgb(247, 247, 247)">    GraphicsWindow.FillRectangle(x,y,cs,cs) </td></tr><tr><td>    index = bi </td></tr><tr><td style="background-color:rgb(247, 247, 247)">    getXY() </td></tr><tr><td>    GraphicsWindow.BrushColor = Array.GetValue(<font style="color:blue">&quot;carr&quot;</font><font style="font-size:11px">,la) </font></td></tr><tr><td style="background-color:rgb(247, 247, 247)">    GraphicsWindow.FillRectangle(x,y,cs,cs) </td></tr><tr><td>    Array.SetValue(<font style="color:blue">&quot;sarr&quot;</font><font style="font-size:11px">,ai,lb) </font></td></tr><tr><td style="background-color:rgb(247, 247, 247)">    Array.SetValue(<font style="color:blue">&quot;sarr&quot;</font><font style="font-size:11px">,bi,la) </font></td></tr><tr><td>    swpCnt = swpCnt + 1 </td></tr><tr><td style="background-color:rgb(247, 247, 247)">EndSub </td></tr><tr><td>             </td></tr><tr><td style="background-color:rgb(247, 247, 247)"><font style="color:blue">Sub</font><font style="font-size:11px"> DrawSarr </font></td></tr><tr><td>    GraphicsWindow.Title = <font style="color:blue">&quot;bsort, initializing sort table&quot;</font><font style="font-size:11px"> </font></td></tr><tr><td style="background-color:rgb(247, 247, 247)">    <font style="color:blue">For</font><font style="font-size:11px"> index = 1 </font><font style="color:blue">To</font><font style="font-size:11px"> cellcnt </font></td></tr><tr><td>        a = Array.GetValue(<font style="color:blue">&quot;parr&quot;</font><font style="font-size:11px">,index) </font></td></tr><tr><td style="background-color:rgb(247, 247, 247)">        Array.SetValue(<font style="color:blue">&quot;sarr&quot;</font><font style="font-size:11px">,index,a) </font></td></tr><tr><td>        getXY() </td></tr><tr><td style="background-color:rgb(247, 247, 247)">        GraphicsWindow.BrushColor = Array.GetValue(<font style="color:blue">&quot;carr&quot;</font><font style="font-size:11px">,a) </font></td></tr><tr><td>        GraphicsWindow.FillRectangle(x,y,cs,cs)  </td></tr><tr><td style="background-color:rgb(247, 247, 247)">    EndFor </td></tr><tr><td>    cmpCnt = 0 </td></tr><tr><td style="background-color:rgb(247, 247, 247)">    swpCnt = 0 </td></tr><tr><td>EndSub </td></tr><tr><td style="background-color:rgb(247, 247, 247)"> </td></tr><tr><td><font style="color:blue">Sub</font><font style="font-size:11px"> InitParr </font></td></tr><tr><td style="background-color:rgb(247, 247, 247)">    <font style="color:green">' Global array of sortable colors</font><font style="font-size:11px"> </font></td></tr><tr><td>    Array.SetValue(<font style="color:blue">&quot;carr&quot;</font><font style="font-size:11px">,1,</font><font style="color:blue">&quot;White&quot;</font><font style="font-size:11px">) </font></td></tr><tr><td style="background-color:rgb(247, 247, 247)">    Array.SetValue(<font style="color:blue">&quot;carr&quot;</font><font style="font-size:11px">,2,</font><font style="color:blue">&quot;Blue&quot;</font><font style="font-size:11px">) </font></td></tr><tr><td>    Array.SetValue(<font style="color:blue">&quot;carr&quot;</font><font style="font-size:11px">,3,</font><font style="color:blue">&quot;Cyan&quot;</font><font style="font-size:11px">) </font></td></tr><tr><td style="background-color:rgb(247, 247, 247)">    Array.SetValue(<font style="color:blue">&quot;carr&quot;</font><font style="font-size:11px">,4,</font><font style="color:blue">&quot;Gray&quot;</font><font style="font-size:11px">) </font></td></tr><tr><td>    Array.SetValue(<font style="color:blue">&quot;carr&quot;</font><font style="font-size:11px">,5,</font><font style="color:blue">&quot;Green&quot;</font><font style="font-size:11px">) </font></td></tr><tr><td style="background-color:rgb(247, 247, 247)">    Array.SetValue(<font style="color:blue">&quot;carr&quot;</font><font style="font-size:11px">,6,</font><font style="color:blue">&quot;Magenta&quot;</font><font style="font-size:11px">) </font></td></tr><tr><td>    Array.SetValue(<font style="color:blue">&quot;carr&quot;</font><font style="font-size:11px">,7,</font><font style="color:blue">&quot;Red&quot;</font><font style="font-size:11px">) </font></td></tr><tr><td style="background-color:rgb(247, 247, 247)">    Array.SetValue(<font style="color:blue">&quot;carr&quot;</font><font style="font-size:11px">,8,</font><font style="color:blue">&quot;Yellow&quot;</font><font style="font-size:11px">) </font></td></tr><tr><td>    Array.SetValue(<font style="color:blue">&quot;carr&quot;</font><font style="font-size:11px">,9,</font><font style="color:blue">&quot;Black&quot;</font><font style="font-size:11px">) </font></td></tr><tr><td style="background-color:rgb(247, 247, 247)">    Array.SetValue(<font style="color:blue">&quot;carr&quot;</font><font style="font-size:11px">,10,</font><font style="color:blue">&quot;DarkBlue&quot;</font><font style="font-size:11px">) </font></td></tr><tr><td>    Array.SetValue(<font style="color:blue">&quot;carr&quot;</font><font style="font-size:11px">,11,</font><font style="color:blue">&quot;CadetBlue&quot;</font><font style="font-size:11px">) </font></td></tr><tr><td style="background-color:rgb(247, 247, 247)">    Array.SetValue(<font style="color:blue">&quot;carr&quot;</font><font style="font-size:11px">,12,</font><font style="color:blue">&quot;DimGray&quot;</font><font style="font-size:11px">) </font></td></tr><tr><td>    Array.SetValue(<font style="color:blue">&quot;carr&quot;</font><font style="font-size:11px">,13,</font><font style="color:blue">&quot;DarkGreen&quot;</font><font style="font-size:11px">) </font></td></tr><tr><td style="background-color:rgb(247, 247, 247)">    Array.SetValue(<font style="color:blue">&quot;carr&quot;</font><font style="font-size:11px">,14,</font><font style="color:blue">&quot;DarkMagenta&quot;</font><font style="font-size:11px">) </font></td></tr><tr><td>    Array.SetValue(<font style="color:blue">&quot;carr&quot;</font><font style="font-size:11px">,15,</font><font style="color:blue">&quot;DarkRed&quot;</font><font style="font-size:11px">) </font></td></tr><tr><td style="background-color:rgb(247, 247, 247)">    Array.SetValue(<font style="color:blue">&quot;carr&quot;</font><font style="font-size:11px">,16,</font><font style="color:blue">&quot;DarkOrange&quot;</font><font style="font-size:11px">) </font></td></tr><tr><td>    <font style="color:green">' build array to sort</font><font style="font-size:11px"> </font></td></tr><tr><td style="background-color:rgb(247, 247, 247)">    <font style="color:blue">For</font><font style="font-size:11px"> i = 1 </font><font style="color:blue">To</font><font style="font-size:11px"> cellcnt </font></td></tr><tr><td>            cell = Math.GetRandomNumber(16) + 1 </td></tr><tr><td style="background-color:rgb(247, 247, 247)">            Array.SetValue(<font style="color:blue">&quot;parr&quot;</font><font style="font-size:11px">,i,cell) </font></td></tr><tr><td>    EndFor </td></tr><tr><td style="background-color:rgb(247, 247, 247)">EndSub </td></tr><tr><td> </td></tr><tr><td style="background-color:rgb(247, 247, 247)"><font style="color:blue">Sub</font><font style="font-size:11px"> DumpSarr </font></td></tr><tr><td>    j = 0 </td></tr><tr><td style="background-color:rgb(247, 247, 247)">    <font style="color:blue">For</font><font style="font-size:11px"> i = 1 </font><font style="color:blue">To</font><font style="font-size:11px"> cellcnt </font></td></tr><tr><td>        j = j +1 </td></tr><tr><td style="background-color:rgb(247, 247, 247)">        TextWindow.Write(Array.GetValue(<font style="color:blue">&quot;sarr&quot;</font><font style="font-size:11px">,i) + </font><font style="color:blue">&quot; &quot;</font><font style="font-size:11px">) </font></td></tr><tr><td>        <font style="color:blue">If</font><font style="font-size:11px"> ( j = 25 ) </font><font style="color:blue">Then</font><font style="font-size:11px"> </font></td></tr><tr><td style="background-color:rgb(247, 247, 247)">            TextWindow.WriteLine(<font style="color:blue">&quot; &quot;</font><font style="font-size:11px">) </font></td></tr><tr><td>            j = 0 </td></tr><tr><td style="background-color:rgb(247, 247, 247)">        EndIf </td></tr><tr><td>    EndFor </td></tr><tr><td style="background-color:rgb(247, 247, 247)">EndSub </td></tr><tr><td> </td></tr></tbody></table></div><br> Sun, 23 Nov 2008 03:35:51 Z2008-11-23T03:35:51Zhttp://social.msdn.microsoft.com/Forums/en-US/smallbasic/thread/eaacf826-9d12-4e3c-aa10-1b2788f160a6#a9613467-ed09-4861-ae10-8915e7b5a14ahttp://social.msdn.microsoft.com/Forums/en-US/smallbasic/thread/eaacf826-9d12-4e3c-aa10-1b2788f160a6#a9613467-ed09-4861-ae10-8915e7b5a14aMatthias Loeuhttp://social.msdn.microsoft.com/Profile/en-US/?user=Matthias%20LoeuPost your sample source code here and get featured on our blogs! Very slow...<br><br> <div style="border-right:#7f9db9 1px solid;border-top:#7f9db9 1px solid;font-size:11px;overflow:auto;border-left:#7f9db9 1px solid;line-height:100%! important;border-bottom:#7f9db9 1px solid;font-family:courier new;background-color:white"> <table style="border-top-width:0px;border-left-width:0px;margin:2px 0px;width:99%;border-bottom:#eee 0px solid;border-collapse:collapse;background-color:#fff;border-right-width:0px" cellspacing=0 cellpadding=0> <colgroup> <col style="padding-left:10px;font-size:11px;border-bottom:#f7f7f7 1px solid;font-family:courier new;white-space:nowrap"></colgroup> <tbody> <tr> <td><font style="font-size:11px"></font><font color="#008000">' Draws the mandelbrot &amp; julia set on the graphics window </font><font style="font-size:11px"> </font></td></tr> <tr> <td style="background-color:#f7f7f7"><font color="#008000">' See http://en.wikipedia.org/wiki/Mandelbrot_set#For_programmers and </font><font style="font-size:11px"> </font></td></tr> <tr> <td><font color="#008000">' http://en.wikipedia.org/wiki/Julia_set </font><font style="font-size:11px"> </font></td></tr> <tr> <td style="background-color:#f7f7f7"><font color="#008000">'  </font><font style="font-size:11px"> </font></td></tr> <tr> <td><font color="#008000">' Author: Matthias Loeu </font><font style="font-size:11px"> </font></td></tr> <tr> <td style="background-color:#f7f7f7"><font color="#008000">' Date: 24 November 2008 </font><font style="font-size:11px"> </font></td></tr> <tr> <td> </td></tr> <tr> <td style="background-color:#f7f7f7">GraphicsWindow.Show()  </td></tr> <tr> <td><font color="#008000">' Size of the window (make it &gt;= resolution) </font><font style="font-size:11px"> </font></td></tr> <tr> <td style="background-color:#f7f7f7">GraphicsWindow.Width = 800  </td></tr> <tr> <td>GraphicsWindow.Height = 800  </td></tr> <tr> <td style="background-color:#f7f7f7"><font color="#008000">' Resolution of the rendering, higher = better &amp; slower </font><font style="font-size:11px"> </font></td></tr> <tr> <td>resolutionx = 300  </td></tr> <tr> <td style="background-color:#f7f7f7">resolutiony = 300  </td></tr> <tr> <td><font color="#008000">' The section of the complex plane we are interested in (x + y*i) </font><font style="font-size:11px"> </font></td></tr> <tr> <td style="background-color:#f7f7f7">minx = -1.5  </td></tr> <tr> <td>miny = -1.3  </td></tr> <tr> <td style="background-color:#f7f7f7">maxx = 1.5  </td></tr> <tr> <td>maxy = 1.3  </td></tr> <tr> <td style="background-color:#f7f7f7"><font color="#008000">' The complex parameter (for the julia set) </font><font style="font-size:11px"> </font></td></tr> <tr> <td>cx = -0.4  </td></tr> <tr> <td style="background-color:#f7f7f7">cy = 0.6  </td></tr> <tr> <td><font color="#008000">' Draw the mandelbrot (1) or julia (0) </font><font style="font-size:11px"> </font></td></tr> <tr> <td style="background-color:#f7f7f7">draw_mandelbrot = 0  </td></tr> <tr> <td><font color="#008000">' Max number of iterations, higher = more accurate &amp; slower </font><font style="font-size:11px"> </font></td></tr> <tr> <td style="background-color:#f7f7f7">max_iter = 500  </td></tr> <tr> <td> </td></tr> <tr> <td style="background-color:#f7f7f7"><font color="#0000ff">If</font><font style="font-size:11px"> (minx &gt; maxx) </font><font color="#0000ff">Then</font><font style="font-size:11px"> </font></td></tr> <tr> <td>    t = minx  </td></tr> <tr> <td style="background-color:#f7f7f7">    minx = maxx  </td></tr> <tr> <td>    maxx = t  </td></tr> <tr> <td style="background-color:#f7f7f7">EndIf  </td></tr> <tr> <td><font color="#0000ff">If</font><font style="font-size:11px"> (miny &gt; maxy) </font><font color="#0000ff">Then</font><font style="font-size:11px"> </font></td></tr> <tr> <td style="background-color:#f7f7f7">    t = miny  </td></tr> <tr> <td>    miny = maxy  </td></tr> <tr> <td style="background-color:#f7f7f7">    maxy = t  </td></tr> <tr> <td>EndIf  </td></tr> <tr> <td style="background-color:#f7f7f7"><font color="#008000">'TextWindow.WriteLine(&quot;min (&quot; + minx + &quot;, &quot; + miny + &quot;)&quot;) </font><font style="font-size:11px"> </font></td></tr> <tr> <td><font color="#008000">'TextWindow.WriteLine(&quot;max (&quot; + maxx + &quot;, &quot; + maxy + &quot;)&quot;) </font><font style="font-size:11px"> </font></td></tr> <tr> <td style="background-color:#f7f7f7"><font color="#008000">' Step size, in the complex plane </font><font style="font-size:11px"> </font></td></tr> <tr> <td>stepx = (maxx - minx)/resolutionx  </td></tr> <tr> <td style="background-color:#f7f7f7">stepy = (maxy - miny)/resolutiony  </td></tr> <tr> <td><font color="#008000">' Size of a &quot;pixel&quot; </font><font style="font-size:11px"> </font></td></tr> <tr> <td style="background-color:#f7f7f7">sizex = GraphicsWindow.Width / resolutionx  </td></tr> <tr> <td>sizey = GraphicsWindow.Height / resolutiony  </td></tr> <tr> <td style="background-color:#f7f7f7"><font color="#008000">' The colors </font><font style="font-size:11px"> </font></td></tr> <tr> <td>Array.SetValue(<font color="#0000ff">&quot;color&quot;</font><font style="font-size:11px">, 0, </font><font color="#0000ff">&quot;white&quot;</font><font style="font-size:11px">)  </font></td></tr> <tr> <td style="background-color:#f7f7f7">Array.SetValue(<font color="#0000ff">&quot;color&quot;</font><font style="font-size:11px">, 1, </font><font color="#0000ff">&quot;lavender&quot;</font><font style="font-size:11px">)  </font></td></tr> <tr> <td>Array.SetValue(<font color="#0000ff">&quot;color&quot;</font><font style="font-size:11px">, 2, </font><font color="#0000ff">&quot;thistle&quot;</font><font style="font-size:11px">)  </font></td></tr> <tr> <td style="background-color:#f7f7f7">Array.SetValue(<font color="#0000ff">&quot;color&quot;</font><font style="font-size:11px">, 3, </font><font color="#0000ff">&quot;plum&quot;</font><font style="font-size:11px">)  </font></td></tr> <tr> <td>Array.SetValue(<font color="#0000ff">&quot;color&quot;</font><font style="font-size:11px">, 4, </font><font color="#0000ff">&quot;violet&quot;</font><font style="font-size:11px">)  </font></td></tr> <tr> <td style="background-color:#f7f7f7">Array.SetValue(<font color="#0000ff">&quot;color&quot;</font><font style="font-size:11px">, 5, </font><font color="#0000ff">&quot;orchid&quot;</font><font style="font-size:11px">)  </font></td></tr> <tr> <td>Array.SetValue(<font color="#0000ff">&quot;color&quot;</font><font style="font-size:11px">, 6, </font><font color="#0000ff">&quot;fuchsia&quot;</font><font style="font-size:11px">)  </font></td></tr> <tr> <td style="background-color:#f7f7f7">Array.SetValue(<font color="#0000ff">&quot;color&quot;</font><font style="font-size:11px">, 7, </font><font color="#0000ff">&quot;mediumorchid&quot;</font><font style="font-size:11px">)  </font></td></tr> <tr> <td>Array.SetValue(<font color="#0000ff">&quot;color&quot;</font><font style="font-size:11px">, 8, </font><font color="#0000ff">&quot;mediumpurple&quot;</font><font style="font-size:11px">)  </font></td></tr> <tr> <td style="background-color:#f7f7f7">Array.SetValue(<font color="#0000ff">&quot;color&quot;</font><font style="font-size:11px">, 9, </font><font color="#0000ff">&quot;blueviolet&quot;</font><font style="font-size:11px">)  </font></td></tr> <tr> <td>Array.SetValue(<font color="#0000ff">&quot;color&quot;</font><font style="font-size:11px">, 10, </font><font color="#0000ff">&quot;darkviolet&quot;</font><font style="font-size:11px">)  </font></td></tr> <tr> <td style="background-color:#f7f7f7">Array.SetValue(<font color="#0000ff">&quot;color&quot;</font><font style="font-size:11px">, 11, </font><font color="#0000ff">&quot;darkorchid&quot;</font><font style="font-size:11px">)  </font></td></tr> <tr> <td>Array.SetValue(<font color="#0000ff">&quot;color&quot;</font><font style="font-size:11px">, 12, </font><font color="#0000ff">&quot;purple&quot;</font><font style="font-size:11px">)  </font></td></tr> <tr> <td style="background-color:#f7f7f7">Array.SetValue(<font color="#0000ff">&quot;color&quot;</font><font style="font-size:11px">, 13, </font><font color="#0000ff">&quot;indigo&quot;</font><font style="font-size:11px">)  </font></td></tr> <tr> <td>count_colors = 13  </td></tr> <tr> <td style="background-color:#f7f7f7"> </td></tr> <tr> <td><font color="#008000">' The actual computations </font><font style="font-size:11px"> </font></td></tr> <tr> <td style="background-color:#f7f7f7">start = Clock.Hour*3600 + 60*Clock.Minute + Clock.Second  </td></tr> <tr> <td><font color="#008000">' loop trough every &quot;pixel&quot; </font><font style="font-size:11px"> </font></td></tr> <tr> <td style="background-color:#f7f7f7"><font color="#0000ff">For</font><font style="font-size:11px"> i=1 </font><font color="#0000ff">To</font><font style="font-size:11px"> resolutionx  </font></td></tr> <tr> <td>    <font color="#0000ff">For</font><font style="font-size:11px"> j=1 </font><font color="#0000ff">To</font><font style="font-size:11px"> resolutiony  </font></td></tr> <tr> <td style="background-color:#f7f7f7">        <font color="#008000">' point in the complex plane </font><font style="font-size:11px"> </font></td></tr> <tr> <td>        x = minx + i * stepx  </td></tr> <tr> <td style="background-color:#f7f7f7">        y = miny + j * stepy  </td></tr> <tr> <td>        iter = 0  </td></tr> <tr> <td style="background-color:#f7f7f7">        <font color="#0000ff">If</font><font style="font-size:11px"> (draw_mandelbrot = 1) </font><font color="#0000ff">Then</font><font style="font-size:11px"> </font></td></tr> <tr> <td>            cx = x  </td></tr> <tr> <td style="background-color:#f7f7f7">            cy = y  </td></tr> <tr> <td>        EndIf  </td></tr> <tr> <td style="background-color:#f7f7f7">        <font color="#008000">' iterate... </font><font style="font-size:11px"> </font></td></tr> <tr> <td>        <font color="#0000ff">While</font><font style="font-size:11px"> (x * x + y * y &lt;= 4 </font><font color="#0000ff">And</font><font style="font-size:11px"> iter &lt; max_iter)  </font></td></tr> <tr> <td style="background-color:#f7f7f7">            <font color="#008000">' compute z = z^2 + c </font><font style="font-size:11px"> </font></td></tr> <tr> <td>            t = x * x - y * y + cx  </td></tr> <tr> <td style="background-color:#f7f7f7">            y = 2 * x * y + cy  </td></tr> <tr> <td>            x = t  </td></tr> <tr> <td style="background-color:#f7f7f7">            iter = iter + 1  </td></tr> <tr> <td>        EndWhile  </td></tr> <tr> <td style="background-color:#f7f7f7">          </td></tr> <tr> <td>        GraphicsWindow.BrushColor = Array.GetValue(<font color="#0000ff">&quot;color&quot;</font><font style="font-size:11px">, Math.Floor(count_colors * iter / max_iter))  </font></td></tr> <tr> <td style="background-color:#f7f7f7">        <font color="#008000">' Draw a &quot;pixel&quot; </font><font style="font-size:11px"> </font></td></tr> <tr> <td>        GraphicsWindow.FillRectangle((i-1)*sizex, (j-1)*sizey, sizex, sizey)  </td></tr> <tr> <td style="background-color:#f7f7f7">    EndFor  </td></tr> <tr> <td>    <font color="#008000">'TextWindow.Write(i + &quot; &quot;) </font><font style="font-size:11px"> </font></td></tr> <tr> <td style="background-color:#f7f7f7">EndFor  </td></tr> <tr> <td><font color="#008000">' Running this program during midnight is bad... </font><font style="font-size:11px"> </font></td></tr> <tr> <td style="background-color:#f7f7f7">end = 3600*Clock.Hour + 60*Clock.Minute + Clock.Second  </td></tr> <tr> <td>GraphicsWindow.BrushColor = <font color="#0000ff">&quot;black&quot;</font><font style="font-size:11px"> </font></td></tr> <tr> <td style="background-color:#f7f7f7">GraphicsWindow.DrawText(0, 0, <font color="#0000ff">&quot;Finished in &quot;</font><font style="font-size:11px"> + (end-start) + </font><font color="#0000ff">&quot; seconds&quot;</font><font style="font-size:11px">)  </font></td></tr> <tr> <td> </td></tr></tbody></table></div><br><a href="http://m.loeu.ch/download/julia.png">Image</a> <a href="http://m.loeu.ch/download/julia2.png">Image 2</a> Mon, 24 Nov 2008 16:26:55 Z2008-11-24T17:15:54Zhttp://social.msdn.microsoft.com/Forums/en-US/smallbasic/thread/eaacf826-9d12-4e3c-aa10-1b2788f160a6#a85e8d76-0d8c-4b69-8501-f0af92dd334dhttp://social.msdn.microsoft.com/Forums/en-US/smallbasic/thread/eaacf826-9d12-4e3c-aa10-1b2788f160a6#a85e8d76-0d8c-4b69-8501-f0af92dd334dMikeAWhttp://social.msdn.microsoft.com/Profile/en-US/?user=MikeAWPost your sample source code here and get featured on our blogs! The following is code to search a specific text file for specific text and return the entire line it appears in.<br><br> <div style="border-right:#7f9db9 1px solid;border-top:#7f9db9 1px solid;font-size:11px;overflow:auto;border-left:#7f9db9 1px solid;line-height:100%! important;border-bottom:#7f9db9 1px solid;font-family:Courier New;background-color:white"> <table style="border-top-width:0px;border-left-width:0px;margin:2px 0px;width:99%;border-bottom:#eee 0px solid;border-collapse:collapse;background-color:#fff;border-right-width:0px" cellspacing=0 cellpadding=0> <colgroup> <col style="padding-left:10px;font-size:11px;border-bottom:#f7f7f7 1px solid;font-family:Courier New;white-space:nowrap"> <tbody> <tr> <td><font style="font-size:11px"></font><font style="color:red">filepath</font><font style="font-size:11px"> = </font><font style="color:blue">&quot;C:\testfilepath.txt&quot;</font><font style="font-size:11px"> </font></td></tr> <tr> <td style="background-color:#f7f7f7"></font><font style="color:red">searchtext</font><font style="font-size:11px"> = </font><font style="color:blue">&quot;text to find&quot;</font><font style="font-size:11px"> </font></td></tr> <tr> <td></font><font style="color:red">line</font><font style="font-size:11px"> = </font><font style="color:blue">1</font><font style="font-size:11px"> </font></td></tr> <tr> <td style="background-color:#f7f7f7">While (File.ReadLine(filepath, line) </font><font style="color:blue">&lt;</font><font style="font-size:11px">&gt; &quot;&quot;)  </font></td></tr> <tr> <td>        </font><font style="color:red">filetext</font><font style="font-size:11px"> = </font><font style="color:blue">File</font><font style="font-size:11px">.ReadLine(filepath, line)  </font></td></tr> <tr> <td style="background-color:#f7f7f7">        If (Text.IsSubText(filetext,searchtext)) Then  </td></tr> <tr> <td>            TextWindow.WriteLine(filetext)  </td></tr> <tr> <td style="background-color:#f7f7f7">        EndIf  </td></tr> <tr> <td>        </font><font style="color:red">line </font><font style="font-size:11px">= line + 1  </font></td></tr> <tr> <td style="background-color:#f7f7f7">EndWhile </td></tr></tbody></table></div>Tue, 25 Nov 2008 17:12:29 Z2008-11-25T17:12:29Zhttp://social.msdn.microsoft.com/Forums/en-US/smallbasic/thread/eaacf826-9d12-4e3c-aa10-1b2788f160a6#7f1e2942-09d3-4503-bd2b-56a9780723cfhttp://social.msdn.microsoft.com/Forums/en-US/smallbasic/thread/eaacf826-9d12-4e3c-aa10-1b2788f160a6#7f1e2942-09d3-4503-bd2b-56a9780723cfPath_drchttp://social.msdn.microsoft.com/Profile/en-US/?user=Path_drcPost your sample source code here and get featured on our blogs! OK, I finally put one together that I can post.<br>It's super simple but it's pretty.  :-)<br><br>Randomize a color.<br>Then just draw line from top-left to bottom-right of graphic screen, increase the X at top and decrease bottom X by an random number.<br>When X reaches top-right and bottom-left, choose another random color and start increaseing the right-hand Y and decreasing the left-hand Y by a different random number.<br>Start over again.<br><br>It would have taken less time if I would have left it at that, but noooo.  I had to add instructions and the ability to Exit out.<br>...and while I was reading keyboard commands, why not add the ability to slow down the spin of the spoke?<br><br>I call it Random Spoke.<br><br>*Problem Corrected - small problem with program locking-up.  Random step was finding a number between 0 and 99.  When the step was zero, the program would lock-up.  So added 1 to each of the two &quot;S =&quot; lines.*<br><br> <div style="border-right:#7f9db9 1px solid;border-top:#7f9db9 1px solid;font-size:11px;overflow:auto;border-left:#7f9db9 1px solid;line-height:100%! important;border-bottom:#7f9db9 1px solid;font-family:Courier New;background-color:white"> <table style="border-top-width:0px;border-left-width:0px;margin:2px 0px;width:99%;border-bottom:#eee 0px solid;border-collapse:collapse;background-color:#fff;border-right-width:0px" cellspacing=0 cellpadding=0> <colgroup> <col style="padding-left:10px;font-size:11px;border-bottom:#f7f7f7 1px solid;font-family:Courier New;white-space:nowrap"> <tbody> <tr> <td><font style="font-size:11px">'Setup graphics window.  </font></td></tr> <tr> <td style="background-color:#f7f7f7"></font><font style="color:red">GraphicsWindow.Height</font><font style="font-size:11px">=</font><font style="color:blue">600</font><font style="font-size:11px"> </font></td></tr> <tr> <td></font><font style="color:red">GraphicsWindow.Width</font><font style="font-size:11px">=</font><font style="color:blue">600</font><font style="font-size:11px"> <br><font color="#ff0000">GraphicsWindow.Height</font><font style="font-size:11px">=</font><font style="color:blue">600</font></font></td></tr> <tr> <td style="background-color:#f7f7f7">GraphicsWindow.Show()  </td></tr> <tr> <td> </td></tr> <tr> <td style="background-color:#f7f7f7">'Show instructions  </td></tr> <tr> <td></font><font style="color:red">GraphicsWindow.Title</font><font style="font-size:11px">=</font><font style="color:blue">&quot;Random Spoke instructions&quot;</font><font style="font-size:11px"> </font></td></tr> <tr> <td style="background-color:#f7f7f7"></font><font style="color:red">GraphicsWindow.BrushColor</font><font style="font-size:11px"> = </font><font style="color:blue">&quot;Black&quot;</font><font style="font-size:11px"> </font></td></tr> <tr> <td>GraphicsWindow.DrawText(10,20,&quot;Simple instructions...&quot;)  </td></tr> <tr> <td style="background-color:#f7f7f7">GraphicsWindow.DrawText(30,40,&quot;Down arrow to decrease speed.&quot;)  </td></tr> <tr> <td>GraphicsWindow.DrawText(30,60,&quot;Up arrow to increase speed.&quot;)  </td></tr> <tr> <td style="background-color:#f7f7f7">GraphicsWindow.DrawText(30,75,&quot;(Spoke starts at fastest speed.)&quot;)  </td></tr> <tr> <td>GraphicsWindow.DrawText(30,95,&quot;Escape to end program.&quot;)  </td></tr> <tr> <td style="background-color:#f7f7f7">GraphicsWindow.DrawText(10,120,&quot;Press Space Bar to start.&quot;)  </td></tr> <tr> <td>While (GraphicsWindow.LastKey </font><font style="color:blue">&lt;</font><font style="font-size:11px">&gt; &quot;Space&quot;)  </font></td></tr> <tr> <td style="background-color:#f7f7f7">EndWhile  </td></tr> <tr> <td> </td></tr> <tr> <td style="background-color:#f7f7f7">'Init  </td></tr> <tr> <td></font><font style="color:red">GraphicsWindow.BackgroundColor</font><font style="font-size:11px">=</font><font style="color:blue">0</font><font style="font-size:11px"> </font></td></tr> <tr> <td style="background-color:#f7f7f7"></font><font style="color:red">GraphicsWindow.Title</font><font style="font-size:11px">=</font><font style="color:blue">&quot;What does up, must come down.  Spinning wheel, got to go round...&quot;</font><font style="font-size:11px"> </font></td></tr> <tr> <td> </td></tr> <tr> <td style="background-color:#f7f7f7"> </td></tr> <tr> <td>'Run game until  </td></tr> <tr> <td style="background-color:#f7f7f7">While (EndProgram</font><font style="color:blue">&lt;</font><font style="font-size:11px">&gt;&quot;yes&quot;)  </font></td></tr> <tr> <td>    Start()  </td></tr> <tr> <td style="background-color:#f7f7f7">EndWhile  </td></tr> <tr> <td>Program.End()  </td></tr> <tr> <td style="background-color:#f7f7f7"> </td></tr> <tr> <td>Sub Start  </td></tr> <tr> <td style="background-color:#f7f7f7"> </td></tr> <tr> <td>' spoke turn left/right  </td></tr> <tr> <td style="background-color:#f7f7f7">    </font><font style="color:red">GraphicsWindow.PenColor</font><font style="font-size:11px"> = GraphicsWindow.GetRandomColor()  </font></td></tr> <tr> <td>    </font><font style="color:red">S</font><font style="font-size:11px"> = </font><font style="color:blue">Math</font><font style="font-size:11px">.GetRandomNumber(100) + 1</font></td></tr> <tr> <td style="background-color:#f7f7f7"> </td></tr> <tr> <td>    For </font><font style="color:red">X</font><font style="font-size:11px"> = </font><font style="color:blue">0</font><font style="font-size:11px"> To 600 Step S  </font></td></tr> <tr> <td style="background-color:#f7f7f7">        GraphicsWindow.DrawLine(X,0,600-X,600)  </td></tr> <tr> <td>        Program.Delay(delay)  </td></tr> <tr> <td style="background-color:#f7f7f7">    '   check keypress  </td></tr> <tr> <td>        If (</font><font style="color:red">GraphicsWindow.LastKey</font><font style="font-size:11px"> = </font><font style="color:blue">&quot;Escape&quot;</font><font style="font-size:11px">) Then  </font></td></tr> <tr> <td style="background-color:#f7f7f7">            </font><font style="color:red">EndProgram</font><font style="font-size:11px"> = </font><font style="color:blue">&quot;yes&quot;</font><font style="font-size:11px"> </font></td></tr> <tr> <td>        EndIf  </td></tr> <tr> <td style="background-color:#f7f7f7">        If (</font><font style="color:red">GraphicsWindow.LastKey</font><font style="font-size:11px"> = </font><font style="color:blue">&quot;Down&quot;</font><font style="font-size:11px">) Then  </font></td></tr> <tr> <td>            </font><font style="color:blue">delay</font><font style="font-size:11px"> = delay + 1  </font></td></tr> <tr> <td style="background-color:#f7f7f7">        EndIf  </td></tr> <tr> <td>        If (</font><font style="color:red">GraphicsWindow.LastKey</font><font style="font-size:11px"> = </font><font style="color:blue">&quot;Up&quot;</font><font style="font-size:11px">) Then  </font></td></tr> <tr> <td style="background-color:#f7f7f7">            </font><font style="color:blue">delay</font><font style="font-size:11px"> = delay - 1  </font></td></tr> <tr> <td>            If (delay </font><font style="color:blue">&lt;</font><font style="font-size:11px"> </font><font style="font-weight:bold;color:black">0</font><font style="font-size:11px">) Then  </font></td></tr> <tr> <td style="background-color:#f7f7f7">                </font><font style="color:red">delay</font><font style="font-size:11px"> = </font><font style="color:blue">0</font><font style="font-size:11px"> </font></td></tr> <tr> <td>            EndIf  </td></tr> <tr> <td style="background-color:#f7f7f7">        EndIf  </td></tr> <tr> <td>    EndFor  </td></tr> <tr> <td style="background-color:#f7f7f7"> </td></tr> <tr> <td> </td></tr> <tr> <td style="background-color:#f7f7f7">' spoke turn up/down  </td></tr> <tr> <td>    </font><font style="color:red">GraphicsWindow.PenColor</font><font style="font-size:11px"> = GraphicsWindow.GetRandomColor()  </font></td></tr> <tr> <td style="background-color:#f7f7f7">    </font><font style="color:red">S</font><font style="font-size:11px"> = </font><font style="color:blue">Math</font><font style="font-size:11px">.GetRandomNumber(100) + 1</font></td></tr> <tr> <td> </td></tr> <tr> <td style="background-color:#f7f7f7">    For </font><font style="color:red">Y</font><font style="font-size:11px"> = </font><font style="color:blue">0</font><font style="font-size:11px"> To 600 Step S  </font></td></tr> <tr> <td>        GraphicsWindow.DrawLine(600,Y,0,600-y)  </td></tr> <tr> <td style="background-color:#f7f7f7">        Program.Delay(delay)  </td></tr> <tr> <td>          </td></tr> <tr> <td style="background-color:#f7f7f7">    '   check keypress  </td></tr> <tr> <td>        If (</font><font style="color:red">GraphicsWindow.LastKey</font><font style="font-size:11px"> = </font><font style="color:blue">&quot;Escape&quot;</font><font style="font-size:11px">) Then  </font></td></tr> <tr> <td style="background-color:#f7f7f7">            </font><font style="color:red">EndProgram</font><font style="font-size:11px"> = </font><font style="color:blue">&quot;yes&quot;</font><font style="font-size:11px"> </font></td></tr> <tr> <td>        EndIf  </td></tr> <tr> <td style="background-color:#f7f7f7">        If (</font><font style="color:red">GraphicsWindow.LastKey</font><font style="font-size:11px"> = </font><font style="color:blue">&quot;Down&quot;</font><font style="font-size:11px">) Then  </font></td></tr> <tr> <td>            </font><font style="color:blue">delay</font><font style="font-size:11px"> = delay + 1  </font></td></tr> <tr> <td style="background-color:#f7f7f7">        EndIf  </td></tr> <tr> <td>        If (</font><font style="color:red">GraphicsWindow.LastKey</font><font style="font-size:11px"> = </font><font style="color:blue">&quot;Up&quot;</font><font style="font-size:11px">) Then  </font></td></tr> <tr> <td style="background-color:#f7f7f7">            </font><font style="color:blue">delay</font><font style="font-size:11px"> = delay - 1  </font></td></tr> <tr> <td>            If (delay </font><font style="color:blue">&lt;</font><font style="font-size:11px"> </font><font style="font-weight:bold;color:black">0</font><font style="font-size:11px">) Then  </font></td></tr> <tr> <td style="background-color:#f7f7f7">                </font><font style="color:red">delay</font><font style="font-size:11px"> = </font><font style="color:blue">0</font><font style="font-size:11px"> </font></td></tr> <tr> <td>            EndIf  </td></tr> <tr> <td style="background-color:#f7f7f7">        EndIf  </td></tr> <tr> <td>    EndFor  </td></tr> <tr> <td style="background-color:#f7f7f7"> </td></tr> <tr> <td>EndSub </td></tr></tbody></table></div><br><br>Wed, 26 Nov 2008 23:29:58 Z2008-12-01T17:58:40Zhttp://social.msdn.microsoft.com/Forums/en-US/smallbasic/thread/eaacf826-9d12-4e3c-aa10-1b2788f160a6#41158e17-982b-4ffa-84aa-14d654c5a9bdhttp://social.msdn.microsoft.com/Forums/en-US/smallbasic/thread/eaacf826-9d12-4e3c-aa10-1b2788f160a6#41158e17-982b-4ffa-84aa-14d654c5a9bdDink87522http://social.msdn.microsoft.com/Profile/en-US/?user=Dink87522Post your sample source code here and get featured on our blogs!Nice DRC. Although the program quickly freezes on my PC.  Thu, 27 Nov 2008 02:11:40 Z2008-11-27T02:11:40Zhttp://social.msdn.microsoft.com/Forums/en-US/smallbasic/thread/eaacf826-9d12-4e3c-aa10-1b2788f160a6#185e1c35-ceaf-4b9c-9edf-d15f186a0fcdhttp://social.msdn.microsoft.com/Forums/en-US/smallbasic/thread/eaacf826-9d12-4e3c-aa10-1b2788f160a6#185e1c35-ceaf-4b9c-9edf-d15f186a0fcdPath_drchttp://social.msdn.microsoft.com/Profile/en-US/?user=Path_drcPost your sample source code here and get featured on our blogs! I didn't have a problem on my work PC, but on my home PC (which is much faster) the graphics window keeps the correct width but the height is almost double the size and, like you Dink, it locks up after just a few passes.<br><br>I know it is not a simple mistake, like the program is running but the lines are not drawing, because the Esc key doesn't work.<br>I'm going to post this as new thread and see if anyone has any ideas.<br><br>Thu, 27 Nov 2008 14:15:22 Z2008-11-27T18:55:11Zhttp://social.msdn.microsoft.com/Forums/en-US/smallbasic/thread/eaacf826-9d12-4e3c-aa10-1b2788f160a6#1b1509e1-d313-45d9-ae54-58c33cbffa7ahttp://social.msdn.microsoft.com/Forums/en-US/smallbasic/thread/eaacf826-9d12-4e3c-aa10-1b2788f160a6#1b1509e1-d313-45d9-ae54-58c33cbffa7aVolodymir Tryapichkohttp://social.msdn.microsoft.com/Profile/en-US/?user=Volodymir%20TryapichkoPost your sample source code here and get featured on our blogs!<img src="http://img213.imageshack.us/img213/247/matrixeffectlw6.jpg" title="Matrix Effect"><br><br><br><div style="overflow:auto;background-color:white;line-height:100% ! important;font-family:Courier New;font-size:11px"><pre>index <span style="color:rgb(128, 128, 48)">=</span> <span style="color:rgb(0, 140, 0)">0</span><br>NeedToDraw <span style="color:rgb(128, 128, 48)">=</span> <span style="color:rgb(0, 140, 0)">1</span><br>GraphicsWindow<span style="color:rgb(0, 140, 0)">.</span>KeyDown <span style="color:rgb(128, 128, 48)">=</span> OnKeyDown<br>InitMatrix<span style="color:rgb(128, 128, 48)">(</span><span style="color:rgb(128, 128, 48)">)</span><br>Play<span style="color:rgb(128, 128, 48)">(</span><span style="color:rgb(128, 128, 48)">)</span><br><br><span style="color:rgb(128, 0, 0);font-weight:bold">Sub</span> InitMatrix<br> GraphicsWindow<span style="color:rgb(0, 140, 0)">.</span>BackgroundColor <span style="color:rgb(128, 128, 48)">=</span> <span style="color:rgb(0, 0, 230)">&quot;#000000&quot;</span><br> <span style="color:rgb(128, 0, 0);font-weight:bold">Array</span><span style="color:rgb(0, 140, 0)">.</span>SetValue<span style="color:rgb(128, 128, 48)">(</span><span style="color:rgb(0, 0, 230)">&quot;color&quot;</span><span style="color:rgb(128, 128, 48)">,</span> <span style="color:rgb(0, 140, 0)">00</span><span style="color:rgb(128, 128, 48)">,</span> <span style="color:rgb(0, 0, 230)">&quot;#003300&quot;</span><span style="color:rgb(128, 128, 48)">)</span><br> <span style="color:rgb(128, 0, 0);font-weight:bold">Array</span><span style="color:rgb(0, 140, 0)">.</span>SetValue<span style="color:rgb(128, 128, 48)">(</span><span style="color:rgb(0, 0, 230)">&quot;color&quot;</span><span style="color:rgb(128, 128, 48)">,</span> <span style="color:rgb(0, 140, 0)">01</span><span style="color:rgb(128, 128, 48)">,</span> <span style="color:rgb(0, 0, 230)">&quot;#004400&quot;</span><span style="color:rgb(128, 128, 48)">)</span><br> <span style="color:rgb(128, 0, 0);font-weight:bold">Array</span><span style="color:rgb(0, 140, 0)">.</span>SetValue<span style="color:rgb(128, 128, 48)">(</span><span style="color:rgb(0, 0, 230)">&quot;color&quot;</span><span style="color:rgb(128, 128, 48)">,</span> <span style="color:rgb(0, 140, 0)">02</span><span style="color:rgb(128, 128, 48)">,</span> <span style="color:rgb(0, 0, 230)">&quot;#005500&quot;</span><span style="color:rgb(128, 128, 48)">)</span><br> <span style="color:rgb(128, 0, 0);font-weight:bold">Array</span><span style="color:rgb(0, 140, 0)">.</span>SetValue<span style="color:rgb(128, 128, 48)">(</span><span style="color:rgb(0, 0, 230)">&quot;color&quot;</span><span style="color:rgb(128, 128, 48)">,</span> <span style="color:rgb(0, 140, 0)">03</span><span style="color:rgb(128, 128, 48)">,</span> <span style="color:rgb(0, 0, 230)">&quot;#006600&quot;</span><span style="color:rgb(128, 128, 48)">)</span><br> <span style="color:rgb(128, 0, 0);font-weight:bold">Array</span><span style="color:rgb(0, 140, 0)">.</span>SetValue<span style="color:rgb(128, 128, 48)">(</span><span style="color:rgb(0, 0, 230)">&quot;color&quot;</span><span style="color:rgb(128, 128, 48)">,</span> <span style="color:rgb(0, 140, 0)">04</span><span style="color:rgb(128, 128, 48)">,</span> <span style="color:rgb(0, 0, 230)">&quot;#007700&quot;</span><span style="color:rgb(128, 128, 48)">)</span><br> <span style="color:rgb(128, 0, 0);font-weight:bold">Array</span><span style="color:rgb(0, 140, 0)">.</span>SetValue<span style="color:rgb(128, 128, 48)">(</span><span style="color:rgb(0, 0, 230)">&quot;color&quot;</span><span style="color:rgb(128, 128, 48)">,</span> <span style="color:rgb(0, 140, 0)">05</span><span style="color:rgb(128, 128, 48)">,</span> <span style="color:rgb(0, 0, 230)">&quot;#008800&quot;</span><span style="color:rgb(128, 128, 48)">)</span><br> <span style="color:rgb(128, 0, 0);font-weight:bold">Array</span><span style="color:rgb(0, 140, 0)">.</span>SetValue<span style="color:rgb(128, 128, 48)">(</span><span style="color:rgb(0, 0, 230)">&quot;color&quot;</span><span style="color:rgb(128, 128, 48)">,</span> <span style="color:rgb(0, 140, 0)">06</span><span style="color:rgb(128, 128, 48)">,</span> <span style="color:rgb(0, 0, 230)">&quot;#009900&quot;</span><span style="color:rgb(128, 128, 48)">)</span><br> <span style="color:rgb(128, 0, 0);font-weight:bold">Array</span><span style="color:rgb(0, 140, 0)">.</span>SetValue<span style="color:rgb(128, 128, 48)">(</span><span style="color:rgb(0, 0, 230)">&quot;color&quot;</span><span style="color:rgb(128, 128, 48)">,</span> <span style="color:rgb(0, 140, 0)">17</span><span style="color:rgb(128, 128, 48)">,</span> <span style="color:rgb(0, 0, 230)">&quot;#00AA00&quot;</span><span style="color:rgb(128, 128, 48)">)</span><br> <span style="color:rgb(128, 0, 0);font-weight:bold">Array</span><span style="color:rgb(0, 140, 0)">.</span>SetValue<span style="color:rgb(128, 128, 48)">(</span><span style="color:rgb(0, 0, 230)">&quot;color&quot;</span><span style="color:rgb(128, 128, 48)">,</span> <span style="color:rgb(0, 140, 0)">18</span><span style="color:rgb(128, 128, 48)">,</span> <span style="color:rgb(0, 0, 230)">&quot;#00BB00&quot;</span><span style="color:rgb(128, 128, 48)">)</span><br> <span style="color:rgb(128, 0, 0);font-weight:bold">Array</span><span style="color:rgb(0, 140, 0)">.</span>SetValue<span style="color:rgb(128, 128, 48)">(</span><span style="color:rgb(0, 0, 230)">&quot;color&quot;</span><span style="color:rgb(128, 128, 48)">,</span> <span style="color:rgb(0, 140, 0)">19</span><span style="color:rgb(128, 128, 48)">,</span> <span style="color:rgb(0, 0, 230)">&quot;#00CC00&quot;</span><span style="color:rgb(128, 128, 48)">)</span><br> <span style="color:rgb(128, 0, 0);font-weight:bold">Array</span><span style="color:rgb(0, 140, 0)">.</span>SetValue<span style="color:rgb(128, 128, 48)">(</span><span style="color:rgb(0, 0, 230)">&quot;color&quot;</span><span style="color:rgb(128, 128, 48)">,</span> <span style="color:rgb(0, 140, 0)">10</span><span style="color:rgb(128, 128, 48)">,</span> <span style="color:rgb(0, 0, 230)">&quot;#00DD00&quot;</span><span style="color:rgb(128, 128, 48)">)</span><br> <span style="color:rgb(128, 0, 0);font-weight:bold">Array</span><span style="color:rgb(0, 140, 0)">.</span>SetValue<span style="color:rgb(128, 128, 48)">(</span><span style="color:rgb(0, 0, 230)">&quot;color&quot;</span><span style="color:rgb(128, 128, 48)">,</span> <span style="color:rgb(0, 140, 0)">11</span><span style="color:rgb(128, 128, 48)">,</span> <span style="color:rgb(0, 0, 230)">&quot;#00EE00&quot;</span><span style="color:rgb(128, 128, 48)">)</span><br> <span style="color:rgb(128, 0, 0);font-weight:bold">Array</span><span style="color:rgb(0, 140, 0)">.</span>SetValue<span style="color:rgb(128, 128, 48)">(</span><span style="color:rgb(0, 0, 230)">&quot;color&quot;</span><span style="color:rgb(128, 128, 48)">,</span> <span style="color:rgb(0, 140, 0)">12</span><span style="color:rgb(128, 128, 48)">,</span> <span style="color:rgb(0, 0, 230)">&quot;#00FF00&quot;</span><span style="color:rgb(128, 128, 48)">)</span><br> <span style="color:rgb(128, 0, 0);font-weight:bold">For</span> x <span style="color:rgb(128, 128, 48)">=</span> <span style="color:rgb(0, 140, 0)">0</span> <span style="color:rgb(128, 0, 0);font-weight:bold">To</span> GraphicsWindow<span style="color:rgb(0, 140, 0)">.</span>Width <span style="color:rgb(128, 0, 0);font-weight:bold">Step</span> <span style="color:rgb(0, 140, 0)">13</span><br> index <span style="color:rgb(128, 128, 48)">=</span> index <span style="color:rgb(128, 128, 48)">+</span> <span style="color:rgb(0, 140, 0)">1</span><br> <span style="color:rgb(128, 0, 0);font-weight:bold">Array</span><span style="color:rgb(0, 140, 0)">.</span>SetValue<span style="color:rgb(128, 128, 48)">(</span><span style="color:rgb(0, 0, 230)">&quot;x&quot;</span><span style="color:rgb(128, 128, 48)">,</span> index<span style="color:rgb(128, 128, 48)">,</span> x<span style="color:rgb(128, 128, 48)">)</span><br> <span style="color:rgb(128, 0, 0);font-weight:bold">Array</span><span style="color:rgb(0, 140, 0)">.</span>SetValue<span style="color:rgb(128, 128, 48)">(</span><span style="color:rgb(0, 0, 230)">&quot;y&quot;</span><span style="color:rgb(128, 128, 48)">,</span> index<span style="color:rgb(128, 128, 48)">,</span> Math<span style="color:rgb(0, 140, 0)">.</span>GetRandomNumber<span style="color:rgb(128, 128, 48)">(</span>GraphicsWindow<span style="color:rgb(0, 140, 0)">.</span>Height<span style="color:rgb(128, 128, 48)">)</span><span style="color:rgb(128, 128, 48)">)</span><br> <span style="color:rgb(128, 0, 0);font-weight:bold">Array</span><span style="color:rgb(0, 140, 0)">.</span>SetValue<span style="color:rgb(128, 128, 48)">(</span><span style="color:rgb(0, 0, 230)">&quot;dy&quot;</span><span style="color:rgb(128, 128, 48)">,</span> index<span style="color:rgb(128, 128, 48)">,</span> <span style="color:rgb(0, 140, 0)">5</span> <span style="color:rgb(128, 128, 48)">+</span> Math<span style="color:rgb(0, 140, 0)">.</span>GetRandomNumber<span style="color:rgb(128, 128, 48)">(</span><span style="color:rgb(0, 140, 0)">7</span><span style="color:rgb(128, 128, 48)">)</span><span style="color:rgb(128, 128, 48)">)</span><br> <br> <span style="color:rgb(128, 0, 0);font-weight:bold">Array</span><span style="color:rgb(0, 140, 0)">.</span>SetValue<span style="color:rgb(128, 128, 48)">(</span><span style="color:rgb(0, 0, 230)">&quot;colors&quot;</span><span style="color:rgb(128, 128, 48)">,</span> index<span style="color:rgb(128, 128, 48)">,</span> <span style="color:rgb(128, 0, 0);font-weight:bold">Array</span><span style="color:rgb(0, 140, 0)">.</span>GetValue<span style="color:rgb(128, 128, 48)">(</span><span style="color:rgb(0, 0, 230)">&quot;color&quot;</span><span style="color:rgb(128, 128, 48)">,</span> Math<span style="color:rgb(0, 140, 0)">.</span>GetRandomNumber<span style="color:rgb(128, 128, 48)">(</span><span style="color:rgb(0, 140, 0)">13</span><span style="color:rgb(128, 128, 48)">)</span><span style="color:rgb(128, 128, 48)">)</span><span style="color:rgb(128, 128, 48)">)</span><br> <span style="color:rgb(128, 0, 0);font-weight:bold">If</span><span style="color:rgb(128, 128, 48)">(</span>Math<span style="color:rgb(0, 140, 0)">.</span>GetRandomNumber<span style="color:rgb(128, 128, 48)">(</span><span style="color:rgb(0, 140, 0)">2</span><span style="color:rgb(128, 128, 48)">)</span> <span style="color:rgb(128, 128, 48)">=</span> <span style="color:rgb(0, 140, 0)">0</span><span style="color:rgb(128, 128, 48)">)</span> <span style="color:rgb(128, 0, 0);font-weight:bold">Then</span><br> <span style="color:rgb(128, 0, 0);font-weight:bold">Array</span><span style="color:rgb(0, 140, 0)">.</span>SetValue<span style="color:rgb(128, 128, 48)">(</span><span style="color:rgb(0, 0, 230)">&quot;ch&quot;</span><span style="color:rgb(128, 128, 48)">,</span> index<span style="color:rgb(128, 128, 48)">,</span> <span style="color:rgb(0, 0, 230)">&quot;0&quot;</span><span style="color:rgb(128, 128, 48)">)</span><br> <span style="color:rgb(128, 0, 0);font-weight:bold">Else</span><br> <span style="color:rgb(128, 0, 0);font-weight:bold">Array</span><span style="color:rgb(0, 140, 0)">.</span>SetValue<span style="color:rgb(128, 128, 48)">(</span><span style="color:rgb(0, 0, 230)">&quot;ch&quot;</span><span style="color:rgb(128, 128, 48)">,</span> index<span style="color:rgb(128, 128, 48)">,</span> <span style="color:rgb(0, 0, 230)">&quot;1&quot;</span><span style="color:rgb(128, 128, 48)">)</span><br> EndIf<br> EndFor<br>EndSub<br><br><span style="color:rgb(128, 0, 0);font-weight:bold">Sub</span> DrawMatrix<br> <span style="color:rgb(128, 0, 0);font-weight:bold">For</span> i <span style="color:rgb(128, 128, 48)">=</span> <span style="color:rgb(0, 140, 0)">0</span> <span style="color:rgb(128, 0, 0);font-weight:bold">To</span> index<br> x <span style="color:rgb(128, 128, 48)">=</span> <span style="color:rgb(128, 0, 0);font-weight:bold">Array</span><span style="color:rgb(0, 140, 0)">.</span>GetValue<span style="color:rgb(128, 128, 48)">(</span><span style="color:rgb(0, 0, 230)">&quot;x&quot;</span><span style="color:rgb(128, 128, 48)">,</span> i<span style="color:rgb(128, 128, 48)">)</span><br> y <span style="color:rgb(128, 128, 48)">=</span> <span style="color:rgb(128, 0, 0);font-weight:bold">Array</span><span style="color:rgb(0, 140, 0)">.</span>GetValue<span style="color:rgb(128, 128, 48)">(</span><span style="color:rgb(0, 0, 230)">&quot;y&quot;</span><span style="color:rgb(128, 128, 48)">,</span> i<span style="color:rgb(128, 128, 48)">)</span><br> GraphicsWindow<span style="color:rgb(0, 140, 0)">.</span>BrushColor <span style="color:rgb(128, 128, 48)">=</span> GraphicsWindow<span style="color:rgb(0, 140, 0)">.</span>BackgroundColor<br> GraphicsWindow<span style="color:rgb(0, 140, 0)">.</span>FillRectangle<span style="color:rgb(128, 128, 48)">(</span>x<span style="color:rgb(128, 128, 48)">,</span> y<span style="color:rgb(128, 128, 48)">,</span> <span style="color:rgb(0, 140, 0)">20</span><span style="color:rgb(128, 128, 48)">,</span> <span style="color:rgb(0, 140, 0)">20</span><span style="color:rgb(128, 128, 48)">)</span><br> y <span style="color:rgb(128, 128, 48)">=</span> y <span style="color:rgb(128, 128, 48)">+</span> <span style="color:rgb(128, 0, 0);font-weight:bold">Array</span><span style="color:rgb(0, 140, 0)">.</span>GetValue<span style="color:rgb(128, 128, 48)">(</span><span style="color:rgb(0, 0, 230)">&quot;dy&quot;</span><span style="color:rgb(128, 128, 48)">,</span> i<span style="color:rgb(128, 128, 48)">)</span><br> GraphicsWindow<span style="color:rgb(0, 140, 0)">.</span>BrushColor <span style="color:rgb(128, 128, 48)">=</span> <span style="color:rgb(128, 0, 0);font-weight:bold">Array</span><span style="color:rgb(0, 140, 0)">.</span>GetValue<span style="color:rgb(128, 128, 48)">(</span><span style="color:rgb(0, 0, 230)">&quot;colors&quot;</span><span style="color:rgb(128, 128, 48)">,</span> i<span style="color:rgb(128, 128, 48)">)</span><br> GraphicsWindow<span style="color:rgb(0, 140, 0)">.</span>DrawText<span style="color:rgb(128, 128, 48)">(</span>x<span style="color:rgb(128, 128, 48)">,</span> y<span style="color:rgb(128, 128, 48)">,</span> <span style="color:rgb(128, 0, 0);font-weight:bold">Array</span><span style="color:rgb(0, 140, 0)">.</span>GetValue<span style="color:rgb(128, 128, 48)">(</span><span style="color:rgb(0, 0, 230)">&quot;ch&quot;</span><span style="color:rgb(128, 128, 48)">,</span> i<span style="color:rgb(128, 128, 48)">)</span><span style="color:rgb(128, 128, 48)">)</span><br> <span style="color:rgb(128, 0, 0);font-weight:bold">If</span><span style="color:rgb(128, 128, 48)">(</span>y <span style="color:rgb(128, 128, 48)">&gt;</span> GraphicsWindow<span style="color:rgb(0, 140, 0)">.</span>Height<span style="color:rgb(128, 128, 48)">)</span> <span style="color:rgb(128, 0, 0);font-weight:bold">Then</span><br> y <span style="color:rgb(128, 128, 48)">=</span> <span style="color:rgb(128, 128, 48)">-</span><span style="color:rgb(0, 140, 0)">20</span><br> <span style="color:rgb(128, 0, 0);font-weight:bold">Array</span><span style="color:rgb(0, 140, 0)">.</span>SetValue<span style="color:rgb(128, 128, 48)">(</span><span style="color:rgb(0, 0, 230)">&quot;colors&quot;</span><span style="color:rgb(128, 128, 48)">,</span> i<span style="color:rgb(128, 128, 48)">,</span> <span style="color:rgb(128, 0, 0);font-weight:bold">Array</span><span style="color:rgb(0, 140, 0)">.</span>GetValue<span style="color:rgb(128, 128, 48)">(</span><span style="color:rgb(0, 0, 230)">&quot;color&quot;</span><span style="color:rgb(128, 128, 48)">,</span> Math<span style="color:rgb(0, 140, 0)">.</span>GetRandomNumber<span style="color:rgb(128, 128, 48)">(</span><span style="color:rgb(0, 140, 0)">13</span><span style="color:rgb(128, 128, 48)">)</span><span style="color:rgb(128, 128, 48)">)</span><span style="color:rgb(128, 128, 48)">)</span><br> EndIf<br> <span style="color:rgb(128, 0, 0);font-weight:bold">Array</span><span style="color:rgb(0, 140, 0)">.</span>SetValue<span style="color:rgb(128, 128, 48)">(</span><span style="color:rgb(0, 0, 230)">&quot;y&quot;</span><span style="color:rgb(128, 128, 48)">,</span> i<span style="color:rgb(128, 128, 48)">,</span> y<span style="color:rgb(128, 128, 48)">)</span><br> EndFor<br>EndSub<br><br><span style="color:rgb(128, 0, 0);font-weight:bold">Sub</span> Play<br> <span style="color:rgb(128, 0, 0);font-weight:bold">While</span><span style="color:rgb(128, 128, 48)">(</span>NeedToDraw <span style="color:rgb(128, 128, 48)">=</span> <span style="color:rgb(0, 140, 0)">1</span><span style="color:rgb(128, 128, 48)">)</span><br> DrawMatrix<span style="color:rgb(128, 128, 48)">(</span><span style="color:rgb(128, 128, 48)">)</span><br> EndWhile<br> Program<span style="color:rgb(0, 140, 0)">.</span><span style="color:rgb(128, 0, 0);font-weight:bold">End</span><span style="color:rgb(128, 128, 48)">(</span><span style="color:rgb(128, 128, 48)">)</span><br>EndSub<br><br><span style="color:rgb(128, 0, 0);font-weight:bold">Sub</span> OnKeyDown<br> key <span style="color:rgb(128, 128, 48)">=</span> GraphicsWindow<span style="color:rgb(0, 140, 0)">.</span>LastKey<br> <span style="color:rgb(128, 0, 0);font-weight:bold">If</span><span style="color:rgb(128, 128, 48)">(</span>key <span style="color:rgb(128, 128, 48)">=</span> <span style="color:rgb(0, 0, 230)">&quot;Escape&quot;</span><span style="color:rgb(128, 128, 48)">)</span> <span style="color:rgb(128, 0, 0);font-weight:bold">Then</span><br> NeedToDraw <span style="color:rgb(128, 128, 48)">=</span> <span style="color:rgb(0, 140, 0)">0</span><br> EndIf<br>EndSub<br></pre></div><br>Sat, 29 Nov 2008 22:23:23 Z2008-11-30T14:23:12Zhttp://social.msdn.microsoft.com/Forums/en-US/smallbasic/thread/eaacf826-9d12-4e3c-aa10-1b2788f160a6#385f7c6a-67a7-4cec-aef2-9693635235b9http://social.msdn.microsoft.com/Forums/en-US/smallbasic/thread/eaacf826-9d12-4e3c-aa10-1b2788f160a6#385f7c6a-67a7-4cec-aef2-9693635235b9Dink87522http://social.msdn.microsoft.com/Profile/en-US/?user=Dink87522Post your sample source code here and get featured on our blogs!Can you please post the code without the line numbering so we can copy and paste it and run the code.  Sun, 30 Nov 2008 01:43:47 Z2008-11-30T01:43:47Zhttp://social.msdn.microsoft.com/Forums/en-US/smallbasic/thread/eaacf826-9d12-4e3c-aa10-1b2788f160a6#1e319212-6d2b-463c-8313-93309287fc3fhttp://social.msdn.microsoft.com/Forums/en-US/smallbasic/thread/eaacf826-9d12-4e3c-aa10-1b2788f160a6#1e319212-6d2b-463c-8313-93309287fc3fTekgnohttp://social.msdn.microsoft.com/Profile/en-US/?user=TekgnoPost your sample source code here and get featured on our blogs!I developed an example program that converts decimal numbers into their hexadecimal equivalent.<br>It initially sounded like a rather simple endeavor, a little text manipulation, and a bit of recursion using the stack to pass values to subroutines.<br>Two things to keep in mind:<br>Firstly, all variables seem to be global, when recursing, push everything you may need onto the stack as it will most <br>likely get trashed.<br>Secondly, sometimes text will get treated as a number and concatenating two such strings results in them getting added rather than appended.<br><br>The first one is the most important to remember in general, but the second one chewed up the most of my time to find out.<br>The Text.Append that is planned for Xmas release will be gladly welcomed :)<br><br>I am aware that the recursion is totally unnecessary and extremely inefficient but thought it a good way to demonstrate the concept.<br>I'll re-write this to do away with the recursion and use something simpler to demo that, maybe Newton's square root approximation or factorials.<br><br><div style="overflow:auto;background-color:white;line-height:100% ! important;font-family:Courier New;font-size:11px"><table style="border-width:0px;margin:2px 0px;width:99%;border-collapse:collapse;background-color:rgb(255, 255, 255)" cellpadding=0 cellspacing=0><col style="font-family:Courier New;font-size:11px;padding-left:10px;white-space:nowrap"><tbody><tr><td><font style="font-size:11px"></font><font style="color:green">'Demonstration code to convert decimal numbers in hexadecimal</font><font style="font-size:11px"> </font></td></tr><tr><td style="background-color:rgb(247, 247, 247)"><font style="color:green">'By tekgno , Wednesday 3 December 2008</font><font style="font-size:11px"> </font></td></tr><tr><td><font style="color:green">'This example demonstrates recursion and some text manipulation</font><font style="font-size:11px"> <br></font></td></tr><tr><td style="background-color:rgb(247, 247, 247)"> </td></tr><tr><td><font style="color:green">'Initialise our array of decimal to hex characters</font><font style="font-size:11px"> </font></td></tr><tr><td style="background-color:rgb(247, 247, 247)">Array.SetValue(<font style="color:blue">&quot;dec2hex&quot;</font><font style="font-size:11px">,0,</font><font style="color:blue">&quot;0&quot;</font><font style="font-size:11px">) </font></td></tr><tr><td>Array.SetValue(<font style="color:blue">&quot;dec2hex&quot;</font><font style="font-size:11px">,1,</font><font style="color:blue">&quot;1&quot;</font><font style="font-size:11px">) </font></td></tr><tr><td style="background-color:rgb(247, 247, 247)">Array.SetValue(<font style="color:blue">&quot;dec2hex&quot;</font><font style="font-size:11px">,2,</font><font style="color:blue">&quot;2&quot;</font><font style="font-size:11px">) </font></td></tr><tr><td>Array.SetValue(<font style="color:blue">&quot;dec2hex&quot;</font><font style="font-size:11px">,3,</font><font style="color:blue">&quot;3&quot;</font><font style="font-size:11px">) </font></td></tr><tr><td style="background-color:rgb(247, 247, 247)">Array.SetValue(<font style="color:blue">&quot;dec2hex&quot;</font><font style="font-size:11px">,4,</font><font style="color:blue">&quot;4&quot;</font><font style="font-size:11px">) </font></td></tr><tr><td>Array.SetValue(<font style="color:blue">&quot;dec2hex&quot;</font><font style="font-size:11px">,5,</font><font style="color:blue">&quot;5&quot;</font><font style="font-size:11px">) </font></td></tr><tr><td style="background-color:rgb(247, 247, 247)">Array.SetValue(<font style="color:blue">&quot;dec2hex&quot;</font><font style="font-size:11px">,6,</font><font style="color:blue">&quot;6&quot;</font><font style="font-size:11px">) </font></td></tr><tr><td>Array.SetValue(<font style="color:blue">&quot;dec2hex&quot;</font><font style="font-size:11px">,7,</font><font style="color:blue">&quot;7&quot;</font><font style="font-size:11px">) </font></td></tr><tr><td style="background-color:rgb(247, 247, 247)">Array.SetValue(<font style="color:blue">&quot;dec2hex&quot;</font><font style="font-size:11px">,8,</font><font style="color:blue">&quot;8&quot;</font><font style="font-size:11px">) </font></td></tr><tr><td>Array.SetValue(<font style="color:blue">&quot;dec2hex&quot;</font><font style="font-size:11px">,9,</font><font style="color:blue">&quot;9&quot;</font><font style="font-size:11px">) </font></td></tr><tr><td style="background-color:rgb(247, 247, 247)">Array.SetValue(<font style="color:blue">&quot;dec2hex&quot;</font><font style="font-size:11px">,10,</font><font style="color:blue">&quot;A&quot;</font><font style="font-size:11px">) </font></td></tr><tr><td>Array.SetValue(<font style="color:blue">&quot;dec2hex&quot;</font><font style="font-size:11px">,11,</font><font style="color:blue">&quot;B&quot;</font><font style="font-size:11px">) </font></td></tr><tr><td style="background-color:rgb(247, 247, 247)">Array.SetValue(<font style="color:blue">&quot;dec2hex&quot;</font><font style="font-size:11px">,12,</font><font style="color:blue">&quot;C&quot;</font><font style="font-size:11px">) </font></td></tr><tr><td>Array.SetValue(<font style="color:blue">&quot;dec2hex&quot;</font><font style="font-size:11px">,13,</font><font style="color:blue">&quot;D&quot;</font><font style="font-size:11px">) </font></td></tr><tr><td style="background-color:rgb(247, 247, 247)">Array.SetValue(<font style="color:blue">&quot;dec2hex&quot;</font><font style="font-size:11px">,14,</font><font style="color:blue">&quot;E&quot;</font><font style="font-size:11px">) </font></td></tr><tr><td>Array.SetValue(<font style="color:blue">&quot;dec2hex&quot;</font><font style="font-size:11px">,15,</font><font style="color:blue">&quot;F&quot;</font><font style="font-size:11px">) </font></td></tr><tr><td style="background-color:rgb(247, 247, 247)"> </td></tr><tr><td> </td></tr><tr><td style="background-color:rgb(247, 247, 247)">TextWindow.Show() </td></tr><tr><td> </td></tr><tr><td style="background-color:rgb(247, 247, 247)"><font style="color:green">'Loop through a range of numbers to demonstrate </font><font style="font-size:11px"> </font></td></tr><tr><td><font style="color:blue">For</font><font style="font-size:11px"> i = 1 </font><font style="color:blue">To</font><font style="font-size:11px"> 255 </font></td></tr><tr><td style="background-color:rgb(247, 247, 247)"> <font style="color:green">'In order to pass values to our subroutine, we use the stack</font><font style="font-size:11px"> </font></td></tr><tr><td> <font style="color:green">'Push on here</font><font style="font-size:11px"> </font></td></tr><tr><td style="background-color:rgb(247, 247, 247)"> Stack.PushValue(<font style="color:blue">&quot;hex&quot;</font><font style="font-size:11px">,i) </font></td></tr><tr><td> <font style="color:green">'Call the sub</font><font style="font-size:11px"> </font></td></tr><tr><td style="background-color:rgb(247, 247, 247)"> toHex() </td></tr><tr><td> <font style="color:green">'Pop our answer off the top of the stack</font><font style="font-size:11px"> </font></td></tr><tr><td style="background-color:rgb(247, 247, 247)"> txt = Stack.PopValue(<font style="color:blue">&quot;hex&quot;</font><font style="font-size:11px">) </font></td></tr><tr><td> TextWindow.WriteLine(i+<font style="color:blue">&quot;     &quot;</font><font style="font-size:11px">+txt) </font></td></tr><tr><td style="background-color:rgb(247, 247, 247)">endfor </td></tr><tr><td> </td></tr><tr><td style="background-color:rgb(247, 247, 247)"> </td></tr><tr><td>  </td></tr><tr><td style="background-color:rgb(247, 247, 247)">  </td></tr><tr><td>  </td></tr><tr><td style="background-color:rgb(247, 247, 247)"> <font style="color:blue">Sub</font><font style="font-size:11px"> toHex </font></td></tr><tr><td>    <font style="color:green">'Get the value passed to the sub</font><font style="font-size:11px"> </font></td></tr><tr><td style="background-color:rgb(247, 247, 247)">    h = Stack.PopValue(<font style="color:blue">&quot;hex&quot;</font><font style="font-size:11px">) </font></td></tr><tr><td>    t = <font style="color:blue">&quot;&quot;</font><font style="font-size:11px"> </font></td></tr><tr><td style="background-color:rgb(247, 247, 247)">     </td></tr><tr><td>    <font style="color:green">'If 'h' is greater than 15, then we cannot use our lookup table</font><font style="font-size:11px"> </font></td></tr><tr><td style="background-color:rgb(247, 247, 247)">    <font style="color:blue">If</font><font style="font-size:11px"> (h &gt; 15) </font><font style="color:blue">Then</font><font style="font-size:11px"> </font></td></tr><tr><td>        <font style="color:green">'Push everything we need onto the stack</font><font style="font-size:11px"> </font></td></tr><tr><td style="background-color:rgb(247, 247, 247)">        <font style="color:green">'We need to do this otherwise everything seems to get trashed</font><font style="font-size:11px"> </font></td></tr><tr><td>        Stack.PushValue(<font style="color:blue">&quot;hex&quot;</font><font style="font-size:11px">,h) </font></td></tr><tr><td style="background-color:rgb(247, 247, 247)">         </td></tr><tr><td>        <font style="color:green">'Take the modulus of the value we wish to convert, we convert this with our lookup table</font><font style="font-size:11px"> </font></td></tr><tr><td style="background-color:rgb(247, 247, 247)">        r = Math.Remainder(h,16) </td></tr><tr><td>        Stack.PushValue(<font style="color:blue">&quot;hex&quot;</font><font style="font-size:11px">,r) </font></td></tr><tr><td style="background-color:rgb(247, 247, 247)">         </td></tr><tr><td>        <font style="color:green">'Divide the value by 16 and recurse to convert it</font><font style="font-size:11px"> </font></td></tr><tr><td style="background-color:rgb(247, 247, 247)">        j = (h - r) / 16 </td></tr><tr><td>         </td></tr><tr><td style="background-color:rgb(247, 247, 247)">        Stack.PushValue(<font style="color:blue">&quot;hex&quot;</font><font style="font-size:11px">,j) </font></td></tr><tr><td>        toHex() </td></tr><tr><td style="background-color:rgb(247, 247, 247)">         </td></tr><tr><td>        <font style="color:green">'Retrieve the answer and all our other variables</font><font style="font-size:11px"> </font></td></tr><tr><td style="background-color:rgb(247, 247, 247)">        t = Stack.PopValue(<font style="color:blue">&quot;hex&quot;</font><font style="font-size:11px">) </font></td></tr><tr><td>        r = Stack.PopValue(<font style="color:blue">&quot;hex&quot;</font><font style="font-size:11px">)         </font></td></tr><tr><td style="background-color:rgb(247, 247, 247)">        h = Stack.PopValue(<font style="color:blue">&quot;hex&quot;</font><font style="font-size:11px">) </font></td></tr><tr><td>    EndIf  </td></tr><tr><td style="background-color:rgb(247, 247, 247)">     </td></tr><tr><td>    <font style="color:green">'If h &lt; 16 we can use our lookup table</font><font style="font-size:11px"> </font></td></tr><tr><td style="background-color:rgb(247, 247, 247)">    <font style="color:blue">If</font><font style="font-size:11px"> (h &lt; 16) </font><font style="color:blue">Then</font><font style="font-size:11px"> </font></td></tr><tr><td>        r = h </td></tr><tr><td style="background-color:rgb(247, 247, 247)">    EndIf  </td></tr><tr><td>     </td></tr><tr><td style="background-color:rgb(247, 247, 247)">    <font style="color:green">'We convert for a single character</font><font style="font-size:11px"> </font></td></tr><tr><td>    c = Array.GetValue(<font style="color:blue">&quot;dec2hex&quot;</font><font style="font-size:11px">,r) </font></td></tr><tr><td style="background-color:rgb(247, 247, 247)">     </td></tr><tr><td>    <font style="color:green">'Append our converted character to the rest of the string if applicable    </font><font style="font-size:11px"> </font></td></tr><tr><td style="background-color:rgb(247, 247, 247)">    <font style="color:green">'The extra space and the line to remove it again are needed as </font><font style="font-size:11px"> </font></td></tr><tr><td>    <font style="color:green">'       smallbasic will treat the text as numbers if it can</font><font style="font-size:11px"> </font></td></tr><tr><td style="background-color:rgb(247, 247, 247)">    <font style="color:green">'       Christmas release will allow us to use Text.Append and clean this up</font><font style="font-size:11px"> </font></td></tr><tr><td>    t = <font style="color:blue">&quot; &quot;</font><font style="font-size:11px"> + t  + c </font></td></tr><tr><td style="background-color:rgb(247, 247, 247)">    t = Text.GetSubText(t,1,text.GetLength(t)-1) </td></tr><tr><td>      </td></tr><tr><td style="background-color:rgb(247, 247, 247)">    <font style="color:green">'Finally Push our answer onto the stack</font><font style="font-size:11px"> </font></td></tr><tr><td>    Stack.PushValue(<font style="color:blue">&quot;hex&quot;</font><font style="font-size:11px">,t) </font></td></tr><tr><td style="background-color:rgb(247, 247, 247)"> </td></tr><tr><td>EndSub  </td></tr><tr><td style="background-color:rgb(247, 247, 247)"> </td></tr></tbody></table></div><br><br>Tue, 02 Dec 2008 23:47:08 Z2008-12-02T23:47:08Zhttp://social.msdn.microsoft.com/Forums/en-US/smallbasic/thread/eaacf826-9d12-4e3c-aa10-1b2788f160a6#963cdf58-aa8b-42c5-ba41-5f8da013fd48http://social.msdn.microsoft.com/Forums/en-US/smallbasic/thread/eaacf826-9d12-4e3c-aa10-1b2788f160a6#963cdf58-aa8b-42c5-ba41-5f8da013fd48Tekgnohttp://social.msdn.microsoft.com/Profile/en-US/?user=TekgnoPost your sample source code here and get featured on our blogs!OK, this version lacks recursion, but still uses the stack to pass values to/from the sub.<br><br><div style="overflow:auto;background-color:white;line-height:100% ! important;font-family:Courier New;font-size:11px"><table style="border-width:0px;margin:2px 0px;width:99%;border-collapse:collapse;background-color:rgb(255, 255, 255)" cellpadding=0 cellspacing=0><col style="font-family:Courier New;font-size:11px;padding-left:10px;white-space:nowrap"><tbody><tr><td><font style="font-size:11px"></font><font style="color:green">'Demonstration code to convert decimal numbers in hexadecimal</font><font style="font-size:11px"> </font></td></tr><tr><td style="background-color:rgb(247, 247, 247)"><font style="color:green">' Version 2.0</font><font style="font-size:11px"> </font></td></tr><tr><td><font style="color:green">'By tekgno , Wednesday 3 December 2008</font><font style="font-size:11px"> </font></td></tr><tr><td style="background-color:rgb(247, 247, 247)"><font style="color:green">'Demonstrates use of the stack to pass values to/from a sub</font><font style="font-size:11px"> </font></td></tr><tr><td> </td></tr><tr><td style="background-color:rgb(247, 247, 247)"> </td></tr><tr><td><font style="color:green">'Initialise our array of decimal to hex characters</font><font style="font-size:11px"> </font></td></tr><tr><td style="background-color:rgb(247, 247, 247)">Array.SetValue(<font style="color:blue">&quot;dec2hex&quot;</font><font style="font-size:11px">,0,</font><font style="color:blue">&quot;0&quot;</font><font style="font-size:11px">) </font></td></tr><tr><td>Array.SetValue(<font style="color:blue">&quot;dec2hex&quot;</font><font style="font-size:11px">,1,</font><font style="color:blue">&quot;1&quot;</font><font style="font-size:11px">) </font></td></tr><tr><td style="background-color:rgb(247, 247, 247)">Array.SetValue(<font style="color:blue">&quot;dec2hex&quot;</font><font style="font-size:11px">,2,</font><font style="color:blue">&quot;2&quot;</font><font style="font-size:11px">) </font></td></tr><tr><td>Array.SetValue(<font style="color:blue">&quot;dec2hex&quot;</font><font style="font-size:11px">,3,</font><font style="color:blue">&quot;3&quot;</font><font style="font-size:11px">) </font></td></tr><tr><td style="background-color:rgb(247, 247, 247)">Array.SetValue(<font style="color:blue">&quot;dec2hex&quot;</font><font style="font-size:11px">,4,</font><font style="color:blue">&quot;4&quot;</font><font style="font-size:11px">) </font></td></tr><tr><td>Array.SetValue(<font style="color:blue">&quot;dec2hex&quot;</font><font style="font-size:11px">,5,</font><font style="color:blue">&quot;5&quot;</font><font style="font-size:11px">) </font></td></tr><tr><td style="background-color:rgb(247, 247, 247)">Array.SetValue(<font style="color:blue">&quot;dec2hex&quot;</font><font style="font-size:11px">,6,</font><font style="color:blue">&quot;6&quot;</font><font style="font-size:11px">) </font></td></tr><tr><td>Array.SetValue(<font style="color:blue">&quot;dec2hex&quot;</font><font style="font-size:11px">,7,</font><font style="color:blue">&quot;7&quot;</font><font style="font-size:11px">) </font></td></tr><tr><td style="background-color:rgb(247, 247, 247)">Array.SetValue(<font style="color:blue">&quot;dec2hex&quot;</font><font style="font-size:11px">,8,</font><font style="color:blue">&quot;8&quot;</font><font style="font-size:11px">) </font></td></tr><tr><td>Array.SetValue(<font style="color:blue">&quot;dec2hex&quot;</font><font style="font-size:11px">,9,</font><font style="color:blue">&quot;9&quot;</font><font style="font-size:11px">) </font></td></tr><tr><td style="background-color:rgb(247, 247, 247)">Array.SetValue(<font style="color:blue">&quot;dec2hex&quot;</font><font style="font-size:11px">,10,</font><font style="color:blue">&quot;A&quot;</font><font style="font-size:11px">) </font></td></tr><tr><td>Array.SetValue(<font style="color:blue">&quot;dec2hex&quot;</font><font style="font-size:11px">,11,</font><font style="color:blue">&quot;B&quot;</font><font style="font-size:11px">) </font></td></tr><tr><td style="background-color:rgb(247, 247, 247)">Array.SetValue(<font style="color:blue">&quot;dec2hex&quot;</font><font style="font-size:11px">,12,</font><font style="color:blue">&quot;C&quot;</font><font style="font-size:11px">) </font></td></tr><tr><td>Array.SetValue(<font style="color:blue">&quot;dec2hex&quot;</font><font style="font-size:11px">,13,</font><font style="color:blue">&quot;D&quot;</font><font style="font-size:11px">) </font></td></tr><tr><td style="background-color:rgb(247, 247, 247)">Array.SetValue(<font style="color:blue">&quot;dec2hex&quot;</font><font style="font-size:11px">,14,</font><font style="color:blue">&quot;E&quot;</font><font style="font-size:11px">) </font></td></tr><tr><td>Array.SetValue(<font style="color:blue">&quot;dec2hex&quot;</font><font style="font-size:11px">,15,</font><font style="color:blue">&quot;F&quot;</font><font style="font-size:11px">) </font></td></tr><tr><td style="background-color:rgb(247, 247, 247)"> </td></tr><tr><td> </td></tr><tr><td style="background-color:rgb(247, 247, 247)">TextWindow.Show() </td></tr><tr><td> </td></tr><tr><td style="background-color:rgb(247, 247, 247)"><font style="color:green">'Loop through a range of numbers to demonstrate </font><font style="font-size:11px"> </font></td></tr><tr><td><font style="color:blue">For</font><font style="font-size:11px"> i = 1 </font><font style="color:blue">To</font><font style="font-size:11px"> 255 </font></td></tr><tr><td style="background-color:rgb(247, 247, 247)"> <font style="color:green">'In order to pass values to our subroutine, we use the stack</font><font style="font-size:11px"> </font></td></tr><tr><td> <font style="color:green">'Push on here</font><font style="font-size:11px"> </font></td></tr><tr><td style="background-color:rgb(247, 247, 247)"> Stack.PushValue(<font style="color:blue">&quot;hex&quot;</font><font style="font-size:11px">,i) </font></td></tr><tr><td> <font style="color:green">'Call the sub</font><font style="font-size:11px"> </font></td></tr><tr><td style="background-color:rgb(247, 247, 247)"> toHex() </td></tr><tr><td> <font style="color:green">'Pop our answer off the top of the stack</font><font style="font-size:11px"> </font></td></tr><tr><td style="background-color:rgb(247, 247, 247)"> txt = Stack.PopValue(<font style="color:blue">&quot;hex&quot;</font><font style="font-size:11px">) </font></td></tr><tr><td> TextWindow.WriteLine(i+<font style="color:blue">&quot;     &quot;</font><font style="font-size:11px">+txt) </font></td></tr><tr><td style="background-color:rgb(247, 247, 247)">endfor </td></tr><tr><td>  </td></tr><tr><td style="background-color:rgb(247, 247, 247)">  </td></tr><tr><td>  </td></tr><tr><td style="background-color:rgb(247, 247, 247)"> <font style="color:blue">Sub</font><font style="font-size:11px"> toHex </font></td></tr><tr><td>    <font style="color:green">'Get the value passed to the sub</font><font style="font-size:11px"> </font></td></tr><tr><td style="background-color:rgb(247, 247, 247)">    h = Stack.PopValue(<font style="color:blue">&quot;hex&quot;</font><font style="font-size:11px">) </font></td></tr><tr><td>    t = <font style="color:blue">&quot;&quot;</font><font style="font-size:11px"> </font></td></tr><tr><td style="background-color:rgb(247, 247, 247)">     </td></tr><tr><td>    <font style="color:blue">While</font><font style="font-size:11px"> (h &gt; 0) </font></td></tr><tr><td style="background-color:rgb(247, 247, 247)">         </td></tr><tr><td>        <font style="color:green">'Take the modulus of the value we wish to convert, we convert this with our lookup table</font><font style="font-size:11px"> </font></td></tr><tr><td style="background-color:rgb(247, 247, 247)">        r = Math.Remainder(h,16) </td></tr><tr><td>         </td></tr><tr><td style="background-color:rgb(247, 247, 247)">        <font style="color:green">'The extra space and the line to remove it again are needed as </font><font style="font-size:11px"> </font></td></tr><tr><td>        <font style="color:green">'       smallbasic will treat the text as numbers if it can</font><font style="font-size:11px"> </font></td></tr><tr><td style="background-color:rgb(247, 247, 247)">        <font style="color:green">'       Christmas release will allow us to use Text.Append and clean this up</font><font style="font-size:11px"> </font></td></tr><tr><td>        t = <font style="color:blue">&quot; &quot;</font><font style="font-size:11px"> + Array.GetValue(</font><font style="color:blue">&quot;dec2hex&quot;</font><font style="font-size:11px">,r) + t  </font></td></tr><tr><td style="background-color:rgb(247, 247, 247)">        t = Text.GetSubText(t,1,text.GetLength(t)-1) </td></tr><tr><td>         </td></tr><tr><td style="background-color:rgb(247, 247, 247)">        <font style="color:green">'Divide the value by 16 </font><font style="font-size:11px"> </font></td></tr><tr><td>        h = (h - r) / 16 </td></tr><tr><td style="background-color:rgb(247, 247, 247)">    EndWhile  </td></tr><tr><td>     </td></tr><tr><td style="background-color:rgb(247, 247, 247)">    <font style="color:green">'Finally Push our answer onto the stack</font><font style="font-size:11px"> </font></td></tr><tr><td>    Stack.PushValue(<font style="color:blue">&quot;hex&quot;</font><font style="font-size:11px">,t) </font></td></tr><tr><td style="background-color:rgb(247, 247, 247)"> </td></tr><tr><td>EndSub  </td></tr><tr><td style="background-color:rgb(247, 247, 247)"> </td></tr><tr><td> </td></tr></tbody></table></div><br> Tue, 02 Dec 2008 23:58:55 Z2008-12-02T23:58:55Zhttp://social.msdn.microsoft.com/Forums/en-US/smallbasic/thread/eaacf826-9d12-4e3c-aa10-1b2788f160a6#e0b863fb-aa8e-40a1-9398-5ce0627037b4http://social.msdn.microsoft.com/Forums/en-US/smallbasic/thread/eaacf826-9d12-4e3c-aa10-1b2788f160a6#e0b863fb-aa8e-40a1-9398-5ce0627037b4Tekgnohttp://social.msdn.microsoft.com/Profile/en-US/?user=TekgnoPost your sample source code here and get featured on our blogs!Here is a much easier to understand recursion demo for calculating factorials:<br><br><div style="overflow:auto;background-color:white;line-height:100% ! important;font-family:Courier New;font-size:11px"><table style="border-width:0px;margin:2px 0px;width:99%;border-collapse:collapse;background-color:rgb(255, 255, 255)" cellpadding=0 cellspacing=0><col style="font-family:Courier New;font-size:11px;padding-left:10px;white-space:nowrap"><tbody><tr><td><font style="font-size:11px"></font><font style="color:green">'Factorials!</font><font style="font-size:11px"> </font></td></tr><tr><td style="background-color:rgb(247, 247, 247)"><font style="color:green">'By Tekgno, Wednesday 3 December 2008</font><font style="font-size:11px"> </font></td></tr><tr><td><font style="color:green">'A demo in recursion</font><font style="font-size:11px"> </font></td></tr><tr><td style="background-color:rgb(247, 247, 247)"> </td></tr><tr><td> </td></tr><tr><td style="background-color:rgb(247, 247, 247)">TextWindow.Show() </td></tr><tr><td> </td></tr><tr><td style="background-color:rgb(247, 247, 247)"><font style="color:green">'Show the factorials for all numbers up to 27, any higher and it crashes :(</font><font style="font-size:11px"> </font></td></tr><tr><td><font style="color:blue">For</font><font style="font-size:11px"> i = 0 </font><font style="color:blue">To</font><font style="font-size:11px"> 27 </font></td></tr><tr><td style="background-color:rgb(247, 247, 247)">    <font style="color:green">'Use the push/pop for value passing</font><font style="font-size:11px"> </font></td></tr><tr><td>    Stack.PushValue(<font style="color:blue">&quot;fact&quot;</font><font style="font-size:11px">,i ) </font></td></tr><tr><td style="background-color:rgb(247, 247, 247)">    factorial() </td></tr><tr><td>    a = Stack.PopValue(<font style="color:blue">&quot;fact&quot;</font><font style="font-size:11px">) </font></td></tr><tr><td style="background-color:rgb(247, 247, 247)">    TextWindow.WriteLine(i+<font style="color:blue">&quot;:    &quot;</font><font style="font-size:11px">+a) </font></td></tr><tr><td>EndFor  </td></tr><tr><td style="background-color:rgb(247, 247, 247)"> </td></tr><tr><td> </td></tr><tr><td style="background-color:rgb(247, 247, 247)"> </td></tr><tr><td><font style="color:blue">Sub</font><font style="font-size:11px"> factorial </font></td></tr><tr><td style="background-color:rgb(247, 247, 247)">    <font style="color:green">'Grab the number we wish to find the factorial for from the stack</font><font style="font-size:11px"> </font></td></tr><tr><td>    f = Stack.PopValue(<font style="color:blue">&quot;fact&quot;</font><font style="font-size:11px">) </font></td></tr><tr><td style="background-color:rgb(247, 247, 247)">    r = 1 </td></tr><tr><td>     </td></tr><tr><td style="background-color:rgb(247, 247, 247)">    <font style="color:green">'Since n! = n * (n-1)!</font><font style="font-size:11px"> </font></td></tr><tr><td>    <font style="color:green">'If n &gt; 1 then we find what (n-1)! is</font><font style="font-size:11px"> </font></td></tr><tr><td style="background-color:rgb(247, 247, 247)">    <font style="color:blue">If</font><font style="font-size:11px"> (f &gt; 1) </font><font style="color:blue">Then</font><font style="font-size:11px"> </font></td></tr><tr><td>        Stack.PushValue(<font style="color:blue">&quot;fact&quot;</font><font style="font-size:11px">,f) </font></td></tr><tr><td style="background-color:rgb(247, 247, 247)">        Stack.PushValue(<font style="color:blue">&quot;fact&quot;</font><font style="font-size:11px">,f-1) </font></td></tr><tr><td>        factorial() </td></tr><tr><td style="background-color:rgb(247, 247, 247)">        r = Stack.PopValue(<font style="color:blue">&quot;fact&quot;</font><font style="font-size:11px">) </font></td></tr><tr><td>        f = Stack.PopValue(<font style="color:blue">&quot;fact&quot;</font><font style="font-size:11px">) </font></td></tr><tr><td style="background-color:rgb(247, 247, 247)">          </td></tr><tr><td>    EndIf  </td></tr><tr><td style="background-color:rgb(247, 247, 247)"> </td></tr><tr><td>    <font style="color:green">'At this point, r will either still be initialised at 1, or will contain (n-1)!</font><font style="font-size:11px"> </font></td></tr><tr><td style="background-color:rgb(247, 247, 247)">    r = f * r </td></tr><tr><td>    <font style="color:green">'The factorial for 0 is 1</font><font style="font-size:11px"> </font></td></tr><tr><td style="background-color:rgb(247, 247, 247)">    <font style="color:blue">If</font><font style="font-size:11px"> (f = 0) </font><font style="color:blue">Then</font><font style="font-size:11px">  </font></td></tr><tr><td>        r = 1 </td></tr><tr><td style="background-color:rgb(247, 247, 247)">    EndIf  </td></tr><tr><td>    <font style="color:green">'The factorial for negative numbers is undefined</font><font style="font-size:11px"> </font></td></tr><tr><td style="background-color:rgb(247, 247, 247)">    <font style="color:blue">If</font><font style="font-size:11px"> (f &lt; 0) </font><font style="color:blue">Then</font><font style="font-size:11px"> </font></td></tr><tr><td>        r = <font style="color:blue">&quot;Undefined&quot;</font><font style="font-size:11px"> </font></td></tr><tr><td style="background-color:rgb(247, 247, 247)">    EndIf  </td></tr><tr><td>    Stack.PushValue(<font style="color:blue">&quot;fact&quot;</font><font style="font-size:11px">,r) </font></td></tr><tr><td style="background-color:rgb(247, 247, 247)">         </td></tr><tr><td>EndSub      </td></tr><tr><td style="background-color:rgb(247, 247, 247)"> </td></tr></tbody></table></div><br> Wed, 03 Dec 2008 00:32:53 Z2008-12-03T00:32:53Zhttp://social.msdn.microsoft.com/Forums/en-US/smallbasic/thread/eaacf826-9d12-4e3c-aa10-1b2788f160a6#70874443-5960-4dc1-af98-b21f45836218http://social.msdn.microsoft.com/Forums/en-US/smallbasic/thread/eaacf826-9d12-4e3c-aa10-1b2788f160a6#70874443-5960-4dc1-af98-b21f45836218Vijaye Rajihttp://social.msdn.microsoft.com/Profile/en-US/?user=Vijaye%20RajiPost your sample source code here and get featured on our blogs! Really nice, Tekgno.  I really like the recursion demonstration with factorials!<br>Mon, 08 Dec 2008 02:17:49 Z2008-12-08T02:17:49Zhttp://social.msdn.microsoft.com/Forums/en-US/smallbasic/thread/eaacf826-9d12-4e3c-aa10-1b2788f160a6#88780658-5aef-4907-a04a-948b837cd8e8http://social.msdn.microsoft.com/Forums/en-US/smallbasic/thread/eaacf826-9d12-4e3c-aa10-1b2788f160a6#88780658-5aef-4907-a04a-948b837cd8e8George Birbilishttp://social.msdn.microsoft.com/Profile/en-US/?user=George%20BirbilisPost your sample source code here and get featured on our blogs! Since there's a Stack object, how come SmallBasic doesn't support function parameters? Wouldn't be hard to generate code internally to push all params to stack and then at the function pop them at the reverse order into local variables<hr class="sig">Microsoft MVP J# 2004-2007, Borland Spirit of Delphi 2001Mon, 08 Dec 2008 12:32:38 Z2008-12-08T12:32:38Zhttp://social.msdn.microsoft.com/Forums/en-US/smallbasic/thread/eaacf826-9d12-4e3c-aa10-1b2788f160a6#d9b7dd38-39b5-46dc-b3aa-415bcdc6e9e8http://social.msdn.microsoft.com/Forums/en-US/smallbasic/thread/eaacf826-9d12-4e3c-aa10-1b2788f160a6#d9b7dd38-39b5-46dc-b3aa-415bcdc6e9e8George Birbilishttp://social.msdn.microsoft.com/Profile/en-US/?user=George%20BirbilisPost your sample source code here and get featured on our blogs! could also try porting some of the demos from the other SmallBASIC (see screenshots at <a href="http://smallbasic.sourceforge.net/?q=node/835">http://smallbasic.sourceforge.net/?q=node/835</a>)<hr class="sig">Microsoft MVP J# 2004-2007, Borland Spirit of Delphi 2001Mon, 08 Dec 2008 12:51:15 Z2008-12-08T12:51:15Zhttp://social.msdn.microsoft.com/Forums/en-US/smallbasic/thread/eaacf826-9d12-4e3c-aa10-1b2788f160a6#62129b4a-e18f-4196-96ed-8b76fa827a6dhttp://social.msdn.microsoft.com/Forums/en-US/smallbasic/thread/eaacf826-9d12-4e3c-aa10-1b2788f160a6#62129b4a-e18f-4196-96ed-8b76fa827a6dVijaye Rajihttp://social.msdn.microsoft.com/Profile/en-US/?user=Vijaye%20RajiPost your sample source code here and get featured on our blogs! The reason we don't have function parameters is because there isn't a notion of scopes in Small Basic (just like QBasic).  In order for function parameters to work, they should be made applicable only inside of sub body, which contradicts the &quot;all variables are global&quot; principle.<br>Mon, 08 Dec 2008 15:29:10 Z2008-12-08T15:29:10Zhttp://social.msdn.microsoft.com/Forums/en-US/smallbasic/thread/eaacf826-9d12-4e3c-aa10-1b2788f160a6#5e9102eb-1a14-4995-ade3-fd13461333b5http://social.msdn.microsoft.com/Forums/en-US/smallbasic/thread/eaacf826-9d12-4e3c-aa10-1b2788f160a6#5e9102eb-1a14-4995-ade3-fd13461333b5George Birbilishttp://social.msdn.microsoft.com/Profile/en-US/?user=George%20BirbilisPost your sample source code here and get featured on our blogs!The problem with the lack of scope is that you can't expect schools to use this for teaching programming, except for very young kids (primary school maybe, although many would use visual programming [see Scratch or Boku for example] at that age). You shouldn't use GWBasic/QBasic as example in my opinion, should use QuickBasic/TurboBasic/PowerBasic instead as example in my opinion. <br><br>Also, as I've written elsewhere on the forum, it's contradictory/inconsistent that object (library) methods that you provide take params whereas the end-user's own methods (for &quot;libraries&quot; the end-user [educator or child] wants to make in SmallBasic code) don't take params. That way you have two classes of calls, with the user's defined stuff being inferior to the ones you've defined (or that others have defined as SmallBasic extensions in low-level C# etc. code)<br><br><br>For example Logo uses the concept of &quot;local&quot; and &quot;global&quot; with commands like &quot;localmake&quot; (for locals) and &quot;make&quot; (for globals). First-time users will use &quot;make&quot; and later on will get introduced to &quot;localmake&quot; (also it has say local &quot;x command which is remembered and if followed by make &quot;x 10 later on it does a localmake for &quot;x)<br><hr class="sig">Microsoft MVP J# 2004-2007, Borland Spirit of Delphi 2001Mon, 08 Dec 2008 15:49:18 Z2008-12-08T15:49:18Zhttp://social.msdn.microsoft.com/Forums/en-US/smallbasic/thread/eaacf826-9d12-4e3c-aa10-1b2788f160a6#995b576b-3c63-47bd-b072-425a9691502chttp://social.msdn.microsoft.com/Forums/en-US/smallbasic/thread/eaacf826-9d12-4e3c-aa10-1b2788f160a6#995b576b-3c63-47bd-b072-425a9691502cPath_drchttp://social.msdn.microsoft.com/Profile/en-US/?user=Path_drcPost your sample source code here and get featured on our blogs!Still working on the 3D maze thing but wanted to complete something (getting a bit of coder's block) to get my mind off it.<br><br> I call this one Random Bouncing Points.<br><br>Enter the number of points, from 2 to 20.<br><br>Those points bounce around the screen in random directions and in random increments, drawing a line from point 1 to point 2 to point 3... depending on number of points entered, and then from last point to first point.<br>The color of lines are random and change to a random color every time any point bounces off a wall.<br><br>While points are bouncing, you can press keys to do the following:<br><br>End Program  = Escape key<br><br>Increase delay (up to 200 ms)<br>(slow down the time between points replotting) = Up arrow<br><br>Decrease delay (to zero)<br>(speeds up time between points replotting) = Down arrow<br><br> <div style="border-right:#7f9db9 1px solid;border-top:#7f9db9 1px solid;font-size:11px;overflow:auto;border-left:#7f9db9 1px solid;width:699px;line-height:100%! important;border-bottom:#7f9db9 1px solid;font-family:Courier New;height:203px;background-color:white"> <table style="border-top-width:0px;border-left-width:0px;margin:2px 0px;width:99%;border-bottom:#eee 0px solid;border-collapse:collapse;background-color:#fff;border-right-width:0px" cellspacing=0 cellpadding=0> <colgroup> <col style="padding-left:10px;font-size:11px;border-bottom:#f7f7f7 1px solid;font-family:Courier New;white-space:nowrap"> <tbody> <tr> <td><font style="font-size:11px">'Random Bouncing Points  </font></td></tr> <tr> <td style="background-color:#f7f7f7">'created for Microsoft Small Basic  </td></tr> <tr> <td>'by David R. Crutchfield on 12/11/2008  </td></tr> <tr> <td style="background-color:#f7f7f7"> </td></tr> <tr> <td></font><font style="color:red">correctkey</font><font style="font-size:11px"> = </font><font style="color:blue">&quot;False&quot;</font><font style="font-size:11px"> </font></td></tr> <tr> <td style="background-color:#f7f7f7">While (</font><font style="color:red">correctkey</font><font style="font-size:11px"> = </font><font style="color:blue">&quot;False&quot;</font><font style="font-size:11px">)  </font></td></tr> <tr> <td>    TextWindow.Show()  </td></tr> <tr> <td style="background-color:#f7f7f7">    TextWindow.WriteLine(&quot;Type number of points to bounce (from 2 to 20, or 0 to exit)&quot;)  </td></tr> <tr> <td>    TextWindow.Write(&quot;and press the Enter key: &quot;)  </td></tr> <tr> <td style="background-color:#f7f7f7">    </font><font style="color:red">numofpoints</font><font style="font-size:11px"> = </font><font style="color:blue">TextWindow</font><font style="font-size:11px">.ReadNumber()  </font></td></tr> <tr> <td> </td></tr> <tr> <td style="background-color:#f7f7f7">    If (numofpoints</font><font style="color:blue">&gt;</font><font style="font-size:11px">1 And numofpoints</font><font style="color:blue">&lt;</font><font style="font-size:11px">21) Then  </font></td></tr> <tr> <td>        </font><font style="color:red">correctkey</font><font style="font-size:11px"> = </font><font style="color:blue">&quot;True&quot;</font><font style="font-size:11px"> </font></td></tr> <tr> <td style="background-color:#f7f7f7">    Else  </td></tr> <tr> <td>        If (</font><font style="color:red">numofpoints</font><font style="font-size:11px"> = </font><font style="color:blue">0</font><font style="font-size:11px">) Then  </font></td></tr> <tr> <td style="background-color:#f7f7f7">            </font><font style="color:red">correctkey</font><font style="font-size:11px"> = </font><font style="color:blue">&quot;True&quot;</font><font style="font-size:11px">    </font></td></tr> <tr> <td>            Program.End()  </td></tr> <tr> <td style="background-color:#f7f7f7">        Else  </td></tr> <tr> <td>            TextWindow.WriteLine(&quot;&quot;)  </td></tr> <tr> <td style="background-color:#f7f7f7">            TextWindow.WriteLine(&quot;Number can be no less than 2 and no larger than 20,&quot;)  </td></tr> <tr> <td>            TextWindow.WriteLine(&quot;or 0 (zero) to exit.&quot;)  </td></tr> <tr> <td style="background-color:#f7f7f7">            TextWindow.WriteLine(&quot;&quot;)  </td></tr> <tr> <td>            Sound.PlayBellRingAndWait()  </td></tr> <tr> <td style="background-color:#f7f7f7">        EndIf  </td></tr> <tr> <td>          </td></tr> <tr> <td style="background-color:#f7f7f7">    EndIf  </td></tr> <tr> <td>EndWhile  </td></tr> <tr> <td style="background-color:#f7f7f7"> </td></tr> <tr> <td>TextWindow.Hide()  </td></tr> <tr> <td style="background-color:#f7f7f7"> </td></tr> <tr> <td>'ranomize X, Y starting coordinates , direction, and point movement amount  </td></tr> <tr> <td style="background-color:#f7f7f7">For </font><font style="color:red">pointnum</font><font style="font-size:11px"> = </font><font style="color:blue">1</font><font style="font-size:11px"> To numofpoints  </font></td></tr> <tr> <td>    Array.SetValue(&quot;X&quot;,pointnum,Math.GetRandomNumber(801))  </td></tr> <tr> <td style="background-color:#f7f7f7">    Array.SetValue(&quot;Y&quot;,pointnum,Math.GetRandomNumber(800))  </td></tr> <tr> <td>      </td></tr> <tr> <td style="background-color:#f7f7f7">    '   randomize X axis start direction  </td></tr> <tr> <td>    </font><font style="color:red">direction</font><font style="font-size:11px"> = </font><font style="color:blue">Math</font><font style="font-size:11px">.GetRandomNumber(2)  </font></td></tr> <tr> <td style="background-color:#f7f7f7">    If (</font><font style="color:red">direction</font><font style="font-size:11px"> = </font><font style="color:blue">0</font><font style="font-size:11px">) Then  </font></td></tr> <tr> <td>        Array.SetValue(&quot;directionX&quot;,pointnum,-1)  </td></tr> <tr> <td style="background-color:#f7f7f7">    Else  </td></tr> <tr> <td>        Array.SetValue(&quot;directionX&quot;,pointnum,1)  </td></tr> <tr> <td style="background-color:#f7f7f7">    EndIf  </td></tr> <tr> <td>      </td></tr> <tr> <td style="background-color:#f7f7f7">    '   randomize Y axis start direction  </td></tr> <tr> <td>    </font><font style="color:red">direction</font><font style="font-size:11px"> = </font><font style="color:blue">Math</font><font style="font-size:11px">.GetRandomNumber(2)  </font></td></tr> <tr> <td style="background-color:#f7f7f7">    If (</font><font style="color:red">direction</font><font style="font-size:11px"> = </font><font style="color:blue">0</font><font style="font-size:11px">) Then  </font></td></tr> <tr> <td>        Array.SetValue(&quot;directionY&quot;,pointnum,-1)  </td></tr> <tr> <td style="background-color:#f7f7f7">    Else  </td></tr> <tr> <td>        Array.SetValue(&quot;directionY&quot;,pointnum,1)  </td></tr> <tr> <td style="background-color:#f7f7f7">    EndIf  </td></tr> <tr> <td> </td></tr> <tr> <td style="background-color:#f7f7f7">    '   randomize start move amount for X and Y axis  </td></tr> <tr> <td>    Array.SetValue(&quot;moveX&quot;,pointnum,Math.GetRandomNumber(50)+1)  </td></tr> <tr> <td style="background-color:#f7f7f7">    Array.SetValue(&quot;moveY&quot;,pointnum,Math.GetRandomNumber(50)+1)  </td></tr> <tr> <td>EndFor  </td></tr> <tr> <td style="background-color:#f7f7f7"> </td></tr> <tr> <td>'initialize graphics window  </td></tr> <tr> <td style="background-color:#f7f7f7"></font><font style="color:red">GraphicsWindow.Height</font><font style="font-size:11px"> = </font><font style="color:blue">800</font><font style="font-size:11px"> </font></td></tr> <tr> <td></font><font style="color:red">GraphicsWindow.Width</font><font style="font-size:11px"> = </font><font style="color:blue">800</font><font style="font-size:11px"> </font></td></tr> <tr> <td style="background-color:#f7f7f7"></font><font style="color:red">GraphicsWindow.BackgroundColor</font><font style="font-size:11px"> = </font><font style="color:blue">&quot;Black&quot;</font><font style="font-size:11px"> </font></td></tr> <tr> <td></font><font style="color:red">GraphicsWindow.Title</font><font style="font-size:11px"> = </font><font style="color:blue">&quot;Random Bouncing Points&quot;</font><font style="font-size:11px"> </font></td></tr> <tr> <td style="background-color:#f7f7f7">GraphicsWindow.Show()  </td></tr> <tr> <td></font><font style="color:blue">GraphicsWindow</font><font style="font-size:11px"></font><font style="color:red">GraphicsWindow.PenColor</font><font style="font-size:11px"> = GraphicsWindow.GetRandomColor()  </font></td></tr> <tr> <td style="background-color:#f7f7f7"> </td></tr> <tr> <td></font><font style="color:red">GraphicsWindow.KeyDown</font><font style="font-size:11px"> = </font><font style="color:blue">ReadKey</font><font style="font-size:11px"> </font></td></tr> <tr> <td style="background-color:#f7f7f7"> </td></tr> <tr> <td></font><font style="color:red">repeat</font><font style="font-size:11px"> = </font><font style="color:blue">&quot;True&quot;</font><font style="font-size:11px"> </font></td></tr> <tr> <td style="background-color:#f7f7f7"> </td></tr> <tr> <td>While (repeat)  </td></tr> <tr> <td style="background-color:#f7f7f7">    Program.Delay(pause)  </td></tr> <tr> <td>    For </font><font style="color:red">pointnum</font><font style="font-size:11px"> = </font><font style="color:blue">1</font><font style="font-size:11px"> To numofpoints  </font></td></tr> <tr> <td style="background-color:#f7f7f7">        If (pointnum</font><font style="color:blue">&lt;</font><font style="font-size:11px">numofpoints) Then  </font></td></tr> <tr> <td>            GraphicsWindow.DrawLine(Array.GetValue(&quot;X&quot;,pointnum), Array.GetValue(&quot;Y&quot;,pointnum), Array.GetValue(&quot;X&quot;,pointnum+1), Array.GetValue(&quot;Y&quot;,pointnum+1))  </td></tr> <tr> <td style="background-color:#f7f7f7">        Else  </td></tr> <tr> <td>            GraphicsWindow.DrawLine(Array.GetValue(&quot;X&quot;,pointnum), Array.GetValue(&quot;Y&quot;,pointnum), Array.GetValue(&quot;X&quot;,1), Array.GetValue(&quot;Y&quot;,1))  </td></tr> <tr> <td style="background-color:#f7f7f7">        EndIf  </td></tr> <tr> <td> </td></tr> <tr> <td style="background-color:#f7f7f7">        '   move X axis  </td></tr> <tr> <td>        </font><font style="color:red">newX</font><font style="font-size:11px"> = </font><font style="color:blue">Array</font><font style="font-size:11px">.GetValue(&quot;X&quot;,pointnum)+Array.GetValue(&quot;moveX&quot;,pointnum)*Array.GetValue(&quot;directionX&quot;,pointnum)  </font></td></tr> <tr> <td style="background-color:#f7f7f7">        If (newX</font><font style="color:blue">&lt;</font><font style="font-size:11px">0 Or newX</font><font style="color:blue">&gt;</font><font style="font-size:11px">800) Then  </font></td></tr> <tr> <td>            If (newX</font><font style="color:blue">&gt;</font><font style="font-size:11px">800) Then  </font></td></tr> <tr> <td style="background-color:#f7f7f7">                </font><font style="color:red">newX</font><font style="font-size:11px"> = </font><font style="color:blue">800</font><font style="font-size:11px"> - (newX - 800)  </font></td></tr> <tr> <td>                Array.SetValue(&quot;directionX&quot;,pointnum,-1)  </td></tr> <tr> <td style="background-color:#f7f7f7">            Else  </td></tr> <tr> <td>                </font><font style="color:red">newX</font><font style="font-size:11px"> = newX * -1  </font></td></tr> <tr> <td style="background-color:#f7f7f7">                Array.SetValue(&quot;directionX&quot;,pointnum,1)  </td></tr> <tr> <td>            EndIf  </td></tr> <tr> <td style="background-color:#f7f7f7">              </td></tr> <tr> <td>            ' randomize X axis move amount after hitting wall.  </td></tr> <tr> <td style="background-color:#f7f7f7">            Array.SetValue(&quot;moveX&quot;,pointnum,Math.GetRandomNumber(50)+1)  </td></tr> <tr> <td>            'get random color when point hits wall  </td></tr> <tr> <td style="background-color:#f7f7f7">            </font><font style="color:blue">GraphicsWindow.</font><font style="font-size:11px"></font><font style="color:red">GraphicsWindow.PenColor</font><font style="font-size:11px"> = GraphicsWindow.GetRandomColor()  </font></td></tr> <tr> <td>        EndIf  </td></tr> <tr> <td style="background-color:#f7f7f7">          </td></tr> <tr> <td>        Array.SetValue(&quot;X&quot;,pointnum,newX)  </td></tr> <tr> <td style="background-color:#f7f7f7">          </td></tr> <tr> <td>        ' move Y axis  </td></tr> <tr> <td style="background-color:#f7f7f7">        </font><font style="color:red">newY</font><font style="font-size:11px"> = </font><font style="color:blue">Array</font><font style="font-size:11px">.GetValue(&quot;Y&quot;,pointnum)+Array.GetValue(&quot;moveY&quot;,pointnum)*Array.GetValue(&quot;directionY&quot;,pointnum)  </font></td></tr> <tr> <td>        If (newY</font><font style="color:blue">&lt;</font><font style="font-size:11px">0 Or newY</font><font style="color:blue">&gt;</font><font style="font-size:11px">800) Then  </font></td></tr> <tr> <td style="background-color:#f7f7f7">            If (newY</font><font style="color:blue">&gt;</font><font style="font-size:11px">800) Then  </font></td></tr> <tr> <td>                </font><font style="color:red">newY</font><font style="font-size:11px"> = </font><font style="color:blue">800</font><font style="font-size:11px"> - (newY - 800)  </font></td></tr> <tr> <td style="background-color:#f7f7f7">                Array.SetValue(&quot;directionY&quot;,pointnum,-1)  </td></tr> <tr> <td>            Else  </td></tr> <tr> <td style="background-color:#f7f7f7">                </font><font style="color:red">newY</font><font style="font-size:11px"></font><font style="color:blue">newY</font><font style="font-size:11px"> = newY * -1  </font></td></tr> <tr> <td>                Array.SetValue(&quot;directionY&quot;,pointnum,1)  </td></tr> <tr> <td style="background-color:#f7f7f7">            EndIf  </td></tr> <tr> <td> </td></tr> <tr> <td style="background-color:#f7f7f7">            ' randomize Y axis move amount after hitting wall.  </td></tr> <tr> <td>            Array.SetValue(&quot;moveY&quot;,pointnum,Math.GetRandomNumber(50)+1)  </td></tr> <tr> <td style="background-color:#f7f7f7">            'get randome color when point hits wall  </td></tr> <tr> <td>            </font><font style="color:blue">GraphicsWindow</font><font style="font-size:11px"></font><font style="color:red">GraphicsWindow.PenColor</font><font style="font-size:11px"> = GraphicsWindow.GetRandomColor()  </font></td></tr> <tr> <td style="background-color:#f7f7f7">        EndIf  </td></tr> <tr> <td>          </td></tr> <tr> <td style="background-color:#f7f7f7">        Array.SetValue(&quot;Y&quot;,pointnum,newY)  </td></tr> <tr> <td>          </td></tr> <tr> <td style="background-color:#f7f7f7">    EndFor  </td></tr> <tr> <td>EndWhile  </td></tr> <tr> <td style="background-color:#f7f7f7"> </td></tr> <tr> <td>Program.End()  </td></tr> <tr> <td style="background-color:#f7f7f7"> </td></tr> <tr> <td> </td></tr> <tr> <td style="background-color:#f7f7f7">Sub ReadKey  </td></tr> <tr> <td>    </font><font style="color:red">key</font><font style="font-size:11px"> = </font><font style="color:blue">GraphicsWindow</font><font style="font-size:11px">.LastKey  </font></td></tr> <tr> <td style="background-color:#f7f7f7">    If (</font><font style="color:red">key</font><font style="font-size:11px"> = </font><font style="color:blue">&quot;Escape&quot;</font><font style="font-size:11px">) Then  </font></td></tr> <tr> <td>        </font><font style="color:red">repeat</font><font style="font-size:11px"> = </font><font style="color:blue">&quot;False&quot;</font><font style="font-size:11px"> </font></td></tr> <tr> <td style="background-color:#f7f7f7">    EndIf  </td></tr> <tr> <td>    If (</font><font style="color:red">key</font><font style="font-size:11px"> = </font><font style="color:blue">&quot;Up&quot;</font><font style="font-size:11px">) Then  </font></td></tr> <tr> <td style="background-color:#f7f7f7">        </font><font style="color:red">pause</font><font style="font-size:11px"></font><font style="color:blue">pause</font><font style="font-size:11px"> = pause + 1  </font></td></tr> <tr> <td>        If (pause </font><font style="color:blue">&gt;</font><font style="font-size:11px"> 200) Then  </font></td></tr> <tr> <td style="background-color:#f7f7f7">            </font><font style="color:red">pause</font><font style="font-size:11px"> = </font><font style="color:blue">200</font><font style="font-size:11px"> </font></td></tr> <tr> <td>        EndIf  </td></tr> <tr> <td style="background-color:#f7f7f7">    EndIf  </td></tr> <tr> <td>    If (</font><font style="color:red">key</font><font style="font-size:11px"> = </font><font style="color:blue">&quot;Down&quot;</font><font style="font-size:11px">) Then  </font></td></tr> <tr> <td style="background-color:#f7f7f7">        </font><font style="color:red">pause</font><font style="font-size:11px"></font><font style="color:blue">pause</font><font style="font-size:11px"> = pause - 1  </font></td></tr> <tr> <td>        If (pause </font><font style="color:blue">&lt;</font><font style="font-size:11px"> </font><font style="font-weight:bold;color:black">0</font><font style="font-size:11px">) Then  </font></td></tr> <tr> <td style="background-color:#f7f7f7">            </font><font style="color:red">pause</font><font style="font-size:11px"> = </font><font style="color:blue">0</font><font style="font-size:11px"> </font></td></tr> <tr> <td>        EndIf  </td></tr> <tr> <td style="background-color:#f7f7f7">    EndIf  </td></tr> <tr> <td>    </font><font style="color:red">GraphicsWindow.Title</font><font style="font-size:11px"> = </font><font style="color:blue">&quot;Random Bouncing Points   Delay = &quot;</font><font style="font-size:11px">+pause+&quot; milliseconds&quot;  </font></td></tr> <tr> <td style="background-color:#f7f7f7">EndSub </td></tr></tbody></table></div><br><br>Lines of code = 103<br>Remark lines = 14<br>Blank lines = 23<br>Total lines = 140<br><br>Executable file size = 6 KB<br><br>By the way.<br>I sent the executable file to a friend in the office here.<br>He has the same office computer that I have, but when he runs it, it immediately crashes and wants to send a report to Microsoft.<br>If I want to share the programs I create do the recipients have to have something special to run the exe's?Fri, 12 Dec 2008 02:58:17 Z2008-12-12T06:40:13Zhttp://social.msdn.microsoft.com/Forums/en-US/smallbasic/thread/eaacf826-9d12-4e3c-aa10-1b2788f160a6#c03a5598-b29e-4da0-bbe8-62a91dfe64edhttp://social.msdn.microsoft.com/Forums/en-US/smallbasic/thread/eaacf826-9d12-4e3c-aa10-1b2788f160a6#c03a5598-b29e-4da0-bbe8-62a91dfe64edRushworkshttp://social.msdn.microsoft.com/Profile/en-US/?user=RushworksPost your sample source code here and get featured on our blogs!<font style="font-size:12px">Path_drc,<br>The code you provided seems to have some typos in it,<br> <font style="font-size:12px" color="#0000ff">GraphicsWindow </font><font style="font-size:12px;color:red">GraphicsWindow.PenColor</font></font><font style="font-size:12px"> = GraphicsWindow.GetRandomColor()  <br><br>To send to a friend you must include your <font color="#ff0000">.exe file</font> and <font color="#ff0000">SmallBasicLibrary.dll</font>, plus any other libraries(.dll) you used to create your program.  They must also have the .Net Framework Runtime installed on their computer</font>Fri, 12 Dec 2008 05:05:04 Z2008-12-12T05:05:04Zhttp://social.msdn.microsoft.com/Forums/en-US/smallbasic/thread/eaacf826-9d12-4e3c-aa10-1b2788f160a6#7c9f0b32-4bc2-4f3d-a3c3-e240c0720dd5http://social.msdn.microsoft.com/Forums/en-US/smallbasic/thread/eaacf826-9d12-4e3c-aa10-1b2788f160a6#7c9f0b32-4bc2-4f3d-a3c3-e240c0720dd5Path_drchttp://social.msdn.microsoft.com/Profile/en-US/?user=Path_drcPost your sample source code here and get featured on our blogs! I don't know how that happened.  I copied straight from the editor after a few succesfull runs.<br><br>I'll correct it tomorrow.<br><br>THNX!Fri, 12 Dec 2008 06:43:56 Z2008-12-12T06:43:56Zhttp://social.msdn.microsoft.com/Forums/en-US/smallbasic/thread/eaacf826-9d12-4e3c-aa10-1b2788f160a6#bf476332-c158-4848-9b3c-ba1965ed1854http://social.msdn.microsoft.com/Forums/en-US/smallbasic/thread/eaacf826-9d12-4e3c-aa10-1b2788f160a6#bf476332-c158-4848-9b3c-ba1965ed1854Vijaye Rajihttp://social.msdn.microsoft.com/Profile/en-US/?user=Vijaye%20RajiPost your sample source code here and get featured on our blogs! Love it, DRC.  Here's DRC's program with the typos fixed.<br><br> <div style="border-right:#cccccc 1px solid;padding-right:4px;border-top:#cccccc 1px solid;padding-left:4px;padding-bottom:4px;margin:4px;border-left:#cccccc 1px solid;padding-top:4px;border-bottom:#cccccc 1px solid"><pre>'Random Bouncing Points 'created for Microsoft Small Basic 'by David R. Crutchfield on 12/11/2008 correctkey = &quot;False&quot; While (correctkey = &quot;False&quot;) TextWindow.Show() TextWindow.WriteLine(&quot;Type number of points to bounce (from 2 to 20, or 0 to exit)&quot;) TextWindow.Write(&quot;and press the Enter key: &quot;) numofpoints = TextWindow.ReadNumber() If (numofpoints&gt;1 And numofpoints&lt;21) Then correctkey = &quot;True&quot; Else If (numofpoints = 0) Then correctkey = &quot;True&quot; Program.End() Else TextWindow.WriteLine(&quot;&quot;) TextWindow.WriteLine(&quot;Number can be no less than 2 and no larger than 20,&quot;) TextWindow.WriteLine(&quot;or 0 (zero) to exit.&quot;) TextWindow.WriteLine(&quot;&quot;) Sound.PlayBellRingAndWait() EndIf EndIf EndWhile TextWindow.Hide() 'ranomize X, Y starting coordinates , direction, and point movement amount For pointnum = 1 To numofpoints Array.SetValue(&quot;X&quot;,pointnum,Math.GetRandomNumber(801)) Array.SetValue(&quot;Y&quot;,pointnum,Math.GetRandomNumber(800)) ' randomize X axis start direction direction = Math.GetRandomNumber(2) If (direction = 0) Then Array.SetValue(&quot;directionX&quot;,pointnum,-1) Else Array.SetValue(&quot;directionX&quot;,pointnum,1) EndIf ' randomize Y axis start direction direction = Math.GetRandomNumber(2) If (direction = 0) Then Array.SetValue(&quot;directionY&quot;,pointnum,-1) Else Array.SetValue(&quot;directionY&quot;,pointnum,1) EndIf ' randomize start move amount for X and Y axis Array.SetValue(&quot;moveX&quot;,pointnum,Math.GetRandomNumber(50)+1) Array.SetValue(&quot;moveY&quot;,pointnum,Math.GetRandomNumber(50)+1) EndFor 'initialize graphics window GraphicsWindow.Height = 800 GraphicsWindow.Width = 800 GraphicsWindow.BackgroundColor = &quot;Black&quot; GraphicsWindow.Title = &quot;Random Bouncing Points&quot; GraphicsWindow.Show() GraphicsWindow.PenColor = GraphicsWindow.GetRandomColor() GraphicsWindow.KeyDown = ReadKey repeat = &quot;True&quot; While (repeat) Program.Delay(pause) For pointnum = 1 To numofpoints If (pointnum800) Then If (newY&gt;800) Then newY = 800 - (newY - 800) Array.SetValue(&quot;directionY&quot;,pointnum,-1) Else newYnewY = newY * -1 Array.SetValue(&quot;directionY&quot;,pointnum,1) EndIf ' randomize Y axis move amount after hitting wall. Array.SetValue(&quot;moveY&quot;,pointnum,Math.GetRandomNumber(50)+1) 'get randome color when point hits wall GraphicsWindow.PenColor = GraphicsWindow.GetRandomColor() EndIf Array.SetValue(&quot;Y&quot;,pointnum,newY) EndFor EndWhile Program.End() Sub ReadKey key = GraphicsWindow.LastKey If (key = &quot;Escape&quot;) Then repeat = &quot;False&quot; EndIf If (key = &quot;Up&quot;) Then pause = pause + 1 If (pause &gt; 200) Then pause = 200 EndIf EndIf If (key = &quot;Down&quot;) Then pause = pause - 1 If (pause &lt; 0) Then pause = 0 EndIf EndIf GraphicsWindow.Title = &quot;Random Bouncing Points Delay = &quot;+pause+&quot; milliseconds&quot; EndSub </pre></div>Fri, 12 Dec 2008 07:31:51 Z2008-12-12T07:31:51Zhttp://social.msdn.microsoft.com/Forums/en-US/smallbasic/thread/eaacf826-9d12-4e3c-aa10-1b2788f160a6#19239179-ccb2-4405-95ee-acc8b939965ahttp://social.msdn.microsoft.com/Forums/en-US/smallbasic/thread/eaacf826-9d12-4e3c-aa10-1b2788f160a6#19239179-ccb2-4405-95ee-acc8b939965aPath_drchttp://social.msdn.microsoft.com/Profile/en-US/?user=Path_drcPost your sample source code here and get featured on our blogs! Thanks Vijaye, I didn't get back to make the corrections myself.<br>Lots of stuff going on with Christmas so close.<br><br>Christmas.... hmmmmm...<br>How about an unoffical Christmas tree contest?  :D<br><br>Maybe I could get my random color lines to bounce around in the shape of a tree?<br>Nah - too redundant.  lol<br>Mon, 15 Dec 2008 16:09:23 Z2008-12-15T19:46:50Zhttp://social.msdn.microsoft.com/Forums/en-US/smallbasic/thread/eaacf826-9d12-4e3c-aa10-1b2788f160a6#dc49ddee-380c-494b-9e3b-b10f307b9cbahttp://social.msdn.microsoft.com/Forums/en-US/smallbasic/thread/eaacf826-9d12-4e3c-aa10-1b2788f160a6#dc49ddee-380c-494b-9e3b-b10f307b9cbaSteven Donhttp://social.msdn.microsoft.com/Profile/en-US/?user=Steven%20DonPost your sample source code here and get featured on our blogs!Although a Mandelbrot drawing program was already posted, I figured I'd submit mine as well. It makes use of the new GraphicsWindow.GetColorFromRGB method in Small Basic 0.2 (and let me discover a bug in that as well: it seems to have errors in calculating the colour components so that 255 is counted as 0 [probably through a rounding error that results in 256]).<br> <br> <div style="overflow:auto;background-color:white;line-height:100% ! important;font-family:courier new;font-size:11px"> <table style="border-width:0px;margin:2px 0px;width:99%;border-collapse:collapse;background-color:rgb(255, 255, 255)" cellpadding=0 cellspacing=0> <col style="font-family:courier new;font-size:11px;padding-left:10px;white-space:nowrap"> <tbody> <tr> <td><font style="font-size:11px"></font><font style="color:green">' MANDELBROT.SB - Coded in 2008 by Steven Don - http://www.shdon.com</font><font style="font-size:11px"> </font></td> </tr> <tr> <td style="background-color:rgb(247, 247, 247)"><font style="color:green">'</font><font style="font-size:11px"> </font></td> </tr> <tr> <td><font style="color:green">' This small demonstration draws a picture of the Mandelbrot set according to</font><font style="font-size:11px"> </font></td> </tr> <tr> <td style="background-color:rgb(247, 247, 247)"><font style="color:green">' the Escape Time Algorithm. While an in-depth discussion of complex and</font><font style="font-size:11px"> </font></td> </tr> <tr> <td><font style="color:green">' imaginary functions is beyond the scope of a sample program (for more</font><font style="font-size:11px"> </font></td> </tr> <tr> <td style="background-color:rgb(247, 247, 247)"><font style="color:green">' information, please refer to Wikipedia's article on the Mandelbrot set:</font><font style="font-size:11px"> </font></td> </tr> <tr> <td><font style="color:green">' http://en.wikipedia.org/wiki/Mandelbrot_set</font><font style="font-size:11px"> </font></td> </tr> <tr> <td style="background-color:rgb(247, 247, 247)"><font style="color:green">'</font><font style="font-size:11px"> </font></td> </tr> <tr> <td><font style="color:green">' This program demonstrates the use of simple for-loops, arrays and building a</font><font style="font-size:11px"> </font></td> </tr> <tr> <td style="background-color:rgb(247, 247, 247)"><font style="color:green">' picture by plotting individual pixels.</font><font style="font-size:11px"> </font></td> </tr> <tr> <td> </td> </tr> <tr> <td style="background-color:rgb(247, 247, 247)"><font style="color:green">'How many times to apply the Mandelbrot polynomial. The higher this number, the more accurate (and slower) the results</font><font style="font-size:11px"> </font></td> </tr> <tr> <td>max_iteration = 50 </td> </tr> <tr> <td style="background-color:rgb(247, 247, 247)"> </td> </tr> <tr> <td><font style="color:green">'Get the dimensions of the graphics viewport</font><font style="font-size:11px"> </font></td> </tr> <tr> <td style="background-color:rgb(247, 247, 247)">width = GraphicsWindow.Width </td> </tr> <tr> <td>height = GraphicsWindow.Height </td> </tr> <tr> <td style="background-color:rgb(247, 247, 247)"><font style="color:green">'Dividing those dimensions gets the coordinates of the center of the viewport</font><font style="font-size:11px"> </font></td> </tr> <tr> <td>half_width = width / 2 </td> </tr> <tr> <td style="background-color:rgb(247, 247, 247)">half_height = height / 2 </td> </tr> <tr> <td> </td> </tr> <tr> <td style="background-color:rgb(247, 247, 247)"><font style="color:green">'Set up a gradient of colours</font><font style="font-size:11px"> </font></td> </tr> <tr> <td><font style="color:blue">For</font><font style="font-size:11px"> i = 0 </font><font style="color:blue">To</font><font style="font-size:11px"> max_iteration </font></td> </tr> <tr> <td style="background-color:rgb(247, 247, 247)">   </td> </tr> <tr> <td>  <font style="color:green">'How far into the loop are we?</font><font style="font-size:11px"> </font></td> </tr> <tr> <td style="background-color:rgb(247, 247, 247)">  fraction = i / max_iteration </td> </tr> <tr> <td>   </td> </tr> <tr> <td style="background-color:rgb(247, 247, 247)">  <font style="color:green">'Calculate colour components based on that - play around with these to get different colour schemes</font><font style="font-size:11px"> </font></td> </tr> <tr> <td>  red = Math.Min (fraction * 8, 1) </td> </tr> <tr> <td style="background-color:rgb(247, 247, 247)">  green = Math.Max (0, Math.Min ((fraction * 4) - 0.5, 1)) </td> </tr> <tr> <td>  blue = Math.Min (fraction, 1) </td> </tr> <tr> <td style="background-color:rgb(247, 247, 247)">   </td> </tr> <tr> <td>  <font style="color:green">'Combine them into a colour - the components should actually be multiplied by 255 rather than 254, but there is a bug in Small Basic</font><font style="font-size:11px"> </font></td> </tr> <tr> <td style="background-color:rgb(247, 247, 247)">  rgb = GraphicsWindow.GetColorFromRGB (red * 254, green * 254, blue * 254) </td> </tr> <tr> <td>   </td> </tr> <tr> <td style="background-color:rgb(247, 247, 247)">  <font style="color:green">'Store it for later reference</font><font style="font-size:11px"> </font></td> </tr> <tr> <td>  Array.SetValue (<font style="color:blue">&quot;colours&quot;</font><font style="font-size:11px">, i, rgb) </font></td> </tr> <tr> <td style="background-color:rgb(247, 247, 247)">EndFor </td> </tr> <tr> <td> </td> </tr> <tr> <td style="background-color:rgb(247, 247, 247)"><font style="color:green">'Last colour (for points belonging to the actual Mandelbrot set) is black</font><font style="font-size:11px"> </font></td> </tr> <tr> <td>Array.SetValue (<font style="color:blue">&quot;colours&quot;</font><font style="font-size:11px">, max_iteration, </font><font style="color:blue">&quot;black&quot;</font><font style="font-size:11px">) </font></td> </tr> <tr> <td style="background-color:rgb(247, 247, 247)"> </td> </tr> <tr> <td><font style="color:green">'Open the graphics display</font><font style="font-size:11px"> </font></td> </tr> <tr> <td style="background-color:rgb(247, 247, 247)">GraphicsWindow.Show () </td> </tr> <tr> <td> </td> </tr> <tr> <td style="background-color:rgb(247, 247, 247)"><font style="color:green">'Handle all pixels</font><font style="font-size:11px"> </font></td> </tr> <tr> <td><font style="color:blue">For</font><font style="font-size:11px"> y_pixel = 0 </font><font style="color:blue">To</font><font style="font-size:11px"> height </font></td> </tr> <tr> <td style="background-color:rgb(247, 247, 247)">   </td> </tr> <tr> <td>  <font style="color:green">'Get fractional vertical coordinate</font><font style="font-size:11px"> </font></td> </tr> <tr> <td style="background-color:rgb(247, 247, 247)">  y_fractional = (y_pixel / half_height) - 1 </td> </tr> <tr> <td>  <font style="color:blue">For</font><font style="font-size:11px"> x_pixel = 0 </font><font style="color:blue">To</font><font style="font-size:11px"> width </font></td> </tr> <tr> <td style="background-color:rgb(247, 247, 247)">     </td> </tr> <tr> <td>    <font style="color:green">'Get fractional horizontal coordinate</font><font style="font-size:11px"> </font></td> </tr> <tr> <td style="background-color:rgb(247, 247, 247)">    x_fractional = (x_pixel / half_width) - 1.5 </td> </tr> <tr> <td>     </td> </tr> <tr> <td style="background-color:rgb(247, 247, 247)">    <font style="color:green">'These for the components (real and imaginary parts) of a complex number</font><font style="font-size:11px"> </font></td> </tr> <tr> <td>    real = x_fractional </td> </tr> <tr> <td style="background-color:rgb(247, 247, 247)">    imaginary = y_fractional </td> </tr> <tr> <td>     </td> </tr> <tr> <td style="background-color:rgb(247, 247, 247)">    <font style="color:green">'Repeatedly apply the Mandelbrot polynomial, with a maximum of &quot;max_iteration&quot; steps</font><font style="font-size:11px"> </font></td> </tr> <tr> <td>    iteration = 0 </td> </tr> <tr> <td style="background-color:rgb(247, 247, 247)">    <font style="color:blue">While</font><font style="font-size:11px"> (real*real+imaginary*imaginary&lt;=4 </font><font style="color:blue">And</font><font style="font-size:11px"> iteration&lt;max_iteration) </font></td> </tr> <tr> <td>       </td> </tr> <tr> <td style="background-color:rgb(247, 247, 247)">      <font style="color:green">'Generate a new real component (square of real component is positive, square of imaginary component is negative so subtract it, add in the original real part)</font><font style="font-size:11px"> </font></td> </tr> <tr> <td>      real_new = real*real - imaginary*imaginary + x_fractional </td> </tr> <tr> <td style="background-color:rgb(247, 247, 247)">       </td> </tr> <tr> <td>      <font style="color:green">'Generate a new imaginary component and use it</font><font style="font-size:11px"> </font></td> </tr> <tr> <td style="background-color:rgb(247, 247, 247)">      imaginary = 2*real*imaginary + y_fractional </td> </tr> <tr> <td>       </td> </tr> <tr> <td style="background-color:rgb(247, 247, 247)">      <font style="color:green">'Use that new real component</font><font style="font-size:11px"> </font></td> </tr> <tr> <td>      real = real_new </td> </tr> <tr> <td style="background-color:rgb(247, 247, 247)">       </td> </tr> <tr> <td>      <font style="color:green">'Count as another step</font><font style="font-size:11px"> </font></td> </tr> <tr> <td style="background-color:rgb(247, 247, 247)">      iteration = iteration + 1 </td> </tr> <tr> <td>    EndWhile </td> </tr> <tr> <td style="background-color:rgb(247, 247, 247)">     </td> </tr> <tr> <td>    <font style="color:green">'Draw the pixel based on the number of iterations</font><font style="font-size:11px"> </font></td> </tr> <tr> <td style="background-color:rgb(247, 247, 247)">    GraphicsWindow.SetPixel (x_pixel, y_pixel, Array.GetValue (<font style="color:blue">&quot;colours&quot;</font><font style="font-size:11px">, iteration)) </font></td> </tr> <tr> <td>  EndFor </td> </tr> <tr> <td style="background-color:rgb(247, 247, 247)">EndFor </td> </tr> <tr> <td> </td> </tr> <tr> <td style="background-color:rgb(247, 247, 247)"><font style="color:green">'By the time we get here, a long time may have passed - play a sound to let the user know it's done</font><font style="font-size:11px"> </font></td> </tr> <tr> <td>Sound.PlayChime ()<br> </td> </tr> </tbody> </table> </div> <br> I hope somebody finds it amusing. At the very least, it'll be a pretty picture.<br> <br> <br> Fri, 19 Dec 2008 23:33:17 Z2008-12-19T23:33:17Zhttp://social.msdn.microsoft.com/Forums/en-US/smallbasic/thread/eaacf826-9d12-4e3c-aa10-1b2788f160a6#46d73fc8-e6c1-4299-9dd0-8a77a5928c23http://social.msdn.microsoft.com/Forums/en-US/smallbasic/thread/eaacf826-9d12-4e3c-aa10-1b2788f160a6#46d73fc8-e6c1-4299-9dd0-8a77a5928c23Vijaye Rajihttp://social.msdn.microsoft.com/Profile/en-US/?user=Vijaye%20RajiPost your sample source code here and get featured on our blogs! Screenshot of the Mandelbrot program by Steven.  Using max_iteration = 500.<br> <br> This one took about an hour to complete.<br> <br> <img alt="" src="http://smallbasic.com/drop/mandelbrot.png"> Sat, 20 Dec 2008 01:11:47 Z2008-12-20T01:13:34Zhttp://social.msdn.microsoft.com/Forums/en-US/smallbasic/thread/eaacf826-9d12-4e3c-aa10-1b2788f160a6#a80a3d4b-d127-417c-8103-38b1479bb84dhttp://social.msdn.microsoft.com/Forums/en-US/smallbasic/thread/eaacf826-9d12-4e3c-aa10-1b2788f160a6#a80a3d4b-d127-417c-8103-38b1479bb84dDink87522http://social.msdn.microsoft.com/Profile/en-US/?user=Dink87522Post your sample source code here and get featured on our blogs!The Mandelbrot program is awesome Steven.  Sat, 20 Dec 2008 14:00:06 Z2008-12-20T14:00:06Zhttp://social.msdn.microsoft.com/Forums/en-US/smallbasic/thread/eaacf826-9d12-4e3c-aa10-1b2788f160a6#825cdcea-3f4f-448a-a726-c5ba0daffd26http://social.msdn.microsoft.com/Forums/en-US/smallbasic/thread/eaacf826-9d12-4e3c-aa10-1b2788f160a6#825cdcea-3f4f-448a-a726-c5ba0daffd26W. Kevin Hazzardhttp://social.msdn.microsoft.com/Profile/en-US/?user=W.%20Kevin%20HazzardPost your sample source code here and get featured on our blogs!<font><div style="overflow:auto;background-color:white;border:solid 1px #7f9db9;width:;height:;line-height:100% !important;font-family:Courier New;font-size:11px"><table cellpadding=0 cellspacing=0 style="width:99%;margin:2px 0px 2px 0px;border-collapse:collapse;border-bottom:2px solid #eee;background-color:#fff;border-width:0px"><col style="font-family:Courier New;font-size:11px;padding-left:10px;border-bottom:1px solid #F7F7F7;white-space:nowrap"><tbody><tr><td><font style="font-size:11px">GraphicsWindow.Title = </font><font style="color:blue">&quot;David's Rose&quot;</font><font style="font-size:11px"> </font></td></tr><tr><td style="background-color:#F7F7F7">DrawRose() </td></tr><tr><td> </td></tr><tr><td style="background-color:#F7F7F7"><font style="color:blue">Sub</font><font style="font-size:11px"> DrawRose </font></td></tr><tr><td></td></tr><tr><td style="background-color:#F7F7F7">  GraphicsWindow.BrushColor = <font style="color:blue">&quot;Black&quot;</font><font style="font-size:11px"> </font></td></tr><tr><td>  GraphicsWindow.FillRectangle(0, 0, GraphicsWindow.Width, GraphicsWindow.Height) </td></tr><tr><td style="background-color:#F7F7F7">  GraphicsWindow.PenWidth = 2 </td></tr><tr><td>  GraphicsWindow.PenColor = <font style="color:blue">&quot;Crimson&quot;</font><font style="font-size:11px"> </font></td></tr><tr><td style="background-color:#F7F7F7">  Turtle.Speed = 9 </td></tr><tr><td>  Turtle.Show() </td></tr><tr><td style="background-color:#F7F7F7">  <font style="color:blue">For</font><font style="font-size:11px"> sideLength = 1 </font><font style="color:blue">To</font><font style="font-size:11px"> 250 </font></td></tr><tr><td>    Turtle.Move(sideLength) </td></tr><tr><td style="background-color:#F7F7F7">    Turtle.Turn(89) </td></tr><tr><td>  EndFor </td></tr><tr><td style="background-color:#F7F7F7">  GraphicsWindow.PenColor = <font style="color:blue">&quot;DarkRed&quot;</font><font style="font-size:11px"> </font></td></tr><tr><td>  <font style="color:blue">For</font><font style="font-size:11px"> sideLength = 0 </font><font style="color:blue">To</font><font style="font-size:11px"> 249 </font></td></tr><tr><td style="background-color:#F7F7F7">    Turtle.Move(250 - sideLength) </td></tr><tr><td>    Turtle.Turn(89) </td></tr><tr><td style="background-color:#F7F7F7">  EndFor </td></tr><tr><td></td></tr><tr><td style="background-color:#F7F7F7">  Turtle.Hide() </td></tr><tr><td>EndSub</td></tr></tbody></table></div></font><div><br></div><div>Here's a rose that my son drew for his mom.</div>Sat, 20 Dec 2008 15:29:38 Z2008-12-20T15:34:39Zhttp://social.msdn.microsoft.com/Forums/en-US/smallbasic/thread/eaacf826-9d12-4e3c-aa10-1b2788f160a6#ade0ff20-81f4-44dd-ac41-61566bba35e2http://social.msdn.microsoft.com/Forums/en-US/smallbasic/thread/eaacf826-9d12-4e3c-aa10-1b2788f160a6#ade0ff20-81f4-44dd-ac41-61566bba35e2Vijaye Rajihttp://social.msdn.microsoft.com/Profile/en-US/?user=Vijaye%20RajiPost your sample source code here and get featured on our blogs! Very pretty Kevin.  Here's the screenshot of David's Rose.<br><br><img src="http://smallbasic.com/drop/turtle_rose.jpg">Sat, 20 Dec 2008 20:18:07 Z2008-12-20T20:18:07Zhttp://social.msdn.microsoft.com/Forums/en-US/smallbasic/thread/eaacf826-9d12-4e3c-aa10-1b2788f160a6#16b039af-6871-40a3-9342-76158c3342a6http://social.msdn.microsoft.com/Forums/en-US/smallbasic/thread/eaacf826-9d12-4e3c-aa10-1b2788f160a6#16b039af-6871-40a3-9342-76158c3342a6Dink87522http://social.msdn.microsoft.com/Profile/en-US/?user=Dink87522Post your sample source code here and get featured on our blogs!The rose program crashes my SB.  Sat, 20 Dec 2008 23:27:46 Z2008-12-20T23:27:46Zhttp://social.msdn.microsoft.com/Forums/en-US/smallbasic/thread/eaacf826-9d12-4e3c-aa10-1b2788f160a6#e1507c8e-c596-4c7d-b7ac-9ff3e79937eahttp://social.msdn.microsoft.com/Forums/en-US/smallbasic/thread/eaacf826-9d12-4e3c-aa10-1b2788f160a6#e1507c8e-c596-4c7d-b7ac-9ff3e79937eaTekgnohttp://social.msdn.microsoft.com/Profile/en-US/?user=TekgnoPost your sample source code here and get featured on our blogs!Neat code Steven, mandelbrot sets are usually the first thing I play with in a new language.  Something you may like to try to speed things up a bit is to precalculate the squares for real and imaginary to save calculating them twice each loop.  Another thing (which wont be much use if you decide to add a zoom feature) is to take advantage of the symmetry about the y-axis. Mon, 22 Dec 2008 03:32:12 Z2008-12-22T03:32:12Zhttp://social.msdn.microsoft.com/Forums/en-US/smallbasic/thread/eaacf826-9d12-4e3c-aa10-1b2788f160a6#6fbca3eb-d728-49ee-9eeb-b42cb6abc487http://social.msdn.microsoft.com/Forums/en-US/smallbasic/thread/eaacf826-9d12-4e3c-aa10-1b2788f160a6#6fbca3eb-d728-49ee-9eeb-b42cb6abc487Kenny Kasajianhttp://social.msdn.microsoft.com/Profile/en-US/?user=Kenny%20KasajianPost your sample source code here and get featured on our blogs!<div style="border-right:#7f9db9 1px solid;border-top:#7f9db9 1px solid;font-size:11px;overflow:auto;border-left:#7f9db9 1px solid;line-height:100%! important;border-bottom:#7f9db9 1px solid;font-family:courier new;background-color:white"> <table style="border-top-width:0px;border-left-width:0px;margin:2px 0px;width:99%;border-bottom:#eee 0px solid;border-collapse:collapse;background-color:#fff;border-right-width:0px" cellspacing=0 cellpadding=0> <colgroup> <col style="padding-left:10px;font-size:11px;border-bottom:#f7f7f7 1px solid;font-family:courier new;white-space:nowrap"></colgroup> <tbody> <tr> <td><font style="font-size:11px">'Spiral  </font></td></tr> <tr> <td style="background-color:#f7f7f7"> </td></tr> <tr> <td>Radius = 200  </td></tr> <tr> <td style="background-color:#f7f7f7">RadiusStep = .2  </td></tr> <tr> <td> </td></tr> <tr> <td style="background-color:#f7f7f7">Angle = 0  </td></tr> <tr> <td>x1 = 320 + Math.Sin(Angle) * Radius  </td></tr> <tr> <td style="background-color:#f7f7f7">y1 = 220 + Math.Cos(Angle) * Radius  </td></tr> <tr> <td>While Radius &gt; 0  </td></tr> <tr> <td style="background-color:#f7f7f7"> </td></tr> <tr> <td>  x = 320 + Math.Sin(Angle) * Radius  </td></tr> <tr> <td style="background-color:#f7f7f7">  y = 220 + Math.Cos(Angle) * Radius     </td></tr> <tr> <td>  Angle = Angle + .1  </td></tr> <tr> <td style="background-color:#f7f7f7">  GraphicsWindow.DrawLine(x,y,x1,y1)  </td></tr> <tr> <td>    </td></tr> <tr> <td style="background-color:#f7f7f7">  x1 = x  </td></tr> <tr> <td>  y1 = y  </td></tr> <tr> <td style="background-color:#f7f7f7">    </td></tr> <tr> <td>  Radius = Radius - RadiusStep  </td></tr> <tr> <td style="background-color:#f7f7f7">  RadiusStep = RadiusStep - .0001  </td></tr> <tr> <td>    </td></tr> <tr> <td style="background-color:#f7f7f7">EndWhile  </td></tr> <tr> <td>  </td></tr></tbody></table></div><br><a href="http://tinypic.com"><img alt="Image and video hosting by TinyPic" src="http://i41.tinypic.com/25s9yyw.jpg" border=0></a> Mon, 22 Dec 2008 17:44:40 Z2008-12-24T23:50:48Zhttp://social.msdn.microsoft.com/Forums/en-US/smallbasic/thread/eaacf826-9d12-4e3c-aa10-1b2788f160a6#ba40b185-a030-4f8a-947c-67c590322ae8http://social.msdn.microsoft.com/Forums/en-US/smallbasic/thread/eaacf826-9d12-4e3c-aa10-1b2788f160a6#ba40b185-a030-4f8a-947c-67c590322ae8Kenny Kasajianhttp://social.msdn.microsoft.com/Profile/en-US/?user=Kenny%20KasajianPost your sample source code here and get featured on our blogs!I probably wrote this the first time about 20 years ago.  It's simple enough where I remembered most it from memory.<br><br> <p> </p> <div style="border-right:#7f9db9 1px solid;border-top:#7f9db9 1px solid;font-size:11px;overflow:auto;border-left:#7f9db9 1px solid;line-height:100%! important;border-bottom:#7f9db9 1px solid;font-family:Courier New;background-color:white"> <table style="border-top-width:0px;border-left-width:0px;margin:2px 0px;width:99%;border-bottom:#eee 0px solid;border-collapse:collapse;background-color:#fff;border-right-width:0px" cellspacing=0 cellpadding=0> <colgroup> <col style="padding-left:10px;font-size:11px;border-bottom:#f7f7f7 1px solid;font-family:Courier New;white-space:nowrap"> <tbody> <tr> <td><font style="font-size:11px"> </font></td></tr> <tr> <td style="background-color:#f7f7f7">x1 = Math.GetRandomNumber(640)  </td></tr> <tr> <td>y2 = Math.GetRandomNumber(480)  </td></tr> <tr> <td style="background-color:#f7f7f7">h1 = 5  </td></tr> <tr> <td>v1 = 5  </td></tr> <tr> <td style="background-color:#f7f7f7"> </td></tr> <tr> <td>x2 = Math.GetRandomNumber(640)  </td></tr> <tr> <td style="background-color:#f7f7f7">y2 = Math.GetRandomNumber(480)  </td></tr> <tr> <td>h2 = 3  </td></tr> <tr> <td style="background-color:#f7f7f7">v2 = 3  </td></tr> <tr> <td> </td></tr> <tr> <td style="background-color:#f7f7f7">GraphicsWindow.PenWidth = 2  </td></tr> <tr> <td> </td></tr> <tr> <td style="background-color:#f7f7f7">start:  </td></tr> <tr> <td>x1 = x1 + h1  </td></tr> <tr> <td style="background-color:#f7f7f7">y1 = y1 + v1  </td></tr> <tr> <td> </td></tr> <tr> <td style="background-color:#f7f7f7">x2 = x2 + h2  </td></tr> <tr> <td>y2 = y2 + v2  </td></tr> <tr> <td style="background-color:#f7f7f7"> </td></tr> <tr> <td>If x1 &lt; 0 Or x1 &gt; 640 Then  </td></tr> <tr> <td style="background-color:#f7f7f7">  h1 = -h1  </td></tr> <tr> <td>EndIf  </td></tr> <tr> <td style="background-color:#f7f7f7"> </td></tr> <tr> <td>If y1 &lt; 0 Or y1 &gt; 480 Then  </td></tr> <tr> <td style="background-color:#f7f7f7">  v1 = -v1  </td></tr> <tr> <td>EndIf  </td></tr> <tr> <td style="background-color:#f7f7f7"> </td></tr> <tr> <td> </td></tr> <tr> <td style="background-color:#f7f7f7">If x2 &lt; 0 Or x2 &gt; 640 Then  </td></tr> <tr> <td>  h2 = -h2  </td></tr> <tr> <td style="background-color:#f7f7f7">EndIf  </td></tr> <tr> <td> </td></tr> <tr> <td style="background-color:#f7f7f7">If y2 &lt; 0 Or y2 &gt; 480 Then  </td></tr> <tr> <td>  v2 = -v2  </td></tr> <tr> <td style="background-color:#f7f7f7">EndIf  </td></tr> <tr> <td> </td></tr> <tr> <td style="background-color:#f7f7f7"> </td></tr> <tr> <td>GraphicsWindow.PenColor = GraphicsWindow.GetColorFromRGB( Math.GetRandomNumber(255), Math.GetRandomNumber(255), Math.GetRandomNumber(255))  </td></tr> <tr> <td style="background-color:#f7f7f7">GraphicsWindow.DrawLine( x1, y1, y1, y2 )  </td></tr> <tr> <td> </td></tr> <tr> <td style="background-color:#f7f7f7">Goto start </td></tr></tbody></table></div><a href="http://tinypic.com"><br><br><br><br><br><img alt="Image and video hosting by TinyPic" src="http://i39.tinypic.com/cql35.jpg" border=0></a>Wed, 24 Dec 2008 23:48:10 Z2008-12-24T23:48:10Zhttp://social.msdn.microsoft.com/Forums/en-US/smallbasic/thread/eaacf826-9d12-4e3c-aa10-1b2788f160a6#bee86218-a8b3-4356-a596-95328dab6fb6http://social.msdn.microsoft.com/Forums/en-US/smallbasic/thread/eaacf826-9d12-4e3c-aa10-1b2788f160a6#bee86218-a8b3-4356-a596-95328dab6fb6Kenny Kasajianhttp://social.msdn.microsoft.com/Profile/en-US/?user=Kenny%20KasajianPost your sample source code here and get featured on our blogs!<p>I wrote a simple Tetris program in Small Basic:<br><br></p><a href="http://tinypic.com"><img alt="Image and video hosting by TinyPic" src="http://i44.tinypic.com/wsok5v.jpg" border=0></a> <br>Code posted to the wiki: <a href="http://smallbasic.com/smallbasic.com/wiki/Sample Tetris.ashx ">http://smallbasic.com/smallbasic.com/wiki/Sample%20Tetris.ashx </a>Sat, 27 Dec 2008 13:03:21 Z2008-12-27T19:01:24Zhttp://social.msdn.microsoft.com/Forums/en-US/smallbasic/thread/eaacf826-9d12-4e3c-aa10-1b2788f160a6#aee370e3-6cc6-4f86-bcf2-64cdeb6b82afhttp://social.msdn.microsoft.com/Forums/en-US/smallbasic/thread/eaacf826-9d12-4e3c-aa10-1b2788f160a6#aee370e3-6cc6-4f86-bcf2-64cdeb6b82afDink87522http://social.msdn.microsoft.com/Profile/en-US/?user=Dink87522Post your sample source code here and get featured on our blogs!The Tetris game is awesome Kenny and is the best game I've seen made with SB so far.  Mon, 29 Dec 2008 09:41:23 Z2008-12-29T09:41:23Zhttp://social.msdn.microsoft.com/Forums/en-US/smallbasic/thread/eaacf826-9d12-4e3c-aa10-1b2788f160a6#09c4af09-b81e-42f5-87e9-5e6cb17cd7adhttp://social.msdn.microsoft.com/Forums/en-US/smallbasic/thread/eaacf826-9d12-4e3c-aa10-1b2788f160a6#09c4af09-b81e-42f5-87e9-5e6cb17cd7adFremyCompanyhttp://social.msdn.microsoft.com/Profile/en-US/?user=FremyCompanyPost your sample source code here and get featured on our blogs! Here's a calc.exe (based on <a href="http://social.msdn.microsoft.com/Forums/en-US/smallbasic/thread/18d7be0b-b130-4d5f-ad12-d1f233e4b1f5">my extension</a>).<br><br> <div style="border-bottom:#7f9db9 1px solid;border-left:#7f9db9 1px solid;line-height:100% !important;background-color:white;font-family:Courier New;font-size:11px;overflow:auto;border-top:#7f9db9 1px solid;border-right:#7f9db9 1px solid"> <table style="border-bottom:#eee 0px solid;border-right-width:0px;background-color:#fff;margin:2px 0px;width:99%;border-collapse:collapse;border-top-width:0px;border-left-width:0px" cellspacing=0 cellpadding=0> <colgroup> <col style="border-bottom:#f7f7f7 1px solid;padding-left:10px;font-family:Courier New;white-space:nowrap;font-size:11px"> <tbody> <tr> <td><font style="font-size:11px">CurrentText = </font><font style="color:blue">&quot;0&quot;</font><font style="font-size:11px"> </font></td></tr> <tr> <td style="background-color:#f7f7f7">ClearBeforeType = </font><font style="color:blue">&quot;True&quot;</font><font style="font-size:11px"> </font></td></tr> <tr> <td> </td></tr> <tr> <td style="background-color:#f7f7f7">GraphicsWindow.Hide()  </td></tr> <tr> <td>GraphicsWindow.Title=</font><font style="color:blue">&quot;Calculator made in Small Basic&quot;</font><font style="font-size:11px"> </font></td></tr> <tr> <td style="background-color:#f7f7f7">GraphicsWindow.Hide()  </td></tr> <tr> <td>GraphicsWindow.Width=350  </td></tr> <tr> <td style="background-color:#f7f7f7">GraphicsWindow.Height=185  </td></tr> <tr> <td>GraphicsWindow.CanResize=</font><font style="color:blue">&quot;False&quot;</font><font style="font-size:11px"> </font></td></tr> <tr> <td style="background-color:#f7f7f7">GraphicsWindow.BackgroundColor = GraphicsWindow.GetColorFromRGB(240,240,240)  </td></tr> <tr> <td> </td></tr> <tr> <td style="background-color:#f7f7f7">Shapes.LoadTheme(</font><font style="color:blue">&quot;Vista&quot;</font><font style="font-size:11px">)  </font></td></tr> <tr> <td> </td></tr> <tr> <td style="background-color:#f7f7f7">GraphicsWindow.BrushColor=</font><font style="color:blue">&quot;#f9f9f9&quot;</font><font style="font-size:11px"> </font></td></tr> <tr> <td>GraphicsWindow.PenColor=</font><font style="color:blue">&quot;#B2DFF8&quot;</font><font style="font-size:11px"> </font></td></tr> <tr> <td style="background-color:#f7f7f7">GraphicsWindow.PenWidth=1  </td></tr> <tr> <td> </td></tr> <tr> <td style="background-color:#f7f7f7"></font><font style="color:green">' Fausse textbox </font><font style="font-size:11px"> </font></td></tr> <tr> <td>  </font><font style="color:green">'Bordure </font><font style="font-size:11px"> </font></td></tr> <tr> <td style="background-color:#f7f7f7">  Rect1 = Shapes.AddRectangle(336, 25)  </td></tr> <tr> <td>  Shapes.Move(Rect1, 8, 10)  </td></tr> <tr> <td style="background-color:#f7f7f7">    </td></tr> <tr> <td>  </font><font style="color:green">' Label </font><font style="font-size:11px"> </font></td></tr> <tr> <td style="background-color:#f7f7f7">  GraphicsWindow.BrushColor=</font><font style="color:blue">&quot;Black&quot;</font><font style="font-size:11px"> </font></td></tr> <tr> <td>  ResultLabel = Shapes.AddLabel(335, 23, </font><font style="color:blue">&quot;0&quot;</font><font style="font-size:11px">)  </font></td></tr> <tr> <td style="background-color:#f7f7f7">  Shapes.Move(ResultLabel, 11, 11)  </td></tr> <tr> <td> </td></tr> <tr> <td style="background-color:#f7f7f7"></font><font style="color:green">' Autre déco </font><font style="font-size:11px"> </font></td></tr> <tr> <td>GraphicsWindow.BrushColor=</font><font style="color:blue">&quot;#E6F5FD&quot;</font><font style="font-size:11px"> </font></td></tr> <tr> <td style="background-color:#f7f7f7">GraphicsWindow.PenColor=</font><font style="color:blue">&quot;#B2DFF8&quot;</font><font style="font-size:11px"> </font></td></tr> <tr> <td>Rect1 = Shapes.AddRectangle(247, 145)  </td></tr> <tr> <td style="background-color:#f7f7f7">Shapes.Move(Rect1, 8, 34)  </td></tr> <tr> <td> </td></tr> <tr> <td style="background-color:#f7f7f7">GraphicsWindow.BrushColor=</font><font style="color:blue">&quot;White&quot;</font><font style="font-size:11px"> </font></td></tr> <tr> <td>GraphicsWindow.PenColor=</font><font style="color:blue">&quot;#B2DFF8&quot;</font><font style="font-size:11px"> </font></td></tr> <tr> <td style="background-color:#f7f7f7">Rect1 = Shapes.AddRectangle(90, 145)  </td></tr> <tr> <td>Shapes.Move(Rect1, 8+246, 34)  </td></tr> <tr> <td style="background-color:#f7f7f7">    </td></tr> <tr> <td></font><font style="color:green">' Bouttons : </font><font style="font-size:11px"> </font></td></tr> <tr> <td style="background-color:#f7f7f7"></font><font style="color:green">' - Chiffres </font><font style="font-size:11px"> </font></td></tr> <tr> <td></font><font style="color:blue">For</font><font style="font-size:11px"> V = 0 </font><font style="color:blue">To</font><font style="font-size:11px"> 9  </font></td></tr> <tr> <td style="background-color:#f7f7f7">  CurrentCol = 2-Math.Remainder((9-V), 3)  </td></tr> <tr> <td>  CurrentRow = Math.Floor((9-V)/3)  </td></tr> <tr> <td style="background-color:#f7f7f7">  CurrentWidth = 75  </td></tr> <tr> <td>  </font><font style="color:blue">If</font><font style="font-size:11px"> V=0 </font><font style="color:blue">Then</font><font style="font-size:11px"> </font></td></tr> <tr> <td style="background-color:#f7f7f7">    CurrentWidth = 321-(2*82)  </td></tr> <tr> <td>    CurrentCol = 0  </td></tr> <tr> <td style="background-color:#f7f7f7">  EndIf  </td></tr> <tr> <td>  CurrentButton = Shapes.AddButton(CurrentWidth, 30, V)  </td></tr> <tr> <td style="background-color:#f7f7f7">  Array.SetValue(</font><font style="color:blue">&quot;Buttons&quot;</font><font style="font-size:11px">, v, CurrentButton)  </font></td></tr> <tr> <td>  Shapes.Move(CurrentButton, 12+82*CurrentCol,40+35*CurrentRow)  </td></tr> <tr> <td style="background-color:#f7f7f7">  Shapes.RegisterMouseUpEvent(CurrentButton, </font><font style="color:blue">&quot;AddToText&quot;</font><font style="font-size:11px">)  </font></td></tr> <tr> <td>EndFor  </td></tr> <tr> <td style="background-color:#f7f7f7"> </td></tr> <tr> <td></font><font style="color:green">' - Point </font><font style="font-size:11px"> </font></td></tr> <tr> <td style="background-color:#f7f7f7">CurrentButton = Shapes.AddButton(75, 30, </font><font style="color:blue">&quot;.&quot;</font><font style="font-size:11px">)  </font></td></tr> <tr> <td>Shapes.Move(CurrentButton, 11+82*2,40+35*3)  </td></tr> <tr> <td style="background-color:#f7f7f7">Shapes.RegisterMouseUpEvent(CurrentButton, </font><font style="color:blue">&quot;AddToText&quot;</font><font style="font-size:11px">)  </font></td></tr> <tr> <td> </td></tr> <tr> <td style="background-color:#f7f7f7"></font><font style="color:green">' - Parenthèses </font><font style="font-size:11px"> </font></td></tr> <tr> <td>CurrentButton = Shapes.AddButton(38, 30, </font><font style="color:blue">&quot;(&quot;</font><font style="font-size:11px">)  </font></td></tr> <tr> <td style="background-color:#f7f7f7">Shapes.Move(CurrentButton, 12+82*3,40+35*0)  </td></tr> <tr> <td>Shapes.RegisterMouseUpEvent(CurrentButton, </font><font style="color:blue">&quot;AddToText&quot;</font><font style="font-size:11px">)  </font></td></tr> <tr> <td style="background-color:#f7f7f7"> </td></tr> <tr> <td>CurrentButton = Shapes.AddButton(38, 30, </font><font style="color:blue">&quot;)&quot;</font><font style="font-size:11px">)  </font></td></tr> <tr> <td style="background-color:#f7f7f7">Shapes.Move(CurrentButton, 55+82*3,40+35*0)  </td></tr> <tr> <td>Shapes.RegisterMouseUpEvent(CurrentButton, </font><font style="color:blue">&quot;AddToText&quot;</font><font style="font-size:11px">)  </font></td></tr> <tr> <td style="background-color:#f7f7f7"> </td></tr> <tr> <td></font><font style="color:green">' - Addition </font><font style="font-size:11px"> </font></td></tr> <tr> <td style="background-color:#f7f7f7">CurrentButton = Shapes.AddButton(38, 30, </font><font style="color:blue">&quot;+&quot;</font><font style="font-size:11px">)  </font></td></tr> <tr> <td>Shapes.Move(CurrentButton, 12+82*3,40+35*1)  </td></tr> <tr> <td style="background-color:#f7f7f7">Shapes.RegisterMouseUpEvent(CurrentButton, </font><font style="color:blue">&quot;AddToText&quot;</font><font style="font-size:11px">)  </font></td></tr> <tr> <td> </td></tr> <tr> <td style="background-color:#f7f7f7">CurrentButton = Shapes.AddButton(38, 30, </font><font style="color:blue">&quot;-&quot;</font><font style="font-size:11px">)  </font></td></tr> <tr> <td>Shapes.Move(CurrentButton, 55+82*3,40+35*1)  </td></tr> <tr> <td style="background-color:#f7f7f7">Shapes.RegisterMouseUpEvent(CurrentButton, </font><font style="color:blue">&quot;AddToText&quot;</font><font style="font-size:11px">)  </font></td></tr> <tr> <td> </td></tr> <tr> <td style="background-color:#f7f7f7"></font><font style="color:green">' - Multiplication </font><font style="font-size:11px"> </font></td></tr> <tr> <td>CurrentButton = Shapes.AddButton(38, 30, </font><font style="color:blue">&quot;*&quot;</font><font style="font-size:11px">)  </font></td></tr> <tr> <td style="background-color:#f7f7f7">Shapes.Move(CurrentButton, 12+82*3,40+35*2)  </td></tr> <tr> <td>Shapes.RegisterMouseUpEvent(CurrentButton, </font><font style="color:blue">&quot;AddToText&quot;</font><font style="font-size:11px">)  </font></td></tr> <tr> <td style="background-color:#f7f7f7"> </td></tr> <tr> <td>CurrentButton = Shapes.AddButton(38, 30, </font><font style="color:blue">&quot;/&quot;</font><font style="font-size:11px">)  </font></td></tr> <tr> <td style="background-color:#f7f7f7">Shapes.Move(CurrentButton, 55+82*3,40+35*2)  </td></tr> <tr> <td>Shapes.RegisterMouseUpEvent(CurrentButton, </font><font style="color:blue">&quot;AddToText&quot;</font><font style="font-size:11px">)  </font></td></tr> <tr> <td style="background-color:#f7f7f7"> </td></tr> <tr> <td></font><font style="color:green">' - Résultat </font><font style="font-size:11px"> </font></td></tr> <tr> <td style="background-color:#f7f7f7">CurrentButton = Shapes.AddButton(38, 30, </font><font style="color:blue">&quot;=&quot;</font><font style="font-size:11px">)  </font></td></tr> <tr> <td>Shapes.Move(CurrentButton, 12+82*3,40+35*3)  </td></tr> <tr> <td style="background-color:#f7f7f7">Shapes.RegisterMouseUpEvent(CurrentButton, </font><font style="color:blue">&quot;GetResult&quot;</font><font style="font-size:11px">)  </font></td></tr> <tr> <td> </td></tr> <tr> <td style="background-color:#f7f7f7">CurrentButton = Shapes.AddButton(38, 30, </font><font style="color:blue">&quot;&lt;==&quot;</font><font style="font-size:11px">)  </font></td></tr> <tr> <td>Shapes.Move(CurrentButton, 55+82*3,40+35*3)  </td></tr> <tr> <td style="background-color:#f7f7f7">Shapes.RegisterMouseUpEvent(CurrentButton, </font><font style="color:blue">&quot;RemoveToText&quot;</font><font style="font-size:11px">)  </font></td></tr> <tr> <td> </td></tr> <tr> <td style="background-color:#f7f7f7"></font><font style="color:green">' Show the window </font><font style="font-size:11px"> </font></td></tr> <tr> <td>GraphicsWindow.Show()  </td></tr> <tr> <td style="background-color:#f7f7f7"> </td></tr> <tr> <td> </td></tr> <tr> <td style="background-color:#f7f7f7"></font><font style="color:blue">Sub</font><font style="font-size:11px"> AddToText  </font></td></tr> <tr> <td>  Src = Shapes.LastEventSource  </td></tr> <tr> <td style="background-color:#f7f7f7">  Src = Shapes.GetText(Src)  </td></tr> <tr> <td>  </font><font style="color:blue">If</font><font style="font-size:11px"> ClearBeforeType=</font><font style="color:blue">&quot;True&quot;</font><font style="font-size:11px"> </font><font style="color:blue">Then</font><font style="font-size:11px"> </font></td></tr> <tr> <td style="background-color:#f7f7f7">    </font><font style="color:blue">If</font><font style="font-size:11px"> Math.Floor(Src)=Src </font><font style="color:blue">Then</font><font style="font-size:11px">   </font></td></tr> <tr> <td>      CurrentText=</font><font style="color:blue">&quot;&quot;</font><font style="font-size:11px"> </font></td></tr> <tr> <td style="background-color:#f7f7f7">    <font color="#3333ff">EndIf</font>   </td></tr> <tr> <td>    ClearBeforeType=</font><font style="color:blue">&quot;False&quot;</font><font style="font-size:11px"> </font></td></tr> <tr> <td style="background-color:#f7f7f7">  <font color="#3333ff">EndIf</font>  </td></tr> <tr> <td>  CurrentText = Text.Append(CurrentText, Src)  </td></tr> <tr> <td style="background-color:#f7f7f7">  Shapes.SetText(ResultLabel, CurrentText)  </td></tr> <tr> <td><font color="#3333ff">EndSub</font>  </td></tr> <tr> <td style="background-color:#f7f7f7"> </td></tr> <tr> <td></font><font style="color:blue">Sub</font><font style="font-size:11px"> RemoveToText  </font></td></tr> <tr> <td style="background-color:#f7f7f7">  </font><font style="color:blue">If</font><font style="font-size:11px"> ClearBeforeType=</font><font style="color:blue">&quot;True&quot;</font><font style="font-size:11px"> </font><font style="color:blue">Then</font><font style="font-size:11px"> </font></td></tr> <tr> <td>    CurrentText=</font><font style="color:blue">&quot;&quot;</font><font style="font-size:11px"> </font></td></tr> <tr> <td style="background-color:#f7f7f7">    ClearBeforeType=</font><font style="color:blue">&quot;False&quot;</font><font style="font-size:11px"> </font></td></tr> <tr> <td>    Shapes.SetText(ResultLabel, CurrentText)  </td></tr> <tr> <td style="background-color:#f7f7f7">  </font><font style="color:blue">Else</font><font style="font-size:11px"> </font></td></tr> <tr> <td>    Len = Text.GetLength(CurrentText)  </td></tr> <tr> <td style="background-color:#f7f7f7">    CurrentText = Text.GetSubText(CurrentText, 0, len-1)  </td></tr> <tr> <td>    Shapes.SetText(ResultLabel, CurrentText)  </td></tr> <tr> <td style="background-color:#f7f7f7">  <font color="#3333ff">EndIf</font>  </td></tr> <tr> <td><font color="#3333ff">EndSub</font>  </td></tr> <tr> <td style="background-color:#f7f7f7"> </td></tr> <tr> <td></font><font style="color:blue">Sub</font><font style="font-size:11px"> GetResult  </font></td></tr> <tr> <td style="background-color:#f7f7f7">  ClearBeforeType=</font><font style="color:blue">&quot;True&quot;</font><font style="font-size:11px"> </font></td></tr> <tr> <td>  </font><font style="color:green">'SmallBasic.Eval(&quot;CurrentText = (&quot; + CurrentText +&quot;)&quot;) </font><font style="font-size:11px"> </font></td></tr> <tr> <td style="background-color:#f7f7f7">  CurrentText = SmallBasic.MathEval(CurrentText)  </td></tr> <tr> <td>  Shapes.SetText(ResultLabel, CurrentText)  </td></tr> <tr> <td style="background-color:#f7f7f7"><font color="#3333ff">EndSub</font> </td></tr></tbody></table></div><a title="" href="http://sctk3w.bay.livefilestore.com/y1pet10_91vMuI9RkeL0qmNO-HfJ2MwExca5ScasmglHAvKhpSGhmDcn36VBoSlKwZOY_D_oBtLdhd-SdH6Y0Upvg/calc.png"><br><img title="" alt="" src="http://sctk3w.bay.livefilestore.com/y1pet10_91vMuI9RkeL0qmNO-HfJ2MwExca42c1JY5CyXwp8V-oYDiKhhIrruSVqgt3N18cw7lYyE7tDYgFndKkvQ/calc.png" width=356 height=211></a><br> <hr class=sig> Fremy VB &amp; C#Sat, 03 Jan 2009 09:44:46 Z2009-01-03T11:05:15Zhttp://social.msdn.microsoft.com/Forums/en-US/smallbasic/thread/eaacf826-9d12-4e3c-aa10-1b2788f160a6#deae678f-2658-4833-8d1b-d7b170b94097http://social.msdn.microsoft.com/Forums/en-US/smallbasic/thread/eaacf826-9d12-4e3c-aa10-1b2788f160a6#deae678f-2658-4833-8d1b-d7b170b94097Vijaye Rajihttp://social.msdn.microsoft.com/Profile/en-US/?user=Vijaye%20RajiPost your sample source code here and get featured on our blogs! Very nice, Francois.  Could you also provide a link to your extension from your post (you can edit your post to add that link).  That way people wouldn't have to go searching for it.Sat, 03 Jan 2009 10:34:17 Z2009-01-03T10:34:17Zhttp://social.msdn.microsoft.com/Forums/en-US/smallbasic/thread/eaacf826-9d12-4e3c-aa10-1b2788f160a6#5f141d32-1ab9-4642-8ead-3ab234e1ff4ahttp://social.msdn.microsoft.com/Forums/en-US/smallbasic/thread/eaacf826-9d12-4e3c-aa10-1b2788f160a6#5f141d32-1ab9-4642-8ead-3ab234e1ff4aDink87522http://social.msdn.microsoft.com/Profile/en-US/?user=Dink87522Post your sample source code here and get featured on our blogs!The calculator looks great Fremy.  Sat, 03 Jan 2009 14:20:56 Z2009-01-03T14:20:56Zhttp://social.msdn.microsoft.com/Forums/en-US/smallbasic/thread/eaacf826-9d12-4e3c-aa10-1b2788f160a6#8b0ed6c5-7aa6-4eaa-8e17-80fafdef6a04http://social.msdn.microsoft.com/Forums/en-US/smallbasic/thread/eaacf826-9d12-4e3c-aa10-1b2788f160a6#8b0ed6c5-7aa6-4eaa-8e17-80fafdef6a04FremyCompanyhttp://social.msdn.microsoft.com/Profile/en-US/?user=FremyCompanyPost your sample source code here and get featured on our blogs!Here's a print screen of a game I'm currently making in Small Basic.<br><br>I think the final release will come with a compass for more ease in the reading of the data written in the top-left.<br><br>I don't post the code at this time, because there isn't any IA at this time, so the only thing you can do is moving around the second boat and firing on it (but you'll not inflige damage to him). When the IA will be clear (it can take several time because I'm back to school), I'll edit this post to include the code and a fresh preview.<br><br>[EDIT: The fault of calculation are due to the fact I was using my fr-fr culture when I took the screenshot, so the calculation is wrong]<br><br><img src="http://sctk3w.bay.livefilestore.com/y1p2ee9aWBVf7m2laY5Ys_bdbK29EBy5CHOJtkS9JpSwX0rcIXd6mz1gWFizf-gpt5-jewTLGBaZNaBquIOhhrvrQ/First Preview.jpg"> <hr class=sig> Fremy VB &amp; C#Mon, 05 Jan 2009 18:08:26 Z2009-01-05T18:12:43Zhttp://social.msdn.microsoft.com/Forums/en-US/smallbasic/thread/eaacf826-9d12-4e3c-aa10-1b2788f160a6#6f5a1511-9927-45a5-aab4-bb9ba5e212e4http://social.msdn.microsoft.com/Forums/en-US/smallbasic/thread/eaacf826-9d12-4e3c-aa10-1b2788f160a6#6f5a1511-9927-45a5-aab4-bb9ba5e212e4Path_drchttp://social.msdn.microsoft.com/Profile/en-US/?user=Path_drcPost your sample source code here and get featured on our blogs! Awesome Tetris game Kenny!<br><br>Your remarks document the code in detail and the game itself plays great.<br><br>I found the random shapes to not be random enough at times.  Like 5 boxes in a row one time and then, as the shapes were reaching the top, I got 7 purple shapes (backwards L or 7 - depends on how you turn it :D) in a row.<br>...or does that happen a lot in the original Tetris games?<br><br>Besides that, and adding sound, this game is just about perfect.<br><br>A great add-on would be to keep high score in a text file.<br>...and even get a little more fancy by asking for a name to go with high score.<br><br>Thanks again Kenny.Tue, 06 Jan 2009 20:12:19 Z2009-01-06T20:12:19Zhttp://social.msdn.microsoft.com/Forums/en-US/smallbasic/thread/eaacf826-9d12-4e3c-aa10-1b2788f160a6#710d8a44-4447-4a8a-83a7-81e4cfe5f14ehttp://social.msdn.microsoft.com/Forums/en-US/smallbasic/thread/eaacf826-9d12-4e3c-aa10-1b2788f160a6#710d8a44-4447-4a8a-83a7-81e4cfe5f14eRasterIRQhttp://social.msdn.microsoft.com/Profile/en-US/?user=RasterIRQPost your sample source code here and get featured on our blogs!<p>&lt;Echoy voice&gt;Turtle in spaaaaaaaaaaaaace!&lt;/Echoy voice&gt;<br><br>This proggie displays a filled circle that's supposed to be a planet, and then has the turtle going around in an orbit around the planet. If you move the mouse left and right over the graphics window, the turtle spins around itself so you can make it face any direction you want. The turtle even has an engine that thrusts him forward, in whatever direction he's facing, as long as you hold the left mouse button down.<br><br><em><strong><font style="font-size:14px">Tips for playing:</font></strong></em><br>To make the turtle fly further out from the planet, make him face the direction of flight, and give him a gentle push with the engine (short press on the left mouse button). Conversely, you can bring him back down by turning the tail end towards the direction of flight, and fire the engines again.<br>Be careful no to go too fast; if the turtle gets beyond what's known as <a title="Read more about escape velocity at Wikipedia" href="http://en.wikipedia.org/wiki/Escape_velocity">escape velocity</a>, he's going to fly away from the planet forever, never to return to the confines of your graphics window.<br><br><em><strong><font style="font-size:14px">Tips for hacking/expanding on this program:</font></strong></em><br>If the turtle is flying too slow or too fast for your taste on your machine, the trick is to change the numbers in <strong>VelX = 0.03</strong> and <strong>Gravity = 0.001</strong> at the beginning of the program. It takes a bit of tries (or nasty, hard-core math) to find the balance between plunging to the ground like a rock, and flying off the graphics window alltogether.<br><br>The whole idea in this program, is that &quot;everything&quot; (at least the position and speed) is split up into two parts; a horizontal (&quot;left/right&quot;) part called the X co-ordinate, and a vertical (&quot;up/down&quot;) part called the Y co-ordinate -- and then every change and every motion is done to both of these parts (notice how a lot of things in the code below come in pairs of &quot;something-X&quot; and &quot;something-Y&quot;).<br><br>As you've probably found out after a bit of playing around with the turtle, you can't &quot;crash&quot; onto the planet's surface; you just &quot;plunge into&quot; inside the planet! The program already computes the distance to the <u>center</u> of the planet (it's in the variable called <em>R</em>), so if this <em>R</em> less than the radius of the planet (which is 100 pixels in my code), we've hit the ground. To make it possible to &quot;crash&quot;, see if you can make it stop (and perhaps play a noise) when that happens.<br><br>Some &quot;flight instruments&quot; would be nice too; e.g. something to tell you how high up above the surface you are. You can work out your height above the now &quot;crash-enabled&quot; planetary surface, as <strong>Height = R - 100</strong> (remember the 100 was the planet's radius, measured in pixels), and display it in a corner somewhere.<br>An by keeping a copy (called, say, <strong>OldHeight</strong>) of the previous value of <strong>Height</strong>, just before a new <strong>Height</strong> is calculated, you can then subtract the <strong>OldHeight</strong> from the <strong>NewHeight</strong> to work out how fast you're ascending or descending.<br>You can also work out your current speed like this: <strong>Speed = Math.SquareRoot(VelX * VelX + VelY * VelY)<br><br></p> <div style="border-right:#7f9db9 1px solid;border-top:#7f9db9 1px solid;font-size:11px;overflow:auto;border-left:#7f9db9 1px solid;line-height:100%! important;border-bottom:#7f9db9 1px solid;font-family:Courier New;background-color:white"> <table style="border-top-width:0px;border-left-width:0px;margin:2px 0px;width:99%;border-bottom:#eee 0px solid;border-collapse:collapse;background-color:#fff;border-right-width:0px" cellspacing=0 cellpadding=0> <colgroup> <col style="padding-left:10px;font-size:11px;border-bottom:#f7f7f7 1px solid;font-family:Courier New;white-space:nowrap"> <tbody> <tr> <td><font style="font-size:11px">VelX = 0.03 </font><font style="color:green">' Set the initial velocity in x and y directions in </font><font style="font-size:11px"> </font></td></tr> <tr> <td style="background-color:#f7f7f7">VelY = 0    </font><font style="color:green">' VelX and VelY </font><font style="font-size:11px"> </font></td></tr> <tr> <td> </td></tr> <tr> <td style="background-color:#f7f7f7">Gravity = 0.001 </font><font style="color:green">' Sets the strength of this planet's gravitational field </font><font style="font-size:11px"> </font></td></tr> <tr> <td> </td></tr> <tr> <td style="background-color:#f7f7f7">GraphicsWindow.BackgroundColor = </font><font style="color:blue">&quot;Black&quot;</font><font style="font-size:11px">  </font><font style="color:green">' Black background </font><font style="font-size:11px"> </font></td></tr> <tr> <td>GraphicsWindow.BrushColor = </font><font style="color:blue">&quot;#2030FF&quot;</font><font style="font-size:11px">   </font><font style="color:green">' Color for the planet </font><font style="font-size:11px"> </font></td></tr> <tr> <td style="background-color:#f7f7f7"> </td></tr> <tr> <td>GraphicsWindow.Width = 600  </font><font style="color:green">' Set the size of the </font><font style="font-size:11px"> </font></td></tr> <tr> <td style="background-color:#f7f7f7">GraphicsWindow.Height = 600 </font><font style="color:green">' graphics window </font><font style="font-size:11px"> </font></td></tr> <tr> <td> </td></tr> <tr> <td style="background-color:#f7f7f7">GraphicsWindow.FillEllipse(200,200,200,200) </font><font style="color:green">' Draw the planet </font><font style="font-size:11px"> </font></td></tr> <tr> <td> </td></tr> <tr> <td style="background-color:#f7f7f7">PosX = 0    </font><font style="color:green">' Set the space-faring turtle's initial position as </font><font style="font-size:11px"> </font></td></tr> <tr> <td>PosY = 130  </font><font style="color:green">' a pair of x and y coordinates in PosX and PosY </font><font style="font-size:11px"> </font></td></tr> <tr> <td style="background-color:#f7f7f7"> </td></tr> <tr> <td>Heading = 0 </font><font style="color:green">' Set the turtle's initial &quot;heading&quot;, or direction </font><font style="font-size:11px"> </font></td></tr> <tr> <td style="background-color:#f7f7f7"> </td></tr> <tr> <td>Turtle.Show() </font><font style="color:green">' Display the turtle &quot;astronaut&quot; </font><font style="font-size:11px"> </font></td></tr> <tr> <td style="background-color:#f7f7f7"> </td></tr> <tr> <td>MainLoop: </font><font style="color:green">' We keep going back to this label, as long as the &quot;flight simulation&quot; runs... </font><font style="font-size:11px"> </font></td></tr> <tr> <td style="background-color:#f7f7f7"> </td></tr> <tr> <td>Heading = Mouse.MouseX  </font><font style="color:green">' Use the left/right position of the mouse cursor to select heading </font><font style="font-size:11px"> </font></td></tr> <tr> <td style="background-color:#f7f7f7"> </td></tr> <tr> <td></font><font style="color:blue">If</font><font style="font-size:11px"> Mouse.IsLeftButtonDown </font><font style="color:blue">Then</font><font style="font-size:11px">  </font><font style="color:green">' If the left mouse button is pressed down, we fire the engine </font><font style="font-size:11px"> </font></td></tr> <tr> <td style="background-color:#f7f7f7">  VelX = VelX + 0.0001 * Math.Sin(Math.GetRadians(Heading)) </font><font style="color:green">' Add a little forward thrust </font><font style="font-size:11px"> </font></td></tr> <tr> <td>  VelY = VelY + 0.0001 * Math.Cos(Math.GetRadians(Heading)) </font><font style="color:green">' in the direction the turtle faces </font><font style="font-size:11px"> </font></td></tr> <tr> <td style="background-color:#f7f7f7">EndIf </font><font style="color:green">' (Ends check on whether the mouse button was pressed in order to fire the engine) </font><font style="font-size:11px"> </font></td></tr> <tr> <td> </td></tr> <tr> <td style="background-color:#f7f7f7">R2 = PosX * PosX + PosY * PosY  </font><font style="color:green">' Get the square of the distance to the planet's center </font><font style="font-size:11px"> </font></td></tr> <tr> <td>GForce = Gravity / R2 </font><font style="color:green">' The force of gravity is inversely proportional to the square of the distance </font><font style="font-size:11px"> </font></td></tr> <tr> <td style="background-color:#f7f7f7">R = Math.SquareRoot(R2) </font><font style="color:green">' Takes the square root to get the distance &quot;itself&quot; </font><font style="font-size:11px"> </font></td></tr> <tr> <td>Ratio = GForce / R  </font><font style="color:green">' Ratio between the force of gravity to excert, and the distance </font><font style="font-size:11px"> </font></td></tr> <tr> <td style="background-color:#f7f7f7">VelX = VelX - Ratio * PosX  </font><font style="color:green">' Now we can calculate the effect that the planet's gravity </font><font style="font-size:11px"> </font></td></tr> <tr> <td>VelY = VelY - Ratio * PosY  </font><font style="color:green">' has on the current velocity, in the x and y directions </font><font style="font-size:11px"> </font></td></tr> <tr> <td style="background-color:#f7f7f7"> </td></tr> <tr> <td>PosX = PosX + VelX  </font><font style="color:green">' Update the current position by adding the speeds in VelX </font><font style="font-size:11px"> </font></td></tr> <tr> <td style="background-color:#f7f7f7">PosY = PosY + VelY  </font><font style="color:green">' and VelY, to the position coordinates in PosX and PosY </font><font style="font-size:11px"> </font></td></tr> <tr> <td> </td></tr> <tr> <td style="background-color:#f7f7f7">Turtle.X = 300 + PosX </font><font style="color:green">' Place the turtle by converting the PosX and PosY coor- </font><font style="font-size:11px"> </font></td></tr> <tr> <td>Turtle.Y = 300 - PosY </font><font style="color:green">' dinates to screen coordinates, centered on the planet </font><font style="font-size:11px"> </font></td></tr> <tr> <td style="background-color:#f7f7f7">Turtle.Angle = Heading  </font><font style="color:green">' Have the turtle face in the direction given in Heading </font><font style="font-size:11px"> </font></td></tr> <tr> <td> </td></tr> <tr> <td style="background-color:#f7f7f7"></font><font style="color:blue">If</font><font style="font-size:11px"> GraphicsWindow.LastKey &lt;&gt; </font><font style="color:blue">&quot;Escape&quot;</font><font style="font-size:11px"> </font><font style="color:blue">Then</font><font style="font-size:11px">  </font><font style="color:green">' So long as the Escape key is *not* pressed </font><font style="font-size:11px"> </font></td></tr> <tr> <td>  Goto MainLoop </font><font style="color:green">' Go back and repeat the whole thing to keep the simulation going. </font><font style="font-size:11px"> </font></td></tr> <tr> <td style="background-color:#f7f7f7">EndIf </font><font style="color:green">' (Ends check on whether the Escape key was pressed or not)</font><font style="font-size:11px"> </font></td></tr></tbody></table></div></strong><hr class="sig">38911 BASIC bytes free...Fri, 16 Jan 2009 08:36:45 Z2009-01-16T08:36:45Zhttp://social.msdn.microsoft.com/Forums/en-US/smallbasic/thread/eaacf826-9d12-4e3c-aa10-1b2788f160a6#a9fd56ce-c17a-479d-9f52-26462ca34e11http://social.msdn.microsoft.com/Forums/en-US/smallbasic/thread/eaacf826-9d12-4e3c-aa10-1b2788f160a6#a9fd56ce-c17a-479d-9f52-26462ca34e11RasterIRQhttp://social.msdn.microsoft.com/Profile/en-US/?user=RasterIRQPost your sample source code here and get featured on our blogs!<span class=postedBy>Kenny Kasajian's dancing lines</span> reminds me of an old game; &quot;Stix&quot; or &quot;Styx&quot; or something like that: While a bunch of &quot;sticks&quot; danced around the screen just like in your program, the player moved something like the turtle in Small Basic around the screen, to &quot;enclose&quot; more and more screen area. If the dancing sticks hit the line as the player was &quot;drawing&quot; it, he/she lost a life. Cover 75(?) percent of the screen, and the game advances to the next level... <hr class=sig> 38911 BASIC bytes free...Fri, 16 Jan 2009 08:42:49 Z2009-01-16T08:44:09Zhttp://social.msdn.microsoft.com/Forums/en-US/smallbasic/thread/eaacf826-9d12-4e3c-aa10-1b2788f160a6#4cbff11e-bb97-456c-8761-1b8d81662a24http://social.msdn.microsoft.com/Forums/en-US/smallbasic/thread/eaacf826-9d12-4e3c-aa10-1b2788f160a6#4cbff11e-bb97-456c-8761-1b8d81662a24Path_drchttp://social.msdn.microsoft.com/Profile/en-US/?user=Path_drcPost your sample source code here and get featured on our blogs! Whoops, hit wrong button to post my program.<br>...so I'll just copy and paste it over here.  :-)<br><br> <p style="margin:0in 0in 10pt"><font face=Calibri>Wow, where do I start?</font></p> <p style="margin:0in 0in 10pt"><font face=Calibri>I have been working on this little project for over a month now (don’t remember exactly when I started), and it has been fun and at times frustrating.</font></p> <p style="margin:0in 0in 10pt"><font face=Calibri>What I am presenting today is a 3D maze program, that  will eventually grow into a RPG in the flavor of the old Wizardy wireframe dungeons.  There are a few shortcomings in this maze;</font></p> <p style="margin:0in 0in 0pt 0.5in"><span><font face=Calibri>1)</font><span style="font:7pt 'Times New Roman'">      </span><font face=Calibri>Doesn’t look for walls beyond a single wide hall (to exclude rooms too).  If you change the mapdata to reflect anything more than single wide corridors, nothing will be drawn.</font></p> <p style="margin:0in 0in 0pt 0.5in"><span><font face=Calibri>2)</font><span style="font:7pt 'Times New Roman'">      </span><font face=Calibri>The maze data is setup in a way where every point of the graph is in the data:  the space you are standing in is x = 2, y = 2 the place for a wall to the east is 3, 2  - you never stand in 3, 2 (you can stand in 4, 2) because the odd numbers are wall place holders.  Not only is this slightly confusing to the casual observer, but makes the coding (to me anyway) much more complex to pull wall data.</font></p> <p style="margin:0in 0in 0pt 0.5in"><span><font face=Calibri>3)</font><span style="font:7pt 'Times New Roman'">      </span><font face=Calibri>When you hit a wall, it plays a cool Windows XP Low Battery .wav file (C:\WINDOWS\Media\Windows XP Battery Low.wav) – problem is it only plays once per game.</font></p> <p style="margin:0in 0in 10pt 0.5in"><span><font face=Calibri>4)</font><span style="font:7pt 'Times New Roman'">      </span><font face=Calibri>A few TODO’s left – to include asking for player’s name, and others shown in remarks within my code.</font></p> <p style="margin:0in 0in 10pt"><font face=Calibri>As I was fixing some small problems, I decided that I want to revamp the data.  The next prgrams's data will be a little more complex than what is in this program, but will make coding a little easier.</font></p> <p style="margin:0in 0in 10pt"><font face=Calibri>Something that amazed me was how I coded the entire maze program before running any part of it and only had a few syntax errors, and most of those were due to copying and pasting code that didn’t have enough paren’s in it.  I also surprised myself, when finding something that didn’t work right (like some of the walls didn’t draw correctly), by knowing exactly where to go and, in some cases, know exactly what I needed to change before I got there.</font></p> <p style="margin:0in 0in 10pt"><font face=Calibri>I am ready to take any suggestions and/or criticism, especially better ways to code.  Maybe I overlooked something or maybe there’s a better way, in Small Basic, to</p> <p style="margin:0in 0in 10pt">perform the same tasks.<br></p> <div style="border-right:#7f9db9 1px solid;border-top:#7f9db9 1px solid;font-size:11px;overflow:auto;border-left:#7f9db9 1px solid;width:857px;line-height:100%! important;border-bottom:#7f9db9 1px solid;font-family:Courier New;height:346px;background-color:white"> <table style="border-top-width:0px;border-left-width:0px;margin:2px 0px;width:99%;border-bottom:#eee 0px solid;border-collapse:collapse;background-color:#fff;border-right-width:0px" cellspacing=0 cellpadding=0> <colgroup> <col style="padding-left:10px;font-size:11px;border-bottom:#f7f7f7 1px solid;font-family:Courier New;white-space:nowrap"> <tbody> <tr> <td><font style="font-size:11px"></font><font style="color:red">'3D Wireframe Maze<br>'by David R. Crutchfield (a.k.a. Pathdrc)<br>'ver: 1.0<br>'Date:1/19/2009<br><br>GraphicsWindow.BackgroundColor</font><font style="font-size:11px">=</font><font style="color:blue">&quot;Black&quot;</font><font style="font-size:11px"> </font></td></tr> <tr> <td style="background-color:#f7f7f7"></font><font style="color:red">GraphicsWindow.Height</font><font style="font-size:11px"> = </font><font style="color:blue">600</font><font style="font-size:11px"> </font></td></tr> <tr> <td></font><font style="color:red">GraphicsWindow.Width</font><font style="font-size:11px"> = </font><font style="color:blue">800</font><font style="font-size:11px"> </font></td></tr> <tr> <td style="background-color:#f7f7f7">GraphicsWindow.Show()  </td></tr> <tr> <td> </td></tr> <tr> <td style="background-color:#f7f7f7"></font><font style="color:red">GraphicsWindow.KeyDown</font><font style="font-size:11px"> = </font><font style="color:blue">ReadKey</font><font style="font-size:11px"> </font></td></tr> <tr> <td> </td></tr> <tr> <td style="background-color:#f7f7f7"> </td></tr> <tr> <td>'Information frame on left  </td></tr> <tr> <td style="background-color:#f7f7f7"></font><font style="color:red">GraphicsWindow.BrushColor</font><font style="font-size:11px"> = </font><font style="color:blue">&quot;Gainsboro&quot;</font><font style="font-size:11px"> </font></td></tr> <tr> <td>GraphicsWindow.FillRectangle(0,0,200,600)  </td></tr> <tr> <td style="background-color:#f7f7f7">    'text in Info Frame  </td></tr> <tr> <td>    </font><font style="color:red">GraphicsWindow.BrushColor</font><font style="font-size:11px"> = </font><font style="color:blue">&quot;Black&quot;</font><font style="font-size:11px"> </font></td></tr> <tr> <td style="background-color:#f7f7f7">    GraphicsWindow.DrawText(48,1,&quot;Adventurer's Name&quot;)  </td></tr> <tr> <td>    GraphicsWindow.DrawText(48,80,&quot;Map Coordinates:&quot;)  </td></tr> <tr> <td style="background-color:#f7f7f7">    GraphicsWindow.DrawText(5,220,&quot;</font><font style="color:red">Forward</font><font style="font-size:11px"> = </font><font style="color:blue">Up</font><font style="font-size:11px"> Arrow&quot;)  </font></td></tr> <tr> <td>    GraphicsWindow.DrawText(5,240,&quot;</font><font style="color:red">Back</font><font style="font-size:11px"> = </font><font style="color:blue">Down</font><font style="font-size:11px"> Arrow&quot;)  </font></td></tr> <tr> <td style="background-color:#f7f7f7">    GraphicsWindow.DrawText(5,260,&quot;Turn </font><font style="color:red">left</font><font style="font-size:11px"> = </font><font style="color:blue">Left</font><font style="font-size:11px"> Arrow&quot;)  </font></td></tr> <tr> <td>    GraphicsWindow.DrawText(5,280,&quot;Turn </font><font style="color:red">right</font><font style="font-size:11px"> = </font><font style="color:blue">Right</font><font style="font-size:11px"> Arrow&quot;)  </font></td></tr> <tr> <td style="background-color:#f7f7f7">    GraphicsWindow.DrawText(5,320,&quot;To start </font><font style="color:red">over</font><font style="font-size:11px"> = </font><font style="color:blue">Back</font><font style="font-size:11px"> Space&quot;)  </font></td></tr> <tr> <td>    GraphicsWindow.DrawText(5,340,&quot;End </font><font style="color:red">program</font><font style="font-size:11px"> = </font><font style="color:blue">Esc</font><font style="font-size:11px">&quot;)  </font></td></tr> <tr> <td style="background-color:#f7f7f7"> </td></tr> <tr> <td>'draw box around Maze-View window on the right  </td></tr> <tr> <td style="background-color:#f7f7f7"> </font><font style="color:red">GraphicsWindow.PenColor</font><font style="font-size:11px"> = </font><font style="color:blue">&quot;White&quot;</font><font style="font-size:11px"> </font></td></tr> <tr> <td> </font><font style="color:red">GraphicsWindow.PenWidth</font><font style="font-size:11px"> = </font><font style="color:blue">4</font><font style="font-size:11px"> </font></td></tr> <tr> <td style="background-color:#f7f7f7"> GraphicsWindow.DrawRectangle(200,0,600,600)  </td></tr> <tr> <td>   </td></tr> <tr> <td style="background-color:#f7f7f7">'Map data  </td></tr> <tr> <td> </td></tr> <tr> <td style="background-color:#f7f7f7">  </font><font style="color:red">MapWidth</font><font style="font-size:11px"> = </font><font style="color:blue">9</font><font style="font-size:11px"> </font></td></tr> <tr> <td>  </font><font style="color:red">MapHeight</font><font style="font-size:11px"> = </font><font style="color:blue">11</font><font style="font-size:11px"> </font></td></tr> <tr> <td style="background-color:#f7f7f7">  </font><font style="color:red">StartX</font><font style="font-size:11px"> = </font><font style="color:blue">4</font><font style="font-size:11px"> </font></td></tr> <tr> <td>  </font><font style="color:red">StartY</font><font style="font-size:11px"> = </font><font style="color:blue">10</font><font style="font-size:11px"> </font></td></tr> <tr> <td style="background-color:#f7f7f7">  </font><font style="color:red">StartFacing</font><font style="font-size:11px"> = </font><font style="color:blue">1</font><font style="font-size:11px"> </font></td></tr> <tr> <td>  Array.SetValue(&quot;mapdata&quot;,1,&quot;000111000000&quot;)  </td></tr> <tr> <td style="background-color:#f7f7f7">  Array.SetValue(&quot;mapdata&quot;,2,&quot;000101000000&quot;)  </td></tr> <tr> <td>  Array.SetValue(&quot;mapdata&quot;,3,&quot;000101111111&quot;)  </td></tr> <tr> <td style="background-color:#f7f7f7">  Array.SetValue(&quot;mapdata&quot;,4,&quot;000101000001&quot;)  </td></tr> <tr> <td>  Array.SetValue(&quot;mapdata&quot;,5,&quot;000101111101&quot;)  </td></tr> <tr> <td style="background-color:#f7f7f7">  Array.SetValue(&quot;mapdata&quot;,6,&quot;000100000001&quot;)  </td></tr> <tr> <td>  Array.SetValue(&quot;mapdata&quot;,7,&quot;011101111111&quot;)  </td></tr> <tr> <td style="background-color:#f7f7f7">  Array.SetValue(&quot;mapdata&quot;,8,&quot;010001000000&quot;)  </td></tr> <tr> <td>  Array.SetValue(&quot;mapdata&quot;,9,&quot;011101000000&quot;)  </td></tr> <tr> <td style="background-color:#f7f7f7">  Array.SetValue(&quot;mapdata&quot;,10,&quot;00010100000&quot;)  </td></tr> <tr> <td>  Array.SetValue(&quot;mapdata&quot;,11,&quot;00011100000&quot;)  </td></tr> <tr> <td style="background-color:#f7f7f7"> </td></tr> <tr> <td>'Setup variables  </td></tr> <tr> <td style="background-color:#f7f7f7"></font><font style="color:red">CurrentX</font><font style="font-size:11px"> = </font><font style="color:blue">StartX</font><font style="font-size:11px"> </font></td></tr> <tr> <td></font><font style="color:red">CurrentY</font><font style="font-size:11px"> = </font><font style="color:blue">StartY</font><font style="font-size:11px"> </font></td></tr> <tr> <td style="background-color:#f7f7f7"></font><font style="color:red">Facing</font><font style="font-size:11px"> = </font><font style="color:blue">StartFacing</font><font style="font-size:11px"> '</font><font style="color:red">1</font><font style="font-size:11px"> = </font><font style="color:blue">north</font><font style="font-size:11px">/up, </font><font style="color:red">2</font><font style="font-size:11px"> = </font><font style="color:blue">east</font><font style="font-size:11px">/right, </font><font style="color:red">3</font><font style="font-size:11px"> = </font><font style="color:blue">south</font><font style="font-size:11px">/down, </font><font style="color:red">4</font><font style="font-size:11px"> = </font><font style="color:blue">west</font><font style="font-size:11px">/left  </font></td></tr> <tr> <td></font><font style="color:red">Main</font><font style="font-size:11px"> = </font><font style="color:blue">&quot;True&quot;</font><font style="font-size:11px"> </font></td></tr> <tr> <td style="background-color:#f7f7f7"> </td></tr> <tr> <td>'Start main program  </td></tr> <tr> <td style="background-color:#f7f7f7">While (Main)  </td></tr> <tr> <td>  DrawWalls()  </td></tr> <tr> <td style="background-color:#f7f7f7">  DisplayCurrentXY() 'show coordinates in information frame.  </td></tr> <tr> <td>    </font><font style="color:red">loop</font><font style="font-size:11px"> = </font><font style="color:blue">&quot;True&quot;</font><font style="font-size:11px"> </font></td></tr> <tr> <td style="background-color:#f7f7f7">    </font><font style="color:red">keyisupdated</font><font style="font-size:11px"> = </font><font style="color:blue">&quot;False&quot;</font><font style="font-size:11px"> </font></td></tr> <tr> <td>  WaitForKeyDownAndProcess()  </td></tr> <tr> <td style="background-color:#f7f7f7">EndWhile  </td></tr> <tr> <td> </td></tr> <tr> <td style="background-color:#f7f7f7">Program.End()  </td></tr> <tr> <td> </td></tr> <tr> <td style="background-color:#f7f7f7"> </td></tr> <tr> <td>Sub WaitForKeyDownAndProcess  </td></tr> <tr> <td style="background-color:#f7f7f7">  While (loop)  </td></tr> <tr> <td>    If (</font><font style="color:red">keyisupdated</font><font style="font-size:11px"> = </font><font style="color:blue">&quot;True&quot;</font><font style="font-size:11px">) Then  </font></td></tr> <tr> <td style="background-color:#f7f7f7">      If (</font><font style="color:red">key</font><font style="font-size:11px"> = </font><font style="color:blue">&quot;Up&quot;</font><font style="font-size:11px">) Then  </font></td></tr> <tr> <td>        'test if wall is blocking forward movement  </td></tr> <tr> <td style="background-color:#f7f7f7">        If </font><font style="color:red">NoForward</font><font style="font-size:11px"> = </font><font style="color:blue">&quot;True&quot;</font><font style="font-size:11px"> Then  </font></td></tr> <tr> <td>          HitWall()  </td></tr> <tr> <td style="background-color:#f7f7f7">          </font><font style="color:red">keyisupdated</font><font style="font-size:11px"> = </font><font style="color:blue">&quot;False&quot;</font><font style="font-size:11px"> </font></td></tr> <tr> <td>        Else  </td></tr> <tr> <td style="background-color:#f7f7f7">          </font><font style="color:red">loop</font><font style="font-size:11px"> = </font><font style="color:blue">&quot;False&quot;</font><font style="font-size:11px"> </font></td></tr> <tr> <td>          'find facing and update current position based on forward movement.  </td></tr> <tr> <td style="background-color:#f7f7f7">          If </font><font style="color:red">Facing</font><font style="font-size:11px"> = </font><font style="color:blue">1</font><font style="font-size:11px"> Then  </font></td></tr> <tr> <td>            </font><font style="color:red">CurrentY</font><font style="font-size:11px"></font><font style="color:blue">CurrentY</font><font style="font-size:11px"> = CurrentY - 2  </font></td></tr> <tr> <td style="background-color:#f7f7f7">          ElseIf </font><font style="color:red">Facing</font><font style="font-size:11px"> = </font><font style="color:blue">2</font><font style="font-size:11px"> Then  </font></td></tr> <tr> <td>            </font><font style="color:red">CurrentX</font><font style="font-size:11px"></font><font style="color:blue">CurrentX</font><font style="font-size:11px"> = CurrentX + 2  </font></td></tr> <tr> <td style="background-color:#f7f7f7">          ElseIf </font><font style="color:red">Facing</font><font style="font-size:11px"> = </font><font style="color:blue">3</font><font style="font-size:11px"> Then  </font></td></tr> <tr> <td>            </font><font style="color:red">CurrentY</font><font style="font-size:11px"></font><font style="color:blue">CurrentY</font><font style="font-size:11px"> = CurrentY + 2  </font></td></tr> <tr> <td style="background-color:#f7f7f7">          ElseIf </font><font style="color:red">Facing</font><font style="font-size:11px"> = </font><font style="color:blue">4</font><font style="font-size:11px"> Then  </font></td></tr> <tr> <td>            </font><font style="color:red">CurrentX</font><font style="font-size:11px"></font><font style="color:blue">CurrentX</font><font style="font-size:11px"> = CurrentX - 2  </font></td></tr> <tr> <td style="background-color:#f7f7f7">          EndIf  </td></tr> <tr> <td>        EndIf  </td></tr> <tr> <td style="background-color:#f7f7f7">      EndIf  </td></tr> <tr> <td>        </td></tr> <tr> <td style="background-color:#f7f7f7">      '[TODO] code for </font><font style="color:red">key</font><font style="font-size:11px"> = </font><font style="color:blue">BackSpace</font><font style="font-size:11px"> (restart position at beginging of maze)  </font></td></tr> <tr> <td>        </td></tr> <tr> <td style="background-color:#f7f7f7">      If </font><font style="color:red">key</font><font style="font-size:11px"> = </font><font style="color:blue">&quot;Left&quot;</font><font style="font-size:11px"> Then  </font></td></tr> <tr> <td>        </font><font style="color:red">NoForward</font><font style="font-size:11px"> = </font><font style="color:blue">&quot;False&quot;</font><font style="font-size:11px"> </font></td></tr> <tr> <td style="background-color:#f7f7f7">        </font><font style="color:red">loop</font><font style="font-size:11px"> = </font><font style="color:blue">&quot;False&quot;</font><font style="font-size:11px"> </font></td></tr> <tr> <td>        </font><font style="color:red">Facing</font><font style="font-size:11px"></font><font style="color:blue">Facing</font><font style="font-size:11px"> = Facing - 1  </font></td></tr> <tr> <td style="background-color:#f7f7f7">        If Facing </font><font style="color:blue">&lt;</font><font style="font-size:11px"> </font><font style="font-weight:bold;color:black">1</font><font style="font-size:11px"> Then  </font></td></tr> <tr> <td>          </font><font style="color:red">Facing</font><font style="font-size:11px"> = </font><font style="color:blue">4</font><font style="font-size:11px"> </font></td></tr> <tr> <td style="background-color:#f7f7f7">        Endif  </td></tr> <tr> <td>      EndIf  </td></tr> <tr> <td style="background-color:#f7f7f7">      If </font><font style="color:red">key</font><font style="font-size:11px"> = </font><font style="color:blue">&quot;Right&quot;</font><font style="font-size:11px"> Then  </font></td></tr> <tr> <td>        </font><font style="color:red">NoForward</font><font style="font-size:11px"> = </font><font style="color:blue">&quot;False&quot;</font><font style="font-size:11px"> </font></td></tr> <tr> <td style="background-color:#f7f7f7">        </font><font style="color:red">loop</font><font style="font-size:11px"> = </font><font style="color:blue">&quot;False&quot;</font><font style="font-size:11px"> </font></td></tr> <tr> <td>        </font><font style="color:red">Facing</font><font style="font-size:11px"></font><font style="color:blue">Facing</font><font style="font-size:11px"> = Facing + 1  </font></td></tr> <tr> <td style="background-color:#f7f7f7">        If Facing </font><font style="color:blue">&gt;</font><font style="font-size:11px"> 4 Then  </font></td></tr> <tr> <td>          </font><font style="color:red">Facing</font><font style="font-size:11px"> = </font><font style="color:blue">1</font><font style="font-size:11px"> </font></td></tr> <tr> <td style="background-color:#f7f7f7">        EndIf  </td></tr> <tr> <td>      EndIf  </td></tr> <tr> <td style="background-color:#f7f7f7">      If </font><font style="color:red">key</font><font style="font-size:11px"> = </font><font style="color:blue">&quot;Down&quot;</font><font style="font-size:11px"> Then  </font></td></tr> <tr> <td>        </font><font style="color:red">loop</font><font style="font-size:11px"> = </font><font style="color:blue">&quot;False&quot;</font><font style="font-size:11px"> </font></td></tr> <tr> <td style="background-color:#f7f7f7">        'Make sure no wall behind you and then move back one.  </td></tr> <tr> <td>        If </font><font style="color:red">Facing</font><font style="font-size:11px"> = </font><font style="color:blue">1</font><font style="font-size:11px"> and Text.GetSubText(Array.GetValue(&quot;mapdata&quot;,CurrentY+1),CurrentX,1) = 0 Then  </font></td></tr> <tr> <td style="background-color:#f7f7f7">          </font><font style="color:red">CurrentY</font><font style="font-size:11px"></font><font style="color:blue">CurrentY</font><font style="font-size:11px"> = CurrentY + 2  </font></td></tr> <tr> <td>        ElseIf </font><font style="color:red">Facing</font><font style="font-size:11px"> = </font><font style="color:blue">2</font><font style="font-size:11px"> and Text.GetSubText(Array.GetValue(&quot;mapdata&quot;,CurrentY),CurrentX-1,1) = 0 Then  </font></td></tr> <tr> <td style="background-color:#f7f7f7">          </font><font style="color:red">CurrentX</font><font style="font-size:11px"></font><font style="color:blue">CurrentX</font><font style="font-size:11px"> = CurrentX - 2  </font></td></tr> <tr> <td>        ElseIf </font><font style="color:red">Facing</font><font style="font-size:11px"> = </font><font style="color:blue">3</font><font style="font-size:11px"> and Text.GetSubText(Array.GetValue(&quot;mapdata&quot;,CurrentY-1),CurrentX,1) = 0 Then  </font></td></tr> <tr> <td style="background-color:#f7f7f7">          </font><font style="color:red">CurrentY</font><font style="font-size:11px"></font><font style="color:blue">CurrentY</font><font style="font-size:11px"> = CurrentY - 2  </font></td></tr> <tr> <td>        ElseIf </font><font style="color:red">Facing</font><font style="font-size:11px"> = </font><font style="color:blue">4</font><font style="font-size:11px"> and Text.GetSubText(Array.GetValue(&quot;mapdata&quot;,CurrentY),CurrentX+1,1) = 0 Then  </font></td></tr> <tr> <td style="background-color:#f7f7f7">          </font><font style="color:red">CurrentX</font><font style="font-size:11px"></font><font style="color:blue">CurrentX</font><font style="font-size:11px"> = CurrentX + 2  </font></td></tr> <tr> <td>        Else  </td></tr> <tr> <td style="background-color:#f7f7f7">          HitWall()  </td></tr> <tr> <td>        EndIf  </td></tr> <tr> <td style="background-color:#f7f7f7">        </font><font style="color:red">keyisupdated</font><font style="font-size:11px"> = </font><font style="color:blue">&quot;False&quot;</font><font style="font-size:11px"> </font></td></tr> <tr> <td>      EndIf  </td></tr> <tr> <td style="background-color:#f7f7f7">        </td></tr> <tr> <td>      If </font><font style="color:red">key</font><font style="font-size:11px"> = </font><font style="color:blue">&quot;Back&quot;</font><font style="font-size:11px"> Then  </font></td></tr> <tr> <td style="background-color:#f7f7f7">        </font><font style="color:red">loop</font><font style="font-size:11px"> = </font><font style="color:blue">&quot;False&quot;</font><font style="font-size:11px"> </font></td></tr> <tr> <td>        </font><font style="color:red">keyisupdated</font><font style="font-size:11px"> = </font><font style="color:blue">&quot;False&quot;</font><font style="font-size:11px"> </font></td></tr> <tr> <td style="background-color:#f7f7f7">        RestartMazeQuestion()  </td></tr> <tr> <td>      EndIf  </td></tr> <tr> <td style="background-color:#f7f7f7">      If (</font><font style="color:red">key</font><font style="font-size:11px"> = </font><font style="color:blue">&quot;Escape&quot;</font><font style="font-size:11px">) Then  </font></td></tr> <tr> <td>        </font><font style="color:red">Main</font><font style="font-size:11px"> = </font><font style="color:blue">&quot;False&quot;</font><font style="font-size:11px"> </font></td></tr> <tr> <td style="background-color:#f7f7f7">        </font><font style="color:red">loop</font><font style="font-size:11px"> = </font><font style="color:blue">&quot;False&quot;</font><font style="font-size:11px"> </font></td></tr> <tr> <td>      EndIf  </td></tr> <tr> <td style="background-color:#f7f7f7">    EndIf  </td></tr> <tr> <td>  EndWhile  </td></tr> <tr> <td style="background-color:#f7f7f7"></font><font style="color:red">keyisupdated</font><font style="font-size:11px"> = </font><font style="color:blue">&quot;False&quot;</font><font style="font-size:11px"> </font></td></tr> <tr> <td>Sound.PlayClickAndWait()  </td></tr> <tr> <td style="background-color:#f7f7f7">EndSub  </td></tr> <tr> <td> </td></tr> <tr> <td style="background-color:#f7f7f7">Sub DrawWalls  </td></tr> <tr> <td>    </td></tr> <tr> <td style="background-color:#f7f7f7">  EraseMazeWalls()  </td></tr> <tr> <td>    </td></tr> <tr> <td style="background-color:#f7f7f7">  'determine walls  </td></tr> <tr> <td>    </td></tr> <tr> <td style="background-color:#f7f7f7">  For </font><font style="color:red">fm</font><font style="font-size:11px"> = </font><font style="color:blue">0</font><font style="font-size:11px"> to 4  </font></td></tr> <tr> <td>    </font><font style="color:red">WallSection1</font><font style="font-size:11px"> = </font><font style="color:blue">0</font><font style="font-size:11px"> </font></td></tr> <tr> <td style="background-color:#f7f7f7">    </font><font style="color:red">WallSection2</font><font style="font-size:11px"> = </font><font style="color:blue">0</font><font style="font-size:11px"> </font></td></tr> <tr> <td>    </font><font style="color:red">WallSection3</font><font style="font-size:11px"> = </font><font style="color:blue">0</font><font style="font-size:11px"> </font></td></tr> <tr> <td style="background-color:#f7f7f7">      </td></tr> <tr> <td>    ' facing north/south  </td></tr> <tr> <td style="background-color:#f7f7f7">    If </font><font style="color:red">Facing</font><font style="font-size:11px"> = </font><font style="color:blue">1</font><font style="font-size:11px"> Or </font><font style="color:red">Facing</font><font style="font-size:11px"> = </font><font style="color:blue">3</font><font style="font-size:11px"> Then  </font></td></tr> <tr> <td>      If </font><font style="color:red">Facing</font><font style="font-size:11px"> = </font><font style="color:blue">1</font><font style="font-size:11px"> then  </font></td></tr> <tr> <td style="background-color:#f7f7f7">        </font><font style="color:red">wd</font><font style="font-size:11px"> = </font><font style="color:blue">1</font><font style="font-size:11px"> </font></td></tr> <tr> <td>      Else  </td></tr> <tr> <td style="background-color:#f7f7f7">        </font><font style="color:red">wd</font><font style="font-size:11px"> = -1  </font></td></tr> <tr> <td>      EndIf  </td></tr> <tr> <td style="background-color:#f7f7f7">        </td></tr> <tr> <td>      If Text.GetSubText(Array.GetValue(&quot;mapdata&quot;,CurrentY-(fm*2*wd)),CurrentX - wd,1) = 1 Then  </td></tr> <tr> <td style="background-color:#f7f7f7">        </font><font style="color:red">WallSection1</font><font style="font-size:11px"> = 1  </font></td></tr> <tr> <td>      ElseIf Text.GetSubText(Array.GetValue(&quot;mapdata&quot;,CurrentY-(fm*2*wd + wd)),CurrentX - (2*wd),1) = 1 Then  </td></tr> <tr> <td style="background-color:#f7f7f7">        </font><font style="color:red">WallSection1</font><font style="font-size:11px"> = </font><font style="color:blue">2</font><font style="font-size:11px"> </font></td></tr> <tr> <td>      EndIf  </td></tr> <tr> <td style="background-color:#f7f7f7">          </td></tr> <tr> <td>      If Text.GetSubText(Array.GetValue(&quot;mapdata&quot;,CurrentY-(fm*2*wd + wd)),CurrentX,1) = 1 Then  </td></tr> <tr> <td style="background-color:#f7f7f7">        </font><font style="color:red">WallSection2</font><font style="font-size:11px"> = </font><font style="color:blue">1</font><font style="font-size:11px"> </font></td></tr> <tr> <td>      EndIf  </td></tr> <tr> <td style="background-color:#f7f7f7">      If Text.GetSubText(Array.GetValue(&quot;mapdata&quot;,CurrentY-(fm*2*wd)),CurrentX + wd,1) = 1 Then  </td></tr> <tr> <td>        </font><font style="color:red">WallSection3</font><font style="font-size:11px"> = </font><font style="color:blue">1</font><font style="font-size:11px"> </font></td></tr> <tr> <td style="background-color:#f7f7f7">      ElseIf Text.GetSubText(Array.GetValue(&quot;mapdata&quot;,CurrentY-(fm*2*wd + (1*wd))),CurrentX + (2*wd),1) = 1 Then  </td></tr> <tr> <td>        </font><font style="color:red">WallSection3</font><font style="font-size:11px"> = </font><font style="color:blue">2</font><font style="font-size:11px"> </font></td></tr> <tr> <td style="background-color:#f7f7f7">      EndIf  </td></tr> <tr> <td>        </td></tr> <tr> <td style="background-color:#f7f7f7">    EndIf  </td></tr> <tr> <td>      </td></tr> <tr> <td style="background-color:#f7f7f7">    ' facing east/west  </td></tr> <tr> <td>    If </font><font style="color:red">Facing</font><font style="font-size:11px"> = </font><font style="color:blue">2</font><font style="font-size:11px"> Or </font><font style="color:red">Facing</font><font style="font-size:11px"> = </font><font style="color:blue">4</font><font style="font-size:11px"> Then  </font></td></tr> <tr> <td style="background-color:#f7f7f7">      If </font><font style="color:red">Facing</font><font style="font-size:11px"> = </font><font style="color:blue">2</font><font style="font-size:11px"> then  </font></td></tr> <tr> <td>        </font><font style="color:red">wd</font><font style="font-size:11px"> = </font><font style="color:blue">1</font><font style="font-size:11px"> </font></td></tr> <tr> <td style="background-color:#f7f7f7">      Else  </td></tr> <tr> <td>        </font><font style="color:red">wd</font><font style="font-size:11px"> = -1  </font></td></tr> <tr> <td style="background-color:#f7f7f7">      EndIf  </td></tr> <tr> <td>        </td></tr> <tr> <td style="background-color:#f7f7f7">      If Text.GetSubText(Array.GetValue(&quot;mapdata&quot;,CurrentY-(1*wd)),CurrentX +(fm*2*wd),1) = 1 Then  </td></tr> <tr> <td>        </font><font style="color:red">WallSection1</font><font style="font-size:11px"> = 1  </font></td></tr> <tr> <td style="background-color:#f7f7f7">      ElseIf Text.GetSubText(Array.GetValue(&quot;mapdata&quot;,CurrentY-(2*wd)),CurrentX + (fm*2*wd+(1*wd)),1) = 1 Then  </td></tr> <tr> <td>        </font><font style="color:red">WallSection1</font><font style="font-size:11px"> = </font><font style="color:blue">2</font><font style="font-size:11px"> </font></td></tr> <tr> <td style="background-color:#f7f7f7">      EndIf  </td></tr> <tr> <td>      If Text.GetSubText(Array.GetValue(&quot;mapdata&quot;,CurrentY),CurrentX +(fm*2*wd+(1*wd)),1) = 1 Then  </td></tr> <tr> <td style="background-color:#f7f7f7">        </font><font style="color:red">WallSection2</font><font style="font-size:11px"> = </font><font style="color:blue">1</font><font style="font-size:11px"> </font></td></tr> <tr> <td>      EndIf  </td></tr> <tr> <td style="background-color:#f7f7f7">      If Text.GetSubText(Array.GetValue(&quot;mapdata&quot;,CurrentY+(1*wd)),CurrentX +(fm*2*wd),1) = 1 Then  </td></tr> <tr> <td>        </font><font style="color:red">WallSection3</font><font style="font-size:11px"> = </font><font style="color:blue">1</font><font style="font-size:11px"> </font></td></tr> <tr> <td style="background-color:#f7f7f7">      ElseIf Text.GetSubText(Array.GetValue(&quot;mapdata&quot;,CurrentY+(2*wd)),CurrentX +(fm*2*wd+(1*wd)),1) = 1 Then  </td></tr> <tr> <td>        </font><font style="color:red">WallSection3</font><font style="font-size:11px"> = </font><font style="color:blue">2</font><font style="font-size:11px"> </font></td></tr> <tr> <td style="background-color:#f7f7f7">      EndIf  </td></tr> <tr> <td>        </td></tr> <tr> <td style="background-color:#f7f7f7">    EndIf  </td></tr> <tr> <td>      </td></tr> <tr> <td style="background-color:#f7f7f7">      </td></tr> <tr> <td>    'draw the walls  </td></tr> <tr> <td style="background-color:#f7f7f7">    </font><font style="color:red">GraphicsWindow.BrushColor</font><font style="font-size:11px"> = </font><font style="color:blue">&quot;White&quot;</font><font style="font-size:11px"> </font></td></tr> <tr> <td>    If </font><font style="color:red">fm</font><font style="font-size:11px"> = </font><font style="color:blue">0</font><font style="font-size:11px"> Then  </font></td></tr> <tr> <td style="background-color:#f7f7f7">      ' immediate  </td></tr> <tr> <td>      If </font><font style="color:red">WallSection1</font><font style="font-size:11px"> = 1 Then  </font></td></tr> <tr> <td style="background-color:#f7f7f7">        GraphicsWindow.DrawLine(200,0,240,40)  </td></tr> <tr> <td>        GraphicsWindow.DrawLine(240,40,240,560)  </td></tr> <tr> <td style="background-color:#f7f7f7">        GraphicsWindow.DrawLine(240,560,200,600)  </td></tr> <tr> <td>      EndIf  </td></tr> <tr> <td style="background-color:#f7f7f7">        </td></tr> <tr> <td>      If </font><font style="color:red">WallSection1</font><font style="font-size:11px"> = </font><font style="color:blue">2</font><font style="font-size:11px"> Then  </font></td></tr> <tr> <td style="background-color:#f7f7f7">        GraphicsWindow.DrawLine(200,40,240,40)  </td></tr> <tr> <td>        GraphicsWindow.DrawLine(240,40,240,560)  </td></tr> <tr> <td style="background-color:#f7f7f7">        GraphicsWindow.DrawLine(240,560,200,560)  </td></tr> <tr> <td>      EndIf  </td></tr> <tr> <td style="background-color:#f7f7f7">        </td></tr> <tr> <td>      If </font><font style="color:red">WallSection2</font><font style="font-size:11px"> = </font><font style="color:blue">1</font><font style="font-size:11px"> Then  </font></td></tr> <tr> <td style="background-color:#f7f7f7">        GraphicsWindow.DrawLine(240,40,240,560)  </td></tr> <tr> <td>        GraphicsWindow.DrawLine(240,560,760,560)  </td></tr> <tr> <td style="background-color:#f7f7f7">        GraphicsWindow.DrawLine(760,560,760,40)  </td></tr> <tr> <td>        GraphicsWindow.DrawLine(760,40,240,40)  </td></tr> <tr> <td style="background-color:#f7f7f7">        </font><font style="color:red">fm</font><font style="font-size:11px"> = </font><font style="color:blue">4</font><font style="font-size:11px"> 'end wall drawing because you can't see any further  </font></td></tr> <tr> <td>        </font><font style="color:red">NoForward</font><font style="font-size:11px"> = </font><font style="color:blue">&quot;true&quot;</font><font style="font-size:11px"> </font></td></tr> <tr> <td style="background-color:#f7f7f7">      EndIf  </td></tr> <tr> <td>        </td></tr> <tr> <td style="background-color:#f7f7f7">      If </font><font style="color:red">WallSection3</font><font style="font-size:11px"> = </font><font style="color:blue">1</font><font style="font-size:11px"> Then  </font></td></tr> <tr> <td>        GraphicsWindow.DrawLine(800,0,760,40)  </td></tr> <tr> <td style="background-color:#f7f7f7">        GraphicsWindow.DrawLine(760,40,760,560)  </td></tr> <tr> <td>        GraphicsWindow.DrawLine(760,560,800,600)  </td></tr> <tr> <td style="background-color:#f7f7f7">      EndIf  </td></tr> <tr> <td>        </td></tr> <tr> <td style="background-color:#f7f7f7">      If </font><font style="color:red">WallSection3</font><font style="font-size:11px"> = </font><font style="color:blue">2</font><font style="font-size:11px"> Then  </font></td></tr> <tr> <td>        GraphicsWindow.DrawLine(800,40,760,40)  </td></tr> <tr> <td style="background-color:#f7f7f7">        GraphicsWindow.DrawLine(760,40,760,560)  </td></tr> <tr> <td>        GraphicsWindow.DrawLine(760,560,800,560)   </td></tr> <tr> <td style="background-color:#f7f7f7">      EndIf  </td></tr> <tr> <td> </td></tr> <tr> <td style="background-color:#f7f7f7">    Else  </td></tr> <tr> <td>    </td></tr> <tr> <td style="background-color:#f7f7f7">      ' greater than immediate  </td></tr> <tr> <td>      </font><font style="color:red">WallSize</font><font style="font-size:11px"> = </font><font style="color:blue">80</font><font style="font-size:11px"> </font></td></tr> <tr> <td style="background-color:#f7f7f7">      </font><font style="color:red">WallPositionLeftX</font><font style="font-size:11px"> = </font><font style="color:blue">240</font><font style="font-size:11px"> </font></td></tr> <tr> <td>      </font><font style="color:red">WallPositionRightX</font><font style="font-size:11px"> = </font><font style="color:blue">760</font><font style="font-size:11px"> </font></td></tr> <tr> <td style="background-color:#f7f7f7">      </font><font style="color:red">WallPositionTopY</font><font style="font-size:11px"> = </font><font style="color:blue">40</font><font style="font-size:11px"> </font></td></tr> <tr> <td>      </font><font style="color:red">WallPositionBottomY</font><font style="font-size:11px"> =</font><font style="color:blue">560</font><font style="font-size:11px"> </font></td></tr> <tr> <td style="background-color:#f7f7f7"> </td></tr> <tr> <td>      </td></tr> <tr> <td style="background-color:#f7f7f7">      If fm </font><font style="color:blue">&gt;</font><font style="font-size:11px"> 1 Then  </font></td></tr> <tr> <td>        For </font><font style="color:red">count</font><font style="font-size:11px"> = </font><font style="color:blue">1</font><font style="font-size:11px"> To fm-1  </font></td></tr> <tr> <td style="background-color:#f7f7f7">          </font><font style="color:red">WallPositionLeftX</font><font style="font-size:11px"></font><font style="color:blue">WallPositionLeftX</font><font style="font-size:11px"> = WallPositionLeftX + WallSize  </font></td></tr> <tr> <td>          </font><font style="color:red">WallPositionRightX</font><font style="font-size:11px"></font><font style="color:blue">WallPositionRightX</font><font style="font-size:11px"> = WallPositionRightX - WallSize  </font></td></tr> <tr> <td style="background-color:#f7f7f7">          </font><font style="color:red">WallPositionTopY</font><font style="font-size:11px"></font><font style="color:blue">WallPositionTopY</font><font style="font-size:11px"> = WallPositionTopY + WallSize  </font></td></tr> <tr> <td>          </font><font style="color:red">WallPositionBottomY</font><font style="font-size:11px"></font><font style="color:blue">WallPositionBottomY</font><font style="font-size:11px"> = WallPositionBottomY - WallSize  </font></td></tr> <tr> <td style="background-color:#f7f7f7">          </font><font style="color:red">WallSize</font><font style="font-size:11px"></font><font style="color:blue">WallSize</font><font style="font-size:11px"> = WallSize - Math.Round(WallSize / 4)  </font></td></tr> <tr> <td>        EndFor  </td></tr> <tr> <td style="background-color:#f7f7f7">      EndIf  </td></tr> <tr> <td>        </td></tr> <tr> <td style="background-color:#f7f7f7">      If </font><font style="color:red">WallSection1</font><font style="font-size:11px"> = 1 Then  </font></td></tr> <tr> <td>        GraphicsWindow.DrawLine(WallPositionLeftX,WallPositionTopY,WallPositionLeftX + WallSize,WallPositionTopY + WallSize)  </td></tr> <tr> <td style="background-color:#f7f7f7">        GraphicsWindow.DrawLine(WallPositionLeftX + WallSize,WallPositionTopY + WallSize,WallPositionLeftX + WallSize,WallPositionBottomY - WallSize)  </td></tr> <tr> <td>        GraphicsWindow.DrawLine(WallpositionLeftX + WallSize,WallPositionBottomY - WallSize,WallPositionLeftX,WallPositionBottomY)  </td></tr> <tr> <td style="background-color:#f7f7f7">        GraphicsWindow.DrawLine(WallPositionLeftX,WallPositionBottomY,WallPositionLeftX,WallPositionTopY)  </td></tr> <tr> <td>      EndIf  </td></tr> <tr> <td style="background-color:#f7f7f7">        </td></tr> <tr> <td>      If </font><font style="color:red">WallSection1</font><font style="font-size:11px"> = </font><font style="color:blue">2</font><font style="font-size:11px"> Then  </font></td></tr> <tr> <td style="background-color:#f7f7f7">        GraphicsWindow.DrawLine(WallPositionLeftX,WallPositionTopY + WallSize,WallPositionLeftX + WallSize,WallPositionTopY + WallSize)  </td></tr> <tr> <td>        GraphicsWindow.DrawLine(WallPositionLeftX + WallSize,WallPositionTopY + WallSize,WallPositionLeftX + WallSize,WallPositionBottomY - WallSize)  </td></tr> <tr> <td style="background-color:#f7f7f7">        GraphicsWindow.DrawLine(WallpositionLeftX + WallSize,WallPositionBottomY - WallSize,WallPositionLeftX,WallPositionBottomY - WallSize)  </td></tr> <tr> <td>        GraphicsWindow.DrawLine(WallPositionLeftX,WallPositionBottomY - WallSize,WallPositionLeftX,WallPositionTopY + WallSize)  </td></tr> <tr> <td style="background-color:#f7f7f7">      EndIf  </td></tr> <tr> <td>        </td></tr> <tr> <td style="background-color:#f7f7f7">      If </font><font style="color:red">WallSection2</font><font style="font-size:11px"> = </font><font style="color:blue">1</font><font style="font-size:11px"> Then  </font></td></tr> <tr> <td>        GraphicsWindow.DrawLine(WallPositionLeftX + WallSize,WallPositionTopY + WallSize,WallPositionRightX - WallSize,WallPositionTopY + WallSize)  </td></tr> <tr> <td style="background-color:#f7f7f7">        GraphicsWindow.DrawLine(WallPositionRightX - WallSize,WallPositionTopY + WallSize,WallPositionRightX - WallSize,WallPositionBottomY - WallSize)  </td></tr> <tr> <td>        GraphicsWindow.DrawLine(WallPositionRightX - WallSize,WallPositionBottomY - WallSize,WallpositionLeftX + WallSize,WallPositionBottomY - WallSize)  </td></tr> <tr> <td style="background-color:#f7f7f7">        GraphicsWindow.DrawLine(WallpositionLeftX + WallSize,WallPositionBottomY - WallSize,WallPositionLeftX + WallSize,WallPositionTopY + WallSize)  </td></tr> <tr> <td>        </font><font style="color:red">fm</font><font style="font-size:11px"> = </font><font style="color:blue">4</font><font style="font-size:11px"> 'end wall drawing because you can't see any further  </font></td></tr> <tr> <td style="background-color:#f7f7f7">      EndIf  </td></tr> <tr> <td>        </td></tr> <tr> <td style="background-color:#f7f7f7">      If </font><font style="color:red">WallSection3</font><font style="font-size:11px"> = </font><font style="color:blue">1</font><font style="font-size:11px"> Then  </font></td></tr> <tr> <td>        GraphicsWindow.DrawLine(WallPositionRightX,WallPositionTopY,WallPositionRightX - WallSize,WallPositionTopY + WallSize)  </td></tr> <tr> <td style="background-color:#f7f7f7">        GraphicsWindow.DrawLine(WallPositionRightX - WallSize,WallPositionTopY + WallSize,WallPositionRightX - WallSize,WallPositionBottomY - WallSize)  </td></tr> <tr> <td>        GraphicsWindow.DrawLine(WallPositionRightX - WallSize,WallPositionBottomY - WallSize,WallPositionRightX,WallPositionBottomY)  </td></tr> <tr> <td style="background-color:#f7f7f7">        GraphicsWindow.DrawLine(WallPositionRightX,WallPositionBottomY,WallPositionRightX,WallPositionTopY)  </td></tr> <tr> <td>      EndIf  </td></tr> <tr> <td style="background-color:#f7f7f7">        </td></tr> <tr> <td>      If </font><font style="color:red">WallSection3</font><font style="font-size:11px"> = </font><font style="color:blue">2</font><font style="font-size:11px"> Then  </font></td></tr> <tr> <td style="background-color:#f7f7f7">        GraphicsWindow.DrawLine(WallPositionRightX,WallPositionTopY + WallSize,WallPositionRightX - WallSize,WallPositionTopY + WallSize)  </td></tr> <tr> <td>        GraphicsWindow.DrawLine(WallPositionRightX - WallSize,WallPositionTopY + WallSize,WallPositionRightX - WallSize,WallPositionBottomY - WallSize)  </td></tr> <tr> <td style="background-color:#f7f7f7">        GraphicsWindow.DrawLine(WallPositionRightX - WallSize,WallPositionBottomY - WallSize,WallPositionRightX,WallPositionBottomY - WallSize)  </td></tr> <tr> <td>        GraphicsWindow.DrawLine(WallPositionRightX,WallPositionBottomY - WallSize,WallPositionRightX,WallPositionTopY + WallSize)  </td></tr> <tr> <td style="background-color:#f7f7f7">      EndIf  </td></tr> <tr> <td>      </td></tr> <tr> <td style="background-color:#f7f7f7">    EndIf  </td></tr> <tr> <td>    </td></tr> <tr> <td style="background-color:#f7f7f7">  EndFor  </td></tr> <tr> <td>    </td></tr> <tr> <td style="background-color:#f7f7f7">EndSub  </td></tr> <tr> <td> </td></tr> <tr> <td style="background-color:#f7f7f7"> </td></tr> <tr> <td>Sub HitWall  </td></tr> <tr> <td style="background-color:#f7f7f7">  'play sound to indicate hit wall  </td></tr> <tr> <td>  Sound.PlayAndWait(&quot;C:\WINDOWS\Media\Windows XP Battery Low.wav&quot;)  </td></tr> <tr> <td style="background-color:#f7f7f7">    </td></tr> <tr> <td>  '[TODO]'s   </td></tr> <tr> <td style="background-color:#f7f7f7">  'maybe put &quot;OUCH&quot; in maze view  </td></tr> <tr> <td>  'put message in information frame that you ran into a wall   </td></tr> <tr> <td style="background-color:#f7f7f7">  '(IDEA: when secret walls are implemented, make some sound like magic or &quot;swush&quot; like sound when walking through secret wall)  </td></tr> <tr> <td>  'Note: be sure to clear both messages once a succesful Forward, left, right, or back move has been made.  </td></tr> <tr> <td style="background-color:#f7f7f7">EndSub  </td></tr> <tr> <td> </td></tr> <tr> <td style="background-color:#f7f7f7"> </td></tr> <tr> <td>Sub ReadKey  </td></tr> <tr> <td style="background-color:#f7f7f7">    </font><font style="color:red">key</font><font style="font-size:11px"> = </font><font style="color:blue">GraphicsWindow</font><font style="font-size:11px">.LastKey  </font></td></tr> <tr> <td>    </font><font style="color:red">keyisupdated</font><font style="font-size:11px"> = </font><font style="color:blue">&quot;True&quot;</font><font style="font-size:11px"> </font></td></tr> <tr> <td style="background-color:#f7f7f7">EndSub  </td></tr> <tr> <td> </td></tr> <tr> <td style="background-color:#f7f7f7"> </td></tr> <tr> <td>Sub EraseMazeWalls  </td></tr> <tr> <td style="background-color:#f7f7f7">  'erase walls from maze-view window  </td></tr> <tr> <td>  </font><font style="color:red">GraphicsWindow.BrushColor</font><font style="font-size:11px"> = </font><font style="color:blue">&quot;Black&quot;</font><font style="font-size:11px"> </font></td></tr> <tr> <td style="background-color:#f7f7f7">  </font><font style="color:red">GraphicsWindow.PenWidth</font><font style="font-size:11px"> = </font><font style="color:blue">2</font><font style="font-size:11px"> </font></td></tr> <tr> <td>  GraphicsWindow.FillRectangle(202,2,596,596)  </td></tr> <tr> <td style="background-color:#f7f7f7"> </td></tr> <tr> <td> </td></tr> <tr> <td style="background-color:#f7f7f7">  'draw box around Maze-View window on the right  </td></tr> <tr> <td>  </font><font style="color:red">GraphicsWindow.PenColor</font><font style="font-size:11px"> = </font><font style="color:blue">&quot;White&quot;</font><font style="font-size:11px"> </font></td></tr> <tr> <td style="background-color:#f7f7f7">  </font><font style="color:red">GraphicsWindow.PenWidth</font><font style="font-size:11px"> = </font><font style="color:blue">4</font><font style="font-size:11px"> </font></td></tr> <tr> <td>  GraphicsWindow.DrawRectangle(200,0,600,600)  </td></tr> <tr> <td style="background-color:#f7f7f7">EndSub  </td></tr> <tr> <td> </td></tr> <tr> <td style="background-color:#f7f7f7"> </td></tr> <tr> <td>Sub DisplayCurrentXY  </td></tr> <tr> <td style="background-color:#f7f7f7">  'erase old coordinates  </td></tr> <tr> <td>  </font><font style="color:red">GraphicsWindow.BrushColor</font><font style="font-size:11px"> = </font><font style="color:blue">&quot;Gainsboro&quot;</font><font style="font-size:11px"> </font></td></tr> <tr> <td style="background-color:#f7f7f7">  GraphicsWindow.FillRectangle(48,95,110,45)  </td></tr> <tr> <td>    </td></tr> <tr> <td style="background-color:#f7f7f7">  'display new coordinates  </td></tr> <tr> <td>  </font><font style="color:red">GraphicsWindow.BrushColor</font><font style="font-size:11px"> = </font><font style="color:blue">&quot;Black&quot;</font><font style="font-size:11px"> </font></td></tr> <tr> <td style="background-color:#f7f7f7">  </font><font style="color:red">CoordinatesText</font><font style="font-size:11px"> = </font><font style="color:blue">&quot;X = &quot;</font><font style="font-size:11px"> + CurrentX + &quot; </font><font style="color:red">Y</font><font style="font-size:11px"> = &quot; + CurrentY  </font></td></tr> <tr> <td>  </font><font style="color:red">DirectionText</font><font style="font-size:11px"> = </font><font style="color:blue">&quot;Facing: &quot;</font><font style="font-size:11px"> </font></td></tr> <tr> <td style="background-color:#f7f7f7">  If </font><font style="color:red">Facing</font><font style="font-size:11px"> = </font><font style="color:blue">1</font><font style="font-size:11px"> Then  </font></td></tr> <tr> <td>    </font><font style="color:red">DirectionText</font><font style="font-size:11px"></font><font style="color:blue">DirectionText</font><font style="font-size:11px"> = DirectionText + &quot;North&quot;  </font></td></tr> <tr> <td style="background-color:#f7f7f7">  ElseIf </font><font style="color:red">Facing</font><font style="font-size:11px"> = </font><font style="color:blue">2</font><font style="font-size:11px"> Then  </font></td></tr> <tr> <td>    </font><font style="color:red">DirectionText</font><font style="font-size:11px"></font><font style="color:blue">DirectionText</font><font style="font-size:11px"> = DirectionText + &quot;East&quot;  </font></td></tr> <tr> <td style="background-color:#f7f7f7">  ElseIf </font><font style="color:red">Facing</font><font style="font-size:11px"> = </font><font style="color:blue">3</font><font style="font-size:11px"> Then  </font></td></tr> <tr> <td>    </font><font style="color:red">DirectionText</font><font style="font-size:11px"></font><font style="color:blue">DirectionText</font><font style="font-size:11px"> = DirectionText + &quot;South&quot;  </font></td></tr> <tr> <td style="background-color:#f7f7f7">  Else  </td></tr> <tr> <td>    </font><font style="color:red">DirectionText</font><font style="font-size:11px"></font><font style="color:blue">DirectionText</font><font style="font-size:11px"> = DirectionText + &quot;West&quot;  </font></td></tr> <tr> <td style="background-color:#f7f7f7">  EndIf  </td></tr> <tr> <td>    </td></tr> <tr> <td style="background-color:#f7f7f7">  GraphicsWindow.DrawText(48,95,CoordinatesText)  </td></tr> <tr> <td>  GraphicsWindow.DrawText(48,110,DirectionText)  </td></tr> <tr> <td style="background-color:#f7f7f7">    </td></tr> <tr> <td>EndSub  </td></tr> <tr> <td style="background-color:#f7f7f7"> </td></tr> <tr> <td> </td></tr> <tr> <td style="background-color:#f7f7f7">Sub RestartMazeQuestion  </td></tr> <tr> <td>    </td></tr> <tr> <td style="background-color:#f7f7f7">  </font><font style="color:red">RestartMazeQuestionAnswered</font><font style="font-size:11px"> = </font><font style="color:blue">&quot;False&quot;</font><font style="font-size:11px"> </font></td></tr> <tr> <td>  </font><font style="color:red">GraphicsWindow.BrushColor</font><font style="font-size:11px"> = </font><font style="color:blue">&quot;Black&quot;</font><font style="font-size:11px"> </font></td></tr> <tr> <td style="background-color:#f7f7f7">  GraphicsWindow.DrawText(5,400,&quot;You pressed the Backspace key.&quot;)  </td></tr> <tr> <td>  GraphicsWindow.DrawText(5,415,&quot;Do you really wish to restart&quot;)  </td></tr> <tr> <td style="background-color:#f7f7f7">  GraphicsWindow.DrawText(5,430,&quot;the maze?&quot;)  </td></tr> <tr> <td>  While (</font><font style="color:red">RestartMazeQuestionAnswered</font><font style="font-size:11px"> = </font><font style="color:blue">&quot;False&quot;</font><font style="font-size:11px">)  </font></td></tr> <tr> <td style="background-color:#f7f7f7">      </td></tr> <tr> <td>    If text.ConvertToLowerCase(key) = &quot;y&quot; Then  </td></tr> <tr> <td style="background-color:#f7f7f7">      </font><font style="color:red">CurrentX</font><font style="font-size:11px"> = </font><font style="color:blue">StartX</font><font style="font-size:11px"> </font></td></tr> <tr> <td>      </font><font style="color:red">CurrentY</font><font style="font-size:11px"> = </font><font style="color:blue">StartY</font><font style="font-size:11px"> </font></td></tr> <tr> <td style="background-color:#f7f7f7">      </font><font style="color:red">Facing</font><font style="font-size:11px"> = </font><font style="color:blue">StartFacing</font><font style="font-size:11px"> </font></td></tr> <tr> <td>      </font><font style="color:red">RestartMazeQuestionAnswered</font><font style="font-size:11px"> = </font><font style="color:blue">&quot;True&quot;</font><font style="font-size:11px"> </font></td></tr> <tr> <td style="background-color:#f7f7f7">    ElseIf text.ConvertToLowerCase(key) = &quot;n&quot; Then  </td></tr> <tr> <td>      </font><font style="color:red">RestartMazeQuestionAnswered</font><font style="font-size:11px"> = </font><font style="color:blue">&quot;True&quot;</font><font style="font-size:11px"> </font></td></tr> <tr> <td style="background-color:#f7f7f7">    EndIf  </td></tr> <tr> <td>      </td></tr> <tr> <td style="background-color:#f7f7f7">  EndWhile  </td></tr> <tr> <td>    </td></tr> <tr> <td style="background-color:#f7f7f7">  'erase Restart Maze message  </td></tr> <tr> <td>  </font><font style="color:red">GraphicsWindow.BrushColor</font><font style="font-size:11px"> = </font><font style="color:blue">&quot;Gainsboro&quot;</font><font style="font-size:11px"> </font></td></tr> <tr> <td style="background-color:#f7f7f7">  GraphicsWindow.FillRectangle(5,400,195,595)  </td></tr> <tr> <td>    </td></tr> <tr> <td style="background-color:#f7f7f7">EndSub </td></tr></tbody></table></div> <p style="margin:0in 0in 10pt"><br></font></p></span></span></span></span>Tue, 20 Jan 2009 18:41:34 Z2009-01-20T18:41:34Zhttp://social.msdn.microsoft.com/Forums/en-US/smallbasic/thread/eaacf826-9d12-4e3c-aa10-1b2788f160a6#cee6e23c-d58d-4248-a4e7-b49dd29c0c04http://social.msdn.microsoft.com/Forums/en-US/smallbasic/thread/eaacf826-9d12-4e3c-aa10-1b2788f160a6#cee6e23c-d58d-4248-a4e7-b49dd29c0c04Kenny Kasajianhttp://social.msdn.microsoft.com/Profile/en-US/?user=Kenny%20KasajianPost your sample source code here and get featured on our blogs!<p>You're welcome on the Tetris game.<br><br>Funny about the randomness.   The code is just using the built-in random number function.   But we can probably make it work a little more like what you expect.  Perhaps we can ensure that the next shape is different than the current shape.<br><br>high score is a good idea.<br><br>sound won't really do the right thing.   currently, the sound system is only to play wave files, and it does it in the background.   There's indeterminate amount of delay between the code that invokes a sound and when you actually hear the sound.<br><br>As I was playing the game myself, and my son came and asked me to help him with his homework, I realized another feature I left out -- the Pause button.  :)<br><br>So when I have time, I may go and and add those features there.   Or perhaps, someone else can. :)<br><br></p>Wed, 21 Jan 2009 09:11:50 Z2009-01-21T09:11:50Zhttp://social.msdn.microsoft.com/Forums/en-US/smallbasic/thread/eaacf826-9d12-4e3c-aa10-1b2788f160a6#201e4aab-a784-474e-9472-6a10cc121115http://social.msdn.microsoft.com/Forums/en-US/smallbasic/thread/eaacf826-9d12-4e3c-aa10-1b2788f160a6#201e4aab-a784-474e-9472-6a10cc121115Kenny Kasajianhttp://social.msdn.microsoft.com/Profile/en-US/?user=Kenny%20KasajianPost your sample source code here and get featured on our blogs! The game was QIXWed, 21 Jan 2009 09:14:23 Z2009-01-21T09:14:23Zhttp://social.msdn.microsoft.com/Forums/en-US/smallbasic/thread/eaacf826-9d12-4e3c-aa10-1b2788f160a6#95d8def4-fee2-4944-a924-5cd98728cdb9http://social.msdn.microsoft.com/Forums/en-US/smallbasic/thread/eaacf826-9d12-4e3c-aa10-1b2788f160a6#95d8def4-fee2-4944-a924-5cd98728cdb9Stendechttp://social.msdn.microsoft.com/Profile/en-US/?user=StendecPost your sample source code here and get featured on our blogs!<p> Hi B0ff1n,</p> <p>I too have been modifying the paddle game to create a simple version of Breakout (will be posting soon) you may want to combine your improvements with my code.</p> <p>Anyway, I noticed when running your code, that the ball sinks halfway down into the paddle. Looking at the values used a correction should be made when testing for the ball hitting the paddle. The co-ordinates of the ball are those of the top-left corner of the imaginary enclosing square. This means that you have to allow for the diameter of the ball and not the radius as you would if you were taking the centre of the ball as your reference.</p> <p>If you change your test for collision to &quot;If (y &gt;= gh-8)&quot; then the ball will change direction when it touches the paddle. It actually looks better though with &quot;If (y &gt;= gh-6)&quot; as this gives a more positive contact.</p> <p> </p>Sat, 31 Jan 2009 17:16:58 Z2009-01-31T17:16:58Zhttp://social.msdn.microsoft.com/Forums/en-US/smallbasic/thread/eaacf826-9d12-4e3c-aa10-1b2788f160a6#73c776ce-757a-45e8-b3eb-314065108a4dhttp://social.msdn.microsoft.com/Forums/en-US/smallbasic/thread/eaacf826-9d12-4e3c-aa10-1b2788f160a6#73c776ce-757a-45e8-b3eb-314065108a4dStendechttp://social.msdn.microsoft.com/Profile/en-US/?user=StendecPost your sample source code here and get featured on our blogs!<div style="border-right:#7f9db9 1px solid;border-top:#7f9db9 1px solid;font-size:11px;overflow:auto;border-left:#7f9db9 1px solid;line-height:100%! important;border-bottom:#7f9db9 1px solid;font-family:Courier New;background-color:white"> <table style="border-top-width:0px;border-left-width:0px;margin:2px 0px;width:99%;border-bottom:#eee 0px solid;border-collapse:collapse;background-color:#fff;border-right-width:0px" cellspacing=0 cellpadding=0> <colgroup> <col style="padding-left:10px;font-size:11px;border-bottom:#f7f7f7 1px solid;font-family:Courier New;white-space:nowrap"> <tbody> <tr> <td><font style="font-size:11px">'BrickWall  </font></td></tr> <tr> <td style="background-color:#f7f7f7">'A development of the paddle game sample.  </td></tr> <tr> <td>'Revove all the bricks to complete the game.  </td></tr> <tr> <td style="background-color:#f7f7f7">' Game over if you miss the ball.  </td></tr> <tr> <td>'You are penalised -1 each time no bricks are hit.  </td></tr> <tr> <td style="background-color:#f7f7f7">'The movement of the ball is influenced by where it hits the paddle.  </td></tr> <tr> <td>'Do not let the bricks reach the bottom of the screen.  </td></tr> <tr> <td style="background-color:#f7f7f7"> </td></tr> <tr> <td>GameStart:  </td></tr> <tr> <td style="background-color:#f7f7f7"></font><font style="color:red">paddle</font><font style="font-size:11px"> = </font><font style="color:blue">GraphicsWindow</font><font style="font-size:11px">.AddRectangle(120, 12)  </font></td></tr> <tr> <td></font><font style="color:red">ball</font><font style="font-size:11px"> = </font><font style="color:blue">GraphicsWindow</font><font style="font-size:11px">.AddEllipse(16, 16)  </font></td></tr> <tr> <td style="background-color:#f7f7f7"></font><font style="color:red">bricksLeft</font><font style="font-size:11px"> = </font><font style="color:blue">48</font><font style="font-size:11px"> </font></td></tr> <tr> <td></font><font style="color:red">brickStartY</font><font style="font-size:11px"> = </font><font style="color:blue">35</font><font style="font-size:11px"> </font></td></tr> <tr> <td style="background-color:#f7f7f7"></font><font style="color:red">hitCount</font><font style="font-size:11px"> = </font><font style="color:blue">0</font><font style="font-size:11px"> </font></td></tr> <tr> <td></font><font style="color:red">GraphicsWindow.FontSize</font><font style="font-size:11px"> = </font><font style="color:blue">14</font><font style="font-size:11px"> </font></td></tr> <tr> <td style="background-color:#f7f7f7"></font><font style="color:red">GraphicsWindow.MouseMove</font><font style="font-size:11px"> = </font><font style="color:blue">OnMouseMove</font><font style="font-size:11px"> </font></td></tr> <tr> <td> </td></tr> <tr> <td style="background-color:#f7f7f7">For </font><font style="color:red">idx</font><font style="font-size:11px"> = </font><font style="color:blue">0</font><font style="font-size:11px"> To 15  </font></td></tr> <tr> <td>  Array.SetValue(&quot;GreenBricks&quot;, idx, 1)  </td></tr> <tr> <td style="background-color:#f7f7f7">  Array.SetValue(&quot;YellowBricks&quot;, idx, 1)  </td></tr> <tr> <td>  Array.SetValue(&quot;RedBricks&quot;, idx, 1)  </td></tr> <tr> <td style="background-color:#f7f7f7">Endfor  </td></tr> <tr> <td>DrawBricks()  </td></tr> <tr> <td style="background-color:#f7f7f7"></font><font style="color:red">score</font><font style="font-size:11px"> = </font><font style="color:blue">0</font><font style="font-size:11px"> </font></td></tr> <tr> <td>PrintScore()  </td></tr> <tr> <td style="background-color:#f7f7f7"> </td></tr> <tr> <td></font><font style="color:red">gw</font><font style="font-size:11px"> = </font><font style="color:blue">GraphicsWindow</font><font style="font-size:11px">.Width  </font></td></tr> <tr> <td style="background-color:#f7f7f7"></font><font style="color:red">gh</font><font style="font-size:11px"> = </font><font style="color:blue">GraphicsWindow</font><font style="font-size:11px">.Height  </font></td></tr> <tr> <td></font><font style="color:red">y</font><font style="font-size:11px"> = </font><font style="color:blue">gh</font><font style="font-size:11px"> - 28  </font></td></tr> <tr> <td style="background-color:#f7f7f7">GraphicsWindow.MoveShape(ball, x, y)  </td></tr> <tr> <td></font><font style="color:red">deltaX</font><font style="font-size:11px"> = </font><font style="color:blue">1</font><font style="font-size:11px"> </font></td></tr> <tr> <td style="background-color:#f7f7f7"></font><font style="color:red">deltaY</font><font style="font-size:11px"> = -2  </font></td></tr> <tr> <td>Sound.PlayBellRingAndWait()  </td></tr> <tr> <td style="background-color:#f7f7f7"> </td></tr> <tr> <td>RunLoop:  </td></tr> <tr> <td style="background-color:#f7f7f7">  </font><font style="color:red">x</font><font style="font-size:11px"></font><font style="color:blue">x</font><font style="font-size:11px"> = x + deltaX  </font></td></tr> <tr> <td>  </font><font style="color:red">y</font><font style="font-size:11px"></font><font style="color:blue">y</font><font style="font-size:11px"> = y + deltaY  </font></td></tr> <tr> <td style="background-color:#f7f7f7">    </td></tr> <tr> <td>  </font><font style="color:red">gw</font><font style="font-size:11px"> = </font><font style="color:blue">GraphicsWindow</font><font style="font-size:11px">.Width  </font></td></tr> <tr> <td style="background-color:#f7f7f7">  </font><font style="color:red">gh</font><font style="font-size:11px"> = </font><font style="color:blue">GraphicsWindow</font><font style="font-size:11px">.Height  </font></td></tr> <tr> <td>  If (x </font><font style="color:blue">&gt;</font><font style="font-size:11px">= gw - 16 Or x </font><font style="color:blue">&lt;</font><font style="font-size:11px">= 0) Then  </font></td></tr> <tr> <td style="background-color:#f7f7f7">    </font><font style="color:red">deltaX</font><font style="font-size:11px"> = -deltaX  </font></td></tr> <tr> <td>  EndIf  </td></tr> <tr> <td style="background-color:#f7f7f7">  If (y </font><font style="color:blue">&lt;</font><font style="font-size:11px">= 0) Then  </font></td></tr> <tr> <td>    </font><font style="color:red">deltaY</font><font style="font-size:11px"> = -deltaY  </font></td></tr> <tr> <td style="background-color:#f7f7f7">  EndIf  </td></tr> <tr> <td>   </td></tr> <tr> <td style="background-color:#f7f7f7">  </font><font style="color:red">padX</font><font style="font-size:11px"> = </font><font style="color:blue">GraphicsWindow</font><font style="font-size:11px">.GetLeftOfShape(paddle)  </font></td></tr> <tr> <td>  If ((y </font><font style="color:blue">&gt;</font><font style="font-size:11px">= gh - 28 + 2) And x </font><font style="color:blue">&gt;</font><font style="font-size:11px">= padX And x </font><font style="color:blue">&lt;</font><font style="font-size:11px">= padX + 120) Then  </font></td></tr> <tr> <td style="background-color:#f7f7f7">    </font><font style="color:red">y</font><font style="font-size:11px"> = </font><font style="color:blue">gh</font><font style="font-size:11px"> - 28 + 2  </font></td></tr> <tr> <td>    'Sound.PlayClick()  </td></tr> <tr> <td style="background-color:#f7f7f7">    </font><font style="color:red">hitCount</font><font style="font-size:11px"></font><font style="color:blue">hitCount</font><font style="font-size:11px"> = hitCount + 1  </font></td></tr> <tr> <td>    If Math.Remainder(hitCount, 3) = 0 Then 'Move bricks downwards  </td></tr> <tr> <td style="background-color:#f7f7f7">      For </font><font style="color:red">idx</font><font style="font-size:11px"> = </font><font style="color:blue">0</font><font style="font-size:11px"> To 15  </font></td></tr> <tr> <td>        RemoveGreenBrick()  </td></tr> <tr> <td style="background-color:#f7f7f7">        RemoveYellowBrick()  </td></tr> <tr> <td>        RemoveRedBrick()  </td></tr> <tr> <td style="background-color:#f7f7f7">      Endfor  </td></tr> <tr> <td>      </font><font style="color:red">brickStartY</font><font style="font-size:11px"></font><font style="color:blue">brickStartY</font><font style="font-size:11px"> = brickStartY + 20  </font></td></tr> <tr> <td style="background-color:#f7f7f7">      DrawBricks()  </td></tr> <tr> <td>    EndIf  </td></tr> <tr> <td style="background-color:#f7f7f7">    TestRed:  </td></tr> <tr> <td>    For </font><font style="color:red">idx</font><font style="font-size:11px"> = </font><font style="color:blue">0</font><font style="font-size:11px"> To 15  </font></td></tr> <tr> <td style="background-color:#f7f7f7">      If Array.GetValue(&quot;RedBricks&quot;, idx) = 1 Then  </td></tr> <tr> <td>        If brickStartY </font><font style="color:blue">&gt;</font><font style="font-size:11px"> gh - 160 Then  </font></td></tr> <tr> <td style="background-color:#f7f7f7">          Goto EndGame  </td></tr> <tr> <td>        EndIf  </td></tr> <tr> <td style="background-color:#f7f7f7">      EndIf  </td></tr> <tr> <td>    EndFor  </td></tr> <tr> <td style="background-color:#f7f7f7">    TestYellow:  </td></tr> <tr> <td>    For </font><font style="color:red">idx</font><font style="font-size:11px"> = </font><font style="color:blue">0</font><font style="font-size:11px"> To 15  </font></td></tr> <tr> <td style="background-color:#f7f7f7">      If Array.GetValue(&quot;YellowBricks&quot;, idx) = 1 Then  </td></tr> <tr> <td>        If brickStartY </font><font style="color:blue">&gt;</font><font style="font-size:11px"> gh - 100 Then  </font></td></tr> <tr> <td style="background-color:#f7f7f7">          Goto EndGame  </td></tr> <tr> <td>        EndIf  </td></tr> <tr> <td style="background-color:#f7f7f7">      EndIf  </td></tr> <tr> <td>    EndFor  </td></tr> <tr> <td style="background-color:#f7f7f7">    TestGreen:  </td></tr> <tr> <td>    For </font><font style="color:red">idx</font><font style="font-size:11px"> = </font><font style="color:blue">0</font><font style="font-size:11px"> To 15  </font></td></tr> <tr> <td style="background-color:#f7f7f7">      If Array.GetValue(&quot;GreenBricks&quot;, idx) = 1 Then  </td></tr> <tr> <td>        If brickStartY </font><font style="color:blue">&gt;</font><font style="font-size:11px"> gh - 40 Then  </font></td></tr> <tr> <td style="background-color:#f7f7f7">          Goto EndGame  </td></tr> <tr> <td>        EndIf  </td></tr> <tr> <td style="background-color:#f7f7f7">      EndIf  </td></tr> <tr> <td>    EndFor  </td></tr> <tr> <td style="background-color:#f7f7f7">    EndTest:  </td></tr> <tr> <td>      </td></tr> <tr> <td style="background-color:#f7f7f7">    </font><font style="color:red">deltaX</font><font style="font-size:11px"></font><font style="color:blue">deltaX</font><font style="font-size:11px"> = deltaX - 2 + (x - padX) / 30  ' Add some skill  </font></td></tr> <tr> <td> </td></tr> <tr> <td style="background-color:#f7f7f7">    If </font><font style="color:red">score</font><font style="font-size:11px"> = </font><font style="color:blue">oldScore</font><font style="font-size:11px"> Then  'No bricks hit  </font></td></tr> <tr> <td>      </font><font style="color:red">score</font><font style="font-size:11px"></font><font style="color:blue">score</font><font style="font-size:11px"> = score - 1  </font></td></tr> <tr> <td style="background-color:#f7f7f7">    EndIf  </td></tr> <tr> <td>    </font><font style="color:red">oldScore</font><font style="font-size:11px"> = </font><font style="color:blue">score</font><font style="font-size:11px"> </font></td></tr> <tr> <td style="background-color:#f7f7f7">    PrintScore()  </td></tr> <tr> <td>    </font><font style="color:red">deltaY</font><font style="font-size:11px"> = -deltaY  'Change the ball direction  </font></td></tr> <tr> <td style="background-color:#f7f7f7">  EndIf  </td></tr> <tr> <td>  GraphicsWindow.MoveShape(ball, x, y)  </td></tr> <tr> <td style="background-color:#f7f7f7">  Program.Delay(5)  </td></tr> <tr> <td>    </td></tr> <tr> <td style="background-color:#f7f7f7">  ' Green Bricks  </td></tr> <tr> <td>  If y </font><font style="color:blue">&gt;</font><font style="font-size:11px"> brickStartY - 16 And y </font><font style="color:blue">&lt;</font><font style="font-size:11px"> </font><font style="font-weight:bold;color:black">brickStartY</font><font style="font-size:11px"> + 20 Then  ' y position of brick - diameter of ball  </font></td></tr> <tr> <td style="background-color:#f7f7f7">    </font><font style="color:red">idx</font><font style="font-size:11px"> = (x+8) / 40  ' Radius of ball / length of brick  </font></td></tr> <tr> <td>    </font><font style="color:red">idx</font><font style="font-size:11px"> = </font><font style="color:blue">Math</font><font style="font-size:11px">.Floor(idx) ' take integer part  </font></td></tr> <tr> <td style="background-color:#f7f7f7">    If Array.GetValue(&quot;GreenBricks&quot;, idx) = 1 Then  </td></tr> <tr> <td>      Array.SetValue(&quot;GreenBricks&quot;, idx, 0)  </td></tr> <tr> <td style="background-color:#f7f7f7">      RemoveGreenBrick()  </td></tr> <tr> <td>      Sound.PlayChime()  </td></tr> <tr> <td style="background-color:#f7f7f7">      </font><font style="color:red">bricksLeft</font><font style="font-size:11px"></font><font style="color:blue">bricksLeft</font><font style="font-size:11px"> = bricksLeft - 1  </font></td></tr> <tr> <td>      </font><font style="color:red">deltaY</font><font style="font-size:11px"> = -deltaY  'Change ball direction  </font></td></tr> <tr> <td style="background-color:#f7f7f7">      </font><font style="color:red">score</font><font style="font-size:11px"></font><font style="color:blue">score</font><font style="font-size:11px"> = score + 15  </font></td></tr> <tr> <td>      PrintScore()  </td></tr> <tr> <td style="background-color:#f7f7f7">      CheckEnd()  </td></tr> <tr> <td>    EndIf  </td></tr> <tr> <td style="background-color:#f7f7f7">  EndIf  </td></tr> <tr> <td>    </td></tr> <tr> <td style="background-color:#f7f7f7">  ' Yellow Bricks  </td></tr> <tr> <td>  If y </font><font style="color:blue">&gt;</font><font style="font-size:11px"> brickStartY + 44 And y </font><font style="color:blue">&lt;</font><font style="font-size:11px"> </font><font style="font-weight:bold;color:black">brickStartY</font><font style="font-size:11px"> + 80 Then  ' y position of brick - diameter of </font><font style="color:red">ball</font><font style="font-size:11px"> = </font><font style="color:blue">19</font><font style="font-size:11px"> </font></td></tr> <tr> <td style="background-color:#f7f7f7">    </font><font style="color:red">idx</font><font style="font-size:11px"> = (x+8) / 40  ' Radius of ball / length of brick  </font></td></tr> <tr> <td>    </font><font style="color:red">idx</font><font style="font-size:11px"> = </font><font style="color:blue">Math</font><font style="font-size:11px">.Floor(idx) ' take integer part  </font></td></tr> <tr> <td style="background-color:#f7f7f7">    If Array.GetValue(&quot;YellowBricks&quot;, idx) = 1 Then  </td></tr> <tr> <td>      Array.SetValue(&quot;YellowBricks&quot;, idx, 0)  </td></tr> <tr> <td style="background-color:#f7f7f7">      RemoveYellowBrick()  </td></tr> <tr> <td>      Sound.PlayChime()  </td></tr> <tr> <td style="background-color:#f7f7f7">      </font><font style="color:red">bricksLeft</font><font style="font-size:11px"></font><font style="color:blue">bricksLeft</font><font style="font-size:11px"> = bricksLeft - 1  </font></td></tr> <tr> <td>      </font><font style="color:red">deltaY</font><font style="font-size:11px"> = -deltaY  'Change ball direction  </font></td></tr> <tr> <td style="background-color:#f7f7f7">      </font><font style="color:red">score</font><font style="font-size:11px"></font><font style="color:blue">score</font><font style="font-size:11px"> = score + 10  </font></td></tr> <tr> <td>      PrintScore()  </td></tr> <tr> <td style="background-color:#f7f7f7">      CheckEnd()  </td></tr> <tr> <td>    EndIf  </td></tr> <tr> <td style="background-color:#f7f7f7">  EndIf  </td></tr> <tr> <td>    </td></tr> <tr> <td style="background-color:#f7f7f7">  ' Red Bricks  </td></tr> <tr> <td>  If y </font><font style="color:blue">&gt;</font><font style="font-size:11px"> brickStartY + 104 And y </font><font style="color:blue">&lt;</font><font style="font-size:11px"> </font><font style="font-weight:bold;color:black">brickStartY</font><font style="font-size:11px"> + 140 Then  ' y position of brick - diameter of </font><font style="color:red">ball</font><font style="font-size:11px"> = </font><font style="color:blue">19</font><font style="font-size:11px"> </font></td></tr> <tr> <td style="background-color:#f7f7f7">    </font><font style="color:red">idx</font><font style="font-size:11px"> = (x+8) / 40  ' Radius of ball / length of brick  </font></td></tr> <tr> <td>    </font><font style="color:red">idx</font><font style="font-size:11px"> = </font><font style="color:blue">Math</font><font style="font-size:11px">.Floor(idx) ' take integer part  </font></td></tr> <tr> <td style="background-color:#f7f7f7">    If Array.GetValue(&quot;RedBricks&quot;, idx) = 1 Then  </td></tr> <tr> <td>      Array.SetValue(&quot;RedBricks&quot;, idx, 0)  </td></tr> <tr> <td style="background-color:#f7f7f7">      RemoveRedBrick()  </td></tr> <tr> <td>      Sound.PlayChime()  </td></tr> <tr> <td style="background-color:#f7f7f7">      </font><font style="color:red">bricksLeft</font><font style="font-size:11px"></font><font style="color:blue">bricksLeft</font><font style="font-size:11px"> = bricksLeft - 1  </font></td></tr> <tr> <td>      </font><font style="color:red">deltaY</font><font style="font-size:11px"> = -deltaY  'Change ball direction  </font></td></tr> <tr> <td style="background-color:#f7f7f7">      </font><font style="color:red">score</font><font style="font-size:11px"></font><font style="color:blue">score</font><font style="font-size:11px"> = score + 5  </font></td></tr> <tr> <td>      PrintScore()  </td></tr> <tr> <td style="background-color:#f7f7f7">      CheckEnd()  </td></tr> <tr> <td>    EndIf  </td></tr> <tr> <td style="background-color:#f7f7f7">  EndIf  </td></tr> <tr> <td>    </td></tr> <tr> <td style="background-color:#f7f7f7">    </td></tr> <tr> <td>  If (y </font><font style="color:blue">&lt;</font><font style="font-size:11px"> </font><font style="font-weight:bold;color:black">gh</font><font style="font-size:11px">) Then  'Ball not reached bottom of window  </font></td></tr> <tr> <td style="background-color:#f7f7f7">    Goto RunLoop  </td></tr> <tr> <td>  EndIf    </td></tr> <tr> <td style="background-color:#f7f7f7"> </td></tr> <tr> <td>EndGame:  </td></tr> <tr> <td style="background-color:#f7f7f7">  GraphicsWindow.ShowMessage(&quot;Your score is: &quot; + score, &quot;BrickWall&quot;)  </td></tr> <tr> <td>  Program.End()  </td></tr> <tr> <td style="background-color:#f7f7f7"> </td></tr> <tr> <td>Sub OnMouseMove  </td></tr> <tr> <td style="background-color:#f7f7f7">  </font><font style="color:red">paddleX</font><font style="font-size:11px"> = </font><font style="color:blue">GraphicsWindow</font><font style="font-size:11px">.MouseX  </font></td></tr> <tr> <td>  GraphicsWindow.MoveShape(paddle, paddleX - 60, GraphicsWindow.Height - 12)  </td></tr> <tr> <td style="background-color:#f7f7f7">EndSub  </td></tr> <tr> <td> </td></tr> <tr> <td style="background-color:#f7f7f7">Sub PrintScore  </td></tr> <tr> <td>  ' Clear the score first and then draw the real score text  </td></tr> <tr> <td style="background-color:#f7f7f7">  </font><font style="color:red">GraphicsWindow.BrushColor</font><font style="font-size:11px"> = </font><font style="color:blue">&quot;White&quot;</font><font style="font-size:11px"> </font></td></tr> <tr> <td>  GraphicsWindow.FillRectangle(10, 10, 200, 20)  </td></tr> <tr> <td style="background-color:#f7f7f7">  </font><font style="color:red">GraphicsWindow.BrushColor</font><font style="font-size:11px"> = </font><font style="color:blue">&quot;Black&quot;</font><font style="font-size:11px"> </font></td></tr> <tr> <td>  GraphicsWindow.DrawText(10, 10, &quot;Score: &quot; + score)  </td></tr> <tr> <td style="background-color:#f7f7f7">EndSub  </td></tr> <tr> <td>    </td></tr> <tr> <td style="background-color:#f7f7f7">Sub DrawBricks    </td></tr> <tr> <td>  For </font><font style="color:red">idx</font><font style="font-size:11px"> = </font><font style="color:blue">0</font><font style="font-size:11px"> To 15 ' Draw bricks  </font></td></tr> <tr> <td style="background-color:#f7f7f7">    'Program.Delay(100)  </td></tr> <tr> <td>    If Array.GetValue(&quot;GreenBricks&quot;, idx) = 1 Then  </td></tr> <tr> <td style="background-color:#f7f7f7">      </font><font style="color:red">GraphicsWindow.PenColor</font><font style="font-size:11px"> = </font><font style="color:blue">&quot;Black&quot;</font><font style="font-size:11px"> </font></td></tr> <tr> <td>      </font><font style="color:red">GraphicsWindow.BrushColor</font><font style="font-size:11px"> = </font><font style="color:blue">&quot;Green&quot;</font><font style="font-size:11px"> </font></td></tr> <tr> <td style="background-color:#f7f7f7">    Else  </td></tr> <tr> <td>      </font><font style="color:red">GraphicsWindow.PenColor</font><font style="font-size:11px"> = </font><font style="color:blue">&quot;White&quot;</font><font style="font-size:11px"> </font></td></tr> <tr> <td style="background-color:#f7f7f7">      </font><font style="color:red">GraphicsWindow.BrushColor</font><font style="font-size:11px"> = </font><font style="color:blue">&quot;White&quot;</font><font style="font-size:11px"> </font></td></tr> <tr> <td>    EndIf  </td></tr> <tr> <td style="background-color:#f7f7f7">    GraphicsWindow.FillRectangle(idx * 40, brickStartY, 40, 20)  </td></tr> <tr> <td>    GraphicsWindow.DrawRectangle(idx * 40, brickStartY, 40, 20)  </td></tr> <tr> <td style="background-color:#f7f7f7"> </td></tr> <tr> <td>    </font><font style="color:red">GraphicsWindow.BrushColor</font><font style="font-size:11px"> = </font><font style="color:blue">&quot;Yellow&quot;</font><font style="font-size:11px"> </font></td></tr> <tr> <td style="background-color:#f7f7f7">    If Array.GetValue(&quot;YellowBricks&quot;, idx) = 1 Then  </td></tr> <tr> <td>      </font><font style="color:red">GraphicsWindow.PenColor</font><font style="font-size:11px"> = </font><font style="color:blue">&quot;Black&quot;</font><font style="font-size:11px"> </font></td></tr> <tr> <td style="background-color:#f7f7f7">      </font><font style="color:red">GraphicsWindow.BrushColor</font><font style="font-size:11px"> = </font><font style="color:blue">&quot;Yellow&quot;</font><font style="font-size:11px"> </font></td></tr> <tr> <td>    Else  </td></tr> <tr> <td style="background-color:#f7f7f7">      </font><font style="color:red">GraphicsWindow.PenColor</font><font style="font-size:11px"> = </font><font style="color:blue">&quot;White&quot;</font><font style="font-size:11px"> </font></td></tr> <tr> <td>      </font><font style="color:red">GraphicsWindow.BrushColor</font><font style="font-size:11px"> = </font><font style="color:blue">&quot;White&quot;</font><font style="font-size:11px"> </font></td></tr> <tr> <td style="background-color:#f7f7f7">    EndIf  </td></tr> <tr> <td>    GraphicsWindow.FillRectangle(idx * 40, brickStartY + 60, 40, 20)  </td></tr> <tr> <td style="background-color:#f7f7f7">    GraphicsWindow.DrawRectangle(idx * 40, brickStartY + 60, 40, 20)  </td></tr> <tr> <td> </td></tr> <tr> <td style="background-color:#f7f7f7">    </font><font style="color:red">GraphicsWindow.BrushColor</font><font style="font-size:11px"> = </font><font style="color:blue">&quot;Red&quot;</font><font style="font-size:11px"> </font></td></tr> <tr> <td>    If Array.GetValue(&quot;RedBricks&quot;, idx) = 1 Then  </td></tr> <tr> <td style="background-color:#f7f7f7">      </font><font style="color:red">GraphicsWindow.PenColor</font><font style="font-size:11px"> = </font><font style="color:blue">&quot;Black&quot;</font><font style="font-size:11px"> </font></td></tr> <tr> <td>      </font><font style="color:red">GraphicsWindow.BrushColor</font><font style="font-size:11px"> = </font><font style="color:blue">&quot;Red&quot;</font><font style="font-size:11px"> </font></td></tr> <tr> <td style="background-color:#f7f7f7">    Else  </td></tr> <tr> <td>      </font><font style="color:red">GraphicsWindow.PenColor</font><font style="font-size:11px"> = </font><font style="color:blue">&quot;White&quot;</font><font style="font-size:11px"> </font></td></tr> <tr> <td style="background-color:#f7f7f7">      </font><font style="color:red">GraphicsWindow.BrushColor</font><font style="font-size:11px"> = </font><font style="color:blue">&quot;White&quot;</font><font style="font-size:11px"> </font></td></tr> <tr> <td>    EndIf  </td></tr> <tr> <td style="background-color:#f7f7f7">    GraphicsWindow.FillRectangle(idx * 40, brickStartY + 120, 40, 20)  </td></tr> <tr> <td>    GraphicsWindow.DrawRectangle(idx * 40, brickStartY + 120, 40, 20)  </td></tr> <tr> <td style="background-color:#f7f7f7">  endfor  </td></tr> <tr> <td>EndSub  </td></tr> <tr> <td style="background-color:#f7f7f7"> </td></tr> <tr> <td>Sub RemoveGreenBrick  </td></tr> <tr> <td style="background-color:#f7f7f7">  </font><font style="color:red">GraphicsWindow.PenColor</font><font style="font-size:11px"> = </font><font style="color:blue">&quot;White&quot;</font><font style="font-size:11px"> </font></td></tr> <tr> <td>  </font><font style="color:red">GraphicsWindow.BrushColor</font><font style="font-size:11px"> = </font><font style="color:blue">&quot;White&quot;</font><font style="font-size:11px"> </font></td></tr> <tr> <td style="background-color:#f7f7f7">  GraphicsWindow.FillRectangle(idx * 40, brickStartY, 40, 20)  </td></tr> <tr> <td>  GraphicsWindow.DrawRectangle(idx * 40, brickStartY, 40, 20)  </td></tr> <tr> <td style="background-color:#f7f7f7">EndSub  </td></tr> <tr> <td> </td></tr> <tr> <td style="background-color:#f7f7f7">Sub RemoveYellowBrick  </td></tr> <tr> <td>  </font><font style="color:red">GraphicsWindow.PenColor</font><font style="font-size:11px"> = </font><font style="color:blue">&quot;White&quot;</font><font style="font-size:11px"> </font></td></tr> <tr> <td style="background-color:#f7f7f7">  </font><font style="color:red">GraphicsWindow.BrushColor</font><font style="font-size:11px"> = </font><font style="color:blue">&quot;White&quot;</font><font style="font-size:11px"> </font></td></tr> <tr> <td>  GraphicsWindow.FillRectangle(idx * 40, brickStartY + 60, 40, 20)  </td></tr> <tr> <td style="background-color:#f7f7f7">  GraphicsWindow.DrawRectangle(idx * 40, brickStartY + 60, 40, 20)  </td></tr> <tr> <td>EndSub  </td></tr> <tr> <td style="background-color:#f7f7f7"> </td></tr> <tr> <td>Sub RemoveRedBrick  </td></tr> <tr> <td style="background-color:#f7f7f7">  </font><font style="color:red">GraphicsWindow.PenColor</font><font style="font-size:11px"> = </font><font style="color:blue">&quot;White&quot;</font><font style="font-size:11px"> </font></td></tr> <tr> <td>  </font><font style="color:red">GraphicsWindow.BrushColor</font><font style="font-size:11px"> = </font><font style="color:blue">&quot;White&quot;</font><font style="font-size:11px"> </font></td></tr> <tr> <td style="background-color:#f7f7f7">  GraphicsWindow.FillRectangle(idx * 40, brickStartY + 120, 40, 20)  </td></tr> <tr> <td>  GraphicsWindow.DrawRectangle(idx * 40, brickStartY + 120, 40, 20)  </td></tr> <tr> <td style="background-color:#f7f7f7">EndSub  </td></tr> <tr> <td> </td></tr> <tr> <td style="background-color:#f7f7f7">Sub CheckEnd  </td></tr> <tr> <td> If </font><font style="color:red">bricksLeft</font><font style="font-size:11px"> = </font><font style="color:blue">0</font><font style="font-size:11px"> Then  </font></td></tr> <tr> <td style="background-color:#f7f7f7">   GraphicsWindow.ShowMessage(&quot;Well Done. Wall destroyed. Your score is: &quot; + score, &quot;BrickWall&quot;)  </td></tr> <tr> <td>   'Goto GameStart  </td></tr> <tr> <td style="background-color:#f7f7f7">   Program.End()  </td></tr> <tr> <td>   'Goto EndGame  </td></tr> <tr> <td style="background-color:#f7f7f7"> EndIf  </td></tr> <tr> <td>EndSub  </td></tr> <tr> <td style="background-color:#f7f7f7"> </td></tr></tbody></table></div> I developed this program from the paddle example. There is plenty of scope for improvement. For example, the click sound has been commented out. If left in a burst of noise is generated when the bricks move downwards. This needs fixing. There is plenty of code duplication for the different colours of bricks which could be streamlined.<br>There is no provision for a high score table (this could make use of a file to remember high scores between sessions).<br>The ball sometimes gets stuck going up and down on the left edge of the window.<br>The noise made when a brick is hit gets a bit annoying but it needs something. The click sound is better but then it seems wrong to use it for the paddle as well.<br>When a brick is removed, the brick to its left loses the black line on its right-hand edge.<br>The bricks are moved down the screen as the game progresses. The time taken to erase them and redraw them in the new position is visible as a slight pause. I'm sure this could be re-written to speed this up.<br>I urge beginners to have a play with this and then see what they can do to alter/improve on it. That is a useful learning exercise.<br>Unfortunately, the forum code submission insists on converting x to xx and y to yy after the RunLoop: label. Please edit these back before running.<br><br>Sat, 31 Jan 2009 20:39:41 Z2009-01-31T20:39:41Zhttp://social.msdn.microsoft.com/Forums/en-US/smallbasic/thread/eaacf826-9d12-4e3c-aa10-1b2788f160a6#ff5c5650-d537-4d9d-b6fc-e8fd22533f33http://social.msdn.microsoft.com/Forums/en-US/smallbasic/thread/eaacf826-9d12-4e3c-aa10-1b2788f160a6#ff5c5650-d537-4d9d-b6fc-e8fd22533f33Coding Cathttp://social.msdn.microsoft.com/Profile/en-US/?user=Coding%20CatPost your sample source code here and get featured on our blogs! <p class=MsoNormal>SmallBasic is brilliant. I will save the details for another forum topic, but I will say now that it solves all of the problems I have been having keeping my Intro to Programming students interested in the subject. Bravo!</p> <p class=MsoNormal> </p> <p class=MsoNormal>With that said, I offer up this little chestnut. It’s the example I use for one of our first projects. Shape iteration is based on multiples of shape sides. This ensures that the &quot;facets&quot; of the resulting shape line up. Side count is limited to ten. After that the shapes start looking like circles. And I could decide between different colors for each shape or holding the color for the entire design; so I didn’t. </p> <p class=MsoNormal> </p> <p class=MsoNormal>Keep up the good work guys.</p><p class=MsoNormal><br></p><p class=MsoNormal><div style="overflow:auto;background-color:white;line-height:100% ! important;font-family:Courier New;font-size:11px"><table style="border-width:0px;margin:2px 0px;width:99%;border-collapse:collapse;background-color:rgb(255, 255, 255)" cellpadding=0 cellspacing=0><col style="font-family:Courier New;font-size:11px;padding-left:10px;white-space:nowrap"><tbody><tr><td><font style="font-size:11px">'Small Basic &quot;SpiralGraph&quot; </font></td></tr><tr><td style="background-color:rgb(247, 247, 247)">'Author: Matthew L. Parets </td></tr><tr><td>top: </td></tr><tr><td style="background-color:rgb(247, 247, 247)"> </td></tr><tr><td><font style="color:red">sides</font><font style="font-size:11px"> = </font><font style="color:blue">Math</font><font style="font-size:11px">.GetRandomNumber(7) + 3 </font></td></tr><tr><td style="background-color:rgb(247, 247, 247)"><font style="color:red">intrMult</font><font style="font-size:11px"> = </font><font style="color:blue">Math</font><font style="font-size:11px">.GetRandomNumber(5) </font></td></tr><tr><td><font style="color:red">sidLen</font><font style="font-size:11px"> = </font><font style="color:blue">720</font><font style="font-size:11px"> / sides </font></td></tr><tr><td style="background-color:rgb(247, 247, 247)"><font style="color:red">colorDepth</font><font style="font-size:11px"> = </font><font style="color:blue">Math</font><font style="font-size:11px">.GetRandomNumber(2) </font></td></tr><tr><td> </td></tr><tr><td style="background-color:rgb(247, 247, 247)"><font style="color:red">Turtle.Speed</font><font style="font-size:11px"> = </font><font style="color:blue">10</font><font style="font-size:11px"> </font></td></tr><tr><td>if <font style="color:red">colorDepth</font><font style="font-size:11px"> = </font><font style="color:blue">1</font><font style="font-size:11px"> then </font></td></tr><tr><td style="background-color:rgb(247, 247, 247)">  <font style="color:blue">GraphicsWindow</font><font style="font-size:11px"></font><font style="color:red">GraphicsWindow.PenColor</font><font style="font-size:11px"> = GraphicsWindow.GetRandomColor() </font></td></tr><tr><td>EndIf  </td></tr><tr><td style="background-color:rgb(247, 247, 247)">For <font style="color:red">j</font><font style="font-size:11px">=</font><font style="color:blue">1</font><font style="font-size:11px"> To sides * intrMult </font></td></tr><tr><td>  if <font style="color:red">colorDepth</font><font style="font-size:11px"> = </font><font style="color:blue">2</font><font style="font-size:11px"> then </font></td></tr><tr><td style="background-color:rgb(247, 247, 247)">    <font style="color:blue">GraphicsWindow</font><font style="font-size:11px"></font><font style="color:red">GraphicsWindow.PenColor</font><font style="font-size:11px"> = GraphicsWindow.GetRandomColor() </font></td></tr><tr><td>  EndIf  </td></tr><tr><td style="background-color:rgb(247, 247, 247)">  For <font style="color:red">i</font><font style="font-size:11px">=</font><font style="color:blue">1</font><font style="font-size:11px"> To sides </font></td></tr><tr><td>    Turtle.Move(sidLen) </td></tr><tr><td style="background-color:rgb(247, 247, 247)">    Turtle.Turn(360/sides) </td></tr><tr><td>  EndFor </td></tr><tr><td style="background-color:rgb(247, 247, 247)"> </td></tr><tr><td>  Turtle.Turn(360/(sides*intrMult)) </td></tr><tr><td style="background-color:rgb(247, 247, 247)">EndFor </td></tr><tr><td> </td></tr><tr><td style="background-color:rgb(247, 247, 247)">Program.Delay(4000) </td></tr><tr><td>GraphicsWindow.Clear() </td></tr><tr><td style="background-color:rgb(247, 247, 247)"> </td></tr><tr><td>Goto top </td></tr><tr><td style="background-color:rgb(247, 247, 247)"> </td></tr><tr><td> </td></tr></tbody></table></div><br></p> Sat, 31 Jan 2009 23:59:15 Z2009-01-31T23:59:15Zhttp://social.msdn.microsoft.com/Forums/en-US/smallbasic/thread/eaacf826-9d12-4e3c-aa10-1b2788f160a6#0a0df7ad-bc85-4779-8560-e76030646db6http://social.msdn.microsoft.com/Forums/en-US/smallbasic/thread/eaacf826-9d12-4e3c-aa10-1b2788f160a6#0a0df7ad-bc85-4779-8560-e76030646db6Michael Mixhttp://social.msdn.microsoft.com/Profile/en-US/?user=Michael%20MixPost your sample source code here and get featured on our blogs!<div dir=ltr style="text-align:left">Monty Hall Paradox in Small Basic (<a href="http://en.wikipedia.org/wiki/Monty_Hall_problem">more on the paradox at Wikipedia</a>).<br> <br> <div style="overflow:auto;background-color:white;line-height:100% ! important;font-family:Courier New;font-size:11px"><table style="border-width:0px;margin:2px 0px;width:99%;border-collapse:collapse;background-color:rgb(255, 255, 255)" cellpadding=0 cellspacing=0><col style="font-family:Courier New;font-size:11px;padding-left:10px;white-space:nowrap"><tbody><tr><td><font style="font-size:11px"></font><font style="color:red">losses</font><font style="font-size:11px"> = </font><font style="color:blue">0</font><font style="font-size:11px"> </font></td></tr><tr><td style="background-color:rgb(247, 247, 247)"><font style="color:red">wins</font><font style="font-size:11px"> = </font><font style="color:blue">0</font><font style="font-size:11px"> </font></td></tr><tr><td> </td></tr><tr><td style="background-color:rgb(247, 247, 247)">For <font style="color:red">n</font><font style="font-size:11px"> = </font><font style="color:blue">0</font><font style="font-size:11px"> To 10000 </font></td></tr><tr><td>  <font style="color:red">win</font><font style="font-size:11px"> = </font><font style="color:blue">Math</font><font style="font-size:11px">.GetRandomNumber(3) </font></td></tr><tr><td style="background-color:rgb(247, 247, 247)">   </td></tr><tr><td>  For <font style="color:red">i</font><font style="font-size:11px"> = </font><font style="color:blue">1</font><font style="font-size:11px"> To 3 </font></td></tr><tr><td style="background-color:rgb(247, 247, 247)">     </td></tr><tr><td>    If <font style="color:red">win</font><font style="font-size:11px"> = i Then </font></td></tr><tr><td style="background-color:rgb(247, 247, 247)">      TextWindow.Write(&quot;1&quot; + &quot;    &quot;) </td></tr><tr><td>    Else </td></tr><tr><td style="background-color:rgb(247, 247, 247)">      TextWindow.Write(&quot;0&quot; + &quot;    &quot;) </td></tr><tr><td>    EndIf </td></tr><tr><td style="background-color:rgb(247, 247, 247)">     </td></tr><tr><td>  EndFor </td></tr><tr><td style="background-color:rgb(247, 247, 247)">   </td></tr><tr><td>  <font style="color:red">shot</font><font style="font-size:11px"> = </font><font style="color:blue">Math</font><font style="font-size:11px">.GetRandomNumber(3) </font></td></tr><tr><td style="background-color:rgb(247, 247, 247)">   </td></tr><tr><td>  TextWindow.Write(&quot;<font style="color:red">shot</font><font style="font-size:11px"> = </font><font style="color:blue">&quot; + shot + &quot;</font><font style="font-size:11px">    &quot;) </font></td></tr><tr><td style="background-color:rgb(247, 247, 247)">   </td></tr><tr><td>  If <font style="color:red">win</font><font style="font-size:11px"> = </font><font style="color:blue">shot</font><font style="font-size:11px"> Then </font></td></tr><tr><td style="background-color:rgb(247, 247, 247)">     </td></tr><tr><td>    <font style="color:red">losses</font><font style="font-size:11px"></font><font style="color:blue">losses</font><font style="font-size:11px"> = losses + 1 </font></td></tr><tr><td style="background-color:rgb(247, 247, 247)">    TextWindow.WriteLine(&quot;Loss&quot;) </td></tr><tr><td>     </td></tr><tr><td style="background-color:rgb(247, 247, 247)">  Else </td></tr><tr><td>     </td></tr><tr><td style="background-color:rgb(247, 247, 247)">    <font style="color:red">wins</font><font style="font-size:11px"></font><font style="color:blue">wins</font><font style="font-size:11px"> = wins + 1 </font></td></tr><tr><td>    TextWindow.WriteLine(&quot;Win&quot;) </td></tr><tr><td style="background-color:rgb(247, 247, 247)">     </td></tr><tr><td>  EndIf </td></tr><tr><td style="background-color:rgb(247, 247, 247)">   </td></tr><tr><td>EndFor </td></tr><tr><td style="background-color:rgb(247, 247, 247)"> </td></tr><tr><td>TextWindow.WriteLine(&quot;<font style="color:red">Losses</font><font style="font-size:11px"> = &quot; + losses) </font></td></tr><tr><td style="background-color:rgb(247, 247, 247)">TextWindow.WriteLine(&quot;<font style="color:red">Wins</font><font style="font-size:11px"> = &quot; + wins) </font></td></tr></tbody></table></div><br> </div> Mon, 02 Feb 2009 12:43:48 Z2009-02-02T12:43:48Zhttp://social.msdn.microsoft.com/Forums/en-US/smallbasic/thread/eaacf826-9d12-4e3c-aa10-1b2788f160a6#8dd5d8b3-05a9-426b-893f-e23619c4706ahttp://social.msdn.microsoft.com/Forums/en-US/smallbasic/thread/eaacf826-9d12-4e3c-aa10-1b2788f160a6#8dd5d8b3-05a9-426b-893f-e23619c4706aCoding Cathttp://social.msdn.microsoft.com/Profile/en-US/?user=Coding%20CatPost your sample source code here and get featured on our blogs!Today I offer up my latest opus. While being a hoot to write, this little app does show how environments like SmallBasic tend to encourage spaghetti code. But like it said, it was fun to write.<br><br>This program does show off a problem with the turtle graphics system. The longer the program is up, the slower it runs. After about 20 mins the pauses between movements is so long that the turtle appears to stutter.<br><br><br><div style="overflow:auto;background-color:white;line-height:100% ! important;font-family:Courier New;font-size:11px"><table style="border-width:0px;margin:2px 0px;width:99%;border-collapse:collapse;background-color:rgb(255, 255, 255)" cellpadding=0 cellspacing=0><col style="font-family:Courier New;font-size:11px;padding-left:10px;white-space:nowrap"><tbody><tr><td><font style="font-size:11px"></font><font style="color:green">'Snaking:random curving paths for our turtle friend</font><font style="font-size:11px"> </font></td></tr><tr><td style="background-color:rgb(247, 247, 247)"><font style="color:green">'author: Matthew L. Parets</font><font style="font-size:11px"> </font></td></tr><tr><td><font style="color:green">'Initalization</font><font style="font-size:11px"> </font></td></tr><tr><td style="background-color:rgb(247, 247, 247)"><font style="color:green">'************************************************************************************</font><font style="font-size:11px"> </font></td></tr><tr><td>Turtle.Speed = 10 </td></tr><tr><td style="background-color:rgb(247, 247, 247)">red = Math.GetRandomNumber(256) - 1 </td></tr><tr><td>blue = Math.GetRandomNumber(256) - 1  </td></tr><tr><td style="background-color:rgb(247, 247, 247)">green = Math.GetRandomNumber(256) - 1 </td></tr><tr><td>GraphicsWindow.PenColor = GraphicsWindow.GetColorFromRGB(red,green,blue)  </td></tr><tr><td style="background-color:rgb(247, 247, 247)">turnIntr = Math.GetRandomNumber(45) + 5 </td></tr><tr><td>turnCnt = 0 </td></tr><tr><td style="background-color:rgb(247, 247, 247)">direction = ((Math.GetRandomNumber(90)/10) - 5) </td></tr><tr><td>Turtle.Turn(Math.GetRandomNumber(360) - 1) </td></tr><tr><td style="background-color:rgb(247, 247, 247)"><font style="color:green">'Main Loop</font><font style="font-size:11px"> </font></td></tr><tr><td>top: <font style="color:green">'*******************************************************************************</font><font style="font-size:11px"> </font></td></tr><tr><td style="background-color:rgb(247, 247, 247)">red = red + (Math.GetRandomNumber(3) - 2) </td></tr><tr><td>blue = blue + (Math.GetRandomNumber(3) - 2) </td></tr><tr><td style="background-color:rgb(247, 247, 247)">green = green + (Math.GetRandomNumber(3) - 2) </td></tr><tr><td>GraphicsWindow.PenColor = GraphicsWindow.GetColorFromRGB(red,green,blue) </td></tr><tr><td style="background-color:rgb(247, 247, 247)">Turtle.Move(2) </td></tr><tr><td>turnCnt = turnCnt + 1 </td></tr><tr><td style="background-color:rgb(247, 247, 247)"><font style="color:blue">If</font><font style="font-size:11px"> turnCnt &gt;= turnIntr </font><font style="color:blue">Then</font><font style="font-size:11px"> </font></td></tr><tr><td>  direction = ((Math.GetRandomNumber(90)/10) - 5) </td></tr><tr><td style="background-color:rgb(247, 247, 247)">  if direction = 0 then </td></tr><tr><td>    maxArc = 100 </td></tr><tr><td style="background-color:rgb(247, 247, 247)">  else </td></tr><tr><td>      maxArc = 135 / math.Abs(direction) </td></tr><tr><td style="background-color:rgb(247, 247, 247)">  EndIf </td></tr><tr><td>  </td></tr><tr><td style="background-color:rgb(247, 247, 247)">  turnIntr = Math.GetRandomNumber(maxArc) </td></tr><tr><td> </td></tr><tr><td style="background-color:rgb(247, 247, 247)">  turnCnt = 0 </td></tr><tr><td>EndIf </td></tr><tr><td style="background-color:rgb(247, 247, 247)"> </td></tr><tr><td>Turtle.Turn(direction) </td></tr><tr><td style="background-color:rgb(247, 247, 247)"><font style="color:green">'Range Checking</font><font style="font-size:11px"> </font></td></tr><tr><td><font style="color:green">'*****************************************************************************************</font><font style="font-size:11px"> </font></td></tr><tr><td style="background-color:rgb(247, 247, 247)"><font style="color:blue">If</font><font style="font-size:11px"> Turtle.X &gt; GraphicsWindow.Width </font><font style="color:blue">Then</font><font style="font-size:11px"> </font></td></tr><tr><td>  Turtle.X = GraphicsWindow.Width </td></tr><tr><td style="background-color:rgb(247, 247, 247)">  <font style="color:blue">If</font><font style="font-size:11px"> Turtle.Angle &gt; 90 </font><font style="color:blue">Then</font><font style="font-size:11px"> </font></td></tr><tr><td>    Turtle.Angle = 180 </td></tr><tr><td style="background-color:rgb(247, 247, 247)">  <font style="color:blue">Else</font><font style="font-size:11px"> </font></td></tr><tr><td>    Turtle.Angle = 0 </td></tr><tr><td style="background-color:rgb(247, 247, 247)">  EndIf  </td></tr><tr><td>  direction = 0  </td></tr><tr><td style="background-color:rgb(247, 247, 247)">  turnCnt = turnIntr  </td></tr><tr><td>EndIf </td></tr><tr><td style="background-color:rgb(247, 247, 247)"> </td></tr><tr><td><font style="color:blue">If</font><font style="font-size:11px"> Turtle.X &lt; 0 </font><font style="color:blue">Then</font><font style="font-size:11px"> </font></td></tr><tr><td style="background-color:rgb(247, 247, 247)">  Turtle.X = 0 </td></tr><tr><td>  <font style="color:blue">If</font><font style="font-size:11px"> Turtle.Angle &gt; 270 </font><font style="color:blue">Then</font><font style="font-size:11px"> </font></td></tr><tr><td style="background-color:rgb(247, 247, 247)">    Turtle.Angle = 0 </td></tr><tr><td>  <font style="color:blue">Else</font><font style="font-size:11px"> </font></td></tr><tr><td style="background-color:rgb(247, 247, 247)">    Turtle.Angle = 180 </td></tr><tr><td>  EndIf  </td></tr><tr><td style="background-color:rgb(247, 247, 247)">  direction = 0   </td></tr><tr><td>  turnCnt = turnIntr  </td></tr><tr><td style="background-color:rgb(247, 247, 247)">EndIf </td></tr><tr><td> </td></tr><tr><td style="background-color:rgb(247, 247, 247)"><font style="color:blue">If</font><font style="font-size:11px"> Turtle.Y &gt; GraphicsWindow.Height </font><font style="color:blue">Then</font><font style="font-size:11px"> </font></td></tr><tr><td>  Turtle.Y = GraphicsWindow.Height </td></tr><tr><td style="background-color:rgb(247, 247, 247)">  <font style="color:blue">If</font><font style="font-size:11px"> Turtle.Angle &gt; 180 </font><font style="color:blue">Then</font><font style="font-size:11px"> </font></td></tr><tr><td>    Turtle.Angle = 270 </td></tr><tr><td style="background-color:rgb(247, 247, 247)">  <font style="color:blue">Else</font><font style="font-size:11px"> </font></td></tr><tr><td>    Turtle.Angle = 90 </td></tr><tr><td style="background-color:rgb(247, 247, 247)">  EndIf  </td></tr><tr><td>  direction = 0   </td></tr><tr><td style="background-color:rgb(247, 247, 247)">  turnCnt = turnIntr  </td></tr><tr><td>EndIf </td></tr><tr><td style="background-color:rgb(247, 247, 247)"> </td></tr><tr><td><font style="color:blue">If</font><font style="font-size:11px"> Turtle.Y &lt; 0 </font><font style="color:blue">Then</font><font style="font-size:11px"> </font></td></tr><tr><td style="background-color:rgb(247, 247, 247)">  Turtle.Y = 0 </td></tr><tr><td>  <font style="color:blue">If</font><font style="font-size:11px"> Turtle.Angle &gt; 0 </font><font style="color:blue">And</font><font style="font-size:11px"> Turtle.Angle &lt; 90 then </font></td></tr><tr><td style="background-color:rgb(247, 247, 247)">    Turtle.Angle = 90 </td></tr><tr><td>  <font style="color:blue">Else</font><font style="font-size:11px"> </font></td></tr><tr><td style="background-color:rgb(247, 247, 247)">    Turtle.Angle = 270 </td></tr><tr><td>  EndIf  </td></tr><tr><td style="background-color:rgb(247, 247, 247)">  direction = 0   </td></tr><tr><td>  turnCnt = turnIntr  </td></tr><tr><td style="background-color:rgb(247, 247, 247)">EndIf </td></tr><tr><td> </td></tr><tr><td style="background-color:rgb(247, 247, 247)">Goto top </td></tr><tr><td> </td></tr><tr><td style="background-color:rgb(247, 247, 247)"> </td></tr></tbody></table></div><br> Sun, 08 Feb 2009 21:57:59 Z2009-02-08T21:57:59Zhttp://social.msdn.microsoft.com/Forums/en-US/smallbasic/thread/eaacf826-9d12-4e3c-aa10-1b2788f160a6#58ae5ac3-1a1a-4314-9984-cdd165f567e6http://social.msdn.microsoft.com/Forums/en-US/smallbasic/thread/eaacf826-9d12-4e3c-aa10-1b2788f160a6#58ae5ac3-1a1a-4314-9984-cdd165f567e6Stendechttp://social.msdn.microsoft.com/Profile/en-US/?user=StendecPost your sample source code here and get featured on our blogs! I have updated my BrickWall example to cover the breaking changes in v0.3. If you want it it is here<br><a href="http://smallbasic.com/program/?QRQ360">http://smallbasic.com/program/?QRQ360</a>.<br>Fri, 13 Feb 2009 13:06:38 Z2009-02-13T13:06:38Zhttp://social.msdn.microsoft.com/Forums/en-US/smallbasic/thread/eaacf826-9d12-4e3c-aa10-1b2788f160a6#be9fc704-bb0a-4295-bd3c-2f39c5c7fea4http://social.msdn.microsoft.com/Forums/en-US/smallbasic/thread/eaacf826-9d12-4e3c-aa10-1b2788f160a6#be9fc704-bb0a-4295-bd3c-2f39c5c7fea4Coding Cathttp://social.msdn.microsoft.com/Profile/en-US/?user=Coding%20CatPost your sample source code here and get featured on our blogs! <p class=MsoNormal>For my next offering, I give you this recreation of an early PC app. The default text is a minor nod to my wife on Valentines weekend. While creating it, I stumbled across a little inconstancy in the graphics rendering system. The anti-aliasing for the text and the shapes leaves artifacts behind when you try to clear the text or shapes by redrawing the shape in the background color. </p> <p class=MsoNormal> </p> <p class=MsoNormal>The code can be directly imported with the import ID: HZN400</p> <p class=MsoNormal> </p> <p class=MsoNormal> <div style="overflow:auto;background-color:white;line-height:100% ! important;font-family:Courier New;font-size:11px"><table style="border-width:0px;margin:2px 0px;width:99%;border-collapse:collapse;background-color:rgb(255, 255, 255)" cellpadding=0 cellspacing=0><col style="font-family:Courier New;font-size:11px;padding-left:10px;white-space:nowrap"><tbody><tr><td><font style="font-size:11px"></font><font style="color:green">'Blimp - A remake of an early PC basic app.</font><font style="font-size:11px"> </font></td></tr><tr><td style="background-color:rgb(247, 247, 247)"><font style="color:green">'author: Matthew L. Parets</font><font style="font-size:11px"> </font></td></tr><tr><td><font style="color:green">'Initial Default Values </font><font style="font-size:11px"> </font></td></tr><tr><td style="background-color:rgb(247, 247, 247)"><font style="color:green">'************************************************************************************</font><font style="font-size:11px"> </font></td></tr><tr><td>offset = 75 </td></tr><tr><td style="background-color:rgb(247, 247, 247)">textoffset = 175 </td></tr><tr><td>blmWid = 500 </td></tr><tr><td style="background-color:rgb(247, 247, 247)">blmHei = 250 </td></tr><tr><td>steps = 8 </td></tr><tr><td style="background-color:rgb(247, 247, 247)">gap = 10 </td></tr><tr><td>centerX = GraphicsWindow.Width / 2 </td></tr><tr><td style="background-color:rgb(247, 247, 247)">centerY = GraphicsWindow.Height / 2 </td></tr><tr><td>bgColor = <font style="color:blue">&quot;lightblue&quot;</font><font style="font-size:11px"> </font></td></tr><tr><td style="background-color:rgb(247, 247, 247)">msg = <font style="color:blue">&quot;Sara and Matt...Forever!...XOXOXOXOXOXOXOXOXOXOXOXOXOXO&quot;</font><font style="font-size:11px"> </font></td></tr><tr><td> </td></tr><tr><td style="background-color:rgb(247, 247, 247)"> </td></tr><tr><td><font style="color:green">'Draw the blimp</font><font style="font-size:11px"> </font></td></tr><tr><td style="background-color:rgb(247, 247, 247)"><font style="color:green">'************************************************************************************</font><font style="font-size:11px"> </font></td></tr><tr><td>GraphicsWindow.BackgroundColor = bgColor </td></tr><tr><td style="background-color:rgb(247, 247, 247)">GraphicsWindow.BrushColor = <font style="color:blue">&quot;blue&quot;</font><font style="font-size:11px"> </font></td></tr><tr><td>GraphicsWindow.PenColor = <font style="color:blue">&quot;black&quot;</font><font style="font-size:11px"> </font></td></tr><tr><td style="background-color:rgb(247, 247, 247)">ewid = blmWid </td></tr><tr><td>ehei = blmHei </td></tr><tr><td style="background-color:rgb(247, 247, 247)"><font style="color:blue">For</font><font style="font-size:11px"> i = 1 </font><font style="color:blue">To</font><font style="font-size:11px"> steps </font></td></tr><tr><td>  GraphicsWindow.FillEllipse(centerX - (ewid/2),centerY - (ehei/2) - offset,ewid,ehei) </td></tr><tr><td style="background-color:rgb(247, 247, 247)">  GraphicsWindow.DrawEllipse(centerX - (ewid/2),centerY - (ehei/2) - offset,ewid,ehei) </td></tr><tr><td>  hg = ehei </td></tr><tr><td style="background-color:rgb(247, 247, 247)">  ehei = ehei - gap </td></tr><tr><td>  gap = gap + (gap * 0.35) </td></tr><tr><td style="background-color:rgb(247, 247, 247)">  <font style="color:blue">If</font><font style="font-size:11px"> Math.Remainder(i,2) = 0 </font><font style="color:blue">Then</font><font style="font-size:11px"> </font></td></tr><tr><td>    GraphicsWindow.BrushColor = <font style="color:blue">&quot;blue&quot;</font><font style="font-size:11px"> </font></td></tr><tr><td style="background-color:rgb(247, 247, 247)">    GraphicsWindow.PenColor = <font style="color:blue">&quot;black&quot;</font><font style="font-size:11px"> </font></td></tr><tr><td>  <font style="color:blue">Else</font><font style="font-size:11px"> </font></td></tr><tr><td style="background-color:rgb(247, 247, 247)">    GraphicsWindow.BrushColor = <font style="color:blue">&quot;yellow&quot;</font><font style="font-size:11px"> </font></td></tr><tr><td>    GraphicsWindow.PenColor = <font style="color:blue">&quot;black&quot;</font><font style="font-size:11px"> </font></td></tr><tr><td style="background-color:rgb(247, 247, 247)">  EndIf </td></tr><tr><td>EndFor </td></tr><tr><td style="background-color:rgb(247, 247, 247)"> </td></tr><tr><td><font style="color:green">'Draw the gandola</font><font style="font-size:11px"> </font></td></tr><tr><td style="background-color:rgb(247, 247, 247)"><font style="color:green">'************************************************************************************</font><font style="font-size:11px"> </font></td></tr><tr><td>GraphicsWindow.BrushColor = <font style="color:blue">&quot;brown&quot;</font><font style="font-size:11px"> </font></td></tr><tr><td style="background-color:rgb(247, 247, 247)">GraphicsWindow.FillRectangle(centerX - 75,centerY + (blmHei/2) - offset - 5,150,20) </td></tr><tr><td>GraphicsWindow.DrawRectangle(centerX - 75,centerY + (blmHei/2) - offset - 5,150,20) </td></tr><tr><td style="background-color:rgb(247, 247, 247)">GraphicsWindow.DrawLine(centerX + 75, centerY + (blmHei/2) - offset + 5,centerX + 85, centerY + (blmHei/2) - offset + 5) </td></tr><tr><td> </td></tr><tr><td style="background-color:rgb(247, 247, 247)">GraphicsWindow.BrushColor = <font style="color:blue">&quot;lightblue&quot;</font><font style="font-size:11px"> </font></td></tr><tr><td>GraphicsWindow.FillRectangle(centerX - 73,centerY + (blmHei/2) - offset - 0,15,10) </td></tr><tr><td style="background-color:rgb(247, 247, 247)">GraphicsWindow.DrawRectangle(centerX - 73,centerY + (blmHei/2) - offset - 0,15,10) </td></tr><tr><td> </td></tr><tr><td style="background-color:rgb(247, 247, 247)">GraphicsWindow.FillRectangle(centerX - 47,centerY + (blmHei/2) - offset - 0,30,10) </td></tr><tr><td>GraphicsWindow.DrawRectangle(centerX - 47,centerY + (blmHei/2) - offset - 0,30,10) </td></tr><tr><td style="background-color:rgb(247, 247, 247)"> </td></tr><tr><td>GraphicsWindow.FillRectangle(centerX - 4,centerY + (blmHei/2) - offset - 0,30,10) </td></tr><tr><td style="background-color:rgb(247, 247, 247)">GraphicsWindow.DrawRectangle(centerX - 4,centerY + (blmHei/2) - offset - 0,30,10) </td></tr><tr><td> </td></tr><tr><td style="background-color:rgb(247, 247, 247)">GraphicsWindow.FillRectangle(centerX + 38,centerY + (blmHei/2) - offset - 0,30,10) </td></tr><tr><td>GraphicsWindow.DrawRectangle(centerX + 38,centerY + (blmHei/2) - offset - 0,30,10) </td></tr><tr><td style="background-color:rgb(247, 247, 247)"> </td></tr><tr><td><font style="color:green">'Final Setup</font><font style="font-size:11px"> </font></td></tr><tr><td style="background-color:rgb(247, 247, 247)"><font style="color:green">'************************************************************************************</font><font style="font-size:11px"> </font></td></tr><tr><td>GraphicsWindow.FontName = <font style="color:blue">&quot;Courier New&quot;</font><font style="font-size:11px"> </font></td></tr><tr><td style="background-color:rgb(247, 247, 247)">GraphicsWindow.FontSize = 36 </td></tr><tr><td>sep = <font style="color:blue">&quot;..............&quot;</font><font style="font-size:11px"> </font></td></tr><tr><td style="background-color:rgb(247, 247, 247)">disp = sep + msg + sep </td></tr><tr><td>i = 1 </td></tr><tr><td style="background-color:rgb(247, 247, 247)"> </td></tr><tr><td><font style="color:green">'Main control loop</font><font style="font-size:11px"> </font></td></tr><tr><td style="background-color:rgb(247, 247, 247)"><font style="color:blue">While</font><font style="font-size:11px"> </font><font style="color:blue">&quot;true&quot;</font><font style="font-size:11px"> </font></td></tr><tr><td>  i = i + 1 </td></tr><tr><td style="background-color:rgb(247, 247, 247)">  <font style="color:blue">If</font><font style="font-size:11px"> i &gt;= Text.GetLength(disp) - Text.GetLength(sep) </font><font style="color:blue">Then</font><font style="font-size:11px"> </font></td></tr><tr><td>    i = 1 </td></tr><tr><td style="background-color:rgb(247, 247, 247)">  EndIf </td></tr><tr><td>  prt = Text.GetSubText(disp,i,text.GetLength(sep)) </td></tr><tr><td style="background-color:rgb(247, 247, 247)">  textcolor = <font style="color:blue">&quot;black&quot;</font><font style="font-size:11px"> </font></td></tr><tr><td>  DispText() </td></tr><tr><td style="background-color:rgb(247, 247, 247)">  Program.Delay(100) </td></tr><tr><td>  textcolor = <font style="color:blue">&quot;yellow&quot;</font><font style="font-size:11px"> </font></td></tr><tr><td style="background-color:rgb(247, 247, 247)">  DispText() </td></tr><tr><td>  Spin() </td></tr><tr><td style="background-color:rgb(247, 247, 247)">EndWhile </td></tr><tr><td> </td></tr><tr><td style="background-color:rgb(247, 247, 247)"> </td></tr><tr><td><font style="color:green">'Displaying marquee text on blimp</font><font style="font-size:11px"> </font></td></tr><tr><td style="background-color:rgb(247, 247, 247)"><font style="color:green">'************************************************************************************</font><font style="font-size:11px"> </font></td></tr><tr><td><font style="color:blue">Sub</font><font style="font-size:11px"> DispText </font></td></tr><tr><td style="background-color:rgb(247, 247, 247)">  GraphicsWindow.BrushColor = textcolor </td></tr><tr><td>  letpos = 24 </td></tr><tr><td style="background-color:rgb(247, 247, 247)">  <font style="color:blue">For</font><font style="font-size:11px"> j=0 </font><font style="color:blue">To</font><font style="font-size:11px"> 6 </font></td></tr><tr><td>    chr = Text.GetSubText(prt,j,1) </td></tr><tr><td style="background-color:rgb(247, 247, 247)">    fntSiz = 21 + (j * 3) </td></tr><tr><td>    GraphicsWindow.FontSize = fntSiz </td></tr><tr><td style="background-color:rgb(247, 247, 247)">    GraphicsWindow.DrawText(centerX - textoffset+(letpos),centerY - offset - ((24 + (j * 3))/2),chr) </td></tr><tr><td>    letpos = letpos + (fntsiz * 0.75) </td></tr><tr><td style="background-color:rgb(247, 247, 247)">  EndFor  </td></tr><tr><td>  <font style="color:blue">For</font><font style="font-size:11px"> j=7 </font><font style="color:blue">To</font><font style="font-size:11px"> 1 </font><font style="color:blue">Step</font><font style="font-size:11px"> -1 </font></td></tr><tr><td style="background-color:rgb(247, 247, 247)">    chr = Text.GetSubText(prt,(Text.GetLength(prt)-j),1) </td></tr><tr><td>    fntSiz = 21 + ((j - 1) * 3) </td></tr><tr><td style="background-color:rgb(247, 247, 247)">    GraphicsWindow.FontSize = fntsiz </td></tr><tr><td>    GraphicsWindow.DrawText(centerX - textoffset+(letpos),centerY - offset - ((24 + ((j - 1) * 3))/2),chr) </td></tr><tr><td style="background-color:rgb(247, 247, 247)">    letpos = letpos + (fntsiz * 0.75) </td></tr><tr><td>  EndFor  </td></tr><tr><td style="background-color:rgb(247, 247, 247)">EndSub </td></tr><tr><td> </td></tr><tr><td style="background-color:rgb(247, 247, 247)"> </td></tr><tr><td><font style="color:green">'Move the propeller</font><font style="font-size:11px"> </font></td></tr><tr><td style="background-color:rgb(247, 247, 247)"><font style="color:green">'************************************************************************************</font><font style="font-size:11px"> </font></td></tr><tr><td><font style="color:blue">Sub</font><font style="font-size:11px"> Spin </font></td></tr><tr><td style="background-color:rgb(247, 247, 247)">  GraphicsWindow.PenWidth = 0.5 </td></tr><tr><td>  <font style="color:blue">If</font><font style="font-size:11px"> spinSwitch = 0 </font><font style="color:blue">Then</font><font style="font-size:11px"> </font></td></tr><tr><td style="background-color:rgb(247, 247, 247)">    spinSwitch = 1 </td></tr><tr><td>    GraphicsWindow.BrushColor = bgColor </td></tr><tr><td style="background-color:rgb(247, 247, 247)">    GraphicsWindow.PenColor = bgColor </td></tr><tr><td>    <font style="color:green">'(centerX + 85), (centerY + (blmHei/2) - offset + 5)</font><font style="font-size:11px"> </font></td></tr><tr><td style="background-color:rgb(247, 247, 247)">    GraphicsWindow.FillTriangle((centerX + 85),(centerY + (blmHei/2) - offset + 5),(centerX + 85)-4,(centerY + (blmHei/2) - offset + 5)-9,(centerX + 85)+2,(centerY + (blmHei/2) - offset + 5)-9) </td></tr><tr><td>    GraphicsWindow.DrawTriangle((centerX + 85),(centerY + (blmHei/2) - offset + 5),(centerX + 85)-4,(centerY + (blmHei/2) - offset + 5)-9,(centerX + 85)+2,(centerY + (blmHei/2) - offset + 5)-9) </td></tr><tr><td style="background-color:rgb(247, 247, 247)">    GraphicsWindow.FillTriangle((centerX + 85),(centerY + (blmHei/2) - offset + 5),(centerX + 85)-2,(centerY + (blmHei/2) - offset + 5)+9,(centerX + 85)+4,(centerY + (blmHei/2) - offset + 5)+9) </td></tr><tr><td>    GraphicsWindow.DrawTriangle((centerX + 85),(centerY + (blmHei/2) - offset + 5),(centerX + 85)-2,(centerY + (blmHei/2) - offset + 5)+9,(centerX + 85)+4,(centerY + (blmHei/2) - offset + 5)+9) </td></tr><tr><td style="background-color:rgb(247, 247, 247)">     </td></tr><tr><td>    GraphicsWindow.BrushColor = <font style="color:blue">&quot;darkgray&quot;</font><font style="font-size:11px"> </font></td></tr><tr><td style="background-color:rgb(247, 247, 247)">    GraphicsWindow.PenColor = <font style="color:blue">&quot;black&quot;</font><font style="font-size:11px"> </font></td></tr><tr><td>    GraphicsWindow.FillTriangle((centerX + 85),(centerY + (blmHei/2) - offset + 5),(centerX + 85)-2,(centerY + (blmHei/2) - offset + 5)-9,(centerX + 85)+4,(centerY + (blmHei/2) - offset + 5)-9) </td></tr><tr><td style="background-color:rgb(247, 247, 247)">    GraphicsWindow.DrawTriangle((centerX + 85),(centerY + (blmHei/2) - offset + 5),(centerX + 85)-2,(centerY + (blmHei/2) - offset + 5)-9,(centerX + 85)+4,(centerY + (blmHei/2) - offset + 5)-9) </td></tr><tr><td>    GraphicsWindow.FillTriangle((centerX + 85),(centerY + (blmHei/2) - offset + 5),(centerX + 85)-4,(centerY + (blmHei/2) - offset + 5)+9,(centerX + 85)+2,(centerY + (blmHei/2) - offset + 5)+9) </td></tr><tr><td style="background-color:rgb(247, 247, 247)">    GraphicsWindow.DrawTriangle((centerX + 85),(centerY + (blmHei/2) - offset + 5),(centerX + 85)-4,(centerY + (blmHei/2) - offset + 5)+9,(centerX + 85)+2,(centerY + (blmHei/2) - offset + 5)+9) </td></tr><tr><td>  <font style="color:blue">Else</font><font style="font-size:11px"> </font></td></tr><tr><td style="background-color:rgb(247, 247, 247)">    spinSwitch = 0 </td></tr><tr><td>    GraphicsWindow.BrushColor = bgColor </td></tr><tr><td style="background-color:rgb(247, 247, 247)">    GraphicsWindow.PenColor = bgColor </td></tr><tr><td>    GraphicsWindow.FillTriangle((centerX + 85),(centerY + (blmHei/2) - offset + 5),(centerX + 85)-2,(centerY + (blmHei/2) - offset + 5)-9,(centerX + 85)+4,(centerY + (blmHei/2) - offset + 5)-9) </td></tr><tr><td style="background-color:rgb(247, 247, 247)">    GraphicsWindow.DrawTriangle((centerX + 85),(centerY + (blmHei/2) - offset + 5),(centerX + 85)-2,(centerY + (blmHei/2) - offset + 5)-9,(centerX + 85)+4,(centerY + (blmHei/2) - offset + 5)-9) </td></tr><tr><td>    GraphicsWindow.FillTriangle((centerX + 85),(centerY + (blmHei/2) - offset + 5),(centerX + 85)-4,(centerY + (blmHei/2) - offset + 5)+9,(centerX + 85)+2,(centerY + (blmHei/2) - offset + 5)+9) </td></tr><tr><td style="background-color:rgb(247, 247, 247)">    GraphicsWindow.DrawTriangle((centerX + 85),(centerY + (blmHei/2) - offset + 5),(centerX + 85)-4,(centerY + (blmHei/2) - offset + 5)+9,(centerX + 85)+2,(centerY + (blmHei/2) - offset + 5)+9) </td></tr><tr><td> </td></tr><tr><td style="background-color:rgb(247, 247, 247)">    GraphicsWindow.BrushColor = <font style="color:blue">&quot;darkgray&quot;</font><font style="font-size:11px"> </font></td></tr><tr><td>    GraphicsWindow.PenColor = <font style="color:blue">&quot;black&quot;</font><font style="font-size:11px"> </font></td></tr><tr><td style="background-color:rgb(247, 247, 247)">    GraphicsWindow.FillTriangle((centerX + 85),(centerY + (blmHei/2) - offset + 5),(centerX + 85)-4,(centerY + (blmHei/2) - offset + 5)-9,(centerX + 85)+2,(centerY + (blmHei/2) - offset + 5)-9) </td></tr><tr><td>    GraphicsWindow.DrawTriangle((centerX + 85),(centerY + (blmHei/2) - offset + 5),(centerX + 85)-4,(centerY + (blmHei/2) - offset + 5)-9,(centerX + 85)+2,(centerY + (blmHei/2) - offset + 5)-9) </td></tr><tr><td style="background-color:rgb(247, 247, 247)">    GraphicsWindow.FillTriangle((centerX + 85),(centerY + (blmHei/2) - offset + 5),(centerX + 85)-2,(centerY + (blmHei/2) - offset + 5)+9,(centerX + 85)+4,(centerY + (blmHei/2) - offset + 5)+9) </td></tr><tr><td>    GraphicsWindow.DrawTriangle((centerX + 85),(centerY + (blmHei/2) - offset + 5),(centerX + 85)-2,(centerY + (blmHei/2) - offset + 5)+9,(centerX + 85)+4,(centerY + (blmHei/2) - offset + 5)+9) </td></tr><tr><td style="background-color:rgb(247, 247, 247)">  EndIf </td></tr><tr><td>   </td></tr><tr><td style="background-color:rgb(247, 247, 247)">EndSub </td></tr><tr><td> </td></tr><tr><td style="background-color:rgb(247, 247, 247)"> </td></tr><tr><td>   </td></tr><tr><td style="background-color:rgb(247, 247, 247)"> </td></tr></tbody></table></div></p> <p class=MsoNormal> </p> <p class=MsoNormal> </p> <p class=MsoNormal>Next weeks submission will be my first use of the animation system for some drifting landmarks.</p> <p class=MsoNormal> </p> <p class=MsoNormal>Just out of curiosity, I did a net search and found the original source at <a href="http://cd.textfiles.com/hof91/GRAPHIC3/">http://cd.textfiles.com/hof91/GRAPHIC3/</a>. There is something magical about the internet.</p> Mon, 16 Feb 2009 01:53:16 Z2009-02-16T01:53:16Zhttp://social.msdn.microsoft.com/Forums/en-US/smallbasic/thread/eaacf826-9d12-4e3c-aa10-1b2788f160a6#bd9325fc-ef76-4a82-aeff-82c63842a818http://social.msdn.microsoft.com/Forums/en-US/smallbasic/thread/eaacf826-9d12-4e3c-aa10-1b2788f160a6#bd9325fc-ef76-4a82-aeff-82c63842a818aStudentDevhttp://social.msdn.microsoft.com/Profile/en-US/?user=aStudentDevPost your sample source code here and get featured on our blogs!<p>I made a calculator in small basic</p><p>The import code is DJD934</p><div style="overflow:auto;background-color:white;border:solid 1px #7f9db9;width:;height:;line-height:100% !important;font-family:Courier New;font-size:11px"><table cellpadding=0 cellspacing=0 style="width:99%;margin:2px 0px 2px 0px;border-collapse:collapse;border-bottom:2px solid #eee;background-color:#fff;border-width:0px"><tbody><tr><td><font style="color:blue">TextWindow.Title = &quot;Calculator&quot;<br>If (Clock.Hour &lt; 12) Then<br>  TextWindow.Write(&quot;Good morning, would you like to do a sum? (y/n) &quot;)<br>  answ = TextWindow.Read()<br>EndIf<br>If (Clock.Hour &gt; 12) Then<br>  TextWindow.Write(&quot;Good afternoon, would you like to do a sum? (y/n) &quot;)<br>  answ = TextWindow.Read()<br>EndIf<br>If (Text.StartsWith(Text.ConvertToLowerCase(answ),&quot;y&quot;)) Then<br>start:<br>TextWindow.Write(&quot;Enter the first number: &quot;)<br>num1 = TextWindow.ReadNumber()<br>TextWindow.Write(&quot;Enter the second number: &quot;)<br>num2 = TextWindow.ReadNumber()<br>TextWindow.WriteLine(&quot;1 = Addition&quot;)<br>TextWindow.WriteLine(&quot;2 = Subtraction&quot;)<br>TextWindow.WriteLine(&quot;3 = Division&quot;)<br>TextWindow.WriteLine(&quot;4 = Multiplication&quot;)<br>TextWindow.Write(&quot;What calculation would you like to do: &quot;)<br>calc = TextWindow.ReadNumber()<br>If (calc = 1) Then<br>  num3 = num1 + num2<br>  TextWindow.WriteLine(num1+ &quot;+&quot; +num2+ &quot;=&quot; +num3)<br>EndIf<br>If (calc = 2) Then<br>  num3 = num1 - num2<br>  TextWindow.WriteLine(num1+ &quot;-&quot; +num2+ &quot;=&quot; +num3)<br>EndIf<br>If (calc = 3) Then<br>  num3 = num1 / num2<br>  TextWindow.WriteLine(num1+ &quot;/&quot; +num2+ &quot;=&quot; +num3)<br>EndIf<br>If (calc = 4) Then<br>  num3 = num1 * num2<br>  TextWindow.WriteLine(num1+ &quot;*&quot; +num2+ &quot;=&quot; +num3)<br>EndIf<br>TextWindow.Write(&quot;Would you like to do another sum? (y/n) &quot;)<br>e = TextWindow.Read()<br>If (Text.StartsWith(Text.ConvertToLowerCase(e),&quot;y&quot;)) Then<br>Goto start<br>EndIf<br>EndIf<br>TextWindow.WriteLine(&quot;Goodbye&quot;)<br><br></font></td></tr><tr><td style="background-color:#F7F7F7"></td></tr><tr><td></td></tr><tr><td style="background-color:#F7F7F7"></td></tr><tr><td></td></tr><tr><td style="background-color:#F7F7F7"></td></tr><tr><td></td></tr><tr><td style="background-color:#F7F7F7"></td></tr><tr><td></td></tr><tr><td style="background-color:#F7F7F7"></td></tr><tr><td></td></tr><tr><td style="background-color:#F7F7F7"></td></tr><tr><td></td></tr><tr><td style="background-color:#F7F7F7"></td></tr><tr><td></td></tr><tr><td style="background-color:#F7F7F7"></td></tr><tr><td></td></tr><tr><td style="background-color:#F7F7F7"></td></tr><tr><td></td></tr><tr><td style="background-color:#F7F7F7"></td></tr><tr><td></td></tr><tr><td style="background-color:#F7F7F7"></td></tr><tr><td></td></tr><tr><td style="background-color:#F7F7F7"></td></tr><tr><td></td></tr><tr><td style="background-color:#F7F7F7"></td></tr><tr><td></td></tr><tr><td style="background-color:#F7F7F7"></td></tr><tr><td></td></tr><tr><td style="background-color:#F7F7F7"></td></tr><tr><td></td></tr><tr><td style="background-color:#F7F7F7"></td></tr><tr><td></td></tr><tr><td style="background-color:#F7F7F7"></td></tr><tr><td></td></tr><tr><td style="background-color:#F7F7F7"></td></tr><tr><td></td></tr></tbody></table></div>Tue, 17 Feb 2009 09:43:14 Z2009-02-17T11:12:13Zhttp://social.msdn.microsoft.com/Forums/en-US/smallbasic/thread/eaacf826-9d12-4e3c-aa10-1b2788f160a6#2fc53907-c7bf-430b-93e4-dddfdecb4ee1http://social.msdn.microsoft.com/Forums/en-US/smallbasic/thread/eaacf826-9d12-4e3c-aa10-1b2788f160a6#2fc53907-c7bf-430b-93e4-dddfdecb4ee1aStudentDevhttp://social.msdn.microsoft.com/Profile/en-US/?user=aStudentDevPost your sample source code here and get featured on our blogs!I have made a dictionary app that can save the definition to a text file name with the word that has been looked up. The import code is: CJJ955 and the web address is <a href="http://smallbasic.com/program/?CJJ955">http://smallbasic.com/program/?CJJ955</a> you'll have to uncomment the line it has automatically commented for the save function. Tue, 17 Feb 2009 20:48:05 Z2009-02-17T20:48:05Zhttp://social.msdn.microsoft.com/Forums/en-US/smallbasic/thread/eaacf826-9d12-4e3c-aa10-1b2788f160a6#f3e5e1da-922c-452c-be1f-335ec0377e5bhttp://social.msdn.microsoft.com/Forums/en-US/smallbasic/thread/eaacf826-9d12-4e3c-aa10-1b2788f160a6#f3e5e1da-922c-452c-be1f-335ec0377e5bjricestkhttp://social.msdn.microsoft.com/Profile/en-US/?user=jricestkPost your sample source code here and get featured on our blogs!Here's a Hex Dump program so you can see how all of those bytes in your programs look!<br><br>Import code is:  RBV160  <p>'HexDump</p> <p><br>'HexDump<br>Revision 1<br>'Added scroll capability because a larger file would exceed the buffer<br>'capacity in the textwindow</p> <p>'Get file path and read data to string<br>TextWindow.Write(&quot;Enter full path of file to dump: &quot;)<br>Filepath=textwindow.Read()<br>Data=File.ReadContents(Filepath)<br>TotalFileLength=text.GetLength(Data)<br>TextWindow.WriteLine(&quot;File length is &quot;+TotalFileLength+&quot; characters&quot;)</p> <p>'Make Data copy without line feeds, carriage returns and bells for text side printing<br>For Position=0 to TotalFileLength-1<br>  if Text.GetSubText(Data,Position,1)=Text.GetCharacter(10) or text.getsubtext(Data,Position,1)=text.getcharacter(13)  or text.getsubtext(Data,Position,1)=text.getcharacter(7)then<br>        DataCopy=Text.Append(DataCopy,Text.GetCharacter(46))  'Replaces with &quot;.&quot;<br>    else<br>        DataCopy=Text.Append(DataCopy,Text.GetSubText(Data,Position,1))<br>    endif<br>endfor</p> <p>For FilePosition=0 to TotalFileLength-1 Step 16<br>   If (TotalFileLength-1)-FilePosition &gt; 15 then<br>      LineLength=15  'Actually 16 because 0 is a position<br>  Else<br>     LineLength=TotalFileLength-FilePosition-1<br>  endif<br>      TextWindow.WriteLine(&quot;&quot;)  'Every other line on the screen is blank<br>      Separator=0<br>  For z = FilePosition To FilePosition+LineLength<br>     Separator=Separator+1   <br>     If Separator=9 Then <br>     TextWindow.Write(&quot;- &quot;)<br>     endif<br>  charactercode=text.GetCharacterCode(Text.GetSubText(Data,z,1))<br>  'Gets rid of FFFD character code<br>    If charactercode = 65533 then<br>       charactercode=0 <br>    endif<br>  'Start breaking characters into hex<br>  UpperHalf=math.Floor(Charactercode/16)</p> <p>  UpperHalfCopy=UpperHalf<br>  'Does upper half byte<br>  ConvertHexHigher()</p> <p><br>  'Does lower half byte<br>  UpperDecimal=UpperHalfCopy*16<br>  LowerHalf=charactercode-UpperDecimal<br>  ConvertHexLower()</p> <p>  'Write full byte + space<br>  TextWindow.Write(text.Append(UpperHalf ,LowerHalf+&quot; &quot;))<br>endfor</p> <p>'Separates the Hex side from the Decimal<br>spaces=&quot;    &quot;<br>  If Separator &lt; 9 then <br>  spaces=spaces + &quot;  &quot;  'Adds 2 spaces for missing separator<br>  endif</p> <p>For padding =0 to 16-LineLength<br>  spaces=spaces+&quot;   &quot;<br>endfor<br>TextWindow.Writeline(spaces+text.GetSubText(DataCopy,FilePosition,LineLength+1))<br>Buffercount=Buffercount+1<br>If Buffercount=150 Then<br>  TextWindow.WriteLine(&quot;Review Buffer.  Hit Enter to Continue&quot;)<br>  TextWindow.Read()<br>  Buffercount=0<br>endif<br>endfor<br>TextWindow.WriteLine(&quot;&quot;)<br>TextWindow.writeline(&quot;Text Window will close by pressing Enter&quot;)<br>TextWindow.Read()<br>Program.End()</p> <p>Sub ConvertHexHigher  'Converts upper half byte to hex format<br>If UpperHalf=10 Then<br>  UpperHalf=&quot;A&quot;<br>ElseIf UpperHalf=11 then<br>  UppereHalf=&quot;B&quot;<br>elseif UpperHalf=12 then<br>  UpperHalf=&quot;C&quot;<br>elseif UpperHalf=13 then<br>  UpperHalf=&quot;D&quot;<br>Elseif  UpperHalf=14 then <br>  UpperHalf=&quot;E&quot;<br>elseif UpperHalf=15 then<br>  UpperHalf=&quot;F&quot;<br>  EndIf<br>EndSub</p> <p>Sub ConvertHexLower  'Converts lower half byte to hex format<br>If LowerHalf=10 Then<br>  LowerHalf=&quot;A&quot;<br> ElseIf LowerHalf=11 then<br>  LowerHalf=&quot;B&quot;<br>elseif LowerHalf=12 then<br>  LowerHalf=&quot;C&quot;<br>elseif LowerHalf=13 then<br>  LowerHalf=&quot;D&quot;<br>Elseif LowerHalf=14 then <br>  LowerHalf=&quot;E&quot;<br>elseif LowerHalf=15 then<br>  LowerHalf=&quot;F&quot;<br>EndIf<br>EndSub</p>Fri, 20 Feb 2009 01:56:29 Z2009-02-21T21:34:18Zhttp://social.msdn.microsoft.com/Forums/en-US/smallbasic/thread/eaacf826-9d12-4e3c-aa10-1b2788f160a6#bf3430e7-c0ea-498e-aef9-323f29f7e1c0http://social.msdn.microsoft.com/Forums/en-US/smallbasic/thread/eaacf826-9d12-4e3c-aa10-1b2788f160a6#bf3430e7-c0ea-498e-aef9-323f29f7e1c0Shmuxelhttp://social.msdn.microsoft.com/Profile/en-US/?user=ShmuxelPost your sample source code here and get featured on our blogs!Here's a nice app to convert between USD, EUR and GBP (Based on Exchange rates of 18/2/09). Was going to add variable exchange rates and user=inputs, but i was too busy at the time<br><br><div style="overflow:auto;background-color:white;line-height:100% ! important;font-family:Courier New;font-size:11px"><table style="border-width:0px;margin:2px 0px;width:99%;border-collapse:collapse;background-color:rgb(255, 255, 255)" cellpadding=0 cellspacing=0><col style="font-family:Courier New;font-size:11px;padding-left:10px;white-space:nowrap"><tbody><tr><td><font style="font-size:11px">start: </font></td></tr><tr><td style="background-color:rgb(247, 247, 247)">TextWindow.WriteLine(<font style="color:blue">&quot;Exchange rates are based on 20/2/09&quot;</font><font style="font-size:11px">) </font></td></tr><tr><td>TextWindow.WriteLine(<font style="color:blue">&quot;1. Convert from GBP to USD&quot;</font><font style="font-size:11px">) </font></td></tr><tr><td style="background-color:rgb(247, 247, 247)">TextWindow.WriteLine(<font style="color:blue">&quot;2. Convert from USD to GBP&quot;</font><font style="font-size:11px">) </font></td></tr><tr><td>TextWindow.WriteLine(<font style="color:blue">&quot;3. Convert from GBP to EUR&quot;</font><font style="font-size:11px">) </font></td></tr><tr><td style="background-color:rgb(247, 247, 247)">TextWindow.WriteLine(<font style="color:blue">&quot;4. Convert from EUR to GBP&quot;</font><font style="font-size:11px">) </font></td></tr><tr><td>TextWindow.WriteLine(<font style="color:blue">&quot;5. Convert from EUR to USD&quot;</font><font style="font-size:11px">) </font></td></tr><tr><td style="background-color:rgb(247, 247, 247)">TextWindow.WriteLine(<font style="color:blue">&quot;6. Convert from USD to EUR&quot;</font><font style="font-size:11px">) </font></td></tr><tr><td>TextWindow.WriteLine(<font style="color:blue">&quot;7. Exit&quot;</font><font style="font-size:11px">) </font></td></tr><tr><td style="background-color:rgb(247, 247, 247)">TextWindow.Write(<font style="color:blue">&quot;Choose your selection: &quot;</font><font style="font-size:11px">) </font></td></tr><tr><td>input = TextWindow.ReadNumber() </td></tr><tr><td style="background-color:rgb(247, 247, 247)"><font style="color:blue">If</font><font style="font-size:11px"> (input = 1) </font><font style="color:blue">Then</font><font style="font-size:11px">  </font></td></tr><tr><td>  goto i1 </td></tr><tr><td style="background-color:rgb(247, 247, 247)">EndIf </td></tr><tr><td><font style="color:blue">If</font><font style="font-size:11px"> (input = 2) </font><font style="color:blue">Then</font><font style="font-size:11px">  </font></td></tr><tr><td style="background-color:rgb(247, 247, 247)">  goto i2 </td></tr><tr><td>EndIf </td></tr><tr><td style="background-color:rgb(247, 247, 247)"><font style="color:blue">If</font><font style="font-size:11px"> (input = 3) </font><font style="color:blue">Then</font><font style="font-size:11px">  </font></td></tr><tr><td>  Goto i3 </td></tr><tr><td style="background-color:rgb(247, 247, 247)">EndIf </td></tr><tr><td><font style="color:blue">If</font><font style="font-size:11px"> (input = 4) </font><font style="color:blue">Then</font><font style="font-size:11px"> </font></td></tr><tr><td style="background-color:rgb(247, 247, 247)">  Goto i4 </td></tr><tr><td>EndIf  </td></tr><tr><td style="background-color:rgb(247, 247, 247)"><font style="color:blue">If</font><font style="font-size:11px"> (input = 5) </font><font style="color:blue">Then</font><font style="font-size:11px"> </font></td></tr><tr><td>  Goto i5 </td></tr><tr><td style="background-color:rgb(247, 247, 247)">EndIf  </td></tr><tr><td>  <font style="color:blue">If</font><font style="font-size:11px"> (input = 6) </font><font style="color:blue">Then</font><font style="font-size:11px"> </font></td></tr><tr><td style="background-color:rgb(247, 247, 247)">    Goto i6 </td></tr><tr><td>EndIf </td></tr><tr><td style="background-color:rgb(247, 247, 247)">    <font style="color:blue">If</font><font style="font-size:11px"> (input = 7) </font><font style="color:blue">Then</font><font style="font-size:11px"> </font></td></tr><tr><td>    Goto i7   </td></tr><tr><td style="background-color:rgb(247, 247, 247)">  <font style="color:blue">Else</font><font style="font-size:11px">  </font></td></tr><tr><td>    TextWindow.WriteLine(<font style="color:blue">&quot;Invalid Entry - Try again!&quot;</font><font style="font-size:11px">) </font></td></tr><tr><td style="background-color:rgb(247, 247, 247)">    Program.Delay(1000) </td></tr><tr><td>   TextWindow.Clear()  </td></tr><tr><td style="background-color:rgb(247, 247, 247)">  Goto start </td></tr><tr><td>EndIf  </td></tr><tr><td style="background-color:rgb(247, 247, 247)"> </td></tr><tr><td>i1: </td></tr><tr><td style="background-color:rgb(247, 247, 247)">Program.Delay(1000) </td></tr><tr><td>TextWindow.Clear() </td></tr><tr><td style="background-color:rgb(247, 247, 247)">TextWindow.Write(<font style="color:blue">&quot;Enter amount in GBP: &quot;</font><font style="font-size:11px">) </font></td></tr><tr><td>gbpi1 = TextWindow.ReadNumber() </td></tr><tr><td style="background-color:rgb(247, 247, 247)">usdo1 = gbpi1*1.4349 </td></tr><tr><td>TextWindow.WriteLine(gbpi1 + <font style="color:blue">&quot; GBP = &quot;</font><font style="font-size:11px"> + usdo1 + </font><font style="color:blue">&quot; USD&quot;</font><font style="font-size:11px">) </font></td></tr><tr><td style="background-color:rgb(247, 247, 247)">Program.Delay(5000) </td></tr><tr><td>TextWindow.Clear() </td></tr><tr><td style="background-color:rgb(247, 247, 247)">Goto start </td></tr><tr><td> </td></tr><tr><td style="background-color:rgb(247, 247, 247)">i2: </td></tr><tr><td>Program.Delay(1000) </td></tr><tr><td style="background-color:rgb(247, 247, 247)">TextWindow.Clear() </td></tr><tr><td>TextWindow.Write(<font style="color:blue">&quot;Enter amount in USD: &quot;</font><font style="font-size:11px">) </font></td></tr><tr><td style="background-color:rgb(247, 247, 247)">usdi2 = TextWindow.ReadNumber() </td></tr><tr><td>gbpo2 = usdi2*0.6969 </td></tr><tr><td style="background-color:rgb(247, 247, 247)">TextWindow.WriteLine(usdi2 + <font style="color:blue">&quot; USD = &quot;</font><font style="font-size:11px"> + gbpo2 + </font><font style="color:blue">&quot; GBP&quot;</font><font style="font-size:11px">) </font></td></tr><tr><td>Program.Delay(5000) </td></tr><tr><td style="background-color:rgb(247, 247, 247)">TextWindow.Clear() </td></tr><tr><td>Goto start </td></tr><tr><td style="background-color:rgb(247, 247, 247)"> </td></tr><tr><td>i3: </td></tr><tr><td style="background-color:rgb(247, 247, 247)">Program.Delay(1000) </td></tr><tr><td>TextWindow.Clear() </td></tr><tr><td style="background-color:rgb(247, 247, 247)">TextWindow.Write(<font style="color:blue">&quot;Enter amount in GBP: &quot;</font><font style="font-size:11px">) </font></td></tr><tr><td>gbpi3 = TextWindow.ReadNumber() </td></tr><tr><td style="background-color:rgb(247, 247, 247)">euro3 = gbpi3*1.1335 </td></tr><tr><td>TextWindow.WriteLine(gbpi3 + <font style="color:blue">&quot; GBP = &quot;</font><font style="font-size:11px"> + euro3 + </font><font style="color:blue">&quot; EUR&quot;</font><font style="font-size:11px">) </font></td></tr><tr><td style="background-color:rgb(247, 247, 247)">Program.Delay(5000) </td></tr><tr><td>TextWindow.Clear() </td></tr><tr><td style="background-color:rgb(247, 247, 247)">Goto start </td></tr><tr><td>   </td></tr><tr><td style="background-color:rgb(247, 247, 247)">i4: </td></tr><tr><td>Program.Delay(1000) </td></tr><tr><td style="background-color:rgb(247, 247, 247)">TextWindow.Clear() </td></tr><tr><td>TextWindow.Write(<font style="color:blue">&quot;Enter amount in EUR: &quot;</font><font style="font-size:11px">) </font></td></tr><tr><td style="background-color:rgb(247, 247, 247)">euri4 = TextWindow.ReadNumber() </td></tr><tr><td>gbpo4 = gbpi3*0.8867 </td></tr><tr><td style="background-color:rgb(247, 247, 247)">TextWindow.WriteLine(euri4 + <font style="color:blue">&quot; EUR = &quot;</font><font style="font-size:11px"> + gbpo4 + </font><font style="color:blue">&quot; GBP&quot;</font><font style="font-size:11px">) </font></td></tr><tr><td>Program.Delay(5000) </td></tr><tr><td style="background-color:rgb(247, 247, 247)">TextWindow.Clear() </td></tr><tr><td>Goto start </td></tr><tr><td style="background-color:rgb(247, 247, 247)"> </td></tr><tr><td>i5: </td></tr><tr><td style="background-color:rgb(247, 247, 247)">Program.Delay(1000) </td></tr><tr><td>TextWindow.Clear() </td></tr><tr><td style="background-color:rgb(247, 247, 247)">TextWindow.Write(<font style="color:blue">&quot;Enter amount in EUR: &quot;</font><font style="font-size:11px">) </font></td></tr><tr><td>euri5 = TextWindow.ReadNumber() </td></tr><tr><td style="background-color:rgb(247, 247, 247)">usdo5 = euri5*1.2690 </td></tr><tr><td>TextWindow.WriteLine(euri5 + <font style="color:blue">&quot; EUR = &quot;</font><font style="font-size:11px"> + usdo5 + </font><font style="color:blue">&quot; USD&quot;</font><font style="font-size:11px">) </font></td></tr><tr><td style="background-color:rgb(247, 247, 247)">Program.Delay(5000) </td></tr><tr><td>TextWindow.Clear() </td></tr><tr><td style="background-color:rgb(247, 247, 247)">Goto start </td></tr><tr><td> </td></tr><tr><td style="background-color:rgb(247, 247, 247)">i6: </td></tr><tr><td>Program.Delay(1000) </td></tr><tr><td style="background-color:rgb(247, 247, 247)">TextWindow.Clear() </td></tr><tr><td>TextWindow.Write(<font style="color:blue">&quot;Enter amount in USD: &quot;</font><font style="font-size:11px">) </font></td></tr><tr><td style="background-color:rgb(247, 247, 247)">usdi6 = TextWindow.ReadNumber() </td></tr><tr><td>euro6 = usdi6*0.7870 </td></tr><tr><td style="background-color:rgb(247, 247, 247)">TextWindow.WriteLine(usdi6 + <font style="color:blue">&quot; USD = &quot;</font><font style="font-size:11px"> + euro6 + </font><font style="color:blue">&quot; EUR&quot;</font><font style="font-size:11px">) </font></td></tr><tr><td>Program.Delay(5000) </td></tr><tr><td style="background-color:rgb(247, 247, 247)">TextWindow.Clear() </td></tr><tr><td>Goto start </td></tr><tr><td style="background-color:rgb(247, 247, 247)"> </td></tr><tr><td>i7: </td></tr><tr><td style="background-color:rgb(247, 247, 247)">Program.Delay(1000) </td></tr><tr><td>TextWindow.Clear() </td></tr><tr><td style="background-color:rgb(247, 247, 247)">TextWindow.WriteLine(<font style="color:blue">&quot;Thank you for using this application&quot;</font><font style="font-size:11px">) </font></td></tr><tr><td>TextWindow.WriteLine(<font style="color:blue">&quot; &quot;</font><font style="font-size:11px">) </font></td></tr><tr><td style="background-color:rgb(247, 247, 247)">TextWindow.WriteLine(<font style="color:blue">&quot;(C)2009, Shmuxel (www.shmuxel.info)&quot;</font><font style="font-size:11px">) </font></td></tr><tr><td>TextWindow.WriteLine(<font style="color:blue">&quot; &quot;</font><font style="font-size:11px">) </font></td></tr><tr><td style="background-color:rgb(247, 247, 247)">TextWindow.WriteLine(<font style="color:blue">&quot;This Application was written on Microsoft Small Basic&quot;</font><font style="font-size:11px">) </font></td></tr><tr><td>Program.Delay(5000) </td></tr><tr><td style="background-color:rgb(247, 247, 247)">Program.<font style="color:blue">End</font><font style="font-size:11px">() </font></td></tr></tbody></table></div><br> Mon, 23 Feb 2009 17:55:33 Z2009-02-23T18:00:58Zhttp://social.msdn.microsoft.com/Forums/en-US/smallbasic/thread/eaacf826-9d12-4e3c-aa10-1b2788f160a6#8b82eed1-ef5e-41d8-8a24-89677b3869b3http://social.msdn.microsoft.com/Forums/en-US/smallbasic/thread/eaacf826-9d12-4e3c-aa10-1b2788f160a6#8b82eed1-ef5e-41d8-8a24-89677b3869b3Stendechttp://social.msdn.microsoft.com/Profile/en-US/?user=StendecPost your sample source code here and get featured on our blogs!<p>I have re-written my Brick Wall program using Shapes for the bricks instead of drawing them.<br>Despite what Vijaye said about shapes being more &quot;heavy/expensive&quot; (&quot;Adding a Shape Without it Showing in the Top Left Corner&quot; thread) the speed of the code has improved, probably due to reduced complexity at the source level. I have also taken the opportunity to add a background image and do some tweaks to the software.<br>The shapes all get added at 0,0. I decided to use this as a feature instead of regarding it as a problem. The bricks are animated to their starting positions which I think gives quite a pleasing effect.</p> <p>Import ref: HBB072</p>Tue, 24 Feb 2009 20:47:52 Z2009-02-24T20:47:52Zhttp://social.msdn.microsoft.com/Forums/en-US/smallbasic/thread/eaacf826-9d12-4e3c-aa10-1b2788f160a6#ca9dd5c0-d7f5-4422-9d16-7aca06f244f7http://social.msdn.microsoft.com/Forums/en-US/smallbasic/thread/eaacf826-9d12-4e3c-aa10-1b2788f160a6#ca9dd5c0-d7f5-4422-9d16-7aca06f244f7moonhyukhttp://social.msdn.microsoft.com/Profile/en-US/?user=moonhyukPost your sample source code here and get featured on our blogs! good job!!<hr class="sig">moonhyuk choiWed, 25 Feb 2009 19:35:59 Z2009-02-25T19:35:59Zhttp://social.msdn.microsoft.com/Forums/en-US/smallbasic/thread/eaacf826-9d12-4e3c-aa10-1b2788f160a6#fc525d2a-b7fb-4e37-a310-081792e7eec8http://social.msdn.microsoft.com/Forums/en-US/smallbasic/thread/eaacf826-9d12-4e3c-aa10-1b2788f160a6#fc525d2a-b7fb-4e37-a310-081792e7eec8Stendechttp://social.msdn.microsoft.com/Profile/en-US/?user=StendecPost your sample source code here and get featured on our blogs! Thanks moonhyuk,<br>    I now offer up a piece of &quot;op art&quot; in the spirit of Small Basic, in that it serves no purpose but it's just fun. Import &quot;Sticks&quot; from FWM281.<br>Sat, 28 Feb 2009 10:50:17 Z2009-02-28T10:50:17Zhttp://social.msdn.microsoft.com/Forums/en-US/smallbasic/thread/eaacf826-9d12-4e3c-aa10-1b2788f160a6#c714f6bd-679c-464e-9f7f-a7e4874b680chttp://social.msdn.microsoft.com/Forums/en-US/smallbasic/thread/eaacf826-9d12-4e3c-aa10-1b2788f160a6#c714f6bd-679c-464e-9f7f-a7e4874b680cjfmherokillerhttp://social.msdn.microsoft.com/Profile/en-US/?user=jfmherokillerPost your sample source code here and get featured on our blogs!<div style="border-right:#7f9db9 1px solid;border-top:#7f9db9 1px solid;font-size:11px;overflow:auto;border-left:#7f9db9 1px solid;line-height:100%! important;border-bottom:#7f9db9 1px solid;font-family:Courier New;background-color:white"> <table style="border-top-width:0px;border-left-width:0px;margin:2px 0px;width:99%;border-bottom:#eee 0px solid;border-collapse:collapse;background-color:#fff;border-right-width:0px" cellspacing=0 cellpadding=0> <colgroup> <col style="border-right:gray 1px solid;padding-right:5px;padding-left:10px;font-size:11px;vertical-align:top;width:5px;color:gray;font-family:Courier New;background-color:#eee;text-align:right"> <col style="padding-left:10px;font-size:11px;border-bottom:#f7f7f7 1px solid;font-family:Courier New;white-space:nowrap"> <tbody> <tr> <td><nobr>1</nobr></td> <td><font style="font-size:11px">music player!  </font></td></tr> <tr> <td><nobr>2</nobr></td> <td style="background-color:#f7f7f7">Sound.PlayAndWait(&quot;C:\Documents and Settings\Jordan\Desktop\New Folder\Windows XP Startup.wav&quot;)  </td></tr> <tr> <td><nobr>3</nobr></td> <td>GraphicsWindow.ShowMessage(&quot;Thank you For lisening to my small basic media player&quot;,&quot;Thank You&quot;)  </td></tr> <tr> <td><nobr>4</nobr></td> <td style="background-color:#f7f7f7">GraphicsWindow.Hide()  </td></tr> <tr> <td><nobr>5</nobr></td> <td>Sound.PlayAndWait(&quot;C:\Documents and Settings\Jordan\Desktop\New Folder\200265__Donkey_.mp3&quot;)  </td></tr> <tr> <td><nobr>6</nobr></td> <td style="background-color:#f7f7f7">GraphicsWindow.ShowMessage(&quot;now for the next song&quot;,&quot;2&quot;)  </td></tr> <tr> <td><nobr>7</nobr></td> <td>GraphicsWindow.Hide()  </td></tr> <tr> <td><nobr>8</nobr></td> <td style="background-color:#f7f7f7">Sound.PlayAndWait(&quot;C:\Documents and Settings\Jordan\Desktop\New Folder\Oh_No_Full_Length.mp3&quot;)  </td></tr> <tr> <td><nobr>9</nobr></td> <td>GraphicsWindow.ShowMessage(&quot;now for the next song&quot;,&quot;3&quot;)  </td></tr> <tr> <td><nobr>10</nobr></td> <td style="background-color:#f7f7f7">GraphicsWindow.Hide()  </td></tr> <tr> <td><nobr>11</nobr></td> <td>Program.Delay(10)  </td></tr> <tr> <td><nobr>12</nobr></td> <td style="background-color:#f7f7f7">Sound.PlayAndWait(&quot;C:\Documents and Settings\Jordan\Desktop\New Folder\alchemy[1].mp3&quot;)  </td></tr> <tr> <td><nobr>13</nobr></td> <td>GraphicsWindow.ShowMessage(&quot;now for the next song&quot;,&quot;4&quot;)  </td></tr> <tr> <td><nobr>14</nobr></td> <td style="background-color:#f7f7f7">GraphicsWindow.Hide()  </td></tr> <tr> <td><nobr>15</nobr></td> <td>Sound.PlayAndWait(&quot;C:\Documents and Settings\Jordan\Desktop\New Folder\gamestartup01.mp3&quot;)  </td></tr> <tr> <td><nobr>16</nobr></td> <td style="background-color:#f7f7f7">GraphicsWindow.ShowMessage(&quot;now for the next song&quot;,&quot;5&quot;)  </td></tr> <tr> <td><nobr>17</nobr></td> <td>GraphicsWindow.Hide()  </td></tr> <tr> <td><nobr>18</nobr></td> <td style="background-color:#f7f7f7">Sound.PlayAndWait(&quot;C:\Documents and Settings\Jordan\Desktop\New Folder\windowsv.wav&quot;)  </td></tr> <tr> <td><nobr>19</nobr></td> <td>GraphicsWindow.ShowMessage(&quot;now for the next song&quot;,&quot;6&quot;)  </td></tr> <tr> <td><nobr>20</nobr></td> <td style="background-color:#f7f7f7">GraphicsWindow.Hide()  </td></tr> <tr> <td><nobr>21</nobr></td> <td>Sound.PlayAndWait(&quot;135468_rickpwnerolledRemix.mp3&quot;)  </td></tr> <tr> <td><nobr>22</nobr></td> <td style="background-color:#f7f7f7">GraphicsWindow.ShowMessage(&quot;Thanks agian for lisening and have a nice rest of your day&quot;,&quot;THANKs agian&quot;)  </td></tr> <tr> <td><nobr>23</nobr></td> <td>GraphicsWindow.ShowMessage(&quot;oh and last thing if you use my program add your name to the give credit list&quot;,&quot;one last thing&quot; )  </td></tr> <tr> <td><nobr>24</nobr></td> <td style="background-color:#f7f7f7">GraphicsWindow.ShowMessage(&quot;this program gives credit to jfmherokiller&quot;,&quot;credit given list&quot;)  </td></tr> <tr> <td><nobr>25</nobr></td> <td>GraphicsWindow.Hide() </td></tr></tbody></table></div>this is a music player i wipped up i might not work but i also might i dont know if it will. Sun, 01 Mar 2009 09:11:18 Z2009-03-01T09:11:18Zhttp://social.msdn.microsoft.com/Forums/en-US/smallbasic/thread/eaacf826-9d12-4e3c-aa10-1b2788f160a6#bc6c1544-ce8e-493d-96be-1cb7f4f93863http://social.msdn.microsoft.com/Forums/en-US/smallbasic/thread/eaacf826-9d12-4e3c-aa10-1b2788f160a6#bc6c1544-ce8e-493d-96be-1cb7f4f93863Ronelyhttp://social.msdn.microsoft.com/Profile/en-US/?user=RonelyPost your sample source code here and get featured on our blogs! Desktop Wallpaper Change from web page contents <br><br> <div style="border-right:#7f9db9 1px solid;border-top:#7f9db9 1px solid;font-size:11px;overflow:auto;border-left:#7f9db9 1px solid;line-height:100%! important;border-bottom:#7f9db9 1px solid;font-family:Courier New;background-color:white"> <table style="border-top-width:0px;border-left-width:0px;margin:2px 0px;width:99%;border-bottom:#eee 0px solid;border-collapse:collapse;background-color:#fff;border-right-width:0px" cellspacing=0 cellpadding=0> <colgroup> <col style="padding-left:10px;font-size:11px;border-bottom:#f7f7f7 1px solid;font-family:Courier New;white-space:nowrap"> <tbody> <tr> <td><font style="font-size:11px">Main()   </font></td></tr> <tr> <td style="background-color:#f7f7f7">Program.End()  </td></tr> <tr> <td> </td></tr> <tr> <td style="background-color:#f7f7f7">Sub Main  </td></tr> <tr> <td></font><font style="color:red">PageContents</font><font style="font-size:11px">=</font><font style="color:blue">Network</font><font style="font-size:11px">.GetWebPageContents(&quot;http://www.fotocommunity.de/pc/pc/channel/2/extra/new/display&quot;)  </font></td></tr> <tr> <td style="background-color:#f7f7f7"></font><font style="color:red">TmpDir</font><font style="font-size:11px">=</font><font style="color:blue">File</font><font style="font-size:11px">.GetTemporaryFilePath()  </font></td></tr> <tr> <td>File.WriteContents(TmpDir,PageContents)  </td></tr> <tr> <td style="background-color:#f7f7f7">File.AppendContents(TmpDir,&quot;Ronely&quot;)  </td></tr> <tr> <td> </td></tr> <tr> <td style="background-color:#f7f7f7"></font><font style="color:red">i</font><font style="font-size:11px">=</font><font style="color:blue">0</font><font style="font-size:11px"> </font></td></tr> <tr> <td>While(&quot;True&quot;)  </td></tr> <tr> <td style="background-color:#f7f7f7"></font><font style="color:red">Text</font><font style="font-size:11px">=</font><font style="color:blue">File</font><font style="font-size:11px">.ReadLine(TmpDir,i)  </font></td></tr> <tr> <td></font><font style="color:red">i</font><font style="font-size:11px">=i+1  </font></td></tr> <tr> <td style="background-color:#f7f7f7"></font><font style="color:red">SubText</font><font style="font-size:11px">=Text.IsSubText(Text,&quot;http://cdn.fotocommunity.com/thumbs/&quot;)  </font></td></tr> <tr> <td>if </font><font style="color:red">SubText</font><font style="font-size:11px">=</font><font style="color:blue">&quot;true&quot;</font><font style="font-size:11px"> Then  </font></td></tr> <tr> <td style="background-color:#f7f7f7"></font><font style="color:red">Len</font><font style="font-size:11px">=</font><font style="color:blue">Text</font><font style="font-size:11px">.GetLength(Text)  </font></td></tr> <tr> <td>Goto Next  </td></tr> <tr> <td style="background-color:#f7f7f7">Endif  </td></tr> <tr> <td>Endwhile  </td></tr> <tr> <td style="background-color:#f7f7f7"> </td></tr> <tr> <td>Next:  </td></tr> <tr> <td style="background-color:#f7f7f7">For </font><font style="color:red">i</font><font style="font-size:11px">=</font><font style="color:blue">0</font><font style="font-size:11px"> To Len-1 Step 1  </font></td></tr> <tr> <td> </td></tr> <tr> <td style="background-color:#f7f7f7"></font><font style="color:red">CmpSubText</font><font style="font-size:11px"> = Text.GetSubText(Text, i, 1)  </font></td></tr> <tr> <td>   If </font><font style="color:red">CmpSubText</font><font style="font-size:11px"> = </font><font style="color:blue">&quot;d&quot;</font><font style="font-size:11px"> then  </font></td></tr> <tr> <td style="background-color:#f7f7f7">     </font><font style="color:red">CmpSubText</font><font style="font-size:11px"> = Text.GetSubText(Text, i, 2)  </font></td></tr> <tr> <td>    if </font><font style="color:red">CmpSubText</font><font style="font-size:11px"> = </font><font style="color:blue">&quot;di&quot;</font><font style="font-size:11px"> then  </font></td></tr> <tr> <td style="background-color:#f7f7f7">      </font><font style="color:red">CmpSubText</font><font style="font-size:11px"> = Text.GetSubText(Text, i, 3)  </font></td></tr> <tr> <td>     if </font><font style="color:red">CmpSubText</font><font style="font-size:11px"> = </font><font style="color:blue">&quot;dis&quot;</font><font style="font-size:11px"> then  </font></td></tr> <tr> <td style="background-color:#f7f7f7">         </font><font style="color:red">ImgName</font><font style="font-size:11px"> = </font><font style="color:blue">Text</font><font style="font-size:11px">.GetSubText(Text, i+8 , 8)  </font></td></tr> <tr> <td>         Goto Finish  </td></tr> <tr> <td style="background-color:#f7f7f7">       Endif  </td></tr> <tr> <td>    Endif  </td></tr> <tr> <td style="background-color:#f7f7f7">  Endif  </td></tr> <tr> <td>EndFor  </td></tr> <tr> <td style="background-color:#f7f7f7"> </td></tr> <tr> <td>Finish:  </td></tr> <tr> <td style="background-color:#f7f7f7">desktop.SetWallPaper(&quot;http://cdn.fotocommunity.com/photos/&quot;+ImgName+&quot;.jpg&quot;)  </td></tr> <tr> <td> </td></tr> <tr> <td style="background-color:#f7f7f7">Endsub </td></tr></tbody></table></div>Sorry for my english Thu, 12 Mar 2009 08:09:11 Z2009-03-12T08:47:14Zhttp://social.msdn.microsoft.com/Forums/en-US/smallbasic/thread/eaacf826-9d12-4e3c-aa10-1b2788f160a6#be9b035f-0a3c-4b2a-abf6-156d2c0cfc2fhttp://social.msdn.microsoft.com/Forums/en-US/smallbasic/thread/eaacf826-9d12-4e3c-aa10-1b2788f160a6#be9b035f-0a3c-4b2a-abf6-156d2c0cfc2fDanAwesomehttp://social.msdn.microsoft.com/Profile/en-US/?user=DanAwesomePost your sample source code here and get featured on our blogs!A simple yet difficult &quot;lights out&quot; style game where you try to turn all of the squares black. When you press ENTER on a square, you change its color, as well as the colors of the squares on its sides. Try it out, you'll see what I mean...<br><br><br><div style="overflow:auto;background-color:white;line-height:100% ! important;font-family:courier new;font-size:11px"> <table style="border-width:0px;margin:2px 0px;border-collapse:collapse;background-color:rgb(255, 255, 255)" cellpadding=0 cellspacing=0 height=2541 width=955> <col style="font-family:courier new;font-size:11px;padding-left:10px;white-space:nowrap"> <tbody> <tr> <td><font style="color:green">'The point of the game is to turn all of the squares black</font><font style="font-size:11px"> </font></td> </tr> <tr> <td style="background-color:rgb(247, 247, 247)"><font style="color:green">'Move with arrow keys,</font><font style="font-size:11px"> </font></td> </tr> <tr> <td><font style="color:green">'Change select square with Enter</font><font style="font-size:11px"> </font></td> </tr> <tr> <td style="background-color:rgb(247, 247, 247)"> </td> </tr> <tr> <td> </td> </tr> <tr> <td style="background-color:rgb(247, 247, 247)">GraphicsWindow.Width = 400 </td> </tr> <tr> <td>GraphicsWindow.Height = 400 </td> </tr> <tr> <td style="background-color:rgb(247, 247, 247)">GraphicsWindow.BackgroundColor = <font style="color:blue">&quot;DarkGray&quot;</font><font style="font-size:11px"> </font></td> </tr> <tr> <td>GraphicsWindow.Title = <font style="color:blue">&quot;Turn em Off&quot;</font><font style="font-size:11px"> </font></td> </tr> <tr> <td style="background-color:rgb(247, 247, 247)"> </td> </tr> <tr> <td>GraphicsWindow.KeyDown = OnKeyDown </td> </tr> <tr> <td style="background-color:rgb(247, 247, 247)"> </td> </tr> <tr> <td>GraphicsWindow.Clear() </td> </tr> <tr> <td style="background-color:rgb(247, 247, 247)"> </td> </tr> <tr> <td>curx = 10 </td> </tr> <tr> <td style="background-color:rgb(247, 247, 247)">cury = 10 </td> </tr> <tr> <td>newx = 10 </td> </tr> <tr> <td style="background-color:rgb(247, 247, 247)">newy = 10 </td> </tr> <tr> <td> </td> </tr> <tr> <td style="background-color:rgb(247, 247, 247)"><font style="color:green">'Randomize and draw squars</font><font style="font-size:11px"> </font></td> </tr> <tr> <td><font style="color:blue">For</font><font style="font-size:11px"> i=0 </font><font style="color:blue">To</font><font style="font-size:11px"> 5 </font></td> </tr> <tr> <td style="background-color:rgb(247, 247, 247)">  <font style="color:blue">For</font><font style="font-size:11px"> j=0 </font><font style="color:blue">To</font><font style="font-size:11px"> 5 </font></td> </tr> <tr> <td>    x = Math.GetRandomNumber(2) </td> </tr> <tr> <td style="background-color:rgb(247, 247, 247)">    <font style="color:blue">If</font><font style="font-size:11px"> (x = 2) </font><font style="color:blue">Then</font><font style="font-size:11px"> </font></td> </tr> <tr> <td>      curcolor = <font style="color:blue">&quot;Black&quot;</font><font style="font-size:11px"> </font></td> </tr> <tr> <td style="background-color:rgb(247, 247, 247)">    <font style="color:blue">Else</font><font style="font-size:11px"> </font></td> </tr> <tr> <td>      curcolor = <font style="color:blue">&quot;Yellow&quot;</font><font style="font-size:11px"> </font></td> </tr> <tr> <td style="background-color:rgb(247, 247, 247)">    EndIf </td> </tr> <tr> <td>    GraphicsWindow.BrushColor = curcolor </td> </tr> <tr> <td style="background-color:rgb(247, 247, 247)">    GraphicsWindow.FillRectangle(j*65+10,i*65+10,50,50) </td> </tr> <tr> <td>  EndFor </td> </tr> <tr> <td style="background-color:rgb(247, 247, 247)">EndFor </td> </tr> <tr> <td> </td> </tr> <tr> <td style="background-color:rgb(247, 247, 247)">DrawCur() </td> </tr> <tr> <td> </td> </tr> <tr> <td style="background-color:rgb(247, 247, 247)"> </td> </tr> <tr> <td><font style="color:green">'Draw currently selected square by drawing larger red square then a smaller square inside</font><font style="font-size:11px"> </font></td> </tr> <tr> <td style="background-color:rgb(247, 247, 247)"><font style="color:blue">Sub</font><font style="font-size:11px"> DrawCur </font></td> </tr> <tr> <td>  curcolor = GraphicsWindow.GetPixel(curx+25,cury+25) </td> </tr> <tr> <td style="background-color:rgb(247, 247, 247)">  GraphicsWindow.BrushColor = <font style="color:blue">&quot;Red&quot;</font><font style="font-size:11px"> </font></td> </tr> <tr> <td>  GraphicsWindow.FillRectangle(curx,cury,50,50) </td> </tr> <tr> <td style="background-color:rgb(247, 247, 247)">  GraphicsWindow.BrushColor = curcolor </td> </tr> <tr> <td>  GraphicsWindow.FillRectangle(curx+2,cury+2,46,46) </td> </tr> <tr> <td style="background-color:rgb(247, 247, 247)">EndSub </td> </tr> <tr> <td> </td> </tr> <tr> <td style="background-color:rgb(247, 247, 247)"> </td> </tr> <tr> <td> </td> </tr> <tr> <td style="background-color:rgb(247, 247, 247)"><font style="color:blue">Sub</font><font style="font-size:11px"> OnKeyDown </font></td> </tr> <tr> <td>  lkey = GraphicsWindow.LastKey </td> </tr> <tr> <td style="background-color:rgb(247, 247, 247)">   </td> </tr> <tr> <td>  <font style="color:green">'Pre-set new cursor position</font><font style="font-size:11px"> </font></td> </tr> <tr> <td style="background-color:rgb(247, 247, 247)">  <font style="color:blue">If</font><font style="font-size:11px"> (lkey = </font><font style="color:blue">&quot;Right&quot;</font><font style="font-size:11px">) </font><font style="color:blue">And</font><font style="font-size:11px"> (curx &lt; 300)  </font><font style="color:blue">Then</font><font style="font-size:11px"> </font></td> </tr> <tr> <td>    newx = curx + 65 </td> </tr> <tr> <td style="background-color:rgb(247, 247, 247)">    newy = cury </td> </tr> <tr> <td>  EndIf </td> </tr> <tr> <td style="background-color:rgb(247, 247, 247)">  <font style="color:blue">If</font><font style="font-size:11px"> (lkey = </font><font style="color:blue">&quot;Left&quot;</font><font style="font-size:11px">) </font><font style="color:blue">And</font><font style="font-size:11px"> (curx &gt; 10) </font><font style="color:blue">Then</font><font style="font-size:11px"> </font></td> </tr> <tr> <td>    newx = curx - 65 </td> </tr> <tr> <td style="background-color:rgb(247, 247, 247)">    newy = cury </td> </tr> <tr> <td>  EndIf </td> </tr> <tr> <td style="background-color:rgb(247, 247, 247)">  <font style="color:blue">If</font><font style="font-size:11px"> (lkey = </font><font style="color:blue">&quot;Down&quot;</font><font style="font-size:11px">) </font><font style="color:blue">And</font><font style="font-size:11px"> (cury &lt; 300) </font><font style="color:blue">Then</font><font style="font-size:11px"> </font></td> </tr> <tr> <td>    newx = curx </td> </tr> <tr> <td style="background-color:rgb(247, 247, 247)">    newy = cury + 65 </td> </tr> <tr> <td>  EndIf </td> </tr> <tr> <td style="background-color:rgb(247, 247, 247)">  <font style="color:blue">If</font><font style="font-size:11px"> (lkey = </font><font style="color:blue">&quot;Up&quot;</font><font style="font-size:11px">) </font><font style="color:blue">And</font><font style="font-size:11px"> (cury &gt; 10) </font><font style="color:blue">Then</font><font style="font-size:11px"> </font></td> </tr> <tr> <td>    newx = curx </td> </tr> <tr> <td style="background-color:rgb(247, 247, 247)">    newy = cury - 65 </td> </tr> <tr> <td>  EndIf </td> </tr> <tr> <td style="background-color:rgb(247, 247, 247)">   </td> </tr> <tr> <td>  <font style="color:green">'Draw square in currunt square w/o red borders and move</font><font style="font-size:11px"> </font></td> </tr> <tr> <td style="background-color:rgb(247, 247, 247)">  GraphicsWindow.BrushColor = curcolor </td> </tr> <tr> <td>  GraphicsWindow.FillRectangle(curx,cury,50,50) </td> </tr> <tr> <td style="background-color:rgb(247, 247, 247)">  curx = newx </td> </tr> <tr> <td>  cury = newy </td> </tr> <tr> <td style="background-color:rgb(247, 247, 247)">   </td> </tr> <tr> <td>  <font style="color:blue">If</font><font style="font-size:11px"> (lkey = </font><font style="color:blue">&quot;Return&quot;</font><font style="font-size:11px">) </font><font style="color:blue">Then</font><font style="font-size:11px"> </font></td> </tr> <tr> <td style="background-color:rgb(247, 247, 247)">    <font style="color:green">'Change current color</font><font style="font-size:11px"> </font></td> </tr> <tr> <td>    tempcolor = curcolor </td> </tr> <tr> <td style="background-color:rgb(247, 247, 247)">    ChangeColor() </td> </tr> <tr> <td>    GraphicsWindow.FillRectangle(curx,cury,50,50) </td> </tr> <tr> <td style="background-color:rgb(247, 247, 247)">     </td> </tr> <tr> <td>    <font style="color:green">'Change top color</font><font style="font-size:11px"> </font></td> </tr> <tr> <td style="background-color:rgb(247, 247, 247)">    <font style="color:blue">If</font><font style="font-size:11px"> (cury &gt; 10) </font><font style="color:blue">Then</font><font style="font-size:11px"> </font></td> </tr> <tr> <td>      tempcolor = GraphicsWindow.GetPixel(curx+25,cury-40) </td> </tr> <tr> <td style="background-color:rgb(247, 247, 247)">      ChangeColor() </td> </tr> <tr> <td>      GraphicsWindow.FillRectangle(curx,cury-65,50,50) </td> </tr> <tr> <td style="background-color:rgb(247, 247, 247)">    EndIf </td> </tr> <tr> <td>     </td> </tr> <tr> <td style="background-color:rgb(247, 247, 247)">    <font style="color:green">'Change left color</font><font style="font-size:11px"> </font></td> </tr> <tr> <td>    <font style="color:blue">If</font><font style="font-size:11px"> (curx &gt; 10) </font><font style="color:blue">Then</font><font style="font-size:11px"> </font></td> </tr> <tr> <td style="background-color:rgb(247, 247, 247)">      tempcolor = GraphicsWindow.GetPixel(curx-40,cury+25) </td> </tr> <tr> <td>      ChangeColor() </td> </tr> <tr> <td style="background-color:rgb(247, 247, 247)">      GraphicsWindow.FillRectangle(curx-65,cury,50,50) </td> </tr> <tr> <td>    EndIf   </td> </tr> <tr> <td style="background-color:rgb(247, 247, 247)">     </td> </tr> <tr> <td>    <font style="color:green">'Change right color</font><font style="font-size:11px"> </font></td> </tr> <tr> <td style="background-color:rgb(247, 247, 247)">    <font style="color:blue">If</font><font style="font-size:11px"> (curx &lt; 300) </font><font style="color:blue">Then</font><font style="font-size:11px"> </font></td> </tr> <tr> <td>      tempcolor = GraphicsWindow.GetPixel(curx+90,cury+25) </td> </tr> <tr> <td style="background-color:rgb(247, 247, 247)">      ChangeColor() </td> </tr> <tr> <td>      GraphicsWindow.FillRectangle(curx+65,cury,50,50) </td> </tr> <tr> <td style="background-color:rgb(247, 247, 247)">    EndIf </td> </tr> <tr> <td>     </td> </tr> <tr> <td style="background-color:rgb(247, 247, 247)">    <font style="color:green">'Change bottom color</font><font style="font-size:11px"> </font></td> </tr> <tr> <td>    <font style="color:blue">If</font><font style="font-size:11px"> (cury &lt; 300) </font><font style="color:blue">Then</font><font style="font-size:11px"> </font></td> </tr> <tr> <td style="background-color:rgb(247, 247, 247)">      tempcolor = GraphicsWindow.GetPixel(curx+25,cury+90) </td> </tr> <tr> <td>      ChangeColor() </td> </tr> <tr> <td style="background-color:rgb(247, 247, 247)">      GraphicsWindow.FillRectangle(curx,cury+65,50,50) </td> </tr> <tr> <td>    EndIf </td> </tr> <tr> <td style="background-color:rgb(247, 247, 247)">    CheckWin() </td> </tr> <tr> <td>  EndIf </td> </tr> <tr> <td style="background-color:rgb(247, 247, 247)">   </td> </tr> <tr> <td>  <font style="color:green">'Redraw currently selected square</font><font style="font-size:11px"> </font></td> </tr> <tr> <td style="background-color:rgb(247, 247, 247)">  DrawCur() </td> </tr> <tr> <td>   </td> </tr> <tr> <td style="background-color:rgb(247, 247, 247)">EndSub </td> </tr> <tr> <td> </td> </tr> <tr> <td style="background-color:rgb(247, 247, 247)"> </td> </tr> <tr> <td> </td> </tr> <tr> <td style="background-color:rgb(247, 247, 247)"><font style="color:green">'Change color from black to yellow and otherwise</font><font style="font-size:11px"> </font></td> </tr> <tr> <td><font style="color:blue">Sub</font><font style="font-size:11px"> ChangeColor </font></td> </tr> <tr> <td style="background-color:rgb(247, 247, 247)">  <font style="color:blue">If</font><font style="font-size:11px"> (tempcolor = </font><font style="color:blue">&quot;#FFFF00&quot;</font><font style="font-size:11px">) </font><font style="color:blue">Then</font><font style="font-size:11px"> </font><font style="color:green">'Yellow</font><font style="font-size:11px"> </font></td> </tr> <tr> <td>    tempcolor = <font style="color:blue">&quot;Black&quot;</font><font style="font-size:11px"> </font></td> </tr> <tr> <td style="background-color:rgb(247, 247, 247)">  <font style="color:blue">Else</font><font style="font-size:11px">   </font></td> </tr> <tr> <td>    tempcolor = <font style="color:blue">&quot;Yellow&quot;</font><font style="font-size:11px"> </font></td> </tr> <tr> <td style="background-color:rgb(247, 247, 247)">  EndIf </td> </tr> <tr> <td>  GraphicsWindow.BrushColor = tempcolor </td> </tr> <tr> <td style="background-color:rgb(247, 247, 247)">EndSub </td> </tr> <tr> <td> </td> </tr> <tr> <td style="background-color:rgb(247, 247, 247)"> </td> </tr> <tr> <td><font style="color:green">'Check all spaces for any yellow.  If not, you win and quit</font><font style="font-size:11px"> </font></td> </tr> <tr> <td style="background-color:rgb(247, 247, 247)"><font style="color:blue">Sub</font><font style="font-size:11px"> CheckWin </font></td> </tr> <tr> <td>  flagw = 0 </td> </tr> <tr> <td style="background-color:rgb(247, 247, 247)">  <font style="color:blue">For</font><font style="font-size:11px"> i=0 </font><font style="color:blue">To</font><font style="font-size:11px"> 5 </font></td> </tr> <tr> <td>    <font style="color:blue">For</font><font style="font-size:11px"> j=0 </font><font style="color:blue">To</font><font style="font-size:11px"> 5 </font></td> </tr> <tr> <td style="background-color:rgb(247, 247, 247)">      <font style="color:blue">If</font><font style="font-size:11px"> (GraphicsWindow.GetPixel(j*65+35,i*65+35) = </font><font style="color:blue">&quot;#FFFF00&quot;</font><font style="font-size:11px">) </font><font style="color:blue">Then</font><font style="font-size:11px"> </font></td> </tr> <tr> <td>        flagw = 1 </td> </tr> <tr> <td style="background-color:rgb(247, 247, 247)">      EndIf </td> </tr> <tr> <td>    EndFor </td> </tr> <tr> <td style="background-color:rgb(247, 247, 247)">  EndFor </td> </tr> <tr> <td>  <font style="color:blue">If</font><font style="font-size:11px"> (flagw = 0) </font><font style="color:blue">Then</font><font style="font-size:11px"> </font></td> </tr> <tr> <td style="background-color:rgb(247, 247, 247)">    GraphicsWindow.ShowMessage(<font style="color:blue">&quot;YOU WIN!&quot;</font><font style="font-size:11px">,</font><font style="color:blue">&quot;WINNER&quot;</font><font style="font-size:11px">) </font></td> </tr> <tr> <td>    Program.<font style="color:blue">End</font><font style="font-size:11px">() </font></td> </tr> <tr> <td style="background-color:rgb(247, 247, 247)">  EndIf </td> </tr> <tr> <td>EndSub </td> </tr> </tbody> </table> </div> <br><br>Good luck, it IS possible to beat.  Oh, and thanks for small basic!<span style="background:gray none repeat scroll 0% 0%;overflow:auto ! important;left:0px;top:0px;width:5px;height:100%;z-index:10000000;font-weight:bold ! important;font-size:medium ! important;font-style:normal ! important"></span>Fri, 27 Mar 2009 22:03:49 Z2009-03-27T22:03:49Zhttp://social.msdn.microsoft.com/Forums/en-US/smallbasic/thread/eaacf826-9d12-4e3c-aa10-1b2788f160a6#b6bc4f45-5165-4e00-93a9-4550331ca929http://social.msdn.microsoft.com/Forums/en-US/smallbasic/thread/eaacf826-9d12-4e3c-aa10-1b2788f160a6#b6bc4f45-5165-4e00-93a9-4550331ca929Vijaye Rajihttp://social.msdn.microsoft.com/Profile/en-US/?user=Vijaye%20RajiPost your sample source code here and get featured on our blogs! &quot;Lights Out&quot; is our sample of the week:  <a href="http://blogs.msdn.com/smallbasic">http://blogs.msdn.com/smallbasic</a> <br>Sat, 28 Mar 2009 00:16:17 Z2009-03-28T00:16:17Zhttp://social.msdn.microsoft.com/Forums/en-US/smallbasic/thread/eaacf826-9d12-4e3c-aa10-1b2788f160a6#33b4765a-c9a2-4f2c-bbfc-6e3a15309c99http://social.msdn.microsoft.com/Forums/en-US/smallbasic/thread/eaacf826-9d12-4e3c-aa10-1b2788f160a6#33b4765a-c9a2-4f2c-bbfc-6e3a15309c99Wolfy87ochttp://social.msdn.microsoft.com/Profile/en-US/?user=Wolfy87ocPost your sample source code here and get featured on our blogs!I know you have already chosen your program for the blog but heres mine anyway, its just a simple etch a scetch although dose draw at a bit of an angle =D<br/> <pre lang=x-vbnet>'My first SB app, not my first VB one though ;) 'Learnt all of this syntax from all of you =D thankyou! 'By Oliver Caldwell, 15, VB and SB rule! 'And this runs off my memory stick...code in school =) posx = GraphicsWindow.Width / 2 posy = GraphicsWindow.Height / 2 Switch1 = False GraphicsWindow.Show() GraphicsWindow.Title = &quot;Etch a scetch!&quot; GraphicsWindow.Width = 1000 GraphicsWindow.Height = 700 GraphicsWindow.Left = 20 GraphicsWindow.Top = 20 GraphicsWindow.BackgroundColor = &quot;Red&quot; GraphicsWindow.BrushColor = &quot;Gray&quot; GraphicsWindow.FillRectangle(20, 20, 960, 660) GraphicsWindow.BrushColor = &quot;White&quot; GraphicsWindow.FillEllipse(10, 650, 100, 100) GraphicsWindow.FillEllipse(890, 650, 100, 100) GraphicsWindow.BrushColor = &quot;Black&quot; GraphicsWindow.MouseDown = MouseDown GraphicsWindow.MouseUp = MouseUp GraphicsWindow.MouseMove = OnMouseMove Sub MouseDown Switch1 = &quot;True&quot; EndSub Sub MouseUp Switch1 = &quot;False&quot; EndSub Sub OnMouseMove If Mouse.MouseX &gt; posx And Switch1 = &quot;True&quot; Then posx = posx + 1 GraphicsWindow.FillRectangle(posx, posy, 1, 1) ElseIf Mouse.MouseX &lt; posx And Switch1 = &quot;True&quot; Then posx = posx - 1 GraphicsWindow.FillRectangle(posx, posy, 1, 1) EndIf If Mouse.MouseY &gt; posy And Switch1 = &quot;True&quot; Then posy = posy + 1 GraphicsWindow.FillRectangle(posx, posy, 1, 1) ElseIf Mouse.MouseY &lt; posy And Switch1 = &quot;True&quot; Then posy = posy - 1 GraphicsWindow.FillRectangle(posx, posy, 1, 1) Endif EndSub</pre> <br/> Heres a screen shot: <br/> <img src="http://www.flowwebdesign.co.uk/image/screenshotsb.bmp" alt=Screenshot height="20%"> <br/> Have fun ;) Wolfy87oc.Mon, 30 Mar 2009 18:46:36 Z2009-03-30T18:54:57Zhttp://social.msdn.microsoft.com/Forums/en-US/smallbasic/thread/eaacf826-9d12-4e3c-aa10-1b2788f160a6#53f8404f-1d8b-4c87-ab0e-c070a70b9679http://social.msdn.microsoft.com/Forums/en-US/smallbasic/thread/eaacf826-9d12-4e3c-aa10-1b2788f160a6#53f8404f-1d8b-4c87-ab0e-c070a70b9679Nino Carrillohttp://social.msdn.microsoft.com/Profile/en-US/?user=Nino%20CarrilloPost your sample source code here and get featured on our blogs!<p>I've written an extension that makes the serial port usable in Small Basic.  It can be downloaded at <a href="http://code.msdn.microsoft.com/sbserial">http://code.msdn.microsoft.com/sbserial</a>.<br/><br/>In the spirit of Small Basic, the extension purposefully makes assumptions about data bits, parity and stop bits.  Flow control defaults to None, but hardware flow control can be activated if needed.  There is no error handling, but (some) parameters passed to the extension are checked for validity and ignored if invalid.  If the extension fails to find the comm port specified in OpenPort, the highest numbered port available is opened.<br/><br/>Example SB code to use with a serial loopback cable: SNL137<br/><br/>' Example code for use with the SmallBasicSerialPort extension and a loopback <br/>' serial cable.<br/>' Replace &quot;COM8&quot;, 75000 with settings appropriate for your system.<br/>' Nino Carrillo 2009</p> <p>CommPort.OpenPort(&quot;COM8&quot;,75000) 'Open COM8 at 75000 baud<br/>CommPort.TXString(&quot;Hello World&quot;) 'Send a string to the port<br/>CommPort.TXByte(10) 'Send linefeed<br/>CommPort.TXByte(13) 'Send carriage return<br/>Program.Delay(500) 'wait for buffers to fill<br/>TextWindow.Write(CommPort.RXAll()) 'read the entire contents of the receive buffer and display<br/>CommPort.TXString(&quot;A&quot;) 'send the letter A<br/>Program.Delay(500)<br/>TextWindow.Write(&quot;The value of the received byte is: &quot; + CommPort.RXByte())<br/>CommPort.TXByte(10) 'Send linefeed<br/>CommPort.TXByte(13) 'Send carriage return<br/>Program.Delay(500)<br/>TextWindow.Write(CommPort.RXAll())<br/>CommPort.TXString(&quot;A&quot;)<br/>TextWindow.Write(&quot;The character received is: &quot;+ CommPort.RXChar())<br/>CommPort.TXByte(10) 'Send linefeed<br/>CommPort.TXByte(13) 'Send carriage return<br/>Program.Delay(500)<br/>TextWindow.Write(CommPort.RXAll())<br/>CommPort.ClosePort()<br/>TextWindow.Write(&quot;List of ports available: &quot; + CommPort.AvailablePorts())</p>Thu, 02 Apr 2009 20:46:10 Z2009-04-02T20:46:10Zhttp://social.msdn.microsoft.com/Forums/en-US/smallbasic/thread/eaacf826-9d12-4e3c-aa10-1b2788f160a6#5292bbf2-f1d9-4756-a3f0-03b3721c0365http://social.msdn.microsoft.com/Forums/en-US/smallbasic/thread/eaacf826-9d12-4e3c-aa10-1b2788f160a6#5292bbf2-f1d9-4756-a3f0-03b3721c0365The Hackerhttp://social.msdn.microsoft.com/Profile/en-US/?user=The%20HackerPost your sample source code here and get featured on our blogs!<p>This is Login/Laod program, save program coming soon. This is just a small EX:<br/></p> <pre lang=x-aspx>T = 5 F = File.GetTemporaryFilePath() TextWindow.WriteLine(&quot;Welcome to the land of Ncioah&quot;) TextWindow.WriteLine(&quot;Are you a new or old user?&quot;) R = TextWindow.Read() If(R = &quot;new&quot;)Then TextWindow.Hide() TextWindow.Show() TextWindow.WriteLine(&quot;Signup Sheet&quot;) TextWindow.Write(&quot;Username:&quot;) Y = TextWindow.Read() TextWindow.WriteLine(&quot;Password:&quot;) X = TextWindow.Read() File.WriteContents(F, Y + &quot; &quot; + X) C = File.ReadContents(F) Textwindow.WriteLine(&quot;Please login&quot;) Goto start EndIf If(R = &quot;old&quot;)Then Start: If(T = &quot;0&quot;)Then Program.End() EndIf TextWindow.WriteLine(&quot;Username&quot;) RR = TextWindow.Read() TextWindow.WriteLine(&quot;Password&quot;) RRR = TextWindow.Read() RRRR = File.ReadContents(F) If(Text.IsSubText(RRRR, RR + &quot; &quot; + RRR))Then TextWindow.WriteLine(&quot;You have succesfully logged in&quot;) Else T = T-1 TextWindow.WriteLine(&quot;Login Failed &quot; + T + &quot; tries left&quot;) Goto Start EndIf EndIf</pre> <p>Try it and tell me what you think. This can be used for like mario style games. Or maybe you suddenly have to stop pong but you were doing so good. This will help that.</p> <p> </p> <p> </p>Tue, 14 Apr 2009 03:33:16 Z2009-04-14T03:34:05Zhttp://social.msdn.microsoft.com/Forums/en-US/smallbasic/thread/eaacf826-9d12-4e3c-aa10-1b2788f160a6#527bbdeb-641a-472d-9954-0759825a52e1http://social.msdn.microsoft.com/Forums/en-US/smallbasic/thread/eaacf826-9d12-4e3c-aa10-1b2788f160a6#527bbdeb-641a-472d-9954-0759825a52e1Live4Themhttp://social.msdn.microsoft.com/Profile/en-US/?user=Live4ThemPost your sample source code here and get featured on our blogs!<p>Here is my Color Script. The turtle paints a pretty picture in my opinion! Enjoy!<br/><br/>GraphicsWindow.KeyDown = K<br/>GraphicsWindow.Show()<br/>GraphicsWindow.PenColor = &quot;black&quot;<br/>GraphicsWindow.BackgroundColor = &quot;blue&quot;<br/>Turtle.Speed =  10<br/>angle = 12343<br/>Squiral()</p> <p><br/>Sub Squiral<br/>  side = 0<br/>  For i = 1 To 360<br/>    Turtle.Move(side)<br/>    Turtle.Turn(angle)<br/>    side = side + 1<br/>    <br/>  EndFor<br/>EndSub</p> <p><br/>Program.Delay(10)</p> <p>Sub K<br/>  If(GraphicsWindow.LastKey = &quot;F1&quot;)Then<br/>    Program.End()<br/>  EndIf<br/>  EndSub<br/><br/><br/><strong>If you tamper around with the angle you find that the figure changes drastically. It is sure to come up with many more shapes and excitment!!!    By: Jacob<br/><br/><br/><br/></strong></p>Fri, 17 Apr 2009 07:06:20 Z2009-04-17T07:06:20Zhttp://social.msdn.microsoft.com/Forums/en-US/smallbasic/thread/eaacf826-9d12-4e3c-aa10-1b2788f160a6#32b86d15-6406-4b66-8b4b-7d2b8a6d5c9dhttp://social.msdn.microsoft.com/Forums/en-US/smallbasic/thread/eaacf826-9d12-4e3c-aa10-1b2788f160a6#32b86d15-6406-4b66-8b4b-7d2b8a6d5c9dThe Hackerhttp://social.msdn.microsoft.com/Profile/en-US/?user=The%20HackerPost your sample source code here and get featured on our blogs!This is V1.0 of a Paint program I am working on. This program uses the GraphicsWindow as the workspace, and the TextWindow as the command reader. Type in commands in the textwindow to change the tools in the GraphicsWindow, most of the commands are listed in the Help section. Select the graphicsWindow and press H for most of the commands.<br/><br/><br/> <div style="color:black;background-color:white"> <pre>GraphicsWindow.Title = &quot;Paint V1.0&quot; TextWindow.Title = &quot;Command reader for Paint V1.0&quot; OH = GraphicsWindow.Height OW = GraphicsWindow.Width GraphicsWindow.Height = OH GraphicsWindow.Width = OW GraphicsWindow.MouseMove = OnMouseMove GraphicsWindow.MouseDown = OnMouseDown GraphicsWindow.KeyDown = K GraphicsWindow.BrushColor = &quot;red&quot; GraphicsWindow.DrawBoundText(10,10,100,&quot;Press H for help&quot;) GraphicsWindow.DrawBoundText(10,30,200,&quot;Click to draw&quot;) GraphicsWindow.DrawBoundText(10,50,200,&quot;Type commands in the Text Window&quot;) GraphicsWindow.DrawBoundText(10,80,300,&quot;Paint your masterpeice!&quot;) While(1=1) TextWindow.WriteLine(&quot;type commands&quot;) P = TextWindow.Read() C = Text.ConvertToLowerCase(P) Read() EndWhile Sub K If(GraphicsWindow.LastKey = &quot;H&quot;)Then Help() Endif Endsub Sub OnMouseDown prevX = GraphicsWindow.MouseX prevY = GraphicsWindow.MouseY EndSub Sub OnMouseMove x = GraphicsWindow.MouseX y = GraphicsWindow.MouseY If (Mouse.IsLeftButtonDown) Then GraphicsWindow.DrawLine(prevX, prevY, x, y) EndIf prevX = x prevY = y EndSub Sub Read If(C = &quot;color&quot;)Then Color() EndIf If(C = &quot;bg color&quot;)Then Bgcolr() EndIf If(C = &quot;pensize&quot;)Then Pen() EndIf If(C = &quot;clear&quot;)Then Clear() EndIf If(C = &quot;window size&quot;)Then GWS() EndIf If(C = &quot;clear tewindow&quot;)Then ClearT() EndIf If(C = &quot;eraser&quot;)Then Eraser() EndIf If(C = &quot;rbg color&quot;)Then RBG() EndIf If(C = &quot;window.size = desktop&quot;)Then Desktop() EndIf If(C = &quot;window.size = half&quot;)Then Half() EndIf If(C = &quot;window.size = orignal&quot;)Then Original() EndIf If(C = &quot;rp color&quot;)Then RPC() EndIf If(C = &quot;text.color&quot;)Then TC() EndIf If(C = &quot;new&quot;)Then New() EndIf If(C = &quot;commands&quot;)Then Commands() EndIf EndSub Sub Color TextWindow.WriteLine(&quot;Type color&quot;) L = TextWindow.Read() GraphicsWindow.PenColor = L EndSub Sub Bgcolr TextWindow.WriteLine(&quot;Type color&quot;) W = TextWindow.Read() GraphicsWindow.BackgroundColor = W EndSub Sub Pen TextWindow.WriteLine(&quot;Type size&quot;) Size = TextWindow.ReadNumber() GraphicsWindow.PenWidth = Size EndSub Sub Clear GraphicsWindow.Clear() EndSub Sub GWS TextWindow.WriteLine(&quot;Type Height&quot;) HE = TextWindow.ReadNumber() TextWindow.WriteLine(&quot;Type Width&quot;) WI = TextWindow.ReadNumber() GraphicsWindow.Height = HE GraphicsWindow.Width = WI EndSub Sub Help GraphicsWindow.ShowMessage(&quot;Instructions&quot;, &quot;HELP&quot;) GraphicsWindow.ShowMessage(&quot;Click to draw&quot;, &quot;HELP&quot;) GraphicsWindow.ShowMessage(&quot;Use the Text Window to type commands&quot;, &quot;HELP&quot;) GraphicsWindow.ShowMessage(&quot;Type color to access the colors function&quot;, &quot;HELP&quot;) GraphicsWindow.ShowMessage(&quot;Then type the color you want to change it to&quot;, &quot;HELP&quot;) GraphicsWindow.ShowMessage(&quot;Type bg color to access the background colors&quot;, &quot;HELP&quot;) GraphicsWindow.ShowMessage(&quot;Type window size to resize the Graphics window&quot;, &quot;HELP&quot;) GraphicsWindow.ShowMessage(&quot;Type clear to clear the screen&quot;, &quot;HELP&quot;) GraphicsWindow.ShowMessage(&quot;Type clear textwindow to clear the textwindow&quot;, &quot;HELP&quot;) GraphicsWindow.ShowMessage(&quot;Type window.size = desktop to make a full screen window&quot;, &quot;HELP&quot;) GraphicsWindow.ShowMessage(&quot;Type window.size = half for a half screen window&quot;, &quot;HELP&quot;) GraphicsWindow.ShowMessage(&quot;Type rbg color for a random background color&quot;, &quot;HELP&quot;) GraphicsWindow.ShowMessage(&quot;Type rp color for a random pencolor&quot;, &quot;HELP&quot;) EndSub Sub ClearT TextWindow.Clear() EndSub Sub Eraser GraphicsWindow.PenColor = GraphicsWindow.BackgroundColor EndSub Sub RBG GraphicsWindow.BackgroundColor = GraphicsWindow.GetRandomColor() EndSub Sub Desktop GraphicsWindow.Height = Desktop.Height - 65 GraphicsWindow.Width = Desktop.Width - 10 EndSub Sub Half GraphicsWindow.Height = Desktop.Height-200 GraphicsWindow.Width = Desktop.Width-200 EndSub Sub Original GraphicsWindow.Width = OW GraphicsWindow.Height = OH EndSub Sub RPC GraphicsWindow.PenColor = GraphicsWindow.GetRandomColor() EndSub Sub TC TextWindow.WriteLine(&quot;Type color&quot;) Forec = TextWindow.Read() TextWindow.ForegroundColor = Forec EndSub Sub New GraphicsWindow.Clear() TextWindow.Clear() EndSub Sub Commands GraphicsWindow.Clear() GraphicsWindow.BrushColor = &quot;black&quot; GraphicsWindow.DrawBoundText(10,10,100,&quot;Soon to come&quot;) 'I will add this in the next version' 'it will be a list of all the commands and sub commands in the system' EndSub </pre> </div> Please post requests for new functions and Ideas so that I can keep improving this program, my next V1.2 will be posted probably in a week or two. I am working on V1.2 and I have added a turtle function. You can either type in the co's X and Y for it to move to that position or type which direction and color and how far. I haven't made it so you can do angles yet though.<br/><br/>The HackerFri, 17 Apr 2009 22:11:37 Z2009-04-18T05:45:46Zhttp://social.msdn.microsoft.com/Forums/en-US/smallbasic/thread/eaacf826-9d12-4e3c-aa10-1b2788f160a6#d114aa91-a1c3-402c-a668-1219d8930d92http://social.msdn.microsoft.com/Forums/en-US/smallbasic/thread/eaacf826-9d12-4e3c-aa10-1b2788f160a6#d114aa91-a1c3-402c-a668-1219d8930d92FremyCompanyhttp://social.msdn.microsoft.com/Profile/en-US/?user=FremyCompanyPost your sample source code here and get featured on our blogs!<p>A Chess Game in Small Basic (no, there's no AI !)<br/><br/>The moves are checked to see if they are valid. You need two players to play the game.</p> <p><img src="http://tzzmag.bay.livefilestore.com/y1prfMSCTI0BGntEfhysb2AxllvkOb4YGX1Kcbg1oV2rWwZn28ztvidO-YynkyD-Eurb9dYETS_cgMIYl-wPgeBIM9izcUhE3SK/Capture d'%C3%A9cran de Smallbasic's ChessGame.png" alt=""></p> <p>The game is in French (though it's only welcome &amp; error messages that are in French). Echecs are not discovered by the program, the play stops when one of the king are taken by another piece.<br/><br/>If you discover bug, I'm ready to fix theses, but I think everything should be good.<br/>[EDIT] Edited today to support Roques. My program doesn't check if the king is in echec at any position of the roque's move.<br/><br/>You can download the game (.exe), the source code and the images at this location : <br/><a href="http://cid-201f3835d49587fe.skydrive.live.com/self.aspx/Public/Small Basic/ChessGame.zip">http://cid-201f3835d49587fe.skydrive.live.com/self.aspx/Public/Small%20Basic/ChessGame.zip</a><br/><br/>For information, there's 550 lines of code. I used my extension for the UI.<br/><br/>Fremy</p> <hr class=sig> Fremy - Developer in VB.NET, C# and JScript ... - Feel free to try my extensionSat, 18 Apr 2009 16:18:38 Z2009-04-19T07:44:48Zhttp://social.msdn.microsoft.com/Forums/en-US/smallbasic/thread/eaacf826-9d12-4e3c-aa10-1b2788f160a6#bc40b16b-22e7-4346-93a1-89c14f089116http://social.msdn.microsoft.com/Forums/en-US/smallbasic/thread/eaacf826-9d12-4e3c-aa10-1b2788f160a6#bc40b16b-22e7-4346-93a1-89c14f089116The Hackerhttp://social.msdn.microsoft.com/Profile/en-US/?user=The%20HackerPost your sample source code here and get featured on our blogs!Here is V1.1 of my paint program, it now has 435 lines of code. The turtle function has been added and if you type commands.list in the command window it will list all the commands in the system V1.1 and all the sub commands will be added in V1.2. Try it out!<br/><br/> <pre lang=x-aspx>'SKC161' '435 lines!' GraphicsWindow.Title = &quot;Paint V1.0&quot; TextWindow.Title = &quot;Command reader for Paint V1.0&quot; OH = GraphicsWindow.Height OW = GraphicsWindow.Width GraphicsWindow.Height = OH GraphicsWindow.Width = OW GraphicsWindow.MouseMove = OnMouseMove GraphicsWindow.MouseDown = OnMouseDown GraphicsWindow.KeyDown = K GraphicsWindow.BrushColor = &quot;red&quot; GraphicsWindow.DrawBoundText(10,10,100,&quot;Press H for help&quot;) GraphicsWindow.DrawBoundText(10,30,200,&quot;Click to draw&quot;) GraphicsWindow.DrawBoundText(10,50,200,&quot;Type commands.list in the Text Window for more help&quot;) GraphicsWindow.DrawBoundText(10,80,300,&quot;Paint your masterpeice!&quot;) TextWindow.ForegroundColor = &quot;red&quot; TextWindow.WriteLine(&quot;What's your name?&quot;) RNT = TextWindow.Read() GraphicsWindow.Title = RNT + &quot;'s masterpeice! V1.1&quot; TextWindow.ForegroundColor = &quot;gray&quot; While(1=1) TextWindow.WriteLine(&quot;type commands&quot;) P = TextWindow.Read() C = Text.ConvertToLowerCase(P) Read() EndWhile Sub K If(GraphicsWindow.LastKey = &quot;H&quot;)Then Help() Endif Endsub Sub OnMouseDown prevX = GraphicsWindow.MouseX prevY = GraphicsWindow.MouseY EndSub Sub OnMouseMove x = GraphicsWindow.MouseX y = GraphicsWindow.MouseY If (Mouse.IsLeftButtonDown) Then GraphicsWindow.DrawLine(prevX, prevY, x, y) EndIf prevX = x prevY = y EndSub Sub Read If(C = &quot;pen.color&quot;)Then Color() EndIf If(C = &quot;paint.bgcolor&quot;)Then Bgcolr() EndIf If(C = &quot;pen.size&quot;)Then Pen() EndIf If(C = &quot;paint.clear&quot;)Then Clear() EndIf If(C = &quot;paint.window.size&quot;)Then GWS() EndIf If(C = &quot;text.clear&quot;)Then ClearT() EndIf If(C = &quot;paint.eraser&quot;)Then Eraser() EndIf If(C = &quot;paint.rbgcolor&quot;)Then RBG() EndIf If(C = &quot;window.size = desktop&quot;)Then Desktop() EndIf If(C = &quot;window.size = half&quot;)Then Half() EndIf If(C = &quot;window.size = orignal&quot;)Then Original() EndIf If(C = &quot;paint.rpcolor&quot;)Then RPC() EndIf If(C = &quot;text.color&quot;)Then TC() EndIf If(C = &quot;project.new&quot;)Then New() EndIf If(C = &quot;commands.list&quot;)Then Commands() EndIf If(C = &quot;turtle.moveto&quot;)Then TurtleM() EndIf If(C = &quot;turtle.move&quot;)Then Turtle() EndIf If(C = &quot;flickr.random&quot;)THen Flickr() Endif If(C = &quot;text.bgcolor&quot;)Then TBGC() EndIf If(C = &quot;text.name&quot;)THen TWN() EndIf If(C = &quot;project.name&quot;)Then PaintN() EndIf If(C = &quot;paint.pen&quot;)Then PPEN() EndIf EndSub Sub Color TextWindow.WriteLine(&quot;Type color&quot;) L = TextWindow.Read() GraphicsWindow.PenColor = L EndSub Sub Bgcolr TextWindow.WriteLine(&quot;Type color&quot;) W = TextWindow.Read() GraphicsWindow.BackgroundColor = W EndSub Sub Pen TextWindow.WriteLine(&quot;Type size&quot;) Size = TextWindow.ReadNumber() GraphicsWindow.PenWidth = Size EndSub Sub Clear GraphicsWindow.Clear() EndSub Sub GWS TextWindow.WriteLine(&quot;Type Height&quot;) HE = TextWindow.ReadNumber() TextWindow.WriteLine(&quot;Type Width&quot;) WI = TextWindow.ReadNumber() GraphicsWindow.Height = HE GraphicsWindow.Width = WI EndSub Sub Help GraphicsWindow.ShowMessage(&quot;Instructions&quot;, &quot;HELP&quot;) GraphicsWindow.ShowMessage(&quot;Click to draw&quot;, &quot;HELP&quot;) GraphicsWindow.ShowMessage(&quot;Use the Text Window to type commands&quot;, &quot;HELP&quot;) GraphicsWindow.ShowMessage(&quot;Type color to access the colors function&quot;, &quot;HELP&quot;) GraphicsWindow.ShowMessage(&quot;Then type the color you want to change it to&quot;, &quot;HELP&quot;) GraphicsWindow.ShowMessage(&quot;Type bg color to access the background colors&quot;, &quot;HELP&quot;) GraphicsWindow.ShowMessage(&quot;Type window size to resize the Graphics window&quot;, &quot;HELP&quot;) GraphicsWindow.ShowMessage(&quot;Type clear to clear the screen&quot;, &quot;HELP&quot;) GraphicsWindow.ShowMessage(&quot;Type clear textwindow to clear the textwindow&quot;, &quot;HELP&quot;) GraphicsWindow.ShowMessage(&quot;Type window.size = desktop to make a full screen window&quot;, &quot;HELP&quot;) GraphicsWindow.ShowMessage(&quot;Type window.size = half for a half screen window&quot;, &quot;HELP&quot;) GraphicsWindow.ShowMessage(&quot;Type rbg color for a random background color&quot;, &quot;HELP&quot;) GraphicsWindow.ShowMessage(&quot;Type rp color for a random pencolor&quot;, &quot;HELP&quot;) EndSub Sub ClearT TextWindow.Clear() EndSub Sub Eraser GraphicsWindow.PenColor = GraphicsWindow.BackgroundColor EndSub Sub RBG GraphicsWindow.BackgroundColor = GraphicsWindow.GetRandomColor() EndSub Sub Desktop GraphicsWindow.Height = Desktop.Height - 65 GraphicsWindow.Width = Desktop.Width - 10 EndSub Sub Half GraphicsWindow.Height = Desktop.Height-200 GraphicsWindow.Width = Desktop.Width-200 EndSub Sub Original GraphicsWindow.Width = OW GraphicsWindow.Height = OH EndSub Sub RPC GraphicsWindow.PenColor = GraphicsWindow.GetRandomColor() EndSub Sub TC TextWindow.WriteLine(&quot;Type text foreground color&quot;) Forec = TextWindow.Read() TextWindow.ForegroundColor = Forec EndSub Sub New GraphicsWindow.Clear() TextWindow.Clear() EndSub Sub Commands TextWindow.Clear() TextWindow.ForegroundColor = &quot;yellow&quot; TextWindow.WriteLine(&quot;Here is a list of all the commands&quot;) TextWindow.WriteLine(&quot;Commands will be listed in red&quot;) TextWindow.WriteLine(&quot;Sub commands will be liste in blue under there parent command(Will be added in later version)&quot;) TextWindow.WriteLine(&quot;Summarys of commands and Sub commands will be listed under there parent in gray&quot;) TextWindow.WriteLine(&quot; &quot;) TextWindow.ForegroundColor = &quot;red&quot; TextWindow.WriteLine(&quot;pen.color&quot;) TextWindow.ForegroundColor = &quot;gray&quot; TextWindow.WriteLine(&quot;will let you choose the color of the pen/pencil&quot;) TextWindow.WriteLine(&quot; &quot;) TextWindow.ForegroundColor = &quot;red&quot; TextWindow.WriteLine(&quot;Pen.Size&quot;) TextWindow.ForegroundColor = &quot;gray&quot; TextWindow.WriteLine(&quot;Will let you choose the size of the pen/pencil&quot;) TextWindow.WriteLine(&quot; &quot;) TextWindow.ForegroundColor = &quot;red&quot; TextWindow.WriteLine(&quot;Paint.bgcolor&quot;) TextWindow.ForegroundColor = &quot;gray&quot; TextWindow.WriteLine(&quot;Will let you choose the background color of the graphicswindow&quot;) TextWindow.WriteLine(&quot; &quot;) TextWindow.ForegroundColor = &quot;red&quot; TextWindow.WriteLine(&quot;Paint.Clear&quot;) TextWindow.ForegroundColor = &quot;gray&quot; TextWindow.WriteLine(&quot;Will clear the project screen&quot;) TextWindow.WriteLine(&quot; &quot;) TextWindow.ForegroundColor = &quot;red&quot; TextWindow.WriteLine(&quot;Paint.Window.Size&quot;) TextWindow.ForegroundColor = &quot;gray&quot; TextWindow.WriteLine(&quot;Will let you choose the size of the project window&quot;) TextWindow.ForegroundColor = &quot;red&quot; TextWindow.WriteLine(&quot; &quot;) TextWindow.WriteLine(&quot;Text.Clear&quot;) TextWindow.ForegroundColor = &quot;gray&quot; TextWindow.WriteLine(&quot;Will clear the command screen&quot;) TextWindow.WriteLine(&quot; &quot;) TextWindow.ForegroundColor = &quot;red&quot; TextWindow.WriteLine(&quot;Paint.Eraser&quot;) TextWindow.ForegroundColor = &quot;gray&quot; TextWindow.WriteLine(&quot;Will change the pen to an eraser&quot;) TextWindow.WriteLine(&quot; &quot;) TextWindow.ForegroundColor = &quot;red&quot; TextWindow.WriteLine(&quot;Paint.Pen&quot;) TextWindow.ForegroundColor = &quot;gray&quot; TextWindow.WriteLine(&quot;Will change the pen from eraser back to pen&quot;) TextWindow.WriteLine(&quot; &quot;) TextWindow.ForegroundColor = &quot;red&quot; TextWindow.WriteLine(&quot;Paint.RBGColor&quot;) TextWindow.ForegroundColor = &quot;gray&quot; TextWindow.WriteLine(&quot;Will change the project screens background color to a random color&quot;) TextWindow.WriteLine(&quot; &quot;) TextWindow.ForegroundColor = &quot;red&quot; TextWindow.WriteLine(&quot;Window.Size&quot;) TextWindow.ForegroundColor = &quot;gray&quot; TextWindow.WriteLine(&quot;Will let you change the size of the project window&quot;) TextWindow.WriteLine(&quot; &quot;) TextWindow.ForegroundColor = &quot;red&quot; TextWindow.WriteLine(&quot;Window.Size = Desktop&quot;) TextWindow.ForegroundColor = &quot;gray&quot; TextWindow.WriteLine(&quot;Will make the project window full screen&quot;) TextWindow.WriteLine(&quot; &quot;) TextWindow.ForegroundColor = &quot;red&quot; TextWindow.WriteLine(&quot;Window.Size = Half&quot;) TextWindow.ForegroundColor = &quot;gray&quot; TextWindow.WriteLine(&quot;Will change the project window to half screen&quot;) TextWindow.WriteLine(&quot; &quot;) TextWindow.ForegroundColor = &quot;red&quot; TextWindow.WriteLine(&quot;Paint.RPColor&quot;) TextWindow.ForegroundColor = &quot;gray&quot; TextWindow.WriteLine(&quot;Will change the pen to a random color&quot;) TextWindow.WriteLine(&quot; &quot;) TextWindow.ForegroundColor = &quot;red&quot; TextWindow.WriteLine(&quot;Text.Color&quot;) TextWindow.ForegroundColor = &quot;gray&quot; TextWindow.WriteLine(&quot;This will let you change the color of the text in the command screen&quot;) TextWindow.WriteLine(&quot; &quot;) TextWindow.ForegroundColor = &quot;red&quot; TextWindow.WriteLine(&quot;Project.New&quot;) TextWindow.ForegroundColor = &quot;gray&quot; TextWindow.WriteLine(&quot;This will clear both the command screen and the project screen&quot;) TextWindow.WriteLine(&quot; &quot;) TextWindow.ForegroundColor = &quot;red&quot; TextWindow.WriteLine(&quot;Commands.List&quot;) TextWindow.ForegroundColor = &quot;gray&quot; TextWindow.WriteLine(&quot;This will list all the commands and sub commands in the system&quot;) TextWindow.WriteLine(&quot; &quot;) TextWindow.ForegroundColor = &quot;red&quot; TextWindow.WriteLine(&quot;Turtle.Move&quot;) TextWindow.ForegroundColor = &quot;gray&quot; TextWindow.WriteLine(&quot;This will let you draw lines with the turtle function&quot;) TextWindow.WriteLine(&quot; &quot;) TextWindow.ForegroundColor = &quot;red&quot; TextWindow.WriteLine(&quot;Turtle.MoveTo&quot;) TextWindow.ForegroundColor = &quot;gray&quot; TextWindow.WriteLine(&quot;Will let you draw lines with the turtle using the X and Y axis&quot;) TextWindow.WriteLine(&quot; &quot;) TextWindow.ForegroundColor = &quot;red&quot; TextWindow.WriteLine(&quot;Flickr.Random&quot;) TextWindow.ForegroundColor = &quot;gray&quot; TextWindow.WriteLine(&quot;Will choose a random picture from Flickr and set it for the background&quot;) TextWindow.WriteLine(&quot; &quot;) TextWindow.ForegroundColor = &quot;red&quot; TextWindow.WriteLine(&quot;Text.BGColor&quot;) TextWindow.ForegroundColor = &quot;gray&quot; TextWindow.WriteLine(&quot;Will let you choose the background color for the command screen&quot;) TextWindow.WriteLine(&quot; &quot;) TextWindow.ForegroundColor = &quot;red&quot; TextWindow.WriteLine(&quot;Text.Name&quot;) TextWindow.ForegroundColor = &quot;gray&quot; TextWindow.WriteLine(&quot;Will let you choose the name of the command screen, the text on the top bar of the command screen&quot;) TextWindow.WriteLine(&quot; &quot;) TextWindow.ForegroundColor = &quot;red&quot; TextWindow.WriteLine(&quot;Project.Name&quot;) TextWindow.ForegroundColor = &quot;gray&quot; TextWindow.WriteLine(&quot;This will let you change the name of the project screen, the text on the top bar of the project screen&quot;) EndSub Sub TurtleM TextWindow.WriteLine(&quot;Pen up or Pen down?&quot;) RRR = TextWindow.Read() If(RRR = &quot;up&quot;)Then Turtle.PenUp() TextWindow.WriteLine(&quot;Turtle.MoveTo X co's?&quot;) R = TextWindow.ReadNumber() TextWindow.WriteLine(&quot;Turtle.MoveTo Y co's&quot;) RR = TextWindow.ReadNumber() Turtle.MoveTo(R,RR) ElseIf(RRR = &quot;down&quot;)Then TextWindow.WriteLine(&quot;What color?&quot;) RRRR = TextWindow.Read() GraphicsWindow.PenColor = RRRR Turtle.PenDown() TextWindow.WriteLine(&quot;Turtle.MoveTo X co's?&quot;) R = TextWindow.ReadNumber() TextWindow.WriteLine(&quot;Turtle.MoveTo Y co's&quot;) RR = TextWindow.ReadNumber() Turtle.MoveTo(R,RR) EndIf EndSub Sub Turtle TextWindow.WriteLine(&quot;Which direction&quot;) RD = TextWindow.Read() TextWindow.WriteLine(&quot;How many degrees?&quot;) RTD = TextWindow.ReadNumber() TextWindow.WriteLine(&quot;Pen up or Pen down?&quot;) RUD = TextWindow.Read() TextWindow.WriteLine(&quot;How far?&quot;) RDD = TextWindow.ReadNumber() TextWindow.WriteLine(&quot;What color?&quot;) RC = TextWindow.Read() GraphicsWindow.PenColor = RC If(RUD = &quot;up&quot;)Then Turtle.PenUp() ElseIf(RUD = &quot;down&quot;)Then Turtle.PenDown() EndIf If(RD = &quot;right&quot;)Then Turtle.TurnRight() Turtle.Move(RDD) ElseIf(RD = &quot;left&quot;)Then Turtle.TurnLeft() Turtle.Move(RDD) EndIf If(RD = &quot;angle&quot;)Then Turtle.Turn(RTD) Turtle.Move(RDD) EndIf EndSub Sub Flickr TextWindow.WriteLine(&quot;Subject one?&quot;) RSO = TextWindow.Read() TextWindow.WriteLine(&quot;Subject two&quot;) RST = TextWindow.Read() Pic = Flickr.GetRandomPicture(RSO + RST) GraphicsWindow.DrawResizedImage(Pic,0,0,GraphicsWindow.Width,GraphicsWindow.Height) EndSub Sub TBGC TextWindow.WriteLine(&quot;Type text background color&quot;) RTBGC = TextWindow.Read() TextWindow.BackgroundColor = RTBGC TextWindow.Clear() EndSub Sub TWN TextWindow.WriteLine(&quot;New Name?&quot;) RNN = TextWindow.Read() TextWindow.Title = RNN Endsub Sub PaintN TextWindow.WriteLine(&quot;New project name?&quot;) RNPN = TextWindow.Read() GraphicsWindow.Title = RNPN EndSub Sub PPEN GraphicsWindow.PenColor = &quot;black&quot; EndSub </pre>Sat, 18 Apr 2009 20:26:10 Z2009-04-18T20:26:10Zhttp://social.msdn.microsoft.com/Forums/en-US/smallbasic/thread/eaacf826-9d12-4e3c-aa10-1b2788f160a6#0204c7dd-6dbf-4e9b-b807-d739bda39b8ahttp://social.msdn.microsoft.com/Forums/en-US/smallbasic/thread/eaacf826-9d12-4e3c-aa10-1b2788f160a6#0204c7dd-6dbf-4e9b-b807-d739bda39b8aFremyCompanyhttp://social.msdn.microsoft.com/Profile/en-US/?user=FremyCompanyPost your sample source code here and get featured on our blogs!Looks great, the hacker.<br/><br/>It would be even better if you can use buttons in the master window to handle the GUI.<br/>You should then restrict the zone where we can paint, though...<hr class="sig">Fremy - Developer in VB.NET, C# and JScript ... - Feel free to try my extensionSun, 19 Apr 2009 07:49:05 Z2009-04-19T07:49:05Zhttp://social.msdn.microsoft.com/Forums/en-US/smallbasic/thread/eaacf826-9d12-4e3c-aa10-1b2788f160a6#d3b4d3b8-5e3e-4ee7-9deb-e0835206fe04http://social.msdn.microsoft.com/Forums/en-US/smallbasic/thread/eaacf826-9d12-4e3c-aa10-1b2788f160a6#d3b4d3b8-5e3e-4ee7-9deb-e0835206fe04The Hackerhttp://social.msdn.microsoft.com/Profile/en-US/?user=The%20HackerPost your sample source code here and get featured on our blogs!<p>I am actually working on a version with buttons and the textwindow. So that the buttons will control the main commands like color, eraser e.t.c. Thanks for the idea.<br/><br/>I have finished a few buttons and the painting box for V1.3, but ran into some difficultys with the turtle functions. So it might be a little longer then expected but it'll be worth the wait!</p>Sun, 19 Apr 2009 16:48:40 Z2009-04-21T02:21:14Zhttp://social.msdn.microsoft.com/Forums/en-US/smallbasic/thread/eaacf826-9d12-4e3c-aa10-1b2788f160a6#c017ae3a-8cdf-4185-82e2-1c64fbe29f74http://social.msdn.microsoft.com/Forums/en-US/smallbasic/thread/eaacf826-9d12-4e3c-aa10-1b2788f160a6#c017ae3a-8cdf-4185-82e2-1c64fbe29f74The Hackerhttp://social.msdn.microsoft.com/Profile/en-US/?user=The%20HackerPost your sample source code here and get featured on our blogs!Here is V1.3(Added buttons). Features have been added that have not been listed yet, but don't worry they will be. I am still having problems with the turtle functions. I can't get it to stop drawing once it leaves the square. But if you have any function requests or ideas please contribute them. If you find any bugs please tell me as well. <pre lang=x-aspx>'Epic Paint' 'V1.3(beta)' '802 lines!' 'WDL232' Size = 1 L = GraphicsWindow.PenColor GraphicsWindow.Title = &quot;Paint V1.3&quot; TextWindow.Title = &quot;Command reader for Paint V1.3&quot; 'Sets the first buttons X and Y co's' ButtonY = GraphicsWindow.Height-20 ButtonX = GraphicsWindow.Width-625 'Sets the height and width of all the buttons' ButtonHe = 10 ButtonWi = 10 'Sets the second buttons X and Y co's' Button2Y = GraphicsWindow.Height-20 Button2X = GraphicsWindow.Width-614 GreenY = GraphicsWindow.Height-20 GreenX = GraphicsWindow.Width-602 ToolsX = 10 ToolsY = 200 EraserX = 15 EraserY = 205 EraserWi = 40 EraserHe = 15 PenX = 65 PenY = 205 GraphicsWindow.BrushColor = &quot;black&quot; GraphicsWindow.DrawRectangle(PenX,PenY,EraserWi,EraserHe) GraphicsWindow.DrawBoundText(PenX+5,PenY,EraserWi,&quot;Pen&quot;) GraphicsWindow.DrawBoundText(EraserX,EraserY,EraserWi,&quot;Eraser&quot;) GraphicsWindow.DrawRectangle(EraserX,EraserY,40,15) BoxX = 120 BoxY = 10 BoxHe = 400 BoxWi = 500 GraphicsWindow.DrawRectangle(ToolsX,ToolsY,100,200) GraphicsWindow.BrushColor = &quot;green&quot; GraphicsWindow.FillRectangle(GreenX,GreenY,ButtonWi,ButtonHe) GraphicsWindow.DrawRectangle(BoxX,BoxY,BoxWi,BoxHe) 'Draws the first button' GraphicsWindow.BrushColor = &quot;blue&quot; GraphicsWindow.FillRectangle(Button2X,Button2Y,ButtonWi,ButtonHe) 'Draws the second button' GraphicsWindow.BrushColor = &quot;red&quot; GraphicsWindow.FillRectangle(ButtonX,ButtonY,ButtonWi,ButtonHe) GraphicsWindow.BrushColor = &quot;blue&quot; GraphicsWindow.DrawBoundText(GraphicsWindow.Width-GraphicsWindow.Width+10,GraphicsWindow.Height-40,100,&quot;Pen.Size = &quot; + Size) GraphicsWindow.BrushColor = L GraphicsWindow.DrawBoundText(GraphicsWindow.Width-GraphicsWindow.Width+10,GraphicsWindow.Height-50,300, &quot;Pen.Color = &quot; + L) GraphicsWindow.DrawBoundText(GraphicsWindow.Width-GraphicsWindow.Width+10,GraphicsWindow.Height-60,300, &quot;Turtle.Color = &quot; + L) OH = GraphicsWindow.Height OW = GraphicsWindow.Width GraphicsWindow.Height = OH GraphicsWindow.Width = OW GraphicsWindow.MouseMove = OnMouseMove GraphicsWindow.MouseDown = OnMouseDown GraphicsWindow.KeyDown = K 'Draws a few help commands' GraphicsWindow.BrushColor = &quot;red&quot; GraphicsWindow.DrawBoundText(10,10,100,&quot;1, Press H for help&quot;) GraphicsWindow.DrawBoundText(10,50,100,&quot;2, Click to draw&quot;) GraphicsWindow.DrawBoundText(10,80,100,&quot;3, Type commands.list in the Text Window for more help&quot;) GraphicsWindow.DrawBoundText(10,160,100,&quot;4, Paint your masterpeice&quot;) 'Changes the title of the project windows to &quot;Your name here&quot;(s) masterpeice' TextWindow.ForegroundColor = &quot;red&quot; TextWindow.WriteLine(&quot;What's your name?&quot;) RNT = TextWindow.Read() GraphicsWindow.Title = RNT + &quot;'s masterpeice! V1.1&quot; TextWindow.Title = RNT + &quot;'s masterpeice TextWindow.ForegroundColor = &quot;gray&quot; 'Generates a forever going While loop that reads the users commands' While(1=1) 'Plays a clicking sound' Sound.PlayClick() TextWindow.WriteLine(&quot;type commands&quot;) P = TextWindow.Read() C = Text.ConvertToLowerCase(P) Read() EndWhile Sub K If(GraphicsWindow.LastKey = &quot;H&quot;)Then Sound.PlayClick() Help() Endif Endsub Sub OnMouseDown Sound.PlayClick() 'Gets the X and Y co's for where the mouse clicked' prevX = GraphicsWindow.MouseX prevY = GraphicsWindow.MouseY 'Checks if they clicked inside the first button' If(prevX &gt; ButtonX And prevX &lt; (ButtonX + ButtonWi)) And (prevY &gt; ButtonY And prevY &lt; (ButtonY + ButtonHe))Then GraphicsWindow.PenColor = &quot;red&quot; GraphicsWindow.BrushColor = &quot;white&quot; GraphicsWindow.FillRectangle(GraphicsWindow.Width-GraphicsWindow.Width+10,GraphicsWindow.Height-50,300,12) L = GraphicsWindow.PenColor GraphicsWindow.BrushColor = L GraphicsWindow.DrawBoundText(GraphicsWindow.Width-GraphicsWindow.Width+10,GraphicsWindow.Height-50,300, &quot;Pen.Color = &quot; + L) 'Checks if they clicked inside the second button' ElseIf(prevX &gt; Button2X And prevX &lt; (Button2X + ButtonWi)) And (prevY &gt; Button2Y And prevY &lt; (Button2Y + ButtonHe))Then GraphicsWindow.PenColor = &quot;blue&quot; GraphicsWindow.BrushColor = &quot;white&quot; GraphicsWindow.FillRectangle(GraphicsWindow.Width-GraphicsWindow.Width+10,GraphicsWindow.Height-50,300,12) L = GraphicsWindow.PenColor GraphicsWindow.BrushColor = L GraphicsWindow.DrawBoundText(GraphicsWindow.Width-GraphicsWindow.Width+10,GraphicsWindow.Height-50,300, &quot;Pen.Color = &quot; + L) ElseIf(prevX &gt; GreenX And prevX &lt; (GreenX + ButtonWi)) And (prevY &gt; GreenY And prevY &lt; (GreenY + ButtonHe))Then GraphicsWindow.PenColor = &quot;green&quot; GraphicsWindow.BrushColor = &quot;white&quot; GraphicsWindow.FillRectangle(GraphicsWindow.Width-GraphicsWindow.Width+10,GraphicsWindow.Height-50,300,12) L = GraphicsWindow.PenColor GraphicsWindow.BrushColor = L GraphicsWindow.DrawBoundText(GraphicsWindow.Width-GraphicsWindow.Width+10,GraphicsWindow.Height-50,300, &quot;Pen.Color = &quot; + L) ElseIf(prevX &gt; EraserX And prevX &lt; (EraserX + EraserWi)) And (prevY &gt; EraserY And prevY &lt; (EraserY + EraserHe))Then GraphicsWindow.PenColor = GraphicsWindow.BackgroundColor GraphicsWindow.BrushColor = &quot;white&quot; GraphicsWindow.FillRectangle(GraphicsWindow.Width-GraphicsWindow.Width+10,GraphicsWindow.Height-50,300,12) GraphicsWindow.BrushColor = &quot;black&quot; GraphicsWindow.DrawBoundText(GraphicsWindow.Width-GraphicsWindow.Width+10,GraphicsWindow.Height-50,300, &quot;Pen.Color = Eraser&quot;) ElseIf(prevX &gt; PenX And prevX &lt; (PenX + EraserWi)) And (prevY &gt; PenY And prevY &lt; (PenY + EraserHe))Then GraphicsWindow.PenColor = &quot;black&quot; GraphicsWindow.BrushColor = &quot;white&quot; GraphicsWindow.FillRectangle(GraphicsWindow.Width-GraphicsWindow.Width+10,GraphicsWindow.Height-50,300,12) GraphicsWindow.BrushColor = &quot;black&quot; GraphicsWindow.DrawBoundText(GraphicsWindow.Width-GraphicsWindow.Width+10,GraphicsWindow.Height-50,300, &quot;Pen.Color = Black&quot;) EndIf If(prevX &gt; BoxX And prevX &lt; (BoxX + BoxWi)) And (prevY &gt; BoxY And prevY &lt; (BoxY + BoxHe))Then If(Mouse.IsRightButtonDown = &quot;true&quot;)Then GraphicsWindow.DrawRectangle(GraphicsWindow.MouseX,GraphicsWindow.MouseY,50,50) EndIf EndIf EndSub Sub OnMouseMove If(prevX &gt; BoxX And prevX &lt; (BoxX + BoxWi)) And (prevY &gt; BoxY And prevY &lt; (BoxY + BoxHe))Then 'Gets the X and Y co's of the mouse whenever it moves forever' x = GraphicsWindow.MouseX y = GraphicsWindow.MouseY 'Checks if the left is down and draws the line' If (Mouse.IsLeftButtonDown) Then GraphicsWindow.DrawLine(prevX, prevY, x, y) EndIf EndIf prevX = x prevY = y EndSub Sub Read 'Checks if the command inputed by the user is valid' If(C = &quot;pen.color&quot;)Then Sound.PlayClick() Color() EndIf If(C = &quot;paint.bgcolor&quot;)Then Sound.PlayClick() Bgcolr() EndIf If(C = &quot;pen.size&quot;)Then Sound.PlayClick() Pen() EndIf If(C = &quot;paint.clear&quot;)Then Sound.PlayClick() Clear() EndIf If(C = &quot;paint.window.size&quot;)Then Sound.PlayClick() GWS() EndIf If(C = &quot;text.clear&quot;)Then Sound.PlayClick() ClearT() EndIf If(C = &quot;paint.eraser&quot;)Then Sound.PlayClick() Eraser() EndIf If(C = &quot;paint.rbgcolor&quot;)Then Sound.PlayClick() RBG() EndIf If(C = &quot;window.size = desktop&quot;)Then Sound.PlayClick() Desktop() EndIf If(C = &quot;window.size = half&quot;)Then Sound.PlayClick() Half() EndIf If(C = &quot;window.size = orignal&quot;)Then Sound.PlayClick() Original() EndIf If(C = &quot;paint.rpcolor&quot;)Then RPC() EndIf If(C = &quot;text.color&quot;)Then TC() EndIf If(C = &quot;project.new&quot;)Then Sound.PlayClick() New() EndIf If(C = &quot;commands.list&quot;)Then Sound.PlayClick() Commands() EndIf If(C = &quot;turtle.moveto&quot;)Then Sound.PlayClick() TurtleM() EndIf If(C = &quot;turtle.move&quot;)Then Sound.PlayClick() Turtle() EndIf If(C = &quot;flickr.random&quot;)THen Sound.PlayClick() Flickr() Endif If(C = &quot;text.bgcolor&quot;)Then Sound.PlayClick() TBGC() EndIf If(C = &quot;text.name&quot;)THen Sound.PlayClick() TWN() EndIf If(C = &quot;project.name&quot;)Then Sound.PlayClick() PaintN() EndIf If(C = &quot;paint.pen&quot;)Then Sound.PlayClick() PPEN() EndIf If(C = &quot;turtle.hide&quot;)Then Sound.PlayClick() TurtleH() EndIf If(C = &quot;turtle.draw.rect&quot;)Then Turtlerect() EndIf If(C = &quot;turtle.draw.star&quot;)Then Star() EndIf EndSub Sub Color 'Changes the pen color to whatever color you can think of' TextWindow.WriteLine(&quot;Type color&quot;) L = TextWindow.Read() GraphicsWindow.PenColor = L GraphicsWindow.BrushColor = &quot;white&quot; GraphicsWindow.FillRectangle(GraphicsWindow.Width-GraphicsWindow.Width+10,GraphicsWindow.Height-50,300,12) GraphicsWindow.BrushColor = L GraphicsWindow.DrawBoundText(GraphicsWindow.Width-GraphicsWindow.Width+10,GraphicsWindow.Height-50,300, &quot;Pen.Color = &quot; + L) EndSub Sub Bgcolr 'Changes the background color to whatever color you can think of' TextWindow.WriteLine(&quot;Type color&quot;) W = TextWindow.Read() GraphicsWindow.BackgroundColor = W EndSub Sub Pen Pen: 'Changes the pen size to whatever number you wish below 6' TextWindow.WriteLine(&quot;Type size&quot;) Size = TextWindow.ReadNumber() If(Size &lt; 6)Then GraphicsWindow.PenWidth = Size GraphicsWindow.BrushColor = &quot;white&quot; GraphicsWindow.FillRectangle(GraphicsWindow.Width-GraphicsWindow.Width+10,GraphicsWindow.Height-40,110,15) GraphicsWindow.BrushColor = &quot;blue&quot; GraphicsWindow.DrawBoundText(GraphicsWindow.Width-GraphicsWindow.Width+10,GraphicsWindow.Height-40,100,&quot;Pen.Size = &quot; + Size) ElseIf(Size &gt;= 6)Then TextWindow.WriteLine(&quot;Invalid size&quot;) Goto Pen EndIf EndSub Sub Clear GraphicsWindow.Clear() EndSub Sub GWS TextWindow.WriteLine(&quot;Type Height&quot;) HE = TextWindow.ReadNumber() Sound.PlayClick() TextWindow.WriteLine(&quot;Type Width&quot;) WI = TextWindow.ReadNumber() GraphicsWindow.Height = HE GraphicsWindow.Width = WI EndSub Sub Help GraphicsWindow.ShowMessage(&quot;Instructions&quot;, &quot;HELP&quot;) GraphicsWindow.ShowMessage(&quot;Click to draw&quot;, &quot;HELP&quot;) GraphicsWindow.ShowMessage(&quot;Use the Text Window to type commands&quot;, &quot;HELP&quot;) GraphicsWindow.ShowMessage(&quot;Type color to access the colors function&quot;, &quot;HELP&quot;) GraphicsWindow.ShowMessage(&quot;Then type the color you want to change it to&quot;, &quot;HELP&quot;) GraphicsWindow.ShowMessage(&quot;Type bg color to access the background colors&quot;, &quot;HELP&quot;) GraphicsWindow.ShowMessage(&quot;Type window size to resize the Graphics window&quot;, &quot;HELP&quot;) GraphicsWindow.ShowMessage(&quot;Type clear to clear the screen&quot;, &quot;HELP&quot;) GraphicsWindow.ShowMessage(&quot;Type clear textwindow to clear the textwindow&quot;, &quot;HELP&quot;) GraphicsWindow.ShowMessage(&quot;Type window.size = desktop to make a full screen window&quot;, &quot;HELP&quot;) GraphicsWindow.ShowMessage(&quot;Type window.size = half for a half screen window&quot;, &quot;HELP&quot;) GraphicsWindow.ShowMessage(&quot;Type rbg color for a random background color&quot;, &quot;HELP&quot;) GraphicsWindow.ShowMessage(&quot;Type rp color for a random pencolor&quot;, &quot;HELP&quot;) EndSub Sub ClearT TextWindow.Clear() EndSub Sub Eraser GraphicsWindow.PenColor = GraphicsWindow.BackgroundColor EndSub Sub RBG GraphicsWindow.BackgroundColor = GraphicsWindow.GetRandomColor() EndSub Sub Desktop GraphicsWindow.Height = Desktop.Height - 65 GraphicsWindow.Width = Desktop.Width - 10 EndSub Sub Half GraphicsWindow.Height = Desktop.Height-200 GraphicsWindow.Width = Desktop.Width-200 EndSub Sub Original GraphicsWindow.Width = OW GraphicsWindow.Height = OH EndSub Sub RPC GraphicsWindow.PenColor = GraphicsWindow.GetRandomColor() L = GraphicsWindow.PenColor GraphicsWindow.BrushColor = &quot;white&quot; GraphicsWindow.FillRectangle(GraphicsWindow.Width-GraphicsWindow.Width+10,GraphicsWindow.Height-50,300,12) GraphicsWindow.BrushColor = L GraphicsWindow.DrawBoundText(GraphicsWindow.Width-GraphicsWindow.Width+10,GraphicsWindow.Height-50,300, &quot;Pen.Color = &quot; + L) EndSub Sub TC TextWindow.WriteLine(&quot;Type text foreground color&quot;) Forec = TextWindow.Read() TextWindow.ForegroundColor = Forec EndSub Sub New 'Epic Paint' 'V1.3(beta)' '700 lines!' Size = 1 L = GraphicsWindow.PenColor GraphicsWindow.Title = &quot;Paint V1.3&quot; TextWindow.Title = &quot;Command reader for Paint V1.3&quot; 'Sets the first buttons X and Y co's' ButtonY = GraphicsWindow.Height-20 ButtonX = GraphicsWindow.Width-625 'Sets the height and width of all the buttons' ButtonHe = 10 ButtonWi = 10 'Sets the second buttons X and Y co's' Button2Y = GraphicsWindow.Height-20 Button2X = GraphicsWindow.Width-614 GreenY = GraphicsWindow.Height-20 GreenX = GraphicsWindow.Width-602 ToolsX = 10 ToolsY = 200 EraserX = 15 EraserY = 205 EraserWi = 40 EraserHe = 15 GraphicsWindow.BrushColor = &quot;black&quot; GraphicsWindow.DrawBoundText(EraserX,EraserY,EraserWi,&quot;Eraser&quot;) GraphicsWindow.DrawRectangle(EraserX,EraserY,40,15) BoxX = 120 BoxY = 10 BoxHe = 400 BoxWi = 500 GraphicsWindow.DrawRectangle(ToolsX,ToolsY,100,200) GraphicsWindow.BrushColor = &quot;green&quot; GraphicsWindow.FillRectangle(GreenX,GreenY,ButtonWi,ButtonHe) GraphicsWindow.DrawRectangle(BoxX,BoxY,BoxWi,BoxHe) 'Draws the first button' GraphicsWindow.BrushColor = &quot;blue&quot; GraphicsWindow.FillRectangle(Button2X,Button2Y,ButtonWi,ButtonHe) 'Draws the second button' GraphicsWindow.BrushColor = &quot;red&quot; GraphicsWindow.FillRectangle(ButtonX,ButtonY,ButtonWi,ButtonHe) GraphicsWindow.BrushColor = &quot;blue&quot; GraphicsWindow.DrawBoundText(GraphicsWindow.Width-GraphicsWindow.Width+10,GraphicsWindow.Height-40,100,&quot;Pen.Size = &quot; + Size) GraphicsWindow.BrushColor = &quot;white&quot; GraphicsWindow.FillRectangle(GraphicsWindow.Width-GraphicsWindow.Width+10,GraphicsWindow.Height-50,300,12) GraphicsWindow.BrushColor = L GraphicsWindow.DrawBoundText(GraphicsWindow.Width-GraphicsWindow.Width+10,GraphicsWindow.Height-50,300, &quot;Pen.Color = &quot; + L) OH = GraphicsWindow.Height OW = GraphicsWindow.Width GraphicsWindow.Height = OH GraphicsWindow.Width = OW GraphicsWindow.MouseMove = OnMouseMove GraphicsWindow.MouseDown = OnMouseDown GraphicsWindow.KeyDown = K 'Draws a few help commands' GraphicsWindow.BrushColor = &quot;red&quot; GraphicsWindow.DrawBoundText(10,10,100,&quot;1, Press H for help&quot;) GraphicsWindow.DrawBoundText(10,50,100,&quot;2, Click to draw&quot;) GraphicsWindow.DrawBoundText(10,80,100,&quot;3, Type commands.list in the Text Window for more help&quot;) GraphicsWindow.DrawBoundText(10,160,100,&quot;4, Paint your masterpeice&quot;) 'Changes the title of the project windows to &quot;Your name here&quot;(s) masterpeice' TextWindow.ForegroundColor = &quot;red&quot; TextWindow.WriteLine(&quot;What's your name?&quot;) RNT = TextWindow.Read() GraphicsWindow.Title = RNT + &quot;'s masterpeice! V1.1&quot; TextWindow.Title = RNT + &quot;'s masterpeice TextWindow.ForegroundColor = &quot;gray&quot; 'Generates a forever going While loop that reads the users commands' EndSub Sub Commands TextWindow.Clear() TextWindow.ForegroundColor = &quot;yellow&quot; TextWindow.WriteLine(&quot;Here is a list of all the commands&quot;) Sound.PlayClick() TextWindow.WriteLine(&quot;Commands will be listed in red&quot;) Sound.PlayClick() TextWindow.WriteLine(&quot;Sub commands will be liste in blue under there parent command(Will be added in later version)&quot;) Sound.PlayClick() TextWindow.WriteLine(&quot;Summarys of commands and Sub commands will be listed under there parent in gray&quot;) TextWindow.WriteLine(&quot; &quot;) TextWindow.ForegroundColor = &quot;red&quot; Sound.PlayClick() TextWindow.WriteLine(&quot;pen.color&quot;) Sound.PlayClick() TextWindow.ForegroundColor = &quot;gray&quot; TextWindow.WriteLine(&quot;will let you choose the color of the pen/pencil&quot;) TextWindow.WriteLine(&quot; &quot;) TextWindow.ForegroundColor = &quot;red&quot; Sound.PlayClick() TextWindow.WriteLine(&quot;Pen.Size&quot;) Sound.PlayClick() TextWindow.ForegroundColor = &quot;gray&quot; TextWindow.WriteLine(&quot;Will let you choose the size of the pen/pencil&quot;) Sound.PlayClick() TextWindow.WriteLine(&quot; &quot;) TextWindow.ForegroundColor = &quot;red&quot; TextWindow.WriteLine(&quot;Paint.bgcolor&quot;) Sound.PlayClick() TextWindow.ForegroundColor = &quot;gray&quot; TextWindow.WriteLine(&quot;Will let you choose the background color of the graphicswindow&quot;) Sound.PlayClick() TextWindow.WriteLine(&quot; &quot;) TextWindow.ForegroundColor = &quot;red&quot; TextWindow.WriteLine(&quot;Paint.Clear&quot;) Sound.PlayClick() TextWindow.ForegroundColor = &quot;gray&quot; TextWindow.WriteLine(&quot;Will clear the project screen&quot;) Sound.PlayClick() TextWindow.WriteLine(&quot; &quot;) TextWindow.ForegroundColor = &quot;red&quot; TextWindow.WriteLine(&quot;Paint.Window.Size&quot;) Sound.PlayClick() TextWindow.ForegroundColor = &quot;gray&quot; TextWindow.WriteLine(&quot;Will let you choose the size of the project window&quot;) Sound.PlayClick() TextWindow.ForegroundColor = &quot;red&quot; TextWindow.WriteLine(&quot; &quot;) TextWindow.WriteLine(&quot;Text.Clear&quot;) Sound.PlayClick() TextWindow.ForegroundColor = &quot;gray&quot; TextWindow.WriteLine(&quot;Will clear the command screen&quot;) Sound.PlayClick() TextWindow.WriteLine(&quot; &quot;) TextWindow.ForegroundColor = &quot;red&quot; TextWindow.WriteLine(&quot;Paint.Eraser&quot;) Sound.PlayClick() TextWindow.ForegroundColor = &quot;gray&quot; TextWindow.WriteLine(&quot;Will change the pen to an eraser&quot;) Sound.PlayClick() TextWindow.WriteLine(&quot; &quot;) TextWindow.ForegroundColor = &quot;red&quot; TextWindow.WriteLine(&quot;Paint.Pen&quot;) Sound.PlayClick() TextWindow.ForegroundColor = &quot;gray&quot; TextWindow.WriteLine(&quot;Will change the pen from eraser back to pen&quot;) Sound.PlayClick() TextWindow.WriteLine(&quot; &quot;) TextWindow.ForegroundColor = &quot;red&quot; TextWindow.WriteLine(&quot;Paint.RBGColor&quot;) Sound.PlayClick() TextWindow.ForegroundColor = &quot;gray&quot; TextWindow.WriteLine(&quot;Will change the project screens background color to a random color&quot;) Sound.PlayClick() TextWindow.WriteLine(&quot; &quot;) TextWindow.ForegroundColor = &quot;red&quot; TextWindow.WriteLine(&quot;Window.Size&quot;) Sound.PlayClick() TextWindow.ForegroundColor = &quot;gray&quot; TextWindow.WriteLine(&quot;Will let you change the size of the project window&quot;) Sound.PlayClick() TextWindow.WriteLine(&quot; &quot;) TextWindow.ForegroundColor = &quot;red&quot; TextWindow.WriteLine(&quot;Window.Size = Desktop&quot;) Sound.PlayClick() TextWindow.ForegroundColor = &quot;gray&quot; TextWindow.WriteLine(&quot;Will make the project window full screen&quot;) Sound.PlayClick() TextWindow.WriteLine(&quot; &quot;) TextWindow.ForegroundColor = &quot;red&quot; TextWindow.WriteLine(&quot;Window.Size = Half&quot;) Sound.PlayClick() TextWindow.ForegroundColor = &quot;gray&quot; TextWindow.WriteLine(&quot;Will change the project window to half screen&quot;) Sound.PlayClick() TextWindow.WriteLine(&quot; &quot;) TextWindow.ForegroundColor = &quot;red&quot; TextWindow.WriteLine(&quot;Paint.RPColor&quot;) Sound.PlayClick() TextWindow.ForegroundColor = &quot;gray&quot; TextWindow.WriteLine(&quot;Will change the pen to a random color&quot;) Sound.PlayClick() TextWindow.WriteLine(&quot; &quot;) TextWindow.ForegroundColor = &quot;red&quot; TextWindow.WriteLine(&quot;Text.Color&quot;) TextWindow.ForegroundColor = &quot;gray&quot; TextWindow.WriteLine(&quot;This will let you change the color of the text in the command screen&quot;) Sound.PlayClick() TextWindow.WriteLine(&quot; &quot;) TextWindow.ForegroundColor = &quot;red&quot; TextWindow.WriteLine(&quot;Project.New&quot;) Sound.PlayClick() TextWindow.ForegroundColor = &quot;gray&quot; TextWindow.WriteLine(&quot;This will clear both the command screen and the project screen&quot;) Sound.PlayClick() TextWindow.WriteLine(&quot; &quot;) TextWindow.ForegroundColor = &quot;red&quot; TextWindow.WriteLine(&quot;Commands.List&quot;) Sound.PlayClick() TextWindow.ForegroundColor = &quot;gray&quot; TextWindow.WriteLine(&quot;This will list all the commands and sub commands in the system&quot;) Sound.PlayClick() TextWindow.WriteLine(&quot; &quot;) TextWindow.ForegroundColor = &quot;red&quot; TextWindow.WriteLine(&quot;Turtle.Move&quot;) Sound.PlayClick() TextWindow.ForegroundColor = &quot;gray&quot; TextWindow.WriteLine(&quot;This will let you draw lines with the turtle function&quot;) Sound.PlayClick() TextWindow.WriteLine(&quot; &quot;) TextWindow.ForegroundColor = &quot;red&quot; TextWindow.WriteLine(&quot;Turtle.MoveTo&quot;) Sound.PlayClick() TextWindow.ForegroundColor = &quot;gray&quot; TextWindow.WriteLine(&quot;Will let you draw lines with the turtle using the X and Y axis&quot;) Sound.PlayClick() TextWindow.WriteLine(&quot; &quot;) TextWindow.ForegroundColor = &quot;red&quot; TextWindow.WriteLine(&quot;Flickr.Random&quot;) Sound.PlayClick() TextWindow.ForegroundColor = &quot;gray&quot; TextWindow.WriteLine(&quot;Will choose a random picture from Flickr and set it for the background&quot;) Sound.PlayClick() TextWindow.WriteLine(&quot; &quot;) TextWindow.ForegroundColor = &quot;red&quot; TextWindow.WriteLine(&quot;Text.BGColor&quot;) Sound.PlayClick() TextWindow.ForegroundColor = &quot;gray&quot; TextWindow.WriteLine(&quot;Will let you choose the background color for the command screen&quot;) Sound.PlayClick() TextWindow.WriteLine(&quot; &quot;) TextWindow.ForegroundColor = &quot;red&quot; TextWindow.WriteLine(&quot;Text.Name&quot;) Sound.PlayClick() TextWindow.ForegroundColor = &quot;gray&quot; TextWindow.WriteLine(&quot;Will let you choose the name of the command screen, the text on the top bar of the command screen&quot;) Sound.PlayClick() TextWindow.WriteLine(&quot; &quot;) TextWindow.ForegroundColor = &quot;red&quot; TextWindow.WriteLine(&quot;Project.Name&quot;) Sound.PlayClick() TextWindow.ForegroundColor = &quot;gray&quot; TextWindow.WriteLine(&quot;This will let you change the name of the project screen, the text on the top bar of the project screen&quot;) EndSub Sub TurtleM TextWindow.WriteLine(&quot;Pen up or Pen down?&quot;) RRR = TextWindow.Read() Sound.PlayClick() If(RRR = &quot;up&quot;)Then Turtle.PenUp() Sound.PlayClick() TextWindow.WriteLine(&quot;Turtle.MoveTo X co's?&quot;) R = TextWindow.ReadNumber() Sound.PlayClick() TextWindow.WriteLine(&quot;Turtle.MoveTo Y co's&quot;) RR = TextWindow.ReadNumber() Turtle.MoveTo(R,RR) ElseIf(RRR = &quot;down&quot;)Then Sound.PlayClick() TextWindow.WriteLine(&quot;What color?&quot;) L = TextWindow.Read() GraphicsWindow.PenColor = L Turtle.PenDown() Sound.PlayClick() TextWindow.WriteLine(&quot;Turtle.MoveTo X co's?&quot;) R = TextWindow.ReadNumber() Sound.PlayClick() TextWindow.WriteLine(&quot;Turtle.MoveTo Y co's&quot;) RR = TextWindow.ReadNumber() Turtle.MoveTo(R,RR) EndIf GraphicsWindow.PenColor = L GraphicsWindow.BrushColor = &quot;white&quot; GraphicsWindow.FillRectangle(GraphicsWindow.Width-GraphicsWindow.Width+10,GraphicsWindow.Height-50,300,12) GraphicsWindow.BrushColor = L GraphicsWindow.DrawBoundText(GraphicsWindow.Width-GraphicsWindow.Width+10,GraphicsWindow.Height-50,300, &quot;Pen.Color = &quot; + L) EndSub Sub Turtle Loop = 0 TextWindow.WriteLine(&quot;Which direction&quot;) RD = TextWindow.Read() Sound.PlayClick() TextWindow.WriteLine(&quot;How many degrees?&quot;) RTD = TextWindow.ReadNumber() Sound.PlayClick() TextWindow.WriteLine(&quot;Pen up or Pen down?&quot;) RUD = TextWindow.Read() Sound.PlayClick() TextWindow.WriteLine(&quot;How far?&quot;) RDD = TextWindow.ReadNumber() Sound.PlayClick() TextWindow.WriteLine(&quot;What color?&quot;) L = TextWindow.Read() GraphicsWindow.PenColor = L Sound.PlayClick() TextWindow.WriteLine(&quot;Loop how many times?&quot;) Looptime = TextWindow.ReadNumber() While(Loop&lt;Looptime) Loop = Loop + 1 If(RUD = &quot;up&quot;)Then Turtle.PenUp() ElseIf(RUD = &quot;down&quot;)Then Turtle.PenDown() EndIf If(RD = &quot;right&quot;)Then Turtle.TurnRight() Turtle.Move(RDD) ElseIf(RD = &quot;left&quot;)Then Turtle.TurnLeft() Turtle.Move(RDD) EndIf If(RD = &quot;angle&quot;)Then Turtle.Turn(RTD) Turtle.Move(RDD) EndIf EndWhile GraphicsWindow.PenColor = L GraphicsWindow.BrushColor = &quot;white&quot; GraphicsWindow.FillRectangle(GraphicsWindow.Width-GraphicsWindow.Width+10,GraphicsWindow.Height-50,300,12) GraphicsWindow.BrushColor = L GraphicsWindow.DrawBoundText(GraphicsWindow.Width-GraphicsWindow.Width+10,GraphicsWindow.Height-50,300, &quot;Pen.Color = &quot; + L) EndSub Sub Flickr TextWindow.WriteLine(&quot;Subject one?&quot;) RSO = TextWindow.Read() Sound.PlayClick() TextWindow.WriteLine(&quot;Subject two&quot;) RST = TextWindow.Read() Pic = Flickr.GetRandomPicture(RSO + RST) GraphicsWindow.DrawResizedImage(Pic,0,0,GraphicsWindow.Width,GraphicsWindow.Height) EndSub Sub TBGC TextWindow.WriteLine(&quot;Type text background color&quot;) RTBGC = TextWindow.Read() TextWindow.BackgroundColor = RTBGC TextWindow.Clear() EndSub Sub TWN TextWindow.WriteLine(&quot;New Name?&quot;) RNN = TextWindow.Read() TextWindow.Title = RNN Endsub Sub PaintN TextWindow.WriteLine(&quot;New project name?&quot;) RNPN = TextWindow.Read() GraphicsWindow.Title = RNPN EndSub Sub PPEN GraphicsWindow.PenColor = &quot;black&quot; GraphicsWindow.BrushColor = L GraphicsWindow.DrawBoundText(GraphicsWindow.Width-GraphicsWindow.Width+10,GraphicsWindow.Height-50,300, &quot;Pen.Color = Black&quot;) EndSub Sub TurtleH Turtle.Hide() EndSub Sub Turtlerect TextWindow.WriteLine(&quot;X co's&quot;) RectX = TextWindow.ReadNumber() TextWindow.WriteLine(&quot;Y co's?&quot;) RectY = TextWindow.ReadNumber() TextWindow.WriteLine(&quot;Height?&quot;) RectHe = TextWindow.ReadNumber() TextWindow.WriteLine(&quot;Width&quot;) RectWi = TextWindow.ReadNumber() TextWindow.WriteLine(&quot;Color&quot;) L = TextWindow.Read() GraphicsWindow.PenColor = L Turtle.PenUp() Turtle.MoveTo(RectX,RectY) Turtle.PenDown() Turtle.Move(RectHe) Turtle.TurnRight() Turtle.Move(RectWi) Turtle.TurnRight() Turtle.Move(RectHe) Turtle.TurnRight() Turtle.Move(RectWi) GraphicsWindow.PenColor = L GraphicsWindow.BrushColor = &quot;white&quot; GraphicsWindow.FillRectangle(GraphicsWindow.Width-GraphicsWindow.Width+10,GraphicsWindow.Height-50,300,12) GraphicsWindow.BrushColor = L GraphicsWindow.DrawBoundText(GraphicsWindow.Width-GraphicsWindow.Width+10,GraphicsWindow.Height-50,300, &quot;Pen.Color = &quot; + L) EndSub Sub Star TextWindow.Write(&quot;Enter the number of points (odd numbers only):&quot;) points = TextWindow.ReadNumber() If Math.Remainder(points,2) = 1 then angle = 180-(360/points/2) TextWindow.Write(&quot;Enter the color:&quot;) GraphicsWindow.PenColor = TextWindow.Read() TextWindow.Write(&quot;Enter the X coordinate of the stars center:&quot;) x = TextWindow.ReadNumber() TextWindow.Write(&quot;Enter the Y coordinate of the stars center:&quot;) y = TextWindow.ReadNumber() Turtle.PenUp() Turtle.MoveTo(x,y) Turtle.PenDown() Turtle.Speed = 10 side = 0 For i = 1 To 100 Turtle.Move(side) Turtle.Turn(angle) side = side + 1 EndFor Turtle.Speed = 1 Else TextWindow.Write(&quot;Invalid Number&quot;) EndIf GraphicsWindow.PenColor = L GraphicsWindow.BrushColor = &quot;white&quot; GraphicsWindow.FillRectangle(GraphicsWindow.Width-GraphicsWindow.Width+10,GraphicsWindow.Height-50,300,12) GraphicsWindow.BrushColor = L GraphicsWindow.DrawBoundText(GraphicsWindow.Width-GraphicsWindow.Width+10,GraphicsWindow.Height-50,300, &quot;Pen.Color = &quot; + L) EndSub </pre>Wed, 22 Apr 2009 03:03:56 Z2009-04-22T03:03:56Zhttp://social.msdn.microsoft.com/Forums/en-US/smallbasic/thread/eaacf826-9d12-4e3c-aa10-1b2788f160a6#1687bc27-8cdd-467f-a5f2-eccd63d3b5f8http://social.msdn.microsoft.com/Forums/en-US/smallbasic/thread/eaacf826-9d12-4e3c-aa10-1b2788f160a6#1687bc27-8cdd-467f-a5f2-eccd63d3b5f8Dratiihttp://social.msdn.microsoft.com/Profile/en-US/?user=DratiiPost your sample source code here and get featured on our blogs!A paint program created in small basic using Fremy's extention.<br/> <pre>'_____________________ 'Paint program V1 'Author Dratii 'Made with Fremy's extention '_____________________ 'Variables set = 0 Erase = 0 Pen = &quot;black&quot; Helptext = &quot;Welcome.&quot; Helptext2 = &quot;The buttons are for using the functions.&quot; Helptext3 = &quot;For some functions pressing the button again will disable the function.&quot; Helptext4 = &quot;The lables above the buttons show the current colour, size, and tool.&quot; Helptext5 = &quot;The 'Eraser' button removes parts of the drawing.&quot; Helptext6 = &quot;The 'Clear' button clears the drawing area.&quot; Helptext7 = &quot;The 'Line' button draw straight lines.&quot; Helptext8 = &quot;The 'Colour' button changes the pen colour.&quot; Helptext9 = &quot;And the '+ and -' buttons change the pensize.&quot; GraphicsWindow.MouseDown = OnMouseDown GraphicsWindow.BackgroundColor = &quot;White&quot; GraphicsWindow.PenWidth = 1 GraphicsWindow.Width = 715 GraphicsWindow.Height = 530 GraphicsWindow.MouseMove = OnMouseMove GraphicsWindow.Title = &quot;Paint Program&quot; GraphicsWindow.CanResize = &quot;no&quot; Pen = &quot;black&quot; Pwidth = 3 buttons() 'creates the buttons 'Colour function Sub Clicker Pen = Dialogs.AskForColor() If(Pen&lt;&gt;&quot;&quot;)then Erase = 0 GraphicsWindow.PenColor = Pen GraphicsWindow.BrushColor = Pen Pen2 = Pen If(Currenttool = &quot;Eraser&quot;)then 'Redraws the lable Pen2 = Pen Controls.Remove(Currenttool) GraphicsWindow.BrushColor = &quot;red&quot; Currenttool = Controls.AddLabel(120, 25, &quot;Pen&quot;) Controls.Move(Currenttool, 237, 470) GraphicsWindow.BrushColor = &quot;black&quot; GraphicsWindow.BrushColor = Pen Pen2 = Pen endif endif 'Redraws the lable Controls.Remove(CurrentColour) CurrentColour = Controls.AddRectangle(10, 10) Controls.Move(CurrentColour, 74, 478) endsub 'Help Function Sub Clicker2 GraphicsWindow.ShowMessage(Helptext, &quot;Help&quot;) GraphicsWindow.ShowMessage(Helptext2, &quot;Help&quot;) GraphicsWindow.ShowMessage(Helptext3, &quot;Help&quot;) GraphicsWindow.ShowMessage(Helptext4, &quot;Help&quot;) GraphicsWindow.ShowMessage(Helptext5, &quot;Help&quot;) GraphicsWindow.ShowMessage(Helptext6, &quot;Help&quot;) GraphicsWindow.ShowMessage(Helptext7, &quot;Help&quot;) GraphicsWindow.ShowMessage(Helptext8, &quot;Help&quot;) GraphicsWindow.ShowMessage(Helptext9, &quot;Help&quot;) endsub 'Eraser Function Sub Clicker8 If(Erase = 0)Then GraphicsWindow.PenColor = &quot;white&quot; Pen2 = Pen Pen = &quot;white&quot; 'Redraws the lable Controls.Remove(Currenttool) GraphicsWindow.BrushColor = &quot;red&quot; Currenttool = Controls.AddLabel(120, 25, &quot;Eraser&quot;) Controls.Move(Currenttool, 237, 470) GraphicsWindow.BrushColor = &quot;black&quot; Erase = 1 set = 0 Else Erase = 0 GraphicsWindow.PenColor = Pen2 Pen = Pen2 'Redraws the lable Controls.Remove(Currenttool) GraphicsWindow.BrushColor = &quot;red&quot; Currenttool = Controls.AddLabel(120, 25, &quot;Pen&quot;) Controls.Move(Currenttool, 237, 470) GraphicsWindow.BrushColor = &quot;black&quot; endif endsub 'Clear Function Sub Clicker9 GraphicsWindow.BrushColor = &quot;white&quot; GraphicsWindow.FillRectangle(0, 0, 725, 600) endsub 'Size Functions Sub Clicker10 If(Pwidth &lt; 10)then Pwidth = Pwidth + 1 endif Repen() endsub Sub Clicker11 If(Pwidth &gt; 1)then Pwidth = Pwidth - 1 endif Repen() endsub 'Line Function Sub Clicker12 If(set = 1)or(set = 2)then set = 0 'Redraws the lable Controls.Remove(Currenttool) GraphicsWindow.BrushColor = &quot;red&quot; Currenttool = Controls.AddLabel(120, 25, &quot;Pen&quot;) Controls.Move(Currenttool, 237, 470) GraphicsWindow.BrushColor = &quot;black&quot; Erase = 0 else set = 1 Pen = Pen2 GraphicsWindow.PenColor = Pen 'Redraws the lable Controls.Remove(Currenttool) GraphicsWindow.BrushColor = &quot;red&quot; Currenttool = Controls.AddLabel(120, 25, &quot;Line&quot;) Controls.Move(Currenttool, 237, 470) GraphicsWindow.BrushColor = Pen Erase = 0 EndIf endsub sub Repen GraphicsWindow.PenWidth = Pwidth 'Redraws the lable Controls.Remove(CurrentSize) GraphicsWindow.BrushColor = &quot;red&quot; CurrentSize = Controls.AddLabel(30, 25, Pwidth) Controls.Move(CurrentSize, 170, 470) GraphicsWindow.BrushColor = Pen endsub Sub buttons Controls.LoadTheme(&quot;XPBlue&quot;) GraphicsWindow.PenWidth = 1 GraphicsWindow.BrushColor=&quot;#E6F5FD&quot; GraphicsWindow.PenColor=&quot;#B2DFF8&quot; Rect1 = Controls.AddRectangle(800, 80) Controls.Move(Rect1, 0, 460) GraphicsWindow.PenWidth = Pwidth GraphicsWindow.PenColor=Pen GraphicsWindow.PenColor = &quot;black&quot; GraphicsWindow.BrushColor = &quot;black&quot; 'Lables Lable = Controls.AddLabel(120, 25, &quot;Colour&quot;) Controls.Move(Lable, 20, 470) CurrentColour = Controls.AddRectangle(10, 10) Controls.Move(CurrentColour, 74, 478) Lable2 = Controls.AddLabel(120, 25, &quot;Pen Size&quot;) Controls.Move(Lable2, 110, 470) GraphicsWindow.BrushColor = &quot;red&quot; CurrentSize = Controls.AddLabel(30, 25, &quot;3&quot;) Controls.Move(CurrentSize, 170, 470) GraphicsWindow.BrushColor = &quot;black&quot; Lable3 = Controls.AddLabel(120, 25, &quot;Tool&quot;) Controls.Move(Lable3, 200, 470) GraphicsWindow.BrushColor = &quot;red&quot; Currenttool = Controls.AddLabel(120, 25, &quot;Pen&quot;) Controls.Move(Currenttool, 237, 470) GraphicsWindow.BrushColor = &quot;black&quot; 'buttons Button = Controls.AddButton(80, 25, &quot;Colour&quot;) Controls.Move(Button, 420, 500) Controls.RegisterMouseDownEvent(Button, &quot;Clicker&quot;) Button8 = Controls.AddButton(80, 25, &quot;Eraser&quot;) Controls.Move(Button8, 20, 500) Controls.RegisterMouseDownEvent(Button8, &quot;Clicker8&quot;) Button9 = Controls.AddButton(80, 25, &quot;Clear&quot;) Controls.Move(Button9, 120, 500) Controls.RegisterMouseDownEvent(Button9, &quot;Clicker9&quot;) Button10 = Controls.AddButton(80, 25, &quot;+&quot;) Controls.Move(Button10, 520, 500) Controls.RegisterMouseDownEvent(Button10, &quot;Clicker10&quot;) Button11 = Controls.AddButton(80, 25, &quot;-&quot;) Controls.Move(Button11, 620, 500) Controls.RegisterMouseDownEvent(Button11, &quot;Clicker11&quot;) Button12 = Controls.AddButton(80, 25, &quot;Line&quot;) Controls.Move(Button12, 320, 500) Controls.RegisterMouseDownEvent(Button12, &quot;Clicker12&quot;) Button2 = Controls.AddButton(80, 25, &quot;Help&quot;) Controls.Move(Button2, 220, 500) Controls.RegisterMouseDownEvent(Button2, &quot;Clicker2&quot;) endsub Sub Line If(set = 2)then GraphicsWindow.PenColor = Pen GraphicsWindow.BrushColor = Pen GraphicsWindow.DrawLine(NewX, NewY, oldX, oldY) set = 1 endif oldX = GraphicsWindow.MouseX oldY = GraphicsWindow.MouseY If(set = 1)then Mousedown2() endif endsub 'The pen Sub Mousedown2 NewX= GraphicsWindow.MouseX NewY = GraphicsWindow.MouseY GraphicsWindow.SetPixel(NewX, NewY, Pen) set = 2 endsub Sub OnMouseDown If(set &lt;&gt; 0)then Line() endif oldX = GraphicsWindow.MouseX oldY = GraphicsWindow.MouseY EndSub Sub OnMouseMove x = GraphicsWindow.MouseX y = GraphicsWindow.MouseY If (Mouse.IsLeftButtonDown)And(set = 0) then GraphicsWindow.DrawLine(oldX, oldY, x, y) endif If(Mouse.IsLeftButtonDown)And(set = 0)And(Pwidth &gt; 3) then GraphicsWindow.SetPixel(x, y, Pen) GraphicsWindow.SetPixel(x +1, y +1, Pen) GraphicsWindow.SetPixel(x -1, y -1, Pen) GraphicsWindow.SetPixel(x +2, y +2, Pen) GraphicsWindow.DrawLine(oldX + 2, oldY + 2, x + 2, y + 2) endif oldX = x oldY = y EndSub</pre>Fri, 24 Apr 2009 10:25:57 Z2009-04-24T10:25:57Zhttp://social.msdn.microsoft.com/Forums/en-US/smallbasic/thread/eaacf826-9d12-4e3c-aa10-1b2788f160a6#0b561bc9-4499-4236-9793-56d92491d8aehttp://social.msdn.microsoft.com/Forums/en-US/smallbasic/thread/eaacf826-9d12-4e3c-aa10-1b2788f160a6#0b561bc9-4499-4236-9793-56d92491d8aeFremyCompanyhttp://social.msdn.microsoft.com/Profile/en-US/?user=FremyCompanyPost your sample source code here and get featured on our blogs!<blockquote>A paint program created in small basic using Fremy's extention.</blockquote> Looks very great ! The UI is beautiful to see.<br/><br/><img src="http://sctk3w.bay.livefilestore.com/y1pHbsh553jWQBSwoPNnCfI6mhxLz9qnWaSdRjcUiBzHjnVgq_My00tTnE4Zf5hk_3UmHwdumS5du2Lcf1TfkopQvmY1Dv0IdRL/PaintProgram.jpg" alt=""><br/><br/>Maybe you can use <code>Controls.SetText</code> instead of removing old labels and adding new ones, but for the rest, it seems great. Idem for the color preview (you can use <code>Controls.SetBackground</code>). Hum, just another small remark. The first time I clicked on the 'Line' button, I didn't find how to get the 'Pen' mode ack. Maybe you should use <code>Controls.SetText</code> too to change the caption of the button in 'Pen' when the mode is 'Line', and 'Line' when the mode is 'Pen'.<br/><br/>Now, if you want some challenge to make the program even better, you could add the possibilities to draw rectangle or circles ;)<br/><br/>Behalve the few remarks, it is good written. You take advantage of subs and made good use of comments. It's pleasant to look at your code. Keep programming like that. <hr class=sig> Fremy - Developer in VB.NET, C# and JScript ... - Feel free to try my extensionFri, 24 Apr 2009 11:50:05 Z2009-04-24T11:57:36Zhttp://social.msdn.microsoft.com/Forums/en-US/smallbasic/thread/eaacf826-9d12-4e3c-aa10-1b2788f160a6#0ea29714-07b1-4f52-a9e3-63b4207a4579http://social.msdn.microsoft.com/Forums/en-US/smallbasic/thread/eaacf826-9d12-4e3c-aa10-1b2788f160a6#0ea29714-07b1-4f52-a9e3-63b4207a4579TheToefistJUhttp://social.msdn.microsoft.com/Profile/en-US/?user=TheToefistJUPost your sample source code here and get featured on our blogs!Fun little ball bounce program.  <br/> <br/> <br/> 'Define a circle, it's size, position and speed<br/> circleRadius = 50<br/> xPosition = circleRadius<br/> yPosition = circleRadius<br/> xSpeed = 50<br/> ySpeed = 0<br/> <br/> 'Set up a timer to tick once for every frame of animation<br/> Timer.Interval = 33   '33 = 30 frames per second<br/> Timer.Tick = onTimerTick<br/> <br/> 'Set up events so you can drag the ball around<br/> GraphicsWindow.MouseMove = onMouseMove<br/> GraphicsWindow.MouseDown = onMouseDown<br/> <br/> 'Put a suiting title on the window<br/> GraphicsWindow.Title = &quot;Ball Bounce Example - Drag and Release to 'Throw' the ball&quot;<br/> <br/> <br/> '--------------------------------------------------------------------------------------------------------------<br/> 'onTimerTick   - This is what happens every frame<br/> '--------------------------------------------------------------------------------------------------------------<br/> Sub onTimerTick<br/>   <br/>   'Call the subroutine that updates the ball for this frame<br/>   Update()<br/>   <br/>   'Now Draw the frame<br/>   Redraw()<br/>   <br/> EndSub<br/> <br/> '--------------------------------------------------------------------------------------------------------------<br/> 'Update   - Updates everything to the next frame of animation<br/> '--------------------------------------------------------------------------------------------------------------<br/> Sub Update<br/>   <br/>   'Move the position of the ball by it's speed<br/>   '-------------------------------------------------<br/>   xPosition = xPosition + xSpeed<br/>   yPosition = yPosition + ySpeed<br/>   <br/>   <br/>   'Check for a bounce against any of the 4 sides of the window<br/>   '-----------------------------------------------------------------------<br/>   <br/>   'first figure out where the sides are<br/>   rightSide = GraphicsWindow.Width - circleRadius<br/>   leftSide = circleRadius<br/>   bottomSide = GraphicsWindow.Height - circleRadius<br/>   topSide = circleRadius<br/>   <br/>   'then bounce if we need to<br/>   If xPosition &gt; rightSide then     'right side<br/>     xPosition = rightSide - circleRadius<br/>     xSpeed = -xSpeed<br/>   EndIf<br/>   If xPosition &lt; leftSide then    'left side<br/>     xPosition = leftSide<br/>     xSpeed = -xSpeed<br/>   EndIf<br/>   If yPosition &gt; bottomSide then    'bottom<br/>     yPosition = bottomSide<br/>     ySpeed = -ySpeed<br/>   EndIf<br/>   If yPosition &lt; topSide then    'top<br/>     yPosition = topSide<br/>     ySpeed = -ySpeed<br/>   EndIf<br/>   <br/>   <br/>   'Gravity  (increases the speed in the down direction to make it fall)<br/>   '-------------------------------------------------------------------------------<br/>   ySpeed = ySpeed + 2<br/>   <br/>   <br/>   'Friction (make the overall speed 95% of it's current speed)<br/>   '---------------------------------------------------------------------<br/>   xSpeed = xSpeed * .95<br/>   ySpeed = ySpeed * .95<br/>   <br/>   <br/>   'Hooking - Advanced Friction (when the ball has so little energy it gets &quot;caught&quot; and can no longer move)<br/>   '-----------------------------------------------------------------------------------------------------------------------------<br/>   If Math.Abs(xSpeed) &lt; .1 then     'Math.Abs() is a simple math function to make negative numbers positive<br/>     xSpeed = 0                                'we're checking to see if the movement ( backwards (negative) or forward (positive) )<br/>   EndIf                                         'is less than .1.  If it is, just stop the movement all together.<br/>   If Math.Abs(ySpeed) &lt; .1 then<br/>     ySpeed = 0<br/>   EndIf<br/>   <br/>   <br/>   <br/> EndSub<br/> <br/> <br/> <br/> '--------------------------------------------------------------------------------------------------------------<br/> 'Redraw     - Clears the GraphicsWindow and Draws the Ball<br/> '--------------------------------------------------------------------------------------------------------------<br/> Sub Redraw<br/>   <br/>   GraphicsWindow.Clear()<br/>   <br/>   'Draw the ball - centering it on the xPosition/yPosition<br/>   circleSize = circleRadius * 2<br/>   GraphicsWindow.DrawEllipse(xPosition-circleRadius, yPosition-circleRadius, circleSize, circleSize)<br/>  <br/> EndSub<br/> <br/> <br/> <br/> '--------------------------------------------------------------------------------------------------------------<br/> 'onMouseDown    - The mouse button was pressed<br/> '--------------------------------------------------------------------------------------------------------------<br/> Sub onMouseDown<br/>   <br/>   'save the position of the mouse in variables<br/>   xOld = GraphicsWindow.MouseX<br/>   yOld = GraphicsWindow.MouseY<br/>   <br/>   'move the ball to where the mouse is<br/>   xPosition = xOld<br/>   yPosition = yOld<br/>   <br/> EndSub <br/> <br/> <br/> <br/> '--------------------------------------------------------------------------------------------------------------<br/> 'onMouseMove    - The mouse was moved<br/> '--------------------------------------------------------------------------------------------------------------<br/> Sub onMouseMove<br/>   <br/>   'see if the button is down.  If it is, then we're dragging the ball<br/>   If Mouse.IsLeftButtonDown Then<br/>     <br/>     'save the position of the mouse in variables<br/>     x = GraphicsWindow.MouseX<br/>     y = GraphicsWindow.MouseY<br/>     <br/>     'find out how far the mouse moved since the last time we we're here<br/>     'this will be the new speed of the ball<br/>     xSpeed = x - xOld<br/>     ySpeed = y - yOld<br/>     <br/>     'move the ball to where the mouse is<br/>     xPosition = x<br/>     yPosition = y<br/>     <br/>     'this mouse position is old, save where it is so we can figure out <br/>     'the speed next time we're here<br/>     xOld = x<br/>     yOld = y<br/> <br/>   EndIf<br/> <br/> EndSub <br/>   <br/>   <br/>     <br/><hr class="sig">Toefist Productions LLC, Minnetonka, MNSat, 25 Apr 2009 09:36:16 Z2009-04-25T09:36:16Zhttp://social.msdn.microsoft.com/Forums/en-US/smallbasic/thread/eaacf826-9d12-4e3c-aa10-1b2788f160a6#d1ae0e72-7bb1-42d5-8d57-80cea745432ahttp://social.msdn.microsoft.com/Forums/en-US/smallbasic/thread/eaacf826-9d12-4e3c-aa10-1b2788f160a6#d1ae0e72-7bb1-42d5-8d57-80cea745432aStendechttp://social.msdn.microsoft.com/Profile/en-US/?user=StendecPost your sample source code here and get featured on our blogs!Hello TheToefistJU,<br/> <br/>I like your use of physics to make a realistic animation. I feel you could improve on it though if you used Shapes rather than GraphicsWindow.DrawEllipse(). With Shapes you can Move or Animate to a new position without having to erase the old position. This would allow you to add a background that wouldn't get corrupted when the ball moved over it.<br/> <br/> I have made slight modifications to your program to illustrate what I mean. I have added a Shapes ball that is Moved to the new position. I have left the original but removed the GraphicsWindow.Clear(). This leaves a trail of the ball position. Notice how the solid ball does not erase the trail as it moves over it.<br/> By the way; if you use Import and Publish (especially for larger files) it helps to follow a thread without a lot of scrolling.<br/> <br/> Import HNQ963Sat, 25 Apr 2009 10:39:58 Z2009-04-26T19:17:42Zhttp://social.msdn.microsoft.com/Forums/en-US/smallbasic/thread/eaacf826-9d12-4e3c-aa10-1b2788f160a6#d8813fc5-a4b4-4c0a-ab0e-bc404a6533efhttp://social.msdn.microsoft.com/Forums/en-US/smallbasic/thread/eaacf826-9d12-4e3c-aa10-1b2788f160a6#d8813fc5-a4b4-4c0a-ab0e-bc404a6533efRushworkshttp://social.msdn.microsoft.com/Profile/en-US/?user=RushworksPost your sample source code here and get featured on our blogs!<blockquote>By the way; if you use Import and Publish (especially for larger files) it helps to follow a thread without a lot of scrolling.<br/></blockquote> Pictures are nice too.<br/>Sun, 26 Apr 2009 02:01:32 Z2009-04-26T02:01:32Zhttp://social.msdn.microsoft.com/Forums/en-US/smallbasic/thread/eaacf826-9d12-4e3c-aa10-1b2788f160a6#81dc2ad6-a3b9-4e31-aea8-17cef7ae5f85http://social.msdn.microsoft.com/Forums/en-US/smallbasic/thread/eaacf826-9d12-4e3c-aa10-1b2788f160a6#81dc2ad6-a3b9-4e31-aea8-17cef7ae5f85Jason Jacqueshttp://social.msdn.microsoft.com/Profile/en-US/?user=Jason%20JacquesPost your sample source code here and get featured on our blogs!<p>Surprised someone has not already posted this but how about some classic Snake action?<br/><br/>Code can be imported using the ID WMX007 or seen here: <a href="http://smallbasic.com/program/?WMX007">http://smallbasic.com/program/?WMX007</a><br/><br/>Instructions: Avoid the walls and yourself while eating as many food items as possible and growing in length. Movement is controlled using the left and right arrow keys. Turns are relative to your current direction.<br/><br/>I've tried to keep the code quite clean and flexible, but the game could be improved with the addition of multiple concurrent food items or maybe even walls! Comments welcome.<br/><br/>With regard to Small Basic itself, I'd welcome the ability to set the location of a shape when creating it, unless I am just being blind and missed it! My implementation sometimes flickers snake segments or food items in the top, left corner as they are created before being moved to their correct location.<br/><br/>    As an off-topic aside I definitely think the publish button should have a confirmation dialogue box - somethings just shouldn't be published!<br/><br/>Thanks for the consideration, hope it's mildly enjoyable!<br/><br/>Jason.</p>Sun, 03 May 2009 22:30:59 Z2009-05-03T23:11:43Zhttp://social.msdn.microsoft.com/Forums/en-US/smallbasic/thread/eaacf826-9d12-4e3c-aa10-1b2788f160a6#dab3e74a-bfde-4445-a000-d12187fb6e34http://social.msdn.microsoft.com/Forums/en-US/smallbasic/thread/eaacf826-9d12-4e3c-aa10-1b2788f160a6#dab3e74a-bfde-4445-a000-d12187fb6e34Jason Jacqueshttp://social.msdn.microsoft.com/Profile/en-US/?user=Jason%20JacquesPost your sample source code here and get featured on our blogs!OK, so I realise now that Snake is already a featured example for Small Basic (though unfortunately the featured code doesn't work correctly in v0.4 and I was unable to determine why) - that's what happens when you don't check the second page of the blog! <div><br/></div> <div>So instead, sticking with the theme of classic games, for your consideration: Asteroids.</div> <div><br/></div> <div>Code can be imported using the ID QFL408 or seen here: <a href="http://smallbasic.com/program/?QFL408">http://smallbasic.com/program/?QFL408</a></div> <div><br/></div> <div>Instructions: Destroy all the asteroids, by shooting them, avoiding getting hit yourself. Left and right arrows keys to rotate, forward and backwards arrow keys to adjust ship speed. Space bar to fire. P key to pause/resume.</div> <div><br/></div> <div>I'm sure the game could benefit from the addition of de-facto standard three lives, some more interesting graphics and maybe even aliens.</div> <div><br/></div> <div>As before, comments welcome!</div> <div><br/></div> <div>Again, thanks for the consideration and I hope you enjoy!</div> <div><br/></div> <div>Jason.</div>Fri, 08 May 2009 19:10:14 Z2009-05-08T19:10:53Zhttp://social.msdn.microsoft.com/Forums/en-US/smallbasic/thread/eaacf826-9d12-4e3c-aa10-1b2788f160a6#ed2215f3-76b7-4eb2-9407-f00fcee2961ahttp://social.msdn.microsoft.com/Forums/en-US/smallbasic/thread/eaacf826-9d12-4e3c-aa10-1b2788f160a6#ed2215f3-76b7-4eb2-9407-f00fcee2961aStendechttp://social.msdn.microsoft.com/Profile/en-US/?user=StendecPost your sample source code here and get featured on our blogs!Very impressive Asteroids game Jason Jacques. Great job!<br/>Fri, 08 May 2009 22:10:49 Z2009-05-08T22:10:49Zhttp://social.msdn.microsoft.com/Forums/en-US/smallbasic/thread/eaacf826-9d12-4e3c-aa10-1b2788f160a6#faa2d982-107f-4d28-bad8-60ed4f3db891http://social.msdn.microsoft.com/Forums/en-US/smallbasic/thread/eaacf826-9d12-4e3c-aa10-1b2788f160a6#faa2d982-107f-4d28-bad8-60ed4f3db891Vijaye Rajihttp://social.msdn.microsoft.com/Profile/en-US/?user=Vijaye%20RajiPost your sample source code here and get featured on our blogs!Nice game, Jason.   Asteroids is the sample of this week!<br/><br/><a href="http://blogs.msdn.com/smallbasic">http://blogs.msdn.com/smallbasic</a><br/><br/><img src="http://smallbasic.com/drop/asteroids.png" alt="">Tue, 12 May 2009 18:15:15 Z2009-05-12T18:15:15Zhttp://social.msdn.microsoft.com/Forums/en-US/smallbasic/thread/eaacf826-9d12-4e3c-aa10-1b2788f160a6#e8988303-31dc-4e43-9555-07983a9bb014http://social.msdn.microsoft.com/Forums/en-US/smallbasic/thread/eaacf826-9d12-4e3c-aa10-1b2788f160a6#e8988303-31dc-4e43-9555-07983a9bb014Vijaye Rajihttp://social.msdn.microsoft.com/Profile/en-US/?user=Vijaye%20RajiPost your sample source code here and get featured on our blogs!<p>I've modified Jason's Asteroids to include images.  The new variant can be downloaded as: <strong>QFL408-0<br/><br/></strong></p> <img src="http://smallbasic.com/drop/asteroids_1.png" alt="">Tue, 12 May 2009 20:56:50 Z2009-05-12T20:56:50Zhttp://social.msdn.microsoft.com/Forums/en-US/smallbasic/thread/eaacf826-9d12-4e3c-aa10-1b2788f160a6#22eaec38-5023-4201-b1d2-3307b4d259cdhttp://social.msdn.microsoft.com/Forums/en-US/smallbasic/thread/eaacf826-9d12-4e3c-aa10-1b2788f160a6#22eaec38-5023-4201-b1d2-3307b4d259cdTrain04http://social.msdn.microsoft.com/Profile/en-US/?user=Train04Post your sample source code here and get featured on our blogs!Hi Im new to small basic but have been programming in VB.net for a while I have created a paint like program that can draw staright lines There are four colours to choose from. If you want the code type SBV954 into import. <img alt=""> (Could someon tell me how to upload a photo because I would like to include a screen shot thank you)<br/>Wed, 13 May 2009 11:11:06 Z2009-05-13T11:21:21Zhttp://social.msdn.microsoft.com/Forums/en-US/smallbasic/thread/eaacf826-9d12-4e3c-aa10-1b2788f160a6#47b90739-5141-4d14-94e7-2524cf558886http://social.msdn.microsoft.com/Forums/en-US/smallbasic/thread/eaacf826-9d12-4e3c-aa10-1b2788f160a6#47b90739-5141-4d14-94e7-2524cf558886Rushworkshttp://social.msdn.microsoft.com/Profile/en-US/?user=RushworksPost your sample source code here and get featured on our blogs!Posting a screen shot<br/><a href="http://social.msdn.microsoft.com/Forums/en-US/smallbasic/thread/c658843c-fd47-477e-93b0-01dcffcd6af4"><br/></a>You must upload your image to a third party site (Flicker, your own personal website or some other site), then edit the HTML of your post to include the picture.<br/><br/>&lt;img alt=&quot;&quot; src=&quot;<a href="http://farm4.static.flickr.com/3044/3102500861_398a6a988f.jpg?v=0"><span style="color:#0033cc">http://farm4.static.flickr.com/3044/3102500861_398a6a988f.jpg?v=0</span></a>&quot; /&gt;<br/>Wed, 13 May 2009 16:40:16 Z2009-05-13T16:40:16Zhttp://social.msdn.microsoft.com/Forums/en-US/smallbasic/thread/eaacf826-9d12-4e3c-aa10-1b2788f160a6#db30d047-a2a1-45da-a72c-516543a11a54http://social.msdn.microsoft.com/Forums/en-US/smallbasic/thread/eaacf826-9d12-4e3c-aa10-1b2788f160a6#db30d047-a2a1-45da-a72c-516543a11a54litdevhttp://social.msdn.microsoft.com/Profile/en-US/?user=litdevPost your sample source code here and get featured on our blogs!Excellent game - nice work Jason!<br/> <br/> I altered it slightly to handle the auto-repeat and auto-delay introduced by my OS for key presses that gives some jerky rotations.  Also each 'fire' requires a separate press of the space bar with these mods.<br/> <br/> QFL408-3<br/>Wed, 13 May 2009 19:31:45 Z2009-05-13T19:31:45Zhttp://social.msdn.microsoft.com/Forums/en-US/smallbasic/thread/eaacf826-9d12-4e3c-aa10-1b2788f160a6#c51fd5b4-3725-4689-8318-b4e376fca5e4http://social.msdn.microsoft.com/Forums/en-US/smallbasic/thread/eaacf826-9d12-4e3c-aa10-1b2788f160a6#c51fd5b4-3725-4689-8318-b4e376fca5e4FremyCompanyhttp://social.msdn.microsoft.com/Profile/en-US/?user=FremyCompanyPost your sample source code here and get featured on our blogs!For the game, maybe we need a maxUserSpeed, because we can go faster than the light, currently :)<br/>It's fun, but only because you can shot all asteroids but one, go the the ligth speed, and wait until the asteroid hit you.<br/><br/>Also, it would be great to have a point lost each time we fire. So, it would be more time-rapporting to shot with precision than with mass.  <hr class=sig> Fremy - Developer in VB.NET, C# and JScript ... - Feel free to try my extensionThu, 14 May 2009 10:08:47 Z2009-05-14T10:10:16Zhttp://social.msdn.microsoft.com/Forums/en-US/smallbasic/thread/eaacf826-9d12-4e3c-aa10-1b2788f160a6#23831ed6-0727-4a57-83dd-2a30bebce79chttp://social.msdn.microsoft.com/Forums/en-US/smallbasic/thread/eaacf826-9d12-4e3c-aa10-1b2788f160a6#23831ed6-0727-4a57-83dd-2a30bebce79cJason Jacqueshttp://social.msdn.microsoft.com/Profile/en-US/?user=Jason%20JacquesPost your sample source code here and get featured on our blogs!It's great to see how into my game everyone is and I'm glad it hasn't been too difficult for you to achieve your modifications - feel free to keep hacking at it! <div><br/></div> <div>I did notice the issue with the maximum speed, but I was never very good at asteroids so always took it slow - seems not everyone feels the same way! I've updated litdev's modifications with a maximum speed parameter (maxSpeed, found in the player setting sections) and added inertia as would have been found in the original game - you can disable it by setting it to zero if you'd rather not slow down.</div> <div><br/></div> <div>During development I actually considered taking a point off for each shot, but dismissed it. However, your point about accuracy is well heeded (I like to spin and fire every second or so...) so I've updated the code appropriately. I've also done some general tidying of the code for example removing the now superfluous player and rock colours.</div> <div><br/></div> <div>Get the new code using the ID QFL408-4 or view online here: <a title="http://smallbasic.com/program/?QFL408-4" href="http://smallbasic.com/program/?QFL408-4">http://smallbasic.com/program/?QFL408-4</a></div> <div><br/></div> <div>Thanks for your input.</div> <div><br/></div> <div>Jason.</div>Thu, 14 May 2009 16:25:01 Z2009-05-14T16:25:01Zhttp://social.msdn.microsoft.com/Forums/en-US/smallbasic/thread/eaacf826-9d12-4e3c-aa10-1b2788f160a6#a03a4291-e640-4e6c-b663-dbeab35c7b04http://social.msdn.microsoft.com/Forums/en-US/smallbasic/thread/eaacf826-9d12-4e3c-aa10-1b2788f160a6#a03a4291-e640-4e6c-b663-dbeab35c7b04Vijaye Rajihttp://social.msdn.microsoft.com/Profile/en-US/?user=Vijaye%20RajiPost your sample source code here and get featured on our blogs!<strong>QFL408-4</strong> is now promoted to <strong>ASTEROIDS.  </strong>You can import this version using the id: <strong>ASTEROIDS</strong>Thu, 14 May 2009 17:09:08 Z2009-05-14T17:09:36Zhttp://social.msdn.microsoft.com/Forums/en-US/smallbasic/thread/eaacf826-9d12-4e3c-aa10-1b2788f160a6#6ae79da4-39f6-4b6e-baa3-566b1bd712d8http://social.msdn.microsoft.com/Forums/en-US/smallbasic/thread/eaacf826-9d12-4e3c-aa10-1b2788f160a6#6ae79da4-39f6-4b6e-baa3-566b1bd712d8Rushworkshttp://social.msdn.microsoft.com/Profile/en-US/?user=RushworksPost your sample source code here and get featured on our blogs!<br/>QuickBasic had Gorillas and now Small Basic does too!<br/><br/><br/><img src="http://farm4.static.flickr.com/3380/3536737323_b13a5b9663.jpg?v=0" alt="" width=350 height=250>  <img src="http://farm4.static.flickr.com/3611/3536737131_bdd7b3578b.jpg?v=0" alt="" width=350 height=250> <br/><br/><br/>Image, Sound, Exe and Source files can be downloaded here<br/><a href="http://code.msdn.microsoft.com/SmallBasicGorillas"><span style="color:#0033cc">http://code.msdn.microsoft.com/SmallBasicGorillas</span></a><br/>Sun, 17 May 2009 01:47:18 Z2009-05-17T01:47:18Zhttp://social.msdn.microsoft.com/Forums/en-US/smallbasic/thread/eaacf826-9d12-4e3c-aa10-1b2788f160a6#325f07a7-9a09-4061-bdbd-186998bc5128http://social.msdn.microsoft.com/Forums/en-US/smallbasic/thread/eaacf826-9d12-4e3c-aa10-1b2788f160a6#325f07a7-9a09-4061-bdbd-186998bc5128The Hackerhttp://social.msdn.microsoft.com/Profile/en-US/?user=The%20HackerPost your sample source code here and get featured on our blogs!<p>I made a 21/Black Jack in the textwindow. I'm going to make it in the graphics window soon and will also add betting. I am also working on five card draw and texas hold'em. <br/><br/>Import Code: NFB246</p> <p>There might still be a few bugs, so let me know if you find one.</p>Wed, 20 May 2009 03:28:40 Z2009-05-20T03:29:11Zhttp://social.msdn.microsoft.com/Forums/en-US/smallbasic/thread/eaacf826-9d12-4e3c-aa10-1b2788f160a6#1fb8a0cb-d788-4f30-a649-98d50594f3a4http://social.msdn.microsoft.com/Forums/en-US/smallbasic/thread/eaacf826-9d12-4e3c-aa10-1b2788f160a6#1fb8a0cb-d788-4f30-a649-98d50594f3a4Stendechttp://social.msdn.microsoft.com/Profile/en-US/?user=StendecPost your sample source code here and get featured on our blogs!I'm sorry, but I just had to correct your instructions. If you wish to use it, import NFB246-0.<br/>In the version of the game that I know you can only have a maximum of five cards. you would also need to check for this.<br/>Wed, 20 May 2009 17:56:46 Z2009-05-20T17:56:46Zhttp://social.msdn.microsoft.com/Forums/en-US/smallbasic/thread/eaacf826-9d12-4e3c-aa10-1b2788f160a6#4ac4e926-db52-43ca-b038-a67169507e1ahttp://social.msdn.microsoft.com/Forums/en-US/smallbasic/thread/eaacf826-9d12-4e3c-aa10-1b2788f160a6#4ac4e926-db52-43ca-b038-a67169507e1aosimonbinladenhttp://social.msdn.microsoft.com/Profile/en-US/?user=osimonbinladenPost your sample source code here and get featured on our blogs!I have made a minesweeper game in Small Basic. <div>It is very basic. (Pun not intended)</div> <div>Basically all it is missing out on is fancy graphics and the auto thingy. (will explain later)</div> <div><br/></div> <div>The import code is: WGT176</div> <div><br/></div> <div>It works the same as the windows minesweeper.</div> <div>Except, when it is a blank square it doesn't auto click all the squares around it.</div> <div>I wasn't sure how to add that feature due to the restrictions in sub routines.</div> <div>If anyone could point me into the right direction or anything for that, that would be nice.</div> <div><br/></div> <div>It also allows you to change the color schemes and enter cheats. (For debugging purposes)</div> <div><br/></div> <div>Feedback would be nice~</div> <div><br/></div> <div>-Simon</div> <div><br/></div>Sun, 31 May 2009 23:55:32 Z2009-05-31T23:55:32Zhttp://social.msdn.microsoft.com/Forums/en-US/smallbasic/thread/eaacf826-9d12-4e3c-aa10-1b2788f160a6#b57ad703-297c-4579-8c9d-b7dc85758375http://social.msdn.microsoft.com/Forums/en-US/smallbasic/thread/eaacf826-9d12-4e3c-aa10-1b2788f160a6#b57ad703-297c-4579-8c9d-b7dc85758375Stendechttp://social.msdn.microsoft.com/Profile/en-US/?user=StendecPost your sample source code here and get featured on our blogs!<p>Looking at the original Minesweeper, it appears to be that the rule for clearing the squares would lend itself to a recursive solution. It goes something like this;<br/><br/>If square is blank (no neighbouring mines) then<br/>for each surrounding square, if not cleared clear square.<br/>if square cleared is blank then<br/>for each surrounding square, if not cleared clear square.<br/><br/>etc.<br/><br/>The check for the square not being cleared should stop any infinite looping behaviour (e.g. where you have four blank squares together and you might otherwise go from square 1 to 2 to 3 to 4 to 1 etc.). Each call to the recursive routine would be unique by virtue of the x and y co-ordinates. These should be &quot;passed&quot; by using the stack.<br/><br/>There is an example program that illustrates recursion and using the stack which I have reproduced here for convenience. The recursive aspect is that DrawTree is called from within DrawTree.<br/>Recursive programming is pretty tricky, but if you feel you can handle it give it a go. You get a tremendous feeling of achievement if it works!<br/><br/>angle = 30<br/>delta = 10<br/>distance = 60<br/>Turtle.Speed = 9<br/>DrawTree()</p> <p>Sub DrawTree<br/>  If (distance &gt; 0) Then<br/>    Turtle.Move(distance)<br/>    Turtle.Turn(angle)<br/>    <br/>    Stack.PushValue(&quot;distance&quot;, distance)<br/>    distance = distance - delta<br/>    DrawTree()<br/>    Turtle.Turn(-angle * 2)<br/>    DrawTree()<br/>    Turtle.Turn(angle)<br/>    distance = Stack.PopValue(&quot;distance&quot;)<br/>    <br/>    Turtle.Move(-distance)<br/>  EndIf<br/>EndSub</p>Mon, 01 Jun 2009 18:37:55 Z2009-06-01T18:43:42Zhttp://social.msdn.microsoft.com/Forums/en-US/smallbasic/thread/eaacf826-9d12-4e3c-aa10-1b2788f160a6#409817bc-cc2a-4f17-b658-550584b2f891http://social.msdn.microsoft.com/Forums/en-US/smallbasic/thread/eaacf826-9d12-4e3c-aa10-1b2788f160a6#409817bc-cc2a-4f17-b658-550584b2f891litdevhttp://social.msdn.microsoft.com/Profile/en-US/?user=litdevPost your sample source code here and get featured on our blogs!Simon,<br/> <br/> This is a good example for the use of stacks as Stendec suggested.<br/> One possible method is GNW384.Tue, 02 Jun 2009 20:38:53 Z2009-06-02T20:44:56Zhttp://social.msdn.microsoft.com/Forums/en-US/smallbasic/thread/eaacf826-9d12-4e3c-aa10-1b2788f160a6#54c55162-831c-4c28-9a38-20e543fc9953http://social.msdn.microsoft.com/Forums/en-US/smallbasic/thread/eaacf826-9d12-4e3c-aa10-1b2788f160a6#54c55162-831c-4c28-9a38-20e543fc9953osimonbinladenhttp://social.msdn.microsoft.com/Profile/en-US/?user=osimonbinladenPost your sample source code here and get featured on our blogs!Wow, that is amazing. Thanks heaps.  <div>That really helped me out. ;)</div> <div>I didn't think that was possible. Ha ha.</div> <div>I tried to use the stack method but mine didn't work so well...</div> <div>But your one, it makes sense. I realize what I did wrong. Ha ha.</div> <div>Thanks for that~!</div>Thu, 04 Jun 2009 04:42:47 Z2009-06-04T04:42:47Zhttp://social.msdn.microsoft.com/Forums/en-US/smallbasic/thread/eaacf826-9d12-4e3c-aa10-1b2788f160a6#c4bf939c-c0fd-4a30-9cd5-bfe635463325http://social.msdn.microsoft.com/Forums/en-US/smallbasic/thread/eaacf826-9d12-4e3c-aa10-1b2788f160a6#c4bf939c-c0fd-4a30-9cd5-bfe635463325litdevhttp://social.msdn.microsoft.com/Profile/en-US/?user=litdevPost your sample source code here and get featured on our blogs!Simon,<br/><br/>I looked at it again and actually all the logic around the 'complete' variable is unnecssary and can be removed, since all neighbours are checked anyway GNW384-1.Thu, 04 Jun 2009 08:37:19 Z2009-06-04T08:37:19Zhttp://social.msdn.microsoft.com/Forums/en-US/smallbasic/thread/eaacf826-9d12-4e3c-aa10-1b2788f160a6#c0e677ad-2216-41b9-90a1-026c1070de6ehttp://social.msdn.microsoft.com/Forums/en-US/smallbasic/thread/eaacf826-9d12-4e3c-aa10-1b2788f160a6#c0e677ad-2216-41b9-90a1-026c1070de6ebigdaddyohttp://social.msdn.microsoft.com/Profile/en-US/?user=bigdaddyoPost your sample source code here and get featured on our blogs!<p>I made a Stargate 80's arcade game in Small Basic:<br/><br/><img src="http://www.outtaether.com/shared/stargates screenshot.JPG" alt=""><br/><br/>It pushed my 3 GHz P4 to do 30 frames/sec, I think it was mostly the movement of the loaded images.  Unfortunately it won't upload, maybe because the file size is 71k - I know I overdid it on it but it was alot of fun making it.  You can download it from FileFront here, along with the sounds I made with some 80's style synthesizers:<br/><br/><a title="http://files.filefront.com/Stargates+ver+10zip/;13880824;/fileinfo.html" href="http://files.filefront.com/Stargates+ver+10zip/;13880824;/fileinfo.html">http://files.filefront.com/Stargates+ver+10zip/;13880824;/fileinfo.html</a><br/><br/>If you make changes, don't put photo-realistic images in it, it'll remove the spirit of the game!  One part of it I think that can be useful is it filters the timer to get a bit more resolution, at the expense of lag determining what frame rate it should run at.  Seemed to help significantly smooth the game.  It's called StarGates being on a Microsoft compiler...<br/><br/>I made a separate post for questions here if you like since this thread is very full: <br/><br/><a href="http://social.msdn.microsoft.com/Forums/en-US/smallbasic/thread/6c6dea16-fa11-4d24-84da-d422f3e17daa">http://social.msdn.microsoft.com/Forums/en-US/smallbasic/thread/6c6dea16-fa11-4d24-84da-d422f3e17daa</a></p>Wed, 10 Jun 2009 15:33:55 Z2009-06-10T18:52:45Zhttp://social.msdn.microsoft.com/Forums/en-US/smallbasic/thread/eaacf826-9d12-4e3c-aa10-1b2788f160a6#02c70120-e253-437b-9cb1-a05d6613ecdahttp://social.msdn.microsoft.com/Forums/en-US/smallbasic/thread/eaacf826-9d12-4e3c-aa10-1b2788f160a6#02c70120-e253-437b-9cb1-a05d6613ecdaJochemPhttp://social.msdn.microsoft.com/Profile/en-US/?user=JochemPPost your sample source code here and get featured on our blogs!<pre> TextWindow.Write(&quot;Enter the degrees of the circle&quot;) circledegrees = TextWindow.Read() TextWindow.Write(&quot;Enter the diameter of the circle&quot;) diameter = TextWindow.Read() Turtle.X = GraphicsWindow.Width / 2 Turtle.Y = 150 For i = 1 To circledegrees / 10 Turtle.Move(diameter) Turtle.Angle = i*10 EndFor</pre> <br/> <br/>Fri, 19 Jun 2009 15:25:10 Z2009-06-19T15:25:10Zhttp://social.msdn.microsoft.com/Forums/en-US/smallbasic/thread/eaacf826-9d12-4e3c-aa10-1b2788f160a6#9e3a2e65-538b-4c03-9f52-549b593a3c4ehttp://social.msdn.microsoft.com/Forums/en-US/smallbasic/thread/eaacf826-9d12-4e3c-aa10-1b2788f160a6#9e3a2e65-538b-4c03-9f52-549b593a3c4elitdevhttp://social.msdn.microsoft.com/Profile/en-US/?user=litdevPost your sample source code here and get featured on our blogs!JochemP,<br/> <br/> Good program.  Looking at the distance the turtle moves:<br/> <br/> A full circle is 360 degrees would be a total distance (circumference) of <br/> <br/> <em>circumference= pi.diameter</em> <br/> <br/> So to go a total perimeter of circledegrees we need to travel <em>perimeter</em> <em>= </em> <em>circumference</em> <em>*circledegree/360</em> <br/> <br/> There are <em>circledegrees/10</em> steps taken by the turtle, so each step should go <em>step = </em> <em>perimeter</em> <em>/ (circledegrees/10)<br/> </em> <br/> When we put this together:<br/> <em><br/> step = pi.diameter*circledegree/360/(circledegrees/10) = pi.diameter/36</em> <br/> <br/> Try the following to use the diameter input to set the diameter of the arc in pixels.<br/> <br/> For i = 1 To circledegrees / 10<br/>   Turtle.Move(Math.Pi*diameter/36)<br/>   Turtle.Angle = i*10<br/> EndFor<br/> <br/>Fri, 19 Jun 2009 20:11:03 Z2009-06-19T20:11:03Zhttp://social.msdn.microsoft.com/Forums/en-US/smallbasic/thread/eaacf826-9d12-4e3c-aa10-1b2788f160a6#364c0a36-4328-4783-b1c1-f847d8c5195fhttp://social.msdn.microsoft.com/Forums/en-US/smallbasic/thread/eaacf826-9d12-4e3c-aa10-1b2788f160a6#364c0a36-4328-4783-b1c1-f847d8c5195fbigdaddyohttp://social.msdn.microsoft.com/Profile/en-US/?user=bigdaddyoPost your sample source code here and get featured on our blogs!I wonder if you could use his program to figure out PI, like I think it was Pythagoras who did by inscribing tons of triangles in a circle?Fri, 19 Jun 2009 22:13:01 Z2009-06-19T22:13:01Zhttp://social.msdn.microsoft.com/Forums/en-US/smallbasic/thread/eaacf826-9d12-4e3c-aa10-1b2788f160a6#5d23c772-48ce-43e2-aa5e-21a9f3309251http://social.msdn.microsoft.com/Forums/en-US/smallbasic/thread/eaacf826-9d12-4e3c-aa10-1b2788f160a6#5d23c772-48ce-43e2-aa5e-21a9f3309251Suduadibhttp://social.msdn.microsoft.com/Profile/en-US/?user=SuduadibPost your sample source code here and get featured on our blogs!Simple colors palette<br/> Code can be imported using the ID SGS247<br/> <br/> <pre>size = &quot;medium&quot; 'enter here the size of the palette - &quot;small&quot;, &quot;medium&quot; or &quot;large&quot; sid = 40 'sid = side of unit square, 40 pixels for &quot;medium&quot; size If (size = &quot;small&quot;) Then sid = 30 ElseIf (size = &quot;large&quot;) Then sid = 50 EndIf int=math.Floor(sid/10) 'int = lenght of interval GraphicsWindow.Title = &quot;Palette&quot; GraphicsWindow.Height = 12*(sid+int)+int GraphicsWindow.Width = 22*(sid+int)+int GraphicsWindow.CanResize=&quot;false&quot; GraphicsWindow.BackgroundColor = &quot;black&quot; GraphicsWindow.Show() GraphicsWindow.FontName=&quot;arial&quot; GraphicsWindow.FontSize=30 GraphicsWindow.Fontbold=&quot;true&quot; color[1]=&quot;IndianRed&quot; color[2]=&quot;LightCoral&quot; color[3]=&quot;Salmon&quot; color[4]=&quot;DarkSalmon&quot; color[5]=&quot;LightSalmon&quot; color[6]=&quot;Crimson&quot; color[7]=&quot;Red&quot; color[8]=&quot;FireBrick&quot; color[9]=&quot;DarkRed&quot; color[10]=&quot;Pink&quot; color[11]=&quot;LightPink&quot; color[12]=&quot;HotPink&quot; color[13]=&quot;DeepPink&quot; color[14]=&quot;MediumVioletRed&quot; color[15]=&quot;PaleVioletRed&quot; color[16]=&quot;LightSalmon&quot; color[17]=&quot;Coral&quot; color[18]=&quot;Tomato&quot; color[19]=&quot;OrangeRed&quot; color[20]=&quot;DarkOrange&quot; color[21]=&quot;Orange&quot; color[22]=&quot;Gold&quot; color[23]=&quot;Yellow&quot; color[24]=&quot;LightYellow&quot; color[25]=&quot;LemonChiffon&quot; color[26]=&quot;LightGoldenRodYellow&quot; color[27]=&quot;PapayaWhip&quot; color[28]=&quot;Moccasin&quot; color[29]=&quot;PeachPuff&quot; color[30]=&quot;PaleGoldenrod&quot; color[31]=&quot;Khaki&quot; color[32]=&quot;DarkKhaki&quot; color[33]=&quot;Lavender&quot; color[34]=&quot;Thistle&quot; color[35]=&quot;Plum&quot; color[36]=&quot;Violet&quot; color[37]=&quot;Orchid&quot; color[38]=&quot;Fuchsia&quot; color[39]=&quot;Magenta&quot; color[40]=&quot;MediumOrchid&quot; color[41]=&quot;MediumPurple&quot; color[42]=&quot;BlueViolet&quot; color[43]=&quot;DarkViolet&quot; color[44]=&quot;DarkOrchid&quot; color[45]=&quot;DarkMagenta&quot; color[46]=&quot;Purple&quot; color[47]=&quot;Indigo&quot; color[48]=&quot;SlateBlue&quot; color[49]=&quot;DarkSlateBlue&quot; color[50]=&quot;MediumSlateBlue&quot; color[51]=&quot;GreenYellow&quot; color[52]=&quot;Chartreuse&quot; color[53]=&quot;LawnGreen&quot; color[54]=&quot;Lime&quot; color[55]=&quot;LimeGreen&quot; color[56]=&quot;PaleGreen&quot; color[57]=&quot;LightGreen&quot; color[58]=&quot;MediumSpringGreen&quot; color[59]=&quot;SpringGreen&quot; color[60]=&quot;MediumSeaGreen&quot; color[61]=&quot;SeaGreen&quot; color[62]=&quot;ForestGreen&quot; color[63]=&quot;Green&quot; color[64]=&quot;DarkGreen&quot; color[65]=&quot;YellowGreen&quot; color[66]=&quot;OliveDrab&quot; color[67]=&quot;Olive&quot; color[68]=&quot;DarkOliveGreen&quot; color[69]=&quot;MediumAquamarine&quot; color[70]=&quot;DarkSeaGreen&quot; color[71]=&quot;LightSeaGreen&quot; color[72]=&quot;DarkCyan&quot; color[73]=&quot;Teal&quot; color[74]=&quot;Aqua&quot; color[75]=&quot;Cyan&quot; color[76]=&quot;LightCyan&quot; color[77]=&quot;PaleTurquoise&quot; color[78]=&quot;Aquamarine&quot; color[79]=&quot;Turquoise&quot; color[80]=&quot;MediumTurquoise&quot; color[81]=&quot;DarkTurquoise&quot; color[82]=&quot;CadetBlue&quot; color[83]=&quot;SteelBlue&quot; color[84]=&quot;LightSteelBlue&quot; color[85]=&quot;PowderBlue&quot; color[86]=&quot;LightBlue&quot; color[87]=&quot;SkyBlue&quot; color[88]=&quot;LightSkyBlue&quot; color[89]=&quot;DeepSkyBlue&quot; color[90]=&quot;DodgerBlue&quot; color[91]=&quot;CornflowerBlue&quot; color[92]=&quot;MediumSlateBlue&quot; color[93]=&quot;RoyalBlue&quot; color[94]=&quot;Blue&quot; color[95]=&quot;MediumBlue&quot; color[96]=&quot;DarkBlue&quot; color[97]=&quot;Navy&quot; color[98]=&quot;MidnightBlue&quot; color[99]=&quot;Cornsilk&quot; color[100]=&quot;BlanchedAlmond&quot; color[101]=&quot;Bisque&quot; color[102]=&quot;NavajoWhite&quot; color[103]=&quot;Wheat&quot; color[104]=&quot;BurlyWood&quot; color[105]=&quot;Tan&quot; color[106]=&quot;RosyBrown&quot; color[107]=&quot;SandyBrown&quot; color[108]=&quot;Goldenrod&quot; color[109]=&quot;DarkGoldenrod&quot; color[110]=&quot;Peru&quot; color[111]=&quot;Chocolate&quot; color[112]=&quot;SaddleBrown&quot; color[113]=&quot;Sienna&quot; color[114]=&quot;Brown&quot; color[115]=&quot;Maroon&quot; color[116]=&quot;White&quot; color[117]=&quot;Snow&quot; color[118]=&quot;Honeydew&quot; color[119]=&quot;MintCream&quot; color[120]=&quot;Azure&quot; color[121]=&quot;AliceBlue&quot; color[122]=&quot;GhostWhite&quot; color[123]=&quot;WhiteSmoke&quot; color[124]=&quot;Seashell&quot; color[125]=&quot;Beige&quot; color[126]=&quot;OldLace&quot; color[127]=&quot;FloralWhite&quot; color[128]=&quot;Ivory&quot; color[129]=&quot;AntiqueWhite&quot; color[130]=&quot;Linen&quot; color[131]=&quot;LavenderBlush&quot; color[132]=&quot;MistyRose&quot; color[133]=&quot;Gainsboro&quot; color[134]=&quot;LightGray&quot; color[135]=&quot;Silver&quot; color[136]=&quot;DarkGray&quot; color[137]=&quot;Gray&quot; color[138]=&quot;DimGray&quot; color[139]=&quot;LightSlateGray&quot; color[140]=&quot;SlateGray&quot; color[141]=&quot;DarkSlateGray&quot; color[142]=&quot;Black&quot; For i = 0 To 11 For j = 1 To 12 GraphicsWindow.brushcolor=color[i*12+j] GraphicsWindow.FillRectangle(int+i*(sid+int),int+(j-1)*(sid+int),sid,sid) Endfor EndFor GraphicsWindow.PenColor=&quot; white&quot; GraphicsWindow.DrawRectangle(int+(i-1)*(sid+int),9*(sid+int)+int,sid,sid) GraphicsWindow.DrawRectangle(12*(sid+int)+int,int,10*(sid+int)-int,10*(sid+int)-int) GraphicsWindow.Mousemove = onmousemove Sub onmousemove x = GraphicsWindow.MouseX y = GraphicsWindow.MouseY GraphicsWindow.BrushColor = &quot;black&quot; GraphicsWindow.FillRectangle(12*(sid+int)+int,10.5*(sid+int)+int,10*(sid+int)+int,1.5*sid) c = 12*Math.Floor(x/(sid+int))+1+Math.Floor(y/(sid+int)) GraphicsWindow.BrushColor = color[c] GraphicsWindow.FillRectangle(12*(sid+int)+int,int,10*(sid+int)-int,10*(sid+int)-int) GraphicsWindow.BrushColor = &quot;white&quot; GraphicsWindow.DrawText(12*(sid+int)+int,10.5*(sid+int)+int,color[c]) EndSub </pre> <br/> <br/> Suduadib<br/>Tue, 23 Jun 2009 18:33:02 Z2009-06-23T18:41:56Zhttp://social.msdn.microsoft.com/Forums/en-US/smallbasic/thread/eaacf826-9d12-4e3c-aa10-1b2788f160a6#4cde0638-7d32-4405-a037-9af9a14a3db3http://social.msdn.microsoft.com/Forums/en-US/smallbasic/thread/eaacf826-9d12-4e3c-aa10-1b2788f160a6#4cde0638-7d32-4405-a037-9af9a14a3db3bigdaddyohttp://social.msdn.microsoft.com/Profile/en-US/?user=bigdaddyoPost your sample source code here and get featured on our blogs!Very nice, something I would have &amp; will use!Tue, 23 Jun 2009 19:53:49 Z2009-06-23T19:53:49Zhttp://social.msdn.microsoft.com/Forums/en-US/smallbasic/thread/eaacf826-9d12-4e3c-aa10-1b2788f160a6#33d3c3a1-51cd-433f-b410-67cd3a364db8http://social.msdn.microsoft.com/Forums/en-US/smallbasic/thread/eaacf826-9d12-4e3c-aa10-1b2788f160a6#33d3c3a1-51cd-433f-b410-67cd3a364db8Suduadibhttp://social.msdn.microsoft.com/Profile/en-US/?user=SuduadibPost your sample source code here and get featured on our blogs!Iterations just for fun ID = VTF373<br/> <br/> <pre>'Just for fun 'leftclick to change pattern and color 'rightclick to change just color GraphicsWindow.Title = &quot;Smoke&quot; GraphicsWindow.Height = 600 GraphicsWindow.Width = 600 GraphicsWindow.CanResize=&quot;false&quot; GraphicsWindow.BackgroundColor = &quot;black&quot; GraphicsWindow.Show() color=&quot;tomato&quot; init() GraphicsWindow.MouseDown = onmousedown While (1=1) x = math.Sin (a[1]*a[6]) - math.Cos (a[2]*a[5]) y = math.Sin (a[3]*a[5]) - math.Cos (a[4]*a[6]) GraphicsWindow.SetPixel(300+x*100,300+y*100,color) a[5] = x a[6] = y EndWhile Sub init For i = 1 to 6 a[i] = Math.Pi * (1-2*Math.GetRandomNumber(1000)/1000) Endfor Endsub Sub onmousedown color=GraphicsWindow.GetRandomColor() If (Mouse.IsLeftButtonDown=&quot;true&quot;) Then GraphicsWindow.Clear() init() EndIf EndSub </pre>Wed, 24 Jun 2009 16:46:19 Z2009-06-24T16:48:29Zhttp://social.msdn.microsoft.com/Forums/en-US/smallbasic/thread/eaacf826-9d12-4e3c-aa10-1b2788f160a6#c6d691d1-25d9-4551-bc02-4e6892509b51http://social.msdn.microsoft.com/Forums/en-US/smallbasic/thread/eaacf826-9d12-4e3c-aa10-1b2788f160a6#c6d691d1-25d9-4551-bc02-4e6892509b51bigdaddyohttp://social.msdn.microsoft.com/Profile/en-US/?user=bigdaddyoPost your sample source code here and get featured on our blogs!I thought i might try making an old text style adventure game that was small so we could understand it.  So I got this one for a TRS-80 and ported it.  It got much larger than I had hoped, the original code printed on two pages.  It was a real job getting rid of line numbered code - ug.  <br/><br/><img src="http://www.outtaether.com/shared/crash.JPG" alt=""><br/><br/>You can download it with code TWC709<br/><br/>I hoped also to make it easy to convert into any kind of adventure game, could be in any environment, enemies, doors, anythings possible.  It really needs another pass making it better coded, and easily modifiable.  If you want to comment, here's the thread <a href="http://social.msdn.microsoft.com/Forums/en-US/smallbasic/thread/24445f00-8064-4857-8924-27ff58a6b646">http://social.msdn.microsoft.com/Forums/en-US/smallbasic/thread/24445f00-8064-4857-8924-27ff58a6b646</a>Sat, 27 Jun 2009 03:47:25 Z2009-06-27T03:47:25Zhttp://social.msdn.microsoft.com/Forums/en-US/smallbasic/thread/eaacf826-9d12-4e3c-aa10-1b2788f160a6#4e304acf-04b4-421a-8152-a303d04fa17ehttp://social.msdn.microsoft.com/Forums/en-US/smallbasic/thread/eaacf826-9d12-4e3c-aa10-1b2788f160a6#4e304acf-04b4-421a-8152-a303d04fa17eThe Hackerhttp://social.msdn.microsoft.com/Profile/en-US/?user=The%20HackerPost your sample source code here and get featured on our blogs!I started playing this and you did a good.<br/>Great Job Bigdaddyo!Sat, 27 Jun 2009 04:05:53 Z2009-06-27T04:05:53Zhttp://social.msdn.microsoft.com/Forums/en-US/smallbasic/thread/eaacf826-9d12-4e3c-aa10-1b2788f160a6#0cd2bb4e-ed9d-47b9-b815-54fb1dfd5f32http://social.msdn.microsoft.com/Forums/en-US/smallbasic/thread/eaacf826-9d12-4e3c-aa10-1b2788f160a6#0cd2bb4e-ed9d-47b9-b815-54fb1dfd5f32Kniggleshttp://social.msdn.microsoft.com/Profile/en-US/?user=KnigglesPost your sample source code here and get featured on our blogs!for inspration,<br/> <br/> GraphicsWindow.BackgroundColor = &quot;midnightblue&quot;<br/> GraphicsWindow.Title = &quot;Blueprintv1&quot;<br/> GraphicsWindow.Width = 800<br/> GraphicsWindow.Height = 600<br/> GraphicsWindow.Show()<br/> <br/> GraphicsWindow.MouseDown = SCENARIo1<br/> <br/> A= 30<br/> c=100<br/> GraphicsWindow.BrushColor = &quot;yellow&quot;<br/> GraphicsWindow.FillRectangle(c,c,a,a)<br/> GraphicsWindow.DrawRectangle(c,c,a,a)<br/> GraphicsWindow.BrushColor = &quot;black&quot;<br/> GraphicsWindow.DrawText(c+6, c+7, &quot;OK&quot;)<br/> <br/> <br/> GraphicsWindow.BrushColor = &quot;yellow&quot;<br/> GraphicsWindow.FillRectangle(310,20,150,30)<br/> GraphicsWindow.DrawRectangle(c,c,a,a)<br/> GraphicsWindow.BrushColor = &quot;black&quot;<br/> GraphicsWindow.DrawText(310+6, 20+7, &quot;No Broken lines = win&quot;)<br/> <br/> <br/> <br/> <br/> <br/> <br/> <br/> <br/> <br/> GraphicsWindow.BrushColor = &quot;yellow&quot;<br/> GraphicsWindow.FillRectangle(10,10,10,10)<br/> GraphicsWindow.DrawRectangle(10,10,10,10)<br/> <br/> GraphicsWindow.BrushColor = &quot;black&quot;<br/> GraphicsWindow.FillRectangle(10,30,30,30)<br/> GraphicsWindow.DrawRectangle(10,30,30,30)<br/> <br/> GraphicsWindow.BrushColor = &quot;black&quot;<br/> GraphicsWindow.FillRectangle(100,30,30,30)<br/> GraphicsWindow.DrawRectangle(100,30,30,30)<br/> GraphicsWindow.PenColor=&quot;white&quot;<br/> mouseclick = 0<br/> <br/> While (&quot;True&quot;)<br/>   If (mouseclick = 1) Then<br/>     mouseclick = 0<br/>     If (xaxis &gt; c And xaxis &lt; (c+a) And yaxis&gt; c And yaxis &lt; (c+a)) Then<br/>       <br/>       For i = 1 To 5<br/> Turtle.Move(9)<br/> Turtle.PenUp()<br/> Turtle.Move(9)<br/> Turtle.PenDown()<br/> EndFor<br/>       <br/>       <br/>       Turtle.move(100)<br/>     ElseIf (xaxis &gt; 10 And xaxis &lt; (20) And yaxis &gt; 10 And yaxis &lt; (20)) Then<br/>       Turtle.Turn(90)<br/>       For i = 1 To 2<br/> Turtle.Move(3)<br/> Turtle.PenUp()<br/> Turtle.Move(3)<br/> Turtle.PenDown()<br/> EndFor<br/>       Turtle.move(100)<br/>     ElseIf (xaxis &gt; 10 And xaxis &lt; (40) And yaxis &gt; 30 And yaxis &lt; (60)) Then<br/>       Turtle.turn(-90)<br/>       For i = 1 To 2<br/> Turtle.Move(5)<br/> Turtle.PenUp()<br/> Turtle.Move(4)<br/> Turtle.PenDown()<br/> EndFor<br/>       Turtle.Move(100)<br/>        ElseIf (xaxis &gt; 100 And xaxis &lt; (140) And yaxis &gt; 30 And yaxis &lt; (60)) Then<br/>          Turtle.turn(45)<br/>          For i = 1 To 5<br/> Turtle.Move(4)<br/> Turtle.PenUp()<br/> Turtle.Move(5)<br/> Turtle.PenDown()<br/> EndFor<br/>       Turtle.Move(100)<br/>     <br/>  <br/>      <br/>     EndIf<br/>   EndIf<br/> EndWhile<br/> <br/> Sub SCENARIo1<br/>   mouseclick = 1<br/>   xaxis = GraphicsWindow.MouseX<br/>   yaxis = GraphicsWindow.MouseY<br/> endsub<br/> <br/> <br/> thanks for the fun microsoft,ect.<br/> <br/> <br/> <br/> <br/>Sat, 27 Jun 2009 16:48:49 Z2009-06-28T04:41:15Zhttp://social.msdn.microsoft.com/Forums/en-US/smallbasic/thread/eaacf826-9d12-4e3c-aa10-1b2788f160a6#23047249-c09d-4714-a050-0001d2e1713ehttp://social.msdn.microsoft.com/Forums/en-US/smallbasic/thread/eaacf826-9d12-4e3c-aa10-1b2788f160a6#23047249-c09d-4714-a050-0001d2e1713elitdevhttp://social.msdn.microsoft.com/Profile/en-US/?user=litdevPost your sample source code here and get featured on our blogs!Three main issues:<br/> <br/> 1] You should use Turtle.MoveTo to move to new coordinates, otherwise you must set the direction and distance using Turtle.Angle and Turtle.Move.<br/> <br/> 2] The OnMouseDown event is not required when we replace Turtle.move(Xaxis, Yaxis, x, y) with Turtle.MoveTo(x,y).  We only need to know the current mouse position, not what it was when the button was first pressed.  In either case, in your code xaxis and yaxis are overwritten in OnMouseMove making the OnMouseDown unneccessary.<br/> <br/> 3] Doing the work inside the event handler subroutine causes problems - this event is continually triggered as the mouse moves and doesn't have time to finish the turtle move before it is triggered again.  The result is that the turtle never gets going because it is continually be asked to start again.<br/> <br/> You can do everything here without events, since we can check the position and mouse button status as you have found.   Therefore try:<br/> <em>GraphicsWindow.BackgroundColor = &quot;Black&quot;  <br/> GraphicsWindow.PenColor = &quot;White&quot;   <br/> <br/> While (&quot;True&quot;) <br/>   x = GraphicsWindow.MouseX  <br/>   y = GraphicsWindow.MouseY  <br/>   If (Mouse.IsLeftButtonDown) Then<br/>     Turtle.MoveTo(x, y)  <br/>   EndIf  <br/> EndWhile</em>Sat, 27 Jun 2009 18:31:01 Z2009-06-27T18:31:01Zhttp://social.msdn.microsoft.com/Forums/en-US/smallbasic/thread/eaacf826-9d12-4e3c-aa10-1b2788f160a6#83edce09-5ace-4060-b93a-075e36cb76c1http://social.msdn.microsoft.com/Forums/en-US/smallbasic/thread/eaacf826-9d12-4e3c-aa10-1b2788f160a6#83edce09-5ace-4060-b93a-075e36cb76c1HenkSWThttp://social.msdn.microsoft.com/Profile/en-US/?user=HenkSWTPost your sample source code here and get featured on our blogs!<pre>'------------------------------------------------------------------------------------------- ' program for elevation-angle-only altitude determentation of model rockets ' ' programmer: Henk Siewert ' date : 29 juni 2009 ' version : 0.1 ' ' Microsoft Small Basic 0.5 '------------------------------------------------------------------------------------------- ' vars '------------------------------------------------------------------------------------------- ' LYN=&quot;--------------------------------------------------------------------------------&quot; SPACES=&quot; &quot; BASELINE=0 ANGLE=0 ALT=0 MENUCHOICE=&quot; &quot; ENGLISH=0 '------------------------------------------------------------------------------------------- ' end vars '------------------------------------------------------------------------------------------- '------------------------------------------------------------------------------------------- ' Main '------------------------------------------------------------------------------------------- screen() language() start() '------------------------------------------------------------------------------------------- ' end Main '------------------------------------------------------------------------------------------- '---------------------------------------------------------------------------- 'subs '---------------------------------------------------------------------------- Sub start header() inputbaseline() inputangle() computealt() menu() Program.End() EndSub Sub language '------------------------------------------------------------------------- 'change language to English or Dutch '------------------------------------------------------------------------- TextWindow.Clear() TextWindow.CursorTop=11 LANG=&quot;English / Engels = 1 Dutch / Nederlands = 2&quot; TextWindow.CursorLeft=40-Text.GetLength(LANG)/2 TextWindow.Write(LANG) TextWindow.CursorTop=13 TextWindow.CursorLeft=40 LANGCHOICE=TextWindow.ReadNumber() If LANGCHOICE=1 then MAKER=&quot; SWT Software&quot; PROG=&quot;Elevation-angle altitude determentation &quot; BEREKEN11=&quot;The rocket reached an altitude of &quot; BEREKEN12=&quot; meters&quot; MENU01=&quot;Again? - y/n&quot; MENU02=&quot;&quot; INPUT011=&quot;Input baseline length,&quot; INPUT012=&quot;in meters: &quot; INPUT021=&quot;Input azimuth angle, INPUT022=&quot;in degrees: &quot; EndIf If LANGCHOICE=2 then MAKER=&quot; SWT Software&quot; PROG=&quot;Berekening van bereikte hoogte van modelraket &quot; BEREKEN11=&quot;De raket heeft een hoogte behaald van &quot; BEREKEN12=&quot; meter&quot; MENU01=&quot;Nog een berekening uitvoeren? - j/n&quot; MENU02=&quot;&quot; INPUT011=&quot;Voer de afstand van het meetpunt tot de lanceerinstallatie in,&quot; INPUT012=&quot;in meters: &quot; INPUT021=&quot;Voer de gemeten hoek in, INPUT022=&quot;in graden: &quot; EndIf EndSub Sub header '------------------------------------------------------------------------- ' clear screen and print header '------------------------------------------------------------------------- ' TextWindow.Clear() TextWindow.Title=PROG 'Set title in top of window TextWindow.Write(LYN) TextWindow.Write(MAKER) TextWindow.CursorLeft=80-Text.GetLength(PROG) TextWindow.Write(PROG) TextWindow.WriteLine(LYN) ' EndSub Sub inputbaseline '------------------------------------------------------------------------- ' input baseline in meters '------------------------------------------------------------------------- ' TextWindow.CursorLeft=40-Text.GetLength(INPUT011)/2 TextWindow.WriteLine(INPUT011) TextWindow.CursorLeft=38-Text.GetLength(INPUT012)/2 TextWindow.Write(INPUT012) BASELINE=TextWindow.ReadNumber() TextWindow.WriteLine(&quot;&quot;) ' EndSub Sub inputangle '------------------------------------------------------------------------- ' input angle in degrees '------------------------------------------------------------------------- ' TextWindow.CursorTop=8 TextWindow.Write(SPACES) TextWindow.CursorTop=7 TextWindow.CursorLeft=0 TextWindow.CursorLeft=40-Text.GetLength(INPUT021)/2 TextWindow.WriteLine(INPUT021) TextWindow.CursorLeft=38-Text.GetLength(INPUT022)/2 TextWindow.Write(INPUT022) ANGLE=TextWindow.ReadNumber() IF ANGLE&gt;80 THEN Sound.PlayChimes() inputangle() endif TextWindow.WriteLine(&quot;&quot;) ' EndSub Sub computealt '--------------------------------------------------------------------------------------------------- ' compute altitude - convert degrees to radians!!! '--------------------------------------------------------------------------------------------------- ' RADIANS=ANGLE*Math.Pi/180 'Pi/180 for converting degrees to radians ALT=BASELINE*Math.Tan(RADIANS) ' '--------------------------------------------------------------------------------------------------- ' output ALT to screen '--------------------------------------------------------------------------------------------------- ' TextWindow.CursorLeft=40-Text.GetLength(BEREKEN11)/2 TextWindow.WriteLine(BEREKEN11) TextWindow.CursorLeft=40-Text.GetLength(ALT+BEREKEN12)/2 TextWindow.Write(ALT) TextWindow.WriteLine(BEREKEN12) TextWindow.WriteLine(&quot;&quot;) EndSub Sub menu '------------------------------------------------------------------------------------------- ' menu '------------------------------------------------------------------------------------------- ' TextWindow.CursorLeft=40-Text.GetLength(MENU01)/2 TextWindow.WriteLine(MENU01) TextWindow.WriteLine(&quot;&quot;) TextWindow.CursorLeft=40 MENUCHOICE=TextWindow.Read() IF (MENUCHOICE=&quot;y&quot;) Then start() EndIf IF (MENUCHOICE=&quot;j&quot;) Then start() EndIf EndSub Sub screen '------------------------------------------------------------------------------------------- ' sets the screen colors '------------------------------------------------------------------------------------------- ' TextWindow.BackgroundColor=&quot;White&quot; TextWindow.ForegroundColor=&quot;Black&quot; TextWindow.Clear() EndSub </pre>Mon, 29 Jun 2009 09:33:56 Z2009-06-29T09:33:56Zhttp://social.msdn.microsoft.com/Forums/en-US/smallbasic/thread/eaacf826-9d12-4e3c-aa10-1b2788f160a6#a5744206-4bc5-42c0-8a1d-9ebce20db141http://social.msdn.microsoft.com/Forums/en-US/smallbasic/thread/eaacf826-9d12-4e3c-aa10-1b2788f160a6#a5744206-4bc5-42c0-8a1d-9ebce20db141litdevhttp://social.msdn.microsoft.com/Profile/en-US/?user=litdevPost your sample source code here and get featured on our blogs!I like the clear structure, comments and text window alignment of text.  You use recursive calls to inputangle (calls itself) if the user enters a value &gt; 80 deg, to prevent a tan(pi/2) problem, hence inputangle is put in the calls stack following an input &gt; 80 deg.  When the user finally gets it right all of the inputangle calls in the stack unwind outputting a blank line for each incorrect user entry.  Hence I suggest:<br/> <br/> <em>If ANGLE&gt;80 Then<br/>   Sound.PlayChimes()<br/>   inputangle()<br/> Else<br/>   TextWindow.WriteLine(&quot;&quot;)<br/> EndIf</em> <br/> <br/> This is obviously an extremely minor point in this context, but the general issue about carefully considering the impact of recursion is worth noting.<br/> <br/> You can also calculate the initial velocity required if you assume g = 10m/s2.<br/>Mon, 29 Jun 2009 20:55:35 Z2009-06-29T20:57:30Zhttp://social.msdn.microsoft.com/Forums/en-US/smallbasic/thread/eaacf826-9d12-4e3c-aa10-1b2788f160a6#19d19bbf-77bc-44cc-87bd-134ccff36f61http://social.msdn.microsoft.com/Forums/en-US/smallbasic/thread/eaacf826-9d12-4e3c-aa10-1b2788f160a6#19d19bbf-77bc-44cc-87bd-134ccff36f61HenkSWThttp://social.msdn.microsoft.com/Profile/en-US/?user=HenkSWTPost your sample source code here and get featured on our blogs!<p class=MsoNormal style="margin:0cm 0cm 10pt"><span style="font-size:small;font-family:Calibri"><span style="font-size:x-small">Hallo<span lang=EN-US> litdef</span>,</span></span></p> <p class=MsoNormal style="margin:0cm 0cm 10pt"><span style="font-size:small"><span style="font-family:Calibri"><span style="font-size:x-small"><span lang=EN-US>You</span> are right.</span></span></span></p> <p class=MsoNormal style="margin:0cm 0cm 10pt"><span lang=EN-US><span style="font-size:small"><span style="font-family:Calibri"><span style="font-size:x-small">I did not come across this problem while testing the program.<br/>I only input 1 angle &gt;80 to test the program. So I never did see the extra lines.<br/>I have put your code in the program.<br/></span></span></span></span></p> <p class=MsoNormal style="margin:0cm 0cm 10pt"><span lang=EN-US><span style="font-size:small"><span style="font-family:Calibri"><br/><span style="font-size:x-small">You can find the new code on: </span><br/><span style="font-size:x-small"><a href="http://cid-f124d5c3ce8fc100.skydrive.live.com/browse.aspx/Public/SmallBasic">http://cid-f124d5c3ce8fc100.skydrive.live.com/browse.aspx/Public/SmallBasic</a><br/><br/>Thank you</span></span></span></span></p>Tue, 30 Jun 2009 11:59:34 Z2009-06-30T12:17:13Zhttp://social.msdn.microsoft.com/Forums/en-US/smallbasic/thread/eaacf826-9d12-4e3c-aa10-1b2788f160a6#2e2353bf-29f0-49d3-8338-a8881197cbdehttp://social.msdn.microsoft.com/Forums/en-US/smallbasic/thread/eaacf826-9d12-4e3c-aa10-1b2788f160a6#2e2353bf-29f0-49d3-8338-a8881197cbdebigdaddyohttp://social.msdn.microsoft.com/Profile/en-US/?user=bigdaddyoPost your sample source code here and get featured on our blogs!<p>How about if you input an angle &gt; 80 degrees, have the program come back with &quot;You're standing way to close to your rocket!&quot;</p>Tue, 30 Jun 2009 19:05:34 Z2009-06-30T19:05:34Zhttp://social.msdn.microsoft.com/Forums/en-US/smallbasic/thread/eaacf826-9d12-4e3c-aa10-1b2788f160a6#0518429e-c52f-4623-9c62-0ec7ea50e5cdhttp://social.msdn.microsoft.com/Forums/en-US/smallbasic/thread/eaacf826-9d12-4e3c-aa10-1b2788f160a6#0518429e-c52f-4623-9c62-0ec7ea50e5cdHenkSWThttp://social.msdn.microsoft.com/Profile/en-US/?user=HenkSWTPost your sample source code here and get featured on our blogs!<p>Ok, but any serious rocketeer knows that you have to stand at a minimum of 100 meters to get an angle you can trust.<br/>So, any input of &gt;80 has to be an error. ;-).</p> <p>Maybe I put that in the next project: Two-station alt-azimuth tracking data reduction.<br/>For this I will use MRDR-2 as a basis. See Handbook of model rocketry by G. Harry Stine / Bill Stine</p> <p> </p>Tue, 30 Jun 2009 20:04:57 Z2009-06-30T20:04:57Zhttp://social.msdn.microsoft.com/Forums/en-US/smallbasic/thread/eaacf826-9d12-4e3c-aa10-1b2788f160a6#7bdaa197-843f-491d-84f1-520f4210f50ahttp://social.msdn.microsoft.com/Forums/en-US/smallbasic/thread/eaacf826-9d12-4e3c-aa10-1b2788f160a6#7bdaa197-843f-491d-84f1-520f4210f50alitdevhttp://social.msdn.microsoft.com/Profile/en-US/?user=litdevPost your sample source code here and get featured on our blogs!Text read using GraphicsWindow - WFB666-0.<br/> <br/> <img src="http://7w7sng.bay.livefilestore.com/y1pv5eR9rift1ATbfbJQSCG3deCJzGoOhAr9O_K0h6CLSn5Djh0i30gJXYIfFDFu2Qc5UAhLBIYo3fl0yJL0ezY8w/SB_GW_input.jpg" alt="">Tue, 30 Jun 2009 22:09:18 Z2009-07-01T19:36:15Zhttp://social.msdn.microsoft.com/Forums/en-US/smallbasic/thread/eaacf826-9d12-4e3c-aa10-1b2788f160a6#fa1fc4b7-0174-4b8f-9f2f-137a185bdaa5http://social.msdn.microsoft.com/Forums/en-US/smallbasic/thread/eaacf826-9d12-4e3c-aa10-1b2788f160a6#fa1fc4b7-0174-4b8f-9f2f-137a185bdaa5MVP_Seo Woo Seokhttp://social.msdn.microsoft.com/Profile/en-US/?user=MVP_Seo%20Woo%20SeokPost your sample source code here and get featured on our blogs!Move mouse, then the turtle will follow you. :-) <div>Program Listing: ?QLM601</div> <div><br/></div> <div> <pre lang=x-vbnet>'----------------------- ' Author: Naggingmachine ' Blog: http://naggingmachine.tistory.com ' Email: wooseok.seo@gmail.com '----------------------- '----------------------- ' Timer setup '----------------------- Timer.Interval = 50 Timer.Tick = onTimerTick '----------------------- ' Mouse setup '----------------------- GraphicsWindow.MouseMove = onMouseMove mouseX = GraphicsWindow.MouseX mouseY = GraphicsWindow.MouseY '----------------------- ' Turtle setup '----------------------- turtleX = GraphicsWindow.Width/2 turtleY = GraphicsWindow.Height/2 Turtle.X = turtleX Turtle.Y = turtleY Turtle.Show() '----------------------- ' Initialize '----------------------- GraphicsWindow.Title = &quot;Having fun with Turtle&quot; GraphicsWindow.BrushColor = GraphicsWindow.GetColorFromRGB(127,127,127) GraphicsWindow.FontName=&quot;arial&quot; GraphicsWindow.FontSize=30 GraphicsWindow.Fontbold=&quot;true&quot; GraphicsWindow.DrawText(0, 0, &quot;Move mouse, then the turtle will follow you.&quot;) moveHorizontal = 5 moveVerticle = 5 Sub onTimerTick ' Get the new X position of the turtle If (mouseX &lt; turtleX) Then If (turtleX - mouseX &lt; 5) Then turtleX = mouseX Else turtleX = turtleX - moveHorizontal EndIf ElseIf (mouseX &gt; turtleX) Then If (mouseX - turtleX &lt; 5) Then turtleX = mouseX Else turtleX = turtleX + moveHorizontal EndIf EndIf ' Get the new Y position of the turtle If (mouseY &lt; turtleY) Then If (turtleY - mouseY &lt; 5) Then turtleY = mouseY Else turtleY = turtleY - moveVerticle EndIf ElseIf (mouseY &gt; turtleY) Then If (mouseY - turtleY &lt; 5) Then turtleY = mouseY Else turtleY = turtleY + moveVerticle EndIf EndIf ' Move the turtle to new position Turtle.X = turtleX Turtle.Y = turtleY EndSub Sub onMouseMove mouseX = GraphicsWindow.MouseX mouseY = GraphicsWindow.MouseY EndSub</pre> <span style="font-size:12px;color:#555555;line-height:21px"><a style="color:#0066cc;text-decoration:none;border-bottom-width:1px;border-bottom-style:dashed;border-bottom-color:initial" rel=lightbox href="http://cfile2.uf.tistory.com/original/1613681E4A4A30299FC20F"><img style="cursor:pointer;border-width:0px" src="http://cfile2.uf.tistory.com/image/1613681E4A4A30299FC20F" alt="" width=600 height=450></a></span></div> <hr class=sig> Microsoft Visual C# MVPWed, 01 Jul 2009 00:21:52 Z2009-07-01T00:22:21Zhttp://social.msdn.microsoft.com/Forums/en-US/smallbasic/thread/eaacf826-9d12-4e3c-aa10-1b2788f160a6#3ea22ea8-f6db-4767-b6d9-ff31601fb83ahttp://social.msdn.microsoft.com/Forums/en-US/smallbasic/thread/eaacf826-9d12-4e3c-aa10-1b2788f160a6#3ea22ea8-f6db-4767-b6d9-ff31601fb83aVijaye Rajihttp://social.msdn.microsoft.com/Profile/en-US/?user=Vijaye%20RajiPost your sample source code here and get featured on our blogs!<div style="font-size:300%">This thread is now being continued at:</div> <a style="font-size:150%" href="http://social.msdn.microsoft.com/Forums/en-US/smallbasic/thread/b1b383c1-6b13-49c0-bf29-00de86103ac6">http://social.msdn.microsoft.com/Forums/en-US/smallbasic/thread/b1b383c1-6b13-49c0-bf29-00de86103ac6</a>Wed, 01 Jul 2009 21:08:03 Z2009-07-01T21:08:03Z