Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Newcomers AppGameKit Corner / Setting multiple spriteoffsets help please

Author
Message
dandrews
4
Years of Service
User Offline
Joined: 26th Jun 2020
Location:
Posted: 5th Sep 2022 18:55
I have a player and gun laser that I would like to rotate together without having to calculate multiple get angles. What's the best way to calculate spriteoffsets to match if they are at different positions on screen.? Thanks for any help
Virtual Nomad
Moderator
18
Years of Service
User Offline
Joined: 14th Dec 2005
Location: SF Bay Area, USA
Posted: 6th Sep 2022 01:25 Edited at: 6th Sep 2022 01:49
i think GetWorldXFromSprite() & GetWorldYFromSprite() are what you're looking for?

+ bonus Move() & Aim() Functions = Angle#stuffs are your friends


re-reading and "a player and gun laser that I would like to rotate together" = you want a FIXED gun that maintains the same angle as the player ship?

or, was i right that you want to rotate the player and have each gun maintain their relative positions ("offsets") ON the player ship when it moves/rotates?

Attachments

Login to view attachments
dandrews
4
Years of Service
User Offline
Joined: 26th Jun 2020
Location:
Posted: 6th Sep 2022 02:18 Edited at: 6th Sep 2022 02:54
thank you nomad, and i have the player and gun are actually one image. the laser is a separate image. i have the top half of the player rotating depending on the pointer position and would loke the laser to rotate with it but keep its same distance from the player top half. so in your example say i had a bullet i wanted to keep in position in front of the tank barrels ready to fire
Virtual Nomad
Moderator
18
Years of Service
User Offline
Joined: 14th Dec 2005
Location: SF Bay Area, USA
Posted: 6th Sep 2022 03:33 Edited at: 6th Sep 2022 03:44
so, i hear "distance" and "offsets" again and can only offer the same as above with Lasers now added to the ends of the guns and a re-write of the Move() function to emphasize the use of SIN/-COS * Distance# to maintain the player's "offset" from the center of the screen (a given pivot point)

SIN/COS(Angle#) was in the last code but not the focus):


otherwise, sorry if i'm being dense/not understanding. it's been a long day and this is my current best effort

ps: more angle/distance/offset stuff in the #LowRez source code offered HERE.
dandrews
4
Years of Service
User Offline
Joined: 26th Jun 2020
Location:
Posted: 6th Sep 2022 03:52 Edited at: 6th Sep 2022 04:52
thank you again i will study the code you provided but i have to admit the whole offset thing has always been a challenge for me. ive been teaching myself with no previous knowledge of coding. AppGameKit has certainly made it easier but i sometimes wish i had someone looking over my shoulder while i bang my head against my desk
i believe i have this correct

Login to post a reply

Server time is: 2024-11-23 09:29:07
Your offset time is: 2024-11-23 09:29:07