Game Development Community

adding a score counter? best practice.

by Jabari A Dumisani · in Torque X Platformer Kit · 02/25/2010 (6:35 pm) · 2 replies

hello, hope all are well. i was wondering has anyone added a score counter to the Platformer Kit? im trying to see where or how would i approach adding one, or altering the life counter to function if i wanted to add points values to the peppers instead of these going toward added lives? thanks for your time, have a great evening.

#1
03/04/2010 (5:15 pm)
hello all again. i would really appreciate any insight as to how this could be done. im wanting to add a score counter and a lives counter, but in trying to manipulate the peppercomponent or collectiblecomponent, this isnt working out and is very confusing. between the Game.cs, GUI.cs, and the others its becoming a chore rather than the assist i paid for. why isnt there a default ScoreComponent.cs included in the Platformer Kit in which on could just add values for the collectibles ive designed(say 20points for a gem, 100 points for a trinkette) and go from there? i hope this isnt because most platformers out now dont have a scoring element, im not trying to clone what already been done and i think this should be at the discretion of the Designer on its implementation.

if no one from the community can answer, then im appealing to anyone from GG can step in and assist.
#2
03/08/2010 (5:08 pm)
public class ScoreCounter
{

private int _score;

public Score 
{
 get { return _score }
 set { _score = value}
}

public ScoreCounter()
{
 _score = 0;
}

public void CalculateScoreIncrease( object to_pass_here )
{

if ( to_pass_here == [a certain thing] )
{
 this.Score += 10;
}
else if ( to_pass_here == [another thing] )
{
 this.Score += 20;
}

}

}

Just thinking out loud, but the above is a really really simple way of doing things - perhaps too simple. There is probably a better way, but I posted this to just give an idea of how to go about implementing this.

When your collectible components are confirming pickup, you can then call the CalculateScoreIncrease method, passing an identifier object (like a string, object type or something) to work out how to increment the score.

The score can then be fed to the user via the GUIText controls, such as the text for the lives.
Sorry if I've got the wrong idea here.