Your browser does not support the canvas tag.

previous        Show / Hide Source        Download        next
/* 
 Title: Art World
 
 Creator: Aaron Munavish Hogarth
 Intro to Media Computation
 Oct 3, 2018
 Instructor: Nicolas Hesler
 
 Instructions: Hit the play button to begin playing "Art World" (Disclaimer no longer a game 
 fully about art because rules). Once in, use the mouse click function
 to draw lines and use the WASD keys to move the eraser around.
 
 "We don't make mistakes, just happy little accidents." - Bob Ross
 
 */

//Colour value list starts
int redColourR = 240;
int redColourG = 29;
int redColourB = 31;
int eraserPinkR = 255;
int eraserPinkG = 172;
int eraserPinkB = 246;
int mountainR = 71;
int mountainG = 94;
int mountainB = 163;
int purplePaintR = 100;
int purplePaintG = 0;
int purplePaintB = 240;
int bluePaintR = 0;
int bluePaintG = 0;
int bluePaintB = 255;
int greenPaintR = 0;
int greenPaintG = 255;
int greenPaintB = 0;
int yellowPaintR = 245;
int yellowPaintG = 255;
int yellowPaintB = 0;
int orangePaintR = 255;
int orangePaintG = 152;
int orangePaintB = 0;
int redPaintR = 255;
int redPaintG = 0;
int redPaintB = 0;
int pinkPaintR = 255;
int pinkPaintG = 0;
int pinkPaintB = 188;
int blackPaint = 0;
int whitePaint = 255;
int i = 10;
int j = 10;
//Colour value list ends

//Eraser tool varaibles
int eraserTool = 255;
int eraserX = 20;
int eraserY = 340;
int eraserXmove = 0;
int eraserYmove = 0;
float eraserSpeed = 3;

//Sharpness value list
int sharpnessOne = 5;
int sharpnessTwo = 20;
int sharpnessThree = 40;
int sharpnessFour = 60;

//Cloud values
float cloudX = 0;
float cloudY = 0;
float cloudSpeed = 0.2;

//Draw mouse values
float mouseStartX;
float mouseStartY;

//Boolean values for menus
boolean isPlay = true;
boolean mousePressedDown = false;


// Booleans for art related mechanics
boolean doDrawLine;
boolean doRedStroke;
boolean doBlueStroke;
boolean doGreenStroke;
boolean doYellowStroke;
boolean doPurpleStroke;
boolean doOrangeStroke;
boolean doPinkStroke;
boolean doBlackStroke;
boolean doWhiteStroke;
boolean randomColour;
boolean sharpnessNormal;
boolean sharpnessThick;
boolean sharpnessThick2;
boolean sharpnessThick3;
boolean sharpnessThickRandom;

// Setup start
void setup() {
  frameRate(60);
  size (400, 400);
  println("Click to start!");
}

void draw() {

  // Boolean switching through menus from titlescreen to play
  if (isPlay) {
    titleScreen();
  } else {
    play();
    updateEraser();
    drawLine();
  }
}

// Games title screen
void titleScreen() {

  
  
  background(121, 82, 48);

  //Looped background
  stroke(0);
  strokeWeight(1);
  for (int i = 0; i <400; i+= 30) {
    for (int j = 10; j <400; j+= 30) {
      line(j, i, j, i+50);
    }
  }
  noStroke();

  // Drawing the Cavas
  fill(255);
  rect(20, 130, 200, 250);

  //Drawing letters (Letter A)
  fill(redColourR, redColourG, redColourB);
  //Left side of letter
  rect(20, 50, 10, 50);
  //Right side of letter
  rect(40, 50, 10, 50);
  //Middle bridge of letter
  rect(30, 60, 10, 10);
  //Top bridge of A
  rect(30, 40, 10, 10);
  //End of A

  //(Start of r) Stem of r
  rect(60, 50, 10, 50);
  //bridge of r 1
  rect(70, 50, 10, 10);
  //bridge of r 2
  rect(80, 60, 20, 10);
  //End of r

  //(Start of t) Stem of t
  rect(120, 40, 10, 60);
  //bridge of t
  rect(110, 50, 30, 10);
  //end of t

  //(Start of w) left side of w
  rect(170, 40, 10, 50);
  //First connection bridge of w
  rect(180, 90, 10, 10);
  //middle of w
  rect(190, 40, 10, 50);
  //Second connection bridge of w
  rect(200, 90, 10, 10);
  //Right side of w
  rect(210, 40, 10, 50);
  //end of w

  //(Start of o) left side of o
  rect(230, 50, 10, 40);
  //bottom bridge of o
  rect(240, 90, 20, 10);
  //top bridge of o
  rect(240, 40, 20, 10);
  //right side of o
  rect(260, 50, 10, 40);
  //end of 0

  //(Start of r) Stem of r
  rect(280, 50, 10, 50);
  //bridge of r 1
  rect(290, 50, 10, 10);
  //bridge of r 2
  rect(300, 60, 20, 10);
  //End of r

  //(start of l) l
  rect(330, 40, 10, 60);
  //end of l

  //(Start of d) left side of d
  rect(350, 70, 10, 20);
  //bottom bridge of d
  rect(360, 90, 20, 10);
  //stem of d
  rect(370, 40, 10, 50);
  //top bridge of d
  rect(360, 70, 20, 10);

  //Big red button
  ellipse(300, 300, 100, 100);

  //Shine on big red button
  fill(0, 0, 0, 50);
  ellipse(300, 300, 60, 60);
}
// End of title screen

