Breakout .2

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 .2

Post by DrChip »

Just having some fun... enjoy!

Code: Select all

REM breakout
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 i ran out of time... v.2 bug fixes
REM enjoy...

GRAPHICS
sw=INT(SCREEN_WIDTH())
sh=INT(SCREEN_HEIGHT())-4
res = 20 ' size 2-20
deltax=res
deltay=res
DIM board(sw+res+res,sh+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
   NEXT x
   FOR y = res TO sh-res-res STEP res
       board(sw/2,y) = brick
   NEXT y
   
   
main:
REFRESH OFF
GRAPHICS CLEAR 0,0,0
GOSUB moveplayer
GOSUB moveblock
GOSUB drawgrid
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
     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
     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
     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
     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_3393.PNG
IMG_3393.PNG (480.13 KiB) Viewed 2739 times
IMG_3390.PNG
IMG_3390.PNG (480.06 KiB) Viewed 2749 times
IMG_3389.PNG
IMG_3389.PNG (460.84 KiB) Viewed 2753 times
IMG_3388.PNG
IMG_3388.PNG (458.41 KiB) Viewed 2753 times

User avatar
rbytes
Posts: 1338
Joined: Sun May 31, 2015 12:11 am
My devices: iPhone 11 Pro Max
iPad Pro 11
MacBook
Dell Inspiron laptop
CHUWI Plus 10 convertible Windows/Android tablet
Location: Calgary, Canada
Flag: Canada
Contact:

Re: Breakout .2

Post by rbytes »

HI. I can't get either version of breakout to work on my iPad Air. I suspect you have designed them just for iPhone. Hope you will make iPad versions. I will post what my screen shots look like.

In both programs, with the screen horizontal, the ball immediately goes through the bottom wall instead of bouncing off, and they both then crash with the error shown.

In both programs, with the screen vertical, the ball immediately goes through the right wall instead of bouncing off, and they both then crash with the error shown.
Attachments
Portrait
Portrait
IMG_0648.PNG (144.08 KiB) Viewed 2734 times
Portrait
Portrait
IMG_0646.PNG (133.42 KiB) Viewed 2734 times
Portrait
Portrait
IMG_0647.PNG (3.25 MiB) Viewed 2734 times
Landscape
Landscape
IMG_0641.PNG (133.75 KiB) Viewed 2735 times
Landscape
Landscape
IMG_0643.PNG (127.19 KiB) Viewed 2735 times
Landscape
Landscape
IMG_0642.PNG (3.07 MiB) Viewed 2735 times
The only thing that gets me down is gravity...

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

Re: Breakout .2

Post by DrChip »

Sorry... I haven't had time. The problem is the screen width and height (sw and sh variables) I cheated and rounded it by subtracting 4. :)

I'll try to fix it for iPads too l, soon.

Cheers,
DrChip

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

Re: Breakout .2

Post by DrChip »

Code: Select all

REM breakout
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 i ran out of time... v.2 bug fixes
REM enjoy...

GRAPHICS
sw=INT(SCREEN_WIDTH())-8 'ipad air 1064 would be -64
sh=INT(SCREEN_HEIGHT())-20 'ipad air 760 would be -60 I'll clean it up later.
res = 20 ' size 2-20
deltax=res
deltay=res
DIM board(sw+res+res,sh+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
   NEXT x
   FOR y = res TO sh-res-res STEP res
       board(sw/2,y) = brick
   NEXT y
   
   
main:
REFRESH OFF
GRAPHICS CLEAR 0,0,0
GOSUB moveplayer
GOSUB moveblock
GOSUB drawgrid
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
     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
     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
     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
     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_0015.PNG
IMG_0015.PNG (370.22 KiB) Viewed 2728 times
IMG_0013.PNG
IMG_0013.PNG (3.61 MiB) Viewed 2728 times

User avatar
rbytes
Posts: 1338
Joined: Sun May 31, 2015 12:11 am
My devices: iPhone 11 Pro Max
iPad Pro 11
MacBook
Dell Inspiron laptop
CHUWI Plus 10 convertible Windows/Android tablet
Location: Calgary, Canada
Flag: Canada
Contact:

Re: Breakout .2

Post by rbytes »

Fast work. It runs fine on my iPad now in portrait mode. Thanks! :D
The only thing that gets me down is gravity...

Post Reply