Coding for final
- Kelly Kiernan
- May 14, 2019
- 3 min read
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; } }
Comments