diff --git a/assets/main.tsx b/assets/main.tsx index 7649ac0..57890e4 100644 --- a/assets/main.tsx +++ b/assets/main.tsx @@ -1,16 +1,49 @@ - - - - - - - - - + + + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/player-idle.atlas b/assets/player-idle.atlas new file mode 100644 index 0000000..d7f7676 --- /dev/null +++ b/assets/player-idle.atlas @@ -0,0 +1,27 @@ + +player-idle.png +size: 64, 32 +format: RGBA8888 +filter: Nearest, Nearest +repeat: none +player-idle1 + rotate: false + xy: 2, 2 + size: 16, 16 + orig: 16, 16 + offset: 0, 0 + index: -1 +player-idle2 + rotate: false + xy: 38, 2 + size: 16, 16 + orig: 16, 16 + offset: 0, 0 + index: -1 +player-idle3 + rotate: false + xy: 20, 2 + size: 16, 16 + orig: 16, 16 + offset: 0, 0 + index: -1 diff --git a/assets/player-idle.png b/assets/player-idle.png new file mode 100644 index 0000000..dd64d84 Binary files /dev/null and b/assets/player-idle.png differ diff --git a/assets/test.tmx b/assets/test.tmx index b8519f0..0fb7de3 100644 --- a/assets/test.tmx +++ b/assets/test.tmx @@ -1,28 +1,58 @@ - + - + -2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2, -2,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,2, -2,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,2, -2,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,2, -2,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,2, -2,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,2, -2,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,2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,5,5,5,5,5,5,5,5, +5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5, +5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5, +5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5, +5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5, +5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5, +5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5, +5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5 diff --git a/assets/world-map.png b/assets/world-map.png new file mode 100644 index 0000000..6ee3176 Binary files /dev/null and b/assets/world-map.png differ diff --git a/core/src/com/redstrate/watersymbol/screens/GameScreen.java b/core/src/com/redstrate/watersymbol/screens/GameScreen.java index 04bbebd..c7c20c7 100644 --- a/core/src/com/redstrate/watersymbol/screens/GameScreen.java +++ b/core/src/com/redstrate/watersymbol/screens/GameScreen.java @@ -5,6 +5,7 @@ import com.badlogic.gdx.Input; import com.badlogic.gdx.Screen; import com.badlogic.gdx.graphics.OrthographicCamera; import com.badlogic.gdx.graphics.Texture; +import com.badlogic.gdx.graphics.g2d.Animation; import com.badlogic.gdx.graphics.g2d.Sprite; import com.badlogic.gdx.graphics.g2d.TextureAtlas; import com.badlogic.gdx.graphics.g2d.TextureRegion; @@ -37,6 +38,8 @@ public class GameScreen implements Screen { Texture playerTexture; Sprite playerSprite; + Animation playerIdleAnimation; + TextureAtlas arrowAtlas; // data for in-turn actions @@ -50,40 +53,42 @@ public class GameScreen implements Screen { camera = new OrthographicCamera(); camera.setToOrtho(false, 800, 480); + camera.zoom = 2.0f; tiledMap = new TmxMapLoader().load("test.tmx"); tiledMapRenderer = new OrthogonalTiledMapRenderer(tiledMap); Unit player = new Unit(); - player.positionX = 1; - player.positionY = 1; + player.positionX = 11; + player.positionY = 16; player.team = Unit.Team.Player; units.add(player); Unit player2 = new Unit(); - player2.positionX = 1; - player2.positionY = 5; + player2.positionX = 11; + player2.positionY = 20; player2.team = Unit.Team.Player; units.add(player2); Unit enemy = new Unit(); - enemy.positionX = 5; - enemy.positionY = 1; + enemy.positionX = 15; + enemy.positionY = 18; enemy.team = Unit.Team.Enemy; units.add(enemy); Unit enemy2 = new Unit(); enemy2.positionX = 15; - enemy2.positionY = 15; + enemy2.positionY = 18; enemy2.team = Unit.Team.Enemy; units.add(enemy2); playerTexture = new Texture(Gdx.files.internal("player.png")); playerSprite = new Sprite(playerTexture); + playerIdleAnimation = new Animation(0.500f, new TextureAtlas("player-idle.atlas").getRegions(), Animation.PlayMode.LOOP_PINGPONG); arrowAtlas = new TextureAtlas("test.atlas"); @@ -113,7 +118,9 @@ public class GameScreen implements Screen { getNextUnit(); - smoothlyTransitionCamera(new Vector3(currentUnit.positionX * 32, currentUnit.positionY * 32, 0)); + if(currentUnit != null) { + smoothlyTransitionCamera(new Vector3(currentUnit.positionX * 16, currentUnit.positionY * 16, 0)); + } } void updateUnits() { @@ -155,7 +162,7 @@ public class GameScreen implements Screen { startNewTeamTurn(Unit.Team.Player); } } else { - smoothlyTransitionCamera(new Vector3(currentUnit.positionX * 32, currentUnit.positionY * 32, 0)); + smoothlyTransitionCamera(new Vector3(currentUnit.positionX * 16, currentUnit.positionY * 16, 0)); } } @@ -242,9 +249,12 @@ public class GameScreen implements Screen { currentlyTransitionCamera = true; } + private float stateTime = 0.0f; + @Override public void render(float delta) { ScreenUtils.clear(0, 0, 0.2f, 1); + stateTime += delta; if(currentlyTransitionCamera) { camera.position.set(oldCameraPosition.lerp(targetCameraPosition, lerp)); @@ -263,8 +273,9 @@ public class GameScreen implements Screen { game.batch.setProjectionMatrix(camera.combined); for(Unit unit : units) { - playerSprite.setPosition(unit.positionX * 32, unit.positionY * 32); - playerSprite.draw(game.batch); + TextureRegion currentFrame = playerIdleAnimation.getKeyFrame(stateTime, true); + + game.batch.draw(currentFrame, unit.positionX * 16, unit.positionY * 16); } // early exit, since we want the camera to finish its nice transition @@ -285,8 +296,8 @@ public class GameScreen implements Screen { double newX = Math.floor(mousePos.x); double newY = Math.floor(mousePos.y); - int newFixedX = (int) (newX / 32.0); - int newFixedY = (int) (newY / 32.0); + int newFixedX = (int) (newX / 16.0); + int newFixedY = (int) (newY / 16.0); ArrayList path = AStar.path(new Vector2(currentUnit.positionX, currentUnit.positionY), new Vector2((float) newFixedX, (float) newFixedY), getCollision(), tiledMap); if (path != null) { @@ -336,7 +347,7 @@ public class GameScreen implements Screen { } if (spriteRegion != null) { - game.batch.draw(spriteRegion, newPosition.x * 32, newPosition.y * 32); + game.batch.draw(spriteRegion, newPosition.x * 16, newPosition.y * 16); } } } @@ -348,7 +359,7 @@ public class GameScreen implements Screen { double newX = Math.floor(mousePos.x); double newY = Math.floor(mousePos.y); - moveUnitTo((int) (newX / 32.0), (int) (newY / 32.0)); + moveUnitTo((int) (newX / 16.0), (int) (newY / 16.0)); hasStartedMoving = false; } @@ -397,7 +408,7 @@ public class GameScreen implements Screen { currentUnit.positionX = (int) nextMove.x; currentUnit.positionY = (int) nextMove.y; - smoothlyTransitionCamera(new Vector3(currentUnit.positionX * 32, currentUnit.positionY * 32, 0)); + smoothlyTransitionCamera(new Vector3(currentUnit.positionX * 16, currentUnit.positionY * 16, 0)); } else { currentlyTakingAction = false; currentlyAwaitingAuxilaryAction = true; @@ -434,8 +445,8 @@ public class GameScreen implements Screen { double newX = Math.floor(mousePos.x); double newY = Math.floor(mousePos.y); - int newFixedX = (int) (newX / 32.0); - int newFixedY = (int) (newY / 32.0); + int newFixedX = (int) (newX / 16.0); + int newFixedY = (int) (newY / 16.0); List actions = getAvailableActionsForPosition(newFixedX, newFixedY); for (int i = 0; i < actions.size(); i++) { @@ -454,7 +465,8 @@ public class GameScreen implements Screen { @Override public void resize(int width, int height) { - camera.setToOrtho(false, width, height); + camera.viewportWidth = 230; + camera.viewportHeight = 230 * ((float)height / (float)width); } @Override