VERSION 5.00
Object = "{22D6F304-B0F6-11D0-94AB-0080C74C7E95}#1.0#0"; "MSDXM.OCX"
Begin VB.Form frmMain 
   BorderStyle     =   1  'Fixed Single
   Caption         =   "Frogger"
   ClientHeight    =   6435
   ClientLeft      =   45
   ClientTop       =   615
   ClientWidth     =   8970
   Icon            =   "frmMain.frx":0000
   LinkTopic       =   "Form1"
   MaxButton       =   0   'False
   MinButton       =   0   'False
   ScaleHeight     =   6435
   ScaleWidth      =   8970
   StartUpPosition =   2  'CenterScreen
   Begin VB.Timer timBonus 
      Interval        =   2000
      Left            =   4800
      Top             =   3480
   End
   Begin VB.PictureBox picNewGame 
      BackColor       =   &H00FFFFFF&
      BorderStyle     =   0  'None
      Height          =   3495
      Left            =   1680
      ScaleHeight     =   3495
      ScaleWidth      =   5295
      TabIndex        =   7
      Top             =   1560
      Visible         =   0   'False
      Width           =   5295
      Begin VB.CommandButton cmdQuit 
         Caption         =   "&Quit Game"
         Height          =   375
         Left            =   600
         TabIndex        =   9
         Top             =   2760
         Width           =   1935
      End
      Begin VB.CommandButton cmdStartNewGame 
         Caption         =   "&Start New Game"
         Height          =   375
         Left            =   600
         TabIndex        =   8
         Top             =   2160
         Width           =   1935
      End
      Begin VB.Label Label1 
         Alignment       =   2  'Center
         BackColor       =   &H00FFFFFF&
         BackStyle       =   0  'Transparent
         Caption         =   "All your Frogs are Dead!!!"
         BeginProperty Font 
            Name            =   "MS Sans Serif"
            Size            =   13.5
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   735
         Left            =   480
         TabIndex        =   10
         Top             =   1200
         Width           =   2295
      End
      Begin VB.Image Image7 
         Height          =   1815
         Left            =   3000
         Picture         =   "frmMain.frx":08CA
         Stretch         =   -1  'True
         Top             =   1320
         Width           =   1815
      End
      Begin VB.Image Image6 
         Height          =   855
         Left            =   240
         Picture         =   "frmMain.frx":23E0
         Stretch         =   -1  'True
         Top             =   240
         Width           =   4695
      End
      Begin VB.Shape Shape1 
         BorderColor     =   &H0000C000&
         BorderWidth     =   2
         Height          =   3255
         Left            =   120
         Top             =   120
         Width           =   5055
      End
   End
   Begin VB.Timer timRoad 
      Interval        =   80
      Left            =   5400
      Top             =   3480
   End
   Begin VB.Timer timRiver 
      Interval        =   80
      Left            =   6000
      Top             =   3480
   End
   Begin VB.Timer timGame 
      Interval        =   50
      Left            =   6600
      Top             =   3480
   End
   Begin VB.Timer timScore 
      Interval        =   100
      Left            =   7200
      Top             =   3480
   End
   Begin VB.Timer timCollision 
      Interval        =   20
      Left            =   7800
      Top             =   3480
   End
   Begin VB.Timer timSnake 
      Interval        =   100
      Left            =   8400
      Top             =   3480
   End
   Begin VB.Image imgBonusFly 
      Height          =   375
      Left            =   120
      Picture         =   "frmMain.frx":4B8B
      Stretch         =   -1  'True
      Top             =   5880
      Width           =   495
   End
   Begin VB.Label lblShowScore 
      AutoSize        =   -1  'True
      BackColor       =   &H00008000&
      BackStyle       =   0  'Transparent
      Caption         =   "0"
      BeginProperty Font 
         Name            =   "Arial"
         Size            =   18
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      ForeColor       =   &H00FFFFFF&
      Height          =   435
      Left            =   1560
      TabIndex        =   5
      Top             =   0
      Width           =   195
   End
   Begin VB.Image imgCar 
      Height          =   600
      Index           =   0
      Left            =   240
      Picture         =   "frmMain.frx":5010
      Top             =   3960
      Width           =   1800
   End
   Begin VB.Image imgCar 
      Height          =   600
      Index           =   4
      Left            =   600
      Picture         =   "frmMain.frx":5AD5
      Top             =   4560
      Width           =   1200
   End
   Begin VB.Image imgCar 
      Height          =   600
      Index           =   8
      Left            =   960
      Picture         =   "frmMain.frx":635E
      Top             =   5160
      Width           =   600
   End
   Begin VB.Image imgCar 
      Height          =   600
      Index           =   1
      Left            =   3120
      Picture         =   "frmMain.frx":68A2
      Top             =   3960
      Width           =   1200
   End
   Begin VB.Image imgCar 
      Height          =   600
      Index           =   5
      Left            =   2640
      Picture         =   "frmMain.frx":713E
      Top             =   4560
      Width           =   600
   End
   Begin VB.Image imgCar 
      Height          =   600
      Index           =   6
      Left            =   4560
      Picture         =   "frmMain.frx":7682
      Top             =   4560
      Width           =   1200
   End
   Begin VB.Image imgCar 
      Height          =   600
      Index           =   2
      Left            =   5760
      Picture         =   "frmMain.frx":7F0B
      Top             =   3960
      Width           =   600
   End
   Begin VB.Image imgCar 
      Height          =   600
      Index           =   3
      Left            =   7440
      Picture         =   "frmMain.frx":8464
      Top             =   3960
      Width           =   600
   End
   Begin VB.Image imgCar 
      Height          =   600
      Index           =   7
      Left            =   7080
      Picture         =   "frmMain.frx":89BD
      Top             =   4560
      Width           =   1200
   End
   Begin VB.Image imgCar 
      Height          =   600
      Index           =   11
      Left            =   7800
      Picture         =   "frmMain.frx":9246
      Top             =   5160
      Width           =   1200
   End
   Begin VB.Image imgCar 
      Height          =   600
      Index           =   9
      Left            =   2880
      Picture         =   "frmMain.frx":9ACF
      Top             =   5160
      Width           =   1800
   End
   Begin VB.Image imgCar 
      Height          =   600
      Index           =   10
      Left            =   5880
      Picture         =   "frmMain.frx":A58D
      Top             =   5160
      Width           =   600
   End
   Begin VB.Image imgSnake 
      Height          =   360
      Left            =   240
      Picture         =   "frmMain.frx":AAD1
      Top             =   3480
      Visible         =   0   'False
      Width           =   1665
   End
   Begin VB.Image imgLife 
      Height          =   375
      Index           =   0
      Left            =   8400
      Picture         =   "frmMain.frx":AFD6
      Stretch         =   -1  'True
      Top             =   5880
      Visible         =   0   'False
      Width           =   375
   End
   Begin VB.Image imgLife 
      Height          =   375
      Index           =   1
      Left            =   7920
      Picture         =   "frmMain.frx":B114
      Stretch         =   -1  'True
      Top             =   5880
      Visible         =   0   'False
      Width           =   375
   End
   Begin VB.Image imgLife 
      Height          =   375
      Index           =   2
      Left            =   7440
      Picture         =   "frmMain.frx":B252
      Stretch         =   -1  'True
      Top             =   5880
      Visible         =   0   'False
      Width           =   375
   End
   Begin VB.Image imgLife 
      Height          =   375
      Index           =   3
      Left            =   6960
      Picture         =   "frmMain.frx":B390
      Stretch         =   -1  'True
      Top             =   5880
      Visible         =   0   'False
      Width           =   375
   End
   Begin VB.Image imgLife 
      Height          =   375
      Index           =   4
      Left            =   6480
      Picture         =   "frmMain.frx":B4CE
      Stretch         =   -1  'True
      Top             =   5880
      Visible         =   0   'False
      Width           =   375
   End
   Begin VB.Image imgFrog 
      Height          =   600
      Index           =   0
      Left            =   600
      Picture         =   "frmMain.frx":B60C
      Top             =   960
      Width           =   600
   End
   Begin VB.Image imgFrog 
      Height          =   600
      Index           =   1
      Left            =   2400
      Picture         =   "frmMain.frx":B785
      Top             =   960
      Width           =   600
   End
   Begin VB.Image imgFrog 
      Height          =   600
      Index           =   2
      Left            =   4200
      Picture         =   "frmMain.frx":B8FE
      Top             =   960
      Width           =   600
   End
   Begin VB.Image imgFrog 
      Height          =   600
      Index           =   3
      Left            =   6000
      Picture         =   "frmMain.frx":BA77
      Top             =   960
      Width           =   600
   End
   Begin VB.Image imgFrog 
      Height          =   600
      Index           =   4
      Left            =   7800
      Picture         =   "frmMain.frx":BBF0
      Top             =   960
      Width           =   600
   End
   Begin VB.Image Image1 
      Height          =   1095
      Left            =   3600
      Picture         =   "frmMain.frx":BD69
      Top             =   480
      Width           =   1815
   End
   Begin VB.Image Image2 
      Height          =   1095
      Left            =   0
      Picture         =   "frmMain.frx":C57F
      Top             =   480
      Width           =   1815
   End
   Begin VB.Image Image3 
      Height          =   1095
      Left            =   1800
      Picture         =   "frmMain.frx":CD95
      Top             =   480
      Width           =   1815
   End
   Begin VB.Image Image4 
      Height          =   1095
      Left            =   5400
      Picture         =   "frmMain.frx":D5AB
      Top             =   480
      Width           =   1815
   End
   Begin VB.Image Image5 
      Height          =   1095
      Left            =   7200
      Picture         =   "frmMain.frx":DDC1
      Top             =   480
      Width           =   1815
   End
   Begin VB.Label lblScore 
      BackColor       =   &H00008000&
      BackStyle       =   0  'Transparent
      Caption         =   "SCORE:"
      BeginProperty Font 
         Name            =   "Arial"
         Size            =   18
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   -1  'True
         Strikethrough   =   0   'False
      EndProperty
      ForeColor       =   &H00C0C0FF&
      Height          =   495
      Left            =   120
      TabIndex        =   6
      Top             =   0
      Width           =   1455
   End
   Begin VB.Label lblHighScore 
      BackColor       =   &H00008000&
      BackStyle       =   0  'Transparent
      Caption         =   "HIGHSCORE:"
      BeginProperty Font 
         Name            =   "Arial"
         Size            =   18
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   -1  'True
         Strikethrough   =   0   'False
      EndProperty
      ForeColor       =   &H00C0C0FF&
      Height          =   495
      Left            =   3120
      TabIndex        =   4
      Top             =   0
      Width           =   2415
   End
   Begin VB.Label lblShowHighScore 
      AutoSize        =   -1  'True
      BackColor       =   &H00008000&
      BackStyle       =   0  'Transparent
      Caption         =   "0"
      BeginProperty Font 
         Name            =   "Arial"
         Size            =   18
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      ForeColor       =   &H00FFFFFF&
      Height          =   435
      Left            =   5520
      TabIndex        =   3
      Top             =   0
      Width           =   195
   End
   Begin VB.Label lblLevel 
      BackColor       =   &H00008000&
      BackStyle       =   0  'Transparent
      Caption         =   "LEVEL:"
      BeginProperty Font 
         Name            =   "Arial"
         Size            =   18
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   -1  'True
         Strikethrough   =   0   'False
      EndProperty
      ForeColor       =   &H00C0C0FF&
      Height          =   495
      Left            =   6840
      TabIndex        =   2
      Top             =   0
      Width           =   1335
   End
   Begin VB.Label lblShowLevel 
      AutoSize        =   -1  'True
      BackColor       =   &H00008000&
      BackStyle       =   0  'Transparent
      Caption         =   "1"
      BeginProperty Font 
         Name            =   "Arial"
         Size            =   18
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      ForeColor       =   &H00FFFFFF&
      Height          =   435
      Left            =   8280
      TabIndex        =   1
      Top             =   0
      Width           =   195
   End
   Begin VB.Shape shpTop 
      BorderColor     =   &H00008000&
      FillColor       =   &H00008000&
      FillStyle       =   0  'Solid
      Height          =   1575
      Left            =   0
      Top             =   0
      Width           =   9015
   End
   Begin VB.Line Line8 
      BorderColor     =   &H0000FFFF&
      X1              =   0
      X2              =   9000
      Y1              =   5760
      Y2              =   5760
   End
   Begin VB.Shape shpCentreGrass 
      BorderStyle     =   0  'Transparent
      FillColor       =   &H00008000&
      FillStyle       =   0  'Solid
      Height          =   615
      Left            =   0
      Top             =   3360
      Width           =   9015
   End
   Begin VB.Shape shpBottomGrass 
      BorderStyle     =   0  'Transparent
      FillColor       =   &H00008000&
      FillStyle       =   0  'Solid
      Height          =   735
      Left            =   0
      Top             =   5760
      Width           =   9015
   End
   Begin VB.Line Line1 
      BorderColor     =   &H0000FFFF&
      X1              =   0
      X2              =   9000
      Y1              =   4080
      Y2              =   4080
   End
   Begin VB.Line Line2 
      BorderColor     =   &H0000FFFF&
      X1              =   0
      X2              =   9000
      Y1              =   3960
      Y2              =   3960
   End
   Begin VB.Line Line3 
      BorderColor     =   &H0000FFFF&
      X1              =   0
      X2              =   9000
      Y1              =   5760
      Y2              =   5760
   End
   Begin VB.Line Line4 
      BorderColor     =   &H0000FFFF&
      X1              =   0
      X2              =   9000
      Y1              =   5640
      Y2              =   5640
   End
   Begin VB.Line Line5 
      BorderColor     =   &H00FFFFFF&
      BorderStyle     =   2  'Dash
      X1              =   0
      X2              =   9000
      Y1              =   5160
      Y2              =   5160
   End
   Begin VB.Line Line6 
      BorderColor     =   &H00FFFFFF&
      X1              =   0
      X2              =   9000
      Y1              =   4560
      Y2              =   4560
   End
   Begin VB.Line Line7 
      BorderColor     =   &H00FFFFFF&
      X1              =   0
      X2              =   9000
      Y1              =   4680
      Y2              =   4680
   End
   Begin MediaPlayerCtl.MediaPlayer MediaPlayer1 
      Height          =   375
      Left            =   120
      TabIndex        =   0
      Top             =   5880
      Visible         =   0   'False
      Width           =   375
      AudioStream     =   -1
      AutoSize        =   0   'False
      AutoStart       =   -1  'True
      AnimationAtStart=   -1  'True
      AllowScan       =   -1  'True
      AllowChangeDisplaySize=   -1  'True
      AutoRewind      =   0   'False
      Balance         =   0
      BaseURL         =   ""
      BufferingTime   =   5
      CaptioningID    =   ""
      ClickToPlay     =   -1  'True
      CursorType      =   0
      CurrentPosition =   -1
      CurrentMarker   =   0
      DefaultFrame    =   ""
      DisplayBackColor=   0
      DisplayForeColor=   16777215
      DisplayMode     =   0
      DisplaySize     =   4
      Enabled         =   -1  'True
      EnableContextMenu=   -1  'True
      EnablePositionControls=   -1  'True
      EnableFullScreenControls=   0   'False
      EnableTracker   =   -1  'True
      Filename        =   ""
      InvokeURLs      =   -1  'True
      Language        =   -1
      Mute            =   0   'False
      PlayCount       =   0
      PreviewMode     =   0   'False
      Rate            =   1
      SAMILang        =   ""
      SAMIStyle       =   ""
      SAMIFileName    =   ""
      SelectionStart  =   -1
      SelectionEnd    =   -1
      SendOpenStateChangeEvents=   -1  'True
      SendWarningEvents=   -1  'True
      SendErrorEvents =   -1  'True
      SendKeyboardEvents=   0   'False
      SendMouseClickEvents=   0   'False
      SendMouseMoveEvents=   0   'False
      SendPlayStateChangeEvents=   -1  'True
      ShowCaptioning  =   0   'False
      ShowControls    =   -1  'True
      ShowAudioControls=   -1  'True
      ShowDisplay     =   0   'False
      ShowGotoBar     =   0   'False
      ShowPositionControls=   -1  'True
      ShowStatusBar   =   0   'False
      ShowTracker     =   -1  'True
      TransparentAtStart=   0   'False
      VideoBorderWidth=   0
      VideoBorderColor=   0
      VideoBorder3D   =   0   'False
      Volume          =   0
      WindowlessVideo =   0   'False
   End
   Begin VB.Shape shpRoad 
      BorderStyle     =   0  'Transparent
      FillColor       =   &H00404040&
      FillStyle       =   0  'Solid
      Height          =   1815
      Left            =   0
      Top             =   3960
      Width           =   9015
   End
   Begin VB.Image imgLog 
      Height          =   600
      Index           =   0
      Left            =   240
      Picture         =   "frmMain.frx":E5D7
      Top             =   1560
      Width           =   1200
   End
   Begin VB.Image imgLog 
      Height          =   600
      Index           =   1
      Left            =   2040
      Picture         =   "frmMain.frx":F0A5
      Top             =   1560
      Width           =   1800
   End
   Begin VB.Image imgLog 
      Height          =   600
      Index           =   3
      Left            =   6000
      Picture         =   "frmMain.frx":FFF4
      Top             =   1560
      Width           =   1200
   End
   Begin VB.Image imgLog 
      Height          =   600
      Index           =   2
      Left            =   4680
      Picture         =   "frmMain.frx":10AC2
      Top             =   1560
      Width           =   600
   End
   Begin VB.Image imgLog 
      Height          =   600
      Index           =   4
      Left            =   7800
      Picture         =   "frmMain.frx":11122
      Top             =   1560
      Width           =   1200
   End
   Begin VB.Image imgLog 
      Height          =   600
      Index           =   5
      Left            =   600
      Picture         =   "frmMain.frx":11BF0
      Top             =   2160
      Width           =   600
   End
   Begin VB.Image imgLog 
      Height          =   600
      Index           =   6
      Left            =   2280
      Picture         =   "frmMain.frx":12250
      Top             =   2160
      Width           =   1800
   End
   Begin VB.Image imgLog 
      Height          =   600
      Index           =   7
      Left            =   5040
      Picture         =   "frmMain.frx":1319F
      Top             =   2160
      Width           =   1200
   End
   Begin VB.Image imgLog 
      Height          =   600
      Index           =   8
      Left            =   6960
      Picture         =   "frmMain.frx":13C6D
      Top             =   2160
      Width           =   1800
   End
   Begin VB.Image imgLog 
      Height          =   600
      Index           =   9
      Left            =   360
      Picture         =   "frmMain.frx":14BBC
      Top             =   2760
      Width           =   1800
   End
   Begin VB.Image imgLog 
      Height          =   600
      Index           =   10
      Left            =   3720
      Picture         =   "frmMain.frx":15B0B
      Top             =   2760
      Width           =   1200
   End
   Begin VB.Image imgLog 
      Height          =   600
      Index           =   11
      Left            =   6240
      Picture         =   "frmMain.frx":165D9
      Top             =   2760
      Width           =   1800
   End
   Begin VB.Shape shpRiver 
      BackColor       =   &H00FF8080&
      BorderColor     =   &H00000000&
      BorderStyle     =   0  'Transparent
      FillColor       =   &H00FF8080&
      FillStyle       =   0  'Solid
      Height          =   1815
      Left            =   0
      Top             =   1560
      Width           =   9015
   End
   Begin VB.Menu mnuFile 
      Caption         =   "&File"
      Begin VB.Menu mnuMusic 
         Caption         =   "&Music Off"
      End
      Begin VB.Menu mnuDivider 
         Caption         =   "-"
      End
      Begin VB.Menu mnuNew 
         Caption         =   "&New Game"
      End
      Begin VB.Menu mnuExit 
         Caption         =   "E&xit Game"
      End
   End
   Begin VB.Menu mnuHelp 
      Caption         =   "&Help"
      Begin VB.Menu mnuAbout 
         Caption         =   "&About Frogger"
      End
      Begin VB.Menu mnuHowTo 
         Caption         =   "How &To Play"
      End
   End
