Weekly Qbasic and Qb64 Lesson Topics
October 12, 2024, 05:58:18 pm
Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
News: Want to see a specific Tutorial? ASK!
 
  Home Help Search Arcade Links Staff List Login Register  

Breakout

Pages: [1]
  Print  
Author Topic: Breakout  (Read 6675 times)
Dustie Bear
Full Member
***
Posts: 115


« on: May 07, 2011, 06:52:11 pm »

Hi

It was to hot this afternoon to do anything outside to do much so.

I left a lot out of this so it would be fairly easy to follow the code.

although its not a complete game it runs correctly for one level.

As I understand it Gary wants some simple games so I left out all the
fancey stuff to keep it simple.

This runs fine and has plenty of room for people to add some frills and whistles
if they want.

here are some suggestions you could add to or change in the game.

Add some randomness to it so the ball starts a differant location each time.
Make it so the ball goes at differant angles on differant levels etc
Make it so the game continues 3 or 4 times after missing the ball. Right now
it ends the game when you miss the ball. LOL
Make levels where the ball goes faster each level when the bricks are all cleared.
Make the rows of brick differant colors for eye candy.
There are a ton of fun things that could be added to it or changed.

Better yet start from scratch and write one.

Come on guys, Write some games to add on here,  I want to play your games!!
I have some complete programs and games on here now.   Where are yours

I see folks talking about how to write programs and etc. but I never see
any real programs come of it, just short samples a lot of which are not all the usefull.

Short samples of stuff get boring after a while.  Grin

Dustie

USE left/right arrow keys to move the paddle,  press q to end the program.

Code:
SCREEN 12

DIM SHARED BallY, BallYY, BallX, BallXX, Blocks
BallY = 200: BallYY = -.3: BallX = 200: BallXX = .2

FOR x = 1 TO 600 STEP 64 ' --- Draw the Blocks
   LINE (x, 50)-(x + 60, 60), 2, BF
   LINE (x, 65)-(x + 60, 75), 2, BF
   LINE (x, 80)-(x + 60, 90), 2, BF
   LINE (x, 95)-(x + 60, 105), 2, BF
NEXT x
LINE (300, 350)-(360, 360), 6, BF ' --- Draw the paddle

DO WHILE a$ <> LCASE$("q")
   a$ = INKEY$

   '   ----- Moving the paddle ------
   IF _KEYDOWN(CVI(CHR$(0) + "M")) THEN
      LINE (300 + m, 350)-(360 + m, 360), 0, BF ' -- Erase old paddle position
      m = m + 1
      LINE (300 + m, 350)-(360 + m, 360), 6, BF ' -- Draw new paddle position
   END IF
   IF _KEYDOWN(CVI(CHR$(0) + "K")) THEN
      LINE (300 + m, 350)-(360 + m, 360), 0, BF ' -- Erase old paddle position
      m = m - 1
      LINE (300 + m, 350)-(360 + m, 360), 6, BF ' -- Draw new paddle position
   END IF

   ' ----------------
   BallMove

   ' -- Missed the ball if went below the paddle
   IF BallY > 400 THEN: LOCATE 29, 30: PRINT " Paddle missed the Ball";: _DISPLAY: SLEEP: SYSTEM ' -- Missed the ball
   ' ----------------

   _LIMIT 400
   _DISPLAY
LOOP
SYSTEM

'____________________________________
SUB BallMove

CIRCLE (BallX, BallY), 5, 0 ' -- erase old ball position
PAINT (BallX, BallY), 0

' -- Control X direction
BallY = BallY + BallYY
BallX = BallX + BallXX
IF BallX < 5 THEN BallXX = .2 ' -- reverse X direction
IF BallX > 630 THEN BallXX = -.2
CIRCLE (BallX, BallY), 5, 7 ' -- Draw new ball
PAINT (BallX, BallY), 7


' -- Reverse y when ball hits top of screen
IF BallY < 5 THEN BallYY = .4

' -- Reverse BallYY when ball hits bottom of blocks
IF POINT(BallX - 5, BallY - 11) = 2 OR POINT(BallX + 5, BallY - 11) = 2 THEN
   BallYY = .4
   PAINT (BallX - 4, BallY - 11), 0 ' -- Erase Block that was hit
   PAINT (BallX + 4, BallY - 11), 0
END IF

