my programs very slow

BlitzPlus Forums/BlitzPlus Programming/my programs very slow

This runs real fast for me...even with text.

Keep in mind people, just because there is a few text commands doesn't mean the program will slow to a crawl...text is ok for small things like what he is doing.

Also, you had the wrong scancode for the down arrow.

Const scr_w = 640
Const scr_h = 480

Graphics scr_w, scr_h,32,1
SetBuffer BackBuffer()

Const UPKEY = 200,LEFTKEY = 203, RIGHTKEY = 205, DOWNKEY = 208 , SPACEBAR = 57
Const ship1$ = "<V>"
Const bullet1$ = " ."
Const enemy1$ = "<><>"

Type ship
	Field x,y
End Type

Type bullets
	Field x,y
End Type

Type enemys
	Field x,y
	Field movx,movy
End Type

Global player.ship = New ship
Global enemy.enemys = New enemys

enemy\x=100
enemy\y=Rnd(200,400)

While Not KeyDown(1)
	Cls

	If KeyDown(LEFTKEY)
		player\x = player\x - 3
	EndIf

	If KeyDown(RIGHTKEY)
		player\x = player\x + 3
	EndIf
	
	If KeyDown(UPKEY)
		player\y = player\y - 3
	EndIf
	
	If KeyDown(DOWNKEY)
		player\y = player\y + 3
	EndIf
	
	If KeyHit(SPACEBAR)
		bullet.bullets = New bullets
		bullet\x = player\x
		bullet\y = player\y
	EndIf

	drawship()
	testbullets()
	drawenemy()

	Flip
Wend





Function drawship()

	Color 0,255,0

	Text player\x,player\y,ship1$
	If player\x < 0
		player\x = 0
	EndIf

	If player\x > scr_w
		player\x = scr_w
	EndIf

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

	If player\y > scr_h
		player\y = scr_h
	EndIf
	
End Function

Function testbullets()
	For bullet.bullets = Each bullets
		bullet\y = bullet\y + 5
		If bullet\y > scr_h
			Delete bullet
		Else
			Color 255,255,255
			Text bullet\x,bullet\y,bullet1$
		EndIf
	Next
End Function

Function drawenemy()
	enemy\movx = Rnd(-3,3)
	enemy\movy = Rnd(-3,3)
	enemy\x = enemy\x + enemy\movx
	If enemy\x < 0 Or enemy\x > scr_w
		enemy\movx = -enemy\movx
	EndIf
	
	Color 255,255,0
	Text enemy\x,enemy\y,enemy1$
End Function 



-cbmeeks