Computer Science Canada

Clearing the brick completely

Author:  Velocity [ Thu Jan 12, 2012 10:19 am ]
Post subject:  Clearing the brick completely

What is it you are trying to achieve?
when the ball hits the brick it clears it permanetly


What is the problem you are having?
i made the if statement and all that but when the ball hits the brick it flashes the clear and then redraws it, obvs cause its in a loop, but how do i make it so that it just stays deleted. im looking for an easy method.

Describe what you have tried to solve this problem
i dont exactly know how to go about doing it, i thought the redraw would work then i did it and it just flashes

Turing:


drawfillbox (xb1, yb1, xb2, yb2, 48)
       
       
        if ball_x1 >= xb1 and ball_x1 <= xb2 and ball_y1 >= yb1 and ball_y1 <= yb2 then
            drawfillbox (xb1, yb1, xb2, yb2, black)
        end if



Please specify what version of Turing you are using
4.1.1a

Author:  Velocity [ Thu Jan 12, 2012 12:07 pm ]
Post subject:  RE:Clearing the brick completely

black is the color of my background thats why the new block will be black, but how would i go about executing this code in a proper way so that it doesnt flash, but just so that it goes away, what basic command or code structure do i need?

Author:  Tony [ Thu Jan 12, 2012 1:32 pm ]
Post subject:  RE:Clearing the brick completely

instead of drawing a brick and then drawing over it, why not simply not draw the brick in the first place?

Author:  chipanpriest [ Thu Jan 12, 2012 1:41 pm ]
Post subject:  Re: Clearing the brick completely

I already posted on your earlier thread but it probably works better here. If you have 10 bricks; for example, you could do this:
Turing:
var alive : array 1 .. 10 of boolean

for i : 1 .. 10
    if alive (i) = true then %if the brick is alive
        %drawbrick
    end if
end for


And when a brick gets hit you could do something like:
Turing:
for i : 1 .. 10
    if /* the ball hits a brick */ then
        alive (i) := false %brick dies
    end if
end for


That's all I did for my space invaders. Hope it helps!

Author:  Velocity [ Thu Jan 12, 2012 5:50 pm ]
Post subject:  RE:Clearing the brick completely

thank you soooo much it helped alot, i got it to work now, thank you all for the great help!


: