EricBentley
New member
- Joined
- Jan 16, 2012
- Messages
- 2
- Programming Experience
- 1-3
Hey guys, new to the forums. Been browsing here for a while, casually taking help off other peoples threads, but I come to you now in my time of despair.
I've been working on this game the past few days, a simple game where two people control different tanks, and shoot each other, very basic so far.
The problem I have is when one player is dead. I have the form recognizing each players death by using this code (It's within a timer subroutine)
That enables a button to be visible, and the code for that button is below
I've tried every method so far, and for the most part it works. The code is executed, and the players health is restored and the players go back into position, however, they are unable to move or shoot after that. I use the arrow keys and WASD keys for movement, like the sample below
and that code is replicated for every key pressed (Arrow keys, WASD, e, and end). Those booleans are handled in a timer subroutine, where if the boolean is true, they will move/shoot. (Turning the booleans to false is done in the 'Private Sub KeysUp' subroutine)
TL;DR
How do I get the game to restart itself when a player dies and hits the replay button?
P.S. I've tried 'Me.Refresh()' as well, and that didn't do anything
I've been working on this game the past few days, a simple game where two people control different tanks, and shoot each other, very basic so far.
The problem I have is when one player is dead. I have the form recognizing each players death by using this code (It's within a timer subroutine)
'Player One Dead If intPlayerOneHealth <= 0 Then btnReplay.Visible = True End If 'Player Two Dead If intPlayerTwoHealth <= 0 Then btnReplay.Visible = True End If
That enables a button to be visible, and the code for that button is below
Private Sub btnReplay_Click(sender As System.Object, e As System.EventArgs) Handles btnReplay.Click intPlayerOneHealth = 100 intPlayerTwoHealth = 100 pbxPlayerOne.Location = New Point(27, 53) pbxPlayerTwo.Location = New Point(700, 461) btnReplay.Visible = False Me.Refresh() End Sub
I've tried every method so far, and for the most part it works. The code is executed, and the players health is restored and the players go back into position, however, they are unable to move or shoot after that. I use the arrow keys and WASD keys for movement, like the sample below
Private Sub KeysDown(ByVal Sender As System.Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles MyBase.KeyDown 'Left arrow key If e.KeyValue = Keys.Left Then bolKeyLeft = True End If End Sub
and that code is replicated for every key pressed (Arrow keys, WASD, e, and end). Those booleans are handled in a timer subroutine, where if the boolean is true, they will move/shoot. (Turning the booleans to false is done in the 'Private Sub KeysUp' subroutine)
TL;DR
How do I get the game to restart itself when a player dies and hits the replay button?
P.S. I've tried 'Me.Refresh()' as well, and that didn't do anything