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 Discussion / How Do You Re-Order Sprites?

Author
Message
Libervurto
20
Years of Service
User Offline
Joined: 30th Jun 2006
Location: On Toast
Posted: 13th Jul 2007 16:14
A while back I was making a 2D gangster game (not the godfather) which displayed the gangsters, cars and shops etc in a front on view. I gave up the project when I found I couldn't change the drawing order of the sprites to the screen (you had guys in the background walking on top of those in front).
Is there a way to change the order?

I make music and art. Here is a sample of my art: done in Paint! It's all I have
Dark Dragon
19
Years of Service
User Offline
Joined: 22nd Jun 2007
Location: In the ring, Kickin\' *donkeybutt*.
Posted: 13th Jul 2007 16:15
I Think it has something to do with the backsave state....
Libervurto
20
Years of Service
User Offline
Joined: 30th Jun 2006
Location: On Toast
Posted: 13th Jul 2007 16:22
I didn't think of that, I'll give it a try.
Thanks

I make music and art. Here is a sample of my art: done in Paint! It's all I have
Dark Dragon
19
Years of Service
User Offline
Joined: 22nd Jun 2007
Location: In the ring, Kickin\' *donkeybutt*.
Posted: 13th Jul 2007 16:24
Sure thing, but if it does not work let me know.
Libervurto
20
Years of Service
User Offline
Joined: 30th Jun 2006
Location: On Toast
Posted: 13th Jul 2007 17:13 Edited at: 13th Jul 2007 17:14
No it didn't work
But I made this little pointless program with the backsave state.



I make music and art. Here is a sample of my art: done in Paint! It's all I have
Dark Dragon
19
Years of Service
User Offline
Joined: 22nd Jun 2007
Location: In the ring, Kickin\' *donkeybutt*.
Posted: 13th Jul 2007 17:15
you probly are gonna have to play with the transparency state to..
Libervurto
20
Years of Service
User Offline
Joined: 30th Jun 2006
Location: On Toast
Posted: 13th Jul 2007 17:16
that wont make any difference to the order they're drawn on screen though

I make music and art. Here is a sample of my art: done in Paint! It's all I have
Dark Dragon
19
Years of Service
User Offline
Joined: 22nd Jun 2007
Location: In the ring, Kickin\' *donkeybutt*.
Posted: 13th Jul 2007 17:22
Hmm...Don't know. I'll try some stuff and get back with you.
Comrade Robski
20
Years of Service
User Offline
Joined: 12th Sep 2005
Location:
Posted: 13th Jul 2007 18:11
Isn't it just based on the order you call each sprite using the SPRITE command? i.e. the sprites you call first will be at the 'bottom' of the pile.

I may be wrong, I can't test it at the moment...
Latch
19
Years of Service
User Offline
Joined: 23rd Jul 2006
Location:
Posted: 13th Jul 2007 19:11
@Comrade Robski
Quote: "Isn't it just based on the order you call each sprite using the SPRITE command?"

That's what I thought, but once the sprite is called, that's it's permanent priority - even if you delete it and recall it.
(on a side note - I modified the lightning texture you posted for one of the challenges into a function and use it to strike lightning periodically in the background of a 3d scene - it's pretty cool)

@Obese87
A while ago someone asked how to write text on a sprite. While this isn't "technically" possible without creating the sprite from an image with text already on it, I wrote some demo code to show how it could be done. After writing the code, I realized that the same method could be used to change sprite priority (which sprite is on top). Basically, you keep the sprites invisible, update their positions and then paste them. The last one pasted has top priority. You have to manage your screen clears and refreshes though - but this method will also increase performance because it takes less processing power to paste a sprite image than it does to constantly show a sprite. Because you update the hidden sprite position, you can still check for sprite collision. Here's an example:



Enjoy your day.
Comrade Robski
20
Years of Service
User Offline
Joined: 12th Sep 2005
Location:
Posted: 13th Jul 2007 19:38
Ahh yes, the PASTE SPRITE command. I've made literally 3 programs ever using sprites (all aborted attempts at DBC challenges).

@Latch: Glad you got some use out of the lightening. I'm going to try and incorporate it as a special effect in an RPG I'm working on. I'll try and get back to entering the DBC challenge again as well!
Libervurto
20
Years of Service
User Offline
Joined: 30th Jun 2006
Location: On Toast
Posted: 13th Jul 2007 20:54
@ Latch

Wow thanks a lot! I thought I was gonna have to write a function to substitute the position and image of every sprite on the screen according to it's height! (why I gave up lol)
Too bad that game is on my old computer, but this will come in very handy.

I make music and art. Here is a sample of my art: done in Paint! It's all I have
Freddix
AGK Developer
23
Years of Service
User Offline
Joined: 19th Sep 2002
Location: France
Posted: 14th Jul 2007 12:31
if you want to choose in which order sprites will be displayed on DarkBASIC v1, I did a small Include file with many functions to do that.
Jump here : http://cordierfr.free.fr/html/
(it's my very old website)
clic on DARKBASIC V1 and then on CODE SOURCE 2D
You'll see a 2D SPRITE LIBRARY

Gandalf said: "All we have to decide is what to do with the time that is given to us"
Odyssey-Creators - X-Quad Editor - 3DMapEditor
Freddix
AGK Developer
23
Years of Service
User Offline
Joined: 19th Sep 2002
Location: France
Posted: 14th Jul 2007 12:31 Edited at: 14th Jul 2007 12:32
EDIT : Removed
Why did the forum double post ?
Sorry.

The 2D SPRITE LIBRARY is free and support sprite priority

Gandalf said: "All we have to decide is what to do with the time that is given to us"
Odyssey-Creators - X-Quad Editor - 3DMapEditor
Libervurto
20
Years of Service
User Offline
Joined: 30th Jun 2006
Location: On Toast
Posted: 14th Jul 2007 15:28 Edited at: 14th Jul 2007 18:27
@ Freddix

Your programs look amazing and very useful, especially the magic-windows thats just the sort of thing I was thinking of making for my Godfather game, and now I don't have to do the legwork lol . I'll give you a mention for all the pieces of code that find it into my games (I'm sure there'll be many).
Thanks,

OBese

[EDIT]
Some of your grammar is incorrect (I know you are French). You seem to use "that" a lot when it should be "this", just remember "this" is something here, and "that" is something over there. Here is an example that I've corrected.

Quote: "File-crypter/uncrypter :
That set of functions can help you crypt/uncrypt your files.
Warning : That system crypt files but does not compress them !
"


Should be

Quote: "File-encryption/decryption :
This set of functions can help you encrypt/decrypt your files.
Warning : This system encrypts files but does not compress them!
"


If you need any help with English I'd be glad to help .

I am king of the noobs!
Freddix
AGK Developer
23
Years of Service
User Offline
Joined: 19th Sep 2002
Location: France
Posted: 15th Jul 2007 02:19
@OBese87 : Yes I know that my english speaking is far to be perfect :p.
The most important thing is that you can understand the meaning

Gandalf said: "All we have to decide is what to do with the time that is given to us"
Odyssey-Creators - X-Quad Editor - 3DMapEditor

Login to post a reply

Server time is: 2026-07-05 22:06:45
Your offset time is: 2026-07-05 22:06:45