End
Attribute VB_Name = "frmMain"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit

Dim Ribbit As String
Dim Dead As String
Dim Giggle As String
Dim Yippee As String
Dim Hop As String
Dim GameOver As String
Dim strPath As String
Dim RtnValue As Long

Dim i As Integer
Dim j As Integer
Dim k As Integer
Dim l As Integer
Dim m As Integer
Dim FrogIndex As Integer
Dim Lives As Integer
Dim Score As Long
Dim HighScore As Long
Dim FrogState(4) As Integer
Dim Home(4) As Boolean
Dim LogSpeed(11) As Integer
Dim NumOfLogs As Integer
Dim ExtraLifeCount As Integer
Dim FrogLog(11) As Boolean
Dim Dry As Boolean
Dim CarSpeed(11) As Integer
Dim NumOfCars As Integer
Dim Level As Integer
Dim Result  As Variant
Dim SnakeAlive As Boolean
Dim Swap As Integer
Dim SwapCount As Integer

'API Functions
Private Declare Function BitBlt Lib "gdi32" (ByVal hDestDC As Long, ByVal X As Long, ByVal y As Long, ByVal nWidth As Long, ByVal nHeight As Long, ByVal hSrcDC As Long, ByVal xSrc As Long, ByVal ySrc As Long, ByVal dwRop As Long) As Long
Private Const SRCCOPY = &HCC0020
Private Declare Function sndPlaySound Lib "winmm.dll" Alias "sndPlaySoundA" (ByVal lpszSoundName As String, ByVal uFlags As Long) As Long
Private Const SND_ASYNC = &H1
Private Const SND_SYNC = &H0
Private Const SND_MEMORY = &H4
Private Const SND_FILENAME = &H20000

Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)


