Game Development Community

TGB and Breakout Tutorial

by Wayne Prasek · in Torque Game Builder · 03/29/2009 (9:08 pm) · 6 replies

Hi all,

I'm new to TGB and have been evaluating it trying to decide if I'm going to purchase it. I've been having some issues with the breakout tutorial and I'm wondering if anyone has experienced the same problem.

I've gone through the entire tutorial and got everything working as described except for a couple bugs.

First, when I move my mouse quickly to the right I notice an obvious pause in the "base" (it stops moving for about 250ms). This behavior does NOT happen if I move the mouse to the left. Thats right... it only happens when I move the mouse to the RIGHT. I asked around in #garagegames and stumped everyone in there. Everyone I talked to was able to re-produce the same problem I'm having. Yes I have checked and double checked my mouse code and it is EXACTLY like the tutorial.

Second, the ball will randomly get stuck when it hits a wall. I have no idea whats causing this because the ball collision code I'm using is exactly the same as the tutorial.

Has anyone else experience similar problems with the tutorial?

Please help!!

About the author

Recent Threads


#1
03/30/2009 (12:08 am)
Wayne, I have the same problems with the mouse but have not found a workaround. As for the ball getting stuck you can use the same hack you use on the paddle, it will take care of the problem. This is my code that fixed it:

I created this function in my base.cs since there wasn't a better place to put it:

function wallClass::makeHittable(%this)
{
%this.setCollisionActive(0,1);
}

In your ball.cs onCollision function change your lines as followed starting with the else if:

} else if (%dstObject.class$="wallClass")
{
%dstObject.schedule(20,"makeHittable");
%dstObject.setCollisionActive(0,0);

alxPlay(wallhit);

$wallbang.setPosition(%points);
$wallbang.playEffect(false);
} else if (%dstObject == $thetileset)
{
//Add later if needed for the tiles to reset collision
%dstObject.schedule(20,"makeHittable");
%dstObject.setCollisionActive(0,0);

$wallbang.setPosition(%points);
$wallbang.playEffect(false);
$thetileset.hitTile(%dstRef,1.0);
}

Then finally I added this to my tiles.cs:

function tileClass::makeHittable(%this)
{
%this.setCollisionActive(0,1);
}

If you figure out the mouse problem let me know, would be nice to fix that. Would love to see this tutorial completed as well, it is so well written it is shame to see it just sitting there.
#2
03/30/2009 (6:06 am)
Thanks for the reply Pubily. The workaround for the stuck ball problem works :) It doesnt make sense why we require a workaround though. The walls dont move so should never move past the ball. I'm wondering if a bug report is in order.
#3
03/30/2009 (3:05 pm)
One or two bug reports are in order :)
#4
03/31/2009 (10:55 am)
After a little more debugging I've found what the "base" movement problem relates to. I did a little tweaking and found out that when I shut the world limits for the base off, it would freely move left or right when I moved the mouse (it would also go off the screen). I then turned the world limits back to "CLAMP" and started tweaking the numbers for the Y limits. This solved the problem but introduced another one. The base would slowly start drifting downward to the lower Y limit. I'm not sure what caused it but I think the ball would slowly push the base downward because of the constant downward force we put on the ball in the tutorial. I noticed that I had "send collision" and "send physics" checked for the base so I shut them off. The reason I did this was because the base wont be sending collisions (the ball does). This solved the problem entirely. The base now moves freely from left to right and stays within the limits I set.

As far as the ball getting stuck problem I think I may have found that solution also. In the file "ball.cs" in the "newBall" function replace this line:

CollisionActiveReceive = "1";

with

CollisionActiveReceive = "0";

The ball hasn't got stuck since I made this change.

Hope this helps.
#5
03/31/2009 (5:16 pm)
Apparently I lied... I've been testing and the ball just got stuck again. So much for the above "fix".
#6
05/31/2009 (2:16 pm)
thanks for sharing your findings, I was also wondering about ball getting stuck, if you have found something more please share here