Browse Source

upstream updates

Chris Cromer 1 year ago
parent
commit
3bf267f3fc

+ 2
- 0
.gitignore View File

@@ -3,3 +3,5 @@
3 3
 target/
4 4
 *.o
5 5
 DroidQuest
6
+.idea/
7
+*.iml

+ 1
- 1
Makefile View File

@@ -4,7 +4,7 @@ MV = mvn
4 4
 CFLAGS=-Wall -Werror -ggdb
5 5
 
6 6
 BIN=DroidQuest
7
-JAR=dq-2.7.jar
7
+JAR=dq-2.8.jar
8 8
 
9 9
 all:
10 10
 	$(CC) $(CFLAGS) dq.c -o dq.o

+ 40
- 1
README View File

@@ -3,11 +3,50 @@ Droid Quest
3 3
 
4 4
 A Java recreation of the classic game Robot Odyssey I
5 5
 
6
+=======
7
+Build with:
8
+
9
+    mvn install
10
+
11
+Run the game:
12
+
13
+    MacOSX / Linux: ./start.sh
14
+    Windows: start.bat (IN PROGRESS)
15
+OR
16
+    java -jar target/dq-2.8.jar
17
+
18
+Controls:
19
+
20
+    / - contextual help
21
+    arrows - normal movement
22
+    control + arrows - fine-grained movement [OS X: command + arrows]
23
+    space - pickup/drop
24
+    C - game cursor
25
+    H - hot cursor
26
+    S - solder pen
27
+    R - toggle radio
28
+    P - paintbrush
29
+    T - toolbox
30
+    [, ] - rotate device
31
+    F - flip
32
+    L - load small chip
33
+    E - enter robot
34
+    X - exit robot
35
+
36
+    Cheat/debug:
37
+
38
+    shift + arrows - move rooms
39
+    M - dump memory usage
40
+
41
+Note: On OS X, control + arrow-keys are bound to Apple's "Mission Control".  I switched to the 'shortcut' modifier which is control on windows and command on OS X.  Alternatively, you can disable
42
+built in OS X shortcuts via System Preferences -> Keyboard -> Shorcuts.
43
+
44
+
6 45
 Copyright (c) 2000 Thomas Foote
7 46
 
8 47
 Optimization to compile, install, and run under linux:
9 48
 
10
-Copyright (c) 2015 Chris Cromer
49
+Copyright (c) 2015-2016 Chris Cromer
11 50
 
12 51
 Permission is hereby granted, free of charge, to any person obtaining
