Breakout .4

Post Reply
DrChip
Posts: 167
Joined: Wed Oct 22, 2014 3:26 pm
My devices: iPhone 4 to 6+,iPad mini to iPad air 2

Breakout .4

Post by DrChip »

My son asked me to fix some bugs. I'm kinda doe with it. I wrote it as I was waiting at an appointment for fun. If anyone wats to fix the bugs and optimize it, it would be greatly appreciated!
Enjoy...

Code: Select all

REM breakout .4
REM just a fun toy i made as i was waiting.
REM you can add more bricks and patterns
REM i was plannimg on adding sound, colors and diffrent backgrounds.
REM .4 fixed a few bugs
REM im done with this, if someone wants to complete
REM it, it would be great! 
REM im too busy and it started as a toy.
REM iPhone 6+/ios 10.3.2 beta 1/SB
REM enjoy...

GRAPHICS
SET ORIENTATION PORTRAIT
res = 20' size 2-20
sw1=INT(SCREEN_WIDTH())
sh1=INT(SCREEN_HEIGHT())
sw2=INT(SCREEN_WIDTH()%10)
sh2=INT(SCREEN_HEIGHT()%10)
sw=(sw1-sw2)
sh=(sh1-sh2)
'sw=INT(SCREEN_WIDTH())
'sh=INT(SCREEN_HEIGHT()) -4

deltax=res
deltay=res
DIM board((sw1+res+res),(sh1+res+res))
px=sw/2
py=sh/2
brick=5 'brick strength
wall=10 'wall fix strength

'setup bricks and walls
setup: 
   FOR x = 0 TO sw-res STEP res
       board(x,0) = wall
       board(x,sh-res) = wall
   NEXT x
   FOR y = res TO sh-res STEP res
       board(0,y) = wall
       board(sw-res,y) = wall
   NEXT y
   FOR x = res TO sw-res-res STEP res
       board(x,res) = brick
       board(x,res*2) = brick
       board(x,res*3) = brick
       board(x,sh/2) = brick
       board(x,sw/2) = brick
   NEXT x
   FOR y = res TO sh-res-res STEP res
       board(sw/2,y) = brick
       board(res,y) = brick
       board(res+res,y) = brick
       board(sw/2+res,y) = brick
       board(sw/2,res*5) = wall
       board(sw/2,res*6) = wall
       board(sw/2,res*7) = wall
       board(sw/2,res*8) = wall
       board(sw/2,res*15) = wall
       board(sw/2,res*16) = wall
       board(sw/2,res*17) = wall
       board(sw/2,res*18) = wall
   NEXT y
   
   
main:
REFRESH OFF
GRAPHICS CLEAR 0,0,0
GOSUB moveplayer
GOSUB moveblock
GOSUB drawgrid
'debug
'DRAW COLOR 0,1,0
'DRAW TEXT px&":"&py&" "&deltax&":"&deltay AT 0,0
REFRESH 
GOTO main

moveplayer:
    'draw tail
    FILL COLOR 0,0,0
    FILL RECT px,py TO px+res,py+res
    
    'move
        px=px+deltax 
        py=py+deltay
        
    'draw player / ball
    FILL COLOR 1,0,0
    FILL RECT px,py TO px+res,py+res
    
    'test brick and ball
     IF board(px,py-res)>0 AND deltay < 0 THEN 
         deltay=-deltay
         IF board(px,py-res) <=brick THEN board(px,py-res)=board(px,py-res)-1
         NOTES SET "D"&STR$(board(px-res,py))
     NOTES PLAY 
     NOTES STOP
     END IF 
     
     IF board(px+res,py)>0 AND deltax > 0 THEN 
          deltax=-deltax
          IF board(px+res,py) <=brick THEN board(px+res,py)=board(px+res,py)-1
          NOTES SET "D"&STR$(board(px-res,py))
     NOTES PLAY 
     NOTES STOP
     END IF 
     
     IF board(px,py+res)>0  AND deltay > 0 THEN 
          deltay=-deltay
          IF board(px,py+res)<=brick THEN board(px,py+res)=board(px,py+res)-1
          NOTES SET "D"&STR$(board(px-res,py))
     NOTES PLAY 
     NOTES STOP
     END IF 
     
     IF board(px-res,py)>0 AND deltax < 0 THEN 
          deltax=-deltax
    IF board(px-res,py)<=brick THEN board(px-res,py)=board(px-res,py)-1
    NOTES SET "D"&STR$(board(px-res,py))
     NOTES PLAY 
     NOTES STOP
     END IF 
     
     IF board(px,py)<=brick THEN board(px,py)=board(px,py)-1
     'END IF 
     
RETURN

'update bricks 
moveblock:
     FOR x = 0 TO sw STEP res
        FOR y = 0 TO sh STEP res
             IF board(x,y) > 0 THEN
                       IF board(x,y) = wall THEN
                       FILL COLOR 1,0,0
                       ELSE
                      FILL COLOR (board(x,y))/brick,board(x,y)/brick,board(x,y)/brick
                      END IF 
                       FILL RECT x,y TO x+res,y+res 
             END IF
        NEXT y
     NEXT x
RETURN

'standard grid
drawgrid:
DRAW COLOR 1,1,1
   FOR x = 0 TO sw-res STEP res
        FOR y = 0 TO sh-res STEP res
            DRAW RECT x,y TO x+res,y+res
        NEXT y
    NEXT x 
RETURN
Attachments
IMG_3977.PNG
IMG_3977.PNG (480.82 KiB) Viewed 3238 times

Post Reply