Game Development Community

Having Multiple Objects Give Multiple Combos Question (Solved)

by rennie moffat · in Torque Game Builder · 04/21/2011 (11:01 am) · 0 replies

EDIT: Solved.
I got it. Essentially just use the object ID.


Cheers.

///////////\\\\\\\\\\\\\

Hi there,
I am having a little trouble with programming a certain something. In my game, my player can shoot a projectile (objectProjectile). This objectProfjectile, on its journey into oblivion can collide with any number of bonus objects, each one above one (the first bonusObject that he hits) will be counted as a combo, thus exponentially increasing the value of the combo. This is easy enough for me to program. Simply do something like this...

function onLevelLoaded()
{
///variable used to count combos
$bonusComboNumberAt = 0;
}

function player::shootProjectile()
{
///$projectile.movingDownScreen
}

function bonusObject::onCollision()
{
if(%dstObject.class $= "projectileClass")
{
%srcObject.figureReward();
}

function bonusObject::figureReward(%this)
{
	if($bonusComboNumberAt == 0)
	{
		//Variable is the number of the projectile shot. 
///so if the 100th projectile shot is here, this marks the projectile as that. 
///...this is done so the computer knows that one projectile is responsible for whatever damage/bonus objects it collides with
		%this.projectileNumber = $ProjectileCount;
	}
	
	///Here I calculate the combination count
	$bonusComboNumberAt = $bonusComboNumberAt + 1;
if($bonusComboNumberAt == 2)
{
%this.setComboRewardAnimation("TwoTimesCombo");
}
if($bonusComboNumberAt == 3)
{
%this.setComboRewardAnimation("ThreeTimesCombo");
}
///etc etc etc	
 
///as the projectile hits a boundary the  $bonusComboNumberAt is set back to zero. Starting the process over, insuring one shot counts
}

The problem I am running into is if I shoot two or three projectiles in rapid succession so that there are a number of projectiles on screen at once. If projectile 1 hits a bonusObject, and then projectile 2 hits one, the count, currently goes to 2, but there is no combo as it was achieved ny two projectiles. How do I insure the bonusObject knows it is struck by a specific projectile, so it can know whether to count a combo and at what count?



Thanks for any help with this. I have been trying to figure it out, but am stumped.

About the author

My thanks to Garage Games and the Garage Games Community combined with owned determination I got one game up, Temple Racer and I am looking to build more interesting, fun games for the mass market of the iOS app store.