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 / Arghhh Print text over sprites

Author
Message
Don3784
13
Years of Service
User Offline
Joined: 15th Apr 2013
Location:
Posted: 21st Aug 2013 02:36
Ok 2 questions, same thread.

Question 1: Is there any way to print text over an actual sprite. not a pasted sprite? There has to be a way but I can't find it I have searched and searched. My issue is i use sprites for collision and i use pasted sprites for other things. So I need both. I have thought of making a character set and convert it into sprites and then use some kind of tile system but that is a lot of work just for text.

Question 2: Is it possible to play an animated sprite in reverse?
Chris Tate
DBPro Master
17
Years of Service
User Offline
Joined: 29th Aug 2008
Location: London, England
Posted: 21st Aug 2013 03:27 Edited at: 21st Aug 2013 03:47
Quote: " Is there any way to print text over an actual sprite. not a pasted sprite?"


Indeed



Quote: "My issue is i use sprites for collision and i use pasted sprites for other things. So I need both"


Sprites can still collide when hidden

Quote: "Is it possible to play an animated sprite in reverse? "


Unlike in AppGameKit, you cannot force a sprite to play back with a negative delta. You have to set the frame manually; which means you would also need to creater a timer to make use of the frame speed convinience.

If you search the forums you will find that most solutions found require a timer function.

My way is easier:


You just play a cloned hidden sprite and use its playback speed for reference. You will not lower the performance significantly because the reference sprite is hidden and the texture memory used is still the same due to the sharing of the same image.

However, if working on something long term or something with an excess quantity of animated sprites for some reason; say 5,000 or more animated sprites, you'd be better of creating the timer function so that sprite loops are made more efficient.

It is still handy to have an arbitrary timer function available for various needs; I use a timer function to detect Miles Per Second measurement of car speed variables; and loops per millisecond iterations in my game.



There are many applications for those two particular functions

Don3784
13
Years of Service
User Offline
Joined: 15th Apr 2013
Location:
Posted: 21st Aug 2013 03:59
Wow thanks for the help once again Chris. I feel like an idiot now, I guess i just didn't see the draw sprites first command. As far as playing my sprites in reverse. It's not something I will be using to much so that should work great for what I need and its so simple. IDK why I didn't think of it. Once again thanks for the help. I'm astonished you don't have tons of badges next to your avi.
Don3784
13
Years of Service
User Offline
Joined: 15th Apr 2013
Location:
Posted: 21st Aug 2013 04:12
BTW Chris do you have twitter? my account is @shadowofawaryn I would like to follow you if you do.
Chris Tate
DBPro Master
17
Years of Service
User Offline
Joined: 29th Aug 2008
Location: London, England
Posted: 21st Aug 2013 04:45 Edited at: 21st Aug 2013 04:47
Thanks; nice to be appreciated. The trick is to assume that there is an easier way, then go looking for it.

I'm not much into twitter or facebook. I should really get more into them. You can just follow my WIP via my banner for now, as updates or comments are made you will get sent an email. 99% of my time is spent programming at the moment, very little time for much else.

Keep posting up any questions and I will often answer them if the Mage, Rudolpho, Mobiius or that Green Gandalf don't beat me to it. lol

Badges; nah no badges for me. There aren't many badges to be obtained in my opinion; there should be more variety of badge requirements, you know like for code-base or snippet contributions, votes, Q&A answer ratings, feedback, badges for not being BANNED, badges for not using GOTO commands.

So far they are just for people who backed TGC's FPSC via kickstarter, or for those who have released TGC products or tools; or valued members valued by whoever it is... etc. etc.

But keep looking up all of those functions in the help files and don't be ignorant of plugins; then sooner rather than later, you will be the one with the badges.

Green Gandalf
VIP Member
21
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 21st Aug 2013 17:18
Quote: "The trick is to assume that there is an easier way, then go looking for it."


Good advice.



