Post by 8XenoTrogdor8 on Feb 3, 2005 0:24:18 GMT -5
This is like one of those old games where a ball bounces around the screen destroying bricks and the player controls the ball with a paddle at the bottom of the screen. But in this version, there are FOUR paddles! (one for each side). This isn't really a complete game because there is no way to win and difficulty doesn't increase, but regardless its still addictive! Seriously! try it for yourself!!!
If you want you can add more stuff to make it more of a progressing game. I plan to make it into a fully playable game with powerups and stuff, kinda like "DXBall" but only better. (Chances are if I do make a game like that, I will have to post it in .exe, because it will have a lot of custom sprites and such). Later all y'all.
'From the labs of XenoTrogdor,
'The first 4-sided "Bricks" game!
'V 1.00
Dim I, X, Y
Dim Paddle (3), PaddleTexture
Dim Ball, BallAngle, BallTexture, BallSpeed
Dim Brick (300), BrickOnScreen (300), BrickTexture, BrickCount, AnyBricksLeft
Dim Score, BallsLost, Level
Dim XDis#, YDis#
PaddleTexture = LoadTexture ("textures\pavement.jpg")
BallTexture = LoadTexture ("data\ball.png")
BrickTexture = LoadTexture ("textures\001.jpg")
Paddle (0) = NewSprite (PaddleTexture)
SprSetPos (400, 20) ' Top
SprSetSize (128, 16)
Paddle (1) = NewSprite (PaddleTexture)
SprSetPos (400, 580) ' Bottom
SprSetSize (128, 16)
Paddle (2) = NewSprite (PaddleTexture)
SprSetPos (20, 300) ' Left
SprSetSize (16, 128)
Paddle (3) = NewSprite (PaddleTexture)
SprSetPos (780, 300) ' Right
SprSetSize (16, 128)
Ball = NewSprite (BallTexture)
SprSetPos (400, 550)
BallAngle = 100
BallSpeed = 4
SprSetVel (MatrixRotateZ (BallAngle) * Vec2 (BallSpeed, 0))
ResizeSpriteArea (800, 600)
TextMode (TEXT_BUFFERED)
ResizeText (50, 30)
Mouse_XD () ' This will remove the mouse cursor from the screen.
Start:
' Put some bricks on the screen.
I = 0
for Y = 0 to 29
for X = 0 to 9
if X >= 1 and X <= 8 then ' X values the bricks will be between.
if Y >= 5 and Y <= 20 then ' Y values the bricks will be between.
BrickOnScreen (I) = TRUE
Brick (I) = NewSprite (BrickTexture)
SprSetPos (X * 80 + 40, Y * 20 + 10)
SprSetSize (75, 15)
I = I + 1
endif
endif
next
next
AnyBricksLeft = TRUE
BrickCount = I
' Delete some random blocks just for fun...
for I = 0 to BrickCount
if Rnd () % 10 = 0 then
DeleteSprite (Brick (I))
BrickOnScreen (I) = FALSE
endif
next
' Loop until all bricks are gone.
While AnyBricksLeft
' Paddle movement and ball collision.
' Top and bottom paddles.
for I = 0 to 1
BindSprite (Paddle (I))
SprSetX (Mouse_X () * 800) ' Locate the paddle at the X value of the mouse.
XDis# = (.5) * SprXSize () + 10 - Abs (SprX () - SprX (Ball)) ' A postive value means the ball
YDis# = (.5) * SprYSize () + 10 - Abs (SprY () - SprY (Ball)) ' is within the paddle (or brick later).
if XDis# >= 0 and YDis# >= 0 then
XDis# = SprX () - SprX (Ball) ' This is the balls position
YDis# = SprY () - SprY (Ball) ' relative to the paddle.
BindSprite (Ball)
if I = 0 then ' Find out which paddle hit the ball.
BallAngle = 90 + (XDis# / SprXSize (Paddle (I))) * 120 ' The maximum angle coming off of the paddle is 120 degrees.
else
BallAngle = 270 - (XDis# / SprXSize (Paddle (I))) * 120
endif
SprSetVel (MatrixRotateZ (BallAngle) * Vec2 (BallSpeed, 0))
endif
next
' Left and right paddles.
for I = 2 to 3
BindSprite (Paddle (I))
SprSetY (Mouse_Y () * 600)
XDis# = (.5) * SprXSize () + 10 - Abs (SprX () - SprX (Ball))
YDis# = (.5) * SprYSize () + 10 - Abs (SprY () - SprY (Ball))
if XDis# >= 0 and YDis# >= 0 then
XDis# = SprX () - SprX (Ball)
YDis# = SprY () - SprY (Ball)
BindSprite (Ball)
if I = 2 then
BallAngle = -(YDis# / SprYSize (Paddle (I))) * 120
else
BallAngle = 180 + (YDis# / SprYSize (Paddle (I))) * 120
endif
SprSetVel (MatrixRotateZ (BallAngle) * Vec2 (BallSpeed, 0))
endif
next
' Ball and brick collision.
AnyBricksLeft = FALSE
for I = 0 to BrickCount
if BrickOnScreen (I) then
AnyBricksLeft = TRUE ' If no bricks are on screen this wont change to true.
BindSprite (Brick (I))
XDis# = (.5) * SprXSize () + 10 - Abs (SprX () - SprX (Ball))
YDis# = (.5) * SprYSize () + 10 - Abs (SprY () - SprY (Ball))
if XDis# >= 0 and YDis# >= 0 then
BindSprite (Ball)
if XDis# <= Abs (SprXVel ()) then SprSetXVel (-SprXVel ()) endif
if YDis# <= Abs (SprYVel ()) then SprSetYVel (-SprYVel ()) endif
DeleteSprite (Brick (I))
BrickOnScreen (I) = FALSE
Score = Score + 1
endif
endif
next
' Test if ball is still on screen
BindSprite (Ball)
XDis# = SprX () - 400
YDis# = SprY () - 300
if Abs (XDis#) >= 450 or Abs (YDis#) >= 350 then
SprSetPos (SprPos (Paddle(1)) + Vec2 (0, 20))
BallAngle = 270
SprSetVel (MatrixRotateZ (BallAngle) * Vec2 (BallSpeed, 0))
BallsLost = BallsLost + 1
endif
' Display some stuff
Cls
Printr "Balls Lost : " + BallsLost
Printr "Level : " + Level
Printr "Score : " + Score
' Move move and draw sprites.
AnimateSprites ()
DrawText ()
Wend
' Level advancement/loop restarting.
Level = Level + 1
Score = Score + Level * 25
Goto Start
If you want you can add more stuff to make it more of a progressing game. I plan to make it into a fully playable game with powerups and stuff, kinda like "DXBall" but only better. (Chances are if I do make a game like that, I will have to post it in .exe, because it will have a lot of custom sprites and such). Later all y'all.