-
Notifications
You must be signed in to change notification settings - Fork 1
/
Input.java
71 lines (52 loc) · 1.67 KB
/
Input.java
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
import javax.imageio.ImageIO;
import java.io.File;
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import java.awt.image.BufferStrategy;
import java.awt.image.BufferedImage;
import java.awt.Graphics2D;
public abstract class Input implements MouseListener,MouseMotionListener,Updatable, Renderable{
protected Window w;
protected int posXmouse = 0;
protected int posYmouse = 0;
protected Cursor cursor;
public Input(Window w){
this.w = w;
cursor = Cursor.getPredefinedCursor(Cursor.HAND_CURSOR);
}
public Cursor getCursor(){
return cursor;
}
public static void loadAssets(){}
public abstract void update();
public abstract void draw(Graphics2D g);
public abstract void mouseClicked(MouseEvent e);
public boolean resetMapPressed(World world, int posXclic, int posYclic){
if (posXclic >=world.getWidth()-40 && posXclic <=world.getWidth()-10 && posYclic>=world.getHeight()+60 && posYclic<=world.getHeight()+90){
w.resetMap();
return true;
}
return false;
}
public abstract void updateButtons();
public void mouseMoved(MouseEvent e) {
//a chaque mouvement retourne un event
posXmouse = e.getX();
posYmouse = e.getY();
updateButtons();
}
public void mousePressed(MouseEvent e) {
//Invoked when a mouse button has been pressed on a component.
}
public void mouseReleased(MouseEvent e) {
//Invoked when a mouse button has been released on a component.
}
public void mouseEntered(MouseEvent e) {
//Invoked when the mouse enters a component.
}
public void mouseExited(MouseEvent e) {
//Invoked when the mouse exits a component.
}
public void mouseDragged(MouseEvent e) {}
}