Bemanistyle #1 In music game coverage - Dance Dance Revolution, Beatmania, IIDX, Popn Music Sponsored Banner Ad. Contact Keith or Djp to AdvertiseSponsored Advertisement

Go Back   Bemanistyle [dot] com Forums > Non-Bemani Topics > General Discussion > Computers & Technology
Reply
 
Thread Tools

Visual Studio/Basic Express help
Old 04-20-2009, 03:11 PM   #1
zonic505
My wife means Sirius business
 
zonic505's Avatar
 
zonic505 is offline
Join Date: Apr 2007
Location: Playing Empress + Premium Best. Finally.
Posts: 3,081
Marketplace Rating: 0
Tokens: 0.00
Bank: 3,471,420.97
Total Tokens: 3,471,420.97
Donate Tokens
Send a message via PM  to zonic505
Question Visual Studio/Basic Express help

I downloaded Visual Basic Express on my laptop so I could work on some projects that I'm doing for Programming on Visual Studio at school & I need some quick help.

I'm making a program that plays Rock, Paper, Scissors & I've got about 1/2 of it done (have it so each of the 3 buttons brings up a pic of a rock, paper, or scissor). What I need help on are 2 things:

1.) Make it so the computer will randomly choose a number from 1, 2, & 3, each of which will be assigned a picture so that each time I click a button from my side, the computer will randomly pick a number, resulting in a picture being brought up.

2.) Make it so that if I were to win, the text box will say "You Win", & all that stuff, to which I think I need to make it something along the lines of "If PictureBox1.Image = BmpImage1 & PictureBox2.Image = bmpImage2, Then "You Win" or something along those lines (I know it won't be exactly typed like that).

Here's my code so far:

Quote:
Public Class Form1
Dim MyValue As Long

Dim X As Integer
Private Sub PictureBox1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PictureBox1.Click

End Sub

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim bmpImage1 As New Bitmap("*location of picture*")
PictureBox1.Image = bmpImage1

End Sub


Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Dim bmpImage2 As New Bitmap("*location of picture*")
PictureBox1.Image = bmpImage2

End Sub

Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
Dim bmpImage3 As New Bitmap("*location of picture*")
PictureBox1.Image = bmpImage3

End Sub

Private Sub PictureBox2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PictureBox2.Click

Randomize() ' Initialize random-number generator.

MyValue = Int((3 * Rnd()) + 1) ' Generate random value between 1 and 3.

TextBox1.Text = MyValue
End Sub
End Class
I can't get it work since the pictures are saved at my school, but I can still work on it from here. Any help would be appreciated.

If anyone can help me so that I can take a picture of my screen (that screencap thing or whatever it is), then I can show a pic of what I'm doing.

Last edited by zonic505 : 04-20-2009 at 03:17 PM.
  Reply With Quote

Old 05-03-2009, 11:42 PM   #2
Jeff Paine
I CAN FRY
 
Jeff Paine's Avatar
 
Jeff Paine is offline
Join Date: Jun 2006
Location: Orlando, FL, USA
Donated: $100 ?
Posts: 821
Marketplace Rating: 0
Tokens: 0.00
Bank: 563.04
Total Tokens: 563.04
Donate Tokens
Send a message via PM  to Jeff Paine

Default

Your randomize code looks right but this is basically what you want to do to take that number and turn it into a picture (written in pseudocode out of laziness):

Quote:
Select Case MyValue
Case 1:
[assign picture #1 to picturebox]
Case 2:
[assign picture #2 to picturebox]
Case 3:
[assign picture #3 to picturebox]
End Select
Select Case basically acts like a giant chain of if-else statements

also, to get the textbox to display "You Win":

Quote:
TextBox1.Text = "You Win"
although you should really be using a label if all you're doing is displaying text and not taking in any user input

An easier way to check if you won is to store the player's choice in a separate value. i.e. if the player clicks Button1 then assign PlayerValue to 1. Then just check If PlayerValue = 1 And MyValue = 2 Then you won

Last edited by Jeff Paine : 05-03-2009 at 11:46 PM.
  Reply With Quote

Old 05-04-2009, 03:12 PM   #3
zonic505
My wife means Sirius business
 
zonic505's Avatar
 
zonic505 is offline
Join Date: Apr 2007
Location: Playing Empress + Premium Best. Finally.
Posts: 3,081
Marketplace Rating: 0
Tokens: 0.00
Bank: 3,471,420.97
Total Tokens: 3,471,420.97
Donate Tokens
Send a message via PM  to zonic505
Default

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).
  Reply With Quote

Old 05-04-2009, 09:52 PM   #4
Jeff Paine
I CAN FRY
 
Jeff Paine's Avatar
 
Jeff Paine is offline
Join Date: Jun 2006
Location: Orlando, FL, USA
Donated: $100 ?
Posts: 821
Marketplace Rating: 0
Tokens: 0.00
Bank: 563.04
Total Tokens: 563.04
Donate Tokens
Send a message via PM  to Jeff Paine

Default

Quote:
Originally Posted by zonic505 View Post
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
  Reply With Quote
Reply



Go Back   Bemanistyle [dot] com Forums > Non-Bemani Topics > General Discussion > Computers & Technology
Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Sponsored Advertisement



All times are GMT -6. The time now is 06:24 PM.

vBulletin skin developed by: eXtremepixels
Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO 3.1.0
| Home | Register | FAQ | Members List | Calendar | Today's Posts | Search | New Posts |