Powered by Free Banners
PirateJohn
14
Years of Service
User Offline
Joined: 4th Aug 2011
Location: California
Posted: 23rd Aug 2013 05:34
Okay, let me add a level of difficulty to the question: Is it possible to draw text on top of a sprite that is on top of 3D graphics? When I try DRAW SPRITES FIRST, the sprite is hidden by the 3D.
Mage
Valued Member
19
Years of Service
User Offline
Joined: 3rd Feb 2007
Location:
Posted: 23rd Aug 2013 08:54
Quote: "Badges; nah no badges for me. There aren't many badges to be obtained in my opinion; there should be more variety of badge requirements, you know like for code-base or snippet contributions, votes, Q&A answer ratings, feedback, badges for not being BANNED, badges for not using GOTO commands."

I feel your pain. I doubt very much they're even checking anymore to be honest.

Chris Tate
DBPro Master
17
Years of Service
User Offline
Joined: 29th Aug 2008
Location: London, England
Posted: 23rd Aug 2013 19:12 Edited at: 23rd Aug 2013 19:17
Quote: "I feel your pain. I doubt very much they're even checking anymore to be honest."




Quote: " Is it possible to draw text on top of a sprite that is on top of 3D graphics? When I try DRAW SPRITES FIRST, the sprite is hidden by the 3D. "


So it is a 3D program; that makes the situation more complex.

Put it this way, sprites are only drawn before everything else or after everything else. They have their own pipeline. Only when you take control of that pipeline can you put the sprites where ever you want them; but doing so is not necessary for everyday use.

Unless anyone knows a better way; I would first ask for the big picture; post up an example of what you have done OR explain why this needs to happen.

It could be that the sprites needed to be behind text in order to represent character billboards; for which there are solutions and even plugins.

Or perhaps you are using the sprites for user interaction, and need feedback text above the sprites; for which you may need text to become sprites; or to be drawn in them. There is also a way to give text its own camera view used as a layer.

It depends where you are going with this?

Mobiius
Valued Member
23
Years of Service
User Offline
Joined: 27th Feb 2003
Location: The Cold North
Posted: 24th Aug 2013 00:11
Hide the sprite used for collision, paste the sprite over the top. I've had to do this in the AppGameKit UI engine I ported to DBP and it works very well.

Mage
Valued Member
19
Years of Service
User Offline
Joined: 3rd Feb 2007
Location:
Posted: 24th Aug 2013 18:06
I would suggest using Bitmap Fonts, and switching to paste sprite for everything. However setting this up takes a lot of work.

PirateJohn
14
Years of Service
User Offline
Joined: 4th Aug 2011
Location: California
Posted: 26th Aug 2013 04:40
Quote: "Unless anyone knows a better way; I would first ask for the big picture; post up an example of what you have done OR explain why this needs to happen."


Fair enough.

I'm making an Olympic Weightlifting game. I want to create a banner at the bottom of the screen that has the lifter's name, scores, country, etc. So basically, the sprite is a blue bar that I created in Photoshop and the text goes on top of the bar.
Chris Tate
DBPro Master
17
Years of Service
User Offline
Joined: 29th Aug 2008
Location: London, England
Posted: 26th Aug 2013 04:49 Edited at: 26th Aug 2013 04:55
The irony here is there is actually a 3D gaming concept called billboarding, which would better suited for 3D banners than sprites. DBP doesn't only allow drawing text on the screen, you can draw text into textures. Infact cameras are not limited to rendering to the screen, they also can render to textures. (Arguably, the DirectX screen is a texture).

However, at this moment in time on the other side of the Atlantic, towards the middle bit of the bottom right edge of England, it is really late, and must be diving into bed soon.

If someone doesn't beat me to it, I will point you in the right direction tomorrow. Meanwhile you could do a search for billboard and texture-text techniques.

