Game Development Community

Ammo

by Robert Carroll · in Torque Game Builder · 09/24/2009 (8:57 pm) · 0 replies

Dose anyone know how I would get this to have ammo and display it in a text object? I got score but im not such a good programmer.
~~~~~~~~~~~~~~~~~~~~~~~
The Top has been Cut Out
~~~~~~~~~~~~~~~~~~~~~~~~
function MouseShootsBehavior::onBehaviorAdd(%this)
{
%this.owner.setUseMouseEvents(true);
}

function MouseShootsBehavior::onBehaviorRemove(%this)
{
}

// begin firing when mouse down
function MouseShootsBehavior::onMouseDown(%this, %modifier, %worldPos)
{
%this.fire(1);
}

// stop firing when mouse up
function MouseShootsBehavior::onMouseUp(%this, %modifier, %worldPos)
{
%this.fire(0);
}


function MouseShootsBehavior::fire(%this, %val)
{
if (%val == 0)
{
cancel(%this.fireSchedule);
return;
}

if (!isObject(%this.projectile))
return;

%projectile = %this.projectile.cloneWithBehaviors();

%projectile.setPosition(%this.owner.position);
%projectile.setRotation(%this.owner.rotation);
%projectile.setLinearVelocityPolar(%this.owner.rotation, %this.projectileSpeed);

// if fireRate < 0, then we want to fire once per mouse down.
if(%this.fireRate <= 0)
{
cancel(%this.fireSchedule);
return;
}