1000010111010
Printable View
1000010111010
10010011011101
1111001110000
1000010000011
10001010011110
1000001001010
101000111
110101101000
1100001011010
10100010101
11111010100
1001111011110
1111011001000
10011100001011
1110110101
11110100010
1110110011011
1101101111010
10010101010011
1010110110111
1100000111000
111001010000
10001110001
100001111010
1011001
1110001111100
1101011000010
101001001001
100000110100
10111110000
10100111010
110000111001
101011000111
10000110011011
1101001001
1110010111
1001111000011
1011110101111
110111110000
1000100101111
10010011110011
1001111000001
110101
1000000000
1111000010
11010011
1111001101000
1111010011001
1101001110010
1011010101111
1011000011101
1k Posts, representational governments for the win!
2345
FD, did you compile the code that I posted in that VB6 thread?
Errr, which one? There are about 3 or 4 at the moment and each is as pointless as the last. They're keeping me mildly amused in my more bored moments but I've got to the point where I'm just skimming them now.
This one:
Code:Option Strict On
Option Explicit On
Module Module1
Private Structure Obj
Public Property Character As Char
Public Property X As Integer
Public Property Y As Integer
End Structure
Private Structure Size
Public Property Height As Integer
Public Property Width As Integer
End Structure
Private asteroids As List(Of Obj)
Private keyThread As Threading.Thread
Private gameThread As Threading.Thread
Private playing As Boolean
Private r As Random
Private screenSize As Size
Private ship As Obj
Sub Main()
r = New Random
Do
Console.WriteLine("Press any key to start a new game.")
Console.ReadKey()
Call NewGame()
Do
Loop Until Not playing
Loop
End Sub
Private Sub NewGame()
asteroids = New List(Of Obj)
keyThread = New Threading.Thread(AddressOf KeyInput)
gameThread = New Threading.Thread(AddressOf GameLoop)
playing = True
screenSize = New Size
ship = New Obj
With screenSize
.Height = 10
.Width = 20
End With
With ship
.Character = "^"c
.X = screenSize.Width \ 2
.Y = screenSize.Height \ 2
End With
Call Draw()
keyThread.Start()
gameThread.Start()
End Sub
Private Sub MoveAsteroids()
For i As Integer = asteroids.Count - 1 To 0 Step -1
Dim asteroid As Obj = asteroids.Item(i)
asteroid.Y += 1
asteroids.Item(i) = asteroid
Next
End Sub
Private Sub NewAsteroid()
Dim newbie As Obj = New Obj
With newbie
.Character = "*"c
.X = r.Next(0, screenSize.Width + 1)
.Y = 0
End With
asteroids.Add(newbie)
End Sub
Private Sub CheckCollision()
For i As Integer = asteroids.Count - 1 To 0 Step -1
Dim asteroid As Obj = asteroids.Item(i)
If asteroid.Y = screenSize.Height + 1 Then
asteroids.RemoveAt(i)
ElseIf asteroid.X = ship.X AndAlso asteroid.Y = ship.Y Then
playing = False
End If
Next
End Sub
Private Sub Draw()
Console.Clear()
Console.CursorLeft = ship.X
Console.CursorTop = ship.Y
Console.Write(ship.Character)
For Each asteroid As Obj In asteroids
Console.CursorLeft = asteroid.X
Console.CursorTop = asteroid.Y
Console.Write(asteroid.Character)
Next
End Sub
Private Sub GameLoop()
Dim s As New Stopwatch
s.Start()
Call MoveAsteroids()
Call NewAsteroid()
Call CheckCollision()
Call Draw()
'Loop
While s.Elapsed <= TimeSpan.FromMilliseconds(16.6)
End While
s.Stop()
Debug.WriteLine(s.ElapsedMilliseconds)
If playing = True Then
gameThread = New Threading.Thread(AddressOf GameLoop)
gameThread.Start()
End If
End Sub
Private Sub KeyInput()
Do
Dim info As ConsoleKeyInfo = Console.ReadKey
If info.Key = ConsoleKey.LeftArrow AndAlso ship.X - 1 >= 0 Then
ship.X -= 1
ElseIf info.Key = ConsoleKey.RightArrow AndAlso ship.X + 1 <= screenSize.Width Then
ship.X += 1
End If
Loop Until Not playing
End Sub
End Module
Oh yes. I did see that and it definitely made me smile. Glad to see my challenge was accepted. It's probably less code than I used back in the day but I reckon the old ZXSpectrum command keys meant I did less typing :)
I haven't compiled it and probably won't get round to it as I surf mostly at work but I'll happily take your word for it that it does what it says on the tin.
It is pretty fun. You're a little ^ at the bottom and * fall from the top to the bottom. The only objective is to avoid hitting the *
In fact I will add it to the Game Demos forum too.
If we were on 4chan that would invite comment.Quote:
The only objective is to avoid hitting the *
Actually, you've persuaded me. I've gone all nostalgic and I'm at home now and need a break so I'm going to feed the cats and then give it a whirl.