当前位置: 首页>>代码示例>>Java>>正文


Java TiledMap类代码示例

本文整理汇总了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());
//	        }
//	   });
	
	}
 
开发者ID:EnzoMolion,项目名称:Projet-PLA,代码行数:37,代码来源:WindowGame.java

示例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);
}
 
开发者ID:IngSW-unipv,项目名称:Progetto-C,代码行数:23,代码来源:MazeView.java

示例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");
}
 
开发者ID:IngSW-unipv,项目名称:Progetto-C,代码行数:28,代码来源:MazeModality.java

示例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;
}
 
开发者ID:Kalwador,项目名称:Java-2D-Game,代码行数:26,代码来源:PlayState.java

示例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);
        }
    }

}
 
开发者ID:Kalwador,项目名称:Java-2D-Game,代码行数:30,代码来源:LoadEntity.java

示例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);
}
 
开发者ID:j-dong,项目名称:trashjam2017,代码行数:15,代码来源:TileMapTest.java

示例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);
}
 
开发者ID:IngSW-unipv,项目名称:Progetto-C,代码行数:15,代码来源:PacmanGame.java

示例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>();
}
 
开发者ID:lhCheung1991,项目名称:car_game,代码行数:32,代码来源:World.java

示例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();

   }
 
开发者ID:maloz,项目名称:p2_java_plateformed2d,代码行数:14,代码来源:Level.java

示例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);
}
 
开发者ID:Kalwador,项目名称:Java-2D-Game,代码行数:38,代码来源:GameStatus.java

示例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();
}
 
开发者ID:Kalwador,项目名称:Java-2D-Game,代码行数:17,代码来源:LoadEntity.java

示例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);
            }
        }
    }
}
 
开发者ID:Kalwador,项目名称:Java-2D-Game,代码行数:12,代码来源:LoadEntity.java

示例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);
            }
        }
    }
}
 
开发者ID:Kalwador,项目名称:Java-2D-Game,代码行数:12,代码来源:LoadEntity.java

示例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;
}
 
开发者ID:dstumpff,项目名称:VortexGameLibrary,代码行数:20,代码来源:TileMap.java

示例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;
                 }
             }
         }
     }
 
开发者ID:GokulEvuri,项目名称:VenganceRabbit,代码行数:33,代码来源:Play.java


注:本文中的org.newdawn.slick.tiled.TiledMap类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。