# Final User Test

FEEDBACK

According to my friend’s feedback, I think what I can improve is to make clearer instructions on the coin pusher. Since when I was making the physical setting, the coin pusher was pretty tricky.

I used the distance sensor to check if a coin has approached. But if the coin falls into the gap, the distance sensor would output an outlier, which could then lead to error. So I wrote “SWIPE a coin to START” before the game starts, hoping that people could just swipe — put the coin into the space and hold it for a second.

At first, my friend just tossed the coin into it, and the distance sensor didn’t capture that before the coin fell through it. Since she majors in IMA, she figured it out herself, but not everyone can understand how distance sensor works! So I decided to write specific instructions on the box about how to swipe a coin.

The other parts of the game was straightforward and understandable. As soon as my friend saw the claw/hand, she realized that it is a claw machine, so naturally she knew the way to play around it.

The last part was to show that there is possibility that you are lucky enough to grab a toy with an award. I set the probability to be quite low, so it took a long time before she could get the award. I had to change the code so that she could cheat on it.

PROGRESS:

```int joyX = A0;
int joyY = A1;
int button = 4;
int button_state;
const int trigPin = 7;
const int echoPin = 6;
int duration = 0;
int dist = 0;
int prize=0;

int red = 10;
int yellow = 9;
int blue = 8;

int posX;
int posY;

void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
Serial.println("0,0,0,0");
pinMode(A0, INPUT);
pinMode(A1, INPUT);
pinMode(button, OUTPUT);
pinMode(trigPin , OUTPUT);
pinMode(echoPin , INPUT);
pinMode(red, OUTPUT);
pinMode(yellow , OUTPUT);
pinMode(blue , OUTPUT);
pinMode(2,INPUT);
digitalWrite(2,HIGH);
}

void loop() {
// put your main code here, to run repeatedly:
//  Serial.println(posY);
//  Serial.println(posX);

digitalWrite(red,prize);
digitalWrite(trigPin, LOW);
delayMicroseconds(2);
digitalWrite(trigPin, HIGH);
delayMicroseconds(2);
digitalWrite(trigPin, LOW);

duration = pulseIn(echoPin, HIGH);
dist = duration/58.2;
//  Serial.println(dist);

while (Serial.available()) {
prize = Serial.parseInt();
// move 0

if (posX >= 550) {
Serial.print(1);
} else {
Serial.print(0);
}
Serial.print(",");

// move 1
if (posX <= 360) {
Serial.print(0);
} else {
Serial.print(0);
}
Serial.print(",");

// grab 2
if (button_state == 0) {
Serial.print(0);
} else {
Serial.print(1);
}
Serial.print(",");

// coin pusher 3
if ( dist < 6 )
{
Serial.println(1);
} else {
Serial.println(0);
}
digitalWrite(red,prize);
digitalWrite(yellow,prize);
digitalWrite(blue,prize);
}

}

}```

