Tuesday, 22 October 2013

Statistical Stats!

I've made another form to show that shows various information about the character you are playing as like their name, main stats like strength and secondary stats like evasion chance

Because, though, our variables for the various stats are stored on the main form we need to pass them through inheritance to this form.

Note: For now I've only manipulated the main stats, strength, agility and intelligence along with the character level, the other stats are just given a number directly on the form until I build on the program a bit more.

Main Form
Private Sub BtnChar_Click(sender As System.Object, e As System.EventArgs) Handles BtnChar.Click

'Open Character screen and pass variables to FrmChar

Dim frm As New FrmChar(Strength, Agility, Intelligence)


frm.Show()
 
 
End Sub

Character Form
Public Class FrmChar
'Declare public variables

Dim str As Integer

Dim agi As Integer

Dim int As Integer

Dim lvl As Integer


Public Sub New(ByVal Strength As Integer, ByVal Agility As Integer, ByVal Intelligence As Integer, ByVal Level As Integer)

'Inherit variables from FrmMain
InitializeComponent()

str = Strength

agi = Agility

int = Intelligence

lvl = Level
 
End Sub

 
 
Public Sub FrmChar_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load

Dim Name As String

Dim HP, MP, Armour, Power, Evade As Integer

'Show variable values in associated text boxes
Name = "Andrew Baldie"



HP = 500000

MP = 500

Armour = 27890

Power = 39020

Evade = 5

TxtName.Text = Name
 
      
TxtLevel.Text = lvl



TxtStr.Text = str

TxtAgi.Text = agi

TxtInt.Text = int

TxtHP.Text = HP

TxtMP.Text = MP

TxtArmour.Text = Armour

TxtPower.Text = Power

TxtEvade.Text = Evade
 
End Sub



 
 
End Class

Monday, 21 October 2013

Oh noes (invisible) monsters ;_;

Decided to implement a counter which upon reaching 0 will trigger a form to appear in which a random battle will occur (in a similar vein to how the first couple of Final Fantasy games handled random encounters)

Private Sub Random_Encounter(ByRef Counter As Integer)

Counter = Counter - 5
If Counter <= 0 Then

FrmBattle.ShowDialog()

Counter = CInt(Int((255 - 50 + 1) * Rnd())) + 50 + 1

End If

End Sub

I've so far only built the trigger, the subsequent building of what appears on the form and the battle mechanics of the monsters while be done later on :)

This is also the start of a big block of updates as I've been pretty bad with updating my blog, I'm sorry!

Thursday, 12 September 2013

Oh my! GUI!

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.

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

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

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

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