VB.NET – Build a small teasing game with VB

The game is indeed small, and really teasing… Actually, it has no interface, no gameplay, nothing. It can be used by professional CS players to train their mouses and brains. Or just to break their keyboard, if they are really nervous.

Anyway, this is the game screen:

game_1

 

The point is to make the values of X and Y equal. These are controlled by the mouse cursor. Anyway, to make it, you should only be staying in the  rectangular in the top left corner. Once you manage, you get a message box. And the score is updated. I was thinking of making it a little better, adding some interface and timers, but I realized that it is really teasing to try to do it. So, it is like this. The interesting part is, that one may see how the numbers from the coordination system are generated by the movement of the mouse.

Pretty much, that is it. You need Windows Form application from Visual Studio with 8 labels to do it. The labels were not named properly 🙂 Like this:

game_2

So far that is it. This is the code in the form:

Public Class Form1

    Function a() As Long
        a = CInt(Math.Ceiling(Rnd() * 30)) + 20
    End Function
    Function b() As Long
        b = CInt(Math.Ceiling(Rnd() * 30)) + 20
    End Function
    Function c() As Long
        c = CInt(Math.Ceiling(Rnd() * 100)) + 90
    End Function
    Function d() As Long
        d = CInt(Math.Ceiling(Rnd() * 100)) + 90
    End Function

    Private my_rectangle As Rectangle = New Rectangle(a(), b(), c(), d())
    Private my_result As Long

    Private Sub Form1_paint(sender As Object, e As PaintEventArgs) Handles MyBase.Paint
        e.Graphics.DrawRectangle(New Pen(Color.Blue), my_rectangle)
    End Sub

    Private Sub Form1_MouseMove(sender As Object, e As MouseEventArgs) Handles MyBase.MouseMove

        If (my_rectangle.Contains(e.X, e.Y)) AndAlso (e.X.ToString() = e.Y.ToString()) Then
            Label6.Text = "Check!"
            my_result += 1
            MsgBox("Bravo!", MsgBoxStyle.Critical, "VitoshAcademy.Com")
        End If

        Label1.Text = "X=" & e.X.ToString()
        Label2.Text = "Y=" & e.Y.ToString()
        Label3.Text = e.Y * e.X
        Label4.Text = e.Y + e.X
        Label5.Text = Math.Abs(e.X - e.Y)
        Label6.Text = e.X / e.Y
        Label7.Text = Math.Sqrt(e.X)
        Label8.Text = "Score is " & my_result
        
    End Sub
End Class

The code is also in GitHub here! Enjoy it! 😀