aahdee-Speech

I thought that I would like this project. I didn’t.

Yikes.

My idea for this project was to have you play as a father that just simply doesn’t want to move to get up and get what he wants, so he calls upon his son. My parents used to (and still do) call upon me for the most mundane things, so I decided to make this into a small game, but make it pretty frustrating. I personally despise being stopped and asked to do something boring like to fix the wifi (which means that I shut it off and then turn it on) or chance the input source on the TV after I’ve shown my parents how to do it multiple times, so I channeled that feeling into making this game annoying to play. The thing is, the player can only get mad at themselves because their child is a sweet, sweet boy that can do nothing wrong. Below are my concept images.

I intended to have visuals for this game, but I didn’t because I felt as if it would ruin the immersion a bit and I was super burnt out this week. Next is the final product.

 

And finally, my code.

 

//setups
var myRec = new p5.SpeechRec('en-US');
 
var stage = -1;
var delay = 0;
var delayMax = 200;
var transition = false;
var startRec = false;
var wordFound = false;
var items = ["computer", "remote", "chips", "blanket", "pillow"];
var initChance = 10;
var wanted = items[Math.floor(Math.random()*5)];
var badWords = ["goddamn", "fucking", "stupid", "shit","bastard"];
var noise;
function setup()
{
	noise = loadSound('news.wav');
	createCanvas(600, 400);
	background(19, 7, 58);
	fill(255,255,255);
}
 
function splash()
{
	textFont("Tahoma",50);
	text("Retrival",10, 50);
	if (noise.isLoaded())
	{
		textFont("Tahoma",20);
		text("click to start",10, 100);
	}
	else
	{
		textSize(20);
		text("loading...",10, 100);
	}
 
	if (noise.isLoaded() && mouseIsPressed)
	{
		noise.play();
		stage = 0;
	}
}
 
function intro()
{
	textFont("Tahoma",20);
	var txt = "";
	var txtW = textWidth(txt);
	var txt2 = "";
	var txtW = textWidth(txt2);
	if (0 <= delay && delay < delayMax) 
	{
		txt = "You are a father in his mid 40s.";
		txtW = textWidth(txt);
		text(txt, width/2-txtW/2, height/2);
	}
	else if (delay <= delayMax*2) 
	{
		txt = "You're sitting on your couch watching TV.";
		txtW = textWidth(txt);
		txt2 = "You want your " + wanted + ", but you're too cozy/lazy to get it.";
		txtW2 = textWidth(txt2);
		text(txt, width/2-txtW/2, height/2);
		text(txt2, width/2-txtW2/2, height/2+40);
	}
	else if (delay <= delayMax*3)
	{
		txt = "Luckily, your son, Mark, can fetch things for you.";
		txtW = textWidth(txt);
		text(txt, width/2-txtW/2, height/2);
	}
	else 
	{
		txt = "Maybe you should call him over...";
		txtW = textWidth(txt);
		text(txt, width/2-txtW/2, height/2);
		if (!startRec) {
			myRec = new p5.SpeechRec('en-US');
			myRec.start();
		}
		startRec = true;
	}
	delay++;
}
 
 
function callMark()
{
	textFont("Tahoma",20);
	var txt = "";
	var txtW = textWidth(txt);
	var txt2 = "";
	var txtW = textWidth(txt2);
	if (delay < delayMax) 
	{
		txt = "Your toddler waddles over with a wide, drooly grin.";
		txtW = textWidth(txt);
		text(txt, width/2-txtW/2, height/2);
	}
	else
	{
		txt = "\"Yes Daddy!\" he sqeaks, and he looks up at you with his large eyes";
		txtW = textWidth(txt);
		txt2 = "waiting for your response. Tell him to get your "+wanted+".";
		txtW2 = textWidth(txt2);
		text(txt, width/2-txtW/2, height/2);
		text(txt2, width/2-txtW2/2, height/2+40);
		if (!startRec) {
			myRec = new p5.SpeechRec('en-US');
			myRec.start();
		}
		startRec = true;
	}
	delay++;
}
 
