Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 14

1

VIDEO GAME INSTRUCTION MANUAL

PRESENTED BY:
JULIAN FELIPE RIVERA SABOGAL

TO THE AREA OF INTERNATIONALIZATION:

NATIONAL UNIFIED CORPORATION OF HIGHER EDUCATION


SYSTEMS ENGINEERING
IBAGUE TOLIMA
APRIL- 2023
2

REALIZATION OF THE CONTROL FOR THE VIDEO GAME

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.

ARDUINO GAME CODE

const int button1=2;


const int button2=3;

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);
  }

  if(digitalRead(button1)==LOW && digitalRead(button2)==LOW){


    Serial.println("9");
    delay(20);
  }
}
6

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

HOW DO YOU LOSE THE GAME


The way in which you lose the game is when you do not catch the ball and not only
that, but also the coins that you already had earned are going down.

PAUSE BY PRESSING THE S KEY AND UNPAUSE BY PRESSING THE A KEY


7

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];

private int puntaje, contador;


private int puntajeMaximo;
private int vida;
private int vidaglobal=0;
private int tiempo, velocidad = 4, i ;
void setup(){
size(600,450);
MyPort=new Serial(this,"COM3",9600);
8

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

}
}

public void masPuntaje()


{
contador++;
if(contador == 10)
{
contador = 0;
// this.puntaje +=1;
}
fill(0);
textSize(30);
text(this.puntaje,200,70);
text(this.puntajeMaximo,340,70);
text(this.vida,460,70);
image(Cruz,400,40,50,40);
image(CajaMonedas,280,40,50,45);
if(tiempo == velocidad)
{
i++;
tiempo = 0;
if(i == 4)
{
i =0;
}

}
tiempo ++;
12

pushMatrix();
image(Moneda[i],150,40,50,45);
popMatrix();

public void setPuntaje(int puntaje)


{
this.puntaje = puntaje;
}

public int getPuntaje()


{
return this.puntaje;
}

public void SubirPuntaje()


{
//if(invencible == false)
//{
// sonido_impacto.trigger();
this.puntaje +=1;
}

public void setPuntajeMaximo()


{
13

if(this.puntaje > this.puntajeMaximo)


{
this.puntajeMaximo = this.puntaje;
}

// metodos para la vida

public void setVida(int vida)


{
this.vida = vida;
}

public int getVida()


{
return this.vida;
}

public void BajarVida()


{
this.vida -=20;
}

void keyPressed() {

final int k = keyCode;


if(k == 'S'){
14

text("Pausa",260,260);
noLoop();
}else if (k == 'A'){
loop();
}

You might also like