Saturday, May 7, 2011

Programming with Processing (Android)

Okay so I finally got the Android emulator working with the processing programming enviroment. You can look up how to do this online, just make sure you download google Android api level 7 from the thrid party tools. Anyways here is a sample sketch I used for running on the Android emulator.

int cx;
int cy;
int w;
int h;
int c;
int cc;
void setup(){
  size(480, 800);
  h = 30;
  w = 30;
  cx = 10;
  cy = 10;
  draw();
}
void draw(){
  fill(cc);
  rect(cx, cy, w, h);
  cx = cx + 30;
  if (cx > 450){
    cx = 10;
    cy = cy + 30;
    if (cy > 760){
      noLoop();
    }
  }
  c = c + 10;
  if (c < 20){
    cc = 0;}
    if (c > 19){
      cc = 255;
      c = 0;}
}

All this really does is draw a checker pattern across the screen, but is a good program to start with. You can also try to change the colors and stuff like that.

No comments:

Post a Comment