P
PerilousProductions
Guest
Thanks for reading, the reason I need help today is because I am having issues working out the maths that would make a sprite fit in an inventory box, basically what I'm doing is making sure whatever items are drawn in the inventory is drawn at a scale required to fit in the box (128x128)
this is what I've got so far:
the reason I use draw_part_ext is because all the items have different offsets, as the offsets for the weapons are placed where a character holds them.
Has anybody got a better approach? I would just like to be able to require the ratio required based on the item being drawn compared to the box it has to fit in.
this is what I've got so far:
Code:
var spr=inv_db[ii,1];
var spr_ratio=2;
var spr_xOff=0;
var spr_yOff=0;
if sprite_get_width(spr)>sprite_get_height(spr){
spr_ratio=1/(sprite_get_width(spr)/64);
spr_yOff=32-spr_ratio*16;
}else{
spr_ratio=1/(sprite_get_height(spr)/64);
spr_xOff=32-spr_ratio*16;
}
draw_sprite_part_ext(spr,0,0,0,
sprite_get_width(spr),
sprite_get_height(spr),
iwo+inv_button_origin_xOffset+spr_xOff+((itemxx)*inv_button_spaceH-32),
iho+inv_button_origin_yOffset+spr_yOff+(itemOffset*inv_button_spaceV-32),
spr_ratio,spr_ratio,-1,1);
Has anybody got a better approach? I would just like to be able to require the ratio required based on the item being drawn compared to the box it has to fit in.