diff options
| author | Jérémy Zurcher <jeremy@asynk.ch> | 2018-09-12 14:55:39 +0200 | 
|---|---|---|
| committer | Jérémy Zurcher <jeremy@asynk.ch> | 2018-09-12 14:55:39 +0200 | 
| commit | 4488edb4714fdff9509c967b74530d54d1fc1fb8 (patch) | |
| tree | c70dc06e8ba413c2cdc85a4fa18edb24f37200bb /core/src/ch/asynk | |
| parent | 5b89e9ad75e72016a4ec5c7d7c59e5ed557e60e7 (diff) | |
| download | gdx-boardgame-4488edb4714fdff9509c967b74530d54d1fc1fb8.zip gdx-boardgame-4488edb4714fdff9509c967b74530d54d1fc1fb8.tar.gz  | |
GameBoard : support rotation
Diffstat (limited to 'core/src/ch/asynk')
| -rw-r--r-- | core/src/ch/asynk/zproject/GameBoard.java | 37 | 
1 files changed, 34 insertions, 3 deletions
diff --git a/core/src/ch/asynk/zproject/GameBoard.java b/core/src/ch/asynk/zproject/GameBoard.java index d1181ad..2b95f47 100644 --- a/core/src/ch/asynk/zproject/GameBoard.java +++ b/core/src/ch/asynk/zproject/GameBoard.java @@ -10,9 +10,17 @@ public class GameBoard implements Disposable, Touchable  {      private final Texture map; +    private int dx; +    private int dy; +    private int w; +    private int h; +    private float r; +    private boolean rotate = false; +      public GameBoard(final Assets assets)      {          this.map = assets.getTexture(assets.MAP_00); +        computeValues();      }      @Override public void dispose() @@ -26,18 +34,41 @@ public class GameBoard implements Disposable, Touchable          return true;      } +    public void setRotate(boolean rotate) +    { +        this.rotate = rotate; +        computeValues(); +    } + +    private void computeValues() +    { +        if (rotate) { +            r = 90; +            dx = - ( map.getWidth() - map.getHeight() ) / 2; +            dy = - dx; +            w = map.getHeight(); +            h = map.getWidth(); +        } else { +            r = 0; +            dx = 0; +            dy = 0; +            w = map.getWidth(); +            h = map.getHeight(); +        } +    } +      public int getWidth()      { -        return map.getWidth(); +        return w;      }      public int getHeight()      { -        return map.getHeight(); +        return h;      }      public void draw(Batch batch)      { -        batch.draw(map, 0, 0); +        batch.draw(map, dx, dy, map.getWidth()/2, map.getHeight()/2, map.getWidth(), map.getHeight(), 1, 1, r, 0, 0, map.getWidth(), map.getHeight(), false, false);      }  }  | 
