Skip to content

Instantly share code, notes, and snippets.

@memish
Created December 6, 2018 12:59
Show Gist options
  • Save memish/308e83864172c60c4d5350a9f860a0c1 to your computer and use it in GitHub Desktop.
Save memish/308e83864172c60c4d5350a9f860a0c1 to your computer and use it in GitHub Desktop.
String[] phrases = new String[2];
/*
prev and next buttons at top take you from one sentence to the next
prev and next buttons on the rectangle take you to next word
click on the rectangle to flip from english to latin
Quizlet Style
TASK:
1) add more to the phrases array
2) customize and make more user Friendly
- example, when you press blue buttons next word should default
to form without definition
*/
int count1 = -1;
int count2 = 0;
String[] lat;
String[] eng;
String disp = "Flip Latin";
boolean latin = false;
void setup(){
setArrays();
size(800,600);
}
void draw(){
background(200);
//top buttons For Phrase
//left Phrase button
fill(255,0,255);
rect(20,20,50,50);
fill(255,255,255);
textSize(32);
text("<",30,50);
//Right Phrase button
fill(255,0,255);
rect(720,20,50,50);
fill(255,255,255);
textSize(32);
text(">",730,50);
//Lower Buttons For phrases
//left word button
fill(0,0,255);
rect(20,320,50,50);
fill(255,255,255);
textSize(32);
text("<",30,350);
//Right word button
fill(0,0,255);
rect(720,320,50,50);
fill(255,255,255);
textSize(32);
text(">",730,350);
//main area
fill(255,255,255);
rect(100,100,600,450);
//show text
textSize(22);
if(lat!=null){
if(latin==false){
fill(255,0,0);
text(lat[count2],110,350);
}else{
fill(0,0,255);
text(eng[count2],110,350);
}
}
}
void mousePressed(){
//left top button
if(mouseX>20 && mouseX<70 && mouseY>20 && mouseY<70){
println("top left - Examine Previous Phrase");
count1--;
if(count1<0){
count1 = phrases.length-1;
}
examinePhrase();
}//top left
if(mouseX>720 && mouseX<770 && mouseY>20 && mouseY<70){
println("top right - examine next phrase");
count1++;
if(count1>phrases.length-1){
count1=0;
}
examinePhrase();
}//top right
//click big rect
if(mouseX>100 && mouseX<700 && mouseY>50 && mouseY<550){
println("Big Rect");
if(latin==false){
latin=true;
}else{
latin=false;
}
}
//bottom buttons
if(mouseX>20 && mouseX<70 && mouseY>320 && mouseY<370){
println("Bottom left");
count2--;
if(count2<0){
count2 = lat.length-1;
}
}//top left
if(mouseX>720 && mouseX<770 && mouseY>320 && mouseY<370){
println("Bottom right ");
count2++;
if(count2>lat.length-1){
count2=0;
}
}//top right
}
public void examinePhrase(){
String[] words = split(phrases[count1],"^");
String[] x = words[0].split(" " );
lat = new String[x.length+1];
eng = new String[x.length+1];
lat[0] = words[1];
eng[0] = words[0];
println("Examine Phrase " + words.length + " " + lat.length);
for(int i = 1; i<lat.length; i++){
eng[i] = x[i-1];
lat[i] = words[i+1];
}
}
public void setArrays(){
phrases[0] = "Argus travels to Troy and picks up a sword."+
"^Argus navigat ad Troiae et portat hastam." +
"^Argus, -i m. nominative; name" +
"^Navigat- navigare: to sail, 1st declension; verb" +
"^Ad (+ acc): to, towards; preposition"+
"^Troiae f. pl. nom- Troy; Troy; noun"+
"^Et - and (conj.)"+
"^Portat, portare: to carry, 1st declension; verb"+
"^up"+
"^a"+
"^Hastam - Hasta, hastae- f.- spear; noun";
phrases[1] = "Argus says ‘In the name of Rome itself!’"+
"^Argus dicit \"in nomine de romani ipse\""+
"^Argus, -i -(proper noun) - name - m. Nominative -"+
"^Dicit/dicere - (verb) - to say 3rd declension"+
"^In (+ ablative) - (preposition) - in"+
"^the"+
"^Nomine"+
"^De (+ ablative) - (preposition) - about/down from/of"+
"^Romanus, -i - (proper noun) - Roman/s - m. nominative"+
"^Ipse, -i - (intensifying pronoun) - myself/yourself/himself/themselves - m. nominative";
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment