<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>WinSoft.se</title>
	<atom:link href="http://www.winsoft.se/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.winsoft.se</link>
	<description>Development with focus on Visual Basic .NET</description>
	<lastBuildDate>Wed, 28 Jul 2010 08:49:52 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>Dagens ord om Skeptikerpodden</title>
		<link>http://www.winsoft.se/2010/07/dagens-ord-om-skeptikerpodden/</link>
		<comments>http://www.winsoft.se/2010/07/dagens-ord-om-skeptikerpodden/#comments</comments>
		<pubDate>Wed, 28 Jul 2010 08:49:52 +0000</pubDate>
		<dc:creator>Anders Hesselbom</dc:creator>
				<category><![CDATA[Personal]]></category>

		<guid isPermaLink="false">http://www.winsoft.se/?p=1319</guid>
		<description><![CDATA[John Houdi säger det så bra, så jag låter han tala: Tänk vad fort det går. Vi har nu gjort 16 avsnitt av Skeptikerpodden! Med tanke på den respons vi fått så har denna poddradio varit eftertraktad länge, vilket vi som gör Skeptikerpodden tycker är oerhört kul. Läs inlägget här.]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.houdi.se/" target="_blank">John Houdi</a> säger det så bra, så jag låter han tala:</p>
<blockquote><p>Tänk vad fort det går. Vi har nu gjort 16 avsnitt av <a href="http://skeptikerpodden.se/" target="_blank">Skeptikerpodden</a>!</p>
<p>Med tanke på den respons vi fått så har denna poddradio varit eftertraktad länge, vilket vi som gör Skeptikerpodden tycker är oerhört kul.</p></blockquote>
<p><a href="http://www.houdi.se/blog/?p=6049" target="_blank">Läs inlägget här.</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.winsoft.se/2010/07/dagens-ord-om-skeptikerpodden/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>First screenshot of the SRT tool</title>
		<link>http://www.winsoft.se/2010/07/first-screenshot-of-the-srt-tool/</link>
		<comments>http://www.winsoft.se/2010/07/first-screenshot-of-the-srt-tool/#comments</comments>
		<pubDate>Fri, 23 Jul 2010 14:20:36 +0000</pubDate>
		<dc:creator>Anders Hesselbom</dc:creator>
				<category><![CDATA[Programs]]></category>

		<guid isPermaLink="false">http://www.winsoft.se/?p=1315</guid>
		<description><![CDATA[Just felt the urge to publish this first screenshot of my new SRT tool. I aim to make this the easiest way to synchronize a subtitle file (*.srt) with a DivX movie.]]></description>
			<content:encoded><![CDATA[<p>Just felt the urge to publish this first screenshot of my new SRT tool. I aim to make this the easiest way to synchronize a subtitle file (*.srt) with a DivX movie.</p>
<p><img alt="" src="http://imghost.winsoft.se/upload/135051279894636srttool.jpg" class="alignnone" width="550" height="414" /></p>
]]></content:encoded>
			<wfw:commentRss>http://www.winsoft.se/2010/07/first-screenshot-of-the-srt-tool/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Writing a game using TurboSprite (2/2)</title>
		<link>http://www.winsoft.se/2010/07/writing-a-game-using-turbosprite-22/</link>
		<comments>http://www.winsoft.se/2010/07/writing-a-game-using-turbosprite-22/#comments</comments>
		<pubDate>Mon, 19 Jul 2010 18:48:56 +0000</pubDate>
		<dc:creator>Anders Hesselbom</dc:creator>
				<category><![CDATA[Visual Basic 9]]></category>
		<category><![CDATA[2D game]]></category>

		<guid isPermaLink="false">http://www.winsoft.se/?p=1306</guid>
		<description><![CDATA[Continued from here. Now I want to enable shooting. When the user presses the Control key, I create a bullet, sets its properties and adds it to the engine. This code is added to the KeyDown event. I have to modify the KeyUp event, because in the previous version, it unconditionally made the ship stop. [...]]]></description>
			<content:encoded><![CDATA[<p>Continued from <a href="http://www.winsoft.se/2010/07/writing-a-game-using-turbosprite-12/">here</a>.</p>
<p>Now I want to enable shooting. When the user presses the Control key, I create a bullet, sets its properties and adds it to the engine. This code is added to the <strong>KeyDown</strong> event. I have to modify the <strong>KeyUp</strong> event, because in the previous version, it unconditionally made the ship stop. Now when more keys are involved, I only want the ship to stop if it is the up or down buttons are released.</p>
<p>This is the new version of the <strong>KeyDown</strong> event:</p>
<pre class="csharpcode">
   <span class="kwrd">Private</span> <span class="kwrd">Sub</span> Form1_KeyDown(<span class="kwrd">ByVal</span> _
sender <span class="kwrd">As</span> <span class="kwrd">Object</span>, <span class="kwrd">ByVal</span> e <span class="kwrd">As</span> System.Windows.Forms.KeyEventArgs) <span class="kwrd">Handles</span> <span class="kwrd">Me</span>.KeyDown
      <span class="kwrd">If</span> e.KeyData = Keys.A <span class="kwrd">Then</span>

         <span class="rem">'If user presses "a", move up!</span>
         <span class="kwrd">Me</span>.PlayerMover.DestY = 0
         <span class="kwrd">Me</span>.PlayerMover.SpeedY = -2

      <span class="kwrd">ElseIf</span> e.KeyData = Keys.Z <span class="kwrd">Then</span>

         <span class="rem">'If user presses "z", move down!</span>
         <span class="kwrd">Me</span>.PlayerMover.DestY = SpriteSurface1.Height
         <span class="kwrd">Me</span>.PlayerMover.SpeedY = 2

      <span class="kwrd">End</span> <span class="kwrd">If</span>

      <span class="kwrd">If</span> (e.KeyData <span class="kwrd">And</span> Keys.ControlKey) = Keys.ControlKey <span class="kwrd">Then</span>

         <span class="rem">'If user presses Control, fire!</span>
         <span class="kwrd">Dim</span> Bullet <span class="kwrd">As</span> <span class="kwrd">New</span> SCG.TurboSprite.PolygonSprite(2, 0, -2, 1, -2, -1)
         Bullet.Position = <span class="kwrd">New</span> Point(Player.Position.X + 15, Player.Position.Y + 9)
         Bullet.Color = Color.Cyan
         SpriteEngineDestination1.AddSprite(Bullet)
         <span class="kwrd">Dim</span> BulletMover <span class="kwrd">As</span> SCG.TurboSprite.DestinationMover = _
SpriteEngineDestination1.GetMover(Bullet)
         BulletMover.Destination = <span class="kwrd">New</span> Point(SpriteSurface1.Width + 5, _
Bullet.Height)
         BulletMover.SpeedX = 4

      <span class="kwrd">End</span> <span class="kwrd">If</span>
   <span class="kwrd">End</span> Sub</pre>
<p>This is the new version of the <strong>KeyUp</strong> event:</p>
<pre class="csharpcode">
   <span class="kwrd">Private</span> <span class="kwrd">Sub</span> Form1_KeyUp(<span class="kwrd">ByVal</span> sender <span class="kwrd">As</span> _
<span class="kwrd">Object</span>, <span class="kwrd">ByVal</span> e <span class="kwrd">As</span> System.Windows.Forms.KeyEventArgs) <span class="kwrd">Handles</span> <span class="kwrd">Me</span>.KeyUp

      <span class="rem">'Stop moving, but only if "a" or "z" is released.</span>
      <span class="kwrd">If</span> e.KeyData = Keys.A <span class="kwrd">Or</span> e.KeyCode = Keys.Z <span class="kwrd">Then</span>
         <span class="kwrd">Me</span>.PlayerMover.SpeedY = 0
      <span class="kwrd">End</span> <span class="kwrd">If</span>

   <span class="kwrd">End</span> Sub</pre>
<p>Finally, when a bullet reaches its destination at the right end of the screen, I want it deleted. Check the <strong>SpriteReachedDestination</strong> event in the final code listing below.</p>
<p>When this is all working, I want to add an enemy and use the collision detection to see if it was killed. I did not subclass the <strong>PolygonSprite</strong>, and this is really something you should do to be able to tag the sprites. The &#8220;ugly hack&#8221; of this post, must be that I use color to determine if the sprite is a bullet, or the enemy. This is the complete code:</p>
<pre class="csharpcode">
<span class="kwrd">Public</span> <span class="kwrd">Class</span> Form1

   <span class="rem">'A reference to the player (created in the Shown event) and the mover.</span>
   <span class="kwrd">Private</span> Player <span class="kwrd">As</span> SCG.TurboSprite.PolygonSprite
   <span class="kwrd">Private</span> PlayerMover <span class="kwrd">As</span> SCG.TurboSprite.DestinationMover

   <span class="kwrd">Private</span> <span class="kwrd">Sub</span> Form1_Shown(<span class="kwrd">ByVal</span> sender _
<span class="kwrd">As</span> <span class="kwrd">Object</span>, <span class="kwrd">ByVal</span> e <span class="kwrd">As</span> System.EventArgs) <span class="kwrd">Handles</span> <span class="kwrd">Me</span>.Shown

      <span class="rem">'Set the desired number of frames per second and activate the surface.</span>
      SpriteSurface1.DesiredFPS = 40
      SpriteSurface1.Active = <span class="kwrd">True</span>

      <span class="rem">'Create the player and save the reference.</span>
      <span class="kwrd">Me</span>.Player = <span class="kwrd">New</span> SCG.TurboSprite.PolygonSprite(-20, -10, 20, 10, -20, 10)

      <span class="rem">'Set player original position.</span>
      <span class="kwrd">Me</span>.Player.Position = <span class="kwrd">New</span> Point(100, 100)

      <span class="rem">'Set player color.</span>
      <span class="kwrd">Me</span>.Player.Color = Color.Yellow

      <span class="rem">'Add the player to the sprite engine.</span>
      SpriteEngineDestination1.AddSprite(<span class="kwrd">Me</span>.Player)

      <span class="rem">'Save a reference to the mover.</span>
      <span class="kwrd">Me</span>.PlayerMover = SpriteEngineDestination1.GetMover(<span class="kwrd">Me</span>.Player)

      <span class="rem">'Now, add an ENEMY!</span>
      <span class="kwrd">Dim</span> Enemy <span class="kwrd">As</span> <span class="kwrd">New</span> SCG.TurboSprite.PolygonSprite(-30, 20, 0, -20, 30, 20)
      Enemy.Position = <span class="kwrd">New</span> Point(SpriteSurface1.Width, SpriteSurface1.Height)
      Enemy.Color = Color.Red
      SpriteEngineDestination1.AddSprite(Enemy)
      <span class="kwrd">Dim</span> EnenyMover <span class="kwrd">As</span> SCG.TurboSprite.DestinationMover = _
SpriteEngineDestination1.GetMover(Enemy)
      EnenyMover.Speed = 1
      EnenyMover.Destination = <span class="kwrd">New</span> Point(-50, 100)

   <span class="kwrd">End</span> <span class="kwrd">Sub</span>

   <span class="kwrd">Private</span> <span class="kwrd">Sub</span> Form1_KeyDown(<span class="kwrd">ByVal</span> sender <span class="kwrd">As</span> _
<span class="kwrd">Object</span>, <span class="kwrd">ByVal</span> e <span class="kwrd">As</span> System.Windows.Forms.KeyEventArgs) <span class="kwrd">Handles</span> <span class="kwrd">Me</span>.KeyDown
      <span class="kwrd">If</span> e.KeyData = Keys.A <span class="kwrd">Then</span>

         <span class="rem">'If user presses "a", move up!</span>
         <span class="kwrd">Me</span>.PlayerMover.DestY = 0
         <span class="kwrd">Me</span>.PlayerMover.SpeedY = -2

      <span class="kwrd">ElseIf</span> e.KeyData = Keys.Z <span class="kwrd">Then</span>

         <span class="rem">'If user presses "z", move down!</span>
         <span class="kwrd">Me</span>.PlayerMover.DestY = SpriteSurface1.Height
         <span class="kwrd">Me</span>.PlayerMover.SpeedY = 2

      <span class="kwrd">End</span> <span class="kwrd">If</span>

      <span class="kwrd">If</span> (e.KeyData <span class="kwrd">And</span> Keys.ControlKey) = Keys.ControlKey <span class="kwrd">Then</span>

         <span class="rem">'If user presses Control, fire!</span>
         <span class="kwrd">Dim</span> Bullet <span class="kwrd">As</span> <span class="kwrd">New</span> SCG.TurboSprite.PolygonSprite(2, 0, -2, 1, -2, -1)
         Bullet.Position = <span class="kwrd">New</span> Point(Player.Position.X + 15, Player.Position.Y + 9)
         Bullet.Color = Color.Cyan
         SpriteEngineDestination1.AddSprite(Bullet)
         <span class="kwrd">Dim</span> BulletMover <span class="kwrd">As</span> SCG.TurboSprite.DestinationMover = _
SpriteEngineDestination1.GetMover(Bullet)
         BulletMover.Destination = <span class="kwrd">New</span> Point(SpriteSurface1.Width + 5, _
Bullet.Height)
         BulletMover.SpeedX = 4

      <span class="kwrd">End</span> <span class="kwrd">If</span>
   <span class="kwrd">End</span> <span class="kwrd">Sub</span>

   <span class="kwrd">Private</span> <span class="kwrd">Sub</span> Form1_KeyUp(<span class="kwrd">ByVal</span> sender <span class="kwrd">As</span> <span class="kwrd">Object</span>, <span class="kwrd">ByVal</span> _
e <span class="kwrd">As</span> System.Windows.Forms.KeyEventArgs) <span class="kwrd">Handles</span> <span class="kwrd">Me</span>.KeyUp

      <span class="rem">'Stop moving, but only if "a" or "z" is released.</span>
      <span class="kwrd">If</span> e.KeyData = Keys.A <span class="kwrd">Or</span> e.KeyCode = Keys.Z <span class="kwrd">Then</span>
         <span class="kwrd">Me</span>.PlayerMover.SpeedY = 0
      <span class="kwrd">End</span> <span class="kwrd">If</span>

   <span class="kwrd">End</span> <span class="kwrd">Sub</span>

   <span class="kwrd">Private</span> <span class="kwrd">Sub</span> SpriteEngineDestination1_SpriteReachedDestination(<span class="kwrd">ByVal</span> sender <span class="kwrd">As</span> _
<span class="kwrd">Object</span>, <span class="kwrd">ByVal</span> e <span class="kwrd">As</span> SCG.TurboSprite.SpriteEventArgs) <span class="kwrd">Handles</span> SpriteEngineDestination1.SpriteReachedDestination
      <span class="rem">'You really should subclass the bullet to be able to</span>
      <span class="rem">'tag it as a bullet. I use color. Hack!!!</span>
      <span class="kwrd">Dim</span> P <span class="kwrd">As</span> SCG.TurboSprite.PolygonSprite = <span class="kwrd">CType</span>(e.Sprite, SCG.TurboSprite.PolygonSprite)
      <span class="kwrd">If</span> P.Color = Color.Cyan <span class="kwrd">Then</span>
         P.Kill()
         SpriteEngineDestination1.RemoveSprite(P)
      <span class="kwrd">End</span> <span class="kwrd">If</span>
   <span class="kwrd">End</span> <span class="kwrd">Sub</span>

   <span class="kwrd">Private</span> <span class="kwrd">Sub</span> SpriteSurface1_SpriteCollision(<span class="kwrd">ByVal</span> sender <span class="kwrd">As</span> _
<span class="kwrd">Object</span>, <span class="kwrd">ByVal</span> e <span class="kwrd">As</span> SCG.TurboSprite.SpriteCollisionEventArgs) <span class="kwrd">Handles</span> SpriteSurface1.SpriteCollision
      <span class="rem">'Did the player shoot the enemy? Is one a bullet and one the enemy?</span>
      <span class="rem">'Again, I use color. Hack!!!</span>
      <span class="kwrd">Dim</span> FirstSprite <span class="kwrd">As</span> SCG.TurboSprite.PolygonSprite = <span class="kwrd">CType</span>(e.Sprite1, _
SCG.TurboSprite.PolygonSprite)
      <span class="kwrd">Dim</span> SecondSprite <span class="kwrd">As</span> SCG.TurboSprite.PolygonSprite = <span class="kwrd">CType</span>(e.Sprite2, _
SCG.TurboSprite.PolygonSprite)
      <span class="kwrd">If</span> FirstSprite.Color = Color.Cyan <span class="kwrd">Then</span>
         <span class="rem">'We have a bullet.</span>
         <span class="kwrd">If</span> SecondSprite.Color = Color.Red <span class="kwrd">Then</span>
            <span class="rem">'And the enemy.</span>
            SecondSprite.Kill()
            SpriteEngineDestination1.RemoveSprite(SecondSprite)
         <span class="kwrd">End</span> <span class="kwrd">If</span>
      <span class="kwrd">ElseIf</span> FirstSprite.Color = Color.Red <span class="kwrd">Then</span>
         <span class="rem">'We have the enemy.</span>
         <span class="kwrd">If</span> SecondSprite.Color = Color.Cyan <span class="kwrd">Then</span>
            <span class="rem">'And a bullet.</span>
            FirstSprite.Kill()
            SpriteEngineDestination1.RemoveSprite(FirstSprite)
         <span class="kwrd">End</span> <span class="kwrd">If</span>
      <span class="kwrd">End</span> <span class="kwrd">If</span>
   <span class="kwrd">End</span> <span class="kwrd">Sub</span>

<span class="kwrd">End</span> <span class="kwrd">Class</span>
</pre>
<p>Again, subclass and add your own properties! Do not use color to determine what sprite you are dealing with. This is the result:</p>
<p><img alt="" src="http://imghost.winsoft.se/upload/142911279565002scramble.jpg" class="alignnone" width="307" height="151" /></p>
<p>Thank you, TurboSprite!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.winsoft.se/2010/07/writing-a-game-using-turbosprite-22/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>En snabbkurs i homeopatiska läkemedel</title>
		<link>http://www.winsoft.se/2010/07/en-snabbkurs-i-homeopatiska-lakemedel/</link>
		<comments>http://www.winsoft.se/2010/07/en-snabbkurs-i-homeopatiska-lakemedel/#comments</comments>
		<pubDate>Mon, 19 Jul 2010 17:08:42 +0000</pubDate>
		<dc:creator>Anders Hesselbom</dc:creator>
				<category><![CDATA[Science]]></category>

		<guid isPermaLink="false">http://www.winsoft.se/?p=1302</guid>
		<description><![CDATA[En liten snabbkurs i homeopatika från Der Spiegel, tips från Orsakverkan (Twitter). D1 betyder att lösningen är spädd med en del av den aktiva ingrediensen och 9 delar vatten. D2 betyder att en D1 lösning är spädd på samma sätt, så att en hundradel av lösningen är den aktiva ingrediensen. Siffran talar alltså om hur [...]]]></description>
			<content:encoded><![CDATA[<p>En liten snabbkurs i homeopatika från <a href="http://www.spiegel.de/international/germany/bild-706971-111828.html" target="_blank">Der Spiegel</a>, tips från <a href="http://twitter.com/orsakverkan" target="_blank">Orsakverkan</a> (Twitter).</p>
<p>D1 betyder att lösningen är spädd med en del av den aktiva ingrediensen och 9 delar vatten. D2 betyder att en D1 lösning är spädd på samma sätt, så att en hundradel av lösningen är den aktiva ingrediensen. Siffran talar alltså om hur många nollor du ska ha i faktorn. D1 betyder 1:10. D2 betyder 1:100. D3 betyder 1:1000. D9 betyder 1:1 miljard, alltså ungefär som en droppe av den aktiva substansen i en tankbil. D78 betyder att av alla molikyler som finns i hela universum, är några stycken från den aktiva ingrediensen. Enligt Der Spiegel används lösningar upp till D1000 i Tyskland. Vågar man påstå att homeopater säljer <em><u>dyrt</u></em> kranvatten?</p>
<p>Du som inte redan följer Pekkas blogg, Orsakverkan, hittar den <a href="http://orsakverkan.blogspot.com/" target="_blank">här</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.winsoft.se/2010/07/en-snabbkurs-i-homeopatiska-lakemedel/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Writing a game using TurboSprite (1/2)</title>
		<link>http://www.winsoft.se/2010/07/writing-a-game-using-turbosprite-12/</link>
		<comments>http://www.winsoft.se/2010/07/writing-a-game-using-turbosprite-12/#comments</comments>
		<pubDate>Mon, 19 Jul 2010 13:13:47 +0000</pubDate>
		<dc:creator>Anders Hesselbom</dc:creator>
				<category><![CDATA[Visual Basic 9]]></category>
		<category><![CDATA[2D game]]></category>

		<guid isPermaLink="false">http://www.winsoft.se/?p=1298</guid>
		<description><![CDATA[There are two things to take away from this post. The ease of TurboSprite and the power and speed of GDI+. Of course, you are still supposed to write games using hardware acceleration, but you can do decent desktop games without DirectX, XNA or OpenGL. In this first part, I will create a player (a [...]]]></description>
			<content:encoded><![CDATA[<p>There are two things to take away from this post. The ease of TurboSprite and the power and speed of GDI+. Of course, you are still supposed to write games using hardware acceleration, but you can do decent desktop games without DirectX, XNA or OpenGL.</p>
<p>In this first part, I will create a player (a spaceship) that can respond to keyboard control. In the second part, the player will be able to shoot and kill enemies.</p>
<p>To start off, I create a project, I add a sprite <strong>surface</strong> and an <strong>sprite engine destination</strong>. I connect them to each other by setting the <strong>Surface</strong> property of the engine. Also, I intend to use collision detection, so I set the <strong>DetectCollisionSelf</strong> property to True.</p>
<p>On the surface, I set the <strong>AutoBlank</strong> property to True and the <strong>AutoBlankColor</strong> property to Black. On the form, I set <strong>KeyPreview</strong> to True.</p>
<p>Note that so far, all the magic is happening in <strong>KeyDown</strong>, <strong>KeyUp</strong> (input feedback) and <strong>Shown</strong> (initialization).</p>
<pre class="csharpcode">
<span class="kwrd">Public</span> <span class="kwrd">Class</span> Form1

   <span class="rem">'A reference to the player (created in the Shown event) and the mover.</span>
   <span class="kwrd">Private</span> Player <span class="kwrd">As</span> SCG.TurboSprite.PolygonSprite
   <span class="kwrd">Private</span> PlayerMover <span class="kwrd">As</span> SCG.TurboSprite.DestinationMover

   <span class="kwrd">Private</span> <span class="kwrd">Sub</span> Form1_Shown(<span class="kwrd">ByVal</span> sender <span class="kwrd">As</span> <span class="kwrd">Object</span>, <span class="kwrd">ByVal</span> e <span class="kwrd">As</span> _
System.EventArgs) <span class="kwrd">Handles</span> <span class="kwrd">Me</span>.Shown

      <span class="rem">'Set the desired number of frames per second and activate the surface.</span>
      SpriteSurface1.DesiredFPS = 40
      SpriteSurface1.Active = <span class="kwrd">True</span>

      <span class="rem">'Create the player and save the reference.</span>
      <span class="kwrd">Me</span>.Player = <span class="kwrd">New</span> SCG.TurboSprite.PolygonSprite(-20, -10, 20, 10, -20, 10)

      <span class="rem">'Set player original position.</span>
      <span class="kwrd">Me</span>.Player.Position = <span class="kwrd">New</span> Point(100, 100)

      <span class="rem">'Set player color.</span>
      <span class="kwrd">Me</span>.Player.Color = Color.Yellow

      <span class="rem">'Add the player to the sprite engine.</span>
      SpriteEngineDestination1.AddSprite(<span class="kwrd">Me</span>.Player)

      <span class="rem">'Save a reference to the mover.</span>
      <span class="kwrd">Me</span>.PlayerMover = SpriteEngineDestination1.GetMover(<span class="kwrd">Me</span>.Player)

   <span class="kwrd">End</span> <span class="kwrd">Sub</span>

   <span class="kwrd">Private</span> <span class="kwrd">Sub</span> Form1_KeyDown(<span class="kwrd">ByVal</span> sender <span class="kwrd">As</span> <span class="kwrd">Object</span>, <span class="kwrd">ByVal</span> _
e <span class="kwrd">As</span> System.Windows.Forms.KeyEventArgs) <span class="kwrd">Handles</span> <span class="kwrd">Me</span>.KeyDown
      <span class="kwrd">If</span> e.KeyData = Keys.A <span class="kwrd">Then</span>

         <span class="rem">'If user presses "a", move up!</span>
         <span class="kwrd">Me</span>.PlayerMover.DestY = 0
         <span class="kwrd">Me</span>.PlayerMover.SpeedY = -2

      <span class="kwrd">ElseIf</span> e.KeyData = Keys.Z <span class="kwrd">Then</span>

         <span class="rem">'If user presses "z", move down!</span>
         <span class="kwrd">Me</span>.PlayerMover.DestY = SpriteSurface1.Height
         <span class="kwrd">Me</span>.PlayerMover.SpeedY = 2

      <span class="kwrd">End</span> <span class="kwrd">If</span>
   <span class="kwrd">End</span> <span class="kwrd">Sub</span>

   <span class="kwrd">Private</span> <span class="kwrd">Sub</span> Form1_KeyUp(<span class="kwrd">ByVal</span> sender <span class="kwrd">As</span> <span class="kwrd">Object</span>, <span class="kwrd">ByVal</span> _
e <span class="kwrd">As</span> System.Windows.Forms.KeyEventArgs) <span class="kwrd">Handles</span> <span class="kwrd">Me</span>.KeyUp

      <span class="rem">'Stop moving!</span>
      <span class="kwrd">Me</span>.PlayerMover.SpeedY = 0

   <span class="kwrd">End</span> <span class="kwrd">Sub</span>

<span class="kwrd">End</span> <span class="kwrd">Class</span>
</pre>
<p>Continued <a href="http://www.winsoft.se/2010/07/writing-a-game-using-turbosprite-22/">here</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.winsoft.se/2010/07/writing-a-game-using-turbosprite-12/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>TurboSprite</title>
		<link>http://www.winsoft.se/2010/07/turbosprite/</link>
		<comments>http://www.winsoft.se/2010/07/turbosprite/#comments</comments>
		<pubDate>Thu, 15 Jul 2010 13:23:01 +0000</pubDate>
		<dc:creator>Anders Hesselbom</dc:creator>
				<category><![CDATA[Visual Basic 9]]></category>
		<category><![CDATA[2D game]]></category>

		<guid isPermaLink="false">http://www.winsoft.se/?p=1293</guid>
		<description><![CDATA[TurboSprite is a software driven (GDI+) sprite engine written by Dion Kurczek in C#. The reason that I&#8217;m picking this up, is that it shows (like I have mentioned before) the amazing capabilities and performance of the GDI+ library in .NET. TurboSprite provides a sprite container, bitmap sprites, vector sprites and collision detection. To be [...]]]></description>
			<content:encoded><![CDATA[<p>TurboSprite is a software driven (GDI+) sprite engine written by Dion Kurczek in C#. The reason that I&#8217;m picking this up, is that it shows (like I have mentioned before) the amazing capabilities and performance of the GDI+ library in .NET. TurboSprite provides a sprite container, bitmap sprites, vector sprites and collision detection.</p>
<p>To be able to use TurboSprite, download and compile it, add the components to your toolbox. Then, add a surface and an engine to a form. Note that you have two engines. One is called <strong>SpriteEngine</strong> and another is called SpriteEngineDestination. Use the <strong>SpriteEngineDestination</strong> object, because it extends the <strong>SpriteEngine</strong> class with the ability to move sprites. You might want to set a few properties to connect the engine to the surface, to tell the engine if you want collision detection and so on. Collision detection is a reasonable cause for using a sprite engine. I use the <strong>AutoBlank</strong> feature of the surface.</p>
<p>About the moving of the sprites, you can acquire the sprite mover using the <strong>GetMover</strong> function for the engine (if you use the <strong>SpriteEngineDestination</strong>), and set the X and Y speed of a sprite. Or you can do as I do in this example below. That is, just set a speed and a destination position. The destination position determines the sprite movement direction.</p>
<p>This code does two thinks (written in the <strong>Show</strong> event of a regular form). The first line activates the sprite engine so that sprites will move. The rest of the code initializes one vector sprite.</p>
<pre class="csharpcode">
<span class="rem">'When the form is loaded, activate the surface</span>
SpriteSurface1.Active = <span class="kwrd">True</span>

<span class="rem">'Create a space ship. These points makes a ship.</span>
<span class="kwrd">Dim</span> S <span class="kwrd">As</span> <span class="kwrd">New</span> SCG.TurboSprite.PolygonSprite(0, -10, 5, 10, 0, 5, -5, 10)

<span class="rem">'Tell the sprite to rotate.</span>
S.Spin = SCG.TurboSprite.SpinType.Clockwise
S.SpinSpeed = 3

<span class="rem">'Start position.</span>
S.Position = <span class="kwrd">New</span> Point(30, 30)

<span class="rem">'Add the sprite to the engine, and acquire the sprite mover from the engine.</span>
SpriteEngineDestination1.AddSprite(S)
<span class="kwrd">Dim</span> Mover <span class="kwrd">As</span> SCG.TurboSprite.DestinationMover = SpriteEngineDestination1.GetMover(S)

<span class="rem">'Tell the mover about speed and direction.</span>
Mover.Speed = 5
Mover.Destination = <span class="kwrd">New</span> Point(50, 40)

<span class="rem">'Tell the mover that the destination really isn't a destination,</span>
<span class="rem">'it's just used as a direction.</span>
Mover.StopAtDestination = <span class="kwrd">False</span>
</pre>
<p>This is the sprite:</p>
<p><img alt="" src="http://imghost.winsoft.se/upload/594291279199894sprite.jpg" class="alignnone" width="307" height="202" /></p>
<p>Download the engine <a href="http://www.codeproject.com/KB/game/TurboSprite.aspx" target="_blank">from the Code Project web site</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.winsoft.se/2010/07/turbosprite/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>User interaction: GetItemAt and GetItemsAt</title>
		<link>http://www.winsoft.se/2010/07/user-interaction-getitemat-och-getitemsat/</link>
		<comments>http://www.winsoft.se/2010/07/user-interaction-getitemat-och-getitemsat/#comments</comments>
		<pubDate>Fri, 09 Jul 2010 17:16:47 +0000</pubDate>
		<dc:creator>Anders Hesselbom</dc:creator>
				<category><![CDATA[Programs]]></category>
		<category><![CDATA[The Wall]]></category>

		<guid isPermaLink="false">http://www.winsoft.se/?p=1282</guid>
		<description><![CDATA[GetItemAt The GetItemAt function returns the graphical item (text item, bar item, numeric item) that exists at a given position, in characters. If no item exists at the given position, the value Nothing will be returned (null). The GetItemsAt function also takes a position (X and Y) as argument but GetItemsAt will always return a [...]]]></description>
			<content:encoded><![CDATA[<p><strong>GetItemAt</strong></p>
<p>The <strong>GetItemAt</strong> function returns the graphical item (text item, bar item, numeric item) that exists at a given position, in characters. If no item exists at the given position, the value <strong>Nothing</strong> will be returned (null). The <strong>GetItemsAt</strong> function also takes a position (X and Y) as argument but <strong>GetItemsAt</strong> will always return a collection object. If no graphical items exist at the given position, the collection will be empty. If more than one item exists at the given position, all of the items will be returned in that collection.</p>
<p>This first example will register two text items. Both of them will be static (that is, they will not auto update). The value of the first one will be Apples and the value of the second one will be Pears. Also, the program registers a callback for mouse clicking. If you click on Apples, a message box will show the word Apples, if you click on Pears, a message box will show the word Pears.</p>
<p>To start off, this code will register the items:</p>
<pre>BackgroundColor = "#000000"

RegisterTextItem 0, "ApplesItem", 4, 2, "#ffffff", "InitApplesItem"
RegisterTextItem 0, "PearsItem", 4, 3, "#ffffff", "InitPearsItem"

Sub InitApplesItem(ByVal Item)
   Item.Value = "Apples"
End Sub

Sub InitPearsItem(ByVal Item)
   Item.Value = "Pears"
End Sub</pre>
<p><img alt="" src="http://imghost.winsoft.se/upload/811861278695578userinteraction1.jpg" class="alignnone" width="354" height="297" /></p>
<p>And this is the complete source code. Here I register a callback function to detect clicks, and from there I use the <strong>GetItemAt</strong> function to see what item the user clicked on.</p>
<pre>BackgroundColor = "#000000"

RegisterTextItem 0, "ApplesItem", 4, 2, "#ffffff", "InitApplesItem"
RegisterTextItem 0, "PearsItem", 4, 3, "#ffffff", "InitPearsItem"
RegisterClickCallback "Click"

Sub InitApplesItem(ByVal Item)
   Item.Value = "Apples"
End Sub

Sub InitPearsItem(ByVal Item)
   Item.Value = "Pears"
End Sub

Sub Click(ByVal X, ByVal Y)
	Set Item=GetItemAt(X, Y)
	If Not Item Is Nothing Then
		MsgBox Item.Value
	End If
End Sub</pre>
<p><strong>GetItemsAt</strong></p>
<p>This is a constructed example to show how to use the <strong>GetItemsAt</strong> function. I am sure you can think of more and better examples.</p>
<p>This program holds a bar item and a text item overlaying the bar item. You want to detect clicks on any bar item in the program. This code adds the text and bar items, it also registers a click callback called Click. The click callback uses the <strong>GetItemsAt</strong> function to determine if the bar was clicked.</p>
<pre>BackgroundColor = "#000000"

Bar=RegisterBarItem(1, "B", 3, 2, "#5599aa", "UpdateBar")
GetItem(Bar).Size = 11
GetItem(Bar).ValueVisible = False

RegisterTextItem 0, "T", 4, 2, "#ffffff", "InitText"
RegisterClickCallback "Click"

Sub InitText(ByVal Item)
   Item.Value = "Some text"
End Sub

Sub UpdateBar(ByVal Item)
   Item.Value=Round(Rnd() * 100)
End Sub

Sub Click(ByVal X, ByVal Y)
   Set Items=GetItemsAt(X, Y)
   For Each Item In Items
      If Item.TypeName = "BarItem" Then
         MsgBox "You have clicked on a bar named " &#038; Item.Name &#038; "."
      End If
   Next
End Sub</pre>
<p>Note how the click callback function filters out any bar items from the collection, and displays the name of them (just one in this case).</p>
]]></content:encoded>
			<wfw:commentRss>http://www.winsoft.se/2010/07/user-interaction-getitemat-och-getitemsat/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Tweaking the wall, part 3/3: Startup script</title>
		<link>http://www.winsoft.se/2010/07/tweaking-the-wall-part-33-startup-script/</link>
		<comments>http://www.winsoft.se/2010/07/tweaking-the-wall-part-33-startup-script/#comments</comments>
		<pubDate>Sun, 04 Jul 2010 09:16:16 +0000</pubDate>
		<dc:creator>Anders Hesselbom</dc:creator>
				<category><![CDATA[Programs]]></category>
		<category><![CDATA[The Wall]]></category>

		<guid isPermaLink="false">http://www.winsoft.se/?p=1278</guid>
		<description><![CDATA[The basic rule is that a VBScript file called TheWall.vbs that is placed in the same folder as TheWall.exe is loaded when TheWall.exe is started. Remember that you start TheWall.exe, not any script file &#8211; the script file is loaded by TheWall.exe. So if you are creating a shortcut, the shortcut should point to TheWall.exe. [...]]]></description>
			<content:encoded><![CDATA[<p>The basic rule is that a VBScript file called TheWall.vbs that is placed in the same folder as TheWall.exe is loaded when TheWall.exe is started. Remember that you start TheWall.exe, not any script file &#8211; the script file is loaded by TheWall.exe. So if you are creating a shortcut, the shortcut should point to TheWall.exe.</p>
<p>You can manipulate this behavior by passing a filename as an argument to TheWall.exe. If a filename is passed, The Wall attempts to load that file instead of TheWall.vbs. There is no fallback, so the file you pass as an argument, must exist. The Wall cannot be started if no filename is passed as argument and the file TheWall.vbs is not present, or if a filename is passed as an argument and that file does not exist.</p>
<p>To check what file is running, use the <strong>ScriptFilename</strong> property.</p>
<pre>MsgBox ScriptFilename</pre>
<p>Just for the fun of it, this code will produce a line that is bouncing within a box. And now you know how to start it.</p>
<pre>BackgroundColor = "#000000"

X1 = 0
Y1 = 0
X1Speed = 4
Y1Speed = 2

X2 = 30
Y2 = 190
X2Speed = 2
Y2Speed = 1

BeforeUpdate "Bounce"

Sub Bounce(ByVal G)
   X1 = X1 + X1Speed
   Y1 = Y1 + Y1Speed
   If X1 > 200 Or X1 < 0 Then
      X1Speed = X1Speed * -1
   End If
   If Y1 > 200 Or Y1 < 0 Then
      Y1Speed = Y1Speed * -1
   End If

   X2 = X2 + X2Speed
   Y2 = Y2 + Y2Speed
   If X2 > 200 Or X2 < 0 Then
      X2Speed = X2Speed * -1
   End If
   If Y2 > 200 Or Y2 < 0 Then
      Y2Speed = Y2Speed * -1
   End If

   G.DrawBar "#555555", 0, 0, 200, 200
   G.DrawLine "#ffffff", X1, Y1, X2, Y2
End Sub</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.winsoft.se/2010/07/tweaking-the-wall-part-33-startup-script/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Tweaking the wall, part 2/3: Using the graphics drawing interface</title>
		<link>http://www.winsoft.se/2010/07/tweaking-the-wall-part-23-using-the-graphics-drawin-interface/</link>
		<comments>http://www.winsoft.se/2010/07/tweaking-the-wall-part-23-using-the-graphics-drawin-interface/#comments</comments>
		<pubDate>Sat, 03 Jul 2010 13:18:22 +0000</pubDate>
		<dc:creator>Anders Hesselbom</dc:creator>
				<category><![CDATA[Programs]]></category>
		<category><![CDATA[The Wall]]></category>

		<guid isPermaLink="false">http://www.winsoft.se/?p=1269</guid>
		<description><![CDATA[The BeforUpdate and AfterUpdate callback functions are basically used to allow custom graphics to be drawn below or above it. The graphics drawing interface is passed as an argument to the function you register as a callback function. Again, this Is the Hello World application of The Wall: BackgroundColor = "#445566" RegisterTextItem 0, "A", 4, [...]]]></description>
			<content:encoded><![CDATA[<p>The <strong>BeforUpdate</strong> and <strong>AfterUpdate</strong> callback functions are basically used to allow custom graphics to be drawn below or above it. The graphics drawing interface is passed as an argument to the function you register as a callback function. Again, this Is the Hello World application of The Wall:</p>
<pre>BackgroundColor = "#445566"
RegisterTextItem 0, "A", 4, 4, "#aabbcc", "InitializeText"

Sub InitializeText(ByVal Item)
   Item.Value = "Hello World!"
End Sub</pre>
<p>This is what we get:</p>
<p><span style="font-size: 18px; background-color: #000; color: #0f0;">Hello World!</span></p>
<p>No, let&#8217;s say that I want to draw something before and after the text item that I have registered in the above code, I would have to register these two callback methods too, like so:</p>
<pre>BackgroundColor = "#000000"
RegisterTextItem 0, "A", 1, 1, "#00ff00", "InitializeText"

BeforeUpdate "MyBeforeFunction"
AfterUpdate "MyAfterFunction"

Sub MyBeforeFunction(ByVal G)
   <span style="color: #0a0;">'TODO: Use the graphics drawing interface here!</span>
End Sub

Sub MyAfterFunction(ByVal G)
   <span style="color: #0a0;">'TODO: Use the graphics drawing interface here!</span>
End Sub

Sub InitializeText(ByVal Item)
   Item.Value = "Hello World!"
End Sub</pre>
<p>Any drawing done in <strong>MyBeforeFunction</strong> will appear behind the text Hello World! since <strong>MyBeforeFunction</strong> was registered using the built in <strong>BeforeUpdate</strong> function. Any drawing done in <strong>MyAfterFunction</strong> will appear in front of the text since it was registered using the built in <strong>AfterUpdate</strong> function.</p>
<p>This will give us a blue rectangle behind the text, and a yellow rectangle in front of the text.</p>
<pre>BackgroundColor = "#000000"
RegisterTextItem 0, "A", 1, 1, "#00ff00", "InitializeText"

BeforeUpdate "MyBeforeFunction"
AfterUpdate "MyAfterFunction"

Sub MyBeforeFunction(ByVal G)
   G.DrawBar "#0000ff", 0, 0, 400, 60
End Sub

Sub MyAfterFunction(ByVal G)
   G.DrawBar "#ffff00", 0, 65, 400, 60
End Sub

Sub InitializeText(ByVal Item)
   Item.Value = "Hello World!"
End Sub</pre>
<p>Like so:</p>
<p><img alt="" src="http://imghost.winsoft.se/upload/114001278162485helloworld.jpg" class="alignnone" width="346" height="149" /></p>
<p>The <strong>DrawLine</strong> function accepts a color (all colors are in string format), X1, Y1, X2 and Y2. The <strong>DrawBar</strong> function accepts a color, X, Y, Width and Height, just as the <strong>DrawRectangle</strong> function.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.winsoft.se/2010/07/tweaking-the-wall-part-23-using-the-graphics-drawin-interface/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>My bits on evolution, part 1</title>
		<link>http://www.winsoft.se/2010/06/my-bits-on-evolution-part-1/</link>
		<comments>http://www.winsoft.se/2010/06/my-bits-on-evolution-part-1/#comments</comments>
		<pubDate>Tue, 29 Jun 2010 17:41:11 +0000</pubDate>
		<dc:creator>Anders Hesselbom</dc:creator>
				<category><![CDATA[Science]]></category>
		<category><![CDATA[Evolution]]></category>

		<guid isPermaLink="false">http://www.winsoft.se/?p=1262</guid>
		<description><![CDATA[Some of my bits for the Swedish Skeptic Podcast, Skeptikerpodden, on evolution and creationism, in Swedish. Några av mina bidrag till svenska Skeptikerpodden om evolution och kreationism, på svenska. 1. &#8220;Evolutionism&#8221; (från Skeptikerpodden 31/3 2010) 2. Kreationistiska falanger (från Skeptikerpodden 12/4 2010) 3. Bevis för evolution (från Skeptikerpodden 3/5 2010)]]></description>
			<content:encoded><![CDATA[<p><em>Some of my bits for the Swedish Skeptic Podcast, Skeptikerpodden, on evolution and creationism, in Swedish.</em></p>
<p>Några av mina bidrag till svenska Skeptikerpodden om evolution och kreationism, på svenska.</p>
<p>1. <a href="http://www.youtube.com/watch?v=rZTCXQTAvSw" target="_blank">&#8220;Evolutionism&#8221;</a> (från Skeptikerpodden 31/3 2010)</p>
<p>2. <a href="http://www.youtube.com/watch?v=sBLzXcP2fo8" target="_blank">Kreationistiska falanger</a> (från Skeptikerpodden 12/4 2010)</p>
<p>3. <a href="http://www.youtube.com/watch?v=L8tZn0qeYRg" target="_blank">Bevis för evolution</a> (från Skeptikerpodden 3/5 2010)</p>
]]></content:encoded>
			<wfw:commentRss>http://www.winsoft.se/2010/06/my-bits-on-evolution-part-1/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
