Advertisement
Guest User

Untitled

a guest
Mar 3rd, 2015
201
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.57 KB | None | 0 0
  1.  
  2. //feel free to muck around with these 2 values
  3. int sx = 10;
  4. int sy = 35;
  5.  
  6. int posY = 3*sx; //variable
  7. int posX = 0;    //constant dependant on with window width
  8.  
  9. void setup() {
  10.   frame.setTitle("Birds-eye-view of flying plane");
  11.   size(512, 768);
  12.   background(174, 59, 52);
  13.  
  14.   stroke(255);
  15.   fill(255);
  16.  
  17.   posX = width/2 - sx/2;
  18. }
  19.  
  20. void drawPlane() {
  21.  
  22.   rect(posX, posY, sx, sy); //body
  23.   ellipse(posX+int(0.5*sx), posY+sy, sx, sy); //nose
  24.   triangle(posX, posY, posX+sx, posY, posX+int(sx*0.5), posY-3*sx); //tail
  25.  
  26.   //tail wings
  27.   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);
  28.   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);
  29.  
  30.   //wings
  31.   triangle(posX,    posY+int(0.75*sy), posX,    posY+int(0.37*sy), posX-sy,    posY);
  32.   triangle(posX+sx, posY+int(0.75*sy), posX+sx, posY+int(0.37*sy), posX+sx+sy, posY);
  33.  
  34.   //inner turbines
  35.   rect(posX-int(1.0/3.0*sy),                posY+int(0.37*sy), int(sx*0.4), int(sx*1.3));
  36.   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));
  37.  
  38.   //outer turbines
  39.   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));
  40.   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));
  41.  
  42. }
  43.  
  44. void keyPressed() {
  45.   posY = 3*sx;
  46. }
  47.  
  48. void draw() {
  49.   background(174, 59, 52);
  50.   drawPlane();
  51.  
  52.   if (posY-3*sx < height+2){ //just to avoid potential problems
  53.     posY++;
  54.   }
  55.  
  56.  
  57. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement