ID:2846350
 
Problem description:

Hi there, I'm not really sure how to do this so I'm asking here. I know it'll get moved if it's in the wrong section lol.

I'm wondering how to scale larger icons in my game down as an overlay. This is because I have an examining system that adds the object as HUD overlay when you're scrolling over it. It works lovely, the only problem being when I introduce a larger icon, and then it distorts my screen (obviously because the icon is too big).

Summary:

Could someone explain how to scale these larger icons down as an overlay? I've seen this feature on Icon Ultima, when you use a massive icon and it gets made into a 32x32, this is essentially what I'm trying to achieve.

Thanks in advance, I'm aaaaalways looking for critisisms aswell if you want to try my WIP.
Love, Bumblemore
Hi! I know of 2 options for how to resolve this. The first is Scale() - this is a proc specifically for scaling icons. You give it an icon, tell it what size you want it to be and it'll scale it for you. The second the transform var which I find to be a bit messy but may work for your purposes. You can also combine Scale and transform. Additionally, transforms can be undone quite easily.

Here's a couple of test-verbs to demonstrate these for you:
mob
verb
Icon_Scale()
var/icon/I = new(icon) // copy the players icon into a variable
I.Scale(64,64) //make the icon 64x64
icon = I // replace the players icon with the new variable

Icon_Transform()
transform *= 2 //double the icon's size

Icon_ScaleTransform()
var/matrix/M = matrix() //to contain both scale numbers
M.Scale(2,2) //will multiply the height and width by 2
transform = M //apply the scale

Remove_Transform()
transform = null // if set to null, it resets the transform


If you want more options, I lifted most of this from the help menu (F1 - search: "icon object" for Scale, or "transform" for the variable)

I'm sure more experienced devs could come up with something else but hopefully this helps :)
Yeah dude I use the F1 reference all the time, it's my greatest teacher. Yeah dude I will try Scale and see if it works, I'll hit the post up in 24 hours or so and let you know how it went.