First hurdle fall... Help!

Blitz3D Forums/Blitz3D Beginners Area/First hurdle fall... Help!

Flynn(Posted 2003) [#1]
I got the Learn To Program... book, which looks excellent.

I'm following it, slowly, step by step. So slowly, in fact, that I decided to type in the ol' 'Hello World' program on Page 23.

-----
Graphics 640,480

Text 280,240,"Hello, World!"

WaitKey()

End
-----

Simple enough, right?

But it doesn't work!

I'm guessing it should print "Hello, World" until you press a key and then end.

But it just opens a blank window with a black background, waits until you press a key and then ends.


Is there something else I need to configure within BlitzPlus to make it actually display the text?


A Very, Very Confused Blitz Beginner.


Mustang(Posted 2003) [#2]
Font color? Maybe the color is black, so it does not exactly jump out of the background?

But the code above works 100% OK with my Blitz3D, and the text is white...


Flynn(Posted 2003) [#3]
Thanks, but shouldn't the font colour default to white on black? If not, how do I change it?


Shambler(Posted 2003) [#4]
It should default to white on black..strange that it doesn't, try this...


Graphics 640,480 
;background Colour
ClsColor 255,0,0
;Text Colour
Color 0,0,255
;ClearScreen to set background colour
Cls

Text 280,240,"Hello, World!" 

WaitKey() 

End 




Flynn(Posted 2003) [#5]
Thanks, Shambler.

Still the same - even with your code (black screen, waits until you press a key, program ends). No sign of a "Hello, World!"


This really isn't endearing me to the idea of coding. ;)

Flynn.


Shambler(Posted 2003) [#6]
Sounds like a driver problem then, go get the latest drivers for your graphics card and let us know if they fix it.

Also, which version of Blitz do you have?

Version 183 is the latest, make sure you have downloaded the update.


GfK(Posted 2003) [#7]
Hi,

If you're running the prog in windowed mode then try it fullscreen by turning off DEBUG mode.

The pseudo double-buffering that DirectX uses in windowed graphics modes is known to be a bit 'iffy' on certain, older graphics cards.

[EDIT] Guess what? I just tried the code in fullscreen - no text! Tried it in windowed mode (with debug on), works fine!

No idea, tbh. I'd stick this in the bugs forum though...[/EDIT]


Flynn(Posted 2003) [#8]
For the record, I tried your code and it worked fine in both the Blitz2D and 3D demos - but it won't work in the full version of BlitzPlus!

That surely can't be a driver issue, can it?


Shambler(Posted 2003) [#9]
Agree with Gfk, must be a bug >.<


Flynn(Posted 2003) [#10]
Sigh. It doesn't work in either windowed (with debug on) or full screen mode.

I know the book wasn't written with BlitzPlus in mind, but isn't this one of the most basic Blitz programs imaginable?

All of the sample games work fine.

*sob*


keyboard(Posted 2003) [#11]
try this Flynn

Graphics 640,480 
setbuffer backbuffer()
Text 280,240,"Hello, World!" 
flip
WaitKey() 
End 



you got to write to the buffer and flip it to the screen


Flynn(Posted 2003) [#12]
Wow. Thanks, keyboard. That worked fine.

So do I have to:

---
setbuffer backbuffer ()
text (etc)
flip
---

every time I want to print something on-screen?

Seems a bit laborious. ;)

Thanks for the help, everyone. I'm still not sure this is 'normal', though.

Flynn.


keyboard(Posted 2003) [#13]
yes, as a general rule. its called a game loop, you'll get used to it.

so you:

setbuffer backbuffer()
while GameOn = true ;start game loop
do game stuff
flip
wend ;end game loop

end ;end program

you do all your calculations, and draw to the backbuffer, then flip to screen ONCE every game loop, usually. Look at the examples, and you will see this pattern

[edit] you dont do:
text 100,200,"hello"
flip
text 100,220,"hello again"
flip



its:

text 100,200,"hello"
text 100,220,"hello again"
flip


get it?


Mustang(Posted 2003) [#14]
Doh! How could I miss that missing setbuffer backbuffer()... IMO you set it ONCE, at the beginning of your prog, right there where you set you resolution too. You do not need to use "setbuffer backbuffer()" inside your game loop, just flip.

http://www.blitzbasic.co.nz/bpdocs/command.php?name=BackBuffer&ref=2d_cat


Flynn(Posted 2003) [#15]
Thanks Mustang/keyboard.

That's a bit clearer. I think. ;)

I'm slightly worried about trying to learn coding from scratch, while at the same time modifying the examples which don't apply to BlitzPlus, but I'm sure I'll cope. :)


keyboard(Posted 2003) [#16]
while at the same time modifying the examples which don't apply to BlitzPlus


Most of the 2d commands are exactly the same, you've crossed the major hurdle, cos Blitz+ uses the backbuffer by default, the reason the first code worked in Blitz2D is that it uses the frontbuffer ( the screen ) by default, so the fact that you never initialised a buffer just meant you used the frontbuffer. Not in Blitz+.

I've been learning for about 9 months now, no previous experience, except a tiny bit of Pascal way back, and it is a lot of fun, Flynn, so stick with it and you will get rewards.


Flynn(Posted 2003) [#17]
Thanks, keyboard. I will stick with it. I'm already up to FOR-NEXT loops. Phew. :)

Flynn.


Ruz(Posted 2003) [#18]
I have jsut started programming too. I find my main problem is concentrating long enough to soak in the information.
My brain wanders and starts thinking of other irrelevant stuff
( mmm watermelon)


Nibble(Posted 2003) [#19]
I thought something in the B+ docs said that certain commands (such as Text and Print) would only work in certain ways. Either they only worked after setting Graphics mode and a buffer, or it was that they only appeared in a separate console window. Something like that...

If you replaced
Text 280,240,"Hello, world!"
with
Print "Hello, world!"

in the original code, would it work?

I really have no idea what I'm talking about, though... I only briefly glanced at the B+ demo when it first came out.


keyboard(Posted 2003) [#20]
yea, <text> works as usual in B+

<print> and <write> send output to a separate "console" window.

Some versions of NVidia (that I know about) drivers have a bug that handles the text command very slowly, and can really mess with the game timing.

For which reason it is best to use Bitmap graphics for your text. This puzzled me for ages when I started, cos I didn't know what the hell bitmap graphics were... Now I've just finished writing a function to output my own font design, just like a word processor. Thats why I say stick with it, cos I am not the smartest puppy of the litter, and I am amazed what fun and what you can do with a little progress, and the help sometimes of the folks at this board.

Oh, I meant to say: Bitmap graphics instead of text means simply that you make your own letters or words, in your favourite graphics editor, saving them as png's, and use those instead of the <text> command.