Game Development Community

Two things I'd like to make sure

by game4Rest · in Torque Game Builder · 01/19/2006 (11:32 pm) · 5 replies

After tring to find the definition of SPEED and SIZE of T2D in vain, I choose to ask here.

When we make maps, we set the tile size by input the number like "4 4", "8 8". I can not figure out what it
exactly means.

Let's suppose I made a map with a 64*64(Pixels) grass tile. If I set the tile size "4 4", the tile seems almost same to original one in size when I load up that .map file. So, I can guess if I set the size by "8 8", the out put will be doubled. But I would like to know the exact meaning.

And one more... We usually set the speed like this way.

$player.setLinearVelocityX($runSpeed);

I would like to know the exact meaning of the speed of $runSpeed. Is it "moving distance by Pixels per milli second" or "moving distance by mm per second"?

As I don't the exact definition of those two, I've been meeting unexpected problem with my output.
So please someone give me an advice.

Thanks in advance.

Hong Jin

#1
01/20/2006 (12:48 am)
The logical units of size is the world-unit. All speeds in T2D are in world-units/sec.

What you see on the screen is related to what you tell your camera to view. If you want a world-unit to equal one pixel (and assuming the t2dSceneWindow occupies the whole canvas) then you need to match the camera-view area to the resolution; this gives a 1:1 relationship of pixels->world-units. This is obviously simple to achieve. The default is 100x75. On a 800x600 resolution, just set this to 800x600.

Irrelevant of what you see on the screen though, if you have a tile that is 8 world-units wide, an object that's travelling past it at 8 world-units/sec takes ... what for it ... one second. :)

Make sense?

- Melv.
#2
01/20/2006 (4:03 am)
Dear Melv,
Thanks a lot for your answer.

But I'm afraid I'm not familiar with the notion "world unit". But after a struggling with it, I'd like to ask you if it will be OK for me to conclude like this.

"A world unit is equal to a pixel on a certain resolution. But by the camera area it can be seen larger or smaller accordingly. When the camera view area equals to the resolution, a world unit will be equal to a pixel on that resolution."

If above is right, I think it is clear.

Hong Jin
#3
01/20/2006 (5:38 am)
Quote:A world unit is equal to a pixel on a certain resolution. But by the camera area it can be seen larger or smaller accordingly. When the camera view area equals to the resolution, a world unit will be equal to a pixel on that resolution.

Essentially, yes. A T2D world-unit isn't directly related to any "real" world-unit, it's just a logical-space. This is the same as pretty much any engine that has a logical coordinate system.

If you want a 1:1 relationship in all resolutions, you can simply change the camera-view dynamically using the t2dSceneWindow callback "onExtentChange()". In this callback you can set the camera-view to the resolution selected. Of course, when I say resolution selected, I actually mean the window size as the users resolution isn't relevant when you're not working in full-screen mode. Using the above callback you can easily enforce a 1:1 relationship or any other that you care to select.

Here's some links related to using the "onExtentChange()":

Link#1
Link#2
Link#3

Hope this helps,

- Melv.
#4
01/21/2006 (3:58 am)
I got much help from the above links.

Thanks alot.

Hong Jin
#5
01/22/2006 (1:48 am)
You are most welcome.

Good luck with your project.

- Melv.