Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //feel free to muck around with these 2 values
- int sx = 10;
- int sy = 35;
- int posY = 3*sx; //variable
- int posX = 0; //constant dependant on with window width
- void setup() {
- frame.setTitle("Birds-eye-view of flying plane");
- size(512, 768);
- background(174, 59, 52);
- stroke(255);
- fill(255);
- posX = width/2 - sx/2;
- }
- void drawPlane() {
- rect(posX, posY, sx, sy); //body
- ellipse(posX+int(0.5*sx), posY+sy, sx, sy); //nose
- triangle(posX, posY, posX+sx, posY, posX+int(sx*0.5), posY-3*sx); //tail
- //tail wings
- triangle(posX+int(sx*0.5), posY-int(1.5*sx), posX+int(sx*0.5), posY-2.5*sx, posX-sx, posY-3*sx);
- triangle(posX+int(sx*0.5), posY-int(1.5*sx), posX+int(sx*0.5), posY-2.5*sx, posX+2*sx, posY-3*sx);
- //wings
- triangle(posX, posY+int(0.75*sy), posX, posY+int(0.37*sy), posX-sy, posY);
- triangle(posX+sx, posY+int(0.75*sy), posX+sx, posY+int(0.37*sy), posX+sx+sy, posY);
- //inner turbines
- rect(posX-int(1.0/3.0*sy), posY+int(0.37*sy), int(sx*0.4), int(sx*1.3));
- rect(posX+sx+int(1.0/3.0*sy)-int(sx*0.4), posY+int(0.37*sy), int(sx*0.4), int(sx*1.3));
- //outer turbines
- rect(posX-int(2.0/3.0*sy), posY+int(0.37*sy)-int(sx*1.3/2), int(sx*0.4), int(sx*1.3*2.0/3.0));
- rect(posX+sx+int(2.0/3.0*sy)-int(sx*0.4), posY+int(0.37*sy)-int(sx*1.3/2), int(sx*0.4), int(sx*1.3*2.0/3.0));
- }
- void keyPressed() {
- posY = 3*sx;
- }
- void draw() {
- background(174, 59, 52);
- drawPlane();
- if (posY-3*sx < height+2){ //just to avoid potential problems
- posY++;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement