annotate game/Engine.java @ 35:aa15b2c556b4

Add comments.
author Matti Hamalainen <ccr@tnsp.org>
date Thu, 17 Feb 2011 03:40:01 +0200
parents e480579cc460
children 3dc5ae9f1c80
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
f930f72ed0f5 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
1 /*
9
a7751971c2a3 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 8
diff changeset
2 * Ristipolku Game Engine
0
f930f72ed0f5 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
3 * (C) Copyright 2011 Matti 'ccr' Hämäläinen <ccr@tnsp.org>
f930f72ed0f5 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
4 */
9
a7751971c2a3 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 8
diff changeset
5 package game;
a7751971c2a3 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 8
diff changeset
6
0
f930f72ed0f5 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
7 import java.awt.*;
f930f72ed0f5 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
8 import java.awt.geom.*;
1
44f1e7b47fcf Preliminary work ... puuh.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
9 import java.awt.event.*;
7
70714c229e23 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 6
diff changeset
10 import java.awt.image.*;
70714c229e23 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 6
diff changeset
11 import java.awt.event.*;
25
bbac3e4a4b9b Cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 24
diff changeset
12 import java.awt.font.*;
9
a7751971c2a3 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 8
diff changeset
13 import javax.imageio.*;
7
70714c229e23 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 6
diff changeset
14 import javax.swing.*;
1
44f1e7b47fcf Preliminary work ... puuh.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
15 import java.util.*;
6
be0bf7544069 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 4
diff changeset
16 import java.io.*;
1
44f1e7b47fcf Preliminary work ... puuh.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
17 import game.*;
44f1e7b47fcf Preliminary work ... puuh.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
18
21
df494a65bf8c More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 18
diff changeset
19
1
44f1e7b47fcf Preliminary work ... puuh.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
20 class PathInfo
44f1e7b47fcf Preliminary work ... puuh.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
21 {
2
1785f66a7beb Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
22 public int in, inX, inY, out, outX, outY;
1
44f1e7b47fcf Preliminary work ... puuh.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
23
2
1785f66a7beb Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
24 public PathInfo(int in, int inX, int inY, int out, int outX, int outY)
1785f66a7beb Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
25 {
1785f66a7beb Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
26 this.in = in;
1785f66a7beb Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
27 this.inX = inX;
1785f66a7beb Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
28 this.inY = inY;
1785f66a7beb Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
29
1785f66a7beb Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
30 this.out = out;
1785f66a7beb Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
31 this.outX = outX;
1785f66a7beb Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
32 this.outY = outY;
1785f66a7beb Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
33 }
27
26adc2827983 More work on the internals.
Matti Hamalainen <ccr@tnsp.org>
parents: 26
diff changeset
34
26adc2827983 More work on the internals.
Matti Hamalainen <ccr@tnsp.org>
parents: 26
diff changeset
35 public void print()
26adc2827983 More work on the internals.
Matti Hamalainen <ccr@tnsp.org>
parents: 26
diff changeset
36 {
26adc2827983 More work on the internals.
Matti Hamalainen <ccr@tnsp.org>
parents: 26
diff changeset
37 System.out.print("PathInfo: inP="+in+", inX="+inX+", inY="+inY+"\n");
26adc2827983 More work on the internals.
Matti Hamalainen <ccr@tnsp.org>
parents: 26
diff changeset
38 System.out.print(" outP="+out+", outX="+outX+", outY="+outY+"\n");
26adc2827983 More work on the internals.
Matti Hamalainen <ccr@tnsp.org>
parents: 26
diff changeset
39 }
1
44f1e7b47fcf Preliminary work ... puuh.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
40 }
0
f930f72ed0f5 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
41
8
d8e7fd8f3ccf Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 7
diff changeset
42 /*
d8e7fd8f3ccf Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 7
diff changeset
43 class AnimatedElement
d8e7fd8f3ccf Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 7
diff changeset
44 {
d8e7fd8f3ccf Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 7
diff changeset
45 float x, y, stime, value;
d8e7fd8f3ccf Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 7
diff changeset
46 Interpolate lerp;
d8e7fd8f3ccf Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 7
diff changeset
47 boolean active;
d8e7fd8f3ccf Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 7
diff changeset
48
d8e7fd8f3ccf Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 7
diff changeset
49 public AnimatedElement(float x, float y, )
d8e7fd8f3ccf Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 7
diff changeset
50 {
d8e7fd8f3ccf Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 7
diff changeset
51 stime = 0;
d8e7fd8f3ccf Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 7
diff changeset
52 this.x = x;
d8e7fd8f3ccf Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 7
diff changeset
53 this.y = y;
d8e7fd8f3ccf Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 7
diff changeset
54
d8e7fd8f3ccf Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 7
diff changeset
55 }
d8e7fd8f3ccf Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 7
diff changeset
56
d8e7fd8f3ccf Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 7
diff changeset
57 public animate(float time)
d8e7fd8f3ccf Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 7
diff changeset
58 {
d8e7fd8f3ccf Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 7
diff changeset
59 if (!active)
d8e7fd8f3ccf Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 7
diff changeset
60 {
d8e7fd8f3ccf Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 7
diff changeset
61 active = true;
d8e7fd8f3ccf Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 7
diff changeset
62 stime = time;
d8e7fd8f3ccf Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 7
diff changeset
63 }
d8e7fd8f3ccf Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 7
diff changeset
64
d8e7fd8f3ccf Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 7
diff changeset
65 float t = (time - stime) / 10.0f;
d8e7fd8f3ccf Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 7
diff changeset
66 if (t < 100)
d8e7fd8f3ccf Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 7
diff changeset
67 value = lerp.getValue(t);
d8e7fd8f3ccf Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 7
diff changeset
68 else
d8e7fd8f3ccf Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 7
diff changeset
69 {
d8e7fd8f3ccf Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 7
diff changeset
70
d8e7fd8f3ccf Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 7
diff changeset
71 }
d8e7fd8f3ccf Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 7
diff changeset
72 }
d8e7fd8f3ccf Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 7
diff changeset
73
d8e7fd8f3ccf Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 7
diff changeset
74 public paint(Graphics2D g, );
d8e7fd8f3ccf Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 7
diff changeset
75 {
d8e7fd8f3ccf Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 7
diff changeset
76 }
d8e7fd8f3ccf Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 7
diff changeset
77 }
d8e7fd8f3ccf Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 7
diff changeset
78 */
0
f930f72ed0f5 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
79
30
60a4579a79df Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 27
diff changeset
80 class IDMWidget
60a4579a79df Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 27
diff changeset
81 {
60a4579a79df Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 27
diff changeset
82 public IDMWidget()
60a4579a79df Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 27
diff changeset
83 {
60a4579a79df Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 27
diff changeset
84 }
60a4579a79df Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 27
diff changeset
85
60a4579a79df Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 27
diff changeset
86 public void paint(Graphics2D g)
60a4579a79df Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 27
diff changeset
87 {
60a4579a79df Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 27
diff changeset
88 }
60a4579a79df Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 27
diff changeset
89
60a4579a79df Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 27
diff changeset
90 public boolean hit(float x, float y)
60a4579a79df Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 27
diff changeset
91 {
60a4579a79df Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 27
diff changeset
92 return false;
60a4579a79df Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 27
diff changeset
93 }
60a4579a79df Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 27
diff changeset
94 }
60a4579a79df Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 27
diff changeset
95
60a4579a79df Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 27
diff changeset
96 class IDMButton
60a4579a79df Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 27
diff changeset
97 {
32
e480579cc460 More work on debugging the path resolving.
Matti Hamalainen <ccr@tnsp.org>
parents: 30
diff changeset
98 BufferedImage imgUp, imgPressed;
e480579cc460 More work on debugging the path resolving.
Matti Hamalainen <ccr@tnsp.org>
parents: 30
diff changeset
99
30
60a4579a79df Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 27
diff changeset
100 public IDMButton(float x, float y, String text)
60a4579a79df Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 27
diff changeset
101 {
60a4579a79df Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 27
diff changeset
102 }
60a4579a79df Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 27
diff changeset
103
60a4579a79df Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 27
diff changeset
104 public void paint(Graphics2D g)
60a4579a79df Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 27
diff changeset
105 {
60a4579a79df Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 27
diff changeset
106 }
60a4579a79df Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 27
diff changeset
107
60a4579a79df Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 27
diff changeset
108 public boolean hit(float x, float y)
60a4579a79df Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 27
diff changeset
109 {
60a4579a79df Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 27
diff changeset
110 return false;
60a4579a79df Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 27
diff changeset
111 }
60a4579a79df Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 27
diff changeset
112 }
60a4579a79df Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 27
diff changeset
113
1
44f1e7b47fcf Preliminary work ... puuh.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
114 class GameBoard
0
f930f72ed0f5 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
115 {
2
1785f66a7beb Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
116 public static final int boardSize = 9;
1785f66a7beb Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
117 public static final int boardMiddle = 4;
1785f66a7beb Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
118 Piece[][] board;
1785f66a7beb Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
119 Piece current;
8
d8e7fd8f3ccf Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 7
diff changeset
120 public boolean flagGameOver;
7
70714c229e23 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 6
diff changeset
121
70714c229e23 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 6
diff changeset
122 int moveX, moveY, movePoint;
9
a7751971c2a3 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 8
diff changeset
123
2
1785f66a7beb Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
124 public GameBoard()
1785f66a7beb Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
125 {
1785f66a7beb Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
126 board = new Piece[boardSize][boardSize];
1785f66a7beb Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
127
1785f66a7beb Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
128 board[boardMiddle][boardMiddle] = new Piece(PieceType.START);
1785f66a7beb Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
129
1785f66a7beb Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
130 moveX = boardMiddle;
1785f66a7beb Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
131 moveY = boardMiddle - 1;
30
60a4579a79df Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 27
diff changeset
132 movePoint = 5;
8
d8e7fd8f3ccf Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 7
diff changeset
133
9
a7751971c2a3 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 8
diff changeset
134 pieceFinishTurn();
8
d8e7fd8f3ccf Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 7
diff changeset
135
d8e7fd8f3ccf Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 7
diff changeset
136 flagGameOver = false;
2
1785f66a7beb Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
137 }
0
f930f72ed0f5 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
138
7
70714c229e23 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 6
diff changeset
139 public void paint(Graphics2D g, int sx, int sy, float scale)
2
1785f66a7beb Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
140 {
1785f66a7beb Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
141 for (int y = 0; y < boardSize; y++)
1785f66a7beb Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
142 for (int x = 0; x < boardSize; x++)
1785f66a7beb Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
143 if (board[x][y] != null)
1785f66a7beb Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
144 {
6
be0bf7544069 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 4
diff changeset
145 AffineTransform save = g.getTransform();
be0bf7544069 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 4
diff changeset
146
4
e0e8fd08331e Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
147 board[x][y].paint(g,
e0e8fd08331e Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
148 sx + (x * scale),
e0e8fd08331e Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
149 sy + (y * scale),
e0e8fd08331e Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
150 scale - scale / 10);
6
be0bf7544069 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 4
diff changeset
151
be0bf7544069 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 4
diff changeset
152 g.setTransform(save);
2
1785f66a7beb Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
153 }
1785f66a7beb Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
154 }
9
a7751971c2a3 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 8
diff changeset
155
a7751971c2a3 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 8
diff changeset
156 public void animate(float time)
a7751971c2a3 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 8
diff changeset
157 {
a7751971c2a3 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 8
diff changeset
158 for (int y = 0; y < boardSize; y++)
a7751971c2a3 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 8
diff changeset
159 for (int x = 0; x < boardSize; x++)
a7751971c2a3 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 8
diff changeset
160 if (board[x][y] != null)
a7751971c2a3 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 8
diff changeset
161 {
a7751971c2a3 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 8
diff changeset
162 board[x][y].animate(time);
a7751971c2a3 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 8
diff changeset
163 }
10
4bacc98973f5 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 9
diff changeset
164
9
a7751971c2a3 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 8
diff changeset
165 }
1
44f1e7b47fcf Preliminary work ... puuh.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
166
2
1785f66a7beb Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
167 private boolean isEmpty(int x, int y)
1785f66a7beb Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
168 {
1785f66a7beb Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
169 return (x >= 0 && x < boardSize && y >= 0 && y < boardSize && board[x][y] == null);
1785f66a7beb Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
170 }
1
44f1e7b47fcf Preliminary work ... puuh.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
171
32
e480579cc460 More work on debugging the path resolving.
Matti Hamalainen <ccr@tnsp.org>
parents: 30
diff changeset
172 public void pieceRotate(Piece.RotateDir dir)
2
1785f66a7beb Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
173 {
9
a7751971c2a3 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 8
diff changeset
174 if (current != null)
a7751971c2a3 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 8
diff changeset
175 current.rotate(dir);
2
1785f66a7beb Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
176 }
1
44f1e7b47fcf Preliminary work ... puuh.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
177
8
d8e7fd8f3ccf Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 7
diff changeset
178 public PathInfo resolvePath(int startX, int startY, int startPoint, boolean mark)
7
70714c229e23 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 6
diff changeset
179 {
70714c229e23 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 6
diff changeset
180 int x = startX, y = startY;
27
26adc2827983 More work on the internals.
Matti Hamalainen <ccr@tnsp.org>
parents: 26
diff changeset
181 int point = startPoint;
26adc2827983 More work on the internals.
Matti Hamalainen <ccr@tnsp.org>
parents: 26
diff changeset
182 Piece curr = board[x][y];
9
a7751971c2a3 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 8
diff changeset
183
27
26adc2827983 More work on the internals.
Matti Hamalainen <ccr@tnsp.org>
parents: 26
diff changeset
184 do
7
70714c229e23 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 6
diff changeset
185 {
27
26adc2827983 More work on the internals.
Matti Hamalainen <ccr@tnsp.org>
parents: 26
diff changeset
186 if (x >= 0 && x < boardSize && y >= 0 && y < boardSize)
26adc2827983 More work on the internals.
Matti Hamalainen <ccr@tnsp.org>
parents: 26
diff changeset
187 {
26adc2827983 More work on the internals.
Matti Hamalainen <ccr@tnsp.org>
parents: 26
diff changeset
188 curr = board[x][y];
26adc2827983 More work on the internals.
Matti Hamalainen <ccr@tnsp.org>
parents: 26
diff changeset
189 if (curr == null)
26adc2827983 More work on the internals.
Matti Hamalainen <ccr@tnsp.org>
parents: 26
diff changeset
190 break;
26adc2827983 More work on the internals.
Matti Hamalainen <ccr@tnsp.org>
parents: 26
diff changeset
191
26adc2827983 More work on the internals.
Matti Hamalainen <ccr@tnsp.org>
parents: 26
diff changeset
192 if (curr.getType() == PieceType.START)
26adc2827983 More work on the internals.
Matti Hamalainen <ccr@tnsp.org>
parents: 26
diff changeset
193 {
26adc2827983 More work on the internals.
Matti Hamalainen <ccr@tnsp.org>
parents: 26
diff changeset
194 // Hit center starting piece
26adc2827983 More work on the internals.
Matti Hamalainen <ccr@tnsp.org>
parents: 26
diff changeset
195 return null;
26adc2827983 More work on the internals.
Matti Hamalainen <ccr@tnsp.org>
parents: 26
diff changeset
196 }
26adc2827983 More work on the internals.
Matti Hamalainen <ccr@tnsp.org>
parents: 26
diff changeset
197 else
26adc2827983 More work on the internals.
Matti Hamalainen <ccr@tnsp.org>
parents: 26
diff changeset
198 {
26adc2827983 More work on the internals.
Matti Hamalainen <ccr@tnsp.org>
parents: 26
diff changeset
199 // Mark, if needed
26adc2827983 More work on the internals.
Matti Hamalainen <ccr@tnsp.org>
parents: 26
diff changeset
200 if (mark)
26adc2827983 More work on the internals.
Matti Hamalainen <ccr@tnsp.org>
parents: 26
diff changeset
201 {
26adc2827983 More work on the internals.
Matti Hamalainen <ccr@tnsp.org>
parents: 26
diff changeset
202 curr.setType(PieceType.LOCKED);
26adc2827983 More work on the internals.
Matti Hamalainen <ccr@tnsp.org>
parents: 26
diff changeset
203 curr.setActiveConnection(point);
26adc2827983 More work on the internals.
Matti Hamalainen <ccr@tnsp.org>
parents: 26
diff changeset
204 }
26adc2827983 More work on the internals.
Matti Hamalainen <ccr@tnsp.org>
parents: 26
diff changeset
205
26adc2827983 More work on the internals.
Matti Hamalainen <ccr@tnsp.org>
parents: 26
diff changeset
206 // Get next piece
26adc2827983 More work on the internals.
Matti Hamalainen <ccr@tnsp.org>
parents: 26
diff changeset
207 point = curr.getConnection(point);
26adc2827983 More work on the internals.
Matti Hamalainen <ccr@tnsp.org>
parents: 26
diff changeset
208 switch (point)
26adc2827983 More work on the internals.
Matti Hamalainen <ccr@tnsp.org>
parents: 26
diff changeset
209 {
26adc2827983 More work on the internals.
Matti Hamalainen <ccr@tnsp.org>
parents: 26
diff changeset
210 case 0: y--; break;
26adc2827983 More work on the internals.
Matti Hamalainen <ccr@tnsp.org>
parents: 26
diff changeset
211 case 1: y--; break;
26adc2827983 More work on the internals.
Matti Hamalainen <ccr@tnsp.org>
parents: 26
diff changeset
212 case 2: x++; break;
26adc2827983 More work on the internals.
Matti Hamalainen <ccr@tnsp.org>
parents: 26
diff changeset
213 case 3: x++; break;
26adc2827983 More work on the internals.
Matti Hamalainen <ccr@tnsp.org>
parents: 26
diff changeset
214 case 4: y++; break;
26adc2827983 More work on the internals.
Matti Hamalainen <ccr@tnsp.org>
parents: 26
diff changeset
215 case 5: y++; break;
26adc2827983 More work on the internals.
Matti Hamalainen <ccr@tnsp.org>
parents: 26
diff changeset
216 case 6: x--; break;
26adc2827983 More work on the internals.
Matti Hamalainen <ccr@tnsp.org>
parents: 26
diff changeset
217 case 7: x--; break;
26adc2827983 More work on the internals.
Matti Hamalainen <ccr@tnsp.org>
parents: 26
diff changeset
218 }
26adc2827983 More work on the internals.
Matti Hamalainen <ccr@tnsp.org>
parents: 26
diff changeset
219 }
26adc2827983 More work on the internals.
Matti Hamalainen <ccr@tnsp.org>
parents: 26
diff changeset
220 }
26adc2827983 More work on the internals.
Matti Hamalainen <ccr@tnsp.org>
parents: 26
diff changeset
221 else
26adc2827983 More work on the internals.
Matti Hamalainen <ccr@tnsp.org>
parents: 26
diff changeset
222 {
26adc2827983 More work on the internals.
Matti Hamalainen <ccr@tnsp.org>
parents: 26
diff changeset
223 // Outside of the board
26adc2827983 More work on the internals.
Matti Hamalainen <ccr@tnsp.org>
parents: 26
diff changeset
224 return null;
26adc2827983 More work on the internals.
Matti Hamalainen <ccr@tnsp.org>
parents: 26
diff changeset
225 }
7
70714c229e23 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 6
diff changeset
226 }
27
26adc2827983 More work on the internals.
Matti Hamalainen <ccr@tnsp.org>
parents: 26
diff changeset
227 while (curr != null);
26adc2827983 More work on the internals.
Matti Hamalainen <ccr@tnsp.org>
parents: 26
diff changeset
228
7
70714c229e23 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 6
diff changeset
229 return new PathInfo(startPoint, startX, startY, point, x, y);
70714c229e23 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 6
diff changeset
230 }
70714c229e23 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 6
diff changeset
231
2
1785f66a7beb Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
232 public void pieceFinishTurn()
1785f66a7beb Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
233 {
35
aa15b2c556b4 Add comments.
Matti Hamalainen <ccr@tnsp.org>
parents: 32
diff changeset
234 // Do we have a piece?
2
1785f66a7beb Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
235 if (current != null)
7
70714c229e23 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 6
diff changeset
236 {
35
aa15b2c556b4 Add comments.
Matti Hamalainen <ccr@tnsp.org>
parents: 32
diff changeset
237 // Yes, place and lock it
6
be0bf7544069 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 4
diff changeset
238 current.setType(PieceType.LOCKED);
8
d8e7fd8f3ccf Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 7
diff changeset
239 PathInfo i = resolvePath(moveX, moveY, movePoint, true);
7
70714c229e23 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 6
diff changeset
240
70714c229e23 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 6
diff changeset
241 if (i != null)
70714c229e23 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 6
diff changeset
242 {
27
26adc2827983 More work on the internals.
Matti Hamalainen <ccr@tnsp.org>
parents: 26
diff changeset
243 System.out.print("moveX="+moveX+", moveY="+moveY+", movePoint="+movePoint+"\n");
26adc2827983 More work on the internals.
Matti Hamalainen <ccr@tnsp.org>
parents: 26
diff changeset
244 i.print();
26adc2827983 More work on the internals.
Matti Hamalainen <ccr@tnsp.org>
parents: 26
diff changeset
245 moveX = i.outX;
26adc2827983 More work on the internals.
Matti Hamalainen <ccr@tnsp.org>
parents: 26
diff changeset
246 moveY = i.outY;
26adc2827983 More work on the internals.
Matti Hamalainen <ccr@tnsp.org>
parents: 26
diff changeset
247 movePoint = i.out;
7
70714c229e23 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 6
diff changeset
248 }
70714c229e23 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 6
diff changeset
249 }
70714c229e23 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 6
diff changeset
250
35
aa15b2c556b4 Add comments.
Matti Hamalainen <ccr@tnsp.org>
parents: 32
diff changeset
251 // Create a new piece
8
d8e7fd8f3ccf Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 7
diff changeset
252 current = new Piece(PieceType.ACTIVE);
35
aa15b2c556b4 Add comments.
Matti Hamalainen <ccr@tnsp.org>
parents: 32
diff changeset
253
aa15b2c556b4 Add comments.
Matti Hamalainen <ccr@tnsp.org>
parents: 32
diff changeset
254 // Find a place for it
7
70714c229e23 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 6
diff changeset
255 if (isEmpty(moveX, moveY))
2
1785f66a7beb Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
256 {
35
aa15b2c556b4 Add comments.
Matti Hamalainen <ccr@tnsp.org>
parents: 32
diff changeset
257 // Current position is empty, use it
8
d8e7fd8f3ccf Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 7
diff changeset
258 board[moveX][moveY] = current;
d8e7fd8f3ccf Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 7
diff changeset
259 }
d8e7fd8f3ccf Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 7
diff changeset
260 else
d8e7fd8f3ccf Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 7
diff changeset
261 {
35
aa15b2c556b4 Add comments.
Matti Hamalainen <ccr@tnsp.org>
parents: 32
diff changeset
262 // Resolve path
8
d8e7fd8f3ccf Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 7
diff changeset
263 PathInfo i = resolvePath(moveX, moveY, movePoint, true);
d8e7fd8f3ccf Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 7
diff changeset
264 if (i != null)
d8e7fd8f3ccf Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 7
diff changeset
265 board[moveX][moveY] = current;
d8e7fd8f3ccf Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 7
diff changeset
266 else
27
26adc2827983 More work on the internals.
Matti Hamalainen <ccr@tnsp.org>
parents: 26
diff changeset
267 {
35
aa15b2c556b4 Add comments.
Matti Hamalainen <ccr@tnsp.org>
parents: 32
diff changeset
268 // Path ended up center/gameboard walls - it's game over, man
27
26adc2827983 More work on the internals.
Matti Hamalainen <ccr@tnsp.org>
parents: 26
diff changeset
269 System.out.print("pieceFinishTurn(): Game Over!\n");
8
d8e7fd8f3ccf Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 7
diff changeset
270 flagGameOver = true;
27
26adc2827983 More work on the internals.
Matti Hamalainen <ccr@tnsp.org>
parents: 26
diff changeset
271 }
2
1785f66a7beb Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
272 }
1
44f1e7b47fcf Preliminary work ... puuh.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
273 }
44f1e7b47fcf Preliminary work ... puuh.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
274 }
44f1e7b47fcf Preliminary work ... puuh.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
275
44f1e7b47fcf Preliminary work ... puuh.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
276
9
a7751971c2a3 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 8
diff changeset
277 public class Engine extends JPanel
18
4507a431b410 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 15
diff changeset
278 implements Runnable, KeyListener, MouseListener
1
44f1e7b47fcf Preliminary work ... puuh.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
279 {
25
bbac3e4a4b9b Cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 24
diff changeset
280 long startTime;
bbac3e4a4b9b Cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 24
diff changeset
281 float gameClock, gameFrames;
8
d8e7fd8f3ccf Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 7
diff changeset
282 Thread animThread;
d8e7fd8f3ccf Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 7
diff changeset
283 boolean animEnable = false;
25
bbac3e4a4b9b Cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 24
diff changeset
284
bbac3e4a4b9b Cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 24
diff changeset
285 Font fontMain, font1, font2;
4
e0e8fd08331e Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
286 GameBoard lauta = null;
9
a7751971c2a3 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 8
diff changeset
287 BufferedImage lautaBG = null, lautaBGScaled = null;
25
bbac3e4a4b9b Cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 24
diff changeset
288 Dimension lautaDim;
22
afde253ec705 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 21
diff changeset
289
21
df494a65bf8c More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 18
diff changeset
290 SoundElement[] sounds;
25
bbac3e4a4b9b Cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 24
diff changeset
291
32
e480579cc460 More work on debugging the path resolving.
Matti Hamalainen <ccr@tnsp.org>
parents: 30
diff changeset
292 Piece testi; int con = 0;
e480579cc460 More work on debugging the path resolving.
Matti Hamalainen <ccr@tnsp.org>
parents: 30
diff changeset
293
21
df494a65bf8c More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 18
diff changeset
294 public SoundElement snd(Sound snd)
df494a65bf8c More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 18
diff changeset
295 {
df494a65bf8c More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 18
diff changeset
296 return sounds[snd.ordinal()];
df494a65bf8c More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 18
diff changeset
297 }
1
44f1e7b47fcf Preliminary work ... puuh.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
298
9
a7751971c2a3 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 8
diff changeset
299 public Engine()
2
1785f66a7beb Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
300 {
25
bbac3e4a4b9b Cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 24
diff changeset
301 // Initialize globals
bbac3e4a4b9b Cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 24
diff changeset
302 System.out.print("Engine() constructor\n");
bbac3e4a4b9b Cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 24
diff changeset
303
bbac3e4a4b9b Cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 24
diff changeset
304 gameClock = 0;
bbac3e4a4b9b Cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 24
diff changeset
305 gameFrames = 0;
bbac3e4a4b9b Cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 24
diff changeset
306 startTime = new Date().getTime();
4
e0e8fd08331e Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
307
32
e480579cc460 More work on debugging the path resolving.
Matti Hamalainen <ccr@tnsp.org>
parents: 30
diff changeset
308 testi = new Piece(PieceType.LOCKED);
e480579cc460 More work on debugging the path resolving.
Matti Hamalainen <ccr@tnsp.org>
parents: 30
diff changeset
309
9
a7751971c2a3 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 8
diff changeset
310
25
bbac3e4a4b9b Cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 24
diff changeset
311 // Load resources
4
e0e8fd08331e Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
312 try
e0e8fd08331e Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
313 {
24
1be98362e5e9 FPS measurement.
Matti Hamalainen <ccr@tnsp.org>
parents: 23
diff changeset
314 ResourceLoader res = new ResourceLoader("graphics/board.jpg");
18
4507a431b410 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 15
diff changeset
315 lautaBG = ImageIO.read(res.getStream());
21
df494a65bf8c More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 18
diff changeset
316
25
bbac3e4a4b9b Cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 24
diff changeset
317 try {
bbac3e4a4b9b Cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 24
diff changeset
318 res = new ResourceLoader("graphics/font.ttf");
bbac3e4a4b9b Cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 24
diff changeset
319 fontMain = Font.createFont(Font.TRUETYPE_FONT, res.getStream());
bbac3e4a4b9b Cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 24
diff changeset
320 font1 = fontMain.deriveFont(24f);
bbac3e4a4b9b Cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 24
diff changeset
321 font2 = fontMain.deriveFont(32f);
bbac3e4a4b9b Cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 24
diff changeset
322 }
bbac3e4a4b9b Cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 24
diff changeset
323 catch (FontFormatException e)
bbac3e4a4b9b Cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 24
diff changeset
324 {
bbac3e4a4b9b Cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 24
diff changeset
325 System.out.print("Could not initialize fonts.\n");
bbac3e4a4b9b Cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 24
diff changeset
326 }
bbac3e4a4b9b Cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 24
diff changeset
327
21
df494a65bf8c More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 18
diff changeset
328 sounds = new SoundElement[16];
df494a65bf8c More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 18
diff changeset
329 for (Sound s : Sound.values())
df494a65bf8c More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 18
diff changeset
330 {
df494a65bf8c More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 18
diff changeset
331 System.out.print(s +" = "+ s.ordinal() +"\n");
23
0741dc117808 Remove sound code for later refactoring.
Matti Hamalainen <ccr@tnsp.org>
parents: 22
diff changeset
332 sounds[s.ordinal()] = new SoundElement("sounds/" + s.getName(), s.isStreaming());
21
df494a65bf8c More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 18
diff changeset
333 }
4
e0e8fd08331e Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
334 }
e0e8fd08331e Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
335 catch (IOException e)
e0e8fd08331e Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
336 {
18
4507a431b410 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 15
diff changeset
337 /*
4
e0e8fd08331e Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
338 JOptionPane.showMessageDialog(null,
21
df494a65bf8c More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 18
diff changeset
339 e.getMessage(),
4
e0e8fd08331e Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
340 "Initialization error",
e0e8fd08331e Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
341 JOptionPane.ERROR_MESSAGE);
18
4507a431b410 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 15
diff changeset
342 */
21
df494a65bf8c More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 18
diff changeset
343 System.out.print(e.getMessage());
18
4507a431b410 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 15
diff changeset
344 }
4507a431b410 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 15
diff changeset
345
4507a431b410 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 15
diff changeset
346 lauta = new GameBoard();
4507a431b410 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 15
diff changeset
347 addKeyListener(this);
4507a431b410 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 15
diff changeset
348 addMouseListener(this);
4507a431b410 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 15
diff changeset
349
4507a431b410 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 15
diff changeset
350 // Get initial focus
4507a431b410 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 15
diff changeset
351 if (!hasFocus())
4507a431b410 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 15
diff changeset
352 {
4507a431b410 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 15
diff changeset
353 System.out.print("Engine(): requesting focus\n");
4507a431b410 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 15
diff changeset
354 requestFocus();
4
e0e8fd08331e Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
355 }
22
afde253ec705 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 21
diff changeset
356
21
df494a65bf8c More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 18
diff changeset
357 snd(Sound.MUSIC_GAME1).loop(-1);
8
d8e7fd8f3ccf Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 7
diff changeset
358 }
d8e7fd8f3ccf Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 7
diff changeset
359
25
bbac3e4a4b9b Cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 24
diff changeset
360
bbac3e4a4b9b Cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 24
diff changeset
361 public void paintComponent(Graphics g)
bbac3e4a4b9b Cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 24
diff changeset
362 {
bbac3e4a4b9b Cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 24
diff changeset
363 Graphics2D g2 = (Graphics2D) g;
bbac3e4a4b9b Cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 24
diff changeset
364
bbac3e4a4b9b Cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 24
diff changeset
365 // Use antialiasing when rendering the game elements
bbac3e4a4b9b Cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 24
diff changeset
366 g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
bbac3e4a4b9b Cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 24
diff changeset
367 RenderingHints.VALUE_ANTIALIAS_ON);
bbac3e4a4b9b Cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 24
diff changeset
368
bbac3e4a4b9b Cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 24
diff changeset
369 g2.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING,
bbac3e4a4b9b Cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 24
diff changeset
370 RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
bbac3e4a4b9b Cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 24
diff changeset
371
bbac3e4a4b9b Cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 24
diff changeset
372 // Rescale background if component size has changed
bbac3e4a4b9b Cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 24
diff changeset
373 Dimension dim = getSize();
bbac3e4a4b9b Cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 24
diff changeset
374 if (lautaDim == null || !dim.equals(lautaDim))
bbac3e4a4b9b Cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 24
diff changeset
375 {
bbac3e4a4b9b Cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 24
diff changeset
376 lautaBGScaled = new BufferedImage(dim.width, dim.height, BufferedImage.TYPE_INT_ARGB);
bbac3e4a4b9b Cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 24
diff changeset
377 Graphics2D gimg = lautaBGScaled.createGraphics();
bbac3e4a4b9b Cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 24
diff changeset
378 gimg.setRenderingHint(RenderingHints.KEY_INTERPOLATION,
bbac3e4a4b9b Cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 24
diff changeset
379 RenderingHints.VALUE_INTERPOLATION_BICUBIC);
bbac3e4a4b9b Cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 24
diff changeset
380
bbac3e4a4b9b Cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 24
diff changeset
381 gimg.drawImage(lautaBG, 0, 0, dim.width, dim.height, null);
bbac3e4a4b9b Cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 24
diff changeset
382 lautaDim = dim;
bbac3e4a4b9b Cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 24
diff changeset
383
bbac3e4a4b9b Cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 24
diff changeset
384 System.out.print("scale changed\n");
bbac3e4a4b9b Cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 24
diff changeset
385 }
bbac3e4a4b9b Cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 24
diff changeset
386
bbac3e4a4b9b Cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 24
diff changeset
387 // Background, pieces
bbac3e4a4b9b Cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 24
diff changeset
388 g2.drawImage(lautaBGScaled, 0, 0, null);
bbac3e4a4b9b Cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 24
diff changeset
389 lauta.paint(g2, 100, 150, 60);
bbac3e4a4b9b Cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 24
diff changeset
390
32
e480579cc460 More work on debugging the path resolving.
Matti Hamalainen <ccr@tnsp.org>
parents: 30
diff changeset
391 testi.paint(g2, 50f,50f,100f);
e480579cc460 More work on debugging the path resolving.
Matti Hamalainen <ccr@tnsp.org>
parents: 30
diff changeset
392
25
bbac3e4a4b9b Cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 24
diff changeset
393 // Scores
bbac3e4a4b9b Cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 24
diff changeset
394 g2.setFont(font1);
bbac3e4a4b9b Cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 24
diff changeset
395 g2.setPaint(Color.white);
bbac3e4a4b9b Cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 24
diff changeset
396
bbac3e4a4b9b Cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 24
diff changeset
397
bbac3e4a4b9b Cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 24
diff changeset
398 // Other elements
bbac3e4a4b9b Cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 24
diff changeset
399 long currTime = new Date().getTime();
32
e480579cc460 More work on debugging the path resolving.
Matti Hamalainen <ccr@tnsp.org>
parents: 30
diff changeset
400 g2.drawString("fps = "+ ((gameFrames * 1000) / (currTime - startTime)), dim.width - 120, 20);
e480579cc460 More work on debugging the path resolving.
Matti Hamalainen <ccr@tnsp.org>
parents: 30
diff changeset
401
e480579cc460 More work on debugging the path resolving.
Matti Hamalainen <ccr@tnsp.org>
parents: 30
diff changeset
402 g2.drawString("con = "+ con, 20, 30);
25
bbac3e4a4b9b Cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 24
diff changeset
403 }
bbac3e4a4b9b Cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 24
diff changeset
404
8
d8e7fd8f3ccf Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 7
diff changeset
405 public void startThreads()
d8e7fd8f3ccf Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 7
diff changeset
406 {
9
a7751971c2a3 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 8
diff changeset
407 System.out.print("startThreads()\n");
8
d8e7fd8f3ccf Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 7
diff changeset
408 if (animThread == null)
d8e7fd8f3ccf Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 7
diff changeset
409 {
d8e7fd8f3ccf Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 7
diff changeset
410 animThread = new Thread(this);
d8e7fd8f3ccf Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 7
diff changeset
411 animEnable = true;
d8e7fd8f3ccf Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 7
diff changeset
412 animThread.start();
d8e7fd8f3ccf Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 7
diff changeset
413 }
d8e7fd8f3ccf Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 7
diff changeset
414 }
d8e7fd8f3ccf Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 7
diff changeset
415
d8e7fd8f3ccf Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 7
diff changeset
416 public void stopThreads()
d8e7fd8f3ccf Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 7
diff changeset
417 {
9
a7751971c2a3 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 8
diff changeset
418 System.out.print("stopThreads()\n");
8
d8e7fd8f3ccf Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 7
diff changeset
419 if (animThread != null)
d8e7fd8f3ccf Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 7
diff changeset
420 {
d8e7fd8f3ccf Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 7
diff changeset
421 animThread.interrupt();
d8e7fd8f3ccf Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 7
diff changeset
422 animEnable = false;
d8e7fd8f3ccf Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 7
diff changeset
423 animThread = null;
d8e7fd8f3ccf Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 7
diff changeset
424 }
22
afde253ec705 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 21
diff changeset
425
afde253ec705 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 21
diff changeset
426 for (Sound s : Sound.values())
afde253ec705 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 21
diff changeset
427 {
afde253ec705 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 21
diff changeset
428 if (snd(s) != null)
afde253ec705 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 21
diff changeset
429 snd(s).stop();
afde253ec705 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 21
diff changeset
430 }
2
1785f66a7beb Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
431 }
0
f930f72ed0f5 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
432
18
4507a431b410 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 15
diff changeset
433 public void mousePressed(MouseEvent e) { }
4507a431b410 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 15
diff changeset
434 public void mouseEntered(MouseEvent e) { }
4507a431b410 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 15
diff changeset
435 public void mouseExited(MouseEvent e) { }
4507a431b410 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 15
diff changeset
436 public void mouseReleased(MouseEvent e) { }
4507a431b410 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 15
diff changeset
437
4507a431b410 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 15
diff changeset
438 public void mouseClicked(MouseEvent e)
4507a431b410 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 15
diff changeset
439 {
4507a431b410 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 15
diff changeset
440 System.out.print("mouseClicked()\n");
4507a431b410 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 15
diff changeset
441 if (!hasFocus())
4507a431b410 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 15
diff changeset
442 {
4507a431b410 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 15
diff changeset
443 System.out.print("requesting focus\n");
4507a431b410 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 15
diff changeset
444 requestFocus();
4507a431b410 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 15
diff changeset
445 }
4507a431b410 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 15
diff changeset
446 }
4507a431b410 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 15
diff changeset
447
9
a7751971c2a3 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 8
diff changeset
448 public void keyTyped(KeyEvent e)
2
1785f66a7beb Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
449 {
1785f66a7beb Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
450 }
1
44f1e7b47fcf Preliminary work ... puuh.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
451
2
1785f66a7beb Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
452 public void keyReleased(KeyEvent e)
1785f66a7beb Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
453 {
1785f66a7beb Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
454 }
1
44f1e7b47fcf Preliminary work ... puuh.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
455
9
a7751971c2a3 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 8
diff changeset
456 public void keyPressed(KeyEvent e)
2
1785f66a7beb Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
457 {
26
3d4cc47df31a Cleanups, fix piece rendering and rotation.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
458 // Handle keyboard input
7
70714c229e23 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 6
diff changeset
459 switch (e.getKeyCode())
2
1785f66a7beb Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
460 {
7
70714c229e23 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 6
diff changeset
461 case KeyEvent.VK_LEFT:
70714c229e23 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 6
diff changeset
462 case KeyEvent.VK_UP:
32
e480579cc460 More work on debugging the path resolving.
Matti Hamalainen <ccr@tnsp.org>
parents: 30
diff changeset
463 lauta.pieceRotate(Piece.RotateDir.LEFT);
2
1785f66a7beb Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
464 break;
0
f930f72ed0f5 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
465
7
70714c229e23 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 6
diff changeset
466 case KeyEvent.VK_RIGHT:
70714c229e23 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 6
diff changeset
467 case KeyEvent.VK_DOWN:
32
e480579cc460 More work on debugging the path resolving.
Matti Hamalainen <ccr@tnsp.org>
parents: 30
diff changeset
468 lauta.pieceRotate(Piece.RotateDir.RIGHT);
2
1785f66a7beb Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
469 break;
1785f66a7beb Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
470
7
70714c229e23 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 6
diff changeset
471 case KeyEvent.VK_ENTER:
2
1785f66a7beb Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
472 lauta.pieceFinishTurn();
23
0741dc117808 Remove sound code for later refactoring.
Matti Hamalainen <ccr@tnsp.org>
parents: 22
diff changeset
473 snd(Sound.PIECE_PLACED).stop();
0741dc117808 Remove sound code for later refactoring.
Matti Hamalainen <ccr@tnsp.org>
parents: 22
diff changeset
474 snd(Sound.PIECE_PLACED).play();
2
1785f66a7beb Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
475 break;
35
aa15b2c556b4 Add comments.
Matti Hamalainen <ccr@tnsp.org>
parents: 32
diff changeset
476
aa15b2c556b4 Add comments.
Matti Hamalainen <ccr@tnsp.org>
parents: 32
diff changeset
477 case KeyEvent.VK_ESCAPE:
aa15b2c556b4 Add comments.
Matti Hamalainen <ccr@tnsp.org>
parents: 32
diff changeset
478 break;
2
1785f66a7beb Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
479 }
1785f66a7beb Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
480 }
8
d8e7fd8f3ccf Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 7
diff changeset
481
d8e7fd8f3ccf Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 7
diff changeset
482 public void run()
d8e7fd8f3ccf Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 7
diff changeset
483 {
d8e7fd8f3ccf Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 7
diff changeset
484 while (animEnable)
d8e7fd8f3ccf Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 7
diff changeset
485 {
26
3d4cc47df31a Cleanups, fix piece rendering and rotation.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
486 // Progress game animation clock
25
bbac3e4a4b9b Cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 24
diff changeset
487 gameClock++;
9
a7751971c2a3 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 8
diff changeset
488
26
3d4cc47df31a Cleanups, fix piece rendering and rotation.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
489 // Animate components
25
bbac3e4a4b9b Cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 24
diff changeset
490 lauta.animate(gameClock);
9
a7751971c2a3 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 8
diff changeset
491
26
3d4cc47df31a Cleanups, fix piece rendering and rotation.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
492 // Repaint with a frame limiter
25
bbac3e4a4b9b Cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 24
diff changeset
493 if (gameClock % 3 == 1)
24
1be98362e5e9 FPS measurement.
Matti Hamalainen <ccr@tnsp.org>
parents: 23
diff changeset
494 {
10
4bacc98973f5 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 9
diff changeset
495 repaint();
25
bbac3e4a4b9b Cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 24
diff changeset
496 gameFrames++;
24
1be98362e5e9 FPS measurement.
Matti Hamalainen <ccr@tnsp.org>
parents: 23
diff changeset
497 }
32
e480579cc460 More work on debugging the path resolving.
Matti Hamalainen <ccr@tnsp.org>
parents: 30
diff changeset
498
e480579cc460 More work on debugging the path resolving.
Matti Hamalainen <ccr@tnsp.org>
parents: 30
diff changeset
499 // debugataan
e480579cc460 More work on debugging the path resolving.
Matti Hamalainen <ccr@tnsp.org>
parents: 30
diff changeset
500 con = ((int) (gameClock / 100)) & 7;
e480579cc460 More work on debugging the path resolving.
Matti Hamalainen <ccr@tnsp.org>
parents: 30
diff changeset
501 testi.clearActiveConnections();
e480579cc460 More work on debugging the path resolving.
Matti Hamalainen <ccr@tnsp.org>
parents: 30
diff changeset
502 testi.setActiveConnection(con);
26
3d4cc47df31a Cleanups, fix piece rendering and rotation.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
503
3d4cc47df31a Cleanups, fix piece rendering and rotation.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
504 // Sleep for a moment
9
a7751971c2a3 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 8
diff changeset
505 try {
a7751971c2a3 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 8
diff changeset
506 Thread.sleep(10);
a7751971c2a3 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 8
diff changeset
507 }
a7751971c2a3 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 8
diff changeset
508 catch (InterruptedException x) {
a7751971c2a3 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 8
diff changeset
509 }
8
d8e7fd8f3ccf Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 7
diff changeset
510 }
d8e7fd8f3ccf Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 7
diff changeset
511 }
0
f930f72ed0f5 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
512 }