Quote:
Originally Posted by zonic505 I figured it out about a week ago. HOWEVER, I do need some new help.
For our final exam, I'm going to do a boxing game (think 2D Punch-Out!!, except stop-motion graphics & the view is like Street Fighter or other fighting games). I'm planning on having health bars, special meters (again, like Punch-Out!!), & perhaps multiple opponents (depends if I have time). I haven't done it yet, but we'll be taking pictures to use as the "graphics", so I need to figure out how to make it so certain pictures will appear if I have my gloves up (like when defending) or getting hit. Again, think Punch-Out!!, but with a Street Fighter/fighting game view. BTW, no movement except the gloves (switch between up & down). |
The easiest way would probably be to just check for input on the form's KeyDown event, switch the pictures, and then run some code for the result:
Code:
Select Case e.KeyCode
Case Keys.Space:
PlayerPictureBox.Image = My.Resources.playerpunch
If OpponentPose = 0 Then
OpponentPictureBox.Image = My.Resources.opponenthit
'call some code here for when the opponent gets hit
Else
OpponentPictureBox.Image = My.Resources.opponentblock
'call some code here for when the opponent blocks
End If
End Select That's assuming you're storing the image as a resource, if you're loading it from a file on the hard drive then just substitute the code accordingly.
If you want to introduce some primitive animation, so the pose will only display for half a second, an easy way to do that would be to put a timer on the form, and add some code to the timer's Tick event to revert the poses back to what they were before the player punched:
Code:
If PlayerGlovesUp = False Then
PlayerPictureBox.Image = My.Resources.playerglovesdown
Else
PlayerPictureBox.Image = My.Resources.playerglovesup
End If
If OpponentGlovesUp = False Then
OpponentPictureBox.Image = My.Resources.opponentglovesdown
Else
OpponentPictureBox.Image = My.Resources.opponentglovesup
End If
Timer1.Enabled = False 'this shuts off the animation after it's played once Make sure the timer starts off disabled, and set the interval to 500 (the timer counts in milliseconds so 500 milliseconds = one half second -- it's pretty inaccurate though so don't use it for anything timing-critical)
Now of course with that code you'll need to set the PlayerGlovesUp and OpponentGlovesUp booleans accordingly whenever the pose changes.
You'll also need to modify the first block of code I wrote a little bit:
Code:
Select Case e.KeyCode
Case Keys.Space:
PlayerPictureBox.Image = My.Resources.playerpunch
If OpponentPose = 0 Then
OpponentPictureBox.Image = My.Resources.opponenthit
'call some code here for when the opponent gets hit
Else
OpponentPictureBox.Image = My.Resources.opponentblock
'call some code here for when the opponent blocks
End If
Timer1.Enabled = False 'just to cancel out any previous animation that may have been playing
Timer1.Enabled = True 'start this animation
End Select Hope that makes sense and/or helps