Imports System.IO Public Class Form1 Dim background(15, 15) As Texture Dim row, column As Integer Dim MapWidth As Integer = 15 'Controls the number of tiles in each row of your map - You can change this to match the width of your map files Dim MapHeight As Integer = 15 'Controls the number of tiles in each column of your map - You can change this to match the height of your map files Dim TileWidth As Integer = 32 'Width, in Pixels of each tile - You could change this if you wanted smaller or larger sized tiles, but I would make certain it holds the same value as TileHeight Dim TileHeight As Integer = 32 Dim map(MapWidth, MapHeight) As String Dim x, y As Integer Dim Towers(200) As Tower Dim towerCount As Integer = 0 Dim Mapfile As StreamReader 'We use StreamReader to read our various map text files. We create an array of streamreaders, since each one holds a different map file Dim Money As Integer = 300 Dim Lives As Integer = 100 Dim Wave As Integer = 1 Dim bl(100) As Bloon Dim bcount As Integer = 0 Dim sc As Scoreboard Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Me.Size = New Size(696, 517) sc = New Scoreboard sc.Location = New Point(500, 50) Controls.Add(sc) updateScoreboard() loadMap() drawMap() End Sub Public Sub loadMap() x = 0 y = 0 Mapfile = New StreamReader("level1.txt") Using Mapfile Do While Mapfile.Peek() >= 0 For Each m As String In Mapfile.ReadLine map(x, y) = m x += 1 Next y += 1 x = 0 Loop End Using Mapfile.Close() End Sub Public Sub drawMap() For Me.x = 0 To MapWidth - 1 For Me.y = 0 To MapHeight - 1 background(x, y) = New Texture(x, y) background(x, y).type = map(x, y) Controls.Add(background(x, y)) background(x, y).drawTexture() AddHandler background(x, y).MouseEnter, AddressOf Highlight AddHandler background(x, y).MouseLeave, AddressOf Revert AddHandler background(x, y).Click, AddressOf AddTower Next Next End Sub Public Sub AddTower(ByVal sender As Object, ByVal e As EventArgs) Dim t As Texture = sender If t.occupied = False And Money > 99 Then Towers(towerCount) = New Tower(t.row, t.column) Controls.Add(Towers(towerCount)) Towers(towerCount).BringToFront() towerCount = towerCount + 1 Money = Money - 100 updateScoreboard() End If End Sub Public Sub Revert(ByVal sender As Object, ByVal e As EventArgs) Dim t As Texture = sender If t.type = "g" And t.occupied = False Then t.Image = Image.FromFile("grass.jpg") End If End Sub Public Sub Highlight(ByVal sender As Object, ByVal e As EventArgs) Dim t As Texture = sender If t.type = "g" Then t.Image = Image.FromFile("hgrass.jpg") End If End Sub Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick If bcount < 10 Then bl(bcount) = New Bloon() Controls.Add(bl(bcount)) bl(bcount).BringToFront() bcount = bcount + 1 End If End Sub Public Sub updateScoreboard() sc.MoneyLabel.Text = "Money: " & Money sc.LivesLabel.Text = "Lives: " & Lives sc.WaveLabel.Text = "Wave: " & Wave End Sub End Class