Game Development Community

Does this sound logical

by Peter Dwyer · in Torque Game Builder · 02/26/2005 (1:48 pm) · 10 replies

Hi all

If this sounds completely insane then please let me know as I'm running on zero caffine at the moment.

I'm setting up a simple indexing system to do my bitmap font stuff (until Melv has some time to implement them or some image based font stuff in T2D). Anyway, what I have done is use the int value of the character as an index into the tiles that represent the font.

This seemed like a simple and quick way to do things but, am I missing some functionality that is already there for this?

At the moment it just sounds too obvious to me. I guess I'm trying to over think this.

edit : So with a bit of simple math my lowercase a becomes frame 0 in the font. Seems to do what I want so I guess the silence means I'm not going insane and it is this easy :o) cool

#1
02/26/2005 (2:04 pm)
I think I can provide a bit of help on that... since I used a Bitmap Font for the scores in Pong.

torque.feylab.com/images/score.png

datablock fxImageMapDatablock2D(scoreMap)
{
	mode = cell;
	cellWidth = 40;
	cellHeight = 50;
	imageCount = 10;		
	textureName = "~/client/images/score";
};

The score font is 400 pixels wide by 50 pixels tall each number is 40 pixels wide x 50 pixels tall for a total of 10 images... numbers 0 - 9. You can have multiple rows.


Setup a staticSprite

%score = new fxStaticSprite2D(p1Score1) { scenegraph = $pongSceneGraph2D; };
	%score.setPosition( "-17 -30" );
	%score.setSize("5 5");
	%score.setGroup( 1 );
	%score.setLayer( 2 );
	%score.setImageMap( scoreMap, 0 );

And to reference the score

p1Score1.setImageMap( scoreMap, %index );

The index will be from 0-9
#2
02/26/2005 (2:06 pm)
Thanks Harold.

Not sure why this sounded so strage to me when I thought of it. I guess after all the 3D math, the simple stuff just sounds too simple..meh go figure
#3
02/27/2005 (12:34 pm)
Pete, to me that's sort of like when you are really thinking hard about code and you notice a word and wonder why it's spelled like that. It's like your brain is trying to get a rest from the task at hand by questioning why some word looks either weird or spelled incorrectly.

At least that's what happens to me

Anyone else?
#4
03/06/2005 (11:18 am)
P1Score1.setImageMap( scoreMap, %index );

Is this common in torquescript? Or will a getImageMap be implemented in the future?

I guess I could write my own class to return setImageMap(scoreMap, %index)

LOL
#5
03/06/2005 (11:27 am)
A little confused here. ;)

What would you want getImageMap() to return?

- Melv.
#6
03/06/2005 (2:00 pm)
@Melv

I think the setImageMap name is the confusion. Especially as in this context it is actually setting a single sprite image. Shouldn't it be sprite.setImage as setImageMap implies you are setting a series of images. Then you have the index parameter and the brain thinks "Set an image map....so what the frack is the index for?!??"

I always think of it as set image from imagemap as this is more logical to me.....or maybe I just have an over complex mind
#7
03/06/2005 (2:50 pm)
Yes, I see what you mean now. Come to think of it, now that you've said that, I feel that its confusing too. Damn you!!!! ;)

Not sure if its too late to change such a wide-spread function. Maybe an overloaded one could be used. We'll see.

Thanks for bring that up though.

- Melv.
#8
03/09/2005 (4:31 am)
I'm doing pretty much exactly the same in my pong game, although my font doesn't look as good :P I've just used system font to get it done quick, might steal your font png from your pong game if you have no objections Harold?

I had tried extracting the font using KEY mode with a purple border around each of the fonts, but for some reason I couldn't get this to work. So I've changed it to cell mode since all the fonts are the same dimentions.

I thought of setImageMap as setting the map, with the index been the default frame it uses from the image map. Then using setFrame from then on to change the frame, so you can forget all about what map your really using.
#9
03/09/2005 (4:45 am)
@Gary: Yes, that's why I put the "setFrame()" in there, so you can just forget the details of which imageMap. :)

ImageMap stuff will get much easier to use in the future, especially where animations and hardware constraints are concerned.

Good Luck,

- Melv.
#10
03/09/2005 (11:42 am)
Gary... Go ahead and use it if you want.

As for why I didn't use setFrame.... well I didn't exactly RTFM when I wrote the pong game.... and it was pretty much completed the night T2D was released. :)

I'm tweaking the Pong game still, so I'll probably change the score function to use setFrame()