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 Discussion / Text won't print to the screen

Author
Message
demons breath
21
Years of Service
User Offline
Joined: 4th Oct 2003
Location: Surrey, UK
Posted: 19th Oct 2007 22:07 Edited at: 19th Oct 2007 22:30
I made a simple little snake game this afternoon because I was a bit bored. The actual game mechanics seem to work alright, but when you die, the text does not display. Then you press any key to reset the variables and start again, but the box on which the end game message is supposed to display doesn't disappear, and the score box doesn't come back. All in all, everything goes a bit poo.





EDIT: By the way I'm pretty sure the problem is in here somewhere:



That would make most sense, seeing as it's where the programme has the problems, and it's also the only bit I really altered before it all started going pearshaped.

EDIT 2: Removed an errant "sync off" command which was from some halbrained earlier attempt to fix this problem. Now the text does display, but it sort of flickers on and off, and the other problems remain.

EDIT 3: Changed the code a little bit more. But I don't think it did any good.

http://jamesmason01.googlepages.com/index.htm
TDK
Retired Moderator
22
Years of Service
User Offline
Joined: 19th Nov 2002
Location: UK
Posted: 20th Oct 2007 02:37
Wow - crazy indentation style or what!

Anyway, remember that Sync refreshes the 3D screen and in the process zaps any 2D text you've just put on it.

So if your program puts text on the screen then goes into a loop which just does nothing but do Sync's until you press a key, then your text will disappear instantly.

Put the Text commands in that loop after the Sync to replace the text that the Sync zaps.

TDK_Man

LBFN
18
Years of Service
User Offline
Joined: 7th Apr 2007
Location: USA
Posted: 20th Oct 2007 02:37
In the procedure endvar, you call the function MakeRoundedBox. During that function, you are pointing to a different bitmap. Simply set the current bitmap to 0 after the function call to MakeRoundedBox and it should fix the problem.

Some thoughts:

Why not grab the image from 600,30,750,180 prior to your main loop and just paste that image at 600,30 where you are placing all of the boxes in the main loop. It would be more efficient.

Why not just 'sync : wait key' after the text is printed in endvar?

Nice little game for an afternoon's work.

LB
demons breath
21
Years of Service
User Offline
Joined: 4th Oct 2003
Location: Surrey, UK
Posted: 20th Oct 2007 07:18
@TDK: I find the indentation easier as it helps find nesting errors. But that's just me. I actually thought that was how most people did it but oh well... I'll try changing the sync positioning later, but the text still shows it just sort of flickers, and the background shows fine, neither of which I would have expected from how you've described the sync command...

@LBFN: oh that might be it I wrote this function for something else where I needed to write to all sorts of different bitmaps. I'll also change those boxes I'm drawing to one image; you're right it would be more efficient. I just kept adding stuff in it was a bit of a hodgepodge of code, not really as structured as it would have been if I was trying to make a more complete code. The reasoning behind not having 'sync : wait key' was that I already had 'sync : suspend for key' but what I replaced it with was one of (more than a few) attempts to resolve the problem. And thanks.

Anyway thanks for the help guys. I'll have a proper look at it later. I should really have been at work 20 minutes ago though it's almost 20 past 5. Yay I love these early starts

http://jamesmason01.googlepages.com/index.htm
demons breath
21
Years of Service
User Offline
Joined: 4th Oct 2003
Location: Surrey, UK
Posted: 20th Oct 2007 17:15
OK Everything's sorted except for some reason, as I'm setting the text size after some text but before some more, it flickers between the two sizes. I think I've seen this before, but don't know if I ever solved it. I'm going to do some forum searching and if that fails then I'll just copy it all to bitmaps but I'd prefer to resolve the problem than just work around it...

http://jamesmason01.googlepages.com/index.htm
LBFN
18
Years of Service
User Offline
Joined: 7th Apr 2007
Location: USA
Posted: 20th Oct 2007 17:21
I have had issues with setting the text size before. I put a wait 3 after a text size change. Try it and see if it fixes the problem.

LB
demons breath
21
Years of Service
User Offline
Joined: 4th Oct 2003
Location: Surrey, UK
Posted: 20th Oct 2007 17:45 Edited at: 20th Oct 2007 17:45
I just copied the first text section into an image, then printed the text. That worked. It's all good now.

It's a bit boring though. Oh well it was only an exercise in programming it's not surprising that it's not hugely entertaining. Much too simple and slow.



Thanks for all the help.

http://jamesmason01.googlepages.com/index.htm

Login to post a reply

Server time is: 2025-05-31 21:01:59
Your offset time is: 2025-05-31 21:01:59