Link to home
Start Free TrialLog in
Avatar of 4mod3
4mod3

asked on

Simple Animation

i have written the following applet to display a red and black chess board :

import java.awt.*;
import java.applet.*;

public class Checker extends Applet {

    public void paint(Graphics g) {
   
        int x,y,xint,yint;
        xint = 0;
        yint = 0;
   
        g.setColor(Color.black);
        g.fillRect(0,0,159,159);
       
        g.setColor(Color.red);
       
        for(y = 1; y <= 8; y++) {
            for(x = 1; x<=8; x++){
                if((((y % 2) == 0) && ((x % 2) == 0)) || (((y % 2) != 0) && ((x % 2) != 0))){
                    g.fillRect(xint,yint,20,20);
                }
                xint += 20;
            }
            yint +=20;
            xint = 0;
        }
    }
}

is there a way to tweak this so as to produce an animation where the squares alternate colors between red and black ?
Avatar of 4mod3
4mod3

ASKER

Just to clarify, my question is based on how to actually animate it within a browser.
I know how to alternate, just need help animating.
ASKER CERTIFIED SOLUTION
Avatar of cocojohn
cocojohn

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial