Professional Documents
Culture Documents
Manual of The Video Game With The Control
Manual of The Video Game With The Control
PRESENTED BY:
JULIAN FELIPE RIVERA SABOGAL
MATERIALS:
• Arduino 1
• Buttons 2
• Small Breadboard 1
• Cables for connection 6
• Resistors 2
3
Step 1
2 wires are connected to the Arduino and to the breadboard. The 1st wire is put on
the Arduino at GND and connected to the breadboard on the negative line. The 2nd
wire is put on the Arduino at 5V and connected to the breadboard on the negative
line.
Step 2
2 cables are connected, the 1st in the Arduino in 2 and the breadboard in line i and
number 12, the 2nd in the Arduino in 3 and the breadboard in i number 19.
4
Step 3
The resistors are placed one line further on in the horizontal part and in the vertical part
they are placed on the same line. In my circuit it would be on line j and number 19, the
other would be on line j and number 12.
Step 4
2 more cables are connected, leaving a horizontal space on the left side of the cables and
resistors that are already placed, this is done on both sides and this is connected to the
negative of the protoboard. This means that the cables go in line i and in number 10 and
17.
5
step 5
And finally we put the buttons that are connected to the two cables in this way.
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
pinMode(button1,INPUT);
pinMode(button2,INPUT);
}
void loop() {
// put your main code here, to run repeatedly:
if(digitalRead(button1)==HIGH){
Serial.println("1");
delay(20);
}
if(digitalRead(button2)==HIGH){
Serial.println("2");
delay(20);
}
GAME OPERATION
The way in which it is played is mainly with the buttons that are, so to speak, our
buttons. The idea is not to drop the ball to the ground and move the bar with
buttons 1 and 2, the first goes to the left and 2 to the right, each time you catch the
ball with the bar it will increase the speed and adding points, and each time you lose
the maximum that exists will appear so that you can overcome the score
PROCESSING CODE
import processing.serial.*;//
Serial MyPort;
int x=100;
int y=100;
int vx =3;
int vy=3;
int RelativePositionX;
String val="";
float value;
int xb;
int pantalla =0;
int flagsound = 1;
PImage Cruz;
PImage CajaMonedas;
PImage [] Moneda = new PImage [4];
pantalla = 0;
Cruz = loadImage("Cruz.png");
Moneda[0] = loadImage("Moneda.png");
Moneda[1] = loadImage("Moneda2.png");
Moneda[2] = loadImage("Moneda3.png");
Moneda[3] = loadImage("Moneda4.png");
CajaMonedas = loadImage("CajaMonedas.png");
}
void draw(){
if (pantalla==0) {
if(MyPort.available()>0){
val=MyPort.readStringUntil('\n');
if (val==null){
return;
}
value=float(val);
}
if(value==1){ // Mover Lado Izquierdo
RelativePositionX-=10;
}
else if(value==2){ // Mover Lado Derecho
RelativePositionX+=10;
}
background(99,99,99);//
xb=200+RelativePositionX;
9
fill(51,102,102);
rect(xb,420,180,30); // Rectangulo
masPuntaje();
fill(51,204,255);
ellipse(x,y,40,40);
}
if (pantalla==1) {
background(12);
textSize(45);
text("Game Over",155,200);
setPuntajeMaximo();
setPuntaje(0);
setVida(100);
text("Puntaje maximo",110,280);
text(this.puntajeMaximo,485,280);
if (keyPressed == true) {
pantalla = 0;
flagsound = 1;
}
}
x+=vx;
if(x>580||x<20){
vx=vx*-1;
10
}
y+=vy;
if(y>height || y<0){
vy=vy*-1;
}
//Colision
if(y>=410&&(x<xb+180)&&(x>xb)){
vy=-(vy+2);
vx+=1;
setPuntaje(this.puntaje +=1);
}
if(y>=450){
x=100;
y=100;
vx=3;
vy=3;
BajarVida();
}
//Vida
if(vidaglobal == 0){
vidaglobal=1;
setVida(100);
}
if(getVida() == 0)
{
pantalla = 1;
11
}
}
}
tiempo ++;
12
pushMatrix();
image(Moneda[i],150,40,50,45);
popMatrix();
void keyPressed() {
text("Pausa",260,260);
noLoop();
}else if (k == 'A'){
loop();
}