Thursday 5 April 2012

Smoke And Mirrors With Print

Following the summary in the last post, round about now, someone familiar with programming but new to AGK might well be wondering;

"If the do/loop repeats the code an infinite number of times, and the Print() command is in the loop, why does it only print hello world once on the screen?"

Which is a very good question - in other languages, you would get a whole load of "Hello World" lines running down the screen.

Technically, I lied when I wrote that the Print() command prints to the screen.  The Print() command actually sends its output to a buffer ready for printing to the screen.

Then, the next time the Sync() command is run, it waits until the right time and transfers everything in the buffer to the screen and clears the buffer.

AGK is different from many other languages in this way.  If you want printed text to stay on the screen for more than one frame, you have to reprint it each frame.

Fortunately it prints text very fast and printed text is not used much beyond diagnostics, so it's not an issue.

But I thought I'd include this slight interlude to cover it before we start coding.

No comments:

Post a Comment