PRo-Beaniie
Well-known member
- Joined
- Mar 17, 2011
- Messages
- 55
- Programming Experience
- 3-5
Hey guys,
Im having some trouble with my progress bars in VB.Net. I am currently making a 2d game for a college assignment. The problem is i have one for health and one for reloading the reload bar works fine but when i try to code the health bar i think it conflicts with the other Progress bar ... hope you guys can help heres my recent code ...
Im having some trouble with my progress bars in VB.Net. I am currently making a 2d game for a college assignment. The problem is i have one for health and one for reloading the reload bar works fine but when i try to code the health bar i think it conflicts with the other Progress bar ... hope you guys can help heres my recent code ...
VB.NET:
Public Class FormMain
'DIM controls ...
Dim sright As Boolean
Dim sleft As Boolean
Dim shooterspeed As Integer
Dim missilespeed As Integer
Dim EnemySpeed As Integer
Dim ERight As Boolean
Dim ELeft As Boolean
Private Sub FormMain_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles Me.KeyDown
'Arrow Key Contorls ...
If e.KeyValue = Keys.Right Then
sright = True
sleft = False
End If
If e.KeyValue = Keys.Left Then
sleft = True
sright = False
End If
If e.KeyValue = Keys.Down Then
sleft = False
sright = False
End If
If e.KeyValue = Keys.Space And Missile.Visible = False Then
Missile.Top = Shooter.Top
Missile.Left = Shooter.Left + (Shooter.Width / 2) - (Missile.Width / 2)
Missile.Visible = True And (Missile.Top >= Shooter.Height + Shooter.Width) And Me.ClientRectangle.Width
End If
End Sub
Private Sub FormMain_KeyUp(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles Me.KeyUp
'Arrow Key Controls...
If e.KeyValue = Keys.Right Then
sright = False
End If
If e.KeyValue = Keys.Left Then
sleft = False
End If
If e.KeyValue = Keys.Space And Missile.Visible = True Then
sleft = False
sright = False
End If
End Sub
Private Sub FormMain_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'Event On Form Load...
LoadSettings()
'Splash Screen Load
TriggerhappyLoad.ShowDialog()
End Sub
Private Sub LoadSettings()
'Load Settings Speed Controls ...
missilespeed = 10
shooterspeed = 3
EnemySpeed = 5
ERight = True
Missile.Visible = False
End Sub
Private Sub FormMain_FormClosing(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing
'Do You Want To Quit?
Dim result As MsgBoxResult
result = MessageBox.Show("Do you really want to quit?", "Quit?", MessageBoxButtons.YesNo, MessageBoxIcon.Question)
If result = MsgBoxResult.No Then
e.Cancel = True
End If
End Sub
Private Sub TimerMain_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TimerMain.Tick
'Timer Main Variables...
moveshooter()
Firemissile()
CheckHit()
MoveEnemy()
Reloadbar()
[COLOR=darkorange]HealthStatus()[/COLOR]
End Sub
Private Sub moveshooter()
'Shooter Timer Variables ...
If sright = True And Shooter.Left + Shooter.Width < Me.ClientRectangle.Width Then
Shooter.Left += shooterspeed
End If
If sleft = True And Shooter.Left > Me.ClientRectangle.Left Then
Shooter.Left -= shooterspeed
End If
End Sub
Private Sub Firemissile()
'Missile Timer Variables ...
If Missile.Visible = True Then
Missile.Top -= missilespeed
End If
If Missile.Top + Missile.Height < Me.ClientRectangle.Top Then
Missile.Visible = False
End If
End Sub
Private Sub CheckHit()
'Timer Main Collision Code ...
If (Missile.Top + Missile.Height >= Enemy.Top) And (Missile.Top <= Enemy.Top + Enemy.Height) And (Missile.Left + Missile.Width >= Enemy.Left) And (Missile.Left <= Enemy.Left + Enemy.Width) And Enemy.Visible = True Then
Enemy.Visible = False
Missile.Visible = False
End If
End Sub
Private Sub MoveEnemy()
'Enemy Timer Variables ...
If ERight = True Then
Enemy.Left += EnemySpeed
End If
If Enemy.Left >= 900 Then
Enemy.Left = -100
End If
End Sub
Private Sub Reloadbar()
ReloadingBar.Maximum = 100
ReloadingBar.Minimum = 0
If Missile.Visible = True Then
ReloadingBar.Value = 100
Else
Missile.Visible = False
ReloadingBar.Value = 0
End If
End Sub
Private Sub [COLOR=darkorange]Healthstatus()[/COLOR]
HealthStatus.Maximum = 100
HealthStatus.Minimum = 0
End Sub
End Class
Last edited: