Game Development Community

Breakout-style game question

by Phillip Miner · in Game Design and Creative Issues · 03/11/2012 (9:51 am) · 1 replies

Hello all,

I'm attempting to build a Breakout-style game using the tutorial provided on the Torque Developer Network under the TGB section. (I'm using Torque Game Builder 1.7.5.) I'm attempting to make my own spin on it by having each color tile (e.g. red, blue, etc.) play its own unique sound when hit by the ball. Problem is, I'm no programming expert by any stretch, and thus I have no clue how to do it. :( I've experimented in a bunch of ways but nothing I know of seems to work, so it's probably something I don't know how to do yet...which is why I'm asking the community here if it's possible, and if so, how.

Thanks!

#1
03/16/2012 (5:34 pm)
Hey Phillip,

I'm more fluent in iT2D, but I think most of this will apply.

You are either going to want to set up each brick with a custom field, so you can do something like this: (assuming your have each color brick in its own class..)

if (%myBrick.color = "Red"}
{
   alxPlay(redSound);
}

In order to set the variables properly in iT2D, I modify the objects in the onAddToScene method:
function myRedBrickClass::onAddToScene(%this, %sceneGraph)  
{
 %this.color="Red";
}

You are going to probably want to handle this in the onCollision function kind of like this:

function myBallClass::onCollision(%theBall, %theThingIHit) //the default names have been changed for clarity.. if that makes sense
 if ( %theThingIHit.getClassName() $="myBrickClass")
{
  %myBrick = %theThingIHit;

      switch$(%myBrick.color)
      {
        case "Red":
        alxPlay(redSound);
        case "Yellow":
        alxPlay(yellowSound);
        case "Blue":
        alxPlay(blueSound);
      }

}

It took me a few weeks to discover all the places that contain documentation on torquescript. If you go through some of my older posts, you will find some tutorials, and link listings.

I'd also hop on the irc channel (server: irc.maxgaming.net room: #garagegames) sometimes there are discussions on iT2D, and of course the weekly community power hour is in there on fridays.

-Ray