Mage
Valued Member
19
Years of Service
User Offline
Joined: 3rd Feb 2007
Location:
Posted: 27th Aug 2013 05:39 Edited at: 27th Aug 2013 06:07
Quote: "I'm making an Olympic Weightlifting game. I want to create a banner at the bottom of the screen that has the lifter's name, scores, country, etc. So basically, the sprite is a blue bar that I created in Photoshop and the text goes on top of the bar."

I assume this is meant to be like a television graphical overlay. Like a broadcast of the event.

I know you are relying on sprites to draw themselves, but this is generally poor programming and it is causing your problems in this case.

This is no different than a HUD. Just use paste sprite, with the text command used last. This will produce the banner on screen with text overlapping. Make sure you remove that sprite draw order code. Also you'll need to make sure the HUD (which is what this is) is drawn each time.

When you make your sprites use hide sprite right afterwards. Rely entirely on paste sprite to draw any and all sprites. It will give you the control you are looking for.

Using sprites for collision...
I don't see how you can't use your other non pasted sprites with this. They shouldn't conflict in any way. You don't have to paste all of your sprites. If you are having issues with on-screen sprites moving overtop of text then program them to disappear or set their alpha to zero when they enter regions of the screen where text is placed. This should still allow for collision.

Nevermind here's the solution...
Or just make copies of your sprites with collision. Set those copies to 0 alpha and use non paste sprite draw method. The visible version of those sprites uses paste sprites. Use collision on just the invisible versions. Then draw text overtop of all of it.

Mage
Valued Member
19
Years of Service
User Offline
Joined: 3rd Feb 2007
Location:
Posted: 27th Aug 2013 06:04 Edited at: 27th Aug 2013 06:06
Oops.

Chris Tate
DBPro Master
17
Years of Service
User Offline
Joined: 29th Aug 2008
Location: London, England
Posted: 27th Aug 2013 15:13
Quote: "Oops."
Why oops?

By the way, I have not forgotten to post the billboard idea; at work at the moment, will post up my contribution later.

Mage
Valued Member
19
Years of Service
User Offline
Joined: 3rd Feb 2007
Location:
Posted: 28th Aug 2013 02:16
Quote: "Why oops?"

iPhone chrome browser screwed up and posted an edit as a whole new post. I can't delete the post so I edited out all the text and placed oops.

I think I solved the OP's problem above. He can keep using sprite detection, just set those sprites alpha to 0. Then alternate visible versions of those sprites (different sprite numbers) can use paste sprite. This will allow him to draw text over everything.

Overall I'd do things differently, but this is working within the OP's limits.

PirateJohn
14
Years of Service
User Offline
Joined: 4th Aug 2011
Location: California
Posted: 1st Sep 2013 21:10
Quote: "I know you are relying on sprites to draw themselves"


Actually, I'm not. I created the sprite in Photoshop and simply use PASTE SPRITE to get it to the screen.

Quote: "This is no different than a HUD. Just use paste sprite, with the text command used last."


Hmm, this is what I tried at first. It could be because I use DRAW SPRITES LAST elsewhere in the program and it carries over. Is there a command that removes the DRAW SPRITES LAST condition?
Mobiius
Valued Member
23
Years of Service
User Offline
Joined: 27th Feb 2003
Location: The Cold North
Posted: 2nd Sep 2013 23:40
Try: DRAW SPRITES FIRST...

Chris Tate
DBPro Master
17
Years of Service
User Offline
Joined: 29th Aug 2008
Location: London, England
Posted: 3rd Sep 2013 03:47 Edited at: 3rd Sep 2013 03:49
Sprites are drawn behind the 3D when drawn first.

I still think you should do what the Mage suggested, but for the sake of it, I have created a demonstration of 3D banners here because I do not know if you are willing to invest time in 2D pipe-lining; which you probably would if your project is a long term commitment.

At least if your more confortable in a 3D scene editor, all you need to do is make the banner as part of the arena and draw text on it...

Login to post a reply

Server time is: 2026-07-06 20:15:38
Your offset time is: 2026-07-06 20:15:38