Private Function StoreSound(ByVal FileName) As String
Dim Buffer As String
Dim F As Integer
Dim SoundBuffer As String
On Error GoTo NoiseGet_Error
Buffer = Space(1024)
SoundBuffer = ""
F = FreeFile
Open FileName For Binary As F
Do While Not EOF(F)
    Get #F, , Buffer
    SoundBuffer = SoundBuffer & Buffer
Loop
Close F
StoreSound = Trim(SoundBuffer)
Exit Function
NoiseGet_Error:
SoundBuffer = ""
Exit Function
End Function

Private Sub cmdQuit_Click()
'Quit Game
    End
End Sub

Private Sub cmdStartNewGame_Click()
'Start New Game
    initialiseGame
End Sub

Private Sub Form_Load()
'Store Sounds in variables
If Right(App.Path, 1) = "\" Then
        strPath = App.Path
    Else
        strPath = App.Path & "\"
    End If
    
    Ribbit = strPath & "sounds\Ribbit.wav"
    Dead = strPath & "sounds\Die.wav"
    GameOver = strPath & "sounds\GameOver.wav"
    Giggle = strPath & "sounds\Giggle.wav"
    Yippee = strPath & "sounds\Yippee.wav"
    Hop = strPath & "sounds\Hop.wav"
'Play background music in a loop
    MediaPlayer1.FileName = strPath & "sounds\music.wav"
    MediaPlayer1.Play
