Diballic Source
by Kevin James · in Torque Game Builder · 06/06/2008 (3:29 pm) · 5 replies
What's up!?
I recently released a pong like game to the Garage Games community at large. Now its time to release the source to the private TGB'ers here.
Floating squares:

The coolest features of diBALLic in my opinion are:
*The smart AI that calculates where the ball is going to go as soon as you hit it.
*Settings that are loaded from a text file and that can be changed by the user.
*Two smart AI's battling each other look pretty cool
The changeable settings:

I will be writing a tutorial on how to create this game. Don't ask me for a timeframe. ;)
I thought I'd distribute the source in order for some advanced TGB'ers to get a headstart.
DOWNLOAD: diBALLic SOURCE (5 megs)
I recently released a pong like game to the Garage Games community at large. Now its time to release the source to the private TGB'ers here.
Floating squares:

The coolest features of diBALLic in my opinion are:
*The smart AI that calculates where the ball is going to go as soon as you hit it.
*Settings that are loaded from a text file and that can be changed by the user.
*Two smart AI's battling each other look pretty cool
The changeable settings:

I will be writing a tutorial on how to create this game. Don't ask me for a timeframe. ;)
I thought I'd distribute the source in order for some advanced TGB'ers to get a headstart.
DOWNLOAD: diBALLic SOURCE (5 megs)
About the author
Hobbyist game developer -- free and open source games FTW.
#2
It may be better to use the %normal -- which could be used as a ratio between x and y. The problem may be that the corner velocity just isn't enough. Thus, check if the %normal isn't a horizontal or vertical, and if it isn't, double the polar velocity. I'll have to look into it.
06/07/2008 (6:54 pm)
Hmm. Interesting. I have had the ball's x velocity greatly reduced when the ball hits a corner before, but its always been still been definitely moving. Interesting solution though basically, as you said, it just makes sure that the ball's x velocity doesn't go to zero. I guess you didn't read the "dontreadme.doc" as it tells you the keys in there; "o" is a re-serve.It may be better to use the %normal -- which could be used as a ratio between x and y. The problem may be that the corner velocity just isn't enough. Thus, check if the %normal isn't a horizontal or vertical, and if it isn't, double the polar velocity. I'll have to look into it.
#3
08/29/2008 (5:12 am)
Kevin - did you yank this? Url doesn't work (404 error), here or non-source version on blog.
#4
08/29/2008 (2:31 pm)
Witchcraft!
#5
09/07/2008 (5:16 am)
It should work now.
Torque 3D Owner Thomas Huehn
I start playing and on first ball it go into an endless loop, while the ball LinearVelocityX was nearly 0. I restarted and when i nearly won it happend again. So i dig into the source and made following fix for this:
function ball::onCollision(%srcObject, %dstObject, %srcRef, %dstRef, %time, %normal, %contacts, %points) { if(%dstObject.getName() $= "blockOne" || %dstObject.getName() $= "blockTwo") { %srcObject.blockBounce(%dstObject, %dstObject.getName()); %srcObject.setPositionX(%srcObject.getPositionX() + (getWord(%normal, 0) / 4)); %srcObject.setPositionY(%srcObject.getPositionY() + (getWord(%normal, 1) / 4)); } if(%dstObject.class $= "boundary") { [b] //XXTH Test: playball.setLinearVelocityX(-0.001);playball.setLinearVelocityy(100); %xvelo=%srcObject.getLinearVelocityX(); if (mAbs(%xvelo)<0.01) { %fixVelo = mGetSign(%xvelo)*5; if (%fixVelo == 0) %fixVelo = 5; //maybe not correct direction but better than endless game. %srcObject.setLinearVelocityX(%fixVelo); } [/b] %srcObject.setPositionX(%srcObject.getPositionX() + (getWord(%normal, 0) / 4)); %srcObject.setPositionY(%srcObject.getPositionY() + (getWord(%normal, 1) / 4)); } //if(%dstObject.class $= "bottomBoundary") //%srcObject.setPositionY(%srcObject.getPositionY() - 0.5); }