Merge branch 'patricksurry-master'

This commit is contained in:
cognitivegears 2016-10-28 18:29:00 -05:00
commit e9627b5554
5 changed files with 75 additions and 43 deletions

View File

@ -3,13 +3,42 @@ DroidQuest
A Java recreation of the classic game Robot Odyssey I A Java recreation of the classic game Robot Odyssey I
Compile command: Build with:
mvn compile mvn install
Run the game: Run the game:
./start_game.sh ./start_game.sh
OR
java -jar target/dq-1.1-SNAPSHOT.jar
Controls:
/ - contextual help
arrows - normal movement
control + arrows - fine-grained movement [OS X: command + arrows]
space - pickup/drop
C - game cursor
H - hot cursor
S - solder pen
R - toggle radio
P - paintbrush
T - toolbox
[, ] - rotate device
F - flip
L - load small chip
E - enter robot
X - exit robot
Cheat/debug:
shift + arrows - move rooms
M - dump memory usage
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
built in OS X shortcuts via System Preferences -> Keyboard -> Shorcuts.
Copyright (c) 2000 Thomas Foote Copyright (c) 2000 Thomas Foote

30
pom.xml
View File

@ -26,21 +26,21 @@
<target>5</target> <target>5</target>
</configuration> </configuration>
</plugin> </plugin>
<plugin>
<!-- Build an executable JAR -->
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>2.4</version>
<configuration>
<archive>
<manifest>
<addClasspath>true</addClasspath>
<classpathPrefix>lib/</classpathPrefix>
<mainClass>com.droidquest.DQ</mainClass>
</manifest>
</archive>
</configuration>
</plugin>
</plugins> </plugins>
</build> </build>
<dependencies>
<!--
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<version>1.0.13</version>
</dependency>
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>16.0</version>
</dependency>
-->
</dependencies>
</project> </project>

View File

