Module Module1
Sub Main()
Dim x, y, ax, ay, skor, i
Dim x2, y2
Randomize()
Dim s
s = 300
x2 = CInt(Rnd() * 70) + 2
y2 = CInt(Rnd() * 21) + 2
Dim tombol As Integer
For i = 1 To 24
Console.BackgroundColor = ConsoleColor.Blue
Console.CursorLeft = 0
Console.CursorTop = i
Console.Write(" ")
Console.CursorLeft = 78
Console.CursorTop = i
Console.Write(" ")
Next
For i = 0 To 78
Console.CursorLeft = i
Console.CursorTop = 1
Console.Write(" ")
Console.CursorLeft = i
Console.CursorTop = 24
Console.Write(" ")
Next
skor = 0
x = 40
y = 12
ax = 0
ay = 0
Console.BackgroundColor = ConsoleColor.Black
Do
Console.CursorLeft = x2
Console.CursorTop = y2
Console.Write("$")
Console.CursorLeft = 10
Console.CursorTop = 0
Console.Write("skor : " & skor)
Console.CursorLeft = x
Console.CursorTop = y
Console.Write("~")
System.Threading.Thread.Sleep(s)
Console.CursorLeft = x2
Console.CursorTop = y2
Console.Write(" ")
Console.CursorLeft = x
Console.CursorTop = y
Console.Write(" ")
x = x + ax
y = y + ay
If (Console.KeyAvailable) Then
tombol = Console.ReadKey.Key
If tombol = 38 Then
ay = -1
ax = 0
ElseIf tombol = 40 Then
ay = 1
ax = 0
ElseIf tombol = 37 Then
ay = 0
ax = -1
ElseIf tombol = 39 Then
ay = 0
ax = 1
End If
End If
If (y <= 1 Or x <= 1 Or x >= 78 Or y >= 24) Then
Console.CursorTop = 12
Console.CursorLeft = 30
Console.Write("Game Over")
tombol = Console.ReadKey.Key
If tombol <> 32 Then
tombol = 27
Else
skor = 0
Console.CursorTop = 12
Console.CursorLeft = 30
Console.Write(" ")
x = 40
y = 12
ax = 0
ay = 0
End If
End If
If x = x2 And y = y2 Then
skor = skor + 10
x2 = CInt(Rnd() * 70) + 2
y2 = CInt(Rnd() * 21) + 2
End If
Loop While (tombol <> 27)
Console.ReadKey()
End Sub
End Module
0 komentar:
Posting Komentar