I working on a 1-player pong style version of breakout. Does anyone know if one exists already or if there is a tutorial for a game?
The code I am playing with is below.
CLS
HIDE MOUSE
SYNC ON
SYNC RATE 60
RANDOMIZE TIMER()
LOAD BITMAP "FireBallsBlack.bmp",1
fireball=2
FOR i=0 to 3
GET IMAGE fireball,i*10,0,(i+1)*10,10
SPRITE fireball,0,0,fireball
CLS
INC fireball
NEXT i
LOAD BITMAP "MarioHoldingPong.bmp",2
mario=6
FOR i=0 to 1
GET IMAGE mario,i*15,21,(i+1)*15,48
SPRITE mario,0,0,mario
CLS
INC mario
NEXT i
LOAD BITMAP "platform.bmp",3
block=1
GET IMAGE block,0,0,65,10
SPRITE block,0,0,block
CLS
REM Gets image of block.
LOAD BITMAP "blocks.bmp",4
GET IMAGE 33,0,0,16,16
CLS
block=33
REM blocks across top
FOR x = 0 to 39
SPRITE block,x*16,0,33
INC block
NEXT x
REM blocks down left side
FOR y = 1 to 27
SPRITE block,0,y*16,33
INC block
NEXT y
REM next blocks down right side. the 15 should be 27, but trial version
rem has reached its limits of objects.
FOR y = 1 to 15
SPRITE block,640-16,y*16,33
INC block
NEXT y
rem LOAD BITMAP "linkwall.bmp"
rem set current bitmap 0
DO
LOAD BITMAP "linkwall.bmp"
rem cls RGB(0,0,0)
playerx = 300 : playery = 447
ballx# = 300.0 : bally# = 397.0
ballyspeed# = 2.0
ballxspeed# = 2.0
speedinc# = 0.2
playerspeed = 0
playermove = 2
player = 1 : ball = 2
score = 0
REPEAT
IF RIGHTKEY()
playerspeed = playermove
ELSE
IF LEFTKEY()
playerspeed = 0 - playermove
ELSE
playerspeed = 0
ENDIF
ENDIF
IF SPRITE COLLISION(player,ball)
ballyspeed# = 0 - (ABS(ballyspeed#) + speedinc#)
random# = (RND(10)-5)/10.0
ballxspeed# = ballxspeed# + (playerspeed/2) + random#
score = score + 1
ENDIF
IF ballx# > 614.0 OR ballx# < 16.0 THEN ballxspeed# = 0.0 - ballxspeed#
IF bally# < 16.0 THEN ballyspeed# = 0.0 - ballyspeed#
playerx = playerx + playerspeed
ballx# = ballx# + ballxspeed#
bally# = bally# + ballyspeed#
SPRITE player,playerx,playery,player
SPRITE 6,playerx+24,playery+8,6
SPRITE ball,ballx#,bally#,ball
SYNC
UNTIL bally# > 480
CLS
TEXT 100,50,"Score: "+STR$(score)
TEXT 100,100,"Press ENTER to play again, or SPACE to end"
REPEAT
SYNC
UNTIL RETURNKEY() OR SPACEKEY()
IF SPACEKEY() THEN EXIT
LOOP
END
It still doesn't do a few things I want like have Mario walk back and fourth carring the pong board instead of sliding, and have the fireball rotate and have a transparent background. I haven't put in the breakout blocks yet and was wanting suggestion on how best to do that or with help on anything in the code. If you want the bitmaps I am using you can get them at
http://www.geocities.com/dr_shows/pong/ or email me at
[email protected]
If you can help or have any suggestion reguarding the above code and things I want to do with it please let me know. I will gladly return the favor if I can.
Thanks to dbheaven.com for the original solo pong code on which my game it based.