Basic question: Variable output to scree
BlitzMax Forums/BlitzMax Beginners Area/Basic question: Variable output to scree
| ||
Hi, I want to see my variable x increase on screen.I thought this code would work well but nothing is output. To output a variable using drawtext I believe I reference it using the + symbol.Any ideas ? Graphics 800,600,0 'set gfx mode Local x=0 SetColor 255,255,255 Repeat x:+1 DrawText +x,100,100 cls Until x=400 |
| ||
try this:Graphics 800,600,0 'set gfx mode Local x=0 SetColor 255,255,255 Repeat Cls 'clear the buffer x:+1 DrawText +x,100,100 Flip 'flip the backbuffer to the front to display what we've drawn Until x=400 you were clearing the current buffer after drawing to it and you weren't Flipping it to the front. |
| ||
Thanks for the reply Perturbatio.Ahh that makes more sense.So I need to clear the buffer before I draw anything and always flip it afterwards ? something like this ? cls DrawImage pacman,x,y,frame Flip Cls DrawImage ko2sprite,x+50,y+10,frame Flip Cls DrawText +x,100,100 flip |
| ||
You need to clear it if you want to start with a blank buffer each frame. Some interesting effects can be achieved by rendering multiple times to the same frame before flipping. you always need to flip to display the frame. You could think of it as a double sided chalkboard, the side you're drawing to is not visible to the user but it is to the artist (you) and you need to flip it around to show what you've drawn. then you can wipe the other side clean whilst it's not in view and start drawing again. (a simplistic analogy but I *think* it makes sense) |
| ||
"(a simplistic analogy but I *think* it makes sense)" The very same analogy you'll find in all the text books ;) |
| ||
The very same analogy you'll find in all the text books ;) not bad considering I've never read it in a book :) |