Help with scoring
by Joe Marty · in Torque X 2D · 11/25/2008 (1:54 pm) · 5 replies
I am working on a side scroller shooter for a class that I am in, and I have not been able to figure out a scoring system for it. I need something that can keep track of the score and also have a way to display the score on the screen.
I found this code in the SpaceWarrior Tuturial to keep track of hitpoints and I was hoping to find a way to change it to keep score but I was not able to do that.
public static void DamagingCollision(T2DSceneObject ourObject, T2DSceneObject theirObject, T2DCollisionInfo info, ref T2DResolveCollisionDelegate resolve, ref T2DCollisionMaterial physicsMaterial)
{
ShipControlsComponent victimControls = theirObject.Components.FindComponent();
if (victimControls != null)
{
victimControls.HitPoints--;
if (victimControls.HitPoints <= 0)
I am relatively new to using TorqueX and XNA so any help in figuring out how to change that code to keep track of score or if you know a different, better way to do it would be very much appreciated.
Thanks,
Joe Marty
I found this code in the SpaceWarrior Tuturial to keep track of hitpoints and I was hoping to find a way to change it to keep score but I was not able to do that.
public static void DamagingCollision(T2DSceneObject ourObject, T2DSceneObject theirObject, T2DCollisionInfo info, ref T2DResolveCollisionDelegate resolve, ref T2DCollisionMaterial physicsMaterial)
{
ShipControlsComponent victimControls = theirObject.Components.FindComponent
if (victimControls != null)
{
victimControls.HitPoints--;
if (victimControls.HitPoints <= 0)
I am relatively new to using TorqueX and XNA so any help in figuring out how to change that code to keep track of score or if you know a different, better way to do it would be very much appreciated.
Thanks,
Joe Marty
#2
12/15/2008 (10:26 am)
I'm also relatively new and would like some help with this. Are there any tutorials out there that may offer more insight?
#3
12/15/2008 (11:53 am)
I would highly recommend picking up John Kanalkis's book "The Complete Guide to Torque X" if you have not already. In the XNA ChopperStrike chapter, he covers another method for dealing with this and it is in general a must read , in my opinion, for anyone new to Torque X.
#4
12/16/2008 (7:34 pm)
Thanks David, I think I will do that.
#5
12/16/2008 (7:50 pm)
No problem :) As an update to my idea above, you could alternatively update the GUI control directly from your VictimControl when the hitpoints change, and bypass using a state machine. Just an idea.public static void DamagingCollision(T2DSceneObject ourObject, T2DSceneObject theirObject, T2DCollisionInfo info, ref T2DResolveCollisionDelegate resolve, ref T2DCollisionMaterial physicsMaterial)
{
ShipControlsComponent victimControls = theirObject.Components.FindComponent<ShipControlsComponent>();
if (victimControls != null)
{
victimControls.HitPoints--;
//Update Your Gui Control here
if (victimControls.HitPoints <= 0)
Torque Owner David Everhart
protected override void Update(GameTime gameTime) { base.Update(gameTime); if (victimControl.HitpointsChanged) { // Reset the Flag victimControl.HitpointsChanged = false; //Update your gui control UpdateScore(); } }Inside your Victim Control would be you HitpointsChanged Flag, which would be set to true whenever your victimControls.HitPoints changes. Just an idea.