Author |
Topic: Graphics: White on Black (Read 512 times) |
|
datwill
Guest
|
|
Graphics: White on Black
« Thread started on: Apr 26th, 2015, 4:16pm » |
|
I seem to be having this problem where I try to draw white text on a black background. It makes white rectangles and resembles nothing of text at all. Do you know what the problem is? EDIT: I'm using LBB v.3 EDIT: Here's some example code, trying to keep as best I can to the conditions of the time I found this when I came across it while coding my computer game:
Code:nomainwin
WindowWidth = DisplayWidth: WindowHeight = DisplayHeight
open "test" for graphics_nf_nsb as #main
#main "trapclose [quit] ; color white ; font geogia italic 10 ; fill black ; home ; down"
#main "\testing text"
wait
[quit]
#main "cls": close #main
|
« Last Edit: Apr 26th, 2015, 4:23pm by datwill » |
Logged
|
|
|
|
Richard Russell
Administrator
member is offline
Posts: 1348
|
|
Re: Graphics: White on Black
« Reply #1 on: Apr 26th, 2015, 4:32pm » |
|
on Apr 26th, 2015, 4:16pm, Daniel Atwill wrote:I seem to be having this problem where I try to draw white text on a black background. It makes white rectangles and resembles nothing of text at all. Do you know what the problem is? |
|
It's impossible even to guess what the problem might be without seeing some code! A trivial example of white text on a black background works OK here:
Code: open "Test" for graphics as #w
#w "backcolor black; color white"
#w "\\This is some text"
wait It's perhaps worth noting that in LBB (and in LB 4.5 when it is released) you can also create white-on-black text in a texteditor:
Code: open "Test" for text as #w
#w "!backcolor black"
#w "!forecolor white"
#w "This is some text"
wait
|
|
Logged
|
|
|
|
Richard Russell
Administrator
member is offline
Posts: 1348
|
|
Re: Graphics: White on Black
« Reply #2 on: Apr 26th, 2015, 5:27pm » |
|
on Apr 26th, 2015, 4:16pm, Daniel Atwill wrote:EDIT: Here's some example code |
|
There's no backcolor command, so you're drawing white-on-white text!
Richard.
|
|
Logged
|
|
|
|
datwill
Guest
|
|
Re: Graphics: White on Black
« Reply #3 on: Apr 26th, 2015, 7:56pm » |
|
OH silly me!
|
|
Logged
|
|
|
|
datwill
Guest
|
|
Re: Graphics: White on Black
« Reply #4 on: Apr 26th, 2015, 8:14pm » |
|
Thanks for the text thing, but I'm still having trouble. One with the timer statement in LBB, and a scrolling text issue... OK, I have some code that's directly from my game. What I want to do is make a "poem" (yeah, it's not that good ::) and don't take any notice of it's contents ;D), scroll form bottom to top, beginning off the screen beyond the bottom, all the way off the top. But something's DEFINITELY not right! Here's some edited code from my game, adding a few lines to make it work. This happens once you wish to play the game with the selected file. It waits for 5 seconds (which it is - good) then begins the scrolling, but the poem suddenly appears near the TOP of the screen :-/ I've notice an issue with the timer statement trying to use it in my progammes, it doesn't time right: Code:WindowWidth = DisplayWidth: WindowHeight = DisplayHeight
nomainwin: open "test" for graphics_nf_nsb as #main
#main "trapclose [quit] ; cls ; fill black ; backcolor black ; color white ; font georgia italic 10"
timer 5000, [startToScroll] 'This is actually 5 seconds...
wait
[continueAfterTimer]
timer 1, [startToScroll] '... YET THIS IS SUPPOSED TO BE A MILISECOND (not what I will use in the actual game), BUT LOOK AT HOW SLOW IT IS!
originalTextPos = DisplayHeight+751
[startToScroll]
originalTextPos -= 5
#main "cls ; fill black ; place 400 ";originalTextPos
#main "\There was once a guardian,"
#main "place 400 ";originalTextPos+15
#main "\Who was once the best of them all,"
#main "place 400 ";originalTextPos+30
#main "\But his gigantic pride,"
#main "place 400 ";originalTextPos+45
#main "\Lead to his downfall."
#main "place 400 ";originalTextPos+70
#main "\he formed a rebel group of other guardians,"
#main "place 400 ";originalTextPos+85
#main "\About a third of the whole population,"
#main "place 400 ";originalTextPos+100
#main "\Which turned against their Master,"
#main "place 400 ";originalTextPos+115
#main "\The very One which gave them their damnation."
#main "place 400 ";originalTextPos+140
#main "\Although He was angry against His rebel servants,"
#main "place 400 ";originalTextPos+155
#main "\He did not let this blind Him of the true prize,"
#main "place 400 ";originalTextPos+180
#main "\For, after six lights and darks,"
#main "place 400 ";originalTextPos+195
#main "\Once his eyes were opened, he made his rise -"
#main "place 400 ";originalTextPos+220
#main "\From the dust, you awake,"
#main "place 400 ";originalTextPos+235
#main "\To find you're in a flower bed,"
#main "place 400 ";originalTextPos+250
#main "\And what you saw was good, as He proclaimed,"
#main "place 400 ";originalTextPos+265
#main "\So you made a decision, to make the first tred..."
if originalTextPos = -325 then timer 0: goto [afterSequence]
wait
[quit]
#main "cls": close #main: end There must be something wrong.
|
|
Logged
|
|
|
|
datwill
Guest
|
|
Re: Graphics: White on Black
« Reply #5 on: Apr 26th, 2015, 8:25pm » |
|
I have found a problem, but don't know what's happening
originalTextPos -= 5 'after [startToScroll]
This isn't taking away 5, it's ASSIGNING -5 to the variable! I found this out with the debugger. I tried the extended version:
originalTextPos = originalTextPos - 5
But is still assigning -5 for some reason.
|
« Last Edit: Apr 26th, 2015, 8:26pm by datwill » |
Logged
|
|
|
|
tsh73
Full Member
member is offline
Gender:
Posts: 210
|
|
Re: Graphics: White on Black
« Reply #6 on: Apr 26th, 2015, 9:20pm » |
|
No, that's all problems in program logic. Code:WindowWidth = DisplayWidth: WindowHeight = DisplayHeight
nomainwin: open "test" for graphics_nf_nsb as #main
#main "trapclose [quit] ; cls ; fill black ; backcolor black ; color white ; font georgia italic 10"
timer 5000, [continueAfterTimer]
'This is actually 5 seconds...
'originalTextPos = DisplayHeight+751 'why?
originalTextPos = DisplayHeight
wait
[continueAfterTimer]
timer 1, [startToScroll] '... YET THIS IS SUPPOSED TO BE A MILISECOND (not what I will use in the actual game), BUT LOOK AT HOW SLOW IT IS!
wait
[startToScroll]
originalTextPos -= 5
#main "cls ; fill black ; place 400 ";originalTextPos
#main "place 40 40"
#main "\";originalTextPos
#main "place 400 ";originalTextPos
#main "\There was once a guardian,"
#main "place 400 ";originalTextPos+15
#main "\Who was once the best of them all,"
#main "place 400 ";originalTextPos+30
#main "\But his gigantic pride,"
#main "place 400 ";originalTextPos+45
#main "\Lead to his downfall."
#main "place 400 ";originalTextPos+70
#main "\he formed a rebel group of other guardians,"
#main "place 400 ";originalTextPos+85
#main "\About a third of the whole population,"
#main "place 400 ";originalTextPos+100
#main "\Which turned against their Master,"
#main "place 400 ";originalTextPos+115
#main "\The very One which gave them their damnation."
#main "place 400 ";originalTextPos+140
#main "\Although He was angry against His rebel servants,"
#main "place 400 ";originalTextPos+155
#main "\He did not let this blind Him of the true prize,"
#main "place 400 ";originalTextPos+180
#main "\For, after six lights and darks,"
#main "place 400 ";originalTextPos+195
#main "\Once his eyes were opened, he made his rise -"
#main "place 400 ";originalTextPos+220
#main "\From the dust, you awake,"
#main "place 400 ";originalTextPos+235
#main "\To find you're in a flower bed,"
#main "place 400 ";originalTextPos+250
#main "\And what you saw was good, as He proclaimed,"
#main "place 400 ";originalTextPos+265
#main "\So you made a decision, to make the first tred..."
if originalTextPos < -325 then timer 0: goto [afterSequence]
wait
[quit]
#main "cls": close #main: end
EDIT RE: 1ms windows might support bigger time chunks. For XP it is 16 ms - it will do 16 even if you ask for 1
|
« Last Edit: Apr 26th, 2015, 9:22pm by tsh73 » |
Logged
|
|
|
|
Richard Russell
Administrator
member is offline
Posts: 1348
|
|
Re: Graphics: White on Black
« Reply #7 on: Apr 26th, 2015, 9:24pm » |
|
on Apr 26th, 2015, 8:25pm, Daniel Atwill wrote:This isn't taking away 5, it's ASSIGNING -5 to the variable! I found this out with the debugger. |
|
I cannot reproduce that. I commented out the NOMAINWIN and added a diagnostic PRINT statement here:
Code:originalTextPos -= 5
print originalTextPos ' debug This is what I get in the mainwin (a new number is printed every 5 seconds as expected):
Code: So, here at least, it is definitely subtracting 5, not assigning -5. If you are seeing something different, I do not understand it.
Richard.
|
|
Logged
|
|
|
|
datwill
Guest
|
|
Re: Graphics: White on Black
« Reply #8 on: Apr 27th, 2015, 08:53am » |
|
tsh73 I assigned the originalTextPos to be greater than the DisplayHeight because doesn't, with text, the coordinates given relate to the LL corner of the block of text? If this is true, assigning the variable DisplayHeight, the first line will just appear at the bottom of the screen and not scroll on, not really what I want. But it is true that I shouldn't be adding 700 odd (why did I do that? ), I only need to add 15. Thank you for pointing that out. I tried typing 1ms as the amount of time and LBB came up witht a syntax error . The time is more like a second...
Richard That is true that it's taking away 5, but for some reason, after testing my programme out AGAIN after tsh73's advice about the DisplayHeight thing, it STILL comes out as -5. How is originalTextPos = DisplayHeight+15 the same as originalTextPos = -5 Me don't get...
|
« Last Edit: Apr 27th, 2015, 08:54am by datwill » |
Logged
|
|
|
|
tsh73
Full Member
member is offline
Gender:
Posts: 210
|
|
Re: Graphics: White on Black
« Reply #9 on: Apr 27th, 2015, 09:02am » |
|
Daniel, my advice was not about "DisplayHeight thing"
Run code from my post. See how fast ot scrolls.
Pay attention to timer labels - there was error in program flow (and I think originalTextPos cames as -5 not because it gets assigned, but rather because it wasn't assigned before: so it had value 0, and -=5 just decreased it to -5 (as should) And it was not assigned again because of wrong program logic: it just never executes line Code:originalTextPos = DisplayHeight+751 )
|
« Last Edit: Apr 27th, 2015, 09:03am by tsh73 » |
Logged
|
|
|
|
Richard Russell
Administrator
member is offline
Posts: 1348
|
|
Re: Graphics: White on Black
« Reply #10 on: Apr 27th, 2015, 09:51am » |
|
While you're making changes, please correct the spelling!
Code:#main "\Lead to his downfall." My three top hates:
Writing it's when it should be its. Writing loose when it should be lose. Writing lead when it should be led. You might also want to consider putting the text strings in DATA statements and reading them in a loop, which is more efficient and easier to change (for example if you wanted to alter the line spacing).
Richard.
|
|
Logged
|
|
|
|
datwill
Guest
|
|
Re: Graphics: White on Black
« Reply #11 on: Apr 27th, 2015, 11:03am » |
|
Thank you Richard and tsh73, I've figured out that the code flow went to the wrong branch label (skipping the variable declaration so it equalled 0 when i took 5 from it resulting in -5) once the 5 seconds were up! and no wonder it was slow because the timer was 5000ms not 1ms!
|
|
Logged
|
|
|
|
|