Jump to content


Photo

VB.NET (08) - Spawning Objects


  • Please log in to reply
No replies to this topic

#1 Zuriki

Zuriki

    Young Padawan

  • Members
  • Pip
  • 1 posts

Posted 22 October 2009 - 11:50 AM

Okay, so I have a class named Tiles, within that class is a function called newWorld which is designed to spawn a tonne of tiles.

Here is a look at what I have so far

Public Class Tiles

	Shared Function newWorld(ByVal WIDTH As Integer, ByVal HEIGHT As Integer)
		Dim n As Integer = 0
		Dim COL As Integer = 0
		Dim ROW As Integer = 0
		Try
			Dim j As Integer = 0
			For i As Integer = 0 To (WIDTH * HEIGHT)
				Dim TILE() As Object
				TILE(n) = New PictureBox
				TILE(n).Name = "TILE" + n.ToString
				TILE(n).Width = 32
				TILE(n).Height = 32
				TILE(n).ImageLocation = "./images/tiles/dirt.png"
				TILE(n).Location = New Point(COL * 32, ROW * 32)
				j = j + 1
				ROW = ROW + 1
				n = n + 1
				If (j = WIDTH) Then
					ROW = 0
					COL = COL + 1
				End If
			Next
			Return 0
		Catch ex As Exception
			Main.Label1.Text = ex.ToString
			Return ex
		End Try
	End Function

End Class

This function is called in

Public Class Main

	Private Sub Main_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
		Tiles.newWorld(32, 32)
	End Sub

End Class

At present it doesn't do anything an just returns a null pointer exception. (That's displayed in Label1 on the Main form).




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users