This repository has been archived by the owner on Jul 25, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ShogiBoardOnMySelf.pde
98 lines (86 loc) · 2.08 KB
/
ShogiBoardOnMySelf.pde
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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
import java.awt.*;
import javax.swing.*;
final int FRAME = 20;
PImage bgImage;
Field field;
PieceTable pieceTableA;
PieceTable pieceTableB;
Formation form;
PlayerSet playerS;
Log log;
Menu menu;
void setup() {
size(1200, 800);
frameRate(FRAME);
bgImage = loadImage("img/bg.jpg");
field = new Field(500, 500);
form = new Formation(field);
pieceTableA = new PieceTable(200, true);
pieceTableB = new PieceTable(200, false);
playerS = new PlayerSet();
log = new Log();
menu = new Menu(width-50, 50, width - 300, 400, #dddddd);
}
void draw() {
if (menu.TurningSwitch.IO) {
if (!playerS.turn) {
translate(width, height);
scale(-1, -1);
}
}
imageMode(CENTER);
image(bgImage, width/2, height/2, width, height);
imageMode(CORNER);
field.showUp();
form.showUp();
pieceTableA.showUp();
pieceTableB.showUp();
playerS.showUp();
//MENU BUTTONS
//translate-resTurningSwitchmenu.TurningSwitchet
if (menu.TurningSwitch.IO) {
if (!playerS.turn) {
translate(width, height);
scale(-1, -1);
}
}
menu.showUp();
}
void mouseClicked() {
if (form.grabedPiece() != null) {
form.grabedPiece().move(field.getTroutOnMouse(), form.getPieceOnMouse());
} else if (pieceTableA.grabedPiece() != null) {
pieceTableA.putField(pieceTableA.grabedPiece(), field.getTroutOnMouse());
} else if (pieceTableB.grabedPiece() != null) {
pieceTableB.putField(pieceTableB.grabedPiece(), field.getTroutOnMouse());
} else {
form.grab();
pieceTableA.grab();
pieceTableB.grab();
}
menu.putButton();
}
void keyPressed () {
if (key == ' ') reset();
if (key == 'b') playerS.resign();
if (key == 'u') log.UNDO();
if (key == 'r') log.REDO();
}
void reset() {
boolean result = popUpJPanel("RESET?");
if (result){
playerS.reset();
field.reset();
form.reset();
pieceTableA.reset();
pieceTableB.reset();
log.reset();
}
}
//GAMEOVER
void gameOver() {
println("TURN: " + playerS.turn);
println("WINNER: " + playerS.getWinnerName());
fill(#000000);
text(playerS.getWinnerName(), width/2, height/2);
}