// Beginning of play screen
void play() {

  //Circle behind sky *test*
  stroke(0);
  fill(0);
  ellipse(20, 20, 20, 20);
  noStroke();

  //Sky background list
  fill(29, 226, 240);
  rect(0, 370, 400, 30);
  fill(29, 220, 240);
  rect(0, 340, 400, 30);
  fill(29, 215, 240);
  rect(0, 310, 400, 30);
  fill(29, 210, 240);
  rect(0, 280, 400, 30);
  fill(29, 205, 240);
  rect(0, 250, 400, 30);
  fill(29, 200, 240);
  rect(0, 220, 400, 30);
  fill(29, 195, 240);
  rect(0, 190, 400, 30);
  fill(29, 190, 240);
  rect(0, 160, 400, 30);
  fill(29, 185, 240);
  rect(0, 130, 400, 30);
  fill(29, 180, 240);
  rect(0, 100, 400, 30);
  fill(29, 175, 240);
  rect(0, 70, 400, 30);
  fill(29, 170, 240);
  rect(0, 40, 400, 30);
  fill(29, 165, 240);
  rect(0, 10, 400, 30);
  fill(29, 160, 240);
  rect(0, 0, 400, 30);
  // Sky background ends

  //Sun top left
  fill(yellowPaintR, orangePaintG, orangePaintB);
  ellipse(40, 40, 40, 40);

  //Mountains in the background
  fill(mountainR, mountainG, mountainB);
  triangle(0, 400, 25, 100, 200, 400);
  fill(mountainR, mountainG, mountainB);
  triangle(200, 400, 325, 100, 400, 400);

  //Grass ground
  fill(0, 140, 0);
  ellipse(200, 400, 400, 50);

  //Setting up the cloud speeds and making the clouds bounce back and forth when they reach the edges of the screen
  cloudX = cloudX + cloudSpeed;
  cloudY = cloudY + cloudSpeed;

  if ((cloudX > width) || (cloudX < 0)) {
    cloudSpeed = cloudSpeed * -1;
  } else if ((cloudY > height) || (cloudY < 0)) {
    cloudSpeed = cloudSpeed * -1;
  }
  //Cloud setting up ends

  //Clouds floating in background
  fill(255, 255, 255, 100);
  ellipse(cloudX, 30, 30, 30);
  fill(255, 255, 255, 100);
  ellipse(cloudX + 20, 30, 30, 30);
  fill(255, 255, 255, 100);
  ellipse(cloudX + 10, 10, 30, 30);
  fill(255, 255, 255, 100);
  ellipse(cloudX + 40, 30, 30, 30);
  fill(255, 255, 255, 100);
  ellipse(cloudX + 30, 10, 30, 30);

  fill(255, 255, 255, 100);
  ellipse(cloudX + 200, 150, 30, 30);
  fill(255, 255, 255, 100);
  ellipse(cloudX + 220, 150, 30, 30);
  fill(255, 255, 255, 100);
  ellipse(cloudX + 210, 130, 30, 30);
  fill(255, 255, 255, 100);
  ellipse(cloudX + 240, 150, 30, 30);
  fill(255, 255, 255, 100);
  ellipse(cloudX + 230, 130, 30, 30);


  // Canvas in middle of screen
  fill(255);
  rect(100, 80, 200, 250);
  noFill();
  rect(100, 80, 200, 250);


  //Top of canvas
  fill(208, 158, 109);
  rect(185, 40, 30, 40);

  //Shelf of the canvas
  fill(208, 158, 109);
  rect(80, 330, 245, 20);

  //Tray for sharpness options
  fill(208, 158, 109);
  rect(10, 175, 40, 150);

  //Tray for the colour options
  fill(208, 158, 109);
  rect(320, 70, 55, 230);

  //Sharpness options 
  fill(blackPaint);
  ellipse(30, 200, 40, 40);
  ellipse(30, 240, 30, 30);
  ellipse(30, 270, 20, 20);
  ellipse(30, 290, 10, 10);

  //Eraser tool
  fill(eraserPinkR, eraserPinkG, eraserPinkB);
  rect(eraserX, eraserY, 20, 40);
  fill(whitePaint);
  rect(eraserX, eraserY, 20, 10);

  //Random sharpness

  fill(blackPaint);
  ellipse(30, 310, (int) random(10, 20), (int) random(10, 20));

  //Sharpness options end

  //Paint options
  //Red paint
  fill(redPaintR, redPaintG, redPaintB);
  rect(325, 100, 20, 20);

  //Blue paint
  fill(bluePaintR, bluePaintG, bluePaintB);
  rect(350, 125, 20, 20);

  //Green paint
  fill(greenPaintR, greenPaintG, greenPaintB);
  rect(325, 150, 20, 20);

  //Purple paint
  fill(purplePaintR, purplePaintG, purplePaintB);
  rect(350, 175, 20, 20);

  //Yellow paint
  fill(yellowPaintR, yellowPaintG, yellowPaintB);
  rect(325, 200, 20, 20);

  //Orange paint
  fill(orangePaintR, orangePaintG, orangePaintB);
  rect(350, 225, 20, 20);

  //Black paint
  fill(blackPaint);
  rect(325, 250, 20, 20);

  //White paint
  fill(whitePaint);
  rect(350, 275, 20, 20);

  //Random paint
  fill((int) random(50, 255), (int) random(50, 255), (int)random (50, 255));
  rect(350, 75, 20, 20);

  //Paint options end
}

