Skip to content

Commit

Permalink
Cerrar programa
Browse files Browse the repository at this point in the history
  • Loading branch information
javierfh03 committed Jan 16, 2023
1 parent e096ef8 commit b8a20e1
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion src/pong/ui/EventoTeclado.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
*/
public class EventoTeclado extends KeyAdapter {

public static boolean w, s, up, down;
public static boolean w, s, up, down, esc;
private Pista panel;

public EventoTeclado(Pista panel) {
Expand All @@ -25,15 +25,23 @@ public void keyPressed(KeyEvent e) {
if (id == KeyEvent.VK_W) {
w = true;
}

if (id == KeyEvent.VK_S) {
s = true;
}

if (id == KeyEvent.VK_UP) {
up = true;
}

if (id == KeyEvent.VK_DOWN) {
down = true;
}

if (id == KeyEvent.VK_ESCAPE){
System.exit(0);
}

panel.repaint();
}

Expand All @@ -44,15 +52,19 @@ public void keyReleased(KeyEvent e) {
if (id == KeyEvent.VK_W) {
w = false;
}

if (id == KeyEvent.VK_S) {
s = false;
}

if (id == KeyEvent.VK_UP) {
up = false;
}

if (id == KeyEvent.VK_DOWN) {
down = false;
}

panel.repaint();
}
}

0 comments on commit b8a20e1

Please sign in to comment.