'Start game
    initialiseGame
End Sub

Private Sub mnuAbout_Click()
'Load About Game Form
    frmAbout.Show vbModal
End Sub

Private Sub mnuExit_Click()
'Exit Game
Dim Response As Integer
Response = MsgBox("Are you sure you want to quit?", vbYesNo + vbCritical + vbDefaultButton2, "Quit Frogger")
If Response = vbNo Then
    Exit Sub
Else
    End
End If
End Sub

Private Sub mnuHowTo_Click()
'Load How To Play Form
    frmHowToPlay.Show vbModal
End Sub

Private Sub mnuMusic_Click()
'If music is On then turn it Off
If mnuMusic.Caption = "&Music Off" Then
    MediaPlayer1.FileName = strPath & "sounds\music.wav"
    MediaPlayer1.Stop
    mnuMusic.Caption = "&Music On"
Else
'If music is Off then turn it On
    MediaPlayer1.FileName = strPath & "sounds\music.wav"
    MediaPlayer1.Play
    mnuMusic.Caption = "&Music Off"
End If
End Sub

Private Sub mnuNew_Click()
'Make sure player wants to start new game
Dim Response As Integer
Response = MsgBox("Are you sure you want to start a new game?", vbYesNo + vbCritical + vbDefaultButton2, "Frogger")
If Response = vbNo Then
    Exit Sub
