The game is working perfect. There is only one small problem. On the long run the game is starting to slow down.
I have timed all the procedures that i using and only one procedure is causing this problem. But when i look at the code there is no reason why this can happend here.
The procedure is:
Code: Select all
Procedure MakeField()
Protected x.i,y.i
Protected x1.i,y1.i
Protected Color.i
DisplaySprite(Spr_BackGround,0,0)
;Put everthing in the field what is visable
StartTime = ElapsedMilliseconds() ;-----------------------------------
For x = 0 To 39
For y = 0 To 39
If Field(x,y) > 0 And field(x,y) < 3
DisplaySprite(Spr_Wall(Field(x,y)),x*32,y*32)
EndIf
If Not(ExplosionActive)
If x= tank1()\FieldX And y = Tank1()\FieldY
DisplayTransparentSprite(Spr_Tank1(Tank1()\Direction),x*32+Tank1()\PosX,y*32+Tank1()\PosY)
EndIf
If x= tank2()\FieldX And y = Tank2()\FieldY
DisplayTransparentSprite(Spr_Tank2(Tank2()\Direction),x*32+Tank2()\PosX,y*32+Tank2()\PosY)
EndIf
EndIf
If Field(x,y) > 9 And Field(x,y) < 14
DisplayTransparentSprite(Spr_PickUp(Field(x,y)-10),x*32,y*32)
EndIf
Next
Next
EndTime = ElapsedMilliseconds() ;------------------------------------------
Between = EndTime - StartTime
;Work on the bonus picked up
UpdateShield()
UpdateRocket()
UpdateBouncing()
;The wall that are shoot away
UpdateWall()
;Explosions General
UpdateExplosionSmall()
UpdateExplosionLarge()
;Display health bar above the tanks
HealtBarTank1()
HealtBarTank2()
;Display Bonus if picked up by tanks
BonusAtTank1()
BonusAtTank2()
;Colliding tank vs tank
TankColliding()
;Move shell over screen
ShowShell1()
ShowShell2()
;Check hitting Something for Tanks
CollideTank1()
CollideTank2()
;Create viewport 1 and 2
CreateViewPort1()
CreateViewPort2()
EndProcedure
The Sprites and images are not changed during the game. The viewports are sprite that are grabed.
The screen is in windows mode, and because of the 2 viewports its 800 * 460. The screen to work in is 1500 * 1500. This is bigger than the viseble part but all is down on the background. When the viewports are made all is cleared and the view ports are made. Then the screen is flipped and then cleared.
When i see the code i see no reason why this part is slowing down.