AppTitle "Space Invaders example by Eikon 02.11.05" Graphics 640, 300, 16, 2 SetBuffer BackBuffer() SeedRnd MilliSecs() Type Obj Field X%, Y%, D%, ID% End Type ; Create Aliens For b = 20 To 80 Step 20 For a = 20 To 200 Step 20 o.Obj = New Obj o\X = a: o\Y = b: o\D = 1: o\ID = 1 Next Next While Not KeyDown(1) ; Render Aliens For o.Obj = Each Obj Select o\ID Case 1 ; Alien Color 0, 255, 0: Text o\X, o\Y, "A" ; Movement If o\D = 1 Then o\X = o\X + 2 Else o\X = o\X - 2 If o\X >= 600 And o\D = 1 Then o\Y = o\Y + 20: o\D = 0 If o\X <= 20 And o\D = 0 Then o\Y = o\Y + 20: o\D = 1 ; Firing If Rand(1, 1000) = 500 Then CreateBullet o\X, o\Y If o\Y > 300 Then Delete o Case 2 ; Bullet Color 255, 255, 255: Rect o\X, o\Y, 1, 1 o\Y = o\Y + 3 If o\Y > 300 Then Delete o End Select Next Delay 5 Flip: Cls Wend: End Function CreateBullet(x, y) o.Obj = New Obj o\X = x + 3: o\Y = y + 5: o\ID = 2 End Function