<?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>Christopher Ross &#187; Torque Game Builder</title>
	<atom:link href="http://www.thisismyurl.com/category/tutorials/torque/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.thisismyurl.com</link>
	<description>Web Development, Online Marketing &#38; Graphic Design</description>
	<lastBuildDate>Tue, 09 Mar 2010 15:05:36 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.1</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Code Free Pong</title>
		<link>http://www.thisismyurl.com/tutorials/torque/code-free-pong/</link>
		<comments>http://www.thisismyurl.com/tutorials/torque/code-free-pong/#comments</comments>
		<pubDate>Sun, 28 Oct 2007 18:12:52 +0000</pubDate>
		<dc:creator>Christopher Ross</dc:creator>
				<category><![CDATA[Free Downloads]]></category>
		<category><![CDATA[Torque Game Builder]]></category>
		<category><![CDATA[pong]]></category>

		<guid isPermaLink="false">http://www.thisismyurl.com/code-free-pong/</guid>
		<description><![CDATA[Pong, the timeless classic that started it all and the first Torque Game Builder tutorial that I’ll tackle. This game is a simple virtual tennis game in which two players (represented by paddles) bounce a ball towards each other.]]></description>
			<content:encoded><![CDATA[<p><a id="thumb2" class="highslide" onclick="return hs.expand(this, {captionId: 'caption1'})" href="http://www.thisismyurl.com/wp-content/uploads/2007/10/screenshot.jpg"  rel="lightbox[roadtrip]"><img title="screenshot.jpg" src="http://www.thisismyurl.com/wp-content/uploads/2007/10/screenshot.thumbnail.jpg" border="1" alt="screenshot.jpg" align="right" /></a>Pong, the timeless classic that started it all and the first <a href="http://garagegames.com/products/torque/tgb/">Torque Game Builder</a> tutorial that I&#8217;ll tackle. This game is a simple virtual tennis game in which two players (represented by paddles) bounce a ball towards each other.</p>
<p>This tutorial is a very basic introduction to the Torque Game Builder engine and it&#8217;s also my first tutorial for the package, the resulting <a title="Code Free Pong For Mac and Windows" href="http://www.thisismyurl.com/wp-content/uploads/2007/10/codefreepong.zip">Code Free Pong For Mac and Windows</a> game can be downloaded and played on Mac and Windows or you can download the <a title="Source Code" href="http://www.thisismyurl.com/wp-content/uploads/2007/10/pong.zip">Source Code</a> directly to follow along.</p>
<h2>Getting Started</h2>
<p>Let&#8217;s get started by opening the Torque Game Builder and creating a new game called Pong. It will be an empty game to start with, so we&#8217;re going to have to import a couple of static graphics to get us started. I&#8217;ve already build the paddles and ball for your game, so you can download these <a title="Assets" href="http://www.thisismyurl.com/wp-content/uploads/2007/10/assets.zip">files</a> to get started without having to build them yourself. Now let&#8217;s import the files by switching to the Create panel and selecting the Create New icon (<img title="Create New" src="http://www.thisismyurl.com/wp-content/uploads/2007/10/createbutton.thumbnail.jpg"  alt="Create New" width="20" height="20" / rel="lightbox[roadtrip]" />) to import each of the two files.</p>
<p>The next step is to setup our game by importing some predefined files and is going to require that we first quit Torque Game Builder and save our level (I called mine <em>LevelOne</em>). Since Torque doesn&#8217;t recognize files added to the directory once it has started, we have to quit TGB for a few moments.</p>
<p>In your file manager, lets move the whole behaviors folder from our desktop to the appropriate folder which in my case is <em>../Pong/game/</em>. We want to replace the existing behavior folder with the <a title="Behaviors" href="http://www.thisismyurl.com/wp-content/uploads/2007/10/behaviors.zip">preprogrammed behaviors</a> supplied by Garage Games. Once those files are copied, we can reload Torque Game Builder and continue building Pong by loading our previous game and then selecting <em>File &gt; Open Level </em>or using the keyboard shortcut <em>Control &#8211; O</em> to load our existing level.</p>
<h2>Setting Up the Ball</h2>
<p>What we want to do now is drag the ball graphic into the middle of our screen and drop it, this will create a single white dot which will act as our ball. Switch from the <strong>Create Panel</strong> to the <strong>Edit</strong> <strong>Panel</strong> and look down the list until you see the <strong>Scripting</strong> tab, open it and lets name this object &#8220;<em>ball</em>&#8221; and then open the <strong>Collision</strong> tab. We want to set the ball to <em>Send</em> and <em>Receive Collisions</em> by clicking the appropriate check boxes. Once that&#8217;s done let&#8217;s switch the <em>Collision Response</em> to BOUNCE.</p>
<p>Now let&#8217;s take a quick look at what we&#8217;ve done here and make sure we understand it all. An understanding of the Torque basics will help us progress through the next part of the tutorial. We dragged a copy of the ball graphic into the picture, then we selected it and clicked Edit. Under that menu, we changed its name to <em>ball</em>. Next, we told it that the ball could both be hit and hit other things. Finally, we told it that when something hits it, the proper response is to bounce.</p>
<h2>Adding Behaviors</h2>
<p>In Torque a <em>Behavior</em> is a preprogrammed set of instructions used to help us get our games up and running faster, the team at GarageGames includes a variety of Behaviors in the TGB kit and we&#8217;re going to use them to create Pong. There are two behaviors we want to setup for our ball.</p>
<p>First, let&#8217;s add the <em>Random Velocity</em> behavior which will give our ball a random start angle at the beginning of the game. To add this, lets open the <strong>Behavior</strong> tab and use the pulldown menu to located it. Once that&#8217;s done, we&#8217;re going use the green + beside the menu to add it to our ball. If you&#8217;d like you can now preview the game and watch your ball spin wildly out of control in a random direction.</p>
<p>Back in Torque, we want to give your ball life and the ability for it to &#8220;die&#8221; so lets add the <em>Takes Damage</em> behavior and set its maximum number of lives to 19 since a game of Pong can only ever go to a maximum of 19 points.</p>
<h2>Setting the World Limits</h2>
<p>Now the ball can take damage and it can also bounce but we need to make the ball stay on screen so lets take a look at the <strong>World Limits</strong> tab and our limit mode to BOUNCE, this will ensure that if the ball hits the edges of the world it will bounce back.</p>
<p>To set the actual World Limits we have two options, we can type the appropriate world limit numbers into the box or we can do it graphically by rolling our mouse over the ball until we see an icon representing the World Limits. If we click onto that icon the screen will zoom out slightly and present you with a lightly shaded box. This box is your World Limits and represents where the call is allowed to travel in the game. Resize the box so the top and bottom are at the top and bottom of the outermost green box (which is the edges of our game screen) and do the same for the left and right but instead of being exactly on the edges, lets add a little space to let the ball fall off our screen. When you hit the <em>Enter</em> key, you&#8217;re returned to your game preview mode and you&#8217;ll see that the values in World Limits now represent the values of the box you resized.</p>
<p>My box has a Min. Bounds of X = -60 and Y = -38, the Max. Bounds are X = 60 and Y = 38. This represents the furthest from the center of the screen my ball is allowed to travel before it bounces and if you&#8217;d like to see it in action you can now preview the game which will show your ball randomly bouncing off the top and bottom of the screen as well as disappearing on the left and right but eventually bouncing back into the frame.</p>
<h2>Killing the Ball</h2>
<p>Our game is coming along great but the problem is obvious, when the ball goes off the left and the right side of our screen, the ball needs to die so lets drag a paddle in from the <strong>Create</strong> menu and then switch back to <strong>Edit</strong>. This isn&#8217;t really going to be a paddle but I want to show you how we can use the same graphic for multiple purposes in Torque Game Builder.</p>
<p>First, lets resize our paddle to stretch from the top of the outermost green line to the bottom of the outermost green line. Let&#8217;s go to the <strong>Scene Object</strong> tab where we should clean up the <em>killzone</em> values by setting it to Position Y = 0 (which will center it vertically) and set it&#8217;s X = 5 which puts it just to the right of our ball. I&#8217;m also going to set the Width = 1 and a Height = 80 to make sure it&#8217;s bigger than my World Limits. Under the <strong>Physics</strong> tab we want to check the option Immovable which will ensure the the ball doesn&#8217;t push it around.</p>
<p>That&#8217;s a great start but now we need to actually kill the ball. Let&#8217;s quickly switch to our <strong>Collision</strong> tab and tell Torque that this new object can Send Collisions but can&#8217;t Receive Collisions.</p>
<p>Under the <strong>Behaviors</strong> tab we want to add the <em>Deals Damage </em>behavior and we want to set the strength of the damage to 1 and deselect the deleteOnHit option. Now our wall deals 1 point of damage each time the ball hits it but it won&#8217;t disappear regardless of how many times it&#8217;s hit.</p>
<p>Let&#8217;s go back to our ball now by selecting it and make sure it&#8217;s in the center of the screen by changing our<strong> Scene Object</strong> settings to a Position of X = 0 and Y = 0. You can now preview the game and watch the ball die each time it hits the <em>killzone</em> wall.</p>
<p>Lets now move our <em>killzone</em> to it&#8217;s proper location but before we do, we want to copy it using the keyboard short cut <em>Control &#8211; C </em>and paste a new one with the keyboard shortcut <em>Control &#8211; V</em>. The first killzone should be moved to Position X = -55 and the second killzone will be at Position X = 55. Now both killzones are off the screen to the left and right but still within the World Limits we set previously. If you test your game the ball will now bounce off the top and bottom of the screen but respawn when it goes past the left and right edges of the screen.</p>
<h2>Setting Up the Paddle</h2>
<p>Now let&#8217;s switch back to the <strong>Create</strong> panel and drag a paddle into the screen. We want to use the same practices we used above to name this paddle &#8220;paddlep&#8221;. Under the <strong>Scene Object </strong>tab we will set the Position to X = 45 and Y = 0 which centers the paddle vertically and places it on the right hand side of our screen. Under the <strong>Collision</strong> tab we want to make this object Send Collision and Physics but not receive either. These are all fairly similar to what we did for our killzone so far but now I want to add the <strong>World Limits</strong> for our paddle by settings it&#8217;s Min. Bounds to X = 44 and Y = -40, it&#8217;s Max. Bounds should be X = 46 and Y = 40, this will set the area our paddle can move. We also want to change the Limit Mode to BOUNCE which will cause it to bounce when it hits the edges.</p>
<p>Adding movement to our paddle is easy with the Torque Game Builder, let&#8217;s add the <strong>Behavior</strong> <em>Thruster Control </em>and change the horizontalThrust to 0 and the verticalTrust to 50. This will cause the paddle to move up and down but lack the power to move left and right. Previewing the game now will let you bounce the ball off the paddle if you&#8217;re lucky enough for it to come your way.</p>
<h2>Adding another Paddle</h2>
<p>As will the killzones, we want to copy and paste the paddle and change it&#8217;s <strong>Scene Object</strong> settings to a Position of X = -45 and Y = 0. The World Zones need to also be changed to Min. Bounds to X = -44 and Y = -40, it&#8217;s Max. Bounds should be X = -46 and Y = 40.  Remember to rename the paddle to paddlec, to reflect that this is the computers paddle.</p>
<p>Selecting the <em>Thruster Control</em> in the <strong>Behaviors</strong> panel will allow us to remove it so that we can add the behavior <em>Move Toward Object</em>, and we can set the object to ball using the pulldown menu with a speed of 50.</p>
<h2>In Summary</h2>
<p>So now we have a simple version of Pong using the Torque Game Builder. It&#8217;s pretty straight forward really, we need a ball which knows the size of the world it&#8217;s allowed in and it needs to bounce if it hits them. If it hits the sides of that world, it needs to die and if it hits the paddles it needs to bounce.</p>
<p>We&#8217;ve done all this without writing a single snippet of code and created a very simple game in about 20 minutes. There are a lot of neat tricks you can learn by experimenting with this tutorial, for example you could change this into a two player game easily by skipping the last step and changing the input keys or you could get rid of the keys altogether and have the players paddle follow the mouse using a behavior.</p>
<h2>What&#8217;s Next?</h2>
<p>This is a simple version of Pong with very little function and it&#8217;s designed as a tutorial for the Torque Game Builder but we could easily expand upon the game by adding more modern graphics, a score board and of course fixing the respawn point so it&#8217;s always in the middle of the screen.</p>
<p>Next weekend I&#8217;ll put together a new version of Pong with TGB using the scripting features. If you have any questions, please feel free to get in touch with me.</p>
<p>In the mean time, you can download the <a title="Code Free Pong For Mac and Windows" href="http://www.thisismyurl.com/wp-content/uploads/2007/10/codefreepong.zip">Code Free Pong For Mac and Windows</a> and play it for yourself.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.thisismyurl.com/tutorials/torque/code-free-pong/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Creating a Splash Screen in Torque Game Builder</title>
		<link>http://www.thisismyurl.com/tutorials/torque/creating-a-splash-screen-in-torque-game-builder/</link>
		<comments>http://www.thisismyurl.com/tutorials/torque/creating-a-splash-screen-in-torque-game-builder/#comments</comments>
		<pubDate>Thu, 25 Oct 2007 23:04:36 +0000</pubDate>
		<dc:creator>Christopher Ross</dc:creator>
				<category><![CDATA[Learning]]></category>
		<category><![CDATA[Torque Game Builder]]></category>
		<category><![CDATA[Dialog Box]]></category>
		<category><![CDATA[F10]]></category>
		<category><![CDATA[fancy name]]></category>
		<category><![CDATA[Game Builder]]></category>
		<category><![CDATA[Garagegames]]></category>
		<category><![CDATA[Graphic Interface]]></category>
		<category><![CDATA[Graphic User Interface]]></category>
		<category><![CDATA[Gui Builder]]></category>
		<category><![CDATA[Gui Class]]></category>
		<category><![CDATA[Heavy Lifting]]></category>
		<category><![CDATA[Keyboard Shortcut]]></category>
		<category><![CDATA[learning curve]]></category>
		<category><![CDATA[Left Hand Corner]]></category>
		<category><![CDATA[Menu Builder]]></category>
		<category><![CDATA[Novice Developers]]></category>
		<category><![CDATA[Pop]]></category>
		<category><![CDATA[Property Menu]]></category>
		<category><![CDATA[Splash Screen]]></category>
		<category><![CDATA[Upper Left Hand Corner]]></category>

		<guid isPermaLink="false">http://www.thisismyurl.com/creating-a-splash-screen-in-torque-game-builder/</guid>
		<description><![CDATA[Torque Game Builder from GarageGames is one of my favorite development suites, it’s straight forward with a low learning curve and an easy to navigate user interface but there are a couple of things that are a little tricky and take getting used to.]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.garagegames.com/products/torque/tgb/">Torque Game Builder</a> from GarageGames is one of my favorite development suites, it&#8217;s straight forward with a low learning curve and an easy to navigate user interface but there are a couple of things that are a little tricky and take getting used to. One of those is the process of adding a simple Splash Screen to your project. In this article I will assume that you&#8217;ve never used the Torque Game Builder program before but that you have a basic understanding of the concepts of gaming. This tutorial is designed to do nothing more than load a screen, fade it from black and then back to black before loading your game.</p>
<p>So lets get started by loading Torque Game Builder and creating a new project (or loading an existing one). Once it&#8217;s opened we want to open the GUI Builder (GUI stands for Graphic User Interface) using the menu Project &gt; GUI Builder or hitting the keyboard shortcut key <em>F10</em>. Once the GUI builder is opened, we are going to add a new GUI by using the menu File &gt; New GIU which will pop up a dialog box allowing you to name your GUI, I want to name mine &#8220;ggSplash&#8221; because it&#8217;s going to be used to load the Garage Game Splash screen. Next we want to set the GUI Class and because it&#8217;s a simple fade in we&#8217;re going to use the <em>GuiFadeinBitmapCtrl</em> which will do most of the heavy lifting for us. Click Create to create the splash screen.</p>
<p>So this is where the Torque Game Builder GUI Builder gets a little tricky for novice developers, in the upper left hand corner of your newly create splash screen is an object tree which will contain the newly create GUI object with the fancy name <em>GuiFadeinBitmapCtrl</em>, click it to access the property menu below and you will see several options that you can set.</p>
<blockquote><p>General &gt; faceinTime &#8211; How long will it take to fade it in milliseconds (1000 = 1 second)</p>
<p>General &gt; waitTime &#8211; How long will it last in milliseconds (1000 = 1 second)</p>
<p>General &gt; fadeouttime &#8211; How long to fade out in milliseconds (1000 = 1 second)</p>
<p>GuiBitmapCtrl &gt; bitmap &#8211; The file that you want to use as your graphic</p></blockquote>
<p>There&#8217;s also a whole lot of very technical elements to this control but unless you understand them, you&#8217;re best to trust GarageGames default values. Using the four above you can effect how the control shows your splash screen. Once you&#8217;re done playing with the settings, save the file as &#8220;ggSplash.gui&#8221; and we&#8217;re ready to move onto the really tricky part.</p>
<p>Unfortunately for novice users, there will be some programming to complete in this part of the tutorial but don&#8217;t panic, I&#8217;ll try to walk you through it gently. First, let&#8217;s load the GUI into the games memory. In order to do this we need to change the code of the main game file which can be found in your game directory. The file is called &#8220;main.cs&#8221; but be careful &#8230; there are two of them. The first is in your root directory, for example if your game is called MyGame it&#8217;s found in a folder called &#8220;MyGame&#8221;, within that folder there is another folder named &#8220;game&#8221;, we want to open the game folder and then load the main.cs file. The best way to know that you&#8217;ve got the right one is to make sure your file has a function named <strong>initializeProject()</strong> near the top (by default it&#8217;s on line 10).</p>
<p>Now, in that file we need to add a special line of code to tell your game that you&#8217;ve create a new GUI interface. To do that, we must add an <em>exec</em> statement, this special statement tells your game to execute special code. To do this, let&#8217;s change our  initializeProject() function to look like this:</p>
<blockquote><p><em>function initializeProject()</em></p>
<p><em> </em><em>{</em></p>
<blockquote><p><em>// Load up the in game gui.</em></p>
<p><em>exec(&#8220;~/gui/mainScreen.gui&#8221;);</p>
<p></em><strong><em>exec(”~/gui/ggSplash.gui”);</em></strong></p>
<p><em> // Exec game scripts.</em></p>
<p><em> </em><em>exec(&#8220;./gameScripts/game.cs&#8221;);</em></p>
<p><em> // This is where the game starts. Right now, we are just starting the first level. You will</em></p>
<p><em>// want to expand this to load up a splash screen followed by a main menu depending on the</p>
<p>// specific needs of your game. Most likely, a menu button will start the actual game, which</p>
<p>// is where startGame should be called from.</p>
<p></em><em>startGame( expandFilename($Game::DefaultScene) );</em></p></blockquote>
<p><em>}</em></p></blockquote>
<p>You&#8217;ll notice that I only added one line to the code above, I&#8217;ve added <strong><em>exec(”~/gui/ggSplash.gui”);</em></strong> just below <em>exec(”~/gui/mainScreen.gui”);</em> what this is doing is really simple, it&#8217;s telling your game to load the mainScreen into memory and also to load the Garage Games Splash screen.</p>
<p>So now your game knows you have a new page but it&#8217;s going to need to know when to load it. To do this, I am going to replace the line <em>startGame( expandFilename($Game::DefaultScene) );</em> with the new line <em>loadSplashScreen();</em> which will now look like this:</p>
<blockquote>
<blockquote><p><em>function initializeProject()</em></p>
<p><em> </em><em>{</em></p>
<blockquote><p><em>// Load up the in game gui.</em></p>
<p><em>exec(&#8220;~/gui/mainScreen.gui&#8221;);</p>
<p></em><em>exec(”~/gui/ggSplash.gui”);</em></p>
<p><em> // Exec game scripts.</em></p>
<p><em> </em><em>exec(&#8220;./gameScripts/game.cs&#8221;);</em></p>
<p><em> // This is where the game starts. Right now, we are just starting the first level. You will</em></p>
<p><em>// want to expand this to load up a splash screen followed by a main menu depending on the</p>
<p>// specific needs of your game. Most likely, a menu button will start the actual game, which</p>
<p>// is where startGame should be called from.</p>
<p></em><em><strong>loadSplashScreen();</strong></em></p></blockquote>
<p><em>}</em></p></blockquote>
</blockquote>
<p>Once that&#8217;s done we need to create a new function for the code to call at startup. In programming a function is a little like a recipe, basically we can keep looking it up when we need it and it always does the same thing. The function that we need to create now will be called <em><strong>loadSplashScreen();</strong></em> and will load our splash screen. Here&#8217;s the code:</p>
<blockquote><p><em>function loadSplashScreen()</em></p>
<p><em> </em><em>{</em></p>
<blockquote><p><em>canvas.setContent(ggSplash);</em></p>
<p><em> </em><em>schedule(100,0,checkSplashTime);</em></p></blockquote>
<p><em>}</em></p>
<p><em>function checkSplashTime()</em></p>
<p><em> </em><em>{</em></p>
<blockquote><p><em>if (ggSplash.done)</em></p>
<p><em>startGame(expandFilename($Game::DefaultScene));</p>
<p>else</p>
<p></em><em>loadSplashScreen();</em></p></blockquote>
<p><em>}</em></p></blockquote>
<p>The second function is a helper for the first, what it&#8217;s doing here is setting the canvas (the screen) based on the values we laid out in the GUI Builder. Then, it&#8217;s checking every .1 second (100 milliseconds) to see if the process is done yet and if it is, it calls the default start screen for the game. Otherwise, it goes back and restarts the process of checking.</p>
<p>That&#8217;s it! That&#8217;s all there is to creating a splash screen in Torque Game Builder, not really complicated but a real pain for a novice coder. To give credit where credit is due, when I first started using TGB I used a great tutorial from http://www.videogamebiscuit.com to help me through some of the growing pains and most of my code above has evolved from there similar <a href="http://www.videogamebiscuit.com/2007/08/">tutorial</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.thisismyurl.com/tutorials/torque/creating-a-splash-screen-in-torque-game-builder/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
	</channel>
</rss>