Else
'Start new game
    initialiseGame
End If
End Sub

Private Sub initialiseGame()
picNewGame.Visible = False
'Reset Score and Lives
Lives = 4
Score = 0
Level = 1
'Set number of Logs, Cars and Speeds
NumOfLogs = 12
NumOfCars = 12
For i = 0 To 4: LogSpeed(i) = 75: Next i
For i = 5 To 8: LogSpeed(i) = -50: Next i
For i = 9 To 11: LogSpeed(i) = 25: Next i
For i = 0 To 3: CarSpeed(i) = 50: Next i
For i = 4 To 7: CarSpeed(i) = -50: Next i
For i = 8 To 11: CarSpeed(i) = -25: Next i
For i = 0 To 4
    FrogState(i) = 0
    imgFrog(i).Visible = False
Next i
For i = 0 To 4
    Home(i) = False
Next i
imgCar(3).Visible = False
imgCar(6).Visible = False
imgCar(10).Visible = False
imgCar(4).Visible = False
imgCar(0).Visible = False
imgLog(3).Visible = True
imgLog(6).Visible = True
imgLog(11).Visible = True
'Start Timers
timSnake.Enabled = True
timScore.Enabled = True
timRoad.Enabled = True
timRiver.Enabled = True
timCollision.Enabled = True
timGame.Enabled = True
timBonus.Enabled = True
For i = 0 To 4
    imgLife(i).Visible = False
Next i
If Lives - 1 > 4 Then j = 4 Else j = Lives - 1
For i = 0 To j
    imgLife(i).Visible = True
Next i
newFrog
End Sub


Private Sub timBonus_Timer()
Dim GameTop As Single
Dim GameLeft As Single
    
'Code for Bonus Fly
Randomize
With imgBonusFly
    GameTop = Rnd * (Height - .Height)
    GameLeft = Rnd * (Width - .Width)
    .Move GameLeft, GameTop
