Posted By: 3run
Proper gun positioning - 12/08/17 19:46
I'm trying to position weapon correctly on the screen, so changing resolution won't actually affect it's appearance. I remember MasterQ32 recommended me to use rel_for_screen, but after I've struggled for a while (I couldn't get it working) he helped me out and made an example, and it worked like a charm! But back then I didn't really get/find any differences to my original code that didn't work Unfortunately I lost some data from my laptop which I was using back then, so I have to make things from scratch.
Idea (if I got it correctly) is to find center of the X coordinates on the screen (screen_size.x / 2) and the lowest Y coordinate of the screen (screen_size.y) and then convert it into the world XYZ coordinates (that's what rel_for_screen does, right? same as vec_for_screen but without views angle and position, for my purpose it's probably even better to use vec_for_screen, cause it's not a view entity but a world one).
Here is how I do that:
But the tricky part here is to position the weapon sprite (yes, I use sprites) correctly. The one I use has it's size 256x256. How do I place it correctly, can any one give me a hint, please?
Best regards.
Idea (if I got it correctly) is to find center of the X coordinates on the screen (screen_size.x / 2) and the lowest Y coordinate of the screen (screen_size.y) and then convert it into the world XYZ coordinates (that's what rel_for_screen does, right? same as vec_for_screen but without views angle and position, for my purpose it's probably even better to use vec_for_screen, cause it's not a view entity but a world one).
Here is how I do that:
Code:
VECTOR pos; vec_set(&pos, vector(screen_size.x / 2, screen_size.y, 4)); // 4 vec_for_screen(&pos, camera);
But the tricky part here is to position the weapon sprite (yes, I use sprites) correctly. The one I use has it's size 256x256. How do I place it correctly, can any one give me a hint, please?
Best regards.