-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
22 changed files
with
1,037 additions
and
66 deletions.
There are no files selected for viewing
Binary file not shown.
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
Binary file not shown.
Binary file not shown.
66 changes: 0 additions & 66 deletions
66
isometric-game-template/src/com/chaonis/isometric/Isometric.java
This file was deleted.
Oops, something went wrong.
88 changes: 88 additions & 0 deletions
88
isometric-game-template/src/com/chaonis/isometric/assets/Assets.java
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,88 @@ | ||
package com.chaonis.isometric.assets; | ||
|
||
import com.badlogic.gdx.assets.AssetManager; | ||
import com.badlogic.gdx.graphics.Texture; | ||
|
||
public final class Assets { | ||
|
||
public static AssetManager manager; | ||
|
||
private static Assets instance; | ||
|
||
//Not synchronized | ||
public static Assets instance() { | ||
if (instance == null) { | ||
instance = new Assets(); | ||
} | ||
return instance; | ||
} | ||
|
||
private Assets() { | ||
manager = new AssetManager(); | ||
} | ||
|
||
public static final String loaderTexture = "data/loader/loader.png"; | ||
public static final String rocketTexture = "data/rocket/rocket.png"; | ||
|
||
public void loadRocketAssets() { | ||
manager.load(rocketTexture, Texture.class); | ||
} | ||
|
||
public void loadLoaderAssets() { | ||
manager.load(loaderTexture, Texture.class); | ||
} | ||
|
||
public void disposeRocketAssets() { | ||
manager.unload(rocketTexture); | ||
} | ||
|
||
public void disposeLoaderAssets() { | ||
manager.unload(loaderTexture); | ||
} | ||
|
||
public static final String BG0_0 = "data/background/bg0_0.etc1"; | ||
public static final String BG1_0 = "data/background/bg1_0.etc1"; | ||
public static final String BG2_0 = "data/background/bg2_0.etc1"; | ||
public static final String BG3_0 = "data/background/bg3_0.etc1"; | ||
public static final String BG0_1 = "data/background/bg0_1.etc1"; | ||
public static final String BG1_1 = "data/background/bg1_1.etc1"; | ||
public static final String BG2_1 = "data/background/bg2_1.etc1"; | ||
public static final String BG3_1 = "data/background/bg3_1.etc1"; | ||
|
||
public void loadBGAssets() { | ||
manager.load(BG0_0, Texture.class); | ||
manager.load(BG1_0, Texture.class); | ||
manager.load(BG2_0, Texture.class); | ||
manager.load(BG3_0, Texture.class); | ||
manager.load(BG0_1, Texture.class); | ||
manager.load(BG1_1, Texture.class); | ||
manager.load(BG2_1, Texture.class); | ||
manager.load(BG3_1, Texture.class); | ||
} | ||
|
||
public void disposeBGAssets() { | ||
manager.unload(BG0_0); | ||
manager.unload(BG1_0); | ||
manager.unload(BG2_0); | ||
manager.unload(BG3_0); | ||
manager.unload(BG0_1); | ||
manager.unload(BG1_1); | ||
manager.unload(BG2_1); | ||
manager.unload(BG3_1); | ||
} | ||
|
||
public void loadGameAssets() { | ||
loadRocketAssets(); | ||
loadBGAssets(); | ||
} | ||
|
||
public void disposeGameAssets() { | ||
disposeRocketAssets(); | ||
disposeBGAssets(); | ||
} | ||
|
||
public static void clear() { | ||
Assets.manager.clear(); | ||
} | ||
|
||
} |
30 changes: 30 additions & 0 deletions
30
isometric-game-template/src/com/chaonis/isometric/model/Globals.java
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,30 @@ | ||
package com.chaonis.isometric.model; | ||
|
||
/** | ||
* Global constants for the World, e.g. Viewport, Tile sizes, Original Camera coordinates, Zoom levels | ||
*/ | ||
public class Globals { | ||
|
||
//static viewport width and height | ||
public final static int VIEWP_W = 1280; | ||
public final static int VIEWP_H = 720; | ||
|
||
public final static int BG_TILE_W = 1024; | ||
public final static int BG_TILE_H = 1024; | ||
|
||
public final static int ORIG_CAM_X = 512; | ||
public final static int ORIG_CAM_Y = 1024; | ||
|
||
public final static float ORIG_ZOOM_LEVEL = 1.0f; | ||
public final static float MIN_ZOOM_LEVEL = 0.4f; | ||
public final static float MAX_ZOOM_LEVEL = 1.3f; | ||
|
||
public final static int TILE_W = 64; | ||
public final static int TILE_H = 32; | ||
|
||
public final static int BORDER = 128; | ||
|
||
//static class | ||
private Globals() { | ||
} | ||
} |
42 changes: 42 additions & 0 deletions
42
isometric-game-template/src/com/chaonis/isometric/model/IsoCamera.java
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,42 @@ | ||
package com.chaonis.isometric.model; | ||
|
||
import com.badlogic.gdx.Gdx; | ||
import com.badlogic.gdx.graphics.GL20; | ||
import com.badlogic.gdx.graphics.OrthographicCamera; | ||
import com.badlogic.gdx.math.Matrix4; | ||
import com.badlogic.gdx.math.Vector3; | ||
|
||
/** | ||
* An OrthographicCamera with additional functions, e.g. worldToGrid(), gridToWorld(). | ||
*/ | ||
public class IsoCamera extends OrthographicCamera { | ||
|
||
private final static Matrix4 gridToWorld; | ||
private final static Matrix4 worldToGrid; | ||
|
||
static { | ||
gridToWorld = new Matrix4(new float[] { | ||
32f, -16f, 0f, 0f, | ||
-32f, -16f, 0f, 0f, | ||
0f, 0f, 1f, 0f, | ||
2048f, 1912f, 0f, 1f | ||
}); | ||
worldToGrid = new Matrix4(gridToWorld).inv(); | ||
} | ||
|
||
public static void worldToGrid(Vector3 worldCoordinate) { | ||
worldCoordinate.mul(worldToGrid); | ||
} | ||
|
||
public static void gridToWorld(Vector3 gridCoordinate) { | ||
gridCoordinate.mul(gridToWorld); | ||
} | ||
|
||
public final static float GRID_SIZE_X = 32f; | ||
public final static float GRID_SIZE_Y = 16f; | ||
|
||
public void clearScreen() { | ||
Gdx.gl.glClearColor(0, 0, 0, 1); | ||
Gdx.gl.glClear(GL20.GL_DEPTH_BUFFER_BIT | GL20.GL_COLOR_BUFFER_BIT | GL20.GL_STENCIL_BUFFER_BIT); | ||
} | ||
} |
18 changes: 18 additions & 0 deletions
18
isometric-game-template/src/com/chaonis/isometric/model/components/BackgroundPosition.java
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,18 @@ | ||
package com.chaonis.isometric.model.components; | ||
|
||
import com.artemis.Component; | ||
|
||
/** | ||
* Background coordinates in Game World. Maybe this component is a bit overkill. | ||
*/ | ||
public class BackgroundPosition extends Component { | ||
|
||
public int x; | ||
public int y; | ||
|
||
public BackgroundPosition(int x, int y) { | ||
this.x = x; | ||
this.y = y; | ||
} | ||
|
||
} |
42 changes: 42 additions & 0 deletions
42
isometric-game-template/src/com/chaonis/isometric/model/components/GridPosition.java
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,42 @@ | ||
package com.chaonis.isometric.model.components; | ||
|
||
import com.artemis.Component; | ||
import com.badlogic.gdx.graphics.g2d.Sprite; | ||
|
||
/** | ||
* This component stores grid coordinates for the given entity. The left | ||
* coordinates are inclusive the right coordinates exclusive regarding the | ||
* occupation of the given grid. (e.g. the smallest entity at (x,y) occupies | ||
* (x,y), but not (x+1,y) or (x, y+1) and neither (x+1,y+1). Even moving objects | ||
* should have one and only one fixed GridPosition. (Namely the position it is | ||
* located at the moment, or the position it is heading now.) | ||
*/ | ||
|
||
public class GridPosition extends Component { | ||
|
||
public Sprite staticSprite = null; | ||
|
||
// For the smallest entities | ||
public GridPosition(int x, int y) { | ||
this(x, y, 1, 1, null); | ||
} | ||
|
||
public GridPosition(int x, int y, int w, int h) { | ||
this(x, y, w, h, null); | ||
} | ||
|
||
public GridPosition(int x, int y, int w, int h, Sprite textureRegion) { | ||
this.x = x; | ||
this.y = y; | ||
this.w = w; | ||
this.h = h; | ||
this.staticSprite = textureRegion; | ||
} | ||
|
||
public int x; | ||
public int y; | ||
|
||
public int w; | ||
public int h; | ||
|
||
} |
27 changes: 27 additions & 0 deletions
27
isometric-game-template/src/com/chaonis/isometric/model/components/MovablePosition.java
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,27 @@ | ||
package com.chaonis.isometric.model.components; | ||
|
||
import com.artemis.Component; | ||
|
||
// This component stores the current position for the given entity for movable objects. | ||
// These are Game World coordinates. | ||
|
||
public class MovablePosition extends Component { | ||
|
||
public float x; | ||
public float y; | ||
|
||
public float oldX; | ||
public float oldY; | ||
|
||
public float startTime = 0; | ||
public float currentTime = 0; | ||
|
||
public boolean moving = false; | ||
|
||
public MovablePosition(float x, float y) { | ||
this.x = x; | ||
this.y = y; | ||
this.oldX = x; | ||
this.oldY = y; | ||
} | ||
} |
Oops, something went wrong.