Gamestudio Links
Zorro Links
Newest Posts
loading historical data 1st time
by AndrewAMD. 04/14/23 12:54
Trade at bar open
by juanex. 04/13/23 19:43
Bug in Highpass2 filter
by rki. 04/13/23 09:54
Adding Limit Orders For IB
by scatters. 04/11/23 16:16
FisherN
by rki. 04/11/23 08:38
AUM Magazine
Latest Screens
SHADOW (2014)
DEAD TASTE
Tactics of World War I
Hecknex World
Who's Online Now
0 registered members (), 938 guests, and 4 spiders.
Key: Admin, Global Mod, Mod
Newest Members
rki, FranzIII, indonesiae, The_Judge, storrealba
18919 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
How do I scale A sprite to certain size? #146468
08/07/07 18:17
08/07/07 18:17
Joined: Nov 2006
Posts: 193
England
RyuShinji Offline OP
Member
RyuShinji  Offline OP
Member

Joined: Nov 2006
Posts: 193
England
How do i scale an sprite entity to i.e 800x600 regardless of its actual defult size?

Re: How do I scale A sprite to certain size? [Re: RyuShinji] #146469
08/07/07 18:47
08/07/07 18:47
Joined: Nov 2005
Posts: 1,007
jigalypuff Offline
Serious User
jigalypuff  Offline
Serious User

Joined: Nov 2005
Posts: 1,007
i think my.scale_x = 1 and my.scale_y = 1 is what your after play with the numbers to get the size you need


Why does everyone like dolphins? Never trust a species which smiles all the time!
Re: How do I scale A sprite to certain size? [Re: jigalypuff] #146470
08/07/07 19:06
08/07/07 19:06
Joined: Nov 2006
Posts: 193
England
RyuShinji Offline OP
Member
RyuShinji  Offline OP
Member

Joined: Nov 2006
Posts: 193
England
to do that i'd have to check the size in quants or somthing right?
im not sure how to do it

Re: How do I scale A sprite to certain size? [Re: RyuShinji] #146471
08/07/07 19:16
08/07/07 19:16
Joined: Oct 2004
Posts: 1,655
T
testDummy Offline
Serious User
testDummy  Offline
Serious User
T

Joined: Oct 2004
Posts: 1,655
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.





Moderated by  HeelX, Lukas, rayp, Rei_Ayanami, Superku, Tobias, TWO, VeT 

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1