// Colour stroke calls being sectioned off
void redStroke() {
  stroke(redPaintR, redPaintG, redPaintB);
}

void blueStroke() {
  stroke(bluePaintR, bluePaintG, bluePaintB);
}

void greenStroke() {
  stroke(greenPaintR, greenPaintG, greenPaintB);
}

void purpleStorke() {
  stroke(purplePaintR, purplePaintG, purplePaintB);
}

void orangeStroke() {
  stroke(orangePaintR, orangePaintG, orangePaintB);
}

void yellowStroke() {
  stroke(yellowPaintR, yellowPaintG, yellowPaintB);
}

void blackStroke() {
  stroke(blackPaint);
}

void whiteStroke() {
  stroke(whitePaint);
}

void randomStroke() {
  stroke((int) random(50, 255), (int) random(50, 255), (int)random (50, 255));
}
//Colour calls end

//Mouse pressed down makes the drawing
void mousePressed() {
  // Changes the title screen into play screen
  if (isPlay) {
    isPlay = false;
  }
  // Saving the mouse's current X position
  else {  
    mouseStartX = mouseX; 
    // Saving the mouse's current Y posistion
    mouseStartY = mouseY; 
    // The line should be drawn
    doDrawLine = true; 

    //If red paint were clicked, change to red paint
    if (pmouseX >= 325 && pmouseX <= 20 && pmouseY <= 20 && pmouseY >= 100);
    {
      redStroke();
    }
  }
}

// When the mouse is released the drawing will stop
void mouseReleased() {
  // The line won't be drawn
  doDrawLine = false;
}


void drawLine() {
  //If the line should be drawn
  if (doDrawLine) {
    stroke(0, 0, 0);
    strokeWeight(5);
    line(mouseStartX, mouseStartY, mouseX, mouseY);
  }
}
// Press keys to move eraser (The control input)
void keyPressed() {
  if (key == 'w');
  {
    eraserYmove = -1;
  }
  if (key == 'a');
  {
    eraserXmove = -1;
  }
  if (key == 's') {
    eraserYmove = 1;
  }
  if (key == 'd') {
    eraserXmove = 1;
  }
}
// When keys are released, eraser stops moving
void keyReleased() {
  if (key == 'w');
  {
    eraserYmove = 0;
  } 
  if (key == 'a');
  {
    eraserXmove = 0;
  }
  if (key == 's') {
    eraserYmove = 0;
  }
  if (key == 'd') {
    eraserXmove = 0;
  }
}

void updateEraser() {
  eraserX += eraserSpeed * eraserXmove; 
  eraserY += eraserSpeed * eraserYmove;
}