[VB.NET] Want to fight a spider? (look over the code please)
This was really all I could think of doing to learn the syntax of vb. I'm really just learning it for shits since I've never bothered to look at it and I need something to do for a week before school starts up.
I made this in about 10 minutes after I spent a little bit reading over a VB.NET book. Look over the code for me and see if there is anything I should be doing differently please. :)
Download (attachments still aren't working): www.rf-dev.com/Fighter.rar
Code:
Public Class Fighter
Public myhp As Single
Public spiderhp As Single
Public DamageToSpider As Single
Public DamageToMe As Single
Public damage As New Random()
Private Sub btnStart_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnStart.Click
myhp = 100
spiderhp = 100
lblMyHP.Text = Convert.ToString(myhp)
lblSpiderHP.Text = Convert.ToString(spiderhp)
btnAttack.Enabled = True
btnReset.Enabled = True
btnStart.Enabled = False
picSpider.Show()
lblSpider.Show()
lblSpiderHP.Show()
hplblSpider.Show()
log.Items.Clear()
log.Items.Add("You have encountered a Spider!")
End Sub
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
btnAttack.Enabled = False
btnReset.Enabled = False
picSpider.Hide()
lblSpider.Hide()
lblSpiderHP.Hide()
hplblSpider.Hide()
End Sub
Private Sub btnReset_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnReset.Click
myhp = 100
spiderhp = 100
lblMyHP.Text = Convert.ToString(myhp)
lblSpiderHP.Text = Convert.ToString(spiderhp)
btnAttack.Enabled = False
btnReset.Enabled = False
btnStart.Enabled = True
picSpider.Hide()
lblSpider.Hide()
lblSpiderHP.Hide()
hplblSpider.Hide()
picMe.Show()
log.Items.Clear()
log.Items.Add("Fighter as been reset!")
End Sub
Private Sub btnAttack_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnAttack.Click
log.Items.Clear()
DamageToSpider = damage.Next(1, 15)
spiderhp = (spiderhp - DamageToSpider)
lblSpiderHP.Text = Convert.ToString(spiderhp)
log.Items.Add("You hit the Spider for " & DamageToSpider & " damage!")
'Not sure how to do this properly yet so I left it out
'System.Threading.Thread.Sleep(500)
DamageToMe = damage.Next(1, 15)
myhp = (myhp - DamageToMe)
lblMyHP.Text = Convert.ToString(myhp)
log.Items.Add("The Spider hits YOU for " & DamageToMe & " damage!")
If (myhp = 0) Or (myhp < 0) Then
btnAttack.Enabled = False
picMe.Hide()
log.Items.Add("You have been defeated by the Spider!")
log.Items.Add("Click reset to battle again!")
End If
If (spiderhp = 0) Or (spiderhp < 0) Then
btnAttack.Enabled = False
picSpider.Hide()
log.Items.Add("You have defeated the Spider!")
log.Items.Add("Click reset to try your luck again!")
End If
End Sub
End Class
Re: [VB.NET] Want to fight a spider? (look over the code please)
nice
I started off like this aswell, but i dont really play around with windows forms, i'm always with the consoles :P
Re: [VB.NET] Want to fight a spider? (look over the code please)
For emulation yeah, my rf emu is console based.
I'm getting in to VB because it seems like I'll be able to code up tools a lot faster than I can with C#.
Re: [VB.NET] Want to fight a spider? (look over the code please)
nice, ahaha rand attack and life
very nice
Re: [VB.NET] Want to fight a spider? (look over the code please)
Your spider always kicks my ass! Imblance! :D
Re: [VB.NET] Want to fight a spider? (look over the code please)
Don't worry Intelext, I got him. Then the spiders kept coming! Finally, I met my maker and perished under the reign of the spiders!
That's a pretty cool game ;) Simple.
Re: [VB.NET] Want to fight a spider? (look over the code please)
Thanks for the comments. :P