Warning: sprite scale may affect framerate
There may be precision problems.
Simple formula (pseudo-code):
scale_x = widthPx / bmap_width
scale_y = heightPx / bmap_height
Hypothetical code (untested):
Code:
bmap* im1_;
entity* e1;
/*******************************
spritefScalePx
_e: entity (or sprite) to scale
_im: bmap passed to ent_create for _e (sprite entity)
_widthPx: width in pixels to scale _e (sprite entity)
_heightPx: height in pixels to scale _e (sprite entity)
*******************************/
function spritefScalePx(_e, _im, _widthPx, _heightPx) {
if (_e == 0 || _im == 0 || _widthPx == 0 || _heightPx == 0) {
error("error: spritefScalePx(0 args)");
return(0);
}
e1 = _e;
im1_ = _im;
// this is the root of the function
e1.scale_x = _widthPx / bmap_width(im1_);
e1.scale_y = _heightPx / bmap_height(im1_);
return(1);
}
Quote:
One quant is one unit in WED and MED coordinates, and therefore one texture pixel at a 1.0 scale.