//Fonts used:
//Harald Runic by David Kerhoff
//Odinson by Iconian Fonts
PFont harald;
PFont odison;
int[][] memory;
int[][] results;
String[] runes = {"F","A","R","H","Y","E","N","X"};
int selector = 0;
int[] choice = {0,2,1,6,7};
int[] puzzle =new int[5];
int[] guess = new int[5];
int round = 0;
int end;
//credits and explanations
void setup(){
size(900,600);
harald = createFont("HaraldRunic-Rn0M.ttf",48);
odison = createFont("Odinson-224w.ttf",48);
startgame();
}
void draw(){
background(75);
if (frameCount == 1){
for (int i=0; i < puzzle.length;i++){
puzzle[i] = int(random(7));
}
}
println(puzzle[0], puzzle[1], puzzle[2], puzzle[3], puzzle[4]);
textAlign(CENTER);
textFont(odison);
fill(0);
textSize(128);
text("Runigma", 360, 160);
textSize(32);
text("Press s to start a new puzzle", 353,203);
fill(128);
textSize(128);
text("Runigma", 350, 150);
textSize(32);
text("Press s to start a new puzzle", 350,200);
stroke(255);
strokeWeight(5);
strokeJoin(ROUND);
line(50, 455, 50, 425);
line(40, 435, 50, 425);
line(60, 435, 50, 425);
line(50, 469, 50, 499);
line(40, 489, 50, 499);
line(60, 489, 50, 499);
line(140+selector*100,525,180+selector*100,525);
for (int i = 0; i < choice.length; i++){
noStroke();
strokeWeight(1);
fill(255);
circle(160+i*100, 462,80);
textSize(48);
fill(0);
textFont(harald);
textAlign(CENTER);
text(runes[choice[i]],160+i*100, 482);
}
for (int i=0; i < 5; i++){
for (int j=0; j< 8; j++){
if ( j < round){
fill(255);
circle(675+i*35,66*(j+1),30);
fill(0);
textFont(harald,22);
textAlign(CENTER);
text(runes[memory[j][i]],675+i*35, 9+66*(j+1));
} else {
fill(255);
circle(675+i*35,66*(j+1),30);
}
}
}
for (int i=0; i < 8; i++){
pushMatrix();
translate(825,38+66*i);
fill(results[i][0]);
circle(30,16,10);
fill(results[i][1]);
circle(18,24,10);
fill(results[i][2]);
circle(42,24,10);
fill(results[i][3]);
circle(23,36,10);
fill(results[i][4]);
circle(37,36,10);
popMatrix();
}
textAlign(LEFT);
textFont(odison,12);
fill(0);
text("Fonts: Harald Runic by David Kerkhoff) Odinson by Iconoan Fonts", 52,577);
text("www.fontspace.com", 52,592);
fill(128);
text("Fonts: Harald Runic by David Kerkhoff) Odinson by Iconoan Fonts", 50,575);
text("www.fontspace.com", 50,590);
fill(0);
circle(650,580,12);
text ("correct rune",672,577);
text ("correct position",672,592);
text ("correct rune",797,577);
text ("incorrect position",797,592);
fill(255);
circle(775,580,12);
fill(128);
text ("correct rune",670,575);
text ("correct position",670,590);
text ("correct rune",795,575);
text ("incorrect position",795,590);
if ( frameCount == end+1){
win();
} else if ( round == 8){
lost();
}
}
void keyPressed(){
if (keyPressed == true && keyCode == RIGHT & selector < 4){
selector++;
}
if (keyPressed == true && keyCode == LEFT & selector > 0){
selector--;
}
if (keyPressed == true && keyCode == UP){
choice[selector]++;
if (choice[selector] == runes.length){
choice[selector]=0;
}
}
if (keyPressed == true && keyCode == DOWN){
choice[selector]--;
if (choice[selector] < 0){
choice[selector]=runes.length-1;
}
}
if (keyPressed == true && key == 's' || key == 'S'){
loop();
startgame();
}
if (keyPressed == true && key == RETURN || key == ENTER){
int[] guess = new int[5];
int counter = 0;
arrayCopy(choice, memory[round]);
arrayCopy(choice, guess);
boolean[] marker = {false,false,false,false,false};
for (int i = 0; i < guess.length;i++){
for (int j = 0; j < puzzle.length;j++){
if (marker[j] != true){
if (guess[i] == puzzle[j]){
results[round][counter] = 255;
counter++;
marker[j] = true;
j = puzzle.length;
}
}
}
}
counter=0;
for (int i = 0; i < guess.length;i++){
if (guess[i] == puzzle[i]){
results[round][counter] = 0;
counter++;
}
}
int sum=0;
for (int i = 0; i < results[round].length;i++){
sum += results[round][i];
}
if (sum == 0){
end=frameCount;
}
//if ( round == 7){
//lost();
//}
round++;
}
}
void startgame() {
round = 0;
end = -1;
memory = new int[8][5];
results = new int[8][5];
for (int i=0; i < puzzle.length;i++){
puzzle[i] = int(random(8));
}
for (int i=0; i < 8; i++){
for (int j=0; j< 5; j++){
results[i][j] = 125;
}
}
}
void win(){
textFont(odison, 32);
textAlign(CENTER);
fill(0);
text("You did decode the old rune texts. Use their knowledge wisely.", 103, 253, 503, 353);
fill(128);
text("You did decode the old rune texts. Use their knowledge wisely.", 100, 250, 500, 350);
noLoop();
}
void lost(){
textFont(odison, 32);
textAlign(CENTER);
fill(0);
text("You could not decipher the old rune texts, Their knowledge stays hidden.", 103, 253, 503, 353);
fill(128);
text("You could not decipher the old rune texts, Their knowledge stays hidden.", 100, 250, 500, 350);
noLoop();
}
3 Likes