-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLeftAction.java
More file actions
40 lines (37 loc) · 845 Bytes
/
LeftAction.java
File metadata and controls
40 lines (37 loc) · 845 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
import java.awt.event.ActionEvent;
import javax.swing.AbstractAction;
/*
* sets action of left user
* the "w" and the "s"
* the LEFT_UP and LEFT_DOWN
*/
public class LeftAction extends AbstractAction
{
Direction dir;
boolean pressed;
public LeftAction(Direction dir, boolean pressed)
{
this.dir = dir;
this.pressed = pressed;
}
/*
* (non-Javadoc)
* @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
* checks the user interaction with the program
* and makes the object "react" to the user interaction
* up goes up and down goes down
*
*/
@Override
public void actionPerformed(ActionEvent arg0)
{
if (pressed)
{
Model.keys.add(dir);
}
else
{
Model.keys.remove(dir);
}
}
}