Screen Flashes Between Black and light grey?
BlitzPlus Forums/BlitzPlus Beginners Area/Screen Flashes Between Black and light grey?
| ||
hey guys, im new to Blitzplus and programming! im in the process of writing my very first text-based programs that change the graphics resolution. im having an issue where the screen will blink back and forth between a light grey background with white letters to a black background with white letters and its almost as if the black screen is off-center from the greyish one. any ideas? thanks! -adam |
| ||
post your code! |
| ||
Make sure that you use "SetBuffer BackBuffer()" just before your main program loop. |
| ||
are you using color r,g,b or clscolor r,g,b at all, seeing your code would be helpful. |
| ||
i believe i have a Buffer problem of some sort. I downloaded the latest version of BlitzPlus, (I was running v1.11). that got rid of the color changing aspect, now both backgrounds are black... However... Ive noticed that my code works in BlitzBasic, but not in BlitzPlus. Is this because Blitzbasic writes directly to the front buffer and that BlitzPlus writes to the back buffer? What it boils down to is i cant seem to get the flips right.... as the program stands right now, its like ive got two different pages flipping, so i can only see every other line of text at any given time. here's the text, its REALLY basic so dont laugh...heh heh.... Source: ;practicing repeat until loop ;this program closes after player presses enter/return Graphics 800,600 Text 0,0, "Why did you open this stupid program?" Flip ;y is the variable that judges the location of the text y=12 Repeat ;print text Text 0,y, "Press Enter to exit." ;wait a sec Delay 1000 Flip ;move next line of text down y=y+12 ;repeat until user hits enter Until KeyHit(28) Text 0,y, "Program is ending." Flip ;wait 2 seconds Delay 2000 |
| ||
The problem is you have 2 buffers and you are writing a line of text to one buffer and showing it with flip, then the current buffer is blank and you are writing to that before showing it with flip. What I do is cls, then redraw the entire screen before flipping. For you this would mean keeping track of what you had output already and redrawing it each time so that both buffers contain the same text. Get it? |
| ||
You should have "Cls" at the beginning of the loop, and the "Delay" should really come after the "Flip". One other thing that MAY be affecting it is that you're using a "Repeat"-"Until" loop, and main program loops are usually "While"-"Wend" loops. But I don't think that it would really make a difference. |
| ||
Grey Alien, thanks for the tip. i'll tinker with it and see what i can come up with. thanx blaine for the additional help. i messed with the locales of the flips for a while, but had to run to work so i wasnt able to do a thorough invesigation. -adam |
| ||
One other thing that MAY be affecting it is that you're using a "Repeat"-"Until" loop, and main program loops are usually "While"-"Wend" loops That's irrelevant. I've made loops using GOTO, and they work fine.Double-buffering (using the Flip command) requires you to redraw the entire screen every frame (Flip). If you don't want to redraw the entire screen every frame, then either don't use the Flip command (only draw to the front-buffer) or draw every change twice (draw commands / Flip / exact same draw commands). But you'll usually find that the second option is just too annoying in most cases and you'll choose to either draw to the frontbuffer only, or redraw the entire screen every frame. |
| ||
I agreee with Wolron in that the main loop type doesn't usually matter. It does matter sometimes though, as a Repeat - Until will always go once whereas a While - Wend can sometimes never go if the While clause is not met. Goto loops are non-standard but do work. I also wonder if anyone has ever made a For - Next loop and adjusted the main For variable so that it never reaches the end of the loop. Wolron: Problem with his code is that if he doesn't use flip, the user'll see nothing! |
| ||
I took the liberty of rewriting your code as an exampleGraphics 800,600 LoopExit = 0 While Not LoopExit Cls Text 0,0, "Why did you open this stupid program?" y=12 Text 0,y, "Press Enter to exit." y=y + 12 ;repeat until user hits enter If KeyHit(28) Then LoopExit = 1 Flip Wend Text 0,y, "Program is ending." Flip ;wait 2 seconds Delay 2000 It doesn't quite do the same thing but should give you an idea of how things work normally. Note that the CLS isn't really needed as the text always appears in the same place, but in most game loops it is needed. My code doesn't keep printing the "Press enter" line, but why would you want to? |
| ||
i see how you've cleaned up the problem there Alien. And you're right, why would anyone want to re-print the same text over and over again? Normally you wouldnt want to, but that was the point of this exercise. Just to teach how to use the Repeat...Until loop. I'm still lost on this one, but such is the life of a new programmer. -adam |
| ||
You have a NES stuck in your code somewhere? :P |
| ||
yeah, im pretty sure its a Nintendo Virus...lol j/k i hadnt even thought of that. -adam |