Your browser does not support the canvas tag.

previous        Show / Hide Source        Download        next
//"Spaceship flying through space" drawing by Sasha Ayagh
//Description: You control a fighter spaceship, by pressing mouse click
//the player can shoot at the flying suacer

void setup() {
  //Set size of window and framerate
  size(500, 500);
}

void draw() {
  //set the void of space
  background(0);
  
  //remove cursor
  noCursor();
 
  //create static stars PART 1#
  
  ellipseMode(CENTER);
  fill(255);
  ellipse(75, 100, 3, 3);
  ellipse(30, 475, 3, 3);
  ellipse(190, 200, 3, 3);
  ellipse(190, 350, 3, 3);
  ellipse(290, 300, 3, 3);
  ellipse(285, 480, 3, 3);
  ellipse(325, 225, 3, 3);
  ellipse(385, 375, 3, 3);
  ellipse(75, 300, 3, 3);
  ellipse(425, 200, 3, 3);
  ellipse(490, 325, 3, 3);
  ellipse(475, 75, 3, 3);
  
  //create static planets PART 2#
  
  //Largest planet 
  fill(150, 0, 200);
  ellipse(350, 100, 65, 65);
  //Moon of largest planet
  fill(155);
  ellipse(380, 275, 30, 30);
  //Smallest planet 
  fill(255, 0, 0);
  ellipse(110, 425, 45, 45);
  
  //create interactive Starship
  //body of the craft
  fill(100);
  noStroke();
  rectMode(CENTER);
  rect(mouseX, mouseY, 40, 120);
  //bottom module
  fill(125, 10, 10);
  rect(mouseX, mouseY+25, 60, 60);
  //wings 1
  fill(100);
  rect(mouseX-30, mouseY+50, 25, 75);
  rect(mouseX+30, mouseY+50, 25, 75);
  //nose
  fill(100);
  rect(mouseX, mouseY-72, 25, 25);
  //window
  fill(255, 255, 0);
  rect(mouseX, mouseY-35, 20, 45);
  //wings 2
  fill(125, 10, 10);
  rect(mouseX-30, mouseY+15, 120, 25);
  rect(mouseX+30, mouseY+15, 120, 25);
  //guns
  stroke(0); 
  fill(100);
  rect(mouseX-50, mouseY-30, 5, 80);
  rect(mouseX+50, mouseY-30, 5, 80);
  
  //flying suacer
  fill(0, 255, 0); 
  ellipse(mouseX, mouseY-255, 100, 100);
  fill(241, 249, 25);
  ellipse(mouseX, mouseY-255, 50, 50);
  rect(mouseX, mouseY-255, 5, 50);
  
}
  
  //blasters for the ship
  
  void mousePressed(){

  //lasers
  stroke(0, 0, 255);
  strokeWeight(4); 
  line(mouseX-50, mouseY-30, 200, 100);
  line(mouseX+50, mouseY-30, 200, 100);
  
}