graphics too slow PLEASE HELP!!!

Community Forums/General Help/graphics too slow PLEASE HELP!!!

rmid(Posted 2014) [#1]
so im making an invaders type of shooting game and I noticed that
the graphics run 10x slower on my windows 8 vs my windows 7 laptop. what is the issue here?


rmid(Posted 2014) [#2]
Graphics 800,600

Type TSHIP
Field X
Field Y
End Type

Global player.tship= New TSHIP
player\x=shipx
player\y=shipy

Global enemyship.tship= New TSHIP
enemyship\x= enemyx
enemyship\y= enemyy


Type TBULLET
Field X
Field Y
Field IMAGE
End Type









;------------------------------------------------------------variables--------------------------------------------
.variables

Global music= LoadSound("sound.ogg")
Global menu= LoadImage("menu.png")
Global stars= LoadImage("stars1.png")
Global stars2=LoadImage("stars2.png")
Global playerim= LoadImage("ship.png")
Global enemy= LoadImage("enemy.png")
Global bulletim=LoadImage("bullet.png")
Global explosion=LoadAnimImage("explosion.png",100,100,0,8)
Global directions=LoadImage("directions.png")
Global explosion1=LoadAnimImage("explosion2.png",100,100,0,1)
Global scrolly=0
Global level=1
Global lives=3
Global gameover=0
Global hits#=5.0
Global env#=2
Global frame=0

Const shipx=250
Const shipy=290
Const enemyx=600
Const enemyy=100




PlaySound music












;-----------------------------------------------------------intro loop-----------------------------
While Not KeyHit(28)
Cls
TileImage stars ,0,scrolly
TileImage stars2 ,0,scrolly*2
TileImage menu
scrolly=scrolly+1
Flip
Wend

Repeat

Cls
TileImage directions
Flip
Until KeyHit(28)






;---------------------------------------------------mainloop----------------------------------
.mainloop

While Not KeyDown(1) Or gameover=1

Cls
level()
drawstars()

drawhud()
testinput()
updatebullet()
collision()


DrawImage playerim,player\x,player\y
DrawImage enemy,enemyship\x,enemyship\y


Flip
Wend
;----------------------------animloop_______________










;---------------------------------------------------functions---------------------------------------------

Function drawhud()

Text 730,10,"Lives:"+lives
Text 730,20,"Level:"+level
Text 730,30,"hits:"+hits
Text 0,0,"press esc to quit"

End Function





Function drawstars()

TileImage stars ,0,scrolly
TileImage stars2 ,0,scrolly*2
scrolly=scrolly+1

End Function








Function testinput()
;-----testkeyplayer----

If KeyDown(205)
player\x=player\x+5

ElseIf KeyDown(203)
player\x=player\x-5

ElseIf KeyDown(208)
player\y=player\y+5

ElseIf KeyDown(200)
player\y=player\y-5
EndIf

;-----if it goes off the screen---

If player\x>= 800
player\x=790
EndIf

If player\x<=0
player\x=5
EndIf

If player\y>=600
player\y=590
EndIf

If player\y<= 0
player\y=5
EndIf



;------enemy follow-----

If player\x>enemyship\x
enemyship\x= enemyship\x +2
EndIf

If player\x<enemyship\x
enemyship\x=enemyship\x-2
EndIf

If player\y>enemyship\y
enemyship\y=enemyship\y+2
EndIf

If player\y<enemyship\y
enemyship\y=enemyship\y-2
EndIf




;-----bulletinput----
If KeyHit(57)
bullet.tbullet= New TBULLET
bullet\x=player\x
bullet\y=player\y
EndIf

End Function

Function updatebullet()

For bullet.tbullet= Each TBULLET
bullet\y=bullet\y-7
DrawImage bulletim,bullet\x,bullet\y
Next

End Function








Function collision()

For bullet.tbullet= Each TBULLET
If ImagesCollide(bulletim,bullet\x,bullet\y,0,enemy,enemyship\x,enemyship\y,0)
explosion2()
hits#=hits#-.15
frame=0
EndIf
Next

If hits#<=0
level=level+1
If level=2
hits#=hits#+7
EndIf
If level=3
hits#=hits#+10
EndIf
If level=4
hits#=hits#+15
EndIf
If level=5
hits#=hits#+19
EndIf
Cls
Text 400,300,"Great! on to level:"+level
Text 400,310,"Enemy Strength + 5!!!"
Flip
Delay 5000
reset()
EndIf


If ImagesCollide(playerim,player\x,player\y,0,enemy,enemyship\x,enemyship\y,0)
explosion()


Delay 500
Cls
reset()
lives=lives-1
EndIf
If lives=0
gameover()
EndIf

End Function









Function reset()


player\x=shipx
player\y=shipy

enemyship\x= enemyx
enemyship\y= enemyy
frame=0
End Function




Function level()

End Function


Function gameover()
Text 400,300,"gameover"
Flip
Delay 5000
gameover=1
Cls

End Function


Function explosion()

Repeat
DrawImage explosion,player\x,player\y,frame
Flip
frame=frame+1
Until frame=8
End Function


Function explosion2()
Repeat
DrawImage explosion,enemyship\x,enemyship\y,frame
Flip
frame=frame+1
Until frame=1
End Function


Derron(Posted 2014) [#3]
If your game runs at different fps on different computers it is most likely not a fault of the code logic.

- driver/engine issues (dx7 on windows8, opengl with gpu drivers which do not like opengl)
- vsync on/off and wrong flip-calls. If the FPS is on one 59/60/70/... and on the other one 220, it is vsync. But if the fps value are lower than a normal refresh rate, this isnt the source of the differing fps values

in your case not used: wrong timer logic, so your manual delays wont work on some computers with negative time values. Like said: not used in your code.


bye
Ron


GfK(Posted 2014) [#4]
If you're using Blitz3D (and I don't know because you haven't said - it helps to post in the correct programming forum for specific language issues), there was an update to resolve speed issues under Windows 8. Go to Account>Product Updates, and download at least Blitz3D v1.107 (a full install of Blitz3D 1.108 is also available but I've no idea what the differences are).