function search(resStr)
{
	textFont("Tahoma",20);
	var txt = "";
	var txtW = textWidth(txt);
	var txt2 = "";
	var txtW = textWidth(txt2);
 
	if (delay < delayMax) 
	{
		txt = "As Mark runs out of the room, giggling furiously,";
		txtW = textWidth(txt);
		txt2 = "you hear him yell \"Okay!!\".";
		txtW2 = textWidth(txt2);
		text(txt, width/2-txtW/2, height/2);
		text(txt2, width/2-txtW2/2, height/2+40);
	}
	else if (delay <= delayMax*2) 
	{
		txt = "You can only hope that he comes back with correct item";
		txtW = textWidth(txt);
		text(txt, width/2-txtW/2, height/2);
	}
	else if (delay <= delayMax*3){
		txt = "...";
		txtW = textWidth(txt);
		text(txt, width/2-txtW/2, height/2);
	}
	else if (delay <= delayMax*3){
		txt = "After some time, you hear Mark scuttle back to you";
		txtW = textWidth(txt);
		text(txt, width/2-txtW/2, height/2);
	}
	else
	{
		var rs = new RiString(resStr);
		var rsWords = rs.words()
		for (var i = 0; i < rsWords.length; i++)
		{
			if (rsWords[i] == wanted)
			{
				wordFound = true;
			}
			if (RiTa.isAdjective(rsWords[i]))
			{
				initChance += 10;
			}
		}
		if (wordFound)
		{
			c = random(100);
			if (c <= initChance)
			{
				delay = 0;
				stage = 3;
				transition = false; 
			}
			else
			{
				delay = 0;
				stage = 2;
				transition = false;
			}
		}
	}
	delay++;
}
 
function success()
{
	textFont("Tahoma",20);
	var txt = "";
	var txtW = textWidth(txt);
	var txt2 = "";
	var txtW = textWidth(txt2);
	if (delay < delayMax) 
	{
		txt = "In his hands, he carries your " +wanted;
		txtW = textWidth(txt);
		txt2 = "and he places it on your lap.";
		txtW2 = textWidth(txt2);
		text(txt, width/2-txtW/2, height/2);
		text(txt2, width/2-txtW2/2, height/2+40);
	}
	else if (delay <= delayMax*2) 
	{
		txt = "Smiling, you thank him, and he shuffles back to the other room";
		txtW = textWidth(txt);
		txt2 = "to go do whatever children his age does.";
		txtW2 = textWidth(txt2);
		text(txt, width/2-txtW/2, height/2);
		text(txt2, width/2-txtW2/2, height/2+40);
	}
	else if (delay <= delayMax*3)
	{
		txt = "You put your "+wanted+" off to the side, and continue to watch TV.";
		txtW = textWidth(txt);
		text(txt, width/2-txtW/2, height/2);
	}
	else
	{
		txt = "end.";
		txtW = textWidth(txt);
		text(txt, width/2-txtW/2, height/2);
	}
	delay++;
}
 
function fail()
{
	transition = false;
	textFont("Tahoma",20);
	var txt = "";
	var txtW = textWidth(txt);
	var txt2 = "";
	var txtW = textWidth(txt2);
	if (delay < delayMax) 
	{
		txt = "In his hands, there is nothing.";
		txtW = textWidth(txt);
		txt2 = "\"I couldn't find it!\"";
		txtW2 = textWidth(txt2);
		text(txt, width/2-txtW/2, height/2);
		text(txt2, width/2-txtW2/2, height/2+40);
	}
	else if (delay <= delayMax*2) 
	{
		txt = "You sigh. But this is to be expected.";
		txtW = textWidth(txt);
		txt2 = "Mark's a toddler, you need to be more descriptive.";
		txtW2 = textWidth(txt2);
		text(txt, width/2-txtW/2, height/2);
		text(txt2, width/2-txtW2/2, height/2+40);
	}
	else{
		txt = "Maybe describing the object would help?";
		txtW = textWidth(txt);
		text(txt, width/2-txtW/2, height/2);
		if (!startRec) {
			myRec = new p5.SpeechRec('en-US');
			myRec.start();
		}
		startRec = true;
	}
	delay++;
 
}
function runGame()
{
 
	if (stage == -1)
	{
		splash();
	}
	if (stage == 0)
	{
		intro();
		if (startRec && myRec.resultValue && (myRec.resultString == "Mark" || myRec.resultString == "mark")) 
		{
			stage++;
			delay = 0;
			startRec = false;
		}
		else if (startRec && myRec.resultValue && !(myRec.resultString == "Mark" || myRec.resultString == "mark"))
		{
			delay = -1;
			var txt = "He didn't hear you. Call him again.";
			var txtW = textWidth(txt);
			text(txt, width/2-txtW/2, height/2);
			myRec = new p5.SpeechRec('en-US');
			myRec.start();
		}
	}
	if (stage == 1)
	{
		//callMark();
		if (startRec && myRec.resultValue)
		{
			delay = 0;
			transition = true;
			startRec = false;
		}
		else if (transition)
		{
			search(myRec.resultString);
		}
		else
		{
			callMark();
		}
	}
	if (stage == 2) //failed action
	{
 
		if (startRec && myRec.resultValue)
		{
			delay = 0;
			transition = true;
			startRec = false;
		}
		else if (transition)
		{
			search(myRec.resultString);
		}
		else
		{
			fail();
		}
 
	}
	if (stage == 3) //success action.
	{
		success();
	}
}
function draw()
{
	background(19, 7, 58);
	runGame();
	//intro();
}