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 DBPro Corner / Odd sprite behavior

Author
Message
TCat87
17
Years of Service
User Offline
Joined: 27th Dec 2006
Location:
Posted: 6th Jan 2007 05:50
Using DBPro and I don't understand what I'm getting from rotate sprite and move sprite. I tried creating and moving a sprite and got what I expected. But when I tried rotating the sprite before moving it I got results I didn't expect. Except for right around north, the angle of movement and distance moved seems wrong. I expected 90 degree rotation to move west, 180 to move south, and 270 to move east. I expected all moves to be the same short distance. Here is the code and attached .bmp file for the sprite imageset image colorkey 255,255,255
`load image "C:\Documents and Settings\Tommy\My Documents\My Pictures\Test2.bmp",1
load image "C:\Documents and Settings\Tommy\My Documents\My Pictures\Test3.bmp",2
`sprite 1,100,100,1
sprite 2,40,10,2
sleep 500
rotate sprite 2,0 `north as expected
`rotate sprite 2,5 `northwest as expected
`rotate sprite 2,10 `west northwest, expected north northwest
`rotate sprite 2,15 `west southwest, expected north northwest
`rotate sprite 2,55 `west southwest, moves too far, expected northwest
`rotate sprite 2,75 `west southwest, moves too far, expected west northwest
`rotate sprite 2,90 `west as expected but moves to edge of screen
`rotate sprite 2,100 `west to very edge of screen
`rotate sprite 2,180 `disappears (has it moved west off screen?)
`rotate sprite 2,270 `disappears
`rotate sprite 2,300 `disappears
`rotate sprite 2,325 `north northeast, moves too far
`rotate sprite 2,340 `north northeast as expected
`rotate sprite 2,350 `north northeast as expected
move sprite 2,10
wait key
]
The results are noted in the comments. What am I doing wrong?

Attachments

Login to view attachments
Flashing Blade
21
Years of Service
User Offline
Joined: 19th Oct 2002
Location: United Kingdom
Posted: 6th Jan 2007 14:52
The rotation point(and positioning point) of your sprite is the top left corner. If you want to rotate around any other point then you must use OFFSET SPRITE()

Looks like you want to rotate around center so just put this line after you have created sprite 2:

OFFSET SPRITE(2,SPRITE WIDTH(2)/2,SPRITE HEIGHT(2)/2)


The word "Gullible" cannot be found in any English Dictionary.
TCat87
17
Years of Service
User Offline
Joined: 27th Dec 2006
Location:
Posted: 6th Jan 2007 16:19
Thanks Flashing Blade!

Login to post a reply

Server time is: 2024-09-25 15:25:12
Your offset time is: 2024-09-25 15:25:12