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.

2D All the way! / Quick Rotation Problem

Author
Message
qwerty michael 007
14
Years of Service
User Offline
Joined: 21st Feb 2010
Location:
Posted: 4th Mar 2010 04:25
hello i am making a spacy sort of game and i have a very simple rotation problem here is the code::

/*pos[0] = X,pos[1] = Y,Speed = 5*/

if(::dbUpKey())
{
pos[1] -= Speed;
dbRotateSprite(2,0);
}
else if (::dbDownKey())
{
pos[1] +=Speed;
dbRotateSprite(2,180);
}
if (::dbLeftKey())
{
pos[0] -=Speed;
dbRotateSprite(2,270);
}
else if (::dbRightKey())
{
pos[0] +=Speed;
dbRotateSprite(2,90);
}

when the function rotates it pivots on the top left corner which is 0,0 can i set the point of rotation to the center of the image so it dosen't noticeably skip over a huge area every time it rotates?
Muddledde
14
Years of Service
User Offline
Joined: 13th Mar 2010
Location:
Posted: 14th Mar 2010 04:44
Oh! I'm excited because I can actually answer this for you! Just figured it out myself. I will throw down some code for you.

dbOffsetSprite(1,24,23);

The second and third numbers will offset the "center" of the sprite by x and y amount. You may have to change the numbers to fit your sprite specifically. Note: They are accepted as integers and your sprite still may not line up correctly when turning (you may have to change the sprite itself some).

Login to post a reply

Server time is: 2024-04-18 07:03:45
Your offset time is: 2024-04-18 07:03:45