1 package org.loon.game.simple.alldirection.rpg;2 import java.awt.Color;3 import java.awt.Graphics;4 import java.io.IOException;5 import java.util.List;6 import org.loon.game.simple.alldirection.GraphicsUtils;7 import org.loon.game.simple.alldirection.LSystem;8 publicclass RpgMap implements Config {9 privateImageMapFactory imageMap;10 privateRoles roles;11 privatebooleanshowGrid;12 privateField2D map2d;13 privateintfirstTileX;14 privateintfirstTileY;15 privateintlastTileX;16 privateintlastTileY;17 publicRpgMap(StringimageFile,StringmapFile) {18 try {19 imageMap=newImageMapFactory(imageFile, mapFile);20 } catch (IOException e) {21 thrownewRuntimeException(e);22 }23 this.map2d=newField2D(imageMap.getMap());24 this.roles=newRoles();25 }26 publicvoid addRole(Role role) {27 roles.addChara(role);28 }29 publicRole getHero() {30 return roles.getHero();31 }32 publicvoid setupHero(Role hero) {33 roles.mainHero(hero);34 }35 publicsynchronized void draw(Graphics g,intoffsetX,intoffsetY) {36 firstTileX=pixelsToTiles(-offsetX);37 lastTileX=firstTileX+pixelsToTiles(LSystem.WIDTH)+1;38 lastTileX=Math.min(lastTileX, getRow());39 firstTileY=pixelsToTiles(-offsetY);40 lastTileY=firstTileY+pixelsToTiles(LSystem.HEIGHT)+1;41 lastTileY=Math.min(lastTileY, getCol());42 for(inti=firstTileX; i
java游戏地图_Java中2.5D游戏八方走法实现原理及相关代码
最新推荐文章于 2021-07-12 14:55:17 发布