Game Development Community

Synching A Game Score To Custom Imagery

by rennie moffat · in Torque Game Builder · 02/28/2010 (6:15 pm) · 7 replies

HI, I am aware of and indeed use the Astroids Score behaviors to help keep score in my game, however, I am wondering.. and there must be, but how would I get custom imagery to work. Meaning, I would use custom made images to represent points scored, not just text. So I would create them (30 points, 45 points, 68 points, etc, representing total points scored thus far).



I think I would need to equate a system very similar to the Astroids one, except that instead of calling new text objects, say 10 points, then + 10 points, then plus 30, I want to equate the score total to an image so that the score will appear as a custom design.


So I am thinking if the score needs to be 30 points I need it to call the image which represents 30 and so on. If anyone has any good approaches to this I would love to hear it.


Thanks,
Ren

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.


#1
02/28/2010 (9:54 pm)
It sounds like you want are bitmap fonts.

I've never used the resource, but it sounds like people are making good use of it:
www.torquepowered.com/community/resources/view/13348
#2
02/28/2010 (10:41 pm)
Thanks William.
About to pass out but is this saying essentially any font I have available to me i can plug into TGB and it will work at live speeds just as it does now with say helvetica plus the crappy pixilation I was seeing today?



#3
02/28/2010 (11:35 pm)
To de-pixelate the text, throw the following code somewhere in your scripts:

function t2dTextObject::onLevelLoaded( %this )
{
  setProperFontSize( %this );
}

function setProperFontSize( %field )
{
  %screenHeight = getWord( sceneWindow2D.getExtent(), 1 );
  %cameraHeight = getWord( sceneWindow2D.getCurrentCameraSize(), 1 );
  %characterHeight = %field.lineHeight;
  %field.removeAllFontSizes();
  %field.addAutoFontSize( %screenHeight, %cameraHeight, %characterHeight );
}

It's not perfect, but I find that it works pretty well.

(Just to note: the text in the TGB editor will still look bad, but once the game runs, it'll look much better.)
#4
03/01/2010 (5:32 am)
great thanks William.

One question tho, and this goes back to by newbish coding expertise.

function t2dTextObject::onLevelLoaded( %this )  
{  
  setProperFontSize( %this );  
}

why is this not like this?
function t2dTextObject::onLevelLoaded( %this )  
{  
  %this.setProperFontSize();  
}




also, if I wanted, assigning something like
when score is 30 points total ($currentScore = 30) to call image30?



just a thought, as I am looking at all possibilities currently.
#5
03/01/2010 (2:09 pm)
just make a sprite sheet of 0-9 and a mount point on each single number to mounte the next....... theres your score in custom numbers oops put all 9 off to the side and just copy them .. works easy place them like -30000 clone and attach to ur score... do the mount points visually in the editor make them pngs!
#6
03/01/2010 (4:10 pm)
It should be fairly obvious why you wouldn't want to make an image per score. If you game could run into the millions, you'd need to make a million images.

I'd say that showing text (which score is just text) falls into 3 categories. First, use GUIs (not TGB). Second, use the t2dTextObject. Third, use t2dStaticSprites.

1. GUIs. Without a lot of extra coding, GUIs will not scale with the size of the screen. Sometimes, this is preferred. You may have played games where you increased the resolution and the text got proportionally smaller, making more room for the "meat" of the game. This is sometimes used in FPS and RTS, but usually not casual games.

2. t2dTextObject. A common and very easy way. You drop the t2dTextObject in, drop my code in somewhere, and you've got text that can be easily updated: every time the score changes, simply put "ScoreTextObject.Text = $currentScore;" or whatever is appropriate.

3. t2dStaticSprites. First you create your numbers in a paint program (typically going from 0 to 9). In the Builder, you add (say) 6 sprites for scores from 0 to 999999. You have to give each digit a different name (I'll use Digit100000, Digit10000, Digit1000, Digit100, Digit10, Digit1). Then whenever your score changes, you update the digits. This requires string or number manipulation and isn't that hard. This method is also very flexible as each digit can be moved independently of each other.

I would say that while prototyping a game, using Option #2 is the quickest and easiest. When your game is nearing completion, you might switch to Option #3.
#7
03/01/2010 (4:15 pm)
The code for de-blurring text is very old. I wrote it once and left it alone. The code has been separated out because I have custom code which allows for the screen to resize. Therefore, this code is also called from "t2dTextObject::onResize".

This code could be updated to become:
function t2dTextObject::onLevelLoaded( %this )
{
  %this.setProperFontSize();
}

function t2dTextObject::setProperFontSize( %this )
{
  %screenHeight = getWord( sceneWindow2D.getExtent(), 1 );
  %cameraHeight = getWord( sceneWindow2D.getCurrentCameraSize(), 1 );
  %characterHeight = %this.lineHeight;
  %this.removeAllFontSizes();
  %this.addAutoFontSize( %screenHeight, %cameraHeight, %characterHeight );
}

But I just have all of my resize code in a single file and I just drop it into a new project. I haven't updated it in years.