End With

'Froggy gets Fly
If imgBonusFly.Left < imgFrog(FrogIndex).Left + imgFrog(FrogIndex).Width _
And imgBonusFly.Left + imgBonusFly.Width > imgFrog(FrogIndex).Left _
And imgBonusFly.Top < imgFrog(FrogIndex).Top + imgFrog(FrogIndex).Height _
And imgBonusFly.Top + imgBonusFly.Height > imgFrog(FrogIndex).Top Then Bonus
End Sub

Private Sub timCollision_Timer()
k = imgFrog(FrogIndex).Top
If (k <> 2760 And k <> 2160 And k <> 1560) Then
    GoTo Road:
Else
'Collision in River
    For i = 0 To NumOfLogs - 1
        If FrogLog(i) = True Then GoTo Safe
    Next i
    For i = 0 To NumOfLogs - 1
        If imgLog(i).Visible = True And (imgLog(i).Left - 250 <= imgFrog(FrogIndex).Left) _
        And (imgFrog(FrogIndex).Left + 600 <= imgLog(i).Left + imgLog(i).Width + 250) _
        And (imgLog(i).Top = k) Then
        For j = 0 To NumOfLogs - 1
        FrogLog(j) = False
    Next j
        FrogLog(i) = True
        GoTo Safe
    End If
    Next i
Safe:
Dry = False
    For i = 0 To 11
        If FrogLog(i) = True Then Dry = True
    Next i
    If Dry = False Then DeadFrog
End If
Road:
If (k <> 5160 And k <> 4560 And k <> 3960) Then
    GoTo Grass
Else
'Collision on Road
    For i = 0 To NumOfCars - 1
        If imgCar(i).Top = imgFrog(FrogIndex).Top _
        And imgCar(i).Visible = True _
        And (imgCar(i).Left + imgCar(i).Width >= imgFrog(FrogIndex).Left And imgCar(i).Left <= imgFrog(FrogIndex).Left + 600) _
        Then DeadFrog
    Next i
End If
Grass:
If (k <> 3360) Then
    GoTo Home
Else
'Collision on Grass
    If imgSnake.Left < imgFrog(FrogIndex).Left + imgFrog(FrogIndex).Width _
    And imgSnake.Left + imgSnake.Width > imgFrog(FrogIndex).Left Then DeadFrog
End If
Home:
End Sub

Private Sub timGame_Timer()
If Lives >= 1 Then
    'If all Frogs are Home then Reset Frog State
    If FrogState(0) = 1 And FrogState(1) = 1 And FrogState(2) = 1 And FrogState(3) = 1 And FrogState(4) = 1 Then
    For i = 0 To 4
        FrogState(i) = 0
    Next i
    newFrog
End If
Else
    gameEnd
End If
End Sub

Private Sub timRiver_Timer()
'Move logs on the River
For l = 0 To NumOfLogs - 1
    If FrogLog(l) = True Then
        imgFrog(FrogIndex).Left = imgFrog(FrogIndex).Left + LogSpeed(l)
        If (imgFrog(FrogIndex).Left) < 0 Or imgFrog(FrogIndex).Left + imgFrog(FrogIndex).Width > frmMain.ScaleWidth Then DeadFrog
    End If
    imgLog(l).Left = imgLog(l).Left + LogSpeed(l)
    If imgLog(l).Left > frmMain.ScaleWidth + (200 * Int(Rnd * 3)) Then imgLog(l).Left = 0 - imgLog(l).Width
    If imgLog(l).Left < (0 - imgLog(l).Width - (200 * Int(Rnd * 2))) Then imgLog(l).Left = frmMain.ScaleWidth
Next l
End Sub

Private Sub timRoad_Timer()
'Move Traffic on the Road
For l = 0 To NumOfCars - 1
    imgCar(l).Left = imgCar(l).Left + CarSpeed(l)
    If imgCar(l).Left > frmMain.ScaleWidth + (50) Then imgCar(l).Left = 0 - imgCar(l).Width
    If imgCar(l).Left < (0 - imgCar(l).Width - (50)) Then imgCar(l).Left = frmMain.ScaleWidth
Next l
End Sub

Private Sub timScore_Timer()
'Show Score, High Score and Level
lblShowScore.Caption = Str(Score)
If Score > HighScore Then HighScore = Score
lblShowHighScore.Caption = Str(HighScore)
lblShowLevel.Caption = Str(Level)

'If no Lives left then Stop
If Lives <= 0 Then GoTo GameOver
For i = Lives - 1 To 4
    imgLife(i).Visible = False
Next i
If Lives <= 1 Then GoTo GameOver
For i = Lives - 2 To 0 Step -1
    imgLife(i).Visible = True
Next i
GameOver:
End Sub

Private Sub timSnake_Timer()
'Animate and move Snake across grass
If SnakeAlive = False Then
    If Int(Rnd * 10) = 1 Then
        SnakeAlive = True
        imgSnake.Left = -1700
        imgSnake.Visible = True
        Swap = 0
        SwapCount = 0
    End If
