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! / Sprite Priority and Tiles

Author
Message
Tribasic
20
Years of Service
User Offline
Joined: 10th Mar 2006
Location:
Posted: 1st May 2006 01:59
Hi,

I'm currently using Paste Image to draw my tiles to the screen. I'm using layers of tiles, so I can have my character appear behind certain tiles ie: walking under a bridge, or going inside a house etc.

But I don't really know how this can be done, because the sprites get drawn to the screen last, and appear over top of everything.

The only other thing I can think of doing is maybe use sprites as tiles instead of using paste image. But I'm not sure if thats a good idea. Or perhaps there is a better way for my to draw the sprites to the screen.

I was just curious how others solved this problem.

Thanks,

TriBasic
spooky
23
Years of Service
User Offline
Joined: 30th Aug 2002
Location: United Kingdom
Posted: 1st May 2006 03:14
It makes things much easier if you use PASTE IMAGE as you can draw each layer in turn, like you do now. Sprites are quicker to draw and you can use the sprite rotation and scale commands. What you need to play with is the SET SPRITE PRIORITY command and give each layer a different priority.

Boo!
Tribasic
20
Years of Service
User Offline
Joined: 10th Mar 2006
Location:
Posted: 1st May 2006 14:26
thanks Spooky,

So you are saying that I should use 'Paste Image' to draw my sprites on the screen? I gave it a quick try before I left for work this morning, and i was able to have my sprite image drawn between layers. So it seems to work.

My next question is, will this have any effect on collision detection? I think if my actual sprite is hidden, it will still be able to collide with other sprites, so I'm guessing that the collision detection will be fine.

Thanks for your help Spooky!

TriBasic

P.S. - I must say, the Darkbasic community is very helpful. I've learned so much from these forums during the past month that I've been here. I have very little programming experience, and I've already made myself a decent Tile editor, a basic 2D Shoot'em up engine and a few retro scrolling text demos with cool FX! This is so much fun!
Cash Curtis II
21
Years of Service
User Offline
Joined: 8th Apr 2005
Location: Corpus Christi Texas
Posted: 1st May 2006 16:43
'Paste Image' is a 2D operation and is slow. Sprites are 3D and very fast.

You should just cycle through your sprites in the order that you're going to layer them and set their priority 1 higher. The higher the priority, the higher the layer.

Quote: "My next question is, will this have any effect on collision detection? I think if my actual sprite is hidden, it will still be able to collide with other sprites, so I'm guessing that the collision detection will be fine."

Hidden sprites still collide. All you have to do is make sprite visibility a condition of collision. That is, for whatever condition you're going to perform, the sprite must collide and be visible.


Come see the WIP!
Pincho Paxton
23
Years of Service
User Offline
Joined: 8th Dec 2002
Location:
Posted: 2nd May 2006 00:17 Edited at: 2nd May 2006 00:18
You could use plains, and just control the z depth yourself. That's just an alternative idea that I am more used to.

Tribasic
20
Years of Service
User Offline
Joined: 10th Mar 2006
Location:
Posted: 2nd May 2006 03:48
I would like to thank everyone for their help! At the moment the easiest solution for me is to use PASTE SPRITE along with my hidden sprite. This way I seem to be able to keep my collisions, and control which layer of tiles the sprite gets drawn between.

But all of you guys have given me a few more things to think about , which is great! I love having lots options open to me when I'm programming.

Thanks!!!!

TriBasic

Login to post a reply

Server time is: 2026-07-04 13:25:51
Your offset time is: 2026-07-04 13:25:51