|
-
May 14th, 2007, 09:41 AM
#1
Thread Starter
New Member
I need help with vb coursework
I'm trying to make a vb version of wack a mole and i have the game working but i do not know anything about making and displaying a highscore so i was wondering if anyone could help me
Last edited by postmanx; May 22nd, 2007 at 09:54 AM.
-
May 15th, 2007, 03:45 PM
#2
Re: I need help with vb coursework
pretty simple setup. set a global variable for score and increment it for each whack. When game is over set hiscore variable to score variable if score variable is larger.
if Score > HiScore then HiScore = Score
of course for permanent save, output to an .ini file is simplest
open "Whakamole.ini" for output as #1
print #1, HiScore
close #1
use Input #1 to read it again.
-
May 16th, 2007, 11:04 AM
#3
Thread Starter
New Member
Re: I need help with vb coursework
Well i missed alot of lessons and have about a week to get the game completed. Is there any place or discussion that have tutorails for basic visual basic stuff?
-
May 16th, 2007, 03:08 PM
#4
Re: I need help with vb coursework
This is the place to look for questions like that.
Use the way Lord Orwell stated, for the saving and reading part, search the forum for GetPrivateProfileString and ReadPrivateProfileString, those API's will help you to read and write INI-files!
You're welcome to rate this post!
If your problem is solved, please use the Mark thread as resolved button
Wait, I'm too old to hurry!
-
May 16th, 2007, 04:38 PM
#5
Thread Starter
New Member
Re: I need help with vb coursework
thanks alot but i started to recode the game and was told the system design sheets:
Form Design
The Introduction form
Design
• Two labels: one for the title of the program and one for your name and the date.
• An ‘Exit’ button.
• Two images with a label above or overlapping each image. The labels should say ‘Play’ and ‘Instructions’. The user must be able to drag the image of their choice to a target area, which will invoke the relevant action. You may use automatic or manual drag-and-drop.
• An image as your target area.
• A label telling the user they need to drag the relevant image to the target area.
The Instruction form
Design
• A label to display the instructions.
• A ‘Close’ button.
The Top Five form
Design
• A control array of 6 labels named IbName. Set the Caption of IbName(0) to ‘Name’ and delete the rest of the captions. Arrange the labels in order from top to bottom on the left-hand side of the form.
• Another control array of 6 labels named IbiScore. Set the Caption of IbiScore(0) to ‘Score’ and delete the rest of the captions. Arrange the labels in order form top to bottom on the right-hand side of the form.
• If you want, you may add five labels with the captions ‘1’ ‘2’ ‘3’ ‘4’ and ‘5’.
• A CommonDialog control.
• A ‘Changefont’ and ‘Close’ button.
The Game form
Design
• A control array of 12 images named imgMouse. They should all have their Picture properties set to the same thing. Also set the Visible property for each image to False.
• Two Timer controls. One will be used to randomly display one or two mice at a time, and the other one will be used to time the game and end it after a set time limit. Set the interval of the first one to about 900 and disable it. Set the interval of the second one to about 35000 and disable it.
i know how to move the picture to make them appear in random places with just one picture but im not sure how to do this with arrays.
-
May 18th, 2007, 01:24 AM
#6
Re: I need help with vb coursework
if you know how to move one picture start from there. Change the "YourPictureControl" to an array.
Around the code that moves the picture put:
Code:
For i=0 To UBound(YourPictureControl)
'your old code, just add the "(i)" to each time you have YourPictureControl
Next i
You're welcome to rate this post!
If your problem is solved, please use the Mark thread as resolved button
Wait, I'm too old to hurry!
-
May 18th, 2007, 07:54 AM
#7
Thread Starter
New Member
Re: I need help with vb coursework
well thank you i put that code in and now it works. Just one problem: the person can click multiple times on an image to rand up points. Is there anyway to fix this? here is the line of code:
Code:
Private Sub imgVirus_Click(Index As Integer)
imgVirus(Index).Picture = LoadPicture(App.Path & "\bass3.bmp")
intPlayerScore = CInt(lblScoreCount)
intPlayerScore = intPlayerScore + 1
lblScoreCount.Caption = intPlayerScore
-
May 21st, 2007, 01:39 AM
#8
Re: I need help with vb coursework
 Originally Posted by postmanx