Else
    imgSnake.Visible = True
    imgSnake.Left = imgSnake.Left + 80
    If imgSnake.Left > 11000 Then
        imgSnake.Visible = False
        SnakeAlive = False
        GoTo 300
    End If
    SwapCount = SwapCount + 1
    If SwapCount > 1 Then
        SwapCount = 0
        If Swap = 0 Then
            Swap = 1
            imgSnake = LoadPicture(App.Path & "\graphics\snake1.gif")
        Else
            Swap = 0
            imgSnake = LoadPicture(App.Path & "\graphics\snake2.gif")
        End If
    End If
End If
300:
End Sub

Private Sub homeCheck()
'Check if Frogs are in Home State
j = imgFrog(FrogIndex).Left
If (j > 500 And j < 700 And Home(0) = False) Then
    Home(0) = True
    imgFrog(FrogIndex).Top = 960
    imgFrog(FrogIndex).Left = 600
    'Load Picture of Froggy in Home State
    imgFrog(FrogIndex) = LoadPicture(App.Path & "\graphics\froggyHome.gif")
    Refresh
    FrogState(FrogIndex) = 1
    allFrogsHomeCheck
    newFrog
Else
If (j > 2300 And j < 2500 And Home(1) = False) Then
    Home(1) = True
    imgFrog(FrogIndex).Top = 960
    imgFrog(FrogIndex).Left = 2400
    'Load Picture of Froggy in Home State
    imgFrog(FrogIndex) = LoadPicture(App.Path & "\graphics\froggyHome.gif")
Refresh
FrogState(FrogIndex) = 1
allFrogsHomeCheck
newFrog
Else
If (j > 4100 And j < 4300 And Home(2) = False) Then
    Home(2) = True
    imgFrog(FrogIndex).Top = 960
    imgFrog(FrogIndex).Left = 4200
    'Load Picture of Froggy in Home State
    imgFrog(FrogIndex) = LoadPicture(App.Path & "\graphics\froggyHome.gif")
    Refresh
    FrogState(FrogIndex) = 1
    allFrogsHomeCheck
    newFrog
Else
If (j > 5900 And j < 6100 And Home(3) = False) Then
    Home(3) = True
    imgFrog(FrogIndex).Top = 960
    imgFrog(FrogIndex).Left = 6000
    'Load Picture of Froggy in Home State
    imgFrog(FrogIndex) = LoadPicture(App.Path & "\graphics\froggyHome.gif")
    Refresh
    FrogState(FrogIndex) = 1
    allFrogsHomeCheck
    newFrog
Else
If (j > 7700 And j < 7900 And Home(4) = False) Then
    Home(4) = True
    imgFrog(FrogIndex).Top = 960
    imgFrog(FrogIndex).Left = 7800
    'Load Picture of Froggy in Home State
    imgFrog(FrogIndex) = LoadPicture(App.Path & "\graphics\froggyHome.gif")
    Refresh
    FrogState(FrogIndex) = 1
    allFrogsHomeCheck
    newFrog
Else
    'Froggy dead
    DeadFrog
End If
End If
End If
End If
End If
End Sub

Private Sub DeadFrog()
'Play Dead sound
RtnValue = sndPlaySound(Dead, SND_FILENAME Or SND_ASYNC)
'Play Froggy Dead Animation
For i = 1 To 3
    imgFrog(FrogIndex) = LoadPicture(App.Path & "\graphics\frogUp1.gif")
    imgFrog(FrogIndex).Refresh
    Sleep (100)
    imgFrog(FrogIndex) = LoadPicture(App.Path & "\graphics\frogRight1.gif")
    imgFrog(FrogIndex).Refresh
    Sleep (100)
    imgFrog(FrogIndex) = LoadPicture(App.Path & "\graphics\frogDown1.gif")
    imgFrog(FrogIndex).Refresh
    Sleep (100)
    imgFrog(FrogIndex) = LoadPicture(App.Path & "\graphics\frogLeft1.gif")
    imgFrog(FrogIndex).Refresh
    Sleep (100)
    imgFrog(FrogIndex) = LoadPicture(App.Path & "\graphics\frogUp1.gif")
    imgFrog(FrogIndex).Refresh
    Sleep (100)
Next i
Sleep (500)
'If no Frogs left then Game Over
Lives = Lives - 1
If Lives = 0 Then
    gameEnd
Else
newFrog
End If
End Sub

Private Sub Bonus()
'Play Yippee sound
RtnValue = sndPlaySound(Yippee, SND_FILENAME Or SND_ASYNC)
'Add bonus points to score
Score = Score + 500
End Sub

Private Sub allFrogsHomeCheck()
Score = Score + 150
'Play Giggle sound
RtnValue = sndPlaySound(Giggle, SND_FILENAME Or SND_ASYNC)
Sleep (1500)
j = 0
For i = 0 To 4
    If Home(i) = True Then j = j + 1
Next i
If j = 5 Then newLevel
End Sub

Private Sub newLevel()
'Score Bonus, gain extra life
Score = Score + 500
Level = Level + 1
ExtraLifeCount = ExtraLifeCount + 1
If ExtraLifeCount = 3 Then ExtraLifeCount = 0: Lives = Lives + 1
'Increase speed for new level
timRoad.Interval = timRoad.Interval - 15
If timRoad.Interval < 50 Then timRoad.Interval = 50
timRiver.Interval = timRiver.Interval - 15
If timRiver.Interval < 50 Then timRiver.Interval = 50
'Set number of cars, trucks and lorries
For i = 0 To NumOfCars - 1
    imgCar(i).Visible = True
