-
Notifications
You must be signed in to change notification settings - Fork 4
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 #1 from chrisj42/practice
Practice
- Loading branch information
Showing
36 changed files
with
1,648 additions
and
39 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
Binary file not shown.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
player.png | ||
size: 128, 64 | ||
format: RGBA8888 | ||
filter: Linear,Linear | ||
repeat: none | ||
idle-down | ||
rotate: false | ||
xy: 0, 0 | ||
size: 24, 28 | ||
orig: 20, 26 | ||
offset: 0, -2 | ||
index: 1 | ||
idle-left | ||
rotate: false | ||
xy: 24, 0 | ||
size: 24, 28 | ||
orig: 16, 28 | ||
offset: 0, 0 | ||
index: 1 | ||
idle-right | ||
rotate: false | ||
xy: 48, 0 | ||
size: 24, 28 | ||
orig: 16, 28 | ||
offset: 0, 0 | ||
index: 1 | ||
idle-up | ||
rotate: false | ||
xy: 72, 0 | ||
size: 24, 28 | ||
orig: 20, 26 | ||
offset: 0, -2 | ||
index: 1 | ||
walk-down | ||
rotate: false | ||
xy: 96, 0 | ||
size: 24, 28 | ||
orig: 24, 28 | ||
offset: 0, 0 | ||
index: 1 | ||
walk-down | ||
rotate: false | ||
xy: 0, 28 | ||
size: 24, 28 | ||
orig: 24, 28 | ||
offset: 0, 0 | ||
index: 2 | ||
walk-left | ||
rotate: false | ||
xy: 24, 28 | ||
size: 24, 28 | ||
orig: 20, 28 | ||
offset: 0, 0 | ||
index: 1 | ||
walk-left | ||
rotate: false | ||
xy: 24, 0 | ||
size: 24, 28 | ||
orig: 16, 28 | ||
offset: 0, 0 | ||
index: 2 | ||
walk-right | ||
rotate: false | ||
xy: 48, 28 | ||
size: 24, 28 | ||
orig: 20, 28 | ||
offset: 0, 0 | ||
index: 1 | ||
walk-right | ||
rotate: false | ||
xy: 48, 0 | ||
size: 24, 28 | ||
orig: 16, 28 | ||
offset: 0, 0 | ||
index: 2 | ||
walk-up | ||
rotate: false | ||
xy: 72, 28 | ||
size: 24, 28 | ||
orig: 24, 28 | ||
offset: 0, 0 | ||
index: 1 | ||
walk-up | ||
rotate: false | ||
xy: 96, 28 | ||
size: 24, 28 | ||
orig: 24, 28 | ||
offset: 0, 0 | ||
index: 2 |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
tiles.png | ||
size: 64, 128 | ||
format: RGBA8888 | ||
filter: Linear,Linear | ||
repeat: none | ||
dirt | ||
rotate: false | ||
xy: 0, 0 | ||
size: 32, 32 | ||
orig: 32, 32 | ||
offset: 0, 0 | ||
index: -1 | ||
grass | ||
rotate: false | ||
xy: 32, 0 | ||
size: 32, 32 | ||
orig: 32, 32 | ||
offset: 0, 0 | ||
index: -1 | ||
sand | ||
rotate: false | ||
xy: 0, 32 | ||
size: 32, 32 | ||
orig: 32, 32 | ||
offset: 0, 0 | ||
index: -1 | ||
tree | ||
rotate: false | ||
xy: 32, 32 | ||
size: 32, 32 | ||
orig: 32, 32 | ||
offset: 0, 0 | ||
index: -1 | ||
water | ||
rotate: false | ||
xy: 0, 64 | ||
size: 32, 32 | ||
orig: 32, 32 | ||
offset: 0, 0 | ||
index: -1 |
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,9 @@ | ||
package miniventure.game; | ||
|
||
@FunctionalInterface | ||
public interface BooleanFunction { | ||
boolean isTrue(); | ||
|
||
BooleanFunction TRUE = () -> true; | ||
BooleanFunction FALSE = () -> false; | ||
} |
This file was deleted.
Oops, something went wrong.
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,60 @@ | ||
package miniventure.game; | ||
|
||
import miniventure.game.screen.GameScreen; | ||
import miniventure.game.screen.MainMenuScreen; | ||
import miniventure.game.world.entity.mob.MobAnimationController; | ||
|
||
import com.badlogic.gdx.Game; | ||
import com.badlogic.gdx.graphics.g2d.BitmapFont; | ||
import com.badlogic.gdx.graphics.g2d.SpriteBatch; | ||
import com.badlogic.gdx.graphics.g2d.TextureAtlas; | ||
|
||
public class GameCore extends Game { | ||
|
||
public static final Version VERSION = new Version("1.0.0"); | ||
|
||
public static final int SCREEN_WIDTH = 800, SCREEN_HEIGHT = 450; | ||
public static TextureAtlas tileAtlas; | ||
public static final int START_TIME = (int) (System.currentTimeMillis()/1000); | ||
|
||
private SpriteBatch batch; | ||
private BitmapFont font; // this is stored here because it is a really good idea to reuse objects where ever possible; and don't repeat instantiations, aka make a font instance in two classes when the fonts are the same. | ||
|
||
private GameScreen gameScreen; // Screens ought to be disposed, but aren't automatically disposed; so we need to do it ourselves. | ||
|
||
@Override | ||
public void create () { | ||
tileAtlas = new TextureAtlas("sprites/tiles.txt"); | ||
batch = new SpriteBatch(); | ||
font = new BitmapFont(); // uses libGDX's default Arial font | ||
|
||
this.setScreen(new MainMenuScreen(this)); | ||
} | ||
|
||
@Override | ||
public void dispose () { | ||
batch.dispose(); | ||
font.dispose(); | ||
if(gameScreen != null) | ||
gameScreen.dispose(); | ||
|
||
tileAtlas.dispose(); | ||
MobAnimationController.disposeTextures(); | ||
} | ||
|
||
public SpriteBatch getBatch() { | ||
return batch; | ||
} | ||
|
||
public BitmapFont getFont() { | ||
return font; | ||
} | ||
|
||
public void setGameScreen(GameScreen gameScreen) { | ||
this.gameScreen = gameScreen; | ||
} | ||
|
||
public static float getElapsedProgramTime() { | ||
return System.currentTimeMillis()/1000f - START_TIME; | ||
} | ||
} |
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,53 @@ | ||
package miniventure.game; | ||
|
||
import org.jetbrains.annotations.NotNull; | ||
|
||
public class Version implements Comparable<Version> { | ||
|
||
static class VersionFormatException extends IllegalArgumentException { | ||
public VersionFormatException(String versionString) { | ||
super("The string \"" + versionString + "\" does not represent a valid version format; valid formats are #.# or #.#.#"); | ||
} | ||
} | ||
|
||
private int make, major, minor; | ||
|
||
public Version(String version) { | ||
String[] nums = version.split("\\."); | ||
if(nums.length > 3 || nums.length < 2) | ||
throw new VersionFormatException(version); | ||
|
||
try { | ||
make = new Integer(nums[0]); | ||
major = new Integer(nums[1]); | ||
if(nums.length == 3) | ||
minor = new Integer(nums[2]); | ||
else | ||
minor = -1; | ||
|
||
if(make < 0 || major < 0 || (nums.length == 3 && minor < 0)) | ||
throw new VersionFormatException(version); | ||
|
||
} catch(NumberFormatException ex) { | ||
throw new VersionFormatException(version); | ||
} | ||
} | ||
|
||
@Override | ||
public int compareTo(@NotNull Version other) { | ||
if(make != other.make) return Integer.compare(make, other.make); | ||
if(major != other.major) return Integer.compare(major, other.major); | ||
if(minor != other.minor) { | ||
if(minor < 0) return 1; // -1 means after all other numbers, so this is after the other version. | ||
else if(other.minor < 0) return -1; // this is before the other version. | ||
else return Integer.compare(minor, other.minor); // compare normally. | ||
} | ||
|
||
return 0; // versions are the same. | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return make+"."+major+(minor<0?" official":"."+minor); | ||
} | ||
} |
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,26 @@ | ||
package miniventure.game.item; | ||
|
||
import com.badlogic.gdx.graphics.g2d.TextureRegion; | ||
|
||
public abstract class Item { | ||
|
||
/* | ||
Will have a use() method, to mark that an item has gotten used. Called by tiles and entities. This class will determine whether it can be used again, however. | ||
Perhaps later I can add a parameter to the use method to specify how *much* to use it. | ||
*/ | ||
|
||
private TextureRegion texture; | ||
|
||
public Item(TextureRegion texture) { | ||
this.texture = texture; | ||
} | ||
|
||
public TextureRegion getTexture() { return texture; } | ||
|
||
public abstract boolean isReflexive(); | ||
|
||
public int getDamage() { return 1; } | ||
|
||
} |
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,17 @@ | ||
package miniventure.game.item; | ||
|
||
public class ToolItem extends Item { | ||
|
||
private final ToolType toolType; | ||
|
||
public ToolItem(ToolType type) { | ||
super(type.texture); | ||
this.toolType = type; | ||
} | ||
|
||
public ToolType getType() { return toolType; } | ||
|
||
|
||
@Override | ||
public boolean isReflexive() { return false; } | ||
} |
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,10 @@ | ||
package miniventure.game.item; | ||
|
||
import com.badlogic.gdx.graphics.g2d.TextureRegion; | ||
|
||
public enum ToolType { | ||
|
||
PICKAXE, SHOVEL, AXE, SWORD; | ||
|
||
public final TextureRegion texture = null; | ||
} |
Oops, something went wrong.