BLiNDPiG
Dec 18th, 2000, 12:29 AM
Hello. I'm writing Arkanoid for my final project in Computer 1. I know this is VB-world, but it may be helpful for you to know that I'm writing it in True Basic... The problem I'm having is with a concept identical as it would be in Visual Basic.
I have the mechanics of the ball and the paddle working, and I figured out how to draw the boxes as the top. The only problem I'm having is when the ball collides with the block. I set up an array for the following:
dim blockx1(80) !block(count) xmin
dim blockx2(80) !block(count) xmax
dim blocky1(80) !block(count) ymin
dim glocky2(80) !block(count) ymax
dim block$(80)
dim blockval(80) !block value [1=on, 0=off]
!There are 80 blocks
!I set window as follows:
set window 0,100,0,100 !xmin,xmax,ymin,ymax
---
This is the code I used to draw the blocks:
FOR a=0 to 3 !4 rows of blocks
FOR b=0 to 19 !19 columns of blocks
LET count=count+1
LET blockx1(count)=(b*5) !block xmin
LET blockx2(count)=(b*5)+5 !block xmax
LET blocky2(count)=65-(a*2) !block ymax
LET blocky1(count)=blocky2(count)-2 !block ymin
SET COLOR rnd*16
BOX AREA blockx1(count),blockx2(count),blocky1(count),blocky2(count)
BOX KEEP blockx1(count),blockx2(count),blocky1(count),blocky2(count) in block$(count)
LET blockval(count)=1 !block(count) is visible
NEXT b
NEXT a
---
That draws 4 rows of 20 blocks each, and each block is a random color. I'm having problems checking which block the ball is boucing off of. Here is the code I'm using:
!finds which block ball is hitting
LET count=0
LET sbloop=1 !just a simple variable to start/stop following loop
IF (by1+2)>56 then !checks if ball is in block area
DO
LET count=count+1
IF (by1+2)>=(blocky1(count)-1) then
IF (bx1+2)>=blockx1(count) and (bx1+2)<blockx1(count+1) then
LET by1=blocky1(count)-2.1
LET by=by*(-1)
LET sbloop=0
BOX HIDE block$(count)
LET blockval(count)=0
END IF
END IF
LOOP until sbloop=0
END IF
---
The ball will make it up to 56, then the ball and paddle will disappear. I've been working at this, trying to make a loop to determine which block the ball is hitting, instead of making 80 separate if else statements to check which block the ball it hitting. Could anyone help me out? I'd really appreciate it. I'll even put you in the credits.
Hope my directions and desires were clear. If there are any questions, post a reply. I can clear them up for you. ***REMEMBER- this is being done in TRUE BASIC. I would have posted this problem on a TB forum, but I haven't found any as of yet.
Thanks for any help I may receive in solving my predicament.
-BLiNDPiG
I have the mechanics of the ball and the paddle working, and I figured out how to draw the boxes as the top. The only problem I'm having is when the ball collides with the block. I set up an array for the following:
dim blockx1(80) !block(count) xmin
dim blockx2(80) !block(count) xmax
dim blocky1(80) !block(count) ymin
dim glocky2(80) !block(count) ymax
dim block$(80)
dim blockval(80) !block value [1=on, 0=off]
!There are 80 blocks
!I set window as follows:
set window 0,100,0,100 !xmin,xmax,ymin,ymax
---
This is the code I used to draw the blocks:
FOR a=0 to 3 !4 rows of blocks
FOR b=0 to 19 !19 columns of blocks
LET count=count+1
LET blockx1(count)=(b*5) !block xmin
LET blockx2(count)=(b*5)+5 !block xmax
LET blocky2(count)=65-(a*2) !block ymax
LET blocky1(count)=blocky2(count)-2 !block ymin
SET COLOR rnd*16
BOX AREA blockx1(count),blockx2(count),blocky1(count),blocky2(count)
BOX KEEP blockx1(count),blockx2(count),blocky1(count),blocky2(count) in block$(count)
LET blockval(count)=1 !block(count) is visible
NEXT b
NEXT a
---
That draws 4 rows of 20 blocks each, and each block is a random color. I'm having problems checking which block the ball is boucing off of. Here is the code I'm using:
!finds which block ball is hitting
LET count=0
LET sbloop=1 !just a simple variable to start/stop following loop
IF (by1+2)>56 then !checks if ball is in block area
DO
LET count=count+1
IF (by1+2)>=(blocky1(count)-1) then
IF (bx1+2)>=blockx1(count) and (bx1+2)<blockx1(count+1) then
LET by1=blocky1(count)-2.1
LET by=by*(-1)
LET sbloop=0
BOX HIDE block$(count)
LET blockval(count)=0
END IF
END IF
LOOP until sbloop=0
END IF
---
The ball will make it up to 56, then the ball and paddle will disappear. I've been working at this, trying to make a loop to determine which block the ball is hitting, instead of making 80 separate if else statements to check which block the ball it hitting. Could anyone help me out? I'd really appreciate it. I'll even put you in the credits.
Hope my directions and desires were clear. If there are any questions, post a reply. I can clear them up for you. ***REMEMBER- this is being done in TRUE BASIC. I would have posted this problem on a TB forum, but I haven't found any as of yet.
Thanks for any help I may receive in solving my predicament.
-BLiNDPiG