@ -15,7 +15,7 @@ import java.awt.event.KeyEvent;
public class Player extends Item implements Avatar { public class Player extends Item implements Avatar {
private int keyRepeatRate = 5; private int keyRepeatRate = 5;
private int shortcut_modifier = Toolkit.getDefaultToolkit ().getMenuShortcutKeyMask();
protected boolean handleSaveSmallChip() { protected boolean handleSaveSmallChip() {
return false; return false;
@ -362,16 +362,16 @@ public class Player extends Item implements Avatar {
else if (e.getKeyCode() == KeyEvent.VK_SLASH && handleHelp()) { else if (e.getKeyCode() == KeyEvent.VK_SLASH && handleHelp()) {
return false; return false;
} }
else if (e.getKeyCode() == KeyEvent.VK_RIGHT && handleMoveRight(e.isShiftDown(), e.isControlDown())) { else if (e.getKeyCode() == KeyEvent.VK_RIGHT && handleMoveRight(e.isShiftDown(), (e.getModifiers() & shortcut_modifier) > 0)) {
return true; return true;
} }
else if (e.getKeyCode() == KeyEvent.VK_LEFT && handleMoveLeft(e.isShiftDown(), e.isControlDown())) { else if (e.getKeyCode() == KeyEvent.VK_LEFT && handleMoveLeft(e.isShiftDown(), (e.getModifiers() & shortcut_modifier) > 0)) {
return true; return true;
} }
else if (e.getKeyCode() == KeyEvent.VK_UP && handleMoveUp(e.isShiftDown(), e.isControlDown())) { else if (e.getKeyCode() == KeyEvent.VK_UP && handleMoveUp(e.isShiftDown(), (e.getModifiers() & shortcut_modifier) > 0)) {
return true; return true;
} }
else if (e.getKeyCode() == KeyEvent.VK_DOWN && handleMoveDown(e.isShiftDown(), e.isControlDown())) { else if (e.getKeyCode() == KeyEvent.VK_DOWN && handleMoveDown(e.isShiftDown(), (e.getModifiers() & shortcut_modifier) > 0)) {
return true; return true;
} }
else if (e.getKeyCode() == KeyEvent.VK_SPACE && handlePickupDrop()) { else if (e.getKeyCode() == KeyEvent.VK_SPACE && handlePickupDrop()) {
@ -455,22 +455,22 @@ public class Player extends Item implements Avatar {
public boolean KeyDown(KeyEvent e) { public boolean KeyDown(KeyEvent e) {
if (e.getKeyCode() == KeyEvent.VK_RIGHT) { if (e.getKeyCode() == KeyEvent.VK_RIGHT) {
if (handleRepeatRight(e.isControlDown())) { if (handleRepeatRight((e.getModifiers() & shortcut_modifier) > 0)) {
return true; return true;
} }
} }
else if (e.getKeyCode() == KeyEvent.VK_LEFT) { else if (e.getKeyCode() == KeyEvent.VK_LEFT) {
if (handleRepeatLeft(e.isControlDown())) { if (handleRepeatLeft((e.getModifiers() & shortcut_modifier) > 0)) {
return true; return true;
} }
} }
else if (e.getKeyCode() == KeyEvent.VK_UP) { else if (e.getKeyCode() == KeyEvent.VK_UP) {
if (handleRepeatUp(e.isControlDown())) { if (handleRepeatUp((e.getModifiers() & shortcut_modifier) > 0)) {
return true; return true;
} }
} }
else if (e.getKeyCode() == KeyEvent.VK_DOWN) { else if (e.getKeyCode() == KeyEvent.VK_DOWN) {
if (handleRepeatDown(e.isControlDown())) { if (handleRepeatDown((e.getModifiers() & shortcut_modifier) > 0)) {
return true; return true;
} }
} }

View File

@ -8,6 +8,8 @@ import java.awt.event.KeyEvent;
import java.awt.image.BufferedImage; import java.awt.image.BufferedImage;
public class Remote extends Item implements Avatar { public class Remote extends Item implements Avatar {
private int shortcut_modifier = Toolkit.getDefaultToolkit ().getMenuShortcutKeyMask();
public Remote() { public Remote() {
width = 4; width = 4;
height = 20; height = 20;
@ -98,28 +100,28 @@ public class Remote extends Item implements Avatar {
} }
else if (e.getKeyCode() == KeyEvent.VK_RIGHT) { else if (e.getKeyCode() == KeyEvent.VK_RIGHT) {
if (carriedBy == null) { if (carriedBy == null) {
moveRight(e.isControlDown()); moveRight((e.getModifiers() & shortcut_modifier) > 0);
} }
repeating = 0; repeating = 0;
return true; return true;
} }
else if (e.getKeyCode() == KeyEvent.VK_LEFT) { else if (e.getKeyCode() == KeyEvent.VK_LEFT) {
if (carriedBy == null) { if (carriedBy == null) {
moveLeft(e.isControlDown()); moveLeft((e.getModifiers() & shortcut_modifier) > 0);
} }
repeating = 0; repeating = 0;
return true; return true;
} }
else if (e.getKeyCode() == KeyEvent.VK_UP) { else if (e.getKeyCode() == KeyEvent.VK_UP) {
if (carriedBy == null) { if (carriedBy == null) {
moveUp(e.isControlDown()); moveUp((e.getModifiers() & shortcut_modifier) > 0);
} }
repeating = 0; repeating = 0;
return true; return true;
} }
else if (e.getKeyCode() == KeyEvent.VK_DOWN) { else if (e.getKeyCode() == KeyEvent.VK_DOWN) {
if (carriedBy == null) { if (carriedBy == null) {
moveDown(e.isControlDown()); moveDown((e.getModifiers() & shortcut_modifier) > 0);
} }
repeating = 0; repeating = 0;
return true; return true;
@ -134,7 +136,7 @@ public class Remote extends Item implements Avatar {
if (e.getKeyCode() == KeyEvent.VK_RIGHT) { if (e.getKeyCode() == KeyEvent.VK_RIGHT) {
repeating++; repeating++;
if (repeating > 10) { if (repeating > 10) {
moveRight(e.isControlDown()); moveRight((e.getModifiers() & shortcut_modifier) > 0);
return true; return true;
} }
return false; return false;
@ -142,7 +144,7 @@ public class Remote extends Item implements Avatar {
else if (e.getKeyCode() == KeyEvent.VK_LEFT) { else if (e.getKeyCode() == KeyEvent.VK_LEFT) {
repeating++; repeating++;
if (repeating > 10) { if (repeating > 10) {
moveLeft(e.isControlDown()); moveLeft((e.getModifiers() & shortcut_modifier) > 0);
return true; return true;
} }
return false; return false;
@ -150,7 +152,7 @@ public class Remote extends Item implements Avatar {
else if (e.getKeyCode() == KeyEvent.VK_UP) { else if (e.getKeyCode() == KeyEvent.VK_UP) {
repeating++; repeating++;
if (repeating > 10) { if (repeating > 10) {
moveUp(e.isControlDown()); moveUp((e.getModifiers() & shortcut_modifier) > 0);
return true; return true;
} }
return false; return false;
@ -158,7 +160,7 @@ public class Remote extends Item implements Avatar {
else if (e.getKeyCode() == KeyEvent.VK_DOWN) { else if (e.getKeyCode() == KeyEvent.VK_DOWN) {
repeating++; repeating++;
if (repeating > 10) { if (repeating > 10) {
moveDown(e.isControlDown()); moveDown((e.getModifiers() & shortcut_modifier) > 0);
return true; return true;
} }
return false; return false;

View File

@ -18,6 +18,7 @@ import java.util.ArrayList;
public class SolderingPen extends Device implements Avatar { public class SolderingPen extends Device implements Avatar {
private boolean hot; private boolean hot;
private Port currentPort = null; // Port that Soldering pen is currently over private Port currentPort = null; // Port that Soldering pen is currently over
private int shortcut_modifier = Toolkit.getDefaultToolkit ().getMenuShortcutKeyMask();
public SolderingPen() { public SolderingPen() {
width = 22; width = 22;
@ -313,28 +314,28 @@ public class SolderingPen extends Device implements Avatar {
} }
else if (e.getKeyCode() == KeyEvent.VK_RIGHT) { else if (e.getKeyCode() == KeyEvent.VK_RIGHT) {
if (carriedBy == null) { if (carriedBy == null) {
moveRight(e.isControlDown()); moveRight((e.getModifiers() & shortcut_modifier) > 0);
} }
repeating = 0; repeating = 0;
return true; return true;
} }
else if (e.getKeyCode() == KeyEvent.VK_LEFT) { else if (e.getKeyCode() == KeyEvent.VK_LEFT) {
if (carriedBy == null) { if (carriedBy == null) {
moveLeft(e.isControlDown()); moveLeft((e.getModifiers() & shortcut_modifier) > 0);
} }
repeating = 0; repeating = 0;
return true; return true;
} }
else if (e.getKeyCode() == KeyEvent.VK_UP) { else if (e.getKeyCode() == KeyEvent.VK_UP) {
if (carriedBy == null) { if (carriedBy == null) {
moveUp(e.isControlDown()); moveUp((e.getModifiers() & shortcut_modifier) > 0);
} }
repeating = 0; repeating = 0;
return true; return true;
} }
else if (e.getKeyCode() == KeyEvent.VK_DOWN) { else if (e.getKeyCode() == KeyEvent.VK_DOWN) {
if (carriedBy == null) { if (carriedBy == null) {
moveDown(e.isControlDown()); moveDown((e.getModifiers() & shortcut_modifier) > 0);
} }
repeating = 0; repeating = 0;
return true; return true;
@ -358,7 +359,7 @@ public class SolderingPen extends Device implements Avatar {
if (e.getKeyCode() == KeyEvent.VK_RIGHT) { if (e.getKeyCode() == KeyEvent.VK_RIGHT) {
repeating++; repeating++;
if (repeating > 10) { if (repeating > 10) {
moveRight(e.isControlDown()); moveRight((e.getModifiers() & shortcut_modifier) > 0);
return true; return true;
} }
return false; return false;
@ -366,7 +367,7 @@ public class SolderingPen extends Device implements Avatar {
else if (e.getKeyCode() == KeyEvent.VK_LEFT) { else if (e.getKeyCode() == KeyEvent.VK_LEFT) {
repeating++; repeating++;
if (repeating > 10) { if (repeating > 10) {
moveLeft(e.isControlDown()); moveLeft((e.getModifiers() & shortcut_modifier) > 0);
return true; return true;
} }
return false; return false;
@ -374,7 +375,7 @@ public class SolderingPen extends Device implements Avatar {
else if (e.getKeyCode() == KeyEvent.VK_UP) { else if (e.getKeyCode() == KeyEvent.VK_UP) {
repeating++; repeating++;
if (repeating > 10) { if (repeating > 10) {
moveUp(e.isControlDown()); moveUp((e.getModifiers() & shortcut_modifier) > 0);
return true; return true;
} }
return false; return false;
@ -382,7 +383,7 @@ public class SolderingPen extends Device implements Avatar {
else if (e.getKeyCode() == KeyEvent.VK_DOWN) { else if (e.getKeyCode() == KeyEvent.VK_DOWN) {
repeating++; repeating++;
if (repeating > 10) { if (repeating > 10) {
moveDown(e.isControlDown()); moveDown((e.getModifiers() & shortcut_modifier) > 0);
return true; return true;
} }
return false; return false;