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 / Printing multiple text statements over image in a window without printing over previous text statements made

Author
Message
Unseen Ghost
21
Years of Service
User Offline
Joined: 2nd Sep 2002
Location: Ohio
Posted: 2nd Dec 2020 18:18 Edited at: 2nd Dec 2020 18:21
Hi,

I'm trying to print multiple text statements in same spot one after another, but can't get it to where the backround image is restored so they don't appear over each other. I have tried using sprites and using "Set Sprite" command to restore the backround, but all that happens is a black image covers the whole window area and the text shows up over each other.

I am also trying to write to log file and it isn't writing and saving it

The only way I can get it to work is repaste the image each time before the text is printed to window and not use sprites. Current code using sprites isn't showing the text at all, just black image, I have tried different flags on the "Get Image command also to no avail.



Can anyone help?
Gigabyte Board/2.93Ghtz Intel Core Duo Proc./4GB Ram/Nvidia Geforce 730 2GB/1TB Western Dig. SSD/Dark Basic Pro 7.7

No one cares how much you know until they know how much you care.
James H
16
Years of Service
User Offline
Joined: 21st Apr 2007
Location: St Helens
Posted: 4th Dec 2020 17:56
Hi
I don't have access to a machine any time soon but 1st thing that strikes me is the lack of sync commands...ie you leave the update to DBP to deal with as it sees fit.
Without sync on and use of sync commands DBP will only sync the screen when it sees fit and not just the screen but other commands to. The use of those 2 commands will allow you to take control of when this happens. Otherwize you will have to play around with commands and TEST for yourself when DBP syncs various things and when it doesn't, but do so in a minimalistic manner ie create specific test beds to test for specific things before you consider making longer programs...hope that helps.
Win 7 Pro 64 bit SP1, AMD A4-5300 APU 3.4GHz, 8GB DDR3, NVidia GeForce GTX 750 1GB GDDR5, ASUS A55BM-E
Unseen Ghost
21
Years of Service
User Offline
Joined: 2nd Sep 2002
Location: Ohio
Posted: 4th Dec 2020 18:27
Thank you James H, now that you mention it about the sync commands, I see it.
Gigabyte Board/2.93Ghtz Intel Core Duo Proc./4GB Ram/Nvidia Geforce 730 2GB/1TB Western Dig. SSD/Dark Basic Pro 7.7

No one cares how much you know until they know how much you care.
Unseen Ghost
21
Years of Service
User Offline
Joined: 2nd Sep 2002
Location: Ohio
Posted: 5th Dec 2020 22:06
I tried the sync commands and I'm still having the same issue
Gigabyte Board/2.93Ghtz Intel Core Duo Proc./4GB Ram/Nvidia Geforce 730 2GB/1TB Western Dig. SSD/Dark Basic Pro 7.7

No one cares how much you know until they know how much you care.
James H
16
Years of Service
User Offline
Joined: 21st Apr 2007
Location: St Helens
Posted: 6th Dec 2020 01:04
Okay, where to start...

first of all you need to read the help files properly, a clear example of you not doing this is when you attempt to write to the same file twice. FROM THE HELP FILES "The file must not exist or the command will fail", so your first attempt will work your second will not as you already closed the file...also once you have ran the program once you then need to find said file and delete it or the second time you run the program both attempts to write to file will fail. This is just a clear example and this particular area of your code and does not need dealing with first....you really really really need to do this stage by stage before progressing. By this I mean write your first stage of code and get it working 100%, then move on. If you had done this you would have realised you load an image, then you grab an image of the screen...but both image ID's are the same! When you load an image it does not automatically get drawn to screen. So the image you loaded does not get automatically put on screen, you then grab an entirely blank image of the screen into the same image ID slot thus overwriting the image you have just loaded in and replacing it with an entirely black image...the same as the background of the window!

