I have all the wall bounces and paddle angles worked out, but I am at a loss as to how to program the bricks.
So far I have
Code: Select all
int paddleleft=0, paddleright=20 ,middle,definer;
float velocx=5, velocy=5, ballx=80, bally=32;
bool cracked=false;
task paddle()
{
while(true)
{
if(ButtonPressed(BTNLEFT,true))
paddleleft--;
if(ButtonPressed(BTNRIGHT,true))
paddleleft++;
paddleright=paddleleft+21;
middle=paddleleft+11;
Wait(50);
}}
task display()
{
while(true)
{
ClearScreen();
CircleOut(ballx,bally,1);
LineOut(paddleleft,5,paddleright,5);
if(!cracked)
RectOut(0,54,10,10);
Wait(100);
}}
task ball()
{
while(true)
{
if(ballx<0)
velocx = -velocx;
if(ballx>100)
velocx= -velocx;
if(bally>64)
velocy= -velocy;
if(bally<=5&&ballx>=paddleleft&&ballx<=paddleright)
{
definer=ballx-middle;
velocy= -velocy;
velocx=definer;
}
ballx+=velocx/5;
bally+=velocy/5;
Wait(50);
}}
task brick()
{
int brickx=0,bricky=54;
while(true)
{if(!cracked){
if(ballx<brickx+10&&ballx>brickx&&bally == bricky)
{
cracked=true;
velocy= -velocy;
}
if(ballx<brickx+10&&ballx>brickx&&bally == bricky+10)
{
cracked=true;
velocy= -velocy;
}
if(bally<bricky+10&&bally>bricky&&ballx == brickx)
{
cracked=true;
velocx= -velocx;
}
if(bally<bricky+10&&bally>bricky&&ballx == brickx+10)
{
cracked=true;
velocx= -velocx;
}}
}}
task main()
{
Precedes(paddle, display, ball, brick);
}
To make about 30 bricks, would I need to make 30 different tasks for the different blocks
or is there an easier way?