Game Development Community

The Adventures of TomFeni.. continued..

by Tom Feni · 01/16/2008 (6:25 pm) · 5 comments

So back to what I was talking about. :) Coding.. I started by picking up Ed Maurina's book about game programming. I started by using some of the various examples and changing them to suiit my needs and made new assets.
I added some danger by adding the cannon and flame trap, which worked ok but had some minor issues due to the player being so low to the ground.. I spent a few weeks on figuring out how to get the fire point to hit the player fairly consistently but still needs work(on my todo list :) For now I am using the simple kill trigger and using those at key areas of danger, ie steam from a pipe, and lava so on and so on..
I also added the door resource by Ramen Sama and changed the door models to gates and wooden doors and such. Worked good and all but the challenge was non existent. I needed locking doors.. Then I noticed the locking doors with keys that someone was kind to post in the door resource update I posted. I added that and added quite a few more key types.
I also added exploding boxes, ifl shapes, some animated shapes, and various items. Then I began work on the lives code, I needed to start with a set amount and on entering a kill trigger I wanted the player to lose a life. I scoured the site but didnt find a whole lot for tge but alot of things for TGB so I used the code from Ed's book for the lives. I then tied it into the guis and decided I wanted to have extra life pickups, but Ed didnt do that, his gets extra life on level finish. So I took the health pack code and changed it to suit my needs.

Extra Life code
datablock ItemData(lifeUp)
{
   // Mission editor category, this datablock will show up in the
   // specified category under the "shapes" root category.
   category = "Health";

   // Basic Item properties
   shapeFile = "~/data/shapes/lifeUp/lifeUp.dts";
   mass = 1;
   friction = 1;
   elasticity = 0.3;
   emap = true;

   // Dynamic properties defined by the scripts

   maxInventory = 1; // need this to activate the pickupName
   pickUpName = "an extra life";

   lightType = "constantLight";
   lightColor = "0.4 0.8 0.3 1.0";
   lightTime = "1000";
   lightRadius = "3";

};

function lifeUp::onPickup(%this, %obj, %user, %amount)
{

   // The parent Item method performs the actual pickup.

     if (Parent::onPickup(%this, %obj, %user, %amount)) {
         $Player::lives++;  // give the player one life
         serverPlay3D(LifeUpSound,%obj.getTransform());

         livescounter.setCounterValue($Player::lives);
          
}

Worked great but didnt have alot of flair so I added a particle effect to the pickup.
datablock ParticleData(lifePickup)
{
   textureName          = "~/data/shapes/particles/hearts";
   dragCoefficient     = 0.0;
   gravityCoefficient   = -0.2;   // rises slowly
   inheritedVelFactor   = 0.00;
   lifetimeMS           = 500;
   lifetimeVarianceMS   = 50;
   useInvAlpha = false;
   spinRandomMin = -60.0;
   spinRandomMax = 60.0;

   colors[0]     = "0.0 0.0 0.8 0.1";
   colors[1]     = "0.6 0.0 0.0 0.1";
   colors[2]     = "0.0 0.8 0.0 0.1";

   sizes[0]      = 0.1;
   sizes[1]      = 0.1;
   sizes[2]      = 0.1;

   times[0]      = 2.0;
   times[1]      = 2.5;
   times[2]      = 2.0;
};

datablock ParticleEmitterData(lifePickupEmitter)
{
   ejectionPeriodMS = 35;
   periodVarianceMS = 0;

   ejectionVelocity = 8.0;
   ejectionOffset   = 0.45;
   velocityVariance = 0.5;

   thetaMin         = 45.0;
   thetaMax         = 90.0;

   particles = lifePickup;
};

datablock ParticleEmitterNodeData(lifePickupEmitterNode)
{
   timeMultiple = 1.5;
};

function lifeUp::onPickup(%this, %obj, %user, %amount)
{

   ....
       %effect = new ParticleEmitterNode() {
             position  = vectorSub(%Obj.getWorldBoxCenter(), "0 0 1");
             rotation  = "1 0 0 0";
             scale     = "1 1 1";
             dataBlock = "lifePickupEmitterNode";
             emitter   = lifePickupEmitter;
             velocity  = "1";
             };

           %obj.myEffect = %effect;
           %obj.delete();

       if(isObject(%effect))
	       %effect.schedule(1500, "delete");

     }
}

Much neater just adding a particle texture. I then took that particle idea and added it to the egg pickup and to the key pickup. So now all the pickups for the most part have spiffy particles shoot up and then disappear after 1.5 seconds.
Then i took that idea and tried adding it to the exploding box so I could show players which box is destroyable. Which didnt work how I planned.
When I destroyed the box the particles stayed put and didnt leave..
function box1::onAdd(%this,%obj)
{
   box::onAdd();

   %effect = new ParticleEmitterNode() {
         position  = vectorSub(%obj.getWorldBoxCenter(), "0 0 -1");
         rotation  = "1 0 0 0";
         scale     = "1 1 1";
         dataBlock = "destroyNode";
         emitter   = destroyParticleEmitter;
         velocity  = "1";
      };

      %obj.myEffect = %effect;

}
So I tried
function box1::onRemove( %this, %Obj )
{
   // 1
   if( isObject( %Obj.myEffect ) )
      %Obj.myEffect.delete();
}
In onDestroyed. Didnt work so I went to onRemove and wham.. worked like a charm.. :)

So then i moved on to a simple save system :)
But I will talk about that next time : )

TomFeni

#1
01/17/2008 (12:05 am)
Cool! :) Is this going to be a kind of Post Mortem series? Looking for more snapshots of your journey.
#2
01/17/2008 (2:13 am)
Post mortem sort of.. I hope to finish the demo by the time I finish telling how I got to that point :)
Soo I will be spacing these out.. I also wanted to share some of the code and resources that I included along the way..


obligatory snapshot follows
home.comcast.net/~toons_project/blog/TobySS22.jpg
recent picture of the game

TomFeni
#3
01/17/2008 (9:26 am)
I like the style. Nice.
#4
01/17/2008 (10:03 am)
turtle power!
#5
01/18/2008 (8:48 am)
This looks like it will be a blast to play. Keep up the great work, and thank you for posting in such detail -- I have learned a lot because of it.

Take Care