04-12-2010, 12:34 PM
This tutorial took me about two hours to write so please show some appreciation.
Note: I myself have only made two game maps, as they are pretty advanced. Good luck, all will go smooth if you follow this properly.
Step 1.
The first thing you need to do is create a class title "BasicTile" (BasicTile.vb).
Now you will have this:
Step 2.
The next thing you must do is set the BasicTile class to inherit from the "Tile" Class.
To do this Insert "Inherits Tile" In between "Public Class BasicTile" and "End Clas".
You will now have this:
Note: The Inherit statement must be on it's own line or your will receive an error.
Step 3.
Now Vb.net should prompt you to create a constructor for the default parent class.
We shall call it "Tile's Constructor".
Make sure you have this code:
Step 4.
Now that the basic floor tiles are setup, we need to create a wall tile.
Create a class called "WallTile" (WallTile.vb)
Use this as the code:
Step 5.
The last basic tile to create is a blank tile. This is used to cover any excess space in the map.
Make a class called "BlankTile"...(BlankTile.vb)
Use this code:
Step 6.
This begins to get tricky
Now that we have our three basic tiles, we need to create the map array.
We will make the field for the map 60 x 20:
Step 7.
Now for the actual map. We are going to make a square room occupying the whole area. This requires a loop for the x-coordinates and another loop within that for the y-coordinates. At the edge of the map we will simply place, "WallTille", and we will fill the rest with "BlankTile".
Put in a method calle "CreateBasicMap"
Step 8.
Now to create that loop.
Call it. "Createbasicmap" in: "main".
Easy enough right?
Step 9.
Now we are going to draw the screen
We'll put the in a another method, so we do not to clog up Main. The method will be called "DrawMap":
This tutorial took me about two hours to write so please show some appreciation.
Note: I myself have only made two game maps, as they are pretty advanced. Good luck, all will go smooth if you follow this properly.
Step 1.
The first thing you need to do is create a class title "BasicTile" (BasicTile.vb).
Now you will have this:
Step 2.
The next thing you must do is set the BasicTile class to inherit from the "Tile" Class.
To do this Insert "Inherits Tile" In between "Public Class BasicTile" and "End Clas".
You will now have this:
Note: The Inherit statement must be on it's own line or your will receive an error.
Step 3.
Now Vb.net should prompt you to create a constructor for the default parent class.
We shall call it "Tile's Constructor".
Make sure you have this code:
Step 4.
Now that the basic floor tiles are setup, we need to create a wall tile.
Create a class called "WallTile" (WallTile.vb)
Use this as the code:
Step 5.
The last basic tile to create is a blank tile. This is used to cover any excess space in the map.
Make a class called "BlankTile"...(BlankTile.vb)
Use this code:
Step 6.
This begins to get tricky
Now that we have our three basic tiles, we need to create the map array.
We will make the field for the map 60 x 20:
Step 7.
Now for the actual map. We are going to make a square room occupying the whole area. This requires a loop for the x-coordinates and another loop within that for the y-coordinates. At the edge of the map we will simply place, "WallTille", and we will fill the rest with "BlankTile".
Put in a method calle "CreateBasicMap"
Step 8.
Now to create that loop.
Call it. "Createbasicmap" in: "main".
Easy enough right?
Step 10.
More loops.
The outermost loop goes by row, and the inner loop goes by column. At the start of each iteration of the outer loop, we set the cursor to the beginning of the appropriate row. As we draw the tiles, the cursor will automatically shift right.
Create another method called, "DrawTile"
Input the code:
Be active and look for part two! It might be up by the end of the night, if not tomorrow!
Hockey
Note: I myself have only made two game maps, as they are pretty advanced. Good luck, all will go smooth if you follow this properly.
Step 1.
The first thing you need to do is create a class title "BasicTile" (BasicTile.vb).
Now you will have this:
Code:
Public Class BasicTile
End Class
Step 2.
The next thing you must do is set the BasicTile class to inherit from the "Tile" Class.
To do this Insert "Inherits Tile" In between "Public Class BasicTile" and "End Clas".
You will now have this:
Code:
Public Class BasicTile
Inherits Tile
End Class
Note: The Inherit statement must be on it's own line or your will receive an error.
Step 3.
Now Vb.net should prompt you to create a constructor for the default parent class.
We shall call it "Tile's Constructor".
Make sure you have this code:
Code:
Public Sub New()
MyBase.New(".", ConsoleColor.Gray, ConsoleColor.Black, True)
End Sub
Step 4.
Now that the basic floor tiles are setup, we need to create a wall tile.
Create a class called "WallTile" (WallTile.vb)
Use this as the code:
Code:
Public Class WallTile
Inherits Tile
Public Sub New()
MyBase.New("#", ConsoleColor.Gray, ConsoleColor.Black, False)
End Sub
End Class
Step 5.
The last basic tile to create is a blank tile. This is used to cover any excess space in the map.
Make a class called "BlankTile"...(BlankTile.vb)
Use this code:
Code:
Public Class BlankTile
Inherits Tile
Public Sub New()
MyBase.New(" ", ConsoleColor.Black, ConsoleColor.Black, False)
End Sub
End Class
Step 6.
This begins to get tricky
Now that we have our three basic tiles, we need to create the map array.
We will make the field for the map 60 x 20:
Code:
Dim map(59, 19) As Tile
Step 7.
Now for the actual map. We are going to make a square room occupying the whole area. This requires a loop for the x-coordinates and another loop within that for the y-coordinates. At the edge of the map we will simply place, "WallTille", and we will fill the rest with "BlankTile".
Put in a method calle "CreateBasicMap"
Code:
Sub CreateBasicMap()
' Get the x- and y- coordinates for the right and bottom
' edges of the map
Dim xLimit As Integer = map.GetUpperBound(0)
Dim yLimit As Integer = map.GetUpperBound(1)
For x As Integer = 0 To xLimit
For y As Integer = 0 To yLimit
If x = 0 Or x = xLimit Or y = 0 Or y = yLimit Then
map(x, y) = New WallTile()
Else
map(x, y) = New BasicTile()
End If
Next
Next
End Sub
Step 8.
Now to create that loop.
Call it. "Createbasicmap" in: "main".
Code:
CreateBasicMap()
Easy enough right?
Step 9.
Now we are going to draw the screen
We'll put the in a another method, so we do not to clog up Main. The method will be called "DrawMap":
Code:
Sub DrawMap()
For y As Integer = 0 To map.GetUpperBound(1)
Console.SetCursorPosition(0, y)
For x As Integer = 0 To map.GetUpperBound(0)
DrawTile(x, y)
Next
Next
End Sub
This tutorial took me about two hours to write so please show some appreciation.
Note: I myself have only made two game maps, as they are pretty advanced. Good luck, all will go smooth if you follow this properly.
Step 1.
The first thing you need to do is create a class title "BasicTile" (BasicTile.vb).
Now you will have this:
Code:
Public Class BasicTile
End Class
Step 2.
The next thing you must do is set the BasicTile class to inherit from the "Tile" Class.
To do this Insert "Inherits Tile" In between "Public Class BasicTile" and "End Clas".
You will now have this:
Code:
Public Class BasicTile
Inherits Tile
End Class
Note: The Inherit statement must be on it's own line or your will receive an error.
Step 3.
Now Vb.net should prompt you to create a constructor for the default parent class.
We shall call it "Tile's Constructor".
Make sure you have this code:
Code:
Public Sub New()
MyBase.New(".", ConsoleColor.Gray, ConsoleColor.Black, True)
End Sub
Step 4.
Now that the basic floor tiles are setup, we need to create a wall tile.
Create a class called "WallTile" (WallTile.vb)
Use this as the code:
Code:
Public Class WallTile
Inherits Tile
Public Sub New()
MyBase.New("#", ConsoleColor.Gray, ConsoleColor.Black, False)
End Sub
End Class
Step 5.
The last basic tile to create is a blank tile. This is used to cover any excess space in the map.
Make a class called "BlankTile"...(BlankTile.vb)
Use this code:
Code:
Public Class BlankTile
Inherits Tile
Public Sub New()
MyBase.New(" ", ConsoleColor.Black, ConsoleColor.Black, False)
End Sub
End Class
Step 6.
This begins to get tricky
Now that we have our three basic tiles, we need to create the map array.
We will make the field for the map 60 x 20:
Code:
Dim map(59, 19) As Tile
Step 7.
Now for the actual map. We are going to make a square room occupying the whole area. This requires a loop for the x-coordinates and another loop within that for the y-coordinates. At the edge of the map we will simply place, "WallTille", and we will fill the rest with "BlankTile".
Put in a method calle "CreateBasicMap"
Code:
Sub CreateBasicMap()
' Get the x- and y- coordinates for the right and bottom
' edges of the map
Dim xLimit As Integer = map.GetUpperBound(0)
Dim yLimit As Integer = map.GetUpperBound(1)
For x As Integer = 0 To xLimit
For y As Integer = 0 To yLimit
If x = 0 Or x = xLimit Or y = 0 Or y = yLimit Then
map(x, y) = New WallTile()
Else
map(x, y) = New BasicTile()
End If
Next
Next
End Sub
Step 8.
Now to create that loop.
Call it. "Createbasicmap" in: "main".
Code:
CreateBasicMap()
Easy enough right?
Step 10.
More loops.
The outermost loop goes by row, and the inner loop goes by column. At the start of each iteration of the outer loop, we set the cursor to the beginning of the appropriate row. As we draw the tiles, the cursor will automatically shift right.
Create another method called, "DrawTile"
Input the code:
Code:
Sub DrawTile(ByVal x As Integer, ByVal y As Integer)
Console.ForegroundColor = map(x, y).ForeGroundColor
Console.BackgroundColor = map(x, y).BackgroundColor
Console.Write(map(x, y).Symbol)
Console.ResetColor()
End Sub
Be active and look for part two! It might be up by the end of the night, if not tomorrow!
Hockey