source: last-defense/main/LastDefenseMain.java@ fb4fc67

Last change on this file since fb4fc67 was fb4fc67, checked in by Dmitry Portnoy <dmitry.portnoy@…>, 6 years ago

Initial commit, code decompiled from a jar

  • Property mode set to 100644
File size: 26.2 KB
Line 
1package main;
2
3import java.awt.Color;
4import java.awt.Frame;
5import java.awt.Font;
6import java.awt.FontMetrics;
7import java.awt.Graphics;
8import java.awt.GraphicsConfiguration;
9import java.awt.GraphicsDevice;
10import java.awt.GraphicsEnvironment;
11import java.awt.MouseInfo;
12import java.awt.Point;
13import java.awt.Toolkit;
14import java.awt.event.KeyEvent;
15import java.awt.event.KeyListener;
16import java.awt.event.MouseEvent;
17import java.awt.event.MouseListener;
18import java.awt.image.BufferStrategy;
19
20import java.io.FileOutputStream;
21import java.io.OutputStream;
22import java.io.PrintStream;
23
24import java.util.Iterator;
25import java.util.LinkedList;
26
27import gamegui.Align;
28import gamegui.Animation;
29import gamegui.Button;
30import gamegui.Label;
31import gamegui.Member;
32import gamegui.MultiTextbox;
33import gamegui.Textbox;
34import gamegui.Window;
35
36import utils.DynamicImage;
37import utils.Utils;
38
39public class LastDefenseMain implements KeyListener, MouseListener {
40 private static final boolean RUNNING_FROM_JAR = true;
41 GameState gameState;
42 AuxState auxState;
43 boolean started;
44 boolean done;
45 boolean showFps;
46 int frameCount;
47 int lastFrameCount;
48 int refreshRate;
49 long lastFpsUpdate;
50 Graphics g;
51 Frame frmMain;
52 Window wndMain;
53 Window wndInfo;
54 Window wndCredits;
55 Window wndDiagnostics;
56 Window wndMessage;
57 DynamicImage background;
58 DynamicImage yellowCursor;
59 DynamicImage greenCursor;
60 DynamicImage redCursor;
61 DynamicImage cursor;
62 Textbox selectedText;
63 Button selectedButton;
64 Font font11;
65 Font font12;
66 Font font14;
67 Font font24;
68 Font fontTT;
69 Font fontCustom11;
70 Font fontCustom12;
71 Font fontCustom14;
72 Font fontCustom24;
73 Font fontCustom30;
74 Font fontCustom48;
75 Font guiFont12;
76 Font guiFont14;
77 Color color1;
78 Color color2;
79 FontMetrics m;
80 Color redHaze;
81 Color blueHaze;
82 LinkedList<Entity> lstObjects;
83 LinkedList<Unit> lstShips;
84 LinkedList<Unit> lstTurrets;
85 long timeLastUpdated;
86 int resources;
87 Animation turret;
88 Animation shield;
89 Animation projectile;
90 Animation assaultShip;
91 Level[] levels;
92 int curLevel;
93 public static int resUsed;
94 public static int shipsKilled;
95 public static int turretsKilled;
96 public static int shieldsKilled;
97 boolean pause;
98 long timePaused;
99 long pauseDuration;
100 boolean showCost;
101 long timeShowingCost;
102 long costDuration;
103 int cost;
104
105 public LastDefenseMain(final GraphicsDevice device) {
106 this.started = false;
107 this.pauseDuration = 3000L;
108 this.costDuration = 1200L;
109 try {
110 final GraphicsConfiguration gc = device.getDefaultConfiguration();
111 (this.frmMain = new Frame(gc)).setUndecorated(true);
112 this.frmMain.setIgnoreRepaint(true);
113 device.setFullScreenWindow(this.frmMain);
114 if (device.isDisplayChangeSupported()) {
115 Utils.chooseBestDisplayMode(device, 800, 600);
116 }
117 this.frmMain.addMouseListener(this);
118 this.frmMain.addKeyListener(this);
119 this.frmMain.createBufferStrategy(2);
120 final BufferStrategy bufferStrategy = this.frmMain.getBufferStrategy();
121 this.g = bufferStrategy.getDrawGraphics();
122 this.refreshRate = device.getDisplayMode().getRefreshRate();
123 Utils.init(gc, true);
124 this.gameState = GameState.Main;
125 this.auxState = AuxState.None;
126 this.done = false;
127 this.showFps = false;
128 this.frameCount = 0;
129 this.lastFrameCount = 0;
130 this.lastFpsUpdate = System.nanoTime();
131 this.selectedText = null;
132 this.selectedButton = null;
133 this.timeLastUpdated = 0L;
134 this.lstObjects = new LinkedList<Entity>();
135 this.lstShips = new LinkedList<Unit>();
136 this.lstTurrets = new LinkedList<Unit>();
137 final Toolkit tk = Toolkit.getDefaultToolkit();
138 this.frmMain.setCursor(tk.createCustomCursor(tk.createImage(""), new Point(), null));
139 this.loadGUI(bufferStrategy);
140 this.loadObjects();
141 this.started = true;
142 while (!this.done) {
143 this.g = bufferStrategy.getDrawGraphics();
144 this.handleGameEvents();
145 this.render(this.g);
146 if (this.frmMain != null) {
147 this.detectMouseOver(this.g);
148 final Point e = MouseInfo.getPointerInfo().getLocation();
149 if (e != null) {
150 this.cursor.draw(this.g, e.x - 5, e.y - 2);
151 }
152 }
153 this.g.dispose();
154 bufferStrategy.show();
155 ++this.frameCount;
156 if (System.nanoTime() - 1000000000L >= this.lastFpsUpdate) {
157 this.lastFpsUpdate = System.nanoTime();
158 this.lastFrameCount = this.frameCount;
159 this.frameCount = 0;
160 }
161 }
162 }
163 catch (Exception e2) {
164 e2.printStackTrace();
165 return;
166 }
167 finally {
168 device.setFullScreenWindow(null);
169 }
170 device.setFullScreenWindow(null);
171 }
172
173 private void loadGUI(final BufferStrategy bufferStrategy) {
174 (this.background = new DynamicImage("background.png")).draw(bufferStrategy.getDrawGraphics(), 0, 0);
175 this.font11 = new Font("Arial", 0, 11);
176 this.font12 = new Font("Arial", 0, 12);
177 this.font14 = new Font("Arial", 0, 14);
178 this.font24 = new Font("Arial", 0, 24);
179 this.fontTT = new Font("Courier New", 0, 11);
180 this.guiFont12 = new Font("Garamond", 1, 12);
181 this.guiFont14 = new Font("Garamond", 1, 14);
182 this.m = this.g.getFontMetrics(this.guiFont12);
183 try {
184 final Font fontCustom = Utils.loadFont("images/gui/Last_words.ttf");
185 this.fontCustom11 = fontCustom.deriveFont(0, 11.0f);
186 this.fontCustom12 = fontCustom.deriveFont(0, 12.0f);
187 this.fontCustom14 = fontCustom.deriveFont(0, 14.0f);
188 this.fontCustom24 = fontCustom.deriveFont(0, 24.0f);
189 this.fontCustom30 = fontCustom.deriveFont(0, 30.0f);
190 this.fontCustom48 = fontCustom.deriveFont(0, 48.0f);
191 }
192 catch (Exception e) {
193 e.printStackTrace();
194 }
195 this.yellowCursor = new DynamicImage("gui/cursor.png");
196 this.greenCursor = new DynamicImage("gui/cursorgreen.png");
197 this.redCursor = new DynamicImage("gui/cursorred.png");
198 this.cursor = this.yellowCursor;
199 this.wndMain = new Window("main", 0, 0, 800, 600, true);
200 FontMetrics metrics = this.g.getFontMetrics(this.fontCustom48);
201 this.wndMain.add(new Button("title", 400 - metrics.stringWidth("Last Defense") / 2, 120, 0, 0, "Last Defense", this.fontCustom48, new Color(20, 200, 20), false));
202 this.wndMain.background = this.background;
203 this.color2 = Color.green;
204 this.color1 = new Color(0, 160, 0);
205 metrics = this.g.getFontMetrics(this.fontCustom30);
206 this.wndMain.add(new Button("new game", 100, 270, metrics.stringWidth("Start Game"), metrics.getHeight(), "Start Game", this.fontCustom30, this.color1, false));
207 this.wndMain.add(new Button("game info", 140, 320, metrics.stringWidth("Game Info"), metrics.getHeight(), "Game Info", this.fontCustom30, this.color1, false));
208 metrics = this.g.getFontMetrics(this.fontCustom24);
209 this.wndMain.add(new Button("credits", 15, 565, metrics.stringWidth("Credits"), metrics.getHeight(), "Credits", this.fontCustom24, this.color1, false));
210 this.wndMain.add(new Button("quit", 730, 565, metrics.stringWidth("Quit"), metrics.getHeight(), "Quit", this.fontCustom24, this.color1, false));
211 this.wndInfo = new Window("info", 0, 0, 800, 600, true);
212 this.wndInfo.background = this.background;
213 this.wndInfo.add(new Label("title", 250, 15, 300, 20, "Game Info", this.font24, new Color(0, 160, 0)));
214 this.wndInfo.add(new MultiTextbox("info", 50, 120, 700, 430, "", false, this.font14, this.g.getFontMetrics(this.font14)));
215 ((MultiTextbox)this.wndInfo.getMember("info")).setBorder(true);
216 ((MultiTextbox)this.wndInfo.getMember("info")).setText(" You must defend against some sort of invasion. You have turrets and shields at your disposal. Turrets will automatically fire at enemy fighters and shields will generate a small forcefield that protects nearby turrets against enemy fire.\n Use your left mouse button to place turrets and your right mouse button to place shields. Both of these cost resources, so make sure to use the resources you have wisely. You start with 100 resources and you can get more as you destroy enemy fighters. Each turret costs 30 resources and each shield costs 50 resources.\n The enemy fighters descend in waves from the top of the screen. Once a wave is defeated, all surviving turrets and shields will have their hitpoints restored to full and the next wave will immediately come.\n There are 20 waves total. Good luck!\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n(Click your mouse to return to the main menu)");
217 this.wndInfo.add(new Label("", 150, 410, 100, 20, "Turret", this.font14, Align.Center));
218 this.wndInfo.add(new Label("", 350, 410, 100, 20, "Shield", this.font14, Align.Center));
219 this.wndInfo.add(new Label("", 550, 410, 100, 20, "Fighter", this.font14, Align.Center));
220 (this.wndCredits = new Window("main", 0, 0, 800, 600, true)).add(new Label("title", 250, 15, 300, 20, "Credits", this.fontCustom24, this.color2));
221 this.wndCredits.background = this.background;
222 this.wndCredits.add(new Label("1", 250, 160, 300, 20, "Created By", this.guiFont14, this.color2));
223 this.wndCredits.add(new Label("2", 250, 180, 300, 20, "Dmitry Portnoy", this.guiFont12, this.color2));
224 this.wndCredits.add(new Label("4", 250, 220, 300, 20, "Free Art", this.guiFont14, this.color2));
225 this.wndCredits.add(new Label("5", 250, 240, 300, 20, "martinstudio.kings-field.com", this.guiFont12, this.color2));
226 (this.wndMessage = new Window("message", 290, 135, 220, 160)).add(new Label("label", 20, 15, 180, 12, "none", this.font12));
227 this.wndMessage.add(new Button("button", 70, 115, 80, 30, "OK", this.font12, Align.Center));
228 this.wndDiagnostics = new Window("diagnostics", 0, 0, 400, 140, true);
229 }
230
231 private void loadObjects() {
232 (this.assaultShip = new Animation("", 0, 0, 64, 64, 200, true)).addFrame(new DynamicImage("ships/assault/assault1.png"));
233 this.assaultShip.addFrame(new DynamicImage("ships/assault/assault2.png"));
234 this.assaultShip.addFrame(new DynamicImage("ships/assault/assault3.png"));
235 this.assaultShip.addFrame(new DynamicImage("ships/assault/assault4.png"));
236 (this.turret = new Animation("", 0, 0, 42, 45, 200, true)).addFrame(new DynamicImage("turrets/turret2.png"));
237 (this.shield = new Animation("", 0, 0, 70, 44, 200, true)).addFrame(new DynamicImage("turrets/shield.png"));
238 (this.projectile = new Animation("", 0, 0, 4, 18, 200, true)).addFrame(new DynamicImage("laser.png"));
239 this.levels = new Level[20];
240 final int[] levelNum = { 3, 3, 4, 5, 6, 8, 10, 12, 14, 17, 20, 24, 28, 34, 40, 45, 50, 56, 62, 70 };
241 for (int x = 0; x < levelNum.length; ++x) {
242 this.levels[x] = new Level();
243 for (int y = 0; y < levelNum[x]; ++y) {
244 this.levels[x].addUnit(new Ship("", this.assaultShip, 5, 40, 200, this.projectile));
245 }
246 }
247 }
248
249 private void loadLevel(final Level l) {
250 final Iterator<Ship> iter = l.lstUnits.iterator();
251 while (iter.hasNext()) {
252 this.addObject(new Ship(iter.next()));
253 }
254 }
255
256 private synchronized void handleGameEvents() {
257 switch (this.gameState) {
258 case Game: {
259 this.spawnObjects();
260 this.updateObjects();
261 break;
262 }
263 }
264 }
265
266 private synchronized void render(final Graphics g) {
267 g.setColor(Color.black);
268 g.fillRect(0, 0, 800, 600);
269 switch (this.gameState) {
270 case Main: {
271 this.wndMain.draw(g);
272 break;
273 }
274 case Info: {
275 this.drawInfo(g);
276 break;
277 }
278 case Credits: {
279 this.drawCredits(g);
280 break;
281 }
282 case Game: {
283 this.drawGame(g);
284 break;
285 }
286 }
287 switch (this.auxState) {
288 case MsgBox: {
289 this.wndMessage.draw(g);
290 g.drawString("Level reached: " + (this.curLevel + 1), 300, 200);
291 g.drawString("Ships destroyed: " + LastDefenseMain.shipsKilled, 300, 215);
292 g.drawString("Resources Used: " + LastDefenseMain.resUsed, 300, 230);
293 g.drawString("Turrets lost: " + LastDefenseMain.turretsKilled, 430, 200);
294 g.drawString("Shields lost: " + LastDefenseMain.shieldsKilled, 430, 215);
295 break;
296 }
297 }
298 if (this.showFps) {
299 this.drawDiagnostics(g);
300 }
301 }
302
303 public void showMessage(final String text) {
304 this.auxState = AuxState.MsgBox;
305 ((Label)this.wndMessage.getMember("label")).setText(text);
306 }
307
308 private void drawInfo(final Graphics g) {
309 this.wndInfo.draw(g);
310 this.turret.draw(g, 200, 400);
311 this.shield.draw(g, 400, 400);
312 this.assaultShip.draw(g, 600, 400);
313 }
314
315 private void drawCredits(final Graphics g) {
316 this.wndCredits.draw(g);
317 }
318
319 private void drawGame(final Graphics g) {
320 this.background.draw(g, 0, 0);
321 for (final Unit cur : this.lstTurrets) {
322 if (cur instanceof Shield) {
323 final Shield shield = (Shield)cur;
324 g.setColor(new Color(0, 0, 255, 100 * shield.hitpoints / shield.maxHitpoints));
325 g.fillOval(shield.loc.getX() - shield.radius, shield.loc.getY() - shield.radius, shield.radius * 2, shield.radius * 2);
326 }
327 }
328 final Iterator<Entity> iter = this.lstObjects.iterator();
329 while (iter.hasNext()) {
330 iter.next().draw(g);
331 }
332 g.setColor(Color.green);
333 g.drawString("Resources: " + this.resources, 0, 15);
334 g.drawString("Level: " + (this.curLevel + 1), 750, 15);
335 if (this.showCost) {
336 if (System.currentTimeMillis() - this.timeShowingCost >= this.costDuration) {
337 this.showCost = false;
338 } else {
339 g.drawString(new StringBuilder().append(this.cost).toString(), MouseInfo.getPointerInfo().getLocation().x - 8, MouseInfo.getPointerInfo().getLocation().y - 25);
340 }
341 }
342 }
343
344 private void drawDiagnostics(final Graphics g) {
345 this.wndDiagnostics.draw(g);
346 g.setColor(Color.green);
347 g.setFont(this.fontTT);
348 g.drawString("Unthrottled FPS: " + this.lastFrameCount, 0, 15);
349 g.drawString("Monitor Refresh Rate: " + this.refreshRate, 0, 30);
350 g.drawString("Player Info", 0, 60);
351 }
352
353 private synchronized void detectMouseOver(final Graphics g) {
354 final Point e = MouseInfo.getPointerInfo().getLocation();
355 if (e == null) {
356 return;
357 }
358 g.setFont(this.guiFont12);
359 this.cursor = this.yellowCursor;
360 switch (this.gameState) {
361 case Main: {
362 if (this.selectedButton != null) {
363 this.selectedButton.color = this.color1;
364 }
365 if (this.wndMain.getMember("new game").isClicked(e.x, e.y)) {
366 this.selectedButton = (Button)this.wndMain.getMember("new game");
367 }
368 else if (this.wndMain.getMember("game info").isClicked(e.x, e.y)) {
369 this.selectedButton = (Button)this.wndMain.getMember("game info");
370 }
371 else if (this.wndMain.getMember("credits").isClicked(e.x, e.y)) {
372 this.selectedButton = (Button)this.wndMain.getMember("credits");
373 }
374 else if (this.wndMain.getMember("quit").isClicked(e.x, e.y)) {
375 this.selectedButton = (Button)this.wndMain.getMember("quit");
376 }
377 else {
378 this.selectedButton = null;
379 }
380 if (this.selectedButton != null) {
381 this.selectedButton.color = this.color2;
382 break;
383 }
384 break;
385 }
386 }
387 }
388
389 private void spawnObjects() {
390 if (this.timeLastUpdated == 0L) {
391 this.timeLastUpdated = System.currentTimeMillis();
392 return;
393 }
394 final long timeCurrent = System.currentTimeMillis();
395 if (timeCurrent - this.timeLastUpdated >= 2000L) {
396 this.timeLastUpdated = timeCurrent;
397 }
398 }
399
400 private void updateObjects() {
401 if (this.pause) {
402 if (System.currentTimeMillis() - this.timePaused >= this.pauseDuration) {
403 this.pause = false;
404 this.loadLevel(this.levels[this.curLevel]);
405 }
406 }
407 else if (this.lstShips.size() == 0) {
408 this.pause = true;
409 this.timePaused = System.currentTimeMillis();
410 ++this.curLevel;
411 if (this.curLevel == 20) {
412 this.gameState = GameState.Main;
413 this.showCost = false;
414 this.showMessage("You have won!");
415 return;
416 }
417 for (final Unit cur : this.lstTurrets) {
418 cur.hitpoints = cur.maxHitpoints;
419 }
420 }
421 else if (this.lstTurrets.size() == 0 && this.resources <= 30) {
422 this.gameState = GameState.Main;
423 this.showCost = false;
424 this.showMessage("You have lost!");
425 return;
426 }
427 final LinkedList<Entity> lstTemp = new LinkedList<Entity>();
428 for (final Entity cur2 : this.lstObjects) {
429 if (cur2 instanceof Ship) {
430 cur2.update(lstTemp, this.lstTurrets);
431 }
432 else if (cur2 instanceof Shield) {
433 cur2.update(this.lstObjects, null);
434 }
435 else {
436 cur2.update(lstTemp, this.lstShips);
437 }
438 }
439 Iterator<Entity> iter2 = this.lstObjects.iterator();
440 while (iter2.hasNext()) {
441 final Entity cur2 = iter2.next();
442 if (cur2.remove) {
443 iter2.remove();
444 this.removeObject(cur2);
445 }
446 }
447 iter2 = lstTemp.iterator();
448 while (iter2.hasNext()) {
449 this.addObject(iter2.next());
450 }
451 }
452
453 private void addObject(final Entity obj) {
454 if (obj instanceof Turret) {
455 this.lstTurrets.add((Turret)obj);
456 }
457 else if (obj instanceof Shield) {
458 this.lstTurrets.add((Shield)obj);
459 }
460 else if (obj instanceof Ship) {
461 this.lstShips.add((Ship)obj);
462 }
463 this.lstObjects.add(obj);
464 }
465
466 private void removeObject(final Entity obj) {
467 if (obj instanceof Turret) {
468 this.lstTurrets.remove(obj);
469 ++LastDefenseMain.turretsKilled;
470 }
471 if (obj instanceof Shield) {
472 this.lstTurrets.remove(obj);
473 ++LastDefenseMain.shieldsKilled;
474 }
475 else if (obj instanceof Ship) {
476 this.lstShips.remove(obj);
477 ++LastDefenseMain.shipsKilled;
478 this.resources += 15;
479 }
480 }
481
482 private synchronized void handleMouseInput(final MouseEvent e) {
483 if (!this.started) {
484 return;
485 }
486 this.selectText(null);
487 switch (this.auxState) {
488 case None: {
489 switch (this.gameState) {
490 case Main: {
491 if (this.wndMain.getMember("new game").isClicked(e.getX(), e.getY())) {
492 this.lstObjects.clear();
493 this.lstTurrets.clear();
494 this.lstShips.clear();
495 this.addObject(new Turret("Turret", this.turret, 5, 40, 400, this.projectile));
496 this.lstTurrets.get(this.lstTurrets.size() - 1).setLocation(new Location(250.0, 450.0));
497 this.curLevel = 0;
498 this.resources = 100;
499 LastDefenseMain.resUsed = 0;
500 LastDefenseMain.shipsKilled = 0;
501 LastDefenseMain.turretsKilled = 0;
502 LastDefenseMain.shieldsKilled = 0;
503 this.pause = true;
504 this.showCost = false;
505 this.timePaused = System.currentTimeMillis();
506 this.gameState = GameState.Game;
507 break;
508 }
509 if (this.wndMain.getMember("game info").isClicked(e.getX(), e.getY())) {
510 this.gameState = GameState.Info;
511 break;
512 }
513 if (this.wndMain.getMember("credits").isClicked(e.getX(), e.getY())) {
514 this.gameState = GameState.Credits;
515 break;
516 }
517 if (this.wndMain.getMember("quit").isClicked(e.getX(), e.getY())) {
518 this.done = true;
519 break;
520 }
521 break;
522 }
523 case Info: {
524 this.gameState = GameState.Main;
525 break;
526 }
527 case Credits: {
528 this.gameState = GameState.Main;
529 break;
530 }
531 case Game: {
532 if (e.getButton() == 1) {
533 if (this.resources >= 30) {
534 this.resources -= 30;
535 LastDefenseMain.resUsed += 30;
536 this.addObject(new Turret("TurretX", this.turret, 5, 40, 400, this.projectile));
537 this.lstTurrets.get(this.lstTurrets.size() - 1).setLocation(new Location(e.getX(), e.getY()));
538 this.cost = -30;
539 }
540 else {
541 this.cost = 0;
542 }
543 }
544 else if (e.getButton() == 3) {
545 if (this.resources >= 50) {
546 this.resources -= 50;
547 LastDefenseMain.resUsed += 50;
548 this.addObject(new Shield("ShieldX", this.shield, 200, 100));
549 this.lstTurrets.get(this.lstTurrets.size() - 1).setLocation(new Location(e.getX(), e.getY()));
550 this.cost = -50;
551 }
552 else {
553 this.cost = 0;
554 }
555 }
556 if (this.cost != 0) {
557 this.showCost = true;
558 this.timeShowingCost = System.currentTimeMillis();
559 break;
560 }
561 break;
562 }
563 }
564 break;
565 }
566 case MsgBox: {
567 if (this.wndMessage.getMember("button").isClicked(e.getX(), e.getY())) {
568 this.auxState = AuxState.None;
569 break;
570 }
571 break;
572 }
573 }
574 }
575
576 private synchronized void handleMouseRelease(final MouseEvent e) {
577 }
578
579 private synchronized void handleKeyboardInput(final KeyEvent e) {
580 if (this.selectedText != null) {
581 this.selectedText.handleEvent(e);
582 }
583 else if (e.getKeyCode() == 27) {
584 if (this.gameState == GameState.Game || this.gameState == GameState.Info) {
585 this.gameState = GameState.Main;
586 this.showCost = false;
587 }
588 else {
589 this.done = true;
590 }
591 }
592 else if (e.getKeyCode() == 83) {
593 this.showFps = !this.showFps;
594 }
595 }
596
597 @Override
598 public void mousePressed(final MouseEvent e) {
599 this.handleMouseInput(e);
600 }
601
602 @Override
603 public void mouseReleased(final MouseEvent e) {
604 this.handleMouseRelease(e);
605 }
606
607 @Override
608 public void mouseEntered(final MouseEvent e) {
609 }
610
611 @Override
612 public void mouseExited(final MouseEvent e) {
613 }
614
615 @Override
616 public void mouseClicked(final MouseEvent e) {
617 }
618
619 @Override
620 public void keyTyped(final KeyEvent e) {
621 }
622
623 @Override
624 public synchronized void keyPressed(final KeyEvent e) {
625 this.handleKeyboardInput(e);
626 }
627
628 @Override
629 public void keyReleased(final KeyEvent e) {
630 }
631
632 private void selectText(final Textbox text) {
633 if (this.selectedText != null) {
634 this.selectedText.setSelected(false);
635 }
636 if ((this.selectedText = text) != null) {
637 text.setSelected(true);
638 }
639 }
640
641 public static void main(final String[] args) {
642 try {
643 final PrintStream st = new PrintStream(new FileOutputStream("err.txt", true));
644 System.setErr(st);
645 System.setOut(st);
646 System.out.println("-----[ Session started on " + Utils.dateString() + " ]-----");
647 final GraphicsEnvironment env = GraphicsEnvironment.getLocalGraphicsEnvironment();
648 final GraphicsDevice device = env.getDefaultScreenDevice();
649 new LastDefenseMain(device);
650 }
651 catch (Exception e) {
652 e.printStackTrace();
653 }
654 System.exit(0);
655 }
656
657 public enum AuxState {
658 None,
659 MsgBox
660 }
661
662 public enum GameState {
663 Main,
664 Info,
665 Credits,
666 Game
667 }
668}
Note: See TracBrowser for help on using the repository browser.