well thank you i put that code in and now it works. Just one problem: the person can click multiple times on an image to rand up points. Is there anyway to fix this? here is the line of code:
Code:
Private Sub imgVirus_Click(Index As Integer)
imgVirus(Index).Picture = LoadPicture(App.Path & "\bass3.bmp")
intPlayerScore = CInt(lblScoreCount)
intPlayerScore = intPlayerScore + 1
lblScoreCount.Caption = intPlayerScore
Which part isn't working as expect?
intPlayerScore = CInt(lblScoreCount) Puts the Caption of the Label into the Var intPlayerScore (changed to an Integer)
intPlayerScore = intPlayerScore + 1 Adds one to the var
lblScoreCount.Caption = intPlayerScore Puts the value off the var into the Label again.
I don't understand: "to rand up points" . If the adding up one point is your problem delete the line "intPlayerScore = intPlayerScore + 1".
You're welcome to rate this post!
If your problem is solved, please use the Mark thread as resolved button
Wait, I'm too old to hurry!
-
May 21st, 2007, 08:22 AM
#9
Thread Starter
New Member
Re: I need help with vb coursework
sorry that was a typo i meant the player can rack up points by clicking on the image multiple times before the image reappear in a random spot. They can gain about 3-6 points with multiple clicks but i only want them to gain one if they hit the target.
-
May 21st, 2007, 08:36 AM
#10
Re: I need help with vb coursework
In this case you need to create a variable that is set to (for example) 1 if the image is displayed(set that when shown the image), to 2 if the image has been clicked on (set that when a point is added) and 0 if the image isn't visible (set that when the image is hidden again).
Only if the variable is 1 the click on the image will add a point1.
You're welcome to rate this post!
If your problem is solved, please use the Mark thread as resolved button
Wait, I'm too old to hurry!
-
May 21st, 2007, 09:27 AM
#11
Thread Starter
New Member
Re: I need help with vb coursework
well im in class now working on it. I think i've done something wrong cause now it click and i watch the code and the varible is empty.
Code:
Private Sub tmrVirus_Timer()
'Makes the virus appear
intNumVirus = 12
intClick = 1
For I = 1 To intNumVirus
imgVirus(I).Visible = False
imgVirus(I).Picture = LoadPicture(App.Path & "\bass2.bmp")
intTop = Int(Rnd * 5000 - 1)
intLeft = Int(Rnd * 5000 - 1)
imgVirus(I).Top = intTop
imgVirus(I).Left = intLeft
Next I
Randomize
imgVirus((Rnd * 11) + 1).Visible = True
End Sub
Code:
Private Sub imgVirus_Click(Index As Integer)
If intClick = 1 Then
imgVirus(Index).Picture = LoadPicture(App.Path & "\bass3.bmp")
intPlayerScore = CInt(lblScoreCount)
intPlayerScore = intPlayerScore + 1
lblScoreCount.Caption = intPlayerScore
intClick = 2
End If
End Sub
-
May 22nd, 2007, 04:18 AM
#12
Re: I need help with vb coursework
Which var is empty?
It seems you are using intClick as the variable that states if an image has been clicked since the last timer event.
Do you show only one image at a time, in this case this useage would be OK.
Please explain your problem in more detail!
You're welcome to rate this post!
If your problem is solved, please use the Mark thread as resolved button
Wait, I'm too old to hurry!
-
May 22nd, 2007, 02:45 PM
#13
Re: I need help with vb coursework
i hate to rain on this code parade, but you aren't writing the game the way the assignment tells you to. You need to have twelve mice all invisible and your random code will make one or two visible at a time. Instead you are moving the same mice around. They should each be in position to start with and set up as a control array. The array will have a click event that will increment the score and make the clicked mouse invisible again. This will stop multiple clicks automatically.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|