xxxxxxxxxx
435
//Assets
var myFontBook;
var Title, Version, Intro, Instruction, SelectReg, SelDiscard, Regions, RegionsBDis, RegionAH, RegionBH, RegionCH, RegionDH, RegionEH;
var pics = [];
var i = 0;
//Color palette
/*
var color1 = '#0f1626';
var color2 = '#e9af28';
var color3 = '#ff533d';
var color4 = '#ab987a';
var color5 = '#f5f5f5';
var color6 = '#000000';
*/
var color1 = '#200605';
var color2 = '#fcb702';
var color3 = '#d51101';
var color4 = '#e35901';
var color5 = '#f7ead8';
var color6 = '#000000';
//Page titles
var line2A, line2, line3, line4;
//Buttons
var homeb, introb, instructionsb, regionbA, regionbB, regionbC, regionbD, regionbE, regionsb, overlayb, discardb, retainb, resetb;
//Counters
var selectedImg = 0;
var currentImg;
var discards = 0;
var discardsMin = 2;
var discardsMax = 3;
var shufflesMin = 0;
var shufflesMax = 10;
var randColour;
//Result page
var resultMsg = "";
var splitString;
function preload() {
//Preload font
myFontBook = loadFont('Assets/Font/GothamRounded-Book.otf');
//Preload images
Title = loadImage('Assets/Images/01-Title-1.png');
Version = loadImage('Assets/Images/01-Version-1.png');
Intro = loadImage('Assets/Images/02A-Text-1.png');
Instruction = loadImage('Assets/Images/02-Text-1.png');
SelectReg = loadImage('Assets/Images/03-Text-1.png');
SelDiscard = loadImage('Assets/Images/04-Text-1.png');
Regions = loadImage('Assets/Images/03-Regions.png');
RegionsBDis = loadImage('Assets/Images/03-Button-1-Dis.png');
RegionAH = loadImage('Assets/Images/03-Region-A-H.png');
RegionBH = loadImage('Assets/Images/03-Region-B-H.png');
RegionCH = loadImage('Assets/Images/03-Region-C-H.png');
RegionDH = loadImage('Assets/Images/03-Region-D-H.png');
RegionEH = loadImage('Assets/Images/03-Region-E-H.png');
for (i=1; i<=10; i++) {
pics[i] = loadImage("Assets/Images/04-Pic-"+i+".png");
}
}
function setup() {
createCanvas(windowWidth, windowHeight);
background(color1);
imageMode(CENTER);
textAlign(CENTER);
textFont(myFontBook);
textSize(20);
noStroke();
fill(color5);
drawScene1();
}
function draw() {
//NA
}
function drawScene1(){
background(color1);
homeb = createImg('Assets/Images/01-Button-1.png');
homeb.mousePressed(drawScene2A);
homeb.position(width/2-112,height/2+160);
image(Title,width/2,height/2-25);
image(Version,width/2,height/2+290);
}
function drawScene2A(){
background(color1);
homeb.hide();
introb = createImg('Assets/Images/02A-Button-1.png');
introb.mousePressed(drawScene2);
introb.position(width/2-87,height/2+170);
image(Intro,width/2,height/2-280);
/*
A bountiful, untouched land awaits! As you build a glorious new country out of the barbarous waste that it was before you arrived, be careful of the types of people you allow to stay! The community you build now will shape the country for all time!
*/
line2A = "A bountiful, untouched land awaits!//As you build a glorious new country/of the barbarous waste that it was/before you arrived, be careful of the/types of people you allow to stay!/The community you build now/ will shape the country/for all time!"
splitString = split(line2A, '/');
text(splitString[0], width / 2, height / 2-100-10);
text(splitString[1], width / 2, height / 2-75-10);
text(splitString[2], width / 2, height / 2-50-10);
text(splitString[3], width / 2, height / 2-25-10);
text(splitString[4], width / 2, height / 2-10);
text(splitString[5], width / 2, height / 2+25-10);
text(splitString[6], width / 2, height / 2+50-10);
text(splitString[7], width / 2, height / 2+75-10);
text(splitString[8], width / 2, height / 2+100-10);
}
function drawScene2(){
background(color1);
introb.hide();
instructionsb = createImg('Assets/Images/02-Button-1.png');
instructionsb.mousePressed(drawScene3);
instructionsb.position(width/2-94,height/2+170);
image(Instruction,width/2,height/2-280);
/*
First, select a region you plan to improve from the several available.
Next, looking at the photos of some randomly-picked colonisees of this region, decide which of them are undesirable. Tap “Retain” to keep the desirables or “Discard” to remove the undesirables.
You must remove 20% to 30% of the population, so your new empire can thrive. Choose wisely!
*/
line2 = "1) First, select a region you plan/to improve from the several available.//2) Next, looking at the photos of/some randomly-picked colonisees/of this region, decide which of/them are undesirable./Tap “Retain” to keep the desirables or/“Discard” to remove the undesirables.//3) You must remove 20% to 30%/ of the population, so your/new empire can thrive./Choose wisely!"
splitString = split(line2, '/');
text(splitString[0], width / 2, height / 2-175-10);
text(splitString[1], width / 2, height / 2-150-10);
text(splitString[2], width / 2, height / 2-125-10);
text(splitString[3], width / 2, height / 2-100-10);
text(splitString[4], width / 2, height / 2-75-10);
text(splitString[5], width / 2, height / 2-50-10);
text(splitString[6], width / 2, height / 2-25-10);
text(splitString[7], width / 2, height / 2-10);
text(splitString[8], width / 2, height / 2+25-10);
text(splitString[9], width / 2, height / 2+50-10);
text(splitString[10], width / 2, height / 2+75-10);
text(splitString[11], width / 2, height / 2+100-10);
text(splitString[12], width / 2, height / 2+125-10);
text(splitString[13], width / 2, height / 2+150-10);
}
function drawScene3(){
background(color1);
instructionsb.hide();
image(SelectReg,width/2,height/2-280);
imageMode(CORNER);
image(RegionsBDis,width/2-167.5,height/2+250);
//image(Regions,width/2,height/2);
regionbA = createImg('Assets/Images/03-Region-A.png');
regionbA.mousePressed(highlightA);
regionbA.position(width/2-162,height/2-202);
regionbB = createImg('Assets/Images/03-Region-B.png');
regionbB.mousePressed(highlightB);
regionbB.position(width/2-90.3,height/2-107.2);
regionbC = createImg('Assets/Images/03-Region-C.png');
regionbC.mousePressed(highlightC);
regionbC.position(width/2+61.4,height/2-93.9);
regionbD = createImg('Assets/Images/03-Region-D.png');
regionbD.mousePressed(highlightD);
regionbD.position(width/2-179.6,height/2-44);
regionbE = createImg('Assets/Images/03-Region-E.png');
regionbE.mousePressed(highlightE);
regionbE.position(width/2-117,height/2+33.35);
}
function highlightA() {
regionsb = createImg('Assets/Images/03-Button-1.png');
regionsb.mousePressed(drawScene4);
regionsb.position(width/2-167.5,height/2+250);
regionbA.hide();
regionbB.hide();
regionbC.hide();
regionbD.hide();
regionbE.hide();
imageMode(CENTER);
image(Regions,width/2,height/2);
imageMode(CORNER);
image(RegionAH,width/2-162,height/2-202);
}
function highlightB() {
regionsb = createImg('Assets/Images/03-Button-1.png');
regionsb.mousePressed(drawScene4);
regionsb.position(width/2-167.5,height/2+250);
regionbA.hide();
regionbB.hide();
regionbC.hide();
regionbD.hide();
regionbE.hide();
imageMode(CENTER);
image(Regions,width/2,height/2);
imageMode(CORNER);
image(RegionBH,width/2-90.3,height/2-107.2);
}
function highlightC() {
regionsb = createImg('Assets/Images/03-Button-1.png');
regionsb.mousePressed(drawScene4);
regionsb.position(width/2-167.5,height/2+250);
regionbA.hide();
regionbB.hide();
regionbC.hide();
regionbD.hide();
regionbE.hide();
imageMode(CENTER);
image(Regions,width/2,height/2);
imageMode(CORNER);
image(RegionCH,width/2+61.4,height/2-93.9);
}
function highlightD() {
regionsb = createImg('Assets/Images/03-Button-1.png');
regionsb.mousePressed(drawScene4);
regionsb.position(width/2-167.5,height/2+250);
regionbA.hide();
regionbB.hide();
regionbC.hide();
regionbD.hide();
regionbE.hide();
imageMode(CENTER);
image(Regions,width/2,height/2);
imageMode(CORNER);
image(RegionDH,width/2-179.6,height/2-44);
}
function highlightE() {
regionsb = createImg('Assets/Images/03-Button-1.png');
regionsb.mousePressed(drawScene4);
regionsb.position(width/2-167.5,height/2+250);
regionbA.hide();
regionbB.hide();
regionbC.hide();
regionbD.hide();
regionbE.hide();
imageMode(CENTER);
image(Regions,width/2,height/2);
imageMode(CORNER);
image(RegionEH,width/2-117,height/2+33.35);
}
function drawScene4() {
background(color1);
regionsb.hide();
/*
overlayb = createImg('Assets/Images/04-Overlay.png');
overlayb.mousePressed(drawScene5);
overlayb.position(width/2-211,height/2-375);
*/
imageMode(CENTER);
image(SelDiscard,width/2,height/2-280);
discardb = createImg('Assets/Images/04-Button-1.png');
discardb.mousePressed(discard);
discardb.position(width/2-67.5+100,height/2+280);
retainb = createImg('Assets/Images/04-Button-2.png');
retainb.mousePressed(retain);
retainb.position(width/2-67.5-100,height/2+280);
selectedImg = int(1, 9);
print(selectedImg);
currentImg = pics[selectedImg];
image(currentImg, width / 2, height / 2);
}
function drawScene5() {
background(color1);
discardb = createImg('Assets/Images/04-Button-1.png');
discardb.mousePressed(discard);
discardb.position(width/2-67.5+100,height/2+280);
retainb = createImg('Assets/Images/04-Button-2.png');
retainb.mousePressed(retain);
retainb.position(width/2-67.5-100,height/2+280);
image(SelDiscard,width/2,height/2-280);
print(selectedImg);
currentImg = pics[selectedImg];
image(currentImg, width / 2, height / 2);
}
function discard (){
discardb.hide();
retainb.hide();
selectedImg++;
discards ++;
if (selectedImg <= shufflesMax){
drawScene5();
} else {
resultPage();
}
}
function retain (){
discardb.hide();
retainb.hide();
selectedImg++;
if (selectedImg <= shufflesMax){
drawScene5();
} else {
resultPage();
}
}
function resultPage(){
background(color1);
resetb = createImg('Assets/Images/05-Button-1.png');
resetb.mousePressed(resetAll);
resetb.position(width/2-150.5,height-220);
//Result ranges: 20% to 30%, less than 20% and more than 30%
if (discards >= discardsMin && discards <= discardsMax) {
resultMsg = "Well done! You have removed/undesirables from your new/country. It is now/generating wealth for you, and/the population is easily managed!";
splitString = split(resultMsg, '/');
text(splitString[0], width / 2, height / 2-75-10);
text(splitString[1], width / 2, height / 2-50-10);
text(splitString[2], width / 2, height / 2-25-10);
text(splitString[3], width / 2, height / 2-10);
text(splitString[4], width / 2, height / 2+25-10);
text(splitString[5], width / 2, height / 2+50-10);
} else if (discards < discardsMin && discards > shufflesMin) {
resultMsg = "Uh oh! You only/discarded " + round(discards/10*100) + "% of the/populace! Your country is/too overpopulated to be/manageable and profitable./Try again!";
splitString = split(resultMsg, '/');
text(splitString[0], width / 2, height / 2-75-10);
text(splitString[1], width / 2, height / 2-50-10);
text(splitString[2], width / 2, height / 2-25-10);
text(splitString[3], width / 2, height / 2-10);
text(splitString[4], width / 2, height / 2+25-10);
text(splitString[5], width / 2, height / 2+50-10);
} else if (discards > discardsMax && discards < shufflesMax) {
resultMsg = "Uh oh! You have/discarded " + round(discards/10*100) + "% of the/populace! Your country does not/ have enough population/to turn a profit./Try again!";
splitString = split(resultMsg, '/');
text(splitString[0], width / 2, height / 2-75-10);
text(splitString[1], width / 2, height / 2-50-10);
text(splitString[2], width / 2, height / 2-25-10);
text(splitString[3], width / 2, height / 2-10);
text(splitString[4], width / 2, height / 2+25-10);
text(splitString[5], width / 2, height / 2+50-10);
} else if (discards == shufflesMin) {
resultMsg = "Uh oh! You have/discarded none of the/populace! Your country is/too overpopulated to be/manageable and profitable./Try again!";
splitString = split(resultMsg, '/');
text(splitString[0], width / 2, height / 2-75-10);
text(splitString[1], width / 2, height / 2-50-10);
text(splitString[2], width / 2, height / 2-25-10);
text(splitString[3], width / 2, height / 2-10);
text(splitString[4], width / 2, height / 2+25-10);
text(splitString[5], width / 2, height / 2+50-10);
} else if (discards == shufflesMax) {
resultMsg = "Uh oh! You have/discarded all of the/populace! Your country/does not have any/population to turn a profit./Try again!";
splitString = split(resultMsg, '/');
text(splitString[0], width / 2, height / 2-75-10);
text(splitString[1], width / 2, height / 2-50-10);
text(splitString[2], width / 2, height / 2-25-10);
text(splitString[3], width / 2, height / 2-10);
text(splitString[4], width / 2, height / 2+25-10);
text(splitString[5], width / 2, height / 2+50-10);
}
}
function resetAll (){
resetb.hide();
drawScene1();
}