ArcBasicDocs

tutorials/beginner

07_ship.abs

38 lines of ArcBasic. Words in colour that are commands link to their help page. To run it, download ArcBasic, open the file and press F5.

Download 07_ship.absAll files in this folder

07_ship.abs
; Moving a ship with the keyboardGraphics 640, 480SetBuffer BackBuffer()x = 300 : y = 400speed = 5r = 90 : g = 200 : b = 255While Not KeyHit(1)	; arrow keys: held down = keep moving	If KeyDown(203) Then x = x - speed      ; left	If KeyDown(205) Then x = x + speed      ; right	If KeyDown(200) Then y = y - speed      ; up	If KeyDown(208) Then y = y + speed      ; down	; space: pressed once = one change	If KeyHit(57) Then r = Rand(50, 255) : g = Rand(50, 255) : b = Rand(50, 255)	; stay on the screen	If x < 0 Then x = 0	If x > 600 Then x = 600	If y < 0 Then y = 0	If y > 450 Then y = 450	Cls	Color r, g, b	Rect x, y + 10, 40, 20          ; body	Rect x + 15, y, 10, 10          ; cockpit	Color 255, 140, 0	Rect x + 5, y + 30, 6, 6        ; flames	Rect x + 29, y + 30, 6, 6	Color 255, 255, 255	Text 10, 10, "Arrows move, Space changes colour, Escape quits"	FlipWendEnd