Math problem (Solved)

Posted by Mordi on June 24, 2010, 11:17 a.m.

I am trying to draw a mini-map onto the HUD, but I am unable to figure out how to calculate the size of minimap so that it fits within the HUD-elements.

Here is a picture to illustrate:

View image

I want the height of the mini-map to be about 68 pixels, but the width doesn't matter that much.

The size of the level can be just about anything.

Can anyone help me out?

Comments

Juju 14 years, 5 months ago

minimap_height = 68

ratio = minimap_height/room_height

minimap_width = ratio*room_width

And to draw onto the minimap:

minimap_x = ratio*x

minimap_y = ratio*y

Mordi 14 years, 5 months ago

This does not work. Am I doing it right?:

mSc = 68/hh;

m_w = mSc*ww;

m_h = 68;

/////////

mSc is ratio

m_w is minimap width

m_h is minimap height

ww and hh are room width and height

And the map is drawn by doing like so:

x*mSc;

Juju 14 years, 5 months ago

That should be working. Check for nuances in how you're using views.

Another solution is to draw pixels to a surface and then scale that surface down.

sirxemic 14 years, 5 months ago

Quote:
This does not work
Then what do you see?

Mordi 14 years, 5 months ago

Nevermind, guys. I got help from Brod @ GMC.

GMC: 1

64: 0

:p

Scott_AW 14 years, 5 months ago

Ouch.

sirxemic 14 years, 5 months ago

I am very sure what juju said works, and that you implemented it incorrectly. So

Mordi: -1 =P

I am curious what solution the gmc gave you.

EDIT: I saw that the gmc gave the exact same solution! So 64d wins for providing it first. >:(

Mordi 14 years, 5 months ago

I guess we're all losers, then! :C

Juju 14 years, 5 months ago

I, for one, am not shamed.

Acid 14 years, 5 months ago

Nor should you be.