@Override
public void keyTyped(KeyEvent e) {
// TODO Auto-generated method stub
}
@Override
public void keyPressed(KeyEvent e) {
// TODO Auto-generated method stub
int keyCode = e.getKeyCode();
//后面会添加具体按键匹配
switch (keyCode) {
case KeyEvent.VK_SPACE:
break;
case KeyEvent.VK_A:
System.out.println("xxsx");
x -= 1;
break;
case KeyEvent.VK_D:
x += 1;
break;
case KeyEvent.VK_W:
y -= 1;
break;
case KeyEvent.VK_S:
y += 1;
break;
}
}
@Override
public void keyReleased(KeyEvent e) {
// TODO Auto-generated method stub
private void start() {
new Thread(new PaintThread()).start();
}
private class PaintThread implements Runnable {
public void run() {
while (true) {
repaint();
try {
Thread.sleep(50);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}
}
@Override
public void keyTyped(KeyEvent e) {
}
@Override
public void keyPressed(KeyEvent e) {
int keyCode = e.getKeyCode();
switch (keyCode) {
case KeyEvent.VK_SPACE:
break;
case KeyEvent.VK_A:
System.out.println("xxsx");
x -= 1;
break;
case KeyEvent.VK_D:
x += 1;
break;
case KeyEvent.VK_W:
y -= 1;
break;
case KeyEvent.VK_S:
y += 1;
break;
}
}
@Override
public void keyReleased(KeyEvent e) {
}
}
public class AirPlane implements IDrawable {
private int x;
private int y;
@Override
public void paint(Graphics g) {
g.setColor(Color.RED);
g.drawRect(x, y, 40, 30);
}
}
private void start() {
new Thread(new PaintThread()).start();
}
private class PaintThread implements Runnable {
public void run() {
while (true) {
repaint();
try {
Thread.sleep(50);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}
}
@Override
public void keyTyped(KeyEvent e) {
}
@Override
public void keyPressed(KeyEvent e) {
int keyCode = e.getKeyCode();
switch (keyCode) {
case KeyEvent.VK_SPACE:
break;
case KeyEvent.VK_A:
System.out.println("xxsx");
x -= 1;
break;
case KeyEvent.VK_D:
x += 1;
break;
case KeyEvent.VK_W:
y -= 1;
break;
case KeyEvent.VK_S:
y += 1;
break;
}
}
@Override
public void keyReleased(KeyEvent e) {
}
}
public class AirPlane implements IDrawable {
private int x;
private int y;
@Override
public void paint(Graphics g) {
g.setColor(Color.RED);
g.drawRect(x, y, 40, 30);
}
}
private void start() {
new Thread(new PaintThread()).start();
}
private class PaintThread implements Runnable {
public void run() {
while (true) {
repaint();
try {
Thread.sleep(50);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}
}
@Override
public void keyTyped(KeyEvent e) {
}
@Override
public void keyPressed(KeyEvent e) {
int keyCode = e.getKeyCode();
switch (keyCode) {
case KeyEvent.VK_SPACE:
break;
case KeyEvent.VK_A:
System.out.println("xxsx");
x -= 1;
break;
case KeyEvent.VK_D:
x += 1;
break;
case KeyEvent.VK_W:
y -= 1;
break;
case KeyEvent.VK_S:
y += 1;
break;
}
}
@Override
public void keyReleased(KeyEvent e) {
}
}
private void start() {
new Thread(new PaintThread()).start();
}
private class PaintThread implements Runnable {
public void run() {
while (true) {
repaint();
try {
Thread.sleep(50);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}
}
@Override
public void keyTyped(KeyEvent e) {
}
@Override
public void keyPressed(KeyEvent e) {
int keyCode = e.getKeyCode();
switch (keyCode) {
case KeyEvent.VK_SPACE:
break;
case KeyEvent.VK_A:
System.out.println("xxsx");
x -= 1;
break;
case KeyEvent.VK_D:
x += 1;
break;
case KeyEvent.VK_W:
y -= 1;
break;
case KeyEvent.VK_S:
y += 1;
break;
}
}
@Override
public void keyReleased(KeyEvent e) {
}
}
private void start() {
new Thread(new PaintThread()).start();
}
private class PaintThread implements Runnable {
public void run() {
while (true) {
repaint();
try {
Thread.sleep(50);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}
}
@Override
public void keyTyped(KeyEvent e) {
}
@Override
public void keyPressed(KeyEvent e) {
int keyCode = e.getKeyCode();
switch (keyCode) {
case KeyEvent.VK_SPACE:
break;
case KeyEvent.VK_A:
System.out.println("xxsx");
x -= 1;
break;
case KeyEvent.VK_D:
x += 1;
break;
case KeyEvent.VK_W:
y -= 1;
break;
case KeyEvent.VK_S:
y += 1;
break;
}
}
@Override
public void keyReleased(KeyEvent e) {
}
}
public class AirPlane implements IDrawable {
private int x;
private int y;
@Override
public void paint(Graphics g) {
g.setColor(Color.RED);
g.drawRect(x, y, 40, 30);
}
}
private void start() {
new Thread(new PaintThread()).start();
}
private class PaintThread implements Runnable {
public void run() {
while (true) {
repaint();
try {
Thread.sleep(50);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}
}
@Override
public void keyTyped(KeyEvent e) {
}
@Override
public void keyPressed(KeyEvent e) {
int keyCode = e.getKeyCode();
switch (keyCode) {
case KeyEvent.VK_SPACE:
break;
case KeyEvent.VK_A:
System.out.println("xxsx");
x -= 1;
break;
case KeyEvent.VK_D:
x += 1;
break;
case KeyEvent.VK_W:
y -= 1;
break;
case KeyEvent.VK_S:
y += 1;
break;
}
}
@Override
public void keyReleased(KeyEvent e) {
}
}
public class AirPlane implements IDrawable {
private int x;
private int y;
@Override
public void paint(Graphics g) {
g.setColor(Color.RED);
g.drawRect(x, y, 40, 30);
}
}