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.

DarkBASIC Professional Discussion / Positioning a sprite utilising the sprite details

Author
Message
bodmcn
15
Years of Service
User Offline
Joined: 6th Oct 2010
Location:
Posted: 6th Oct 2010 12:10
I have been looking through the forum on positioning a sprite and have garnered that the SPRITE (or SPR Srite in eXtends) can be utilised to position the sprite, even though it is the same command to create it from an image.

However,

If you wish to use the details of the sprite, like it's height and width to determine the positioning it all seems to be a bit messy.

I am still not sure why the decision not to simply have a function to position a sprite has not been implemented, it would make things a lot more intuitive.

How do others utilise the details of the sprite when positioning it?
Sasuke
20
Years of Service
User Offline
Joined: 2nd Dec 2005
Location: Milton Keynes UK
Posted: 6th Oct 2010 16:15 Edited at: 6th Oct 2010 16:16
I asked this question once cause the SPRITE command doesn't just only position and create: Position Sprite

A dream is a fantasy, if you achieve that fantasy it was never a dream to begin with.
Grog Grueslayer
Valued Member
21
Years of Service
User Offline
Joined: 30th May 2005
Playing: Green Hell
Posted: 7th Oct 2010 02:57
Most of us use arrays to store the coordinates of each sprite to make them easier to position. The SPRITE command does allow us to change the image used for that SPRITE at any time so we can do manual animation. It really would be a pain if the SPRITE command only created the sprite and position sprite had to be used to position it.

Sasuke
20
Years of Service
User Offline
Joined: 2nd Dec 2005
Location: Milton Keynes UK
Posted: 7th Oct 2010 04:02
Quote: "The SPRITE command does allow us to change the image used for that SPRITE at any time so we can do manual animation."


So does 'Set Sprite Image'.

Quote: "It really would be a pain if the SPRITE command only created the sprite and position sprite had to be used to position it."


Then again, we do it with everything else, why not sprites.

In the link I posted, I made a valid reason why there should be a 'Position Sprite' command, because UV coordinates would get wiped if you wanted to position the sprite, so you'd have to update the UV's every time the sprite needed repositioning. The work around being 'Paste Sprite', but think, there should be no work arounds in your code.

A dream is a fantasy, if you achieve that fantasy it was never a dream to begin with.
bodmcn
15
Years of Service
User Offline
Joined: 6th Oct 2010
Location:
Posted: 7th Oct 2010 04:39
Appreciate the feedback.

Interestingly the eXtends SPR Sprite will create a sprite each time is called whereas the SPRITE command (seems to) update the same sprite.

The finnicky bit with the encapsulated command is that if you want to centre a sprite, you first have to create it from an image with the SPRITE command with arbitary positioning then utilise the sprite value number in SPRITE WIDTH and SPRITE HEIGHT to get the centering values.

It would certainly be more intuitive to have a create command and a positioning as both are autonomous sets of functionality.
Sasuke
20
Years of Service
User Offline
Joined: 2nd Dec 2005
Location: Milton Keynes UK
Posted: 7th Oct 2010 05:24 Edited at: 7th Oct 2010 05:25
As for centring a sprite, you can use OFFSET SPRITE to offest the centre point of the sprite. Also helps if you want to rotate round the centre of the sprite. Example:



A dream is a fantasy, if you achieve that fantasy it was never a dream to begin with.
bodmcn
15
Years of Service
User Offline
Joined: 6th Oct 2010
Location:
Posted: 7th Oct 2010 05:29
I notice though that you are using IMAGE WIDTH and IMAGE HEIGHT to determine the mid-point of the SPRITE. Could this ever be different from scaling or something similar?

It really should be utilising SPRITE WIDTH and SPRITE HEIGHT as part of the SPRITE set of commands for consistency.
Grog Grueslayer
Valued Member
21
Years of Service
User Offline
Joined: 30th May 2005
Playing: Green Hell
Posted: 7th Oct 2010 09:11
Quote: "So does 'Set Sprite Image'."


True but it's easier with SPRITE because we can position it and switch images at the same time.

Quote: "In the link I posted, I made a valid reason why there should be a 'Position Sprite' command, because UV coordinates would get wiped if you wanted to position the sprite, so you'd have to update the UV's every time the sprite needed repositioning."


I think it'd be better to change the SPRITE command to retain the UV coordinates. But I'm not totally against having a position sprite command... I just don't want SPRITE to loose it's positioning ability. It would probably have to keep it's current syntax anyway for backwards compatibility.

Quote: "The work around being 'Paste Sprite', but think, there should be no work arounds in your code."


In a perfect world there shouldn't be workarounds.

Quote: "As for centring a sprite, you can use OFFSET SPRITE to offest the centre point of the sprite. Also helps if you want to rotate round the centre of the sprite. "


I wouldn't mind a center sprite command to do this automatically since we're constantly doing it using the sprites width and height /2. "center sprite 1" instead of "offset sprite 1,imgWidth*.5,imgHeight*.5". Of course keep OFFSET SPRITE for those unique occasions when you don't want the sprite to rotate at exactly center.

bodmcn
15
Years of Service
User Offline
Joined: 6th Oct 2010
Location:
Posted: 7th Oct 2010 11:06 Edited at: 7th Oct 2010 12:03
My previous post seems to have gone missing, so I'll try again...

EDIT: It has now come up...
Frank C
16
Years of Service
User Offline
Joined: 3rd Jul 2010
Location: Houston TX
Posted: 7th Oct 2010 14:26
Most of what your looking for is included in the Advanced Sprites Plugin
Quel
17
Years of Service
User Offline
Joined: 13th Mar 2009
Location:
Posted: 7th Oct 2010 16:18
Just use SPRITE with the coordinates you want to reposition it to, and write SPRITE IMAGE(sprite number) instead of image number. In case you are having problems figuring out what image is the actual sprite is using, i don't know i rushed over the thread in a few secs...

Login to post a reply

Server time is: 2026-07-22 03:51:14
Your offset time is: 2026-07-22 03:51:14