Skip to content

Commit

Permalink
Merge pull request #1 from chrisj42/practice
Browse files Browse the repository at this point in the history
Practice
  • Loading branch information
chrisj42 committed Nov 26, 2017
2 parents 63fa899 + 0d09425 commit 838105f
Show file tree
Hide file tree
Showing 36 changed files with 1,648 additions and 39 deletions.
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ project(":desktop") {
compile "com.badlogicgames.gdx:gdx-box2d-platform:$gdxVersion:natives-desktop"
compile "com.badlogicgames.gdx:gdx-freetype-platform:$gdxVersion:natives-desktop"
compile "com.badlogicgames.gdx:gdx-tools:$gdxVersion"

compile 'org.jetbrains:annotations:15.0'
}
}

Expand All @@ -58,7 +58,7 @@ project(":core") {
compile "com.badlogicgames.gdx:gdx:$gdxVersion"
compile "com.badlogicgames.gdx:gdx-box2d:$gdxVersion"
compile "com.badlogicgames.gdx:gdx-freetype:$gdxVersion"

compile 'org.jetbrains:annotations:15.0'
}
}

Expand Down
Binary file removed core/assets/badlogic.jpg
Binary file not shown.
Binary file added core/assets/sprites/player.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
89 changes: 89 additions & 0 deletions core/assets/sprites/player.txt
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
Binary file added core/assets/sprites/tiles.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
40 changes: 40 additions & 0 deletions core/assets/sprites/tiles.txt
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
2 changes: 1 addition & 1 deletion core/build.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
apply plugin: "java"

sourceCompatibility = 1.6
sourceCompatibility = 1.8
[compileJava, compileTestJava]*.options*.encoding = 'UTF-8'

sourceSets.main.java.srcDirs = [ "src/" ]
Expand Down
9 changes: 9 additions & 0 deletions core/src/miniventure/game/BooleanFunction.java
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;
}
33 changes: 0 additions & 33 deletions core/src/miniventure/game/Game.java

This file was deleted.

60 changes: 60 additions & 0 deletions core/src/miniventure/game/GameCore.java
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;
}
}
53 changes: 53 additions & 0 deletions core/src/miniventure/game/Version.java
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);
}
}
26 changes: 26 additions & 0 deletions core/src/miniventure/game/item/Item.java
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; }

}
17 changes: 17 additions & 0 deletions core/src/miniventure/game/item/ToolItem.java
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; }
}
10 changes: 10 additions & 0 deletions core/src/miniventure/game/item/ToolType.java
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;
}

0 comments on commit 838105f

Please sign in to comment.