# Question - IDELong term feature - Mapping a unit of measure to px

M

##### Guest
I looked around and didn't see this as a topic anywhere so hopefully it is okay to post it here:

Consider a top-down view situation where real world components are intended to be scaled. The size of a vehicle versus the size of the house where the car is pulling up to park. It can be difficult without a compass rose in GameMaker to provide a quick-check sense for real world dimensions. I find myself constantly doing math to scale items in regards to pixel size quite frequently.

Perhaps I am the only one that does this, but it seems that there are many projects I'm taking on where I have to map to real world coordinates, starting with a measure. How big is the pixel? Eventually I'm going to have to deal with the fact that things were initially drawn at improper scales in sprites as well.

Considering a project setting that allowed some group of sprites to report real world measures next to pixels would be fantastic. Once I calculate the scale and measure I want, then the reported size of my sprite canvas would accurately share that. If I import something, I can compare it against a frame of reference.

Suppose I want a user to feel the speed of a vehicle. Surely there is a medium between play-ability, feeling real, the mechanisms available by a developer to present to the user, and the interface created by the studio. Even with all of the variables involved, it would still feel more real, if 30 MPH at the scale of sprites in a game, felt like 30 MPH, a feeling to which most of us can relate. As I move at 30 MPH, how many pixels pass in a second. Surely this is up to the designer, but if you are going to scale and feeling for play-ability, you surely want something that feels right, and that means realism.

I'm basically building this system as I go along now, because I must have the ability to quickly translate acceleration of a missile in m/s to px/s. My structure is 250 feet by 250 feet. This house is on 3 acres.

No one can expect GM2 to be the interpreter of all measures. But giving us the option for 1 unit of measure. And then showing that in related rooms and sprites would be again, fantastic.

Also, consider an artist provides nice art, that is not to scale. I could determine what size I want for it during import by measuring against the compass rose sprite (let's say some car we know is 15 feet x 6 ft. then import (and tell GM2) to treat it appropriately.

GM2: Here is your compass rose sprite. It is AxB px and MxN [ft, m, cm, whatever].
GM2: Select sprite for import
GM2: Show compass rose and imported sprite next to each other.
Me: <Resize input sprite to match scale I believe is appropriate vs. my compass rose sprite> <Move a track bar or other dial>
GM2: <Tracks my scaling of the input sprite> Your input image would be MxN [ft, m, cm, whatever]
Me: <Checks definitive guide> That's the right size.
GM2: Do you want to resize the image as input? Yes / No
GM2: If No, do you want your scaling to be recorded for drawing? Yes / No

Such an option could also automatically handles scale defaults for the given asset for developers that rely on art from different artists. Now loading "sprite1" I would have 2 additional numbers in the left. Real world mapped width and height, and a textbox for Default Sprite Scale [ defaulting to 1.0 ] for non-imported sprites.

I know there are many impacts here, and keeping it to the simplest reporting would be easy to the user. Consider a second how this could impact any approach to fast prototyping of realistic scenarios.

What is the minimum number of pixels I can use to draw a missile? Looks good. Is this the scale I want for my entire production? Maybe not.

The further one gets into asset development the more expensive it gets to change or rework. Proper scale and intent by the developer for what is being presented seems to be pretty key, at least for my projects.

Current process: Today I have a notepad, and scale I've come up with. I want to draw a top-down helicopter. I calculate scale for the furthest, and closest distances of scale I would draw the sprite. Then determine if I'm going to have different sprites at different distances. Once I ascertain exactly how many assets I will have for this object. I then get out the notepad, use the mapping to determine the pixel sizes. This requires calculating pixels per measure of m (pixels per foot, meter, or what not). Then I create the sprites in GM with the relevant pixel sizes. I zoom in and out with a little bit of the asset quick-sketched; just to get a feel for it. If it's not so good, I rework the process as needed.

Potential new GM2 process: I create a compass rose sprite and set how big it is in whatever unit of m I want. This is done once for a project. GM2 determines that per m I have n pixels. Anytime I create a new sprite, I can enter in a measure of m, and it automatically updates the number of pixels.

I'm currently building a complete m to px system inline in the current feature I'm building, as I require the ability to query things in terms of m and have the px taking care of behind the scenes.

Thanks for taking the time to read through this post.

Drew

#### csanyk

##### Member
I would encourage you to program such calculations yourself.

In game development, it's rare that we pay slavish attention to simulating reality, so things like scale are rarely considered. What looks good and feels right often doesn't match well with real-world physics and proportions.

With low-res graphics, we typically take extensive liberties, making a 16x16 or 32x32 grid with iconified graphics which represent things of any and all sizes.

Really though it depends on what type of game you want to make. GMS doesn't stop you from performing these calculations yourself, or using it to build the tools that would allow you to do them. I get the feeling that this is something that few users would find useful, and it would be bothersome for the majority of users to have to ignore. So I don't think there's much chance of it being done as a built-in feature.

M