-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #25 from gal11002/master
Master into William-C
- Loading branch information
Showing
14 changed files
with
481 additions
and
110 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,9 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<classpath> | ||
<classpathentry kind="src" path="src"/> | ||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.7"/> | ||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/> | ||
<classpathentry kind="lib" path="hamcrest-core-1.3.jar"/> | ||
<classpathentry kind="lib" path="junit-4.11.jar"/> | ||
<classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/4"/> | ||
<classpathentry kind="output" path="bin"/> | ||
</classpath> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,11 @@ | ||
eclipse.preferences.version=1 | ||
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled | ||
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7 | ||
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6 | ||
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve | ||
org.eclipse.jdt.core.compiler.compliance=1.7 | ||
org.eclipse.jdt.core.compiler.compliance=1.6 | ||
org.eclipse.jdt.core.compiler.debug.lineNumber=generate | ||
org.eclipse.jdt.core.compiler.debug.localVariable=generate | ||
org.eclipse.jdt.core.compiler.debug.sourceFile=generate | ||
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error | ||
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error | ||
org.eclipse.jdt.core.compiler.source=1.7 | ||
org.eclipse.jdt.core.compiler.source=1.6 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,30 @@ | ||
merchant 1 | ||
water 3 | ||
armor 5 | ||
food 10 | ||
Water 2 | ||
Candy 5 | ||
Apple 7 | ||
Bread 3 | ||
Cake 14 | ||
Jerky 9 | ||
merchant 2 | ||
wood 3 | ||
tarp 6 | ||
PigIron 19 | ||
HighQualityIron 25 | ||
Steel 29 | ||
WoodPlanks 10 | ||
HighQualityWood 18 | ||
FairyTreeWood 40 | ||
WornSword 23 | ||
IronSword 29 | ||
SteelSword 38 | ||
FairySteelSword 95 | ||
BlessedIronDaggerofPig 50000 | ||
merchant 3 | ||
glass 3 | ||
tape 13 | ||
rope 5 | ||
LooseGems 60 | ||
FineCutDiamond 70 | ||
SilverBracelets 85 | ||
SilverNecklace 93 | ||
SilverEmeraldRing 100 | ||
GoldBracelets 84 | ||
GoldNecklace 103 | ||
GoldSapphireRing 133 | ||
GoldDiamondCrown 210 | ||
ExpensiveJewlery? 500 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
package sprites; | ||
|
||
import java.awt.image.BufferedImage; | ||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
|
||
public class Animation { | ||
|
||
private int frameCount; // Counts ticks for change | ||
private int frameDelay; // frame delay 1-12 (You will have to play around with this) | ||
private int currentFrame; // animations current frame | ||
private int animationDirection; // animation direction (i.e counting forward or backward) | ||
private int totalFrames; // total amount of frames for your animation | ||
|
||
private boolean stopped; // has animations stopped | ||
|
||
private List<Frame> frames = new ArrayList<Frame>(); // Arraylist of frames | ||
|
||
public Animation(BufferedImage[] frames, int frameDelay) { | ||
this.frameDelay = frameDelay; | ||
this.stopped = true; | ||
|
||
for (int i = 0; i < frames.length; i++) { | ||
addFrame(frames[i], frameDelay); | ||
} | ||
|
||
this.frameCount = 0; | ||
this.frameDelay = frameDelay; | ||
this.currentFrame = 0; | ||
this.animationDirection = 1; | ||
this.totalFrames = this.frames.size(); | ||
|
||
} | ||
|
||
public void start() { | ||
if (!stopped) { | ||
return; | ||
} | ||
|
||
if (frames.size() == 0) { | ||
return; | ||
} | ||
|
||
stopped = false; | ||
} | ||
|
||
public void stop() { | ||
if (frames.size() == 0) { | ||
return; | ||
} | ||
|
||
stopped = true; | ||
} | ||
|
||
public void restart() { | ||
if (frames.size() == 0) { | ||
return; | ||
} | ||
|
||
stopped = false; | ||
currentFrame = 0; | ||
} | ||
|
||
public void reset() { | ||
this.stopped = true; | ||
this.frameCount = 0; | ||
this.currentFrame = 0; | ||
} | ||
|
||
private void addFrame(BufferedImage frame, int duration) { | ||
if (duration <= 0) { | ||
System.err.println("Invalid duration: " + duration); | ||
throw new RuntimeException("Invalid duration: " + duration); | ||
} | ||
|
||
frames.add(new Frame(frame, duration)); | ||
currentFrame = 0; | ||
} | ||
|
||
public BufferedImage getSprite() { | ||
return frames.get(currentFrame).getFrame(); | ||
} | ||
|
||
public void update() { | ||
if (!stopped) { | ||
frameCount++; | ||
|
||
if (frameCount > frameDelay) { | ||
frameCount = 0; | ||
currentFrame += animationDirection; | ||
|
||
if (currentFrame > totalFrames - 1) { | ||
currentFrame = 0; | ||
} | ||
else if (currentFrame < 0) { | ||
currentFrame = totalFrames - 1; | ||
} | ||
} | ||
} | ||
|
||
} | ||
|
||
} |
Oops, something went wrong.