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 / text not printing to screen

Author
Message
DJm
16
Years of Service
User Offline
Joined: 14th Feb 2010
Location: Portugal
Posted: 25th Feb 2010 02:15
Hi All,

This is a simple problem but I can't find the answer anywhere.

I have used a sprite for my picture backdrop, the same size as the screen.

I use another sprite for my man.

I then want to print it's position on the screen (x,y co-ords) but the text is not showing up. I guess that the text is probably hidden by the screen picture sprite.

I need the text to show up so I can do some calculations based on the position of the man.

Can anyone help?

I have attached the code so you can have a look.
set display mode 864,486,32
SET TEXT TO BOLD
SET TEXT FONT "Arial"
sync on
load image "C:\Program Files\The Game Creators\Dark Basic Professional\Projects\man.png",1
load image "C:\Program Files\The Game Creators\Dark Basic Professional\Projects\backdrop.png",2
sprite 1,0,0,2
y=400: x=243
repeat
if upkey() then dec y
if downkey() then inc y
if leftkey() then dec x
if rightkey() then inc x
SPRITE 2,x,y,1
set cursor 100,100
print "y pos:";y
print "x pos:";x
sync
sleep 20
until spacekey()
end

No good deed goes unpunished!
Hawkblood
16
Years of Service
User Offline
Joined: 5th Dec 2009
Location:
Posted: 25th Feb 2010 03:28 Edited at: 25th Feb 2010 03:29
Yes
Quote: "I guess that the text is probably hidden by the screen picture sprite."

If you want to put text over your sprites, you MUST:



the sprite sn,x,y,in will ALLWAYS put it over your text.... I guess because of how DBP orders it's render loop. Pasting the sprite before you do your text will force the order so that the text is after it.

I had the same problem just today and someone helped me.

The fastest code is the code never written.
DJm
16
Years of Service
User Offline
Joined: 14th Feb 2010
Location: Portugal
Posted: 25th Feb 2010 04:56
Thanks for the help, got it working now.

No good deed goes unpunished!
Rich Dersheimer
AGK Developer
17
Years of Service
User Offline
Joined: 1st Jul 2009
Location: Inside the box
Posted: 25th Feb 2010 05:27 Edited at: 25th Feb 2010 05:27
There are at least a couple of different ways to do what you want.

One way is to use your background image with TEXTURE BACKDROP. But you must have an up-to-date version of DBPro.

Thus:



Another way is to paste your background image (NOT as a sprite) and use SET SPRITE 1,1,1 to force the background to be visible.

Thus:



The second version uses opaque text, so it doesn't keep overwriting the text.

Mobiius
Valued Member
23
Years of Service
User Offline
Joined: 27th Feb 2003
Location: The Cold North
Posted: 26th Feb 2010 08:41
Quote: "I had the same problem just today and someone helped me."



Paste sprite is your friend! (Until you need sprite collision then it's not the friendly kind. )

My signature is NOT a moderator plaything! Stop changing it!
Hawkblood
16
Years of Service
User Offline
Joined: 5th Dec 2009
Location:
Posted: 26th Feb 2010 15:14
Quote: "Paste sprite is your friend! (Until you need sprite collision then it's not the friendly kind. )"

If you put the "hidden" sprite in the same location with the same scale then you WILL be able to use sprite collision!

The fastest code is the code never written.
The Slayer
Forum Vice President
16
Years of Service
User Offline
Joined: 9th Nov 2009
Playing: (Hide and) Seek and Destroy on my guitar!
Posted: 26th Feb 2010 18:38
This is a bit off topic, but instead of using the command SLEEP, it would be better to use the SYNC RATE command.
SLEEP is mostly used to pause the program.

Cheers

Slayer rules!!! Yeaaah, man!
DJm
16
Years of Service
User Offline
Joined: 14th Feb 2010
Location: Portugal
Posted: 28th Feb 2010 02:30
First of all, thanks for all your comments.

I used sprite 1 as the backdrop so all the other sprites must have priority over it and should be drawn on top of it, wrong.

1st loop in my program worked fine but when I gave sprite 1 another image to change the backdrop, image 22, suddenly some of my sprites were not being drawn even though they had much higher sprite numbers.

Afetr 6 hours I found out it matters what image number is associated with the sprite too and fixed the problem by giving sprite 1 an image no.1, hey presto! all my sprites re-appeared.

To answer the SLEEP and SYNC RATE issue, I have found that when I use sync rate, no matter what I set it to, my games run very slow.
I have found I get more control by pausing the game for 1000ths of a second using SLEEP instead. Is this right?

No good deed goes unpunished!

Login to post a reply

Server time is: 2026-07-27 16:01:25
Your offset time is: 2026-07-27 16:01:25