You don't need sprites here either...you need to put "sync on" at the beginning of your program so that you can take control of when you want the screen updating, and when it becomes the right time to update the screen you must call "sync" not once but twice to account for both front and back buffers. This should also be done before you call for the wait command or the system will wait until after that command, then it will update but you will see nothing as you expect because 2 syncs is essentially 1 frame, and your machine will be running at max speed , even if it was running at 60 frames per second you would not see anything as it all happens far too quickly to see. In essence we are manipulating the contents of time at such a scale that the human eye cannot see it. This really boils down to reading AND understanding the help files along with going through the motions of tutorials and examples provided BEFORE moving on. Because you don't use a main loop in your program you have to update both front and back buffer by calling sync twice every time you want to update the commands you have previously written, for you the basics of each stage should be as follows(only use sync on once though right at the beginning)

sync on
load image
paste image
draw text to screen
do any other stuff you might want such as writing to file
sync
sync
wait x amount of time

As for the file stuff, well lets do this all one step at a time... instead of writing to file simply output what you wanted to write to screen first - make sure that date stuff produces the correct result you want in a readable format. What you have been writing to file is um messy, it is not in a readable format, just use strings and not an integer. If you wish to write to the same file more than once then do not close the file until you are done, in fact you only open the file twice yet you close it 3 times! Don't get me wrong, the third time will silently fail and shouldn't produce adverse effects, however it does show you are not paying attention...my guess is you got hacked off trying to get this done then just posted it as is.

Now I don't know why you think a for next loop is need to write the date stuff to file, you should simply add the strings together then use "write string". Again you need to understand data types covered in first sections of the help files and also in command section read the for next loop info to...it should all be there...but like I said get the code to a point where you understand it in full, where it works 100% then move onto the next stage.

I hope I have covered enough to keep you going and along the right track, never give up and keep on coding man, all is good
Win 7 Pro 64 bit SP1, AMD A4-5300 APU 3.4GHz, 8GB DDR3, NVidia GeForce GTX 750 1GB GDDR5, ASUS A55BM-E
Unseen Ghost
21
Years of Service
User Offline
Joined: 2nd Sep 2002
Location: Ohio
Posted: 6th Dec 2020 03:41 Edited at: 6th Dec 2020 03:45
I agree,
I have been away from programming for awhile. I little rusty so to speak lol. I will be back where I was pretty quickly.

I have decided to write the current date as the veriable has it rather than manipulate it and add stuff to it, except the string statement I add to it
Gigabyte Board/2.93Ghtz Intel Core Duo Proc./4GB Ram/Nvidia Geforce 730 2GB/1TB Western Dig. SSD/Dark Basic Pro 7.7

No one cares how much you know until they know how much you care.
Derek Darkly
12
Years of Service
User Offline
Joined: 22nd Sep 2011
Location: Whats Our Vector, Victor?
Posted: 7th Dec 2020 18:42

Hey Ghost!

Try "PASTE SPRITE" instead of "PASTE IMAGE"
If that doesn't work, I'll try to run your code and see if I can help, unless you have decided on something else.

Also, you don't need GET IMAGE after loading your image... that command is for only capturing what's on the screen into an image.
Send your parents to noisy sprite demo hell... enter the D-Zone
Unseen Ghost
21
Years of Service
User Offline
Joined: 2nd Sep 2002
Location: Ohio
Posted: 14th Jan 2021 14:19 Edited at: 14th Jan 2021 14:21
I figured everything out. My log files are working also. Thank you for all the help
Gigabyte Board/2.93Ghtz Intel Core Duo Proc./4GB Ram/Nvidia Geforce 730 2GB/1TB Western Dig. SSD/Dark Basic Pro 7.7

No one cares how much you know until they know how much you care.
James H
16
Years of Service
User Offline
Joined: 21st Apr 2007
Location: St Helens
Posted: 14th Jan 2021 16:20
Cool, glad you got there
Win 7 Pro 64 bit SP1, AMD A4-5300 APU 3.4GHz, 8GB DDR3, NVidia GeForce GTX 750 1GB GDDR5, ASUS A55BM-E

Login to post a reply

Server time is: 2024-03-28 08:45:29
Your offset time is: 2024-03-28 08:45:29