top of page
  • Kelly Kiernan

Coding for final

let font,

  fontsize = 40;

let fortune = [15];

//this is the ballspeed for every variable

var xSpeed = 5;

var xE = 1000;

var yE = 800;

var xS = 960;

var yS = 760;

var pickedFortune;

var beginning = true;

function setup() {

  createCanvas(2000, 1100);

  // Set text characteristics

  textSize(fontsize);

  textAlign(CENTER, CENTER);

  fortune[0] = "Shake again, your future is uncertain.";

  fortune[1] = "Future is cloudy.  Maybe you should try a Magic 9 ball instead.";

  fortune[2] = "Shake the 8 harder, please.  Appearing weak makes your future looks bleak."

  fortune[3] = "As I see it, yes."

  fortune[4] = "It is not certain but it is highly likely."

  fortune[5] = "Oof, the answer is no."

  fortune[6] = "It is improbable."

  fortune[7] = "It could be true."

  fortune[8] = "Interesting that you think a Magic 8 ball would know such a thing."

  fortune[9] = "Better not to tell you now."

  fortune[10] = "Outlook not so good."

  fortune[11] = "Don’t count on it."

  fortune[12] = "My sources say no."

  fortune[13] = "Concentrate harder and ask again."

  fortune[14] = "Trust your judgement, the answer lies within."

  //fortune[14]

  //pick a number, 0 1 or 2

  pickFortune = floor(random(0, 15))

}

function draw() {

  background('pink');

  //is this the beginning screen, or the ending screen

  if (beginning){

    text("Shake to ask the Magic 8 ball a question!", 1000, 300);

    //turn the speed off from the 8ball

  }

  else{

    //this is my magic 8 ball

    fill(0);

    ellipse (xE, yE, 200, 200);

    fill('blue');

    rect(xE - 40, yE - 40, 80, 80);

    fill('white');

    text("8", xE, yE);

    //shake

    //LOOK AT THE WALL BOUNCE CODE

    //1010, 990

    //HERE IS THE RANDOM FORTUNE

    fill(255, 0, 0);

    text(fortune[pickFortune], 1000, 350);

    //add your speed to move your ball here 

  }

}

function drawWords(x) {

  // The text() function needs three parameters:

  // the text to draw, the horizontal position,

  // and the vertical position

  fill(0);

  text(fortune[pickFortune], x, 80);

}

xE += xSpeed;

function keyPressed(){

  if (key == ' '){

    pickFortune = floor(random(0, 15))

    beginning = !beginning;

    xSpeed = -xSpeed;

  }

}

let font,   fontsize = 40; let fortune = [15]; //this is the ballspeed for every variable var xSpeed = 5; var xE = 1000; var yE = 800; var xS = 960; var yS = 760; var pickedFortune; var beginning = true; function setup() {   createCanvas(2000, 1100);   // Set text characteristics   textSize(fontsize);   textAlign(CENTER, CENTER);   fortune[0] = "Shake again, your future is uncertain.";   fortune[1] = "Oof, I'm not revealing that.  Maybe you should try a Magic 9 ball instead.";   fortune[2] = "Shake the 8 harder, please.  You're appearing weak making your future look bleak"   fortune[3] = "Your future will be bright if you decide to turn on the light."   fortune[4] = "Jumping to conclusions can lead to sprained ankles."   fortune[5] = "Fortune #6"   fortune[6] = "Fortune #7"   fortune[7] = "Fortune #8"   fortune[8] = "Fortune #9"   fortune[9] = "Fortune #10"   fortune[10] = "Fortune #11"   fortune[11] = "Fortune #12"   fortune[12] = "Fortune #13"   fortune[13] = "Fortune #14"   fortune[14] = "Fortune #15"   //fortune[14]   //pick a number, 0 1 or 2   pickFortune = floor(random(0, 15)) } function draw() {   background('pink');   //is this the beginning screen, or the ending screen   if (beginning){     text("Welcome", 1000, 300);     //turn the speed off from the 8ball   }   else{     //this is my magic 8 ball     fill(0);     ellipse (xE, yE, 200, 200);     fill('blue');     rect(xE - 40, yE - 40, 80, 80);     fill('white');     text("8", xE, yE);     //shake     //LOOK AT THE WALL BOUNCE CODE     //1010, 990     //HERE IS THE RANDOM FORTUNE     fill(255, 0, 0);     text(fortune[pickFortune], 1000, 350);     //add your speed to move your ball here    } } function drawWords(x) {   // The text() function needs three parameters:   // the text to draw, the horizontal position,   // and the vertical position   fill(0);   text(fortune[pickFortune], x, 80); } xE += xSpeed; function keyPressed(){   if (key == ' '){     pickFortune = floor(random(0, 15))     beginning = !beginning;     xSpeed = -xSpeed;   } }
5 views0 comments

Recent Posts

See All

Final coding

Examples of questions to ask a magic 8 ball Questions from an Aspiring Artist going through Tutorials 1.  Will my Tutorials grade reflect the amount of work that I have put in? 2.  Will I have an exhi

Final project

I didnt want to fully copy the jackson pollack splatter idea, but I really like it and want to maybe do a painting idea. I have a second idea thats a little clearer though. I was thinking of doing a

Interactive drawing

So my code uses a black outlined green circle to create drawings. If i hit up, it gets larger, down arrow, smaller. We have also manipulated colors. Left areow makes it orange, “r“ makes it red. va

bottom of page