```import fisica.*;
import processing.serial.*;
import processing.sound.*;
Serial myPort;
PImage claw;
PImage[][] claws;
PImage bird;
PImage[][] birds;
PImage bg;

boolean start = false;
boolean grab = false;
boolean get = false;
boolean drop = false;
boolean ret = false;
boolean prize = false;
boolean coin = false;
boolean right = false;
boolean left = false;

float speed;
float posX=20, posY=10;
FCircle[] bodies;

ArrayList<FBody> touching = new ArrayList<FBody>();
FCircle tip;
FBody prev_touch;

FWorld world;
int toy_num = 30;

SoundFile grab_sound;
SoundFile drop_sound;
SoundFile prize_sound;
SoundFile start_sound;

void setup() {
size(750, 600);
printArray(Serial.list());
String portname=Serial.list()[1];
println(portname);
myPort = new Serial(this,portname,9600);
myPort.clear();
myPort.bufferUntil('\n');

//
bg.resize(750,600);
generate_claw();
Fisica.init(this);
world = new FWorld();
world.setEdges(0, 0, 750, 530, 255);
generate_birds();

tip = new FCircle(35);
tip.setFill(0);
tip.setStatic(true);
tip.setDrawable(false);

grab_sound = new SoundFile(this, "pick_up.wav");
drop_sound = new SoundFile(this, "drop.wav");
prize_sound = new SoundFile(this, "prize.wav");
start_sound = new SoundFile(this, "coin.wav");
}

void draw() {
//println(mouseX,mouseY);

background(bg);
world.step();
world.draw();

// box
fill(255, 200);
noStroke();
rect(603, 250, 200, 280);
strokeWeight(3);
stroke(0);
line(603, 250, 605, 530);

if (coin) {
start_sound.play();
coin = false;
}

if (start){
initialize_claw();
} else {
fill(#A09B10);
PFont f = createFont("Dialog-48", 40);
textFont(f);
text("SWIPE a coin to START", 145, 100);
fill(#671235);
text("SWIPE a coin to START", 140, 100);
}
}

void initialize_claw() {
if (posX >= width - 80) {
posX = width-80;
}

if (posX <= 20) {
posX = 20;
}

if (!grab) {
if (ret) {
if (posX > 20) {
image(claws[0][0], posX, 10);
posX -=3;
if (prize) {
fill(#901758);
text("CONGRATULATIONS!!!", 150, 100);
}
} else {
ret = false;
world.remove(prev_touch);
prize = false;
}
} else {
image(claws[0][0], posX, 10);
if (right) {
posX += speed;
}

if (left) {
posX -= speed;
}
}
} else {
if (posX >= 550 && !get) {
grab = false;
get = false;
ret = true;
} else {

claw_down();
if (posY<0) {
posY+=3;
}
if (!drop) {
FBody toy = world.getBody(posX+60, posY+80);
if (get && posY < 20) {
image(claws[6][0], posX, posY);
if (posX <= 598) {
posX += 3;
toy.setPosition(posX+60, posY+80);
} else {
drop = true;
drop_sound.play();
toy.setStatic(false);
grab = false;
get = false;
drop = false;
ret = true;
// prize
int ram = (int)random(100);
if (ram <= 1) {
prize = true;
prize_sound.play();
}

}
}
}
}
}

}

void claw_down() {
FBody touch;
tip.setPosition(posX+40, posY+90);
if (posY < 500 && posY > 0) {
touching = tip.getTouching();
if (get) {
image(claws[6][0], posX, posY);
posY -= 3;
if (touching.size()>0) {
touch = touching.get(0);
prev_touch = touch;

touch.setStatic(true);
touch.setPosition(posX+60, posY+80);
}
} else{
image(claws[7][0], posX, posY);
if (touching.size()>0) {
get = true;
grab_sound.play();
} else {
posY += 3;
if (posY >= 500) {
grab = false;
get = false;
ret = true;
}
}
}
}
}

void generate_claw() {
claws = new PImage[8][5];
int w = claw.width / 5;
int h = claw.height / 8;

for (int y=0; y < 8; y++) {
for (int x=0; x< 5; x++) {
claws[y][x] = claw.get(x*w, y*h, w, h);
claws[y][x].resize(100,120);
}
}
}

void generate_birds() {
bodies = new FCircle[30];

birds = new PImage[2][3];
int w1 = bird.width / 3;
int h1 = bird.height / 2;

for (int y=0; y < 2; y++) {
for (int x=0; x< 3; x++) {
birds[y][x] = bird.get(x*w1, y*h1, w1, h1);
birds[y][x].resize(85, 85);
}
}

for (int i=0; i<toy_num; i++) {
b.setPosition(random(100, 500), height/2);
b.setStroke(0);
b.setStrokeWeight(2);
int random_x = int(random(0,2));
int random_y = int(random(0,3));
b.attachImage(birds[random_x][random_y]);
bodies[i] = b;
}

FBox edge = new FBox(10, 300);
edge.setPosition(600, 400);
edge.setStatic(true);
}

void mousePressed() {
// if button pressed, reset
world.clear();
grab = false;
ret = false;
get = false;
drop = false;
start = false;

bg.resize(750,600);
generate_claw();
Fisica.init(this);
world = new FWorld();
world.setEdges(0, 0, 750, 530, 255);
generate_birds();

tip = new FCircle(35);
tip.setFill(0);
tip.setStatic(true);
tip.setDrawable(false);

initialize_claw();
}

void keyPressed() {
// joystick

//if (keyCode == ENTER) {
//  speed = 0;
//  grab = true;
//}
//else {
//  speed = 8;
//}
speed = 8;

if (keyCode == RIGHT) {
posX += speed;
}
if (keyCode == LEFT) {
posX -= speed;
}

}

void serialEvent(Serial myPort){
s=trim(s);
if (s!=null){
println(s);
int values[]=int(split(s,','));
if (values.length>=1){
if (values[3] == 1) {
coin = true;
start = true;
}

if (values[0] == 1 && start) {
left = false;
right = true;
} else {
right = false;
}

if (values[1] == 1 && start) {
right = false;
left = true;
} else {
left = false;
}

if (values[2] == 1 && start) {
grab = true;
}

}
}
myPort.write(int(prize)+"\n");

}```