13 52
 a copy of this software and associated documentation files (the

+ 1
- 1
dq.c View File

@@ -1,6 +1,6 @@
1 1
 #include <stdlib.h>
2 2
 
3 3
 int main() {
4
-	system("java -jar /usr/share/DroidQuest/dq-2.7.jar");
4
+	system("java -jar /usr/share/DroidQuest/dq-2.8.jar");
5 5
 	return 0;
6 6
 }

+ 30
- 35
pom.xml View File

@@ -4,7 +4,7 @@
4 4
 
5 5
 	<groupId>com.droidquest</groupId>
6 6
 	<artifactId>dq</artifactId>
7
-	<version>2.7</version>
7
+	<version>2.8</version>
8 8
 	<packaging>jar</packaging>
9 9
 
10 10
 	<name>DroidQuest</name>
@@ -14,39 +14,34 @@
14 14
 		<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
15 15
 	</properties>
16 16
 
17
-	<build>
18
-		<sourceDirectory>src</sourceDirectory>
19
-		<plugins>
20
-			<plugin>
21
-				<!-- Build an executable JAR -->
22
-				<groupId>org.apache.maven.plugins</groupId>
23
-				<artifactId>maven-jar-plugin</artifactId>
24
-				<version>2.4</version>
25
-				<configuration>
26
-					<archive>
27
-						<manifest>
28
-							<addClasspath>true</addClasspath>
29
-							<classpathPrefix>lib/</classpathPrefix>
30
-							<mainClass>com.droidquest.DQ</mainClass>
31
-						</manifest>
32
-					</archive>
33
-				</configuration>
34
-			</plugin>
35
-		</plugins>
36
-	</build>
17
+    <build>
18
+        <sourceDirectory>src</sourceDirectory>
19
+        <plugins>
20
+            <plugin>
21
+                <groupId>org.apache.maven.plugins</groupId>
22
+                <artifactId>maven-compiler-plugin</artifactId>
23
+                <version>3.3</version>
24
+                <configuration>
25
+                    <source>1.6</source>
26
+                    <target>1.6</target>
27
+                </configuration>
28
+            </plugin>
29
+            <plugin>
30
+              <!-- Build an executable JAR -->
31
+              <groupId>org.apache.maven.plugins</groupId>
32
+              <artifactId>maven-jar-plugin</artifactId>
33
+              <version>2.4</version>
34
+              <configuration>
35
+                <archive>
36
+                  <manifest>
37
+                    <addClasspath>true</addClasspath>
38
+                    <classpathPrefix>lib/</classpathPrefix>
39
+                    <mainClass>com.droidquest.DQ</mainClass>
40
+                  </manifest>
41
+                </archive>
42
+              </configuration>
43
+            </plugin>
44
+        </plugins>
45
+    </build>
37 46
 
38
-	<dependencies>
39
-		<!--
40
-		<dependency>
41
-			<groupId>ch.qos.logback</groupId>
42
-			<artifactId>logback-classic</artifactId>
43
-			<version>1.0.13</version>
44
-		</dependency>
45
-		<dependency>
46
-			<groupId>com.google.guava</groupId>
47
-			<artifactId>guava</artifactId>
48
-			<version>16.0</version>
49
-		</dependency>
50
-	-->
51
-	</dependencies>
52 47
 </project>

+ 9
- 9
src/com/droidquest/avatars/Player.java View File

@@ -15,7 +15,7 @@ import java.awt.event.KeyEvent;
15 15
 public class Player extends Item implements Avatar {
16 16
 
17 17
     private int keyRepeatRate = 5;
18
-
18
+    private int shortcut_modifier = Toolkit.getDefaultToolkit ().getMenuShortcutKeyMask();
19 19
 
20 20
     protected boolean handleSaveSmallChip() {
21 21
         return false;
@@ -363,16 +363,16 @@ public class Player extends Item implements Avatar {
363 363
         else if (e.getKeyCode() == KeyEvent.VK_SLASH && handleHelp()) {
364 364
             return false;
365 365
         }
366
-        else if (e.getKeyCode() == KeyEvent.VK_RIGHT && handleMoveRight(e.isShiftDown(), e.isControlDown())) {
366
+        else if (e.getKeyCode() == KeyEvent.VK_RIGHT && handleMoveRight(e.isShiftDown(), (e.getModifiers() & shortcut_modifier) > 0)) {
367 367
             return true;
368 368
         }
369
-        else if (e.getKeyCode() == KeyEvent.VK_LEFT && handleMoveLeft(e.isShiftDown(), e.isControlDown())) {
369
+        else if (e.getKeyCode() == KeyEvent.VK_LEFT && handleMoveLeft(e.isShiftDown(), (e.getModifiers() & shortcut_modifier) > 0)) {
370 370
             return true;
371 371
         }
372
-        else if (e.getKeyCode() == KeyEvent.VK_UP && handleMoveUp(e.isShiftDown(), e.isControlDown())) {
372
+        else if (e.getKeyCode() == KeyEvent.VK_UP && handleMoveUp(e.isShiftDown(), (e.getModifiers() & shortcut_modifier) > 0)) {
373 373
             return true;
374 374
         }
375
-        else if (e.getKeyCode() == KeyEvent.VK_DOWN && handleMoveDown(e.isShiftDown(), e.isControlDown())) {
375
+        else if (e.getKeyCode() == KeyEvent.VK_DOWN && handleMoveDown(e.isShiftDown(), (e.getModifiers() & shortcut_modifier) > 0)) {
376 376
             return true;
377 377
         }
378 378
         else if (e.getKeyCode() == KeyEvent.VK_SPACE && handlePickupDrop()) {
@@ -456,22 +456,22 @@ public class Player extends Item implements Avatar {
456 456
 
457 457
     public boolean KeyDown(KeyEvent e) {
458 458
         if (e.getKeyCode() == KeyEvent.VK_RIGHT) {
459
-            if (handleRepeatRight(e.isControlDown())) {
459
+            if (handleRepeatRight((e.getModifiers() & shortcut_modifier) > 0)) {
460 460
                 return true;
461 461
             }
462 462
         }
463 463
         else if (e.getKeyCode() == KeyEvent.VK_LEFT) {
464
-            if (handleRepeatLeft(e.isControlDown())) {
464
+            if (handleRepeatLeft((e.getModifiers() & shortcut_modifier) > 0)) {
465 465
                 return true;
466 466
             }
467 467
         }
468 468
         else if (e.getKeyCode() == KeyEvent.VK_UP) {
469
-            if (handleRepeatUp(e.isControlDown())) {
469
+            if (handleRepeatUp((e.getModifiers() & shortcut_modifier) > 0)) {
470 470
                 return true;
471 471
             }
472 472
         }
473 473
         else if (e.getKeyCode() == KeyEvent.VK_DOWN) {
474
-            if (handleRepeatDown(e.isControlDown())) {
474
+            if (handleRepeatDown((e.getModifiers() & shortcut_modifier) > 0)) {
475 475
                 return true;
476 476
             }
477 477
         }

+ 10
- 8
src/com/droidquest/avatars/Remote.java View File

@@ -8,6 +8,8 @@ import java.awt.event.KeyEvent;
8 8
 import java.awt.image.BufferedImage;
9 9
 
10 10
 public class Remote extends Item implements Avatar {
11
+    private int shortcut_modifier = Toolkit.getDefaultToolkit ().getMenuShortcutKeyMask();
12
+
11 13
     public Remote() {
12 14
         width = 4;
13 15
         height = 20;
@@ -98,28 +100,28 @@ public class Remote extends Item implements Avatar {
98 100
         }
99 101
         else if (e.getKeyCode() == KeyEvent.VK_RIGHT) {
100 102
             if (carriedBy == null) {
101
-                moveRight(e.isControlDown());
103
+                moveRight((e.getModifiers() & shortcut_modifier) > 0);
102 104
             }
103 105
             repeating = 0;
104 106
             return true;
105 107
         }
106 108
         else if (e.getKeyCode() == KeyEvent.VK_LEFT) {
107 109
             if (carriedBy == null) {
108
-                moveLeft(e.isControlDown());
110
+                moveLeft((e.getModifiers() & shortcut_modifier) > 0);
109 111
             }
110 112
             repeating = 0;
111 113
             return true;
112 114
         }
113 115
         else if (e.getKeyCode() == KeyEvent.VK_UP) {
114 116
             if (carriedBy == null) {
115
-                moveUp(e.isControlDown());
117
+                moveUp((e.getModifiers() & shortcut_modifier) > 0);
116 118
             }
117 119
             repeating = 0;
118 120
             return true;
119 121
         }
120 122
         else if (e.getKeyCode() == KeyEvent.VK_DOWN) {
121 123
             if (carriedBy == null) {
122
-                moveDown(e.isControlDown());
124
+                moveDown((e.getModifiers() & shortcut_modifier) > 0);
123 125
             }
124 126
             repeating = 0;
125 127
             return true;
@@ -134,7 +136,7 @@ public class Remote extends Item implements Avatar {
134 136
         if (e.getKeyCode() == KeyEvent.VK_RIGHT) {
135 137
             repeating++;
136 138
             if (repeating > 10) {
137
-                moveRight(e.isControlDown());
139
+                moveRight((e.getModifiers() & shortcut_modifier) > 0);
138 140
                 return true;
139 141
             }
140 142
             return false;
@@ -142,7 +144,7 @@ public class Remote extends Item implements Avatar {
142 144
         else if (e.getKeyCode() == KeyEvent.VK_LEFT) {
143 145
             repeating++;
144 146
             if (repeating > 10) {
145
-                moveLeft(e.isControlDown());
147
+                moveLeft((e.getModifiers() & shortcut_modifier) > 0);
146 148
                 return true;
147 149
             }
148 150
             return false;
@@ -150,7 +152,7 @@ public class Remote extends Item implements Avatar {
150 152
         else if (e.getKeyCode() == KeyEvent.VK_UP) {
151 153
             repeating++;
152 154
             if (repeating > 10) {
153
-                moveUp(e.isControlDown());
155
+                moveUp((e.getModifiers() & shortcut_modifier) > 0);
154 156
                 return true;
155 157
             }
156 158
             return false;
@@ -158,7 +160,7 @@ public class Remote extends Item implements Avatar {
158 160
         else if (e.getKeyCode() == KeyEvent.VK_DOWN) {
159 161
             repeating++;
160 162
             if (repeating > 10) {
161
-                moveDown(e.isControlDown());
163
+                moveDown((e.getModifiers() & shortcut_modifier) > 0);
162 164
                 return true;
163 165
             }
164 166
             return false;

+ 13
- 8
src/com/droidquest/avatars/SolderingPen.java View File

@@ -18,6 +18,7 @@ import java.util.ArrayList;
18 18
 public class SolderingPen extends Device implements Avatar {
19 19
     private boolean hot;
20 20
     private Port currentPort = null; // Port that Soldering pen is currently over
21
+    private int shortcut_modifier = Toolkit.getDefaultToolkit ().getMenuShortcutKeyMask();
21 22
 
22 23
     public SolderingPen() {
23 24
         width = 22;
@@ -313,28 +314,28 @@ public class SolderingPen extends Device implements Avatar {
313 314
         }
314 315
         else if (e.getKeyCode() == KeyEvent.VK_RIGHT) {
315 316
             if (carriedBy == null) {
316
-                moveRight(e.isControlDown());
317
+                moveRight((e.getModifiers() & shortcut_modifier) > 0);
317 318
             }
318 319
             repeating = 0;
319 320
             return true;
320 321
         }
321 322
         else if (e.getKeyCode() == KeyEvent.VK_LEFT) {
322 323
             if (carriedBy == null) {
323
-                moveLeft(e.isControlDown());
324
+                moveLeft((e.getModifiers() & shortcut_modifier) > 0);
324 325
             }
325 326
             repeating = 0;
326 327
             return true;
327 328
         }
328 329
         else if (e.getKeyCode() == KeyEvent.VK_UP) {
329 330
             if (carriedBy == null) {
330
-                moveUp(e.isControlDown());
331
+                moveUp((e.getModifiers() & shortcut_modifier) > 0);
331 332
             }
332 333
             repeating = 0;
333 334
             return true;
334 335
         }
335 336
         else if (e.getKeyCode() == KeyEvent.VK_DOWN) {
336 337
             if (carriedBy == null) {
337
-                moveDown(e.isControlDown());
338
+                moveDown((e.getModifiers() & shortcut_modifier) > 0);
338 339
             }
339 340
             repeating = 0;
340 341
             return true;
@@ -358,7 +359,7 @@ public class SolderingPen extends Device implements Avatar {
358 359
         if (e.getKeyCode() == KeyEvent.VK_RIGHT) {
359 360
             repeating++;
360 361
             if (repeating > 10) {
361
-                moveRight(e.isControlDown());
362
+                moveRight((e.getModifiers() & shortcut_modifier) > 0);
362 363
                 return true;
363 364
             }
364 365
             return false;
@@ -366,7 +367,7 @@ public class SolderingPen extends Device implements Avatar {
366 367
         else if (e.getKeyCode() == KeyEvent.VK_LEFT) {
367 368
             repeating++;
368 369
             if (repeating > 10) {
369
-                moveLeft(e.isControlDown());
370
+                moveLeft((e.getModifiers() & shortcut_modifier) > 0);
370 371
                 return true;
371 372
             }
372 373
             return false;
@@ -374,7 +375,7 @@ public class SolderingPen extends Device implements Avatar {
374 375
         else if (e.getKeyCode() == KeyEvent.VK_UP) {
375 376
             repeating++;
376 377
             if (repeating > 10) {
377
-                moveUp(e.isControlDown());
378
+                moveUp((e.getModifiers() & shortcut_modifier) > 0);
378 379
                 return true;
379 380
             }
380 381
             return false;
@@ -382,7 +383,7 @@ public class SolderingPen extends Device implements Avatar {
382 383
         else if (e.getKeyCode() == KeyEvent.VK_DOWN) {
383 384
             repeating++;
384 385
             if (repeating > 10) {
385
-                moveDown(e.isControlDown());
386
+                moveDown((e.getModifiers() & shortcut_modifier) > 0);
386 387
                 return true;
387 388
             }
388 389
             return false;
@@ -428,6 +429,8 @@ public class SolderingPen extends Device implements Avatar {
428 429
             }
429 430
         }
430 431
 
432
+        CheckPort();
433
+
431 434
         level.roomdisplay.dq.selectCursor();
432 435
         return true;
433 436
     }
@@ -505,6 +508,8 @@ public class SolderingPen extends Device implements Avatar {
505 508
 
506 509
         handleRemote();
507 510
 
511
+        CheckPort();
512
+
508 513
         return true;
509 514
     }
510 515
 

+ 1
- 1
src/com/droidquest/items/AutoWire.java View File

@@ -113,7 +113,7 @@ public class AutoWire extends Item {
113 113
 
114 114
         if (animation == 1) {
115 115
             if (portdevices[0].ports[0].myWire == null) { // Wiring
116
-				portdevices[0].ports[0].myWire = new Wire(chip.ports[0], portdevices[0].ports[0]);
116
+                portdevices[0].ports[0].myWire = new Wire(chip.ports[0], portdevices[0].ports[0]);
117 117
             }
118 118
             else { // Unwiring
119 119
                 portdevices[0].ports[0].myWire.Remove();

+ 1
- 1
src/com/droidquest/items/GateKeeper.java View File

@@ -64,7 +64,7 @@ public class GateKeeper extends Item {
64 64
 
65 65
     public void Animate() {
66 66
         if (behavior == 1) {
67
-            if (x != goToX && y != goToY) {
67
+            if (x != goToX || y != goToY) {
68 68
                 if (x != goToX) {
69 69
                     int diff = Math.abs(goToX - x);
70 70
                     int dir = diff / (goToX - x);

+ 5
- 3
src/com/droidquest/items/Sentry.java View File

@@ -240,9 +240,11 @@ public class Sentry extends Item {
240 240
 
241 241
         if (behavior == -1) {
242 242
             if (carrying == null) {
243
-                x = robot.x + robot.width / 2 - width / 2;
244
-                y = robot.y + robot.height / 2 - height / 2;
245
-                PicksUp(robot);
243
+                if(robot != null) {
244
+                    x = robot.x + robot.width / 2 - width / 2;
245
+                    y = robot.y + robot.height / 2 - height / 2;
246
+                    PicksUp(robot);
247
+                }
246 248
             }
247 249
         }
248 250
 

+ 1
- 1
src/com/droidquest/levels/MainMenu.java View File

@@ -144,7 +144,7 @@ public class MainMenu extends Level {
144 144
             room.AddTextBox("Saved Games", 9 * 28, 10 * 32, 80);
145 145
             room.AddTextBox("Games", 450, 6 * 32 + 8, 500);
146 146
             room.AddArrow(559, 6 * 32, Arrow.DIR_RIGHT, 28, Color.white);
147
-            room.AddTextBox("{000,000,000} Version 2.7", 0, 16, 500);
147
+            room.AddTextBox("{000,000,000} Version 2.8", 0, 16, 500);
148 148
             if (cheatmode) {
149 149
                 room.AddTextBox("{BIG} CHEAT ENABLED!", 91, 8 * 32, 500);
150 150
             }

+ 1
- 1
src/com/droidquest/materials/BatteryIn.java View File

@@ -13,7 +13,7 @@ import com.droidquest.levels.Level;
13 13
 public class BatteryIn extends Material {
14 14
     // Charges the Battery when an Energy Crystal is passed over it.
15 15
 
16
-    public void BatteryIn() {
16
+    public BatteryIn() {
17 17
         passable = true;
18 18
         GenerateIcons();
19 19
     }

+ 1
- 0
start.bat View File

@@ -0,0 +1 @@
1
+java -jar "target\dq-2.8.jar"

+ 45
- 0
start.sh View File

@@ -0,0 +1,45 @@
1
+#/bin/sh
2
+
3
+RUNPRG="java"
4
+if ! type -p "${RUNPRG}" > /dev/null;
5
+then
6
+  if [ -n "${JAVA_HOME}" ];
7
+  then
8
+    RUNPRG="${JAVA_HOME}/bin/java"
9
+    if [ ! -x "${RUNPRG}" ];
10
+    then
11
+      echo "JAVA_HOME set, but unable to find java.  Please check your java installation."
12
+      exit 1
13
+    fi
14
+  else
15
+    echo "Java 1.6 or newer needed for DQ.  Must be in PATH or JAVA_HOME set."
16
+    exit 1
17
+  fi
18
+fi
19
+
20
+
21
+if [ -f "target/dq-2.8.jar" ];
22
+then
23
+  echo "Starting DQ."
24
+  ${RUNPRG} -jar "target/dq-2.8.jar"
25
+else
26
+  echo "No jar found, building DQ before running."
27
+  MVNPRG="mvn"
28
+  if ! type -p "${MVNPRG}" > /dev/null;
29
+  then
30
+    if [ -n "${MAVEN_HOME}" ];
31
+    then
32
+      MVNPRG="${MAVEN_HOME}/bin/mvn"
33
+      if [ ! -x "${MVNPRG}" ];
34
+      then
35
+        echo "MAVEN_HOME set, but unable to find mvn executable. Please check your maven installation."
36
+        exit 1
37
+      fi
38
+    else
39
+      echo "Maven required to build DQ.  See maven.apache.org to download."
40
+      exit 1
41
+    fi
42
+  fi
43
+  ${MVNPRG} package
44
+  ${MVNPRG} exec:java -Dexec.mainClass=com.droidquest.DQ
45
+fi

Loading…
Cancel
Save