Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Brick Smasher 3
#1
This is a Breakout-style game. Except in this one, you can move the paddle with the mouse anywhere on the screen to hit the balls and break the bricks. 
Also, the bottom area has a moving space where you try to avoid with the balls. There are 3 different extra goodies that come down from some of the random bricks and you must put your paddle on them to use them. One is "500" which is 500 extra points. The other is "More" where another green ball come into play. And the last one is "Super" where a new red ball comes that can go straight through the bricks without deflecting on them. The limit of balls on the screen is 5. 

I've been wanting to update Brick Smasher 1 for a few years. Brick Smasher 2 was never fully developed. On this one I am finally able to deflect the ball mostly in the opposite direction as where it was hit. But I also added a tiny bit of randomness to it too in case the ball was caught moving completely sideways or completely vertical. I also added the new sounds that QB64pe has which I recently learned about. 

I hope you all like playing it as much as I have. There might be some quirks. For example a text coming down will disappear if another one of the same text appears somewhere else. There might be times where the ball goes through the paddle, but I fixed almost all of that. Or if the ball is coming upward and doesn't bounce back down sometimes. But in my mind, it takes me back to the Atari days when those games weren't perfect either. Smile Tell me what you think, thanks.

Code: (Select All)

'Brick Smasher 3 by SierraKen
'Made on Feb. 27, 2025

'Use your mouse to bounce the balls to break the bricks.
'Collect the different texts that come down when you break the bricks.
'The texts described at the start.

'This is a freeware game.
'Any similar name is completely coincidental and not intended.

Randomize Timer
Screen _NewImage(800, 600, 32)

num = 126

Dim brickx(num), bricky(num), size(num), red(num), green(num), blue(num)
Dim bpoints(num), ba(num)
Dim px(20), py(20), pa(20), pc(20) As _Unsigned Long
Dim super(num), superduper(20)
Dim c As Long

level = 1
score = 0
ball = 3
speed = 3 ' Speed of ball
snd = 900
For yyy = 10 To 440 Step 20
    _Limit 300
    Randomize Timer
    sz = Int(Rnd * 50) + 10
    Randomize Timer
    xxx = Int(Rnd * 570) + 10
    Randomize Timer
    c = Int(Rnd * 225) + 30
    Randomize Timer
    c2 = Int(Rnd * 225) + 30
    Randomize Timer
    c3 = Int(Rnd * 225) + 30
    Circle (xxx, yyy), sz, _RGB32(c, c2, c3)
    Paint (xxx, yyy), _RGB32(c, c2, c3), _RGB32(c, c2, c3)
    _Delay .1
    snd = snd - 10
    Sound snd, .25
    Circle (xxx, yyy), sz, _RGB32(0, 0, 0)
    Paint (xxx, yyy), _RGB32(0, 0, 0)
Next yyy
Sound 100, .5
_PrintString (284, 50), "B R I C K  S M A S H E R  3"
_PrintString (352, 80), "By SierraKen"
_Delay 2
Cls
Print: Print: Print
Print "                      Use the mouse to move the paddle,"
Print "                      to hit the balls to break the bricks."
Print
Print "                      500:  500 points added."
Print "                      More:  An added ball to use."
Print "                      Super: A red ball that goes through the bricks."
Print
Print "                      Esc: Quits at anytime."
Print: Print: Print: Print
Print "                      Press left mouse button to begin!"
Do: While _MouseInput: Wend: Loop Until _MouseButton(1)
Cls


begin:
slotx = 10
sloty = 590
dir = 1
b = 0
hit = 0
balls = 1
c = _RGB32(255, 0, 0)

For clr = 1 To 5
    superduper(clr) = 0
Next clr

