Game Development Community

Egg Turret

by Joshua Reidland · in TGB Platformer Kit · 01/08/2009 (3:51 pm) · 7 replies

I am trying to combined the timer timerShootsadv.cs with the selfDestruct.cs so that the projectiles the egg turret shoots disappears after a certain period of time, anybody have any ideas?

#1
02/16/2009 (5:13 pm)
hmmm.... sounds interesting... but i was wondering to ask,if people still buy 2d games, they do right? the game "Braid" was amde by an INDIE company and now the guy owns a big gamedev bussiness, and that was just in 2008, so im guessing they can, but just asking...
#2
02/17/2009 (3:10 pm)
Well I am a die hard 2d game fan.... I want to eventually make games like bionic commando rearmed.
#3
02/17/2009 (3:12 pm)
oh i forgot to say i got the turret working, I will post a finished project eventually.
#4
02/17/2009 (5:36 pm)
i actually was going to post a solution to your problem but at the time i saw your post was in 08 so I didn't mention it. I had a similar problem myself and figured it out.
#5
02/20/2009 (2:14 pm)
Cool nice to see people in the community that are willing to share there findings, the way i fixed it was combined the timer shoots behavior and the world limit wrap behavior. And you can also use the spawn behavior. There are some things i cant get quite to work in the data blocks though... for example if you wanted to call a behavior
_Behavior2 = "DealsDamage"; and lets say you want to specify the damage ammount so it would be
_Behavior2 = "DealsDamage 10"; i cannot get it to work.


//here is the combined behaviors
//-----------------------------------------------------------------------------
// Torque Game Builder
// Copyright (C) GarageGames.com, Inc.
// Edited by Joshua Reidland
//-----------------------------------------------------------------------------

if (!isObject(TimerShootsBehavior))
{
%template = new BehaviorTemplate(TimerShootsBehavior);

%template.friendlyName = "Timer Shoots World Limit";
%template.behaviorType = "AI";
%template.description = "Set the object to shoot on a timer";

%template.addBehaviorField(projectile, "The projectile to clone and shoot", object, "", t2dSceneObject);
%template.addBehaviorField(fireRate, "The rate to fire shots (seconds)", float, "0.25");
%template.addBehaviorField(fireRateVariance, "The variance in the fire rate (seconds)", float, "0.2");
%template.addBehaviorField(projectileSpeed, "The speed of projectiles (world units per second)", float, "150");
}

function TimerShootsBehavior::onAddToScene(%this, %scenegraph)
{
%this.schedule(%this.fireRate, "fire");

}

function TimerShootsBehavior::fire(%this %limit)
{
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);
%projectile.worldLimitMode = "KILL";

%min = (%this.fireRate - %this.fireRateVariance) * 1000;
%max = (%this.fireRate + %this.fireRateVariance) * 1000;
%random = getRandom(%min, %max);
%this.schedule(%random, "fire");


switch$ (%limit)
{
case "left":
if (%this.owner.getLinearVelocityX() < 0)
%this.owner.setPositionX(getWord(%this.owner.getWorldLimit(), 3) - (%this.owner.getWidth() / 2));
case "right":
if (%this.owner.getLinearVelocityX() > 0)
%this.owner.setPositionX(getWord(%this.owner.getWorldLimit(), 1) + (%this.owner.getWidth() / 2));
case "top":
if (%this.owner.getLinearVelocityY() < 0)
%this.owner.setPositionY(getWord(%this.owner.getWorldLimit(), 4) - (%this.owner.getHeight() / 2));
case "bottom":
if (%this.owner.getLinearVelocityY() > 0)
%this.owner.setPositionY(getWord(%this.owner.getWorldLimit(), 2) + (%this.owner.getHeight() / 2));
}


}
#6
07/29/2009 (6:09 pm)
timerShootsadv.cs isn't mentioned anywhere else on the forum. Any idea where to get it? :)
#7
11/06/2009 (5:11 am)
You can get it I think from the TDN or the shooter game demo that comes with TGB.