top of page
  • Writer's pictureRob George

Week 6: Rollovers + 25 Dots Part A + First Draft Winter Translator

Updated: Dec 10, 2020

Task 1: Stop Go Simple Traffic Light

This task was to practice with rollovers and buttons.

//Week 6: Task 1


float diam=240;

float x1=200;

float y1=150;

float x2=200;

float y2=425;

boolean Green=false;

boolean Red=false;


void setup() {

size(600, 600);

}


void draw() {

background(#FFCC24);

//Green Light

fill(#109D0A);

noStroke();

ellipse(x1, y1, diam, diam);

//Red Light

fill(#F52100);

noStroke();

ellipse(x2, y2, diam, diam);

//Lights Boolean

if (Green){

fill(#109D0A);

noStroke();

ellipse(x1, y1, diam, diam);

textAlign(CENTER);

textSize(70);

text("GO!", 425,200);

}else if (Red){

fill(#F52100);

noStroke();

ellipse(x2, y2, diam, diam);

textAlign(CENTER);

textSize(70);

text("STOP!", 450, 450);

}


//Rollover

if (dist(x1,y1,mouseX,mouseY)<diam/2) {

stroke(255);

strokeWeight(5);

fill(#109D0A);

ellipse(x1, y1, diam, diam);

} else if (dist(x2,y2,mouseX,mouseY)<diam/2) {

stroke(255);

strokeWeight(5);

fill(#F52100);

ellipse(x2, y2, diam, diam);

}

}

void mousePressed(){

if (dist(x1,y1,mouseX,mouseY)<diam/2){

Green=true;

Red=false;

}else if (dist(x2,y2,mouseX,mouseY)<diam/2){

Green=false;

Red=true;

}

}


Assignment 1: 25 Dots Part A

This is Part A of a 25 dots assignment. For this part I had created the 5x5 dots that I will be using for the rest of this project. I created them by using a nested for loop.


//25 Dots Part A


void setup() {

size(720, 720);

}


void draw() {

background(255);

noStroke();

fill(0);


//25 Dots


for (float x=120; x<width; x=x+120) { //Nested for loops

for (float y=120; y<height; y=y+120) {

float diam=50; //Local variable: ellipse diameter is 50

ellipse(x, y, diam, diam);

}

}


//MATH:

//To Find x and y:

//1) 5/6 = 0.83 2) 720*0.83 = 597.6 (rounded up to 600) 3) 720-600=120

}



Assignment 2: Completed Translator

I added icicles and snow. The snow increases by level of difficulty but after a critique I decided I would change the last language (Greek) to Swedish to pair the snow with location and temperature. The colors of the buttons also indicate this as they go from a warmer color to the coldest color. The green also needs to be more of a mint green because it is currently too warm. You can view the newer version in Week 7.


int diam=240; //Button Diameter

int diam2=1200; //Giat snowball diameter


//Buttons

int xENGL=150;

int yENGL=800;

int xSPAN=450;

int ySPAN=800;

int xITAL=750;

int yITAL=800;

int xFREN=1050;

int yFREN=800;

int xGREK=1350;

int yGREK=800;


//Booleans for all buttons

boolean btENGL=false;

boolean btSPAN=false;

boolean btITAL=false;

boolean btFREN=false;

boolean btGREK=false;

boolean bckgrnd=false;


//Making the header translate too

boolean header=true;


//Icicle 1

float iceX1=164;

float iceY1=130;

float iceX1_2=200;

float iceY1_2=240;

float iceX1_3=180;

float iceY1_3=550;

//Icicle 2

float iceX2=250;

float iceY2=140;

float iceX2_2=300;

float iceY2_2=340;

float iceX2_3=275;

float iceY2_3=725;

//Icicle 3

float iceX3=1185;

float iceY3=140;

float iceX3_2=1250;

float iceY3_2=270;

float iceX3_3=1205;

float iceY3_3=840;

//Icicle 4

float iceX4=570;

float iceY4=500;

float iceX4_2=600;

float iceY4_2=550;

float iceX4_3=585;

float iceY4_3=675;


//Snow Images for Buttons

PImage moderateSnow;

PImage heavySnow;


void setup() {

size(1500, 1000);


moderateSnow=loadImage("Moderate Snow@300x.png");

imageMode(CENTER);

moderateSnow.resize(0, 50);


heavySnow=loadImage("Heavy Snow@300x.png");

imageMode(CENTER);

heavySnow.resize(0, 100);

}


void draw() {


background(7, 18, 44);


//Word Display Snowball

noStroke();

fill(255);

ellipse(width/2, 0, diam2, diam2);


//Initial Header text

if (header) {

fill(7, 18, 44);

textSize(90);

textAlign(CENTER);

text("Winter Translator", width/2, 140);

}


//Button Shape

fill(255);

noStroke();

ellipse(xENGL, yENGL, diam, diam);

ellipse(xSPAN, ySPAN, diam, diam);

ellipse(xITAL, yITAL, diam, diam);

ellipse(xFREN, yFREN, diam, diam);

ellipse(xGREK, yGREK, diam, diam);

//Button Text

fill(7, 18, 44);

textSize(40);

textAlign(CENTER);

text("English", xENGL, 810);

text("Spanish", xSPAN, 810);

text("Italian", xITAL, 810);

text("French", xFREN, 810);

text("Greek", xGREK, 810);



//TRANSLATIONS


if (btENGL) { //English

fill(73, 20, 159);

noStroke();

ellipse(xENGL, yENGL, diam, diam);

fill(255);

textSize(40);

textAlign(CENTER);

text("English", xENGL, 810);

//content

fill(73, 20, 159);

textSize(70);

textAlign(CENTER);

text("My favorite season!", width/2, 340);

//Header text

fill(7, 18, 44);

textSize(90);

textAlign(CENTER);

text("Winter Translator", width/2, 140);

} else if (btSPAN) { //Spanish

fill(0, 175, 76);

noStroke();

ellipse(xSPAN, ySPAN, diam, diam);

fill(255);

textSize(40);

textAlign(CENTER);

text("Spanish", xSPAN, 810);

//content

fill(0, 175, 76);

textSize(70);

textAlign(CENTER);

text("Mi estación favorita!", width/2, 340);

//ICICLE //ICICLE

fill(255);

noStroke();

triangle(iceX1, iceY1, iceX1_2, iceY1_2, iceX1_3, iceY1_3);

//Header text

fill(7, 18, 44);

textSize(90);

textAlign(CENTER);

text("Traductor de invierno", width/2, 140);

} else if (btITAL) { //Italian

fill(0, 170, 135);

noStroke();

ellipse(xITAL, yITAL, diam, diam);

fill(255);

textSize(40);

textAlign(CENTER);

text("Italian", xITAL, 810);

//content

fill(0, 170, 135);

textSize(70);

textAlign(CENTER);

text("La mia stagione preferita!", width/2, 340);

//ICICLES //ICICLES

fill(255);

noStroke();

triangle(iceX1, iceY1, iceX1_2, iceY1_2, iceX1_3, iceY1_3);

triangle(iceX2, iceY2, iceX2_2, iceY2_2, iceX2_3, iceY2_3);

//SNOWING //Light Snowfall

frameRate(2);

fill(7, 18, 44, 5);

rect(0, 0, width, height);

noStroke();

fill(255);

ellipse(random(width), random(height), 30, 30);

ellipse(random(width), random(height), 20, 20);

ellipse(random(width), random(height), 40, 40);

//Header text

fill(7, 18, 44);

textSize(90);

textAlign(CENTER);

text("Traduttore Invernale", width/2, 140);

} else if (btFREN) { //French

fill(0, 134, 207);

noStroke();

ellipse(xFREN, yFREN, diam, diam);

fill(255);

textSize(40);

textAlign(CENTER);

text("French", xFREN, 810);

//content

fill(0, 134, 207);

textSize(70);

textAlign(CENTER);

text("Ma saison préférée!", width/2, 340);

//ICICLES //ICICLES

fill(255);

noStroke();

triangle(iceX1, iceY1, iceX1_2, iceY1_2, iceX1_3, iceY1_3);

triangle(iceX2, iceY2, iceX2_2, iceY2_2, iceX2_3, iceY2_3);

triangle(iceX3, iceY3, iceX3_2, iceY3_2, iceX3_3, iceY3_3);

//SNOWING //Moderate Snowfall

frameRate(5);

fill(7, 18, 44, 5);

rect(0, 0, width, height);

noStroke();

fill(255);

ellipse(random(width), random(height), 20, 20);

ellipse(random(width), random(height), 30, 30);

ellipse(random(width), random(height), 25, 25);

ellipse(random(width), random(height), 40, 40);

//Moderate Snow On Top of FRENCH Button //Moderate Button Snow

image(moderateSnow, 1050, 700);

//Header text

fill(7, 18, 44);

textSize(90);

textAlign(CENTER);

text("L'Hiver Traducteur", width/2, 140);

} else if (btGREK) { //Greek

fill(0, 93, 144);

noStroke();

ellipse(xGREK, yGREK, diam, diam);

fill(255);

textSize(40);

textAlign(CENTER);

text("Greek", xGREK, 810);

//content

fill(0, 93, 144);

textSize(70);

textAlign(CENTER);

text("Η αγαπημένη μου σεζόν!", width/2, 340);

//ICICLES //ICICLES

fill(255);

noStroke();

triangle(iceX1, iceY1, iceX1_2, iceY1_2, iceX1_3, iceY1_3);

triangle(iceX2, iceY2, iceX2_2, iceY2_2, iceX2_3, iceY2_3);

triangle(iceX3, iceY3, iceX3_2, iceY3_2, iceX3_3, iceY3_3);

triangle(iceX4, iceY4, iceX4_2, iceY4_2, iceX4_3, iceY4_3);

//SNOWING //Blizzard

frameRate(10);

fill(7, 18, 44, 5);

rect(0, 0, width, height);

noStroke();

fill(255);

ellipse(random(width), random(height), 20, 20);

ellipse(random(width), random(height), 30, 30);

ellipse(random(width), random(height), 25, 25);

ellipse(random(width), random(height), 35, 35);

ellipse(random(width), random(height), 40, 40);

//Heavy Snow On Top of GREEK Button //Heavy Button Snow

image(heavySnow, 1350, 700);

//Header text

fill(7, 18, 44);

textSize(80);

textAlign(CENTER);

text("Χειμώνας Μεταφραστής", width/2, 140);

}

println(mouseX, mouseY);

}


void mousePressed() {


//when mouse pressed on English button


if (dist(xENGL, yENGL, mouseX, mouseY)<diam/2) {

btENGL=true;

btSPAN=false;

btITAL=false;

btFREN=false;

btGREK=false;

header=false;

}


//when mouse pressed on Spanish button


if (dist(xSPAN, ySPAN, mouseX, mouseY)<diam/2) {

btENGL=false;

btSPAN=true;

btITAL=false;

btFREN=false;

btGREK=false;

header=false;

}


//when mouse pressed on Spanish button


if (dist(xITAL, yITAL, mouseX, mouseY)<diam/2) {

btENGL=false;

btSPAN=false;

btITAL=true;

btFREN=false;

btGREK=false;

header=false;

}


//when mouse pressed on Spanish button


if (dist(xFREN, yFREN, mouseX, mouseY)<diam/2) {

btENGL=false;

btSPAN=false;

btITAL=false;

btFREN=true;

btGREK=false;

header=false;

}


//when mouse pressed on Spanish button


if (dist(xGREK, yGREK, mouseX, mouseY)<diam/2) {

btENGL=false;

btSPAN=false;

btITAL=false;

btFREN=false;

btGREK=true;

header=false;

}

}




<Back to Coding Main Page

4 views0 comments
bottom of page