For bb = 60 To 320 Step 20
    For b2 = 50 To 740 Step 40
        b = b + 1
        If b > num Then GoTo nex:
        bricky(b) = bb
        brickx(b) = b2
        size(b) = 50
        red(b) = Rnd * 155
        red(b) = red(b) + 100
        green(b) = Rnd * 155
        green(b) = green(b) + 100
        blue(b) = Rnd * 155
        blue(b) = blue(b) + 100
        bonus = Int(Rnd * 100) + 1
        If bonus > 95 Then bpoints(b) = 1
        bl = Int(Rnd * 100) + 1
        If bl > 95 Then ba(b) = 1
        sup = Int(Rnd * 100 + 1)
        If sup > 98 Then super(b) = 1
    Next b2
Next bb


nex:

' thses remain constant
px = 350: py = 250: pr = 5 ' <<<< label everything of ball with p


mr = 80 ' <<<< Radius of paddle. Everything that starts with m is the mouse paddle.

start:
px(1) = 400: py(1) = 300
Cls

pa(1) = _Pi(2) * Rnd ' pa = ball angle this is rnd times all directions 0 to 360 in degrees 0 to 2*pi in radians

Play "mb"
_Title "Score: " + Str$(score) + "    Level: " + Str$(level) + "    Ball: " + Str$(ball)
Do

    _Limit 80
    Line (10, 10)-(790, 590), _RGB32(255, 255, 255), B

    For b = 1 To num
        Line (brickx(b), bricky(b))-(brickx(b) + 20, bricky(b) + 10), _RGB32(red(b), green(b), blue(b)), BF

        a$ = InKey$
        If a$ = " " Then GoTo start:
        If a$ = Chr$(27) Then End

        While _MouseInput: Wend
        mx = _MouseX
        my = _MouseY

        Line (mx, my)-(mx + mr, my + 10), c, BF

        If balls > 5 Then balls = 5
        For d = 1 To balls
            'Detect ball collision with bricks.
            If px(d) > brickx(b) And px(d) < brickx(b) + 22 And py(d) > bricky(b) And py(d) < bricky(b) + 12 Then
                If superduper(d) = 1 Then GoTo through
                If Sin(pa(d)) > 0 Then ' Ball is moving downward
                    py(d) = bricky(b) - 4 ' Move ball just above the paddle
                Else ' Ball is moving upward (hitting bottom of paddle)
                    py(d) = bricky(b) + 14 ' Move ball just below the paddle
                End If
                'pa(d) = -pa(d)
                pa(d) = _Atan2(py(d) - bricky(b), px(d) - brickx(b))
                px(d) = px(d) + speed * Cos(pa(d))
                py(d) = py(d) + speed * Sin(pa(d))

                through:
                score = score + 10
                Sound 600, 1, , , 4, 5
                _Title "Score: " + Str$(score) + "    Level: " + Str$(level) + "    Ball: " + Str$(ball)
                hit = hit + 1
                If bpoints(b) = 1 Then
                    bbx2 = brickx(b): bby2 = bricky(b)
                    time2 = 1000
                    Sound 700, 1, , , 4, 5
                    Sound 725, 1, , , 4, 5
                    Sound 750, 1, , , 4, 5
                    Sound 775, 1, , , 4, 5
                    Sound 800, 1, , , 4, 5
                End If

                If ba(b) = 1 And balls < 5 Then
                    bbx3 = brickx(b): bby3 = bricky(b)
                    time5 = 1000
                    Sound 700, 1, , , 4, 5
                    Sound 725, 1, , , 4, 5
                    Sound 750, 1, , , 4, 5
                    Sound 775, 1, , , 4, 5
                    Sound 800, 1, , , 4, 5
                End If

                If super(b) = 1 And balls < 5 Then
                    bbx4 = brickx(b): bby4 = bricky(b)
                    time100 = 1000
                    Sound 700, 1, , , 4, 5
                    Sound 725, 1, , , 4, 5
                    Sound 750, 1, , , 4, 5
                    Sound 775, 1, , , 4, 5
                    Sound 800, 1, , , 4, 5
                End If


                If hit = num Then
                    level = level + 1
                    speed = speed + .25
                    If speed > 8 Then speed = 8
                    GoTo begin:
                End If
                brickx(b) = -100: bricky(b) = -100
            End If
        Next d
    Next b

    If time2 > 0 Then
        time2 = time2 - 1
        bby2 = bby2 + .5
        _PrintString (bbx2, bby2), "500"
    End If

    If time2 > 0 Then
        If bbx2 > mx And bbx2 < mx + mr And bby2 > my And bby2 < my + 20 Then
            time2 = 0
            score = score + 500
            Sound 900, 1, , , 4, 5
            Sound 925, 1, , , 4, 5
            Sound 950, 1, , , 4, 5
            Sound 975, 1, , , 4, 5
            Sound 1000, 1, , , 4, 5
            time4 = 1000
            c = _RGB32(0, 255, 0)
            bbx2 = -100: bby2 = -100
        End If
    End If
    If time4 > 0 Then
        time4 = time4 - 1
        If time4 < 5 Then c = _RGB32(255, 0, 0)
    End If

    If time5 > 0 Then
        time5 = time5 - 1
        bby3 = bby3 + .5
        _PrintString (bbx3 - 8, bby3), "More"
    End If
    If time5 > 0 Then
        If bbx3 > mx And bbx3 < mx + mr And bby3 > my And bby3 < my + 20 Then
            time5 = 0
            balls = balls + 1
            If balls > 5 Then balls = 5
            ball = ball + 1
            _Title "Score: " + Str$(score) + "    Level: " + Str$(level) + "    Ball: " + Str$(ball)
            Sound 900, 1, , , 4, 5
            Sound 925, 1, , , 4, 5
            Sound 950, 1, , , 4, 5
            Sound 975, 1, , , 4, 5
            Sound 1000, 1, , , 4, 5
            time6 = 1000
            c = _RGB32(255, 255, 255)
            bbx3 = -100: bby3 = -100
            pa(d) = _Pi(2) * Rnd
        End If
    End If
    If time6 > 0 Then
        time6 = time6 - 1
        If time6 < 5 Then c = _RGB32(255, 0, 0)
    End If

    If time100 > 0 Then
        time100 = time100 - 1
        bby4 = bby4 + .5
        _PrintString (bbx4 - 8, bby4), "Super"
    End If
    If time100 > 0 Then
        If bbx4 > mx And bbx4 < mx + mr And bby4 > my And bby4 < my + 20 Then
            time100 = 0
            balls = balls + 1
            'If balls > 5 Then balls = 5
            ball = ball + 1
            _Title "Score: " + Str$(score) + "    Level: " + Str$(level) + "    Ball: " + Str$(ball)
            Sound 900, 1, , , 4, 5
            Sound 925, 1, , , 4, 5
            Sound 950, 1, , , 4, 5
            Sound 975, 1, , , 4, 5
            Sound 1000, 1, , , 4, 5
            time101 = 1000
            c = _RGB32(255, 255, 133)
            bbx4 = -100: bby4 = -100
            pa(d) = _Pi(2) * Rnd
            superduper(d) = 1
            pc(d) = _RGB32(255, 0, 0)
        End If
    End If
    If time101 > 0 Then
        time101 = time101 - 1
        If time101 < 5 Then c = _RGB32(255, 0, 0)
    End If



    For d = 1 To balls
        'Detect ball collision with paddle.
        If px(d) > mx And px(d) < mx + mr And py(d) > my - 1 And py(d) < my + 11 Then
            If Sin(pa(d)) > 0 Then ' Ball is moving downward
                py(d) = my - 1 ' Move ball just above the paddle
            Else ' Ball is moving upward (hitting bottom of paddle)
                py(d) = my + 21 ' Move ball just below the paddle
            End If
            pa(d) = -pa(d) * ((Rnd / 10) + 1)
            If ti > 0 Then ti = ti - 1: GoTo skip2
            Sound 400, 1, , , 4, 5
            ti = 2
            skip2:
            If py(d) + pr >= my - 1 And px(d) > mx - 1 And px(d) < mx + mr + 1 Then
                py(d) = my - pr ' Prevents it from getting inside the paddle
            End If
        End If
        'keep ball out of wall = wall boundary +- radius of puck
        If px(d) > 790 - pr Then pa(d) = _Pi - pa(d): px(d) = 790 - pr: Sound 400, 1, , , 4, 5
        If px(d) < 10 + pr Then pa(d) = _Pi - pa(d): px(d) = 10 + pr: Sound 400, 1, , , 4, 5
        If py(d) > 590 - pr Then pa(d) = -pa(d): py(d) = 590 - pr: Sound 400, 1, , , 4, 5
        If py(d) < 10 + pr Then pa(d) = -pa(d): py(d) = 10 + pr: Sound 400, 1, , , 4, 5

        ' nove the ball
        px(d) = px(d) + speed * Cos(pa(d))
        py(d) = py(d) + speed * Sin(pa(d))

        'Empty slot at the bottom to keep ball away from.
        If px(d) > slotx And px(d) < slotx + 300 And py(d) > sloty - 11 Then
            ball = ball - 1
            _Title "Score: " + Str$(score) + "    Level: " + Str$(level) + "    Ball: " + Str$(ball)
            px(d) = -200: py(d) = 900
            If superduper(d) = 1 Then superduper(d) = 0
            If balls > 1 Then balls = balls - 1
            If ball = 0 Then End
        End If
        If slotx > 790 Then dir = 2
        If slotx < 10 Then dir = 1
        If dir = 1 Then slotx = slotx + 1
        If dir = 2 Then slotx = slotx - 1
        Line (slotx, sloty)-(slotx + 300, sloty), _RGB32(0, 0, 0)

        If superduper(d) = 1 Then
            pc(d) = _RGB32(255, 0, 0)
        Else
            pc(d) = _RGB32(0, 255, 0)
        End If
        fillCircle px(d), py(d), pr, pc(d) ' draw ball
    Next d
    _Display
    Cls
