Results 1 to 9 of 9

Thread: The Memory Game

Threaded View

  1. #1

    Thread Starter
    New Member
    Join Date
    Aug 2010
    Posts
    6

    The Memory Game

    I'm new around here and if I have posted in the wrong section the I am sorry.

    Anyway, I am having an issue with a game I am developing for my project. As the name states in the title its a Memory Game. (I will post pictures to show you what I mean)







    The issue I am having is that I am creating two levels, one for beginner (less matches) and expert. Now the beginner code works perfectly, but where as the expert doesn't work. Now I used the beginner code however edited it because of the more squares, but now whenever I try to click "New Game" it just crashes VB6.

    Any Ideas? I will provide a copy of my project and code so you guys can take a look for yourself.

    Code:
    Beginner:
    Option Explicit
    Dim lblPos(1 To 16) As Integer
    Dim Tries As Integer
    Dim Pairs As Integer
    
    Sub WasteTime()
    Dim W As Long
    For W = 1 To 50000000
    Next W
    End Sub
    
    Private Sub cmdExit_Click()
    End
    End Sub
    
    
    Private Sub cmdMenu_Click()
    frmGame.Hide
    frmStart.Show
    End Sub
    
    Private Sub cmdNew_Click(Index As Integer)
    Static occupied(1 To 16) As Integer
    Dim I As Integer, GridPos As Integer
    Dim Row As Integer, Column As Integer
    Print "HighScore"
    Randomize
    For I = 1 To 16
    occupied(I) = False
    Next I
    For I = 1 To 16
    PicCover(I).Visible = True
    Do
    Row = Int(Rnd * 4) + 1
    Column = Int(Rnd * 4) + 1
    GridPos = (Row - 1) * 4 + Column
    Loop While occupied(GridPos)
    occupied(GridPos) = True
    lblPos(GridPos) = I
    lblNo(I).Top = 1200 + (Row - 1) * 720
    lblNo(I).Left = 250 + (Column - 1) * 720
    Next I
    Tries = 0
    Pairs = 0
    lblTries.Caption = 0
    End Sub
    
    
    Private Sub Form_Load()
    frmGame.Hide
    frmDifficulty.Show
    End Sub
    
    
    
    Sub PicCover_Click(Index As Integer)
    Static FirstCard As Integer, FirstCover As Integer
    Static SecondCard As Integer, SecondCover As Integer
    PicCover(Index).Visible = False
    Tries = Tries + 1
    DoEvents
    If Tries Mod 2 = 1 Then
    FirstCard = lblPos(Index)
    FirstCover = Index
    Else
    lblTries.Caption = Tries \ 2
    SecondCard = lblPos(Index)
    SecondCover = Index
    If FirstCard Mod 8 = SecondCard Mod 8 Then
    Pairs = Pairs + 1
    If Pairs = 8 Then
    MsgBox "Puzzle Solved..... Good Work"
    Print Tries / 2
    End If
    Else
    WasteTime
    PicCover(FirstCover).Visible = True
    PicCover(SecondCover).Visible = True
    End If
    End If
    End Sub
    
    Expert
    Option Explicit
    Dim lblPos(1 To 32) As Integer
    Dim Tries As Integer
    Dim Pairs As Integer
    
    Sub WasteTime()
    Dim W As Long
    For W = 1 To 50000000
    Next W
    End Sub
    
    Private Sub cmdMenu_Click()
    frmGame.Hide
    frmStart.Show
    End Sub
    
    Private Sub cmdNew_Click(Index As Integer)
    Static occupied(1 To 32) As Integer
    Dim I As Integer, GridPos As Integer
    Dim Row As Integer, Column As Integer
    Print "HighScore"
    Randomize
    For I = 1 To 32
    occupied(I) = False
    Next I
    For I = 1 To 32
    PicCover(I).Visible = True
    Do
    Row = Int(Rnd * 4) + 1
    Column = Int(Rnd * 4) + 1
    GridPos = (Row - 1) * 4 + Column
    Loop While occupied(GridPos)
    occupied(GridPos) = True
    lblPos(GridPos) = I
    lblNo(I).Top = 1200 + (Row - 1) * 720
    lblNo(I).Left = 250 + (Column - 1) * 720
    Next I
    Tries = 0
    Pairs = 0
    lblTries.Caption = 0
    End Sub
    
    Private Sub Form_Load()
    frmGame.Hide
    frmDifficulty.Show
    End Sub
    
    Private Sub PicCover_Click(Index As Integer)
    Static FirstCard As Integer, FirstCover As Integer
    Static SecondCard As Integer, SecondCover As Integer
    PicCover(Index).Visible = False
    Tries = Tries + 1
    DoEvents
    If Tries Mod 2 = 1 Then
    FirstCard = lblPos(Index)
    FirstCover = Index
    Else
    lblTries.Caption = Tries \ 2
    SecondCard = lblPos(Index)
    SecondCover = Index
    If FirstCard Mod 8 = SecondCard Mod 8 Then
    Pairs = Pairs + 1
    If Pairs = 8 Then
    MsgBox "Puzzle Solved..... Good Work"
    Print Tries / 2
    End If
    Else
    WasteTime
    PicCover(FirstCover).Visible = True
    PicCover(SecondCover).Visible = True
    End If
    End If
    End Sub
    Thanks
    Attached Files Attached Files

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width