Flickering background
BlitzMax Forums/BlitzMax Beginners Area/Flickering background
| ||
Hi, I have the following code which animates a sprite.I wanted to add a background using LoadImage but it continually flickers.Any suggestions why 'image' flickers ? Thanks in advance. [/code] Graphics 800,600 'set gfx mode Global FrameTimer = MilliSecs() Global frame:Int = 0 Global x:Int =0 Global myimage:TImage = LoadAnimImage("ko1.png",32,32,0,240) Local image:TImage=LoadImage("pitch.png",flags=-1) DrawImage image:TImage,0,0,frame Flip sound=LoadSound("bouncy.ogg") PlaySound sound Repeat 'Cls DrawImage myimage,x,50,frame If MilliSecs() > FrameTimer + 100 FrameTimer = MilliSecs() frame:+1 EndIf If frame >239 Then frame = 0 Flip FlushMem Until KeyHit(KEY_ESCAPE) soundover = LoadSound ("gameover.ogg") PlaySound soundover[/code] |
| ||
You've commented out your cls command and you don't draw your 'pitch' within the mainloop. |
| ||
You need the background drawing command inside the main loop. |
| ||
Yeah I had that same issue: I see you didnt call Cls and expect what you have drawn to be still on the double buffer: well that does not happen because opengl sometimes uses a triple buffer when in full screen. If you use window mode (Graphics 800,600,0) it wont flicker. |