|  | 		    
					
        
         
          
         
	
          | |  | making this game work Fra : Sjoerd
 | 
 Dato :  24-04-02 10:53
 | 
 |  | 
 I'm writing a game for my daughter. It's the memory-game (finding two images
 with the same picture by turining them). At this moment the game works.
 There is only one thing I have to solve.
 
 How can I realize that every time I play the game the order of images is
 different?
 
 I have 16 different pictures (cat, dog, duck, monkey, snake, etc).  . I have
 4 rows of 8 pictures each. So every picture is used two times.
 
 How to make the following examples work?
 
 game 1:
 ---------
 picture1 = dog
 picture2 = cat
 picture3 = duck
 picture4 = dog
 picture32 = ...
 
 
 next game:
 ---------
 picture1 = cat
 picture2 = monkey
 picture3 = snake
 picture4 = duck
 picture32 = ...
 
 
 next game:
 ---------
 picture1 = ...
 picture2 = ...
 picture3 = ...
 picture4 = ...
 picture32 = ...
 
 
 
 Anyone a suggestion? More suggestions are welcome!
 
 Sjoerd
 svo@home.nl
 
 
 
 
 
 |  |  | 
  Harald Staff (24-04-2002) 
 
	
          | |  | Kommentar Fra : Harald Staff
 | 
 Dato :  24-04-02 11:36
 | 
 |  | Hi Shoerd
 
 Try this little routine (written for 8 pictures only, you take it from
 here):
 
 Option Explicit
 
 Type Selector
 ImgNo As Integer
 SortNo As Double
 End Type
 
 Dim Order(1 To 8) As Selector
 Dim Img(1 To 8) As String
 
 Sub DealImages()
 Dim i1 As Integer
 Dim i2 As Integer
 Dim TmpSelector As Selector
 'set values:
 Img(1) = "dog"
 Img(2) = "dog"
 Img(3) = "snake"
 Img(4) = "snake"
 Img(5) = "cat"
 Img(6) = "cat"
 Img(7) = "fish"
 Img(8) = "fish"
 For i1 = 1 To 8
 Order(i1).ImgNo = i1
 Next
 'shuffle:
 For i1 = 1 To 8
 Randomize
 Order(i1).SortNo = Rnd
 Next
 'sort:
 For i1 = 1 To 7
 For i2 = 1 To 7
 If Order(i1).SortNo > Order(i1 + 1).SortNo Then
 TmpSelector = Order(i2)
 Order(i2) = Order(i2 + 1)
 Order(i2 + 1) = TmpSelector
 End If
 Next
 Next
 'display:
 For i1 = 1 To 8
 MsgBox Img(Order(i1).ImgNo), , "Image " & i1
 Next
 
 End Sub
 
 HTH. Best wishes Harald
 
 
 
 "Sjoerd" <svo@home.nl> skrev i melding
 news:Eivx8.143547$oI.10186220@zwoll1.home.nl...
 >
 > I'm writing a game for my daughter. It's the memory-game (finding two
 images
 > with the same picture by turining them). At this moment the game works.
 > There is only one thing I have to solve.
 >
 > How can I realize that every time I play the game the order of images is
 > different?
 >
 > I have 16 different pictures (cat, dog, duck, monkey, snake, etc).  . I
 have
 > 4 rows of 8 pictures each. So every picture is used two times.
 >
 > How to make the following examples work?
 >
 > game 1:
 > ---------
 > picture1 = dog
 > picture2 = cat
 > picture3 = duck
 > picture4 = dog
 > picture32 = ...
 >
 >
 > next game:
 > ---------
 > picture1 = cat
 > picture2 = monkey
 > picture3 = snake
 > picture4 = duck
 > picture32 = ...
 >
 >
 > next game:
 > ---------
 > picture1 = ...
 > picture2 = ...
 > picture3 = ...
 > picture4 = ...
 > picture32 = ...
 >
 >
 >
 > Anyone a suggestion? More suggestions are welcome!
 >
 > Sjoerd
 > svo@home.nl
 >
 >
 >
 
 
 
 
 |  |  | 
 |  |