<p>

</p>

Produino

Have you ever played a game where your very life begins to blur and you feel as if time and space does not exist? This is what we have encapsulated in the revolutionary game of ARDSHOT. By combining the power of Arduino and Processing we have developed a mind altering experience similar to that of Space Invaders. By moving the tactile joystick along the X-axis you focus a Ball towards one other ball in unfamiliar space. Adjacent to the joystick a smooth, glossy red button awaits your touch. A slight press ejects a line out of your ball towards the other. If your skills persist and the stars align you will see the line collide with a sphere, and in that very moment, the spheres will multiply connected by a curve of complex mathematical precision, the Bézier. As your pulse skyrockets you begin to realize you have one minute to multiply the balls in space, focusing your shot and striving towards a complex result of multiple moving balls and curves. Warning, you may become lost in the constant loop of ARDSHOT as the black button pauses and resets the game.

Ardshot is inspired by some of the first arcade games in the 1970’s that influenced an entire generation. Our intention is to replicate the nativity and innocence embodied by these games. Thus, opening the portal to the virtual world we know today with conventions of analog, digital, design, and functional intelligence permeating our understanding of space and time.

 ———————————————————————————————————————————————————————

ARDSHOT 
import processing.serial.*;
Serial myPort; // Create object from Serial class
String valx,valy,buttonsval; 
int playerx,playery,buttons;
int count=0;
int score=0,finalscore=0;
int i=0;
int a=0, seconds=60;
int speed=4;
int cantidad=0;
int bulletcount=0;
boolean play=false;
Circle[] objectives;
Bullets[] bullet;
StopWatchTimer sw = new StopWatchTimer();
void setup(){
//size(600,600);
fullScreen();
objectives=new Circle[500];
objectives[0]= new Circle();
String portName = Serial.list()[0];
 myPort = new Serial(this, portName, 9600);
 bullet= new Bullets[100];
 textSize(32);
 textAlign(CENTER);
 background(255);
}
void draw(){
 //background(255);
 //textSize(32);
 //println(sw.second());
 if(seconds==0){
 background(255);
 text("Game Over", width/2, height/4);
 text("0",width-100,60);
 text(" : ",width-80,58);
 text("0",width-50,60);
 text("Score: ", 55, 60);
 text(finalscore, 120,60);
 for(int f=0;f<=count;f++){
 objectives[f].target=true;
 }
 play=false;
 sw.stop();
 seconds=60;
 score=0;
 finalscore=0;
 count=0;
 cantidad=0;
 bulletcount=0; 
 
 }
 if(play==true){
 finalscore=score;
 background(255);
 text("0",width-100,60);
 text(" : ",width-80,58);
 text(seconds,width-50,60);
 text("Score: ", 55, 60);
 text(score, 120,60);
 fill(255,0,0);
 ellipse(playerx,playery,20,20); //Draw the player in its coordinates
 noFill();
 seconds=60-sw.second();
 for(int z=0;z<bulletcount;z++){
 if(bullet[z].bullety<=-10){
 continue;
 }
 bullet[z].display();
 bullet[z].move();
 count=cantidad;
 for(int f=0;f<=count;f++){
 //println(z);
 //println(f);
 if(objectives[f].target==true && bullet[z].bullety-objectives[f].ypos<=10 && bullet[z].bulletx-objectives[f].xpos<=10 && bullet[z].bulletx-objectives[f].xpos>=-10){
 background(255);
 cantidad++;
 bullet[z].bullety=-20;
 objectives[cantidad]=new Circle();
 objectives[cantidad+1]=new Circle();
 cantidad++;
 score++;
 
 objectives[f].target=false;
 
 }
 }
 }


for(int b=cantidad;b>=0;b--){
 
 for(int c=b;c>=0;c--){
 
 objectives[c].move();
 //line(objectives[c].xpos,objectives[c].ypos,objectives[b].xpos,objectives[b].ypos);
 noFill();
 bezier(objectives[c].xpos,objectives[c].ypos,objectives[c].xpos,objectives[b].ypos, objectives[b].xpos,objectives[c].ypos, objectives[b].xpos,objectives[b].ypos);
 }}
 for(a=0;a<=cantidad;a++){
 
 objectives[a].display();
 objectives[a].display();
}
 } else{
 textAlign(CENTER);
 fill(255,0,0);
 text("Press start to continue",(width/2),height/2);
 noFill();
 }
if ( myPort.available() > 0) 
 { // If data from arduino is available
 valx = myPort.readStringUntil('y'); 
 valy = myPort.readStringUntil('y');
 buttonsval=myPort.readStringUntil('y');
 
 if(valx!=null && valy!=null&&buttonsval!=null){
 
 valx=valx.substring(0,valx.length()-1);
 valy=valy.substring(0,valy.length()-1);
 buttonsval=buttonsval.substring(0,buttonsval.length()-1);
 
 playery=int(map(parseInt(valy),0,1024,(height*3/4),height));
 playerx=int(map(parseInt(valx),0,1024,0,width));
 buttons=parseInt(buttonsval);
 
 if(buttons==10){
 bullet[bulletcount]=new Bullets(playerx,playery);
 bulletcount++;
 if(bulletcount==100){
 bulletcount=0;
 }
 } else if(buttons==01){
 play= !play;
 if(play==true){
 sw.start();
 }else{sw.stop();}
 
 //println(play);
 }

}

} 

 ---------------------------------------------------------------------------------------------------------------------------------------------------------------------
BULLET 

class Bullets{
float bulletx,bullety,bulletwidth,bulletheight;

Bullets(int x, int y){
bulletwidth=3;
bulletheight=20;
bulletx=x;
bullety=y;
}
void display(){
fill(255,0,0);
rectMode(CENTER);

rect(bulletx,bullety,bulletwidth,bulletheight);
}
void move(){
bullety-=10;
}
}

---------------------------------------------------------------------------------------------------------------------------------------------------------------------
CIRCLE 

class Circle{
float xpos,ypos,radius;
float speed;
int direction;
float pct,step;
 float lastx,lasty,nextx,nexty;
 boolean target;
Circle(/*float speedTemp*/){
radius=10;
//speed=speedTemp;
xpos=int(random(width));
ypos=int(random(height)/2);
direction=int(random(0,7));
pct=0;
step=0;
lastx=xpos;
lasty=ypos;
nextx=random(xpos-20,xpos+20);
nexty=random(ypos-20,ypos+20);
target=true;
}
void display(){
fill(10,90,80);
ellipse(xpos,ypos,radius,radius);
}
void move(){

 
 step+=0.01;
 if(step>1){
 lastx=xpos;
 lasty=ypos;
 nextx=random(xpos-200, xpos+200);
 nexty=random(ypos-100, ypos+100);
 step=0;
 }
 xpos=bezierPoint(lastx,nextx,lastx,nextx,step);
 ypos=bezierPoint(lasty,nexty,lasty,nexty,step);
 xpos=constrain(xpos,10,width-10);
 ypos=constrain(ypos,10,(height*3/4));
 //speed=0.6;
 
// pct += 0.1;
/* if (pct < 1.0) {
 xpos = xpos + (pct * xpos-int(random(10,width-10)));
 ypos = ypos + (pow(pct, 4) * ypos-int(random(10,height/2)));
 }*/

/*xpos=noise(pct)*width;
ypos=noise(speed)*(height/2);*/

/*
xpos=xpos+int(speed*(random(-2,2)));
xpos=constrain(xpos,10,width-10);
ypos=ypos+int(speed*(random(-2,2)));
ypos=constrain(ypos,10,height/2);*/


}

---------------------------------------------------------------------------------------------------------------------------------------------------------------------
TIMER

class StopWatchTimer {
 int startTime, stopTime,timedif;
 boolean running;
 StopWatchTimer(){
 startTime = 0;
 stopTime = 0;
 timedif=0;
 running = false; 
 }
 void start() {
 startTime = millis(); 
 running = true;
 
 }
 void stop() {
 stopTime = millis();
 running = false;
 
 }
 int getElapsedTime() {
 int elapsed;
 if(running){
 elapsed=timedif+millis()-startTime;
 }else{
 timedif=stopTime-startTime;
 elapsed=timedif;
 }
 return elapsed;
 }
 int second() {
 return (((getElapsedTime() / 1000) %61));
 
 }

---------------------------------------------------------------------------------------------------------------------------------------------------------------------

ARDUINO 
#define Xpot A0
#define Ypot A1
#define Start 2
#define shoot 3
int xval,yval;
boolean fire, start,firetemp,starttemp;
boolean lastfire=false;
boolean laststart=false;
void setup() {
Serial.begin(9600);
}

void loop() {
 firetemp=!digitalRead(shoot);
 if(lastfire==true&&firetemp==true){
 fire=false;
 }else if (lastfire==false && firetemp==true){
 fire=true;
 lastfire=fire;
 }else{
 fire=false;
 lastfire=false;
 }
 starttemp=!digitalRead(Start);
 if(laststart==true&&starttemp==true){
 start=false;
 }else if (laststart==false && starttemp==true){
 start=true;
 laststart=start;
 }else{
 start=false;
 laststart=false;
 }
 xval=analogRead(Xpot);
 yval=1024-analogRead(Ypot);
 Serial.print(xval);
 Serial.print("y");
 Serial.print(yval);
 Serial.print("y");
 Serial.print(fire);
 Serial.print(start);
 Serial.print("y");
 /*Serial.print(fire);
 Serial.println(start);*/
 delay(100);
}

---------------------------------------------------------------------------------------------------------------------------------------------------------------------

This exercice is part of the first assignment for the Produino design studio.

Studio SO.4 faculty : Angelos ?Chronis, Angel ?Muñoz

Ardshot is a project of IaaC, Institute for Advanced Architecture of Catalonia

developed at MAA01 in 2017-2018 by:

Student: Elliott Santos, Alberto Holguin, Tim Magara