No More Errata!

Tom and I finished the last chapter (with coding) in the 2d Game Building for Teens book and didn’t find any further problems. Well, except that wherever you see $MeBatty replace it with $BattyPlayer.

After we got done we added a couple more things:

  • Tom added a second ghost so it’s a little harder.
  • We made it so Batty can fire to the left and to the right.

Later this weekend I’m planning on adding an effect of some kind for when Batty gets hit by the ghost, a limit on the lives Batty has, and a way to keep score of the number of ghosts Batty has killed.

And then it will almost be a “real” game! =:)

(Posted in: Torque Game Builder)

2D Game Building for Teens – Errata #4

There are not too many things wrong in chapter 8 of 2D Game Building for Teens — but the things that are wrong will keep your game from working.

First, on page 218 the line of code that looks like this:

function BattyPlayer::createDeathray()

…should look like this:

function BattyPlayer::createDeathray(%this)

If you don’t pass in a reference to $BattyPlayer your deathray will never show up. That code is also shown again on page 222 at the top.

At the top of page 219, as part of the playerDeathray::fire function, the lines of code should be like this:

        %this.setWorldLimit(kill,"-50 -30 40 30");
	%this.setLinearVelocityX(%this.missileSpeed);
	%this.setPositionX(%this.player.getPositionX()+4);
	%this.setPositionY(%this.player.getPositionY()+7);
	%this.setImageMap(deathrayImageMap);
	%this.setSize("8 4");//approximately half size of original graphic
	%this.setCollisionActive(true,true);
	%this.setCollisionPhysics(false,false);
	%this.setCollisionCallback(true);

Some of those lines are the same as in the book, I just pasted the entire chunk here to make it easy for you to grab the whole block.

I did make a couple changes, however.

The book uses %this.setPosition(%this.player.getPosition()) which is fine if you want to set the deathray to the same position as Batty — but the raygun is supposed to be shooting, not the bat. So I used setPositionX and setPositionY so I could add an offset for each and make it look like the deathray was actually coming from the gun.

The other change is in the setSize line – the book said to set the values at 83 and 38, but for me that made a HUGE deathray, the size of half the screen. The values shown above fixed things.

Why that kind of change, after all, we’re only trying to set the size of a known graphic?

I’ll explain why in another post here later. =:)

That code above is also shown on page 222 as part of the entire listing.

One more thing, as in previous chapters, $BattyPlayer is mistakenly referred to as $MeBatty in the code on page 220 — make sure wherever you see $MeBatty you change it to $BattyPlayer.

(Posted in: Torque Game Builder, TorqueScript)

Firing The Deathray

Looks like Tom and I *almost* have the problems whipped in the “deathray” chapter of the book. I have it working, but don’t want to post the fixes until after I understand *why* the changes work– because the problem isn’t just typos,it goes a little deeper than that.

The only things left we have to finish the book are making the ghosts explode and adding some sound.

After that the plan is to add a little more code to make the game more fun/challenging:

1. More than one ghost on screen at a time.
2. Ghosts come from both sides of the screen.
3. Score counts up when ghost is killed.

And maybe even a couple more things…we shall see.=:)

(Posted in: Miscellaneous)

More From the Batty Book

I finally got off the computer long enough to give Tom a shot at it a few days ago and he dove into the next chapter of 2D Game Building for Teens. In that chapter he gives Batty a raygun and can shoot the ghosts before they bump into him.

Well, that’s what’s supposed to happen, anyway. =:)

After fixing a few typos that Tom introduced I got the program to the point where I realized the code in that chapter wasn’t able to work right out of the book.

I’m going through it now and banging my head against things I just don’t know about in TorqueScript. I found one big problem fairly quickly, but the code still isn’t working, so now I’m down to looking at what should be happening rather than at the code itself.

Because I don’t even know if the logic is correct — I’d hate to be looking for typos when the problem is bigger than that.

More later when I have something positive to report…

Jay

(Posted in: Miscellaneous)

Creating A Splash Screen

Been scouring the web for information on building GUIs in Torque Game Builder and came across this tutorial for making a splash screen:

Creating A Splash Screen In TGB

It’s a very short and easy-to-understand tutorial, thanks to Christopher Ross.

I’m taking that tutorial as a launching point and doing more GUI stuff, with buttons, etc., and as soon as I have something figured out I’ll post it here.

(Posted in: Miscellaneous, Torque 2D, Torque Game Builder)

2D Game Building for Teens – Errata #3

Found a few problems in Chapter 7 of the book.

When you create the MeanBat object, step 9 on page 191 references a coin, but it means bat. But the big thing is they don’t tell you to check the Callback checkbox in the World Limits rollout.

Without that the enemy bats will just keep flying instead of turning around and wreaking havoc (which is what we want).

Code problems — the code on page 194 (and repeated on page 196) has three problems — all the same thing is wrong.

You’ll see reference to this in some of the lines:

%this.getRandom(%this.minSpeed, %this.maxSpeed)

That won’t work because there is no getRandom() function that’s part of the %this object — what should be there is this:

getRandom(%this.minSpeed, %this.maxSpeed)

That’s right, just knock off the %this. and you should be good. You’ll find that error in three different places in the code.

Also on those pages you’ll see a couple “case” statements, like this:

case "left"

You need to add a colon to the end of that:

case "left":

Do the same thing for the case “right” statement.

(Posted in: Miscellaneous)

Update to TGB/Jennings Glitch

In a previous post I talked about getting an Invalid Project Data error message — which had stopped us in our tracks. But I think I found a fix — and it has nothing to do with code!

We built the game initially in this location:

:Applications:TorqueGameBuilder:tgb:MyGame

It worked fine until we closed up shop one day and tried to reopen it later — that’s when we got the Invalid Project Data error message.

Tonight I moved the project folder to this location:

:Applications:TorqueGameBuilder:games:MyGame

Lo and behold, it works fine. Everything loads, the game runs fine, etc. Looks like we’re back in the saddle, yeehaw!

I guess I can understand TGB being picky about where things are, but since it worked correctly as we built the game, it seems like it should have worked once the game was reloaded, too.

But it’s working now, which is the main thing.

(Posted in: Miscellaneous, Torque 2D, Torque Game Builder)

Problems with 2D Game Building for Teens

Tom and I are posting problems and fixes to the code in this book as we come across them, but if we miss something, please leave a comment and let us know — we’ll add it to the list so people just getting into the book won’t have as hard a time.

Thanks!

(Posted in: Miscellaneous)

TGB Glitch? Or Jennings Glitch?

Tom and I are kind of stuck in our learning of Torque Game Builder. We’ve been going through the 2D Game Building for Teens book and after fixing the code mistakes things are fine.

Well, things were fine.

The problem we’re having now is launching the project — we’re getting an Invalid Project Data error.

None of the graphics show up, although they’re still in the project, just all blank.

I can change the path of the images in the datablocks.cs file and then the graphics show up when the project is loaded. But then when I try to play the level the graphics are blank.

So I can load the graphics when the datablocks.cs path is one way, and then see the graphics when I run the level when the path is the other way.

It’s the kind of thing that makes me think it’s TGB’s fault, but I can’t find anything “official” on the GarageGames site.

It’s kind of brought things to a halt for now — at least as far as finishing the sample game from the book.

(Posted in: Torque 2D, Torque Game Builder)

2D Game Building for Teens – Errata #2

Here’s another big problem from the book 2D Game Building for Teens. Yes, the code examples are in rotten shape but the book as a whole is a good intro to Torque Game Builder — just make sure you keep checking back here for the fixes. =;)

On pages 163 and 169 the book shows the code for player.cs — and besides the problem shown in Errata #1 on this site, there is a huge chunk of the code shown that shouldn’t be there.

Basically, these functions…

BattyPlayerUp()
BattyPlayerDown()
BattyPlayerLeft()
BattyPlayerRight()

…are duplicated.

The first set shouldn’t be there — just rip those four functions right out and you should be good to go.

(Posted in: Torque 2D, Torque Game Builder, TorqueScript)