kramann.info
© Guido Kramann

Login: Passwort:










kramann.info
© Guido Kramann

Login: Passwort:




Object oriented representation of LUAbot

(EN google-translate)

(PL google-translate)

LUAbot002_OOP.zip -- Processing Project.
LUAbot[] luabot = new LUAbot[8];
public void setup()
{
    size(640,640);
    frameRate(20);
    for(int i=0;i<luabot.length;i++)
       luabot[i] = new LUAbot(80+i*60,80,30.0*i,(i%2)*127+128,((i/2)%2)*127+128,((i/4)%2)*127+128);
}
public void draw()
{
    scale(1,-1); //coordinate transformation
    translate(0,-640);
    background(255);
    noFill();
    stroke(0);
    strokeWeight(height/200);
    ellipse(20,20,40,40);
    line(20,20,40,20);
    
    for(int i=0;i<luabot.length;i++)
       luabot[i].draw();
}

Code 0-1: LUAbot002_OOP

public class LUAbot
{
    float R=20.0;
    float x,y,phi; //position orientation
    float v,w;     //speed pixel per second, angular speed degree per second
    int r,g,b;     //color RED GREEN BLUE
    public LUAbot(float x, float y, float phi, int r, int g, int b)
    {
        this.x=x;
        this.y=y;
        this.phi=phi;
        this.r=r;
        this.g=g;
        this.b=b;
    }
    
    public void draw()
    {
        stroke(0);
        fill(r,g,b);
        ellipse(x,y,R*2,R*2);
        float p = phi*PI/180.0;
        line(x,y,x+R*cos(p),y+R*sin(p));
    }
}

Code 0-2: Tab LUAbot