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 / How to Make Text Overlap Sprites ?

Author
Message
Moaz
15
Years of Service
User Offline
Joined: 18th Jan 2011
Location:
Posted: 3rd Apr 2011 20:25
Hi
That's my question ...when trying to display text over a sprite the sprite overlaps it, I faced the similar problem once ago but i can't remember how i fixed it !
So.. any suggestions ?
baxslash
Valued Member
Bronze Codemaster
19
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 3rd Apr 2011 23:23
Have you tried putting the "text" command after the "paste sprite" command?

...or "Draw sprites first"?

Moaz
15
Years of Service
User Offline
Joined: 18th Jan 2011
Location:
Posted: 4th Apr 2011 02:01
Yep
Draw Sprites First Won't work because there's 3d rendering.
Agent
21
Years of Service
User Offline
Joined: 7th Sep 2004
Location: Sydney, Australia
Posted: 4th Apr 2011 02:06 Edited at: 4th Apr 2011 02:15
What I do is to create all my sprites, manipulate them with rotate, alpha, diffuse, scale, and whatever else I want done, then I use HIDE SPRITE on them and PASTE SPRITE them where I want them. Then I delete them entirely and move on to drawing my text and UI elements.

I don't think I ever leave sprites alive long enough to reach a SYNC command. They're always hidden or deleted before the SYNC rolls around, and they only display at all because I've PASTE SPRITE'd them. It doesn't cost substantial CPU time and allows you full and complete control over draw order.
Non Sequitur M
17
Years of Service
User Offline
Joined: 28th Oct 2008
Location: Where am I!? Where are YOU?
Posted: 4th Apr 2011 21:44
@Agent: That just seems really convoluted... It really depends upon the target pc's cpu power.

@Moaz: I use sprite based fonts. That way, you can control the style better. Also, you know the user's comp can display the fonts, because the file is easily distributed with your program file.

If life were like a box of chocolates, I'd know what I would get... The one that got dropped on the floor and put back in the box.

Iye nehvur yoose spehl chehk, ahn mie tippyng izz fiyne.
Green Gandalf
VIP Member
21
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 4th Apr 2011 22:19
Interesting question.

If the text can be confined to a small part of the screen then something like this might work:



You just need to set the sprite priority carefully if you're using many sprites.
Moaz
15
Years of Service
User Offline
Joined: 18th Jan 2011
Location:
Posted: 5th Apr 2011 00:56 Edited at: 5th Apr 2011 23:05
@Agent, Thanks but it's kind of confusing, but any ways it doesn't work.

@Amo Deus Man, well, thanks a lot, i'll be glad if you explain much further.

@Green Gandalf, your example works fine when there's a solid background, which is not in my case!

any ideas ?
Green Gandalf
VIP Member
21
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 5th Apr 2011 01:00
Quote: "your example works fine when there's a solid background, which not in my case!"


Not sure I understand what you mean.

Could you post a simple example illustrating the problem?
Non Sequitur M
17
Years of Service
User Offline
Joined: 28th Oct 2008
Location: Where am I!? Where are YOU?
Posted: 5th Apr 2011 03:41
@Moaz: Sure. A sprite based font is a font that uses the same image types as your other sprites, instead of the regular .ttf-or True Type Font-file used by Windows, or equivalent files on Mac. I prefer to use .png, as it stores alpha values for transparencies efficiently. You save each letter as it's own image, and load sprites based on the text being outputted to the screen. That's great for game text, or dialogue.

Now, if you want simple text for debugging or such... I can't help, as I could never figure out how to get text from the commands to appear above sprites either...

If life were like a box of chocolates, I'd know what I would get... The one that got dropped on the floor and put back in the box.

Iye nehvur yoose spehl chehk, ahn mie tippyng izz fiyne.
Grog Grueslayer
Valued Member
21
Years of Service
User Offline
Joined: 30th May 2005
Playing: Green Hell
Posted: 5th Apr 2011 09:57 Edited at: 5th Apr 2011 10:00
The easiest way is done the way Baxslash and Agent describe but without deleting the sprites before SYNC (Agents method). It's easier to reuse sprites rather than recreating them every loop.

1. Create the sprite
2. Hide the sprite
3. Paste the sprite
4. Write text over the pasted sprite
5. Go to step 3

Think of sprites as something that hovers over the screen. If you place a sprite it'll block the view of the screen below it. So if you write text in the same spot the sprite is you won't see it because the sprite is blocking the view. HIDE SPRITE allows you to have the sprite wherever you want it (on the screen or off) and not see it so you can view the screen under the sprite. PASTE SPRITE is like a stamp... it stamps the screen with whatever the sprite looks like. If you write text after PASTE SPRITE it'll be over the pasted sprite.



Moaz
15
Years of Service
User Offline
Joined: 18th Jan 2011
Location:
Posted: 5th Apr 2011 17:13
@Amo Deus Man : SO i have to write a whole system for Sprite based text, well, I think I'm going to do it one day.. lots of thanks .

@Grog Grueslayer : I got it, and the problem was solved! Really I'm glad for that , many thanks for your help .

@Green Gandalf: I appreciate your cooperation, thanks!
Green Gandalf
VIP Member
21
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 5th Apr 2011 17:45
@Grog Grueslayer

Thanks for that - I missed that way of doing it.
noobnerd
15
Years of Service
User Offline
Joined: 30th Nov 2010
Location:
Posted: 5th Apr 2011 21:41
what works for me is a code like this.

sync on
sync rate 0
DRAW SPRITES MANUAL

do
sprite 1,x,y,1
print "will be above"

draw sprites
sync

loop
Admiral MH
15
Years of Service
User Offline
Joined: 10th Feb 2011
Location: TX, USA
Posted: 5th Apr 2011 21:54
And just to let to let you know in case you don't, the command "DRAW SPRITES MANUAL" is from Matrix1 Utils plug-in from IanM.

So many useful commands from there, it should be included with the native DBPro commands.
Non Sequitur M
17
Years of Service
User Offline
Joined: 28th Oct 2008
Location: Where am I!? Where are YOU?
Posted: 5th Apr 2011 21:57
@ noobnerd: Are you using a plugin? Because, 'draw sprites manual' isn't a native DBP command!

@ Moaz: Sorry... Yeah. It does take some coding. But, what I was describing was for like, a polished RPG feel, or something. If you're going for an FPS or RTS game, yeah, the other methods are fine.

@ Grog: What about a tile based game. Would the large amount of tiny sprites being manipulated each pass cost some considerable time? I ask because I am currently working on a tile based RPG.

If life were like a box of chocolates, I'd know what I would get... The one that got dropped on the floor and put back in the box.

Iye nehvur yoose spehl chehk, ahn mie tippyng izz fiyne.
Grog Grueslayer
Valued Member
21
Years of Service
User Offline
Joined: 30th May 2005
Playing: Green Hell
Posted: 6th Apr 2011 00:03
@ Moaz:

Np.


@ Green Gandalf:

Np. Sometimes the easy solutions are the hardest to remember.


@ Amo Deus Man:

With tiles it's best to use PASTE IMAGE for the majority of the tiles and only use sprites if you want to use any sprite collision commands (for the player or badguys) or for effects like rotating sprites or semi-transparent sprites. Generally we just use the 2D map array to check for collision for everything... no sprites needed. I wouldn't worry either way you go with it. IanM reworked the sprite commands in Darkbasic Pro so their much better and faster.

Non Sequitur M
17
Years of Service
User Offline
Joined: 28th Oct 2008
Location: Where am I!? Where are YOU?
Posted: 6th Apr 2011 19:09
@ Grog: I've tried that. It works great for a completely flat tile based game. But, I have height to mine. You know, cliffs, walls, trees(large trees at that). I need the sprite priority to easily move the character around, and have things in the foreground hide the character. Thanks though.

I actually have at least three arrays planned for ground tiles. A tile map(obviously), tile heights(to tell if the character can fall from the heights), and tile properties(to check for stairs, ladders, and other things that a player can climb up, as well as walls, cliffs, and the ends of levels). Another thing is, I need transparency so that my character can bee seen through tall walls, and other tall structures. So, I need actual sprites that I can fade in/out. Also, smaller multilevel buildings will be loaded at once, so if you go upstairs, there's not just a random set of stairs on the bottom floor, there is an actual staircase that you manually walk up. It's gonna be sweet... And, epic I hope!

If life were like a box of chocolates, I'd know what I would get... The one that got dropped on the floor and put back in the box.

Iye nehvur yoose spehl chehk, ahn mie tippyng izz fiyne.
Grog Grueslayer
Valued Member
21
Years of Service
User Offline
Joined: 30th May 2005
Playing: Green Hell
Posted: 6th Apr 2011 21:59
That sounds great I can't wait to see it.

Non Sequitur M
17
Years of Service
User Offline
Joined: 28th Oct 2008
Location: Where am I!? Where are YOU?
Posted: 7th Apr 2011 06:14 Edited at: 7th Apr 2011 07:57
COMING FALL 2017!

Hahahaha! jk.

Seriously though, thanks. I can't wait to hit full production! Right now, I'm coding a tile editor that handles the graphics style I'm wanting. I've got parts of a story written, and starting to sketch out character ideas. Once I've got some game play demos and stuff, I'm gonna post in the WIP section. Or, maybe, back story and some art? I don't know... What does the WIP rules say? ... ... ...Oh. Screenshots and demos. Ok.

[EDIT] I probably blabbed too early... I'm still in pre-production planning. Lol.

If life were like a box of chocolates, I'd know what I would get... The one that got dropped on the floor and put back in the box.

Iye nehvur yoose spehl chehk, ahn mie tippyng izz fiyne.
noobnerd
15
Years of Service
User Offline
Joined: 30th Nov 2010
Location:
Posted: 9th Apr 2011 01:47
it isnt native??? I didnt know!! I downloaded the matrixutil a while ago, didnt need it though but somehow i found the draw sprites manual command well it works and might need matrix util to work, sry.
Non Sequitur M
17
Years of Service
User Offline
Joined: 28th Oct 2008
Location: Where am I!? Where are YOU?
Posted: 9th Apr 2011 21:27
Haha. I have Matrix Utility as well... I didn't know that was in there! Hmm. I need to look into it more...

If life were like a box of chocolates, I'd know what I would get... The one that got dropped on the floor and put back in the box.

Iye nehvur yoose spehl chehk, ahn mie tippyng izz fiyne.
pictionaryjr
17
Years of Service
User Offline
Joined: 12th Mar 2009
Location:
Posted: 9th Apr 2011 22:57
if you're doing 3d, you could always just texture a plane

Login to post a reply

Server time is: 2026-07-17 13:58:34
Your offset time is: 2026-07-17 13:58:34