Browse Source

added fields and methods to player class

pull/1/head
17mgeffert 8 years ago
parent
commit
3abe3a3db0
1 changed files with 24 additions and 3 deletions
  1. +24
    -3
      src/tanks/Tanks.java

+ 24
- 3
src/tanks/Tanks.java View File

@ -23,7 +23,8 @@ public class Tanks
//fields
private JFrame frame;
private JPanel panel;
private int fheight=500;
private int fwidth=500;
private Timer move;
private KeyListener key;
@ -167,14 +168,17 @@ public class Tanks
height = 50;
}
void move()
void move()
{
if(up==true)
{
super.move(-1);
super.move(-1);
}
if(down==true)
{
super.move(1);
}
if(left==true)
@ -185,6 +189,23 @@ public class Tanks
{
super.direction+=5;
}
if(y<=0)
{
y+=speed;
}
else if(x<=0)
{
x+=speed;
}
else if(x>=fwidth-width)
{
x-=speed;
}
else if(y>=fheight-height)
{
y-=speed;
}
}
void updateDir(KeyEvent e, boolean pressed)
{

Loading…
Cancel
Save