' -- Reverse BallYY when ball hits top of blocks
IF POINT(BallX - 5, BallY + 11) = 2 OR POINT(BallX + 5, BallY + 11) = 2 THEN
   BallYY = -.4
   PAINT (BallX - 4, BallY + 11), 0 ' -- Erase Block that was hit
   PAINT (BallX + 4, BallY + 11), 0
END IF

' -- Reverse BallYY when ball hits paddle
IF POINT(BallX + 4, BallY + 6) = 6 OR POINT(BallX - 4, BallY + 6) = 6 THEN BallYY = -.4

END SUB

« Last Edit: May 07, 2011, 07:05:29 pm by Dustie Bear » Report Spam   Logged

Share on Facebook Share on Twitter

GarrisonRicketson
Admin
Administrator
Hero Member
*****
Posts: 583



WWW
« Reply #1 on: May 07, 2011, 09:29:56 pm »

I really like this one Dusty,...and yes, I like that, that you kept it as simple as possible, if you have a completed version,...feel free to put a DrobBox link, so anyone can get it if you want,...Thanks a bunch for this one,...
from Garry
Report Spam   Logged

Dustie Bear
Full Member
***
Posts: 115


« Reply #2 on: May 07, 2011, 10:23:28 pm »

Thanks Gary

I do have a complete one with some neat stuff.  I wrote it
in Visual Basic so it would do us no good here.

I posted this to give others something  to work on or ideas to write
their own.

I'd like to see people write some programs that do stuff. One
can write little library stuff and other things but what good is it
if it isn't put into practice. 

Dustie
« Last Edit: May 07, 2011, 10:58:42 pm by Dustie Bear » Report Spam   Logged
Unseen Machine
Post Demos
*
Posts: 46


« Reply #3 on: May 10, 2011, 09:16:09 pm »

As requested, "make your own", here's a GDK version i made. Nothing special but it demonstrates vector movement and rectangle based collision detection, it should be easy to expand also.

http://dl.dropbox.com/u/8822351/GDK_breakout.zip
Report Spam   Logged
Dustie Bear
Full Member
***
Posts: 115


« Reply #4 on: May 10, 2011, 10:38:24 pm »


Good Job Unseen,

Looks great runs smooth and some cool looking blocks along with the nice
colorful paddle.

Thanks for sharing, Smiley

Dustie

Report Spam   Logged
Unseen Machine
Post Demos
*
Posts: 46


« Reply #5 on: May 11, 2011, 05:05:55 am »

Thanks guys, when i want a break from Level Maker i will expand on it a bit (improve the ball bouncing, only allow 1 block to be destroyed per bounce, levels, ball speed etc...).

GDK will never be dead. Wink I will allways favour it above writing games in pure QB64 code, libraries are the way forward. I will be making GDK2 this year as we have a few new tricks available in QB64 that should be taken advantage off, it will support OpenGL via my EZ_GL interface aswell as faster image rotations (_MAPTRIANGLE).
Report Spam   Logged
Unseen Machine
Post Demos
*
Posts: 46


« Reply #6 on: May 11, 2011, 07:46:36 am »

I will do once i have made it at least a little better.
Report Spam   Logged
GarrisonRicketson
Admin
Administrator
Hero Member
*****
Posts: 583



WWW
« Reply #7 on: May 12, 2011, 12:38:17 am »

As requested, "make your own", here's a GDK version i made. Nothing special but it demonstrates vector movement and rectangle based collision detection, it should be easy to expand also.

http://dl.dropbox.com/u/8822351/GDK_breakout.zip
The colors, are always so much more vivid with GDK .
 I may not understand the codeing much, but always am impressed with the end results,...
From Garry
Report Spam   Logged

Dustie Bear
Full Member
***
Posts: 115


« Reply #8 on: May 16, 2011, 11:56:23 am »

Quote
The colors, are always so much more vivid with GDK .

While GDK is an awesome tool,,  Thats just not true about the colors.

If you want nice colors you can use rgb(foo,foo,foo) or _RGB(foo,foo,foo)
in any program whether you use GDK or not and get the very same colors
as when using the GDK.

Just using  'COLOR, foo, foo'    you may not get what you realy want
depending on the screen mode your using.

Dustie
« Last Edit: May 16, 2011, 11:58:59 am by Dustie Bear » Report Spam   Logged

Pages: [1]
  Print  
 
Jump to:  

Powered by EzPortal
Bookmark this site! | Upgrade This Forum
SMF For Free - Create your own Forum


Powered by SMF | SMF © 2016, Simple Machines
Privacy Policy