Next i
If Level = 1 Then
    imgLog(0).Visible = False
    imgCar(3).Visible = False
    imgCar(6).Visible = False
    imgCar(10).Visible = False
    imgCar(4).Visible = False
    imgCar(0).Visible = False
End If
If Level = 2 Then
    imgLog(0).Visible = False
    imgLog(6).Visible = False
    imgCar(3).Visible = False
    imgCar(6).Visible = False
    imgCar(10).Visible = False
End If
If Level = 3 Then
    imgLog(0).Visible = False
    imgLog(6).Visible = False
    imgLog(11).Visible = False
    imgCar(3).Visible = False
End If
If Level >= 4 Then
    imgLog(0).Visible = False
    imgLog(6).Visible = False
    imgLog(11).Visible = False
End If
For i = 0 To 4
    Home(i) = False
    FrogState(i) = 0
    imgFrog(i).Visible = False
Next i
'Play Ribbit sound
RtnValue = sndPlaySound(Ribbit, SND_FILENAME Or SND_ASYNC)
newFrog
End Sub


Private Sub newFrog()
'Select Frog from 0-4
While FrogState(FrogIndex) <> 0
    FrogIndex = Int(Rnd * 5)
Wend
    imgFrog(FrogIndex).Visible = True
    imgFrog(FrogIndex).Top = 5760
    imgFrog(FrogIndex).Left = 4200
    NumOfLogs = 12 '?
    For i = 0 To NumOfLogs - 1
        FrogLog(i) = False
    Next i
End Sub


Private Sub gameEnd()
'Play Game Over sound
RtnValue = sndPlaySound(GameOver, SND_FILENAME Or SND_ASYNC)
Sleep (3000)
'Stop the Timers
timSnake.Enabled = False
timScore.Enabled = False
timRoad.Enabled = False
timRiver.Enabled = False
timCollision.Enabled = False
timGame.Enabled = False
timBonus.Enabled = False
picNewGame.Visible = True
End Sub


Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = 38 Then moveUp
If KeyCode = 40 Then moveDown
If KeyCode = 37 Then moveLeft
If KeyCode = 39 Then moveRight
If KeyCode = 80 Then PauseGame
End Sub


Private Sub moveUp()
For m = 0 To NumOfLogs - 1
    FrogLog(m) = False
Next m
If imgFrog(FrogIndex).Top > 1560 Then
    'Change Image
    imgFrog(FrogIndex) = LoadPicture(App.Path & "\graphics\frogUp2.gif")
    'Play Hop sound
    RtnValue = sndPlaySound(Hop, SND_FILENAME Or SND_ASYNC)
    Score = Score + 50
    imgFrog(FrogIndex).Top = imgFrog(FrogIndex).Top - 600
    imgFrog(FrogIndex) = LoadPicture(App.Path & "\graphics\frogUp1.gif")
Else
    'Check if Frog is Home yet
    homeCheck
End If
DoEvents
End Sub


Private Sub moveDown()
For m = 0 To NumOfLogs - 1
    FrogLog(m) = False
Next m
If imgFrog(FrogIndex).Top < 5760 Then
    'Change Image
    imgFrog(FrogIndex) = LoadPicture(App.Path & "\graphics\frogDown2.gif")
    'Play Hop sound
    RtnValue = sndPlaySound(Hop, SND_FILENAME Or SND_ASYNC)
    Score = Score + 10
    imgFrog(FrogIndex).Top = imgFrog(FrogIndex).Top + 600
    imgFrog(FrogIndex) = LoadPicture(App.Path & "\graphics\frogDown1.gif")
End If
DoEvents
End Sub


Private Sub moveLeft()
For m = 0 To NumOfLogs - 1
    FrogLog(m) = False
Next m
If imgFrog(FrogIndex).Left > 0 Then
    'Change Image
    imgFrog(FrogIndex) = LoadPicture(App.Path & "\graphics\frogLeft2.gif")
    'Play Hop sound
    RtnValue = sndPlaySound(Hop, SND_FILENAME Or SND_ASYNC)
    Score = Score + 5
    imgFrog(FrogIndex).Left = imgFrog(FrogIndex).Left - 600
    imgFrog(FrogIndex) = LoadPicture(App.Path & "\graphics\frogLeft1.gif")
End If
DoEvents
End Sub


Private Sub moveRight()
For m = 0 To NumOfLogs - 1
    FrogLog(m) = False
Next m
If imgFrog(FrogIndex).Left < 8400 Then
    'Change Image
    imgFrog(FrogIndex) = LoadPicture(App.Path & "\graphics\frogRight2.gif")
    'Play Hop sound
    RtnValue = sndPlaySound(Hop, SND_FILENAME Or SND_ASYNC)
    Score = Score + 5
    imgFrog(FrogIndex).Left = imgFrog(FrogIndex).Left + 600
    imgFrog(FrogIndex) = LoadPicture(App.Path & "\graphics\frogRight1.gif")
End If
DoEvents
End Sub


Private Sub PauseGame()
'Pause all Timers
timGame.Enabled = Not (timGame.Enabled)
timBonus.Enabled = Not (timBonus.Enabled)
timCollision.Enabled = Not (timCollision.Enabled)
timRiver.Enabled = Not (timRiver.Enabled)
timRoad.Enabled = Not (timRoad.Enabled)
timSnake.Enabled = Not (timSnake.Enabled)
timScore.Enabled = Not (timScore.Enabled)
End Sub
