-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFourPlayerGUI.java
More file actions
84 lines (83 loc) · 2.71 KB
/
FourPlayerGUI.java
File metadata and controls
84 lines (83 loc) · 2.71 KB
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
72
73
74
75
76
77
78
79
80
81
82
83
84
import java.awt.event.KeyListener;
import java.awt.event.KeyEvent;
import java.awt.Graphics;
/**
* Write a description of class FourPlayerGUI here.
*
* @author (your name)
* @version (a version number or a date)
*/
public class FourPlayerGUI extends RatscrewGUI implements KeyListener
{
// instance variables - replace the example below with your own
private int x;
/**
* Constructor for objects of class FourPlayerGUI
*/
public FourPlayerGUI()
{
super(4);
panel = new FourPlayerPanel(this);
initDisplay();
panel.addKeyListener(this);
repaint();
}
public void repaint(){
super.repaint();
panel.getPlayerCards(0).setBounds(getWidth()/2 - CARD_WIDTH/2, getHeight() - (3*CARD_HEIGHT/2) - 40, CARD_WIDTH, CARD_HEIGHT);
panel.getPlayerData(0).setBounds(getWidth()/2 - CARD_WIDTH/2, getHeight() - (14*CARD_HEIGHT/6) - 20, CARD_WIDTH * 2, CARD_HEIGHT/3);
panel.getPlayerCards(1).setBounds(getWidth() - (3*CARD_WIDTH/2), getHeight()/2 - CARD_HEIGHT/2, CARD_WIDTH, CARD_HEIGHT);
panel.getPlayerData(1).setBounds(getWidth() - CARD_WIDTH*2, getHeight()/2 - (3*CARD_HEIGHT/4), CARD_WIDTH*2, CARD_HEIGHT/3);
panel.getPlayerCards(2).setBounds(getWidth()/2 - CARD_WIDTH/2, 20 + CARD_HEIGHT / 3, CARD_WIDTH, CARD_HEIGHT);
panel.getPlayerData(2).setBounds(getWidth()/2 - CARD_WIDTH/2, 20, CARD_WIDTH * 2, CARD_HEIGHT/3);
panel.getPlayerCards(3).setBounds(20, getHeight()/2 - CARD_HEIGHT/2, CARD_WIDTH, CARD_HEIGHT);
panel.getPlayerData(3).setBounds(20, getHeight()/2 - (3*CARD_HEIGHT/4), CARD_WIDTH*2, CARD_HEIGHT/3);
}
private class FourPlayerPanel extends CardPanel{
public FourPlayerPanel(RatscrewGUI frame){
super(frame);
}
}
public void keyPressed(KeyEvent e){
char key = e.getKeyChar();
if (key=='r'){
game.newGame();
repaint();
return;
}
switch (key){
case 'a':
draw(0);
break;
case 's':
claim(0);
break;
case 'd':
draw(1);
break;
case 'f':
claim(1);
break;
case 'g':
draw(2);
break;
case 'h':
claim(2);
break;
case 'j':
draw(3);
break;
case 'k':
claim(3);
break;
default:
signalError();
return;
}
repaint();
}
public void keyTyped(KeyEvent e){
}
public void keyReleased(KeyEvent e){
}
}