Android Open Source - game-api-android Tile






From Project

Back to project page game-api-android.

License

The source code is released under:

MIT License

If you think the Android project game-api-android listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package android.gameengine.icadroids.tiles;
//from   www .ja v a  2  s.com
/**
 * Every tile in a tilemap is a tile object. You can manipulate the tile by
 * using its methods.
 * 
 * Note: tile objects will be automatically generated by GameTiles
 * 
 * @author Bas van der Zandt
 * 
 */
public class Tile {

  private int tileType;
  /**
   * The position of the tiles in the tilemap. This is NOT the x and y
   * position in the game world!
   */
  private int tileNumberX, tileNumberY;
  /**
   * This tile object is instance of this gameTiles object
   */
  private GameTiles gameTiles;

  /**
   * Every tile has a tiletype and is a instance of an gameTiles object.
   * Tiletype lower than 0 means invisible.
   * 
   * @param tileType
   * @param gameTiles
   */
  public Tile(int tileType, GameTiles gameTiles) {
    super();
    this.tileType = tileType;
    this.gameTiles = gameTiles;
  }

  /**
   * Change the tile type<br />
   * <em>Important!</em> Use this method only when you want to change a tile
   * into another tile. If you want to remove tiles or add tiles at certain positions,
   * use the GameTiles.changeTile method.
   * 
   * @param tileType
   *            the new tiletype
   * @see android.gameengine.icadroids.tiles.GameTiles#changeTile(int, int, int)
   */
  public void setTileType(int tileType) {
    this.tileType = tileType;
  }

  /**
   * Get the tile tiletype
   * 
   * @return the tiletype
   */
  public int getTileType() {
    return tileType;
  }

  /**
   * Get the x tile number <b> in the tile map </b>
   * 
   * @return The x tile number
   */
  public int getTileNumberX() {
    return tileNumberX;
  }

  /**
   * Get the y tile number <b> in the tile map </b>
   * 
   * @return The y tile number
   */
  public int getTileNumberY() {
    return tileNumberY;
  }
  
  /**
   * Set the position of the tile in the tilemap, as index, not real world coordinates
   * 
   * @param i the first index in the double array of the tilemap, that is Y-index
   * @param j the second index in the double array of the tilemap, that is X-index
   */
  void setTileIndex(int i, int j)
  {
    tileNumberX = j;
    tileNumberY = i;
  }

  /**
   * Get the instance of gameTiles where this Tile is a instance from
   * 
   * @return gameTile object
   */
  public GameTiles getGameTiles() {
    return gameTiles;
  }

  /**
   * Get the x position of the tile Note: x and y values are at the top left
   * corner of the tile
   * 
   * @return the x position in the game world
   */
  public int getTileX() {
    return tileNumberX * gameTiles.tileSize;
  }

  /**
   * get the y position of the tile Note: x and y values are at the top left
   * corner of the tile
   * 
   * @return the y position in the game world
   */
  public int getTileY() {
    return tileNumberY * gameTiles.tileSize;
  }

}




Java Source Code List

android.gameengine.icadroids.alarms.Alarm.java
android.gameengine.icadroids.alarms.IAlarm.java
android.gameengine.icadroids.dashboard.DashboardImageView.java
android.gameengine.icadroids.dashboard.DashboardTextView.java
android.gameengine.icadroids.engine.GameEngine.java
android.gameengine.icadroids.engine.GameFPSCounter.java
android.gameengine.icadroids.engine.GameThread.java
android.gameengine.icadroids.engine.GameView.java
android.gameengine.icadroids.engine.Viewport.java
android.gameengine.icadroids.forms.GameForm.java
android.gameengine.icadroids.forms.IFormInput.java
android.gameengine.icadroids.forms.ViewCreator.java
android.gameengine.icadroids.forms.ViewRemover.java
android.gameengine.icadroids.input.MotionSensor.java
android.gameengine.icadroids.input.OnScreenButton.java
android.gameengine.icadroids.input.OnScreenButtons.java
android.gameengine.icadroids.input.TouchInput.java
android.gameengine.icadroids.objects.GameObject.java
android.gameengine.icadroids.objects.MoveableGameObject.java
android.gameengine.icadroids.objects.collisions.CollidingObject.java
android.gameengine.icadroids.objects.collisions.ICollision.java
android.gameengine.icadroids.objects.collisions.TileCollision.java
android.gameengine.icadroids.objects.graphics.AnimatedSprite.java
android.gameengine.icadroids.objects.graphics.Sprite.java
android.gameengine.icadroids.persistence.GamePersistence.java
android.gameengine.icadroids.sound.GameSound.java
android.gameengine.icadroids.sound.MusicPlayer.java
android.gameengine.icadroids.tiles.GameTiles.java
android.gameengine.icadroids.tiles.Tile.java
com.android.vissenspel.Monster.java
com.android.vissenspel.StrawberryControler.java
com.android.vissenspel.Strawberry.java
com.android.vissenspel.Vis.java
com.android.vissenspel.Vissenkom.java
game.MyAndroidGame.java
testGames.AndroidCraft_demo.java
testGames.FormTest.java
testGames.Player.java
testGames.TestGameBas.java
testGames.TestGameLex.java
testGames.TestGameRoel.java
testGames.gameEngineTest.DebugEngine.java
testGames.gameEngineTest.GameEngineTestGame.java
testGames.gameEngineTest.TestGameObject.java
testGames.gameEngineTest.debugObject.java
testGames.gameEngineTest.randomObject.java
testGames.testGameObjectBas.java
testGames.testGame.java