Gamestudio Links
Zorro Links
Newest Posts
Zorro 2.70
by jcl. 09/29/25 09:24
optimize global parameters SOLVED
by dBc. 09/27/25 17:07
ZorroGPT
by TipmyPip. 09/27/25 10:05
assetHistory one candle shift
by jcl. 09/21/25 11:36
Plugins update
by Grant. 09/17/25 16:28
AUM Magazine
Latest Screens
Rocker`s Revenge
Stug 3 Stormartillery
Iljuschin 2
Galactic Strike X
Who's Online Now
3 registered members (NewbieZorro, TipmyPip, 1 invisible), 19,045 guests, and 8 spiders.
Key: Admin, Global Mod, Mod
Newest Members
krishna, DrissB, James168, Ed_Love, xtns
19168 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Screen aligned sprite #392127
01/19/12 15:40
01/19/12 15:40
Joined: Jan 2002
Posts: 4,225
Germany / Essen
Uhrwerk Offline OP
Expert
Uhrwerk  Offline OP
Expert

Joined: Jan 2002
Posts: 4,225
Germany / Essen
Hi everybody,

I have a small problem with aligning a sprite (view entity) exactly to the camera. At first I tried finding out the appropriate x value by manually setting them and then I adjusted the sprites scale_x value with screen_size.x / screen_size.y.

Now my problem is, that this works perfectly in windowed mode but fails in fullscreen mode for the same resolutions I used in the windowed mode. I have a 5:4 1280:1024 monitor. video_aspect is always 1.25. camera.arc is at its default value. camera.aspect is always 1. Which variable did I forget to check?

Or is there a formula that allows to calculate the correct x and y scale values for the sprite with respect to the selected resolution?


Always learn from history, to be sure you make the same mistakes again...
Re: Screen aligned sprite [Re: Uhrwerk] #392613
01/25/12 02:01
01/25/12 02:01
Joined: Jan 2002
Posts: 4,225
Germany / Essen
Uhrwerk Offline OP
Expert
Uhrwerk  Offline OP
Expert

Joined: Jan 2002
Posts: 4,225
Germany / Essen
Just in case anybody stumbles upon the same problem, this is the solution:
Code:
void align_sprite_to_screen(ENTITY* sprite)
{
	VECTOR v;
	v.x = v.y = 0;
	v.z = 512;
	rel_for_screen(&v,camera);
	BMAP* bmp = ent_getskin(sprite,0);
	sprite->scale_x = 2 * v.y / bmap_width(bmp);
	sprite->scale_y = 2 * v.z / bmap_height(bmp);
	sprite->x = v.x - 1;
}




Always learn from history, to be sure you make the same mistakes again...
Re: Screen aligned sprite [Re: Uhrwerk] #395656
02/26/12 06:30
02/26/12 06:30
Joined: Feb 2012
Posts: 9
E
Enix Offline
Newbie
Enix  Offline
Newbie
E

Joined: Feb 2012
Posts: 9
Thanks, it seems like something I`ll need cos it`s very limiting to have a game which looks good only in one resolution.


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

Gamestudio download | 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