Loop

'from Steve Gold standard
Sub fillCircle (CX As Integer, CY As Integer, R As Integer, C As _Unsigned Long)
    Dim Radius As Integer, RadiusError As Integer
    Dim X As Integer, Y As Integer
    Radius = Abs(R): RadiusError = -Radius: X = Radius: Y = 0
    If Radius = 0 Then PSet (CX, CY), C: Exit Sub
    Line (CX - X, CY)-(CX + X, CY), C, BF
    While X > Y
        RadiusError = RadiusError + Y * 2 + 1
        If RadiusError >= 0 Then
            If X <> Y + 1 Then
                Line (CX - Y, CY - X)-(CX + Y, CY - X), C, BF
                Line (CX - Y, CY + X)-(CX + Y, CY + X), C, BF
            End If
            X = X - 1
            RadiusError = RadiusError - X * 2
        End If
        Y = Y + 1
        Line (CX - X, CY - Y)-(CX + X, CY - Y), C, BF
        Line (CX - X, CY + Y)-(CX + X, CY + Y), C, BF
    Wend
End Sub
Reply


Messages In This Thread
Brick Smasher 3 - by SierraKen - Yesterday, 08:26 AM
RE: Brick Smasher 3 - by Delsus - Yesterday, 08:35 AM
RE: Brick Smasher 3 - by bplus - Yesterday, 09:54 AM
RE: Brick Smasher 3 - by SierraKen - Yesterday, 07:42 PM
RE: Brick Smasher 3 - by Rikkos - Yesterday, 08:14 PM
RE: Brick Smasher 3 - by SierraKen - Yesterday, 08:53 PM
RE: Brick Smasher 3 - by SierraKen - Yesterday, 10:39 PM



Users browsing this thread: 1 Guest(s)