Unable to "erase" rectangles

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Unable to "erase" rectangles

michalh
Hi,

I'm trying to draw a black rectangle and then draw a white rectangle over it (in order to "erase" it from the screen). Sometimes it works, but most times it doesn't.

Any ideas why?

Thanks!
-- Michal
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Unable to "erase" rectangles

cadet1620
Administrator
Hard to guess your bug without any code...

--Mark
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Unable to "erase" rectangles

michalh
LOL :)

The methods: (draw - works, erase - doesn't)
**********
method void drawPoint() {
        do Screen.setColot(true);
        do Screen.drawRectangle(x, y, x+4, y+4);
        return;
}
       
method void erasePoint() {
        do Screen.setColot(false);
        do Screen.drawRectangle(x, y, x+4, y+4);
        return;
}

the call to erasePoint:
****************
let firstPoint = SnakeBody.getLoc(); // getLoc() returns the point i want to erase
do firstPoint.erasePoint();

getLoc():
*******

field Point loc;

method Point getLoc() {
        return loc;
}
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Unable to "erase" rectangles

cadet1620
Administrator
michalh wrote
method void drawPoint() {
        do Screen.setColot(true);
        do Screen.drawRectangle(x, y, x+4, y+4);
        return;
}
       
method void erasePoint() {
        do Screen.setColot(false);
        do Screen.drawRectangle(x, y, x+4, y+4);
        return;
}
Do they really say "Screen.setColo t "?  I wonder what's getting called?

FWIW, the Square test in chapter 10 has basically identical code:
    /** Draws the square on the screen. */
    method void draw() {
        do Screen.setColor(true);
        do Screen.drawRectangle(x, y, x + size, y + size);
        return;
    }

    /** Erases the square from the screen. */
    method void erase() {
        do Screen.setColor(false);
        do Screen.drawRectangle(x, y, x + size, y + size);
        return;
    }

--Mark
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Unable to "erase" rectangles

michalh
Apparently it called setColor, but i have no idea why... :)
anyway, fixing that solved the bug.

Thanks!!
-- Michal.
Loading...