|
-
Jun 15th, 2000, 06:08 PM
#1
Thread Starter
Junior Member
hey, well i'm having some probs. i really need help!!!!
i'm making a game (of snakes and ladders, for an assignment), n it has three players, i have got the first player to do the following (the pictures- 108 to 1, being the board that the counter/ player 1, imgcnt1.Picture goes into)
Select Case Position
Case 1
Form2.Picture108.Picture = Form2.imgcnt1.Picture
Case 2
Form2.Picture107.Picture = Form2.imgcnt1.Picture
Case 3
Form2.Picture106.Picture = Form2.imgcnt1.Picture
Case 4
Form2.Picture105.Picture = Form2.imgcnt1.Picture
Case 5
Form2.Picture104.Picture = Form2.imgcnt1.Picture
Case 6
Form2.Picture103.Picture = Form2.imgcnt1.Picture
Case 7
Form2.Picture102.Picture = Form2.imgcnt1.Picture
Case 8
Form2.Picture101.Picture = Form2.imgcnt1.Picture
Case 9
Form2.Picture100.Picture = Form2.imgcnt1.Picture
Case 10
Form2.Picture99.Picture = Form2.imgcnt1.Picture
Case 11
Form2.Picture98.Picture = Form2.imgcnt1.Picture
Case 12
Form2.Picture97.Picture = Form2.imgcnt1.Picture
Case 13
Form2.Picture96.Picture = Form2.imgcnt1.Picture
Case 14
Form2.Picture95.Picture = Form2.imgcnt1.Picture
Case 15
Form2.Picture94.Picture = Form2.imgcnt1.Picture
Case 16
Form2.Picture93.Picture = Form2.imgcnt1.Picture
Case 17
Form2.Picture92.Picture = Form2.imgcnt1.Picture
Case 18
Form2.Picture91.Picture = Form2.imgcnt1.Picture
Case 19
Form2.Picture90.Picture = Form2.imgcnt1.Picture
Case 20
Form2.Picture89.Picture = Form2.imgcnt1.Picture
Case 21
Form2.Picture88.Picture = Form2.imgcnt1.Picture
Case 22
Form2.Picture87.Picture = Form2.imgcnt1.Picture
Case 23
Form2.Picture86.Picture = Form2.imgcnt1.Picture
Case 24
Form2.Picture85.Picture = Form2.imgcnt1.Picture
Case 25
Form2.Picture84.Picture = Form2.imgcnt1.Picture
Case 26
Form2.Picture83.Picture = Form2.imgcnt1.Picture
Case 27
Form2.Picture82.Picture = Form2.imgcnt1.Picture
Case 28
Form2.Picture81.Picture = Form2.imgcnt1.Picture
Case 29
Form2.Picture80.Picture = Form2.imgcnt1.Picture
Case 30
Form2.Picture79.Picture = Form2.imgcnt1.Picture
Case 31
Form2.Picture78.Picture = Form2.imgcnt1.Picture
Case 32
Form2.Picture77.Picture = Form2.imgcnt1.Picture
Case 33
Form2.Picture76.Picture = Form2.imgcnt1.Picture
Case 34
Form2.Picture75.Picture = Form2.imgcnt1.Picture
Case 35
Form2.Picture74.Picture = Form2.imgcnt1.Picture
Case 36
Form2.Picture73.Picture = Form2.imgcnt1.Picture
Case 37
Form2.Picture72.Picture = Form2.imgcnt1.Picture
Case 38
Form2.Picture71.Picture = Form2.imgcnt1.Picture
Case 39
Form2.Picture70.Picture = Form2.imgcnt1.Picture
Case 40
Form2.Picture69.Picture = Form2.imgcnt1.Picture
Case 41
Form2.Picture68.Picture = Form2.imgcnt1.Picture
Case 42
Form2.Picture67.Picture = Form2.imgcnt1.Picture
Case 43
Form2.Picture66.Picture = Form2.imgcnt1.Picture
Case 44
Form2.Picture65.Picture = Form2.imgcnt1.Picture
Case 45
Form2.Picture64.Picture = Form2.imgcnt1.Picture
Case 46
Form2.Picture63.Picture = Form2.imgcnt1.Picture
Case 47
Form2.Picture62.Picture = Form2.imgcnt1.Picture
Case 48
Form2.Picture61.Picture = Form2.imgcnt1.Picture
Case 49
Form2.Picture60.Picture = Form2.imgcnt1.Picture
Case 50
Form2.Picture59.Picture = Form2.imgcnt1.Picture
Case 51
Form2.Picture58.Picture = Form2.imgcnt1.Picture
Case 52
Form2.Picture57.Picture = Form2.imgcnt1.Picture
Case 53
Form2.Picture56.Picture = Form2.imgcnt1.Picture
Case 54
Form2.Picture55.Picture = Form2.imgcnt1.Picture
Case 55
Form2.Picture54.Picture = Form2.imgcnt1.Picture
Case 56
Form2.Picture53.Picture = Form2.imgcnt1.Picture
Case 57
Form2.Picture52.Picture = Form2.imgcnt1.Picture
Case 58
Form2.Picture51.Picture = Form2.imgcnt1.Picture
Case 59
Form2.Picture50.Picture = Form2.imgcnt1.Picture
Case 60
Form2.Picture49.Picture = Form2.imgcnt1.Picture
Case 61
Form2.Picture48.Picture = Form2.imgcnt1.Picture
Case 62
Form2.Picture47.Picture = Form2.imgcnt1.Picture
Case 63
Form2.Picture46.Picture = Form2.imgcnt1.Picture
Case 64
Form2.Picture45.Picture = Form2.imgcnt1.Picture
Case 65
Form2.Picture44.Picture = Form2.imgcnt1.Picture
Case 66
Form2.Picture43.Picture = Form2.imgcnt1.Picture
Case 67
Form2.Picture42.Picture = Form2.imgcnt1.Picture
Case 68
Form2.Picture41.Picture = Form2.imgcnt1.Picture
Case 69
Form2.Picture40.Picture = Form2.imgcnt1.Picture
Case 70
Form2.Picture39.Picture = Form2.imgcnt1.Picture
Case 71
Form2.Picture38.Picture = Form2.imgcnt1.Picture
Case 72
Form2.Picture37.Picture = Form2.imgcnt1.Picture
Case 73
Form2.Picture36.Picture = Form2.imgcnt1.Picture
Case 74
Form2.Picture35.Picture = Form2.imgcnt1.Picture
Case 75
Form2.Picture34.Picture = Form2.imgcnt1.Picture
Case 76
Form2.Picture33.Picture = Form2.imgcnt1.Picture
Case 77
Form2.Picture32.Picture = Form2.imgcnt1.Picture
Case 78
Form2.Picture31.Picture = Form2.imgcnt1.Picture
Case 79
Form2.Picture30.Picture = Form2.imgcnt1.Picture
Case 80
Form2.Picture29.Picture = Form2.imgcnt1.Picture
Case 81
Form2.Picture28.Picture = Form2.imgcnt1.Picture
Case 82
Form2.Picture27.Picture = Form2.imgcnt1.Picture
Case 83
Form2.Picture26.Picture = Form2.imgcnt1.Picture
Case 84
Form2.Picture25.Picture = Form2.imgcnt1.Picture
Case 85
Form2.Picture24.Picture = Form2.imgcnt1.Picture
Case 86
Form2.Picture23.Picture = Form2.imgcnt1.Picture
Case 87
Form2.Picture22.Picture = Form2.imgcnt1.Picture
Case 88
Form2.Picture21.Picture = Form2.imgcnt1.Picture
Case 89
Form2.Picture20.Picture = Form2.imgcnt1.Picture
Case 90
Form2.Picture19.Picture = Form2.imgcnt1.Picture
Case 91
Form2.Picture18.Picture = Form2.imgcnt1.Picture
Case 92
Form2.Picture17.Picture = Form2.imgcnt1.Picture
Case 93
Form2.Picture16.Picture = Form2.imgcnt1.Picture
Case 94
Form2.Picture15.Picture = Form2.imgcnt1.Picture
Case 95
Form2.Picture14.Picture = Form2.imgcnt1.Picture
Case 96
Form2.Picture13.Picture = Form2.imgcnt1.Picture
Case 97
Form2.Picture12.Picture = Form2.imgcnt1.Picture
Case 98
Form2.Picture11.Picture = Form2.imgcnt1.Picture
Case 99
Form2.Picture10.Picture = Form2.imgcnt1.Picture
Case 100
Form2.Picture9.Picture = Form2.imgcnt1.Picture
Case 101
Form2.Picture8.Picture = Form2.imgcnt1.Picture
Case 102
Form2.Picture7.Picture = Form2.imgcnt1.Picture
Case 103
Form2.Picture6.Picture = Form2.imgcnt1.Picture
Case 104
Form2.Picture5.Picture = Form2.imgcnt1.Picture
Case 105
Form2.Picture4.Picture = Form2.imgcnt1.Picture
Case 106
Form2.Picture3.Picture = Form2.imgcnt1.Picture
Case 107
Form2.Picture2.Picture = Form2.imgcnt1.Picture
Case 108
Form2.Picture1.Picture = Form2.imgcnt1.Picture
End Select
Roll = 0 'Starts Roll off as 0
Form2.imgcnt1.Visible = False 'player 1's original counter disappears
Form2.Show 'Shows Form2
End Sub
Private Sub imgDie1_Click()
RollDice
End Sub
Private Sub imgDie2_Click()
RollDice
End Sub
Public Sub RollDice()
Randomize
Die1 = Int(Rnd * 6) + 1 'roll the first die
Select Case Die1 'select the appropriate graphics
Case 1
imgDie1.Picture = LoadPicture("a:\one.bmp")
Roll = Roll + 1
Case 2
imgDie1.Picture = LoadPicture("a:\two.bmp")
Roll = Roll + 2
Case 3
imgDie1.Picture = LoadPicture("a:\three.bmp")
Roll = Roll + 3
Case 4
imgDie1.Picture = LoadPicture("a:\four.bmp")
Roll = Roll + 4
Case 5
imgDie1.Picture = LoadPicture("a:\five.bmp")
Roll = Roll + 5
Case 6
imgDie1.Picture = LoadPicture("a:\six.bmp")
Roll = Roll + 6
End Select
Die2 = Int(Rnd * 6) + 1 'roll second die
Select Case Die2 'select the appropriate graphics
Case 1
imgDie2.Picture = LoadPicture("a:\one.bmp")
Roll = Roll + 1
Case 2
imgDie2.Picture = LoadPicture("a:\two.bmp")
Roll = Roll + 2
Case 3
imgDie2.Picture = LoadPicture("a:\three.bmp")
Roll = Roll + 3
Case 4
imgDie2.Picture = LoadPicture("a:\four.bmp")
Roll = Roll + 4
Case 5
imgDie2.Picture = LoadPicture("a:\five.bmp")
Roll = Roll + 5
Case 6
imgDie2.Picture = LoadPicture("a:\six.bmp")
Roll = Roll + 6
End Select
Position = Position + Roll
End Sub
i want to be able to make all three players move, in turn. i thought that i would do it as a loop but i really don't know how to do it. i've attempted a few things but none of them work. ummm does ne 1 have ne ideas???? please
thanx
-
Jun 15th, 2000, 07:45 PM
#2
Junior Member
pogo,
I think you should have your game board as an array from 1 to 180 instead of the select case. You then should have three different player images and trree variables holding the postions of each player. When you call the 'roll dice' routine you should pass the players position into, add the value of the dice to it, and then pass it back out, when you get the variable back out assign the player image to the spot of the board
eg. Form2.Picture(player1_position).Picture = player1_image
Hope this helps
Using VB 6.0 SP 3
Bed goes up, bed goes down
-
Jun 15th, 2000, 07:52 PM
#3
Thread Starter
Junior Member
yeh i thought about having it as an array. but i don't think i worked out how 2 do that.
n woah i think tha rest of that just went straight over my head!! lol
could u b a bit more specific pls?
thanx
-
Jun 15th, 2000, 08:08 PM
#4
Lively Member
smaller code
instead of case try this
form2.picture(108-position+1).picture=form2.imgcnt1.picture
not had time to test it.
if it works it gets rid of your whole case statement
 VB6 Enterprise sp5, SQL Server2000 
-
Jun 15th, 2000, 08:17 PM
#5
Thread Starter
Junior Member
k ummm it highlights the first .picure and says compile error: Invalid qualifier.
do i have 2 Static it or something?
-
Jun 15th, 2000, 08:34 PM
#6
Junior Member
pogo,
sorry if i did not explain it that well. This should allow you to pass variable in and out.
dim player1_position as integer, player2_position as integer, player3_position as integer
do while (end condition)
player1_position = rolldice(player1_position)
Form2.Picture(player1_position).Picture = player1_image
player2_position = rolldice(player2_position)
Form2.Picture(player2_position).Picture = player2_image
player3_position = rolldice(player3_position)
Form2.Picture(player3_position).Picture = player3_image
loop
Private Sub RollDice(position as interger)
Randomize
Die1 = Int(Rnd * 6) + 1 'roll the first die
Select Case Die1 'select the appropriate graphics
Case 1
imgDie1.Picture = LoadPicture("a:\one.bmp")
Case 2
imgDie1.Picture = LoadPicture("a:\two.bmp")
Case 3
imgDie1.Picture = LoadPicture("a:\three.bmp")
Case 4
imgDie1.Picture = LoadPicture("a:\four.bmp")
Case 5
imgDie1.Picture = LoadPicture("a:\five.bmp")
Case 6
imgDie1.Picture = LoadPicture("a:\six.bmp")
End Select
Die2 = Int(Rnd * 6) + 1 'roll second die
Select Case Die2 'select the appropriate graphics
Case 1
imgDie2.Picture = LoadPicture("a:\one.bmp")
Case 2
imgDie2.Picture = LoadPicture("a:\two.bmp")
Case 3
imgDie2.Picture = LoadPicture("a:\three.bmp")
Case 4
imgDie2.Picture = LoadPicture("a:\four.bmp")
Case 5
imgDie2.Picture = LoadPicture("a:\five.bmp")
Case 6
imgDie2.Picture = LoadPicture("a:\six.bmp")
End Select
position = positon + die1 + die2
RollDice = position
End Sub
Using VB 6.0 SP 3
Bed goes up, bed goes down
-
Jun 15th, 2000, 08:50 PM
#7
Thread Starter
Junior Member
k..sorry i'm really confused.
k do my case statements still have to go in
Select Case Position
Case 1
Form2.Picture108.Picture = Form2.imgcnt1.Picture
Case 2
Form2.Picture107.Picture = Form2.imgcnt1.Picture
(those ones)
Also what is
player2_position = rolldice(player2_position)
the roll dice bit in that, is that just the roll that they get?
sorry, i'm really dumb @ VB....lol..it's tooooo hard!!
-
Jun 15th, 2000, 09:04 PM
#8
Junior Member
You Shouldn't have the 'Select Case Position' instead you should have Form2.Picture as an array
player2_position = rolldice(player2_position)
allows you to pass the current position of each player into the rolldice routine, the rolldice routine will then take the the value rolled and add it to the current positon, and then pass the new position out into the current position
ex. player1 is at position 5, and then rolls a 6, 5 gets passed into the rolldice routine, 6 gets added to 5 and then player1 position is set to 11.
Form2.Picture(player1_position).Picture = player1_image
will then put the player1_image on the 11th element of the array, making it move six spots.
Using VB 6.0 SP 3
Bed goes up, bed goes down
-
Jun 15th, 2000, 09:08 PM
#9
Thread Starter
Junior Member
oh ok
.....how would i do it as an array?
-
Jun 15th, 2000, 09:18 PM
#10
Junior Member
When you add the first image boxe to the form, copy the first one and paste another one of the form it will ask you if you want to create a controlled array select yes. You will have to add 107 of them, the first one will be element 0
Form2.Picture(0)
Form2.Picture(1)
...
Form2.Picture(107)
Using VB 6.0 SP 3
Bed goes up, bed goes down
-
Jun 15th, 2000, 09:27 PM
#11
Thread Starter
Junior Member
if i do that, then that will stuff up heaps of other code i have got. is there ne other way?
-
Jun 15th, 2000, 09:31 PM
#12
Junior Member
making it an array should eliminate alot of your code, anytime you check for the position with a select case you can just reference the array element. Even if you have to do alot of re-writing you should, you don't want to learn bad coding methods when you are first learning
Using VB 6.0 SP 3
Bed goes up, bed goes down
-
Jun 15th, 2000, 09:34 PM
#13
Thread Starter
Junior Member
it's due on tuesday but....is there no other way to make all the players have a turn in order????
-
Jun 15th, 2000, 09:51 PM
#14
Junior Member
i think that you will have to have a select case for each player and loop through them, but that will realy pad your code
good luck
Using VB 6.0 SP 3
Bed goes up, bed goes down
-
Jun 15th, 2000, 09:54 PM
#15
Thread Starter
Junior Member
k, well i'll give it ago.
thanx heaps newayz!!!
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
|