本文整理汇总了Java中org.newdawn.slick.tiled.TiledMap类的典型用法代码示例。如果您正苦于以下问题:Java TiledMap类的具体用法?Java TiledMap怎么用?Java TiledMap使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
TiledMap类属于org.newdawn.slick.tiled包,在下文中一共展示了TiledMap类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: init
import org.newdawn.slick.tiled.TiledMap; //导入依赖的package包/类
@Override
public void init(GameContainer container) throws SlickException {
this.container = container;
this.map = new TiledMap("/home/enzo/newmap.tmx");
SpriteSheet spriteSheet = new SpriteSheet("/home/enzo/SpriteSheetAnim.png", 64, 64);
this.animations[0] = loadAnimation(spriteSheet, 0, 1, 0);
this.animations[1] = loadAnimation(spriteSheet, 0, 1, 1);
this.animations[2] = loadAnimation(spriteSheet, 0, 1, 2);
this.animations[3] = loadAnimation(spriteSheet, 0, 1, 3);
this.animations[4] = loadAnimation(spriteSheet, 1, 9, 0);
this.animations[5] = loadAnimation(spriteSheet, 1, 9, 1);
this.animations[6] = loadAnimation(spriteSheet, 1, 9, 2);
this.animations[7] = loadAnimation(spriteSheet, 1, 9, 3);
Font font = new Font("Verdana", Font.BOLD, 20);
UnicodeFont uFont = new UnicodeFont(font, font.getSize(), font.isBold(), font.isItalic());
nameInput = new TextField(container, uFont, 150,20,500,35, new ComponentListener()
{
public void componentActivated(AbstractComponent source) {
message = "Entered1: "+nameInput.getText();
nameInput.setFocus(true);
}
});
// ComponentListener listener = new ComponentListener();
// TextField nameInput = new TextField(arg0, truetypefont, 150,20,500,35, listener);
//
// {
// public void componentActivated(AbstractComponent source) {
// System.out.println("Entered1: "+nameInput.getText());
// }
// });
}
示例2: init
import org.newdawn.slick.tiled.TiledMap; //导入依赖的package包/类
/**
* This method inizializes map, images, animations and sounds
* @param container
* @throws SlickException
*/
@Override
public void init(GameContainer container) throws SlickException {
ready = new Image("data/ready.jpg");
gameOver = new Image("data/gameover.png");
youWin = new Image("data/youwin.png");
mazeMap = new TiledMap("data/maze/Maze.tmx");
initMapProperty();
initAnimations();
begin = new Sound("data/pacmanSound/begin.wav");
begin.play();
eatFruit = new Sound("data/pacmanSound/eatFruit.wav");
pacmanGame.initMaze(mazeMap,this);
}
示例3: MazeModality
import org.newdawn.slick.tiled.TiledMap; //导入依赖的package包/类
/**
* @param mazeMap
* @param mazeView
* @throws SlickException
*/
public MazeModality(TiledMap mazeMap,MazeView mazeView) throws SlickException {
this.addObserver(mazeView);
tileWidth = mazeMap.getTileWidth();
tileHeight = mazeMap.getTileHeight();
mazeWidth = mazeMap.getWidth();
mazeHeight = mazeMap.getHeight();
initializationTiles(mazeView);
pacman = new PacMan(tileWidth, tileHeight, mazeWidth, tiles);
clyde = new Clyde(tileWidth, tileHeight, mazeWidth, tiles);
blinky = new Blinky(tileWidth, tileHeight, mazeWidth, tiles);
inky = new Inky(tileWidth, tileHeight, mazeWidth, tiles);
pinky = new Pinky(tileWidth, tileHeight, mazeWidth, tiles);
eatGhost = new Sound("data/pacmanSound/eatGhost.wav");
death = new Sound("data/pacmanSound/death.wav");
eatSuperPill = new Sound("data/pacmanSound/eatSuperPill.wav");
}
示例4: updateGameStatus
import org.newdawn.slick.tiled.TiledMap; //导入依赖的package包/类
/**
* Metoda wywoła się przy przejściu przez portal
*
* @param gc Potrzebny do przeładowania camery
*/
public void updateGameStatus(GameContainer gc) {
try {
gs.map = new TiledMap("graphic/map/" + Integer.toString(GameStatus.levelID) + ".tmx");
camera = new core.Camera(gc, gs.map);
//update entity fields:
gs.updateEntityFieldList(gs.map);
//update listy portali na mapie
gs.updatePortalMapList(gs.portalMapList);
//update miniMapy w rogu
hud.frame.miniMapPath = "graphic/miniMap/" + String.valueOf(GameStatus.levelID) + ".png";
hud.frame.miniMap = new Image(hud.frame.miniMapPath);
} catch (SlickException e) {
System.out.println("B R A K minimapy dla tej mapy");
e.printStackTrace();
}
needToMapUpdate = false;
}
示例5: updateEntityFieldList
import org.newdawn.slick.tiled.TiledMap; //导入依赖的package包/类
/**
* Aktualizuje pola aktywne na mapie
* Kolizje, NpcArea,MobsArea
* @param map mapa
*/
public void updateEntityFieldList(TiledMap map) {
for (int i = 8; i < 11; i++) {
exist = new boolean[map.getWidth()][map.getHeight()];
testField = map.getTileId(0, 0, i);
for (int j = 0; j < map.getWidth(); j++) {
for (int k = 0; k < map.getHeight(); k++) {
collisionTileID = map.getTileId(j, k, i);
if (collisionTileID == testField) {
exist[j][k] = true;
}
}
}
if (i == 8) {
updateCollisionFields(map);
}
if (i == 9) {
updateNpcFields(map);
}
if (i == 10) {
updateMobsFields(map);
}
}
}
示例6: init
import org.newdawn.slick.tiled.TiledMap; //导入依赖的package包/类
/**
* @see org.newdawn.slick.BasicGame#init(org.newdawn.slick.GameContainer)
*/
public void init(GameContainer container) throws SlickException {
map = new TiledMap("testdata/testmap.tmx","testdata");
// read some properties from map and layer
mapName = map.getMapProperty("name", "Unknown map name");
monsterDifficulty = map.getLayerProperty(0, "monsters", "easy peasy");
nonExistingMapProperty = map.getMapProperty("zaphod", "Undefined map property");
nonExistingLayerProperty = map.getLayerProperty(1, "beeblebrox", "Undefined layer property");
// store the original tileid of layer 0 at 10, 10
originalTileID = map.getTileId(10, 10, 0);
}
示例7: initMaze
import org.newdawn.slick.tiled.TiledMap; //导入依赖的package包/类
/**
* This method creates the mape based on the game modality
* @param mazeMap
* @param mazeView
* @throws SlickException
*/
public void initMaze(TiledMap mazeMap, MazeView mazeView) throws SlickException{
if(mode.equals("single"))
maze = new SinglePlayer(mazeMap, mazeView);
if(mode.equals("multi"))
maze = new MultiPlayer(mazeMap, mazeView);
if(mode.equals("extreme"))
maze = new Extreme(mazeMap, mazeView);
}
示例8: World
import org.newdawn.slick.tiled.TiledMap; //导入依赖的package包/类
/** Create a new World object. */
public World()
throws SlickException
{
this.map = new TiledMap(Game.ASSETS_PATH + "/map.tmx",
Game.ASSETS_PATH);
this.player = new Player(1332, 13086, Angle.fromDegrees(0));
aiPlayerList = new ArrayList<AIPlayer>();
aiPlayerList.add(new Elephant(1260, 13086, Angle.fromDegrees(0)));
aiPlayerList.add(new Dog(1404, 13086, Angle.fromDegrees(0)));
aiPlayerList.add(new Octopus(1476, 13086, Angle.fromDegrees(0)));
itemList = new ArrayList<Item>();
itemList.add(new OilCan(1350, 12438));
itemList.add(new OilCan(864, 7614));
itemList.add(new OilCan(1962, 6498));
itemList.add(new OilCan(1314, 3690));
itemList.add(new Tomato(990, 11610));
itemList.add(new Tomato(1206, 5130));
itemList.add(new Tomato(1206, 3690));
itemList.add(new Tomato(1422, 2322));
itemList.add(new Boost(990, 10242));
itemList.add(new Boost(1818, 6534));
itemList.add(new Boost(990, 4302));
itemList.add(new Boost(1926, 3510));
panel = new Panel();
hazardList = new ArrayList<Hazard>();
}
示例9: Level
import org.newdawn.slick.tiled.TiledMap; //导入依赖的package包/类
public Level(String level, Player player) throws SlickException {
map = new TiledMap("ressources/level/" + level + ".tmx");
background = new Image("ressources/background/" + map.getMapProperty("back.png", "back.png"));
characters = new ArrayList<Character>();
levelObjects = new ArrayList<LevelObject>();
this.player = player;
addCharacter(player);
loadTileMap();
loadLimite();
loadEnd();
}
示例10: GameStatus
import org.newdawn.slick.tiled.TiledMap; //导入依赖的package包/类
public GameStatus() throws SlickException {
musicOn = true;
//ustawianie pozycji startu gry
this.levelID = 100;
mapPath = "graphic/map/" + Integer.toString(levelID) + ".tmx";
map = new TiledMap(mapPath);
spriteNumber = 1;
this.sprite = new Sprite();
this.x = 238;
this.y = 200;
//czysty bohater
this.hero = new Hero();
this.itemsInBag = new HashMap<>();
this.equipInBag = new HashMap<>();
this.itemsInGame = new HashMap<>();
this.equipInGame = new HashMap<>();
this.quest = new ArrayList<>();
this.skills = new ArrayList<>();
this.money = 0;
//na pierwszej mapie nie ma mobów czy npc - więc kolekcje puste
this.npc = gameUtils.NpcData.dataSeeder();
this.enemy = gameUtils.EnemyData.enemyData();
this.portalMapList = new ArrayList<model.Portal>();
//wczytanie danych o mapie
updateEntityFieldList(map);
updatePortalMapList(portalMapList);
loadAllItemsInGame(itemsInGame);
loadAllEquipInGame(equipInGame);
}
示例11: updateCollisionFields
import org.newdawn.slick.tiled.TiledMap; //导入依赖的package包/类
/**
* Metoda znajdująca pola kolizyjne
* @param map Aktualna mapa
*/
public void updateCollisionFields(TiledMap map) {
collisions = new ArrayList<>();
for (int i = 0; i < map.getWidth(); i++) {
for (int j = 0; j < map.getHeight(); j++) {
if (exist[i][j] == true) {
recField = new Rectangle(i * 32, j * 32, 32, 32);
collisions.add(recField);
}
}
}
collisions.trimToSize();
}
示例12: updateNpcFields
import org.newdawn.slick.tiled.TiledMap; //导入依赖的package包/类
public void updateNpcFields(TiledMap map) {
npc = new ArrayList<>();
for (int i = 0; i < map.getWidth(); i++) {
for (int j = 0; j < map.getHeight(); j++) {
if (exist[i][j] == true) {
recField = new Rectangle(i * 32, j * 32, 32, 32);
npc.add(recField);
}
}
}
}
示例13: updateMobsFields
import org.newdawn.slick.tiled.TiledMap; //导入依赖的package包/类
public void updateMobsFields(TiledMap map) {
mobs = new ArrayList<>();
for (int i = 0; i < map.getWidth(); i++) {
for (int j = 0; j < map.getHeight(); j++) {
if (exist[i][j] == true) {
recField = new Rectangle(i * 32, j * 32, 32, 32);
mobs.add(recField);
}
}
}
}
示例14: TileMap
import org.newdawn.slick.tiled.TiledMap; //导入依赖的package包/类
/**
* The constructor. Takes the path for the .tmx and the x and y coordinates.
*
* @param path The path of the .tmx file
* @param x The x coordinate
* @param y The y coordinate
* @throws SlickException
*/
public TileMap(String path, float x, float y) throws SlickException{
super(x, y, 0, 0);
theTileMap = new TiledMap(path);
this.setX(x);
this.setY(y);
this.setWidth(theTileMap.getWidth() * theTileMap.getTileWidth());
this.setHeight(theTileMap.getHeight() * theTileMap.getTileHeight());
TileSet theTileSet = theTileMap.getTileSet(0);
SpriteSheet sheet = theTileSet.tiles;
}
示例15: init
import org.newdawn.slick.tiled.TiledMap; //导入依赖的package包/类
@Override
public void init(GameContainer gc, StateBasedGame sbg)throws SlickException {
levelMap1 = new TiledMap("/res/hmmm.tmx");
background = new Image("/res/Background.png");
Image [] movementUp = {new Image("/res/wmg1_bk1.png"), new Image("/res/wmg1_bk2.png")};
Image [] movementDown = {new Image("/res/wmg1_fr1.png"), new Image("/res/wmg1_fr2.png")};
Image [] movementLeft = {new Image("/res/wmg1_lf1.png"), new Image("/res/wmg1_lf2.png")};
Image [] movementRight = {new Image("/res/wmg1_rt1.png"), new Image("/res/wmg1_rt2.png")};
int [] duration = {300, 300};
up = new Animation(movementUp, duration, false);
down = new Animation(movementDown, duration, false);
left = new Animation(movementLeft, duration, false);
right = new Animation(movementRight, duration, false);
sprite = right;
blocked = new boolean[levelMap1.getWidth()][levelMap1.getHeight()];
for (int xAxis=0;xAxis<levelMap1.getWidth(); xAxis++)
{
for (int yAxis=0;yAxis<levelMap1.getHeight(); yAxis++)
{
int tileID = levelMap1.getTileId(xAxis, yAxis, 0);
String value = levelMap1.getTileProperty(tileID, "blocked", "false");
if ("true".equals(value))
{
blocked[xAxis][yAxis] = true;
}
}
}
}