-1

vbで迷路を作成しました(mdsn.comのチュートリアルを使用)が、迷路を一周してフィニッシュまでまっすぐ進むことができるので、ユーザーがフォームを終了するとtrueに変わるチーターと呼ばれるブール値を追加してみました。後でフィニッシュに使用したラベルを入力すると、勝者ではなく詐欺師と言うmsgboxですが、常に詐欺師になります

最後のサブに焦点を当てたコードがここにあります

Public Class Form

Dim cheater As Boolean

Private BumpSoundPlayer = New System.Media.SoundPlayer("C:\Windows\Media\chord.wav")

Private finishSoundPlayer = New System.Media.SoundPlayer("C:\Windows\Media\tada.wav")

'Private cheaterSoundPlayer = New System.Media.SoundPlayer("C:\Windows\Media\\W\windows_critical_stop.wav")

Public Sub New()
    InitializeComponent()
    MoveToStart()
End Sub

Private Sub MoveToStart()
    Dim startingPoint = Panel1.Location
    startingPoint.Offset(40, 20)
    Cursor.Position = PointToScreen(startingPoint)
    cheater = False
End Sub

Private Sub wall_MouseEnter() Handles Label8.MouseEnter, Label9.MouseEnter, Label7.MouseEnter, Label60.MouseEnter, Label6.MouseEnter, Label59.MouseEnter, Label58.MouseEnter, Label57.MouseEnter, Label56.MouseEnter, Label55.MouseEnter, Label54.MouseEnter, Label53.MouseEnter, Label52.MouseEnter, Label51.MouseEnter, Label50.MouseEnter, Label5.MouseEnter, Label49.MouseEnter, Label48.MouseEnter, Label47.MouseEnter, Label46.MouseEnter, Label45.MouseEnter, Label44.MouseEnter, Label43.MouseEnter, Label42.MouseEnter, Label41.MouseEnter, Label40.MouseEnter, Label4.MouseEnter, Label39.MouseEnter, Label38.MouseEnter, Label37.MouseEnter, Label36.MouseEnter, Label35.MouseEnter, Label34.MouseEnter, Label33.MouseEnter, Label32.MouseEnter, Label31.MouseEnter, Label30.MouseEnter, Label3.MouseEnter, Label29.MouseEnter, Label28.MouseEnter, Label27.MouseEnter, Label26.MouseEnter, Label25.MouseEnter, Label24.MouseEnter, Label23.MouseEnter, Label22.MouseEnter, Label21.MouseEnter, Label20.MouseEnter, Label2.MouseEnter, Label19.MouseEnter, Label18.MouseEnter, Label17.MouseEnter, Label16.MouseEnter, Label15.MouseEnter, Label14.MouseEnter, Label13.MouseEnter, Label12.MouseEnter, Label11.MouseEnter, Label10.MouseEnter, Label1.MouseEnter
    BumpSoundPlayer.play()
    MoveToStart()
End Sub


Private Sub Panel1_MouseLeave() Handles Panel1.MouseLeave
    cheater = True
End Sub

Private Sub FinishLabel_MouseEnter() Handles FinishLabel.MouseEnter
    If cheater = True Then
        'cheaterSoundPlayer.play()
        MessageBox.Show("sneaky little cheater")
        MoveToStart()
    Else
        finishSoundPlayer.play()
        MessageBox.Show("yay you did it")
        'Close()
        MoveToStart()
    End If

End Sub

End Class
4

1 に答える 1