Figured I'd mess with the UI of the main form and so far this is what I got :)
Not too bad for a first draft I'd say, I use those test buttons to, well, test pieces of code and they won't be there with the finished product. The text box will act as a log of what is happening in the game i.e. describing the area, showing damage, items looted, etc. For the rest of the buttons, they will open seperate forms in order to carry out their named function.
Thursday, 12 September 2013
What Level am I?
Decided to work on a way to determine what level the player character is based on what is their highest attribute level is (e.g. If agility is the highest then the player's level is equal to the level of agility)
So lets say that we have a strength level of 30, an agility level of 25 and an intelligence level of 20
Select Case Level
Case Level
If Strength > Agility And Strength > Intelligence Then
Level = Strength
If Agility > Strength And Agility > Intelligence Then
Level = Agility
If Intelligence > Strength And Intelligence > Agility Then
Level = Intelligence
End If
End If
End If
End Select
Using this case statement the program would determine that strength is the attribute with the highest value and thus is the level of the character
So lets say that we have a strength level of 30, an agility level of 25 and an intelligence level of 20
Select Case Level
Case Level
If Strength > Agility And Strength > Intelligence Then
Level = Strength
If Agility > Strength And Agility > Intelligence Then
Level = Agility
If Intelligence > Strength And Intelligence > Agility Then
Level = Intelligence
End If
End If
End If
End Select
Using this case statement the program would determine that strength is the attribute with the highest value and thus is the level of the character
The Trouble with Buttons
I was having a little trouble in figuring out how to be able to move my little square around whilst having buttons on the form as, by default, VB would set the arrow keys to switch between different buttons rather than moving the square.
After some research I came across this page and it helped me out :) http://social.msdn.microsoft.com/Forums/vstudio/en-US/2559319e-a9c4-4181-8a4e-3ed356189f84/disabling-arrow-keys-like-tabstop-with-buttons-answered
After some research I came across this page and it helped me out :) http://social.msdn.microsoft.com/Forums/vstudio/en-US/2559319e-a9c4-4181-8a4e-3ed356189f84/disabling-arrow-keys-like-tabstop-with-buttons-answered
Tuesday, 10 September 2013
Belated Update on Grid Drawing
Quite slow to update with this but I got VB to draw a 10x10 grid though I may end up going down a different route with this
Private Sub FrmMain_Paint(sender As Object, e As System.Windows.Forms.PaintEventArgs) Handles Me.Paint
'Declare local variables
Dim Graphicals As Graphics
Dim Rectangles As Rectangle
Dim PenColour As New Pen(Color.Red)
Graphicals = Me.CreateGraphics
For a As Integer = 1 To 9
For b As Integer = 1 To 9
Rectangles = New Rectangle(b * 52, a * 52, 50, 50)
Graphicals.DrawRectangle(Pens.Black, Rectangles)
Graphicals.FillRectangle(Brushes.ForestGreen, Rectangles)
Rectangles = Nothing
Next
Next
Graphicals.Dispose()
Graphicals = Nothing
End Sub
Private Sub FrmMain_Paint(sender As Object, e As System.Windows.Forms.PaintEventArgs) Handles Me.Paint
'Declare local variables
Dim Graphicals As Graphics
Dim Rectangles As Rectangle
Dim PenColour As New Pen(Color.Red)
Graphicals = Me.CreateGraphics
For a As Integer = 1 To 9
For b As Integer = 1 To 9
Rectangles = New Rectangle(b * 52, a * 52, 50, 50)
Graphicals.DrawRectangle(Pens.Black, Rectangles)
Graphicals.FillRectangle(Brushes.ForestGreen, Rectangles)
Rectangles = Nothing
Next
Next
Graphicals.Dispose()
Graphicals = Nothing
End Sub
Damage and Defence
Took a bit of a detour and decided to work on some of the equations for calculating damage and armour :D
Its still a bit of a prototype and we are just using some placeholder numbers here but the basic idea of these stats is that pure damage of the attacker is first calculated and then a seperate calculation for the armour rating of the person receiving the damage. And then we do damage - armour to get the amount of reduced damage of the armoured target.
Damage Calculation
Private Sub BtnTest_Click(sender As System.Object, e As System.EventArgs) Handles BtnTest.Click
Randomize()
Dim Attribute, Strength, Power, Damage As Integer
Attribute = 30
Strength = 30
Power = 350
Dim PhyDmgV As Integer = CInt(Int((((Attribute * 1.7) - (Attribute / 2.5)) * Rnd()) + 1))
Damage = Strength * Power * PhyDmgV
MsgBox("Damage equals " & Damage)
End Sub
Defence Calculation
PrivateSub BtnTest_Click(sender As System.Object, e As System.EventArgs) Handles BtnTest.Click
Randomize()
Dim Attribute, Strength, Armour, Defence As Integer
Attribute = 30
Strength = 30
Armour = 180
Dim PhysDefV As Integer = CInt(Int((((Attribute * 1.5) - (Attribute / 2)) * Rnd()) + 1))
Defence = Attribute * Strength * PhysDefV
MsgBox("Defence value is " & Defence)
End Sub
Its still a bit of a prototype and we are just using some placeholder numbers here but the basic idea of these stats is that pure damage of the attacker is first calculated and then a seperate calculation for the armour rating of the person receiving the damage. And then we do damage - armour to get the amount of reduced damage of the armoured target.
Damage Calculation
Private Sub BtnTest_Click(sender As System.Object, e As System.EventArgs) Handles BtnTest.Click
Randomize()
Dim Attribute, Strength, Power, Damage As Integer
Attribute = 30
Strength = 30
Power = 350
Dim PhyDmgV As Integer = CInt(Int((((Attribute * 1.7) - (Attribute / 2.5)) * Rnd()) + 1))
Damage = Strength * Power * PhyDmgV
MsgBox("Damage equals " & Damage)
End Sub
Defence Calculation
PrivateSub BtnTest_Click(sender As System.Object, e As System.EventArgs) Handles BtnTest.Click
Randomize()
Dim Attribute, Strength, Armour, Defence As Integer
Attribute = 30
Strength = 30
Armour = 180
Dim PhysDefV As Integer = CInt(Int((((Attribute * 1.5) - (Attribute / 2)) * Rnd()) + 1))
Defence = Attribute * Strength * PhysDefV
MsgBox("Defence value is " & Defence)
End Sub
Monday, 2 September 2013
It begins with a single step
Andddddddd we have movement :D
Using this little section of code
Private Sub Form1_KeyDown(sender As Object, e As System.Windows.Forms.KeyEventArgs) Handles Me.KeyDown
Dim Loc As Point
Select Case e.KeyCode
Case Keys.Up
If Not ImgChar.Location.Y - 50 < 0 Then
Loc = New Point(ImgChar.Location.X, ImgChar.Location.Y - 50)
ImgChar.Location = Loc
End If
Case Keys.Down
If Not ImgChar.Location.Y + 50 > 450 Then
Loc = New Point(ImgChar.Location.X, ImgChar.Location.Y + 50)
ImgChar.Location = Loc
End If
Case Keys.Left
If Not ImgChar.Location.X - 50 < 0 Then
Loc = New Point(ImgChar.Location.X - 50, ImgChar.Location.Y)
ImgChar.Location = Loc
End If
Case Keys.Right
If Not ImgChar.Location.X + 50 > 450 Then
Loc = New Point(ImgChar.Location.X + 50, ImgChar.Location.Y)
ImgChar.Location = Loc
End If
End Select
End Sub
I've made a little blue square move around my form, its a miracle!
Next stop will be to try and get my program to draw an 8x8 grid and fill them with a colour (green probably)
Using this little section of code
Private Sub Form1_KeyDown(sender As Object, e As System.Windows.Forms.KeyEventArgs) Handles Me.KeyDown
Dim Loc As Point
Select Case e.KeyCode
Case Keys.Up
If Not ImgChar.Location.Y - 50 < 0 Then
Loc = New Point(ImgChar.Location.X, ImgChar.Location.Y - 50)
ImgChar.Location = Loc
End If
Case Keys.Down
If Not ImgChar.Location.Y + 50 > 450 Then
Loc = New Point(ImgChar.Location.X, ImgChar.Location.Y + 50)
ImgChar.Location = Loc
End If
Case Keys.Left
If Not ImgChar.Location.X - 50 < 0 Then
Loc = New Point(ImgChar.Location.X - 50, ImgChar.Location.Y)
ImgChar.Location = Loc
End If
Case Keys.Right
If Not ImgChar.Location.X + 50 > 450 Then
Loc = New Point(ImgChar.Location.X + 50, ImgChar.Location.Y)
ImgChar.Location = Loc
End If
End Select
End Sub
I've made a little blue square move around my form, its a miracle!
Next stop will be to try and get my program to draw an 8x8 grid and fill them with a colour (green probably)
Subscribe to:
Posts (Atom)