I have an somewhat large image, refreshing repeditivly, it manages to flicker, is there any simple ways of fixing this? Thanks,
___
Dan
Printable View
I have an somewhat large image, refreshing repeditivly, it manages to flicker, is there any simple ways of fixing this? Thanks,
___
Dan
I think you mean BitBlt, here's what I did:
Set form1.autorefresh = true
Now set that for all of your source images.
Then at the end of all your BitBlt procedures (I assume your're running this in a loop) add form1.refresh
That should remove the flicker. If not please post a zip of your project and I'll see if I can help.
Im not one to put my game in a entire loop (which im told is a good idea), i just dont like the thought of no control of speed/time, anyways il try it.
beautiful, thanks, but that loop think sparked my mind, anyone feel like they can explain a little about it?
Sure.
You have the program continuing to run through this loop and it calls all your subs in a certain order. Here's an example from one of my games:
VB Code:
Private Sub Timer1_Timer() 'This timer is the backbone of the whole program, it controlls all of its functions If GamePaused = True Then 'Don't run this loop if the game is paused Exit Sub End If BitBlt Form1.hDC, 0, I, picback1.ScaleWidth, _ picback1.ScaleHeight, picback1.hDC, 0, 0, vbSrcCopy 'Draws the background I = I + 1 'This moves the background down a pixel, I have a nice scrolling background in this game BitBlt Form1.hDC, 0, J, picBack2.ScaleWidth, _ picBack2.ScaleHeight, picBack2.hDC, 0, 0, vbSrcCopy 'Draws the second frame of the background, don't bother asking J = J + 1 'Moves it back a pixel, again, don't ask why I'm doing this twice If I = 539 Then 'Just ignore this, you'd have to see my project to understand this I = -600 End If If J = 539 Then 'Ignore this too! J = -600 End If 'Ship Move 'I hardcoded the ship movement procedure in to this sub If Pause = False And GameOver = False Then If Up = True And ShipY - ShipSpeed(ShipType) > 0 Then ShipY = ShipY - ShipSpeed(ShipType) End If If Down = True And ShipY + ShipHeight + ShipSpeed(ShipType) < Form1.ScaleHeight Then ShipY = ShipY + ShipSpeed(ShipType) End If If vLeft = True And ShipX - ShipSpeed(ShipType) > 0 Then ShipX = ShipX - ShipSpeed(ShipType) End If If Right = True And ShipX + ShipWidth + ShipSpeed(ShipType) < 397 Then ShipX = ShipX + ShipSpeed(ShipType) End If End If ExplosionDrift 'Moves the explosions down a pixel AnimateGameOver 'If it is the game over this will run the game over image through it's frames (if check is located in the procedure) EnemyFire 'Enemy firing procedure RenderExplosions 'Explosion Rendering procedure RenderEnemies 'Enemy Rendering procedure MoneyDrift 'drifts the money down a pixel RenderMoney 'Renders the Money power up procedure MoveBullets 'Move Bullets procedure RenderBullets 'Render Bullets procedure If RenderShip = True Then 'Hard coded the rendering of the ship in here BitBlt Form1.hDC, ShipX, ShipY, picshipMask(ShipType).ScaleWidth, _ picshipMask(ShipType).ScaleHeight, picshipMask(ShipType).hDC, 0, 0, vbSrcAnd 'Draw Ship BitBlt Form1.hDC, ShipX, ShipY, picShip(ShipType).ScaleWidth, _ picShip(ShipType).ScaleHeight, picShip(ShipType).hDC, 0, 0, vbSrcPaint 'Draw Ship End If RenderGameOver 'This sub shows the game over image if the game is over (the if check is located in the sub) Form1.Refresh End Sub
Hope this helps, ask questions if you must.
Why wouldnt u get rid of the timer and put a do loop, everyone says loops are better than timers, is this true?
I'm actually planning on using a do loop when I rewrite this to use API timing.
However, for my game it was simpler to just put the code in the timer. Then I know pretty much exactly how often this code would execute. As opposed to in a Do loop the code would be executed as fast as it could, with no wait time in between executions. That would eat up resources and slow down the whole computer.
So I just followed the KISS rule, Keep It Super Simple.