Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Click The Button Game
#1
I'm sure many of you have already made this game, but I wanted to see if I could do it without any help. Smile 
You got 120 seconds to see how many times you can use the mouse to click the button. Plus there's the option to start over. 



Code: (Select All)

Screen _NewImage(800, 600, 32)
begin:
score = 0
buttonx = 370
buttony = 300
text$ = "Click"
_Title "Click The Button Game by SierraKen"

c = 10
For bb = 0 To 30
    c = c + 10
    Line (buttonx + bb, buttony + bb)-(buttonx2 - bb, buttony2 - bb), _RGB32(100 + c, 100 + c, 100 + c), B
Next bb
Color _RGB32(0, 0, 0)
_PrintString (buttonx + 32, buttony + 17), text$

dir = 1
t = Timer
Do

    _Limit 350
    buttonx2 = buttonx + 100
    buttony2 = buttony + 50
    ti = Timer - t
    c = 10
    For bb = 0 To 30
        c = c + 10
        Line (buttonx + bb, buttony + bb)-(buttonx2 - bb, buttony2 - bb), _RGB32(100 + c, 100 + c, 100 + c), B
    Next bb
    Color _RGB32(0, 0, 0), _RGB32(255, 255, 255)
    _PrintString (buttonx + 32, buttony + 17), text$
    Color _RGB32(255, 255, 255), _RGB32(0, 0, 0)
    Locate 1, 1: Print "Score: "; score
    Locate 2, 1: Print "Time Left: "; Int(120 - ti)
    If Int(120 - ti) < 1 Then
        Locate 30, 50
        Print "The End"
        Locate 34, 50
        Input "Again (Y/N)"; ag$
        If Left$(ag$, 1) = "y" Or Left$(ag$, 1) = "Y" Then GoTo begin:
        End
    End If
    While _MouseInput: Wend
    mousex = _MouseX
    mousey = _MouseY
    mouseLeftButton = _MouseButton(1)

    If mouseLeftButton Then
        Clear_MB 1
        If mousex > buttonx And mousex < buttonx2 And mousey > buttony And mousey < buttony2 Then

            c = 110
            _AutoDisplay
            For bb = 0 To 30
                c = c - 10
                Line (buttonx + bb, buttony + bb)-(buttonx2 - bb, buttony2 - bb), _RGB32(100 + c, 100 + c, 100 + c), B
            Next bb
            _Delay .1

            For bb = 0 To 30
                c = c + 10
                Line (buttonx + bb, buttony + bb)-(buttonx2 - bb, buttony2 - bb), _RGB32(100 + c, 100 + c, 100 + c), B
            Next bb
            _Delay .05

            c = 10
            For bb = 0 To 30
                c = c + 10
                Line (buttonx + bb, buttony + bb)-(buttonx2 - bb, buttony2 - bb), _RGB32(100 + c, 100 + c, 100 + c), B
            Next bb

            _Delay .1
            Color _RGB32(0, 0, 0), _RGB32(255, 255, 255)
            _PrintString (buttonx + 32, buttony + 17), text$
            Sound 900, 1, , , 6
            score = score + 1
            Color _RGB32(255, 255, 255), _RGB32(0, 0, 0)
            Locate 1, 1: Print "Score: "; score
            buttonx = Int(Rnd * 650) + 49
            buttony = Int(Rnd * 500) + 19
        End If
    End If

    changedir = Int(Rnd * 100) + 1
    If changedir > 95 Then
        dir = Int(Rnd * 8) + 1
    End If
    If dir = 1 Then buttony = buttony + 1
    If dir = 2 Then buttony = buttony - 1
    If dir = 3 Then buttonx = buttonx + 1
    If dir = 4 Then buttonx = buttonx - 1

    If dir = 5 Then buttony = buttony + 1: buttonx = buttonx + 1
    If dir = 6 Then buttony = buttony - 1: buttonx = buttonx - 1
    If dir = 7 Then buttonx = buttonx + 1: buttony = buttony + 1
    If dir = 8 Then buttonx = buttonx - 1: buttony = buttony - 1

    If buttonx > 700 And dir = 3 Then dir = 4
    If buttonx > 700 And dir = 7 Then dir = 8
    If buttonx < 50 And dir = 4 Then dir = 3
    If buttonx < 50 And dir = 8 Then dir = 7

    If buttony > 520 And dir = 1 Then dir = 2
    If buttony > 520 And dir = 5 Then dir = 6
    If buttony < 50 And dir = 2 Then dir = 1
    If buttony < 50 And dir = 8 Then dir = 7
    _Display
    Cls , _RGB32(0, 0, 0)


Loop until Inkey$ = CHR$(27)


Sub Clear_MB (var As Integer)

    Do Until Not _MouseButton(var)
        While _MouseInput: Wend
    Loop

End Sub 'Clear_MB
Reply


Messages In This Thread
Click The Button Game - by SierraKen - 03-24-2025, 12:15 AM
RE: Click The Button Game - by SierraKen - 03-24-2025, 01:44 AM
RE: Click The Button Game - by PhilOfPerth - 03-24-2025, 02:03 AM
RE: Click The Button Game - by SierraKen - 03-24-2025, 02:19 AM
RE: Click The Button Game - by PhilOfPerth - 03-24-2025, 02:55 AM
RE: Click The Button Game - by SierraKen - 03-24-2025, 03:26 AM
RE: Click The Button Game - by SierraKen - 03-24-2025, 03:50 PM
RE: Click The Button Game - by SierraKen - 03-25-2025, 05:35 AM
RE: Click The Button Game - by bplus - 03-25-2025, 12:16 PM
RE: Click The Button Game - by SierraKen - 03-25-2025, 05:30 PM
RE: Click The Button Game - by johnno56 - 03-27-2025, 07:01 PM
RE: Click The Button Game - by SierraKen - 03-27-2025, 07:40 PM
RE: Click The Button Game - by johnno56 - 03-28-2025, 04:50 AM
RE: Click The Button Game - by SierraKen - 03-30-2025, 03:44 PM
RE: Click The Button Game - by SquirrelMonkey - 03-30-2025, 04:20 PM
RE: Click The Button Game - by NakedApe - 03-30-2025, 05:06 PM
RE: Click The Button Game - by Pete - 03-30-2025, 06:21 PM
RE: Click The Button Game - by SierraKen - 03-31-2025, 06:35 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Find The Button Game SierraKen 1 556 03-31-2025, 11:16 PM
Last Post: SierraKen

Forum Jump:


Users browsing this thread: 1 Guest(s)