Низкий фпс на android в libgdx при отрисовке карты
Всем доброго времени суток. У меня есть карта в виде двумерного массива 1000x300 в ней записаны цифры ,означающие то,что нужно отрисовать 0 - пустота, 1 - земля ,2 - трава ..... и т.д.
Я рисую с помощью libgdx на spriteBatch (canvas) ток часть массива по размеру экрана 1 клеточка = 24x24px SIZE = 24 ,если размеры экрана 1500x720 то я буду отрисовывть 1500/SIZEx720/SIZE
это примерно 63x30
но у меня при запуске на samsung m12 при 120 Ghz 30 фпс максимум а среднее значение в районе 20,при смене на 60Ghz максимум 40фпс а среднее в районе 28-32 фпс
,
естественно это мало.Я хотел бы 60фпс при 120Ghz и выше,была идея отрисовать эту карту полностью на отдельный спрайт а потом его рисовать на спрайтбатче,как это сделать и сможет ли это помочь?
if (System.currentTimeMillis() - time >= 1000) {
time = System.currentTimeMillis();
fps = cadrs;
cadrs = 0;
Log.e("FPS",""+fps)
} else {
cadrs++;
}
Gdx.gl.glClearColor(0f, 0f, 0f, 1f)
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT)
canvas!!.begin()
var startI: Int =
(floor(px / SIZE - Gdx.graphics.width / SIZE / 3) - 8).toInt();
var endI: Int =
floor(px / SIZE + Gdx.graphics.width / SIZE / 3 * 2.1).toInt();
for (i in (startI)..(endI)) {
if (i < 0 || i >= mapController.arr.size) {
continue;
}
var startE: Int =
floor(py / SIZE - Gdx.graphics.height / SIZE / 3 * 1.18 + 0.7).toInt()
var endE: Int =
(floor(py / SIZE + Gdx.graphics.height / SIZE / 3 * (hightTop + 0.7)) + 8).toInt()
for (j in (startE)..(endE)) {
if (j < 0 || j >= mapController.arr[0].size) {
continue;
}
var posx: Float =
(i * size - px + (Gdx.graphics.width / 3))
var posy: Float =
(py * -1 + j * size + Gdx.graphics.height / 3 * hightTop).toFloat();
if (mapController.arr[i][j] == 2 || mapController.arr[i][j] == 1) {
if (mapController.arr[i][j] == 2) {
if (i > 0 && mapController.arr[i - 1][j] == 2 && mapController.arr[i][j - 1] == 2) {
draw(
image_grass_piece,
posx,
posy
)
} else if (1 + i < mapController.arr.size && mapController.arr[i + 1][j] == 2 && mapController.arr[i][j - 1] == 2) {
draw(
image_grass_piece,
posx,
posy
)
} else if (mapController.arr[i][j + 1] == 2 && i + 1 < mapController.arr.size && mapController.arr[i + 1][j] == 2) {
draw(
image_grass_left,
posx,
posy
)
} else if (mapController.arr[i][j + 1] == 2 && j + 1 < mapController.arr[0].size && mapController.arr[i - 1][j] == 2 && i > 0) {
draw(
image_grass_right,
posx,
posy
)
} else {
// data.drawImage()
draw(
image_grass_piece,
posx,
posy
);
// data.drawImage(image_grass_piece,0,0,image_grass_piece.width,image_grass_piece.height,i * size - this.player.position.x + Gdx.graphics.width / 3, this.player.position.y * -1 + j * size + Gdx.graphics.height / 3 * hightTop, SIZE, SIZE)
// data.drawImage(image_grass, 19, 0, 14, 15, i * size - this.player.position.x + Gdx.graphics.width / 3, this.player.position.y * -1 + j * size + Gdx.graphics.height / 3 * hightTop, SIZE, SIZE)
}
}
if (mapController.arr[i][j] == 1) {
// console.log(g)
// data.drawImage(image_ground_piece, i * size - this.player.position.x + Gdx.graphics.width / 3, this.player.position.y * -1 + j * size + Gdx.graphics.height / 3 * hightTop);
// image_ground_piece
draw(
image_ground_tile,
(posx),
(posy)
)
}
}
var opx: Float =
posx;
var opy: Float =
posy;
if (mapController.arr[i][j] == 3) {
// console.log("glizinia ...")
draw(
image_glizinia,
opx.toFloat(),
(opy - START_SIZE * 6 / dt).toFloat()
)
// data.drawImage(image_glizinia, 0, 0, image_glizinia.width, image_glizinia.height, i * size - this.player.position.x + Gdx.graphics.width / 3-image_glizinia.width/2/dt, this.player.position.y * -1 + j * size + Gdx.graphics.height / 3 * hightTop - START_SIZE * 6 / dt, START_SIZE * 8 / dt, START_SIZE * 8 / dt);
}
if (mapController.arr[i][j] == 9) {
// console.log("glizinia ...")
draw(
image_glizinia2,
opx.toFloat(),
(opy - START_SIZE * 6.5 / dt).toFloat()
);
//data.drawImage(image_glizinia2, 0, 0, image_glizinia2.width, image_glizinia2.height, i * size - this.player.position.x + Gdx.graphics.width / 3, this.player.position.y * -1 + j * size + Gdx.graphics.height / 3 * hightTop - START_SIZE * 6.5 / dt, START_SIZE * 8 / dt, START_SIZE * 8 / dt);
}
if (mapController.arr[i][j] == 8) {
// data.fillStyle = "#000000"
//data.fillRect( i * size - this.player.position.x + Gdx.graphics.width / 3, this.player.position.y * -1 + j * size + Gdx.graphics.height / 3 * hightTop, SIZE, SIZE)
draw(
image_trees,
opx.toFloat(),
(opy - START_SIZE * 6 / dt).toFloat()
)
// console.log("glizinia ...")
//data.drawImage(image_trees, 0, 0, image_trees.width, image_trees.height, i * size - this.player.position.x + Gdx.graphics.width / 3-image_trees.width/2/dt, this.player.position.y * -1 + j * size + Gdx.graphics.height / 3 * hightTop - START_SIZE * 6 / dt, START_SIZE * 8 / dt, START_SIZE * 8 / dt);
}
if (mapController.arr[i][j] == 200) {
draw(image_coin, posx, posy)
}
if (mapController.arr[i][j] == 4) {
draw(image_health, posx, posy)
}
if (mapController.arr[i][j] == 5) {
draw(image_power, posx, posy)
}
if (mapController.arr[i][j] == 6) {
draw(image_amor, posx, posy)
}
if (mapController.arr[i][j] == 7) {
// console.log("nitro")
draw(image_nitro, posx, posy)
}
if (mapController.arr[i][j] == 11) {
draw(
image_house1,
posx,
(this.player.position.y * -1 + j * size + Gdx.graphics.height / 3 * hightTop - START_SIZE * 7 / dt).toFloat()
)
}
if (mapController.arr[i][j] == 12) {
draw(
image_house2,
posx,
(this.player.position.y * -1 + j * size + Gdx.graphics.height / 3 * hightTop - START_SIZE * 6 / dt).toFloat()
)
}
if (mapController.arr[i][j] == 13) {
draw(
image_house3,
posx,
(this.player.position.y * -1 + j * size + Gdx.graphics.height / 3 * hightTop - START_SIZE * 7 / dt).toFloat()
)
}
for (entry in mapController.npcMap.entries.iterator()) {
// print("${entry.key} : ${entry.value}")
//entry.value.draw(data)
}
if ( this.player != null && this.player.animate != null) {
var ww = 160 / 1.3;
var hh = 120 / 1.3;
var top = 0;
if (this.player.type == 50 && images.get1(this.player.id + "_stay_top") != null) {
top = images.get1(this.player.id + "_stay_top");
}
if (this.player.type == 51 && images.get1(this.player.id + "_run_top") != null) {
top = images.get1(this.player.id + "_run_top");
}
//for (l in 0..20 - 1) {
// if (this.player.type == l) {
//if (images.get1(this.player.id + "_" + l + "_top") != null)
// top = images.get1(this.player.id + "_" + l + "_top")
// }
// }
if(animate!=null){
var playerX = Gdx.graphics.width / 3 - ((ww - player.w) / 2 / dt)
var playerY = Gdx.graphics.height / 3 * hightTop - top / dt
/* draw(
player.animate,
(playerX).toFloat(),
(playerY).toFloat(),
paint )
*/
}
}
for (i in 0..mapController.anotherPlayers.size-1) {
var enemy_player = this.mapController.anotherPlayers[i];
if (enemy_player.animate == null) continue;
//data.fillRect(this.posx - this.player.position.x + Gdx.graphics.width / 3, this.posy - this.player.position.y + Gdx.graphics.height / 3 * hightTop, this.sizeX / dt, this.sizeY / dt);
var ppx = enemy_player.position.x - this.player.position.x + Gdx.graphics.width / 3;
var ppy = enemy_player.position.y - this.player.position.y + Gdx.graphics.height / 3 * hightTop;
// data.fillStyle = "#ff0101"
//console.log(enemy_player.idPlayer+" "+(enemy_player.position.x - this.player.position.x + Gdx.graphics.width / 3)+";"+(enemy_player.position.y - this.player.position.y + Gdx.graphics.height / 3 * hightTop));
// data.fillRect(enemy_player.position.x - this.player.position.x + Gdx.graphics.width / 3, enemy_player.position.y - this.player.position.y + Gdx.graphics.height / 3 * hightTop, enemy_player.w / dt, enemy_player.h / dt);
//data.fillRect(posx, posy, 32 / dt, 48 / dt);
// if(this.lll !=0){
if (enemy_player.side == 1) {
// data.save()
// data.scale(-1, 1)
// data.translate(-example.width - (example.width - (example.width - ppx) * 2) - enemy_player.w / 3 * 2 / dt, 0);
// console.log((example.width-(example.width-ppx)*2))
//console.log(-example.width+ppx)
//if(ppx<0 ||ppx>window.innerWidth)return;
// if(ppy<0 ||ppy>window.innerHeight)return;
// ctx.translate(-example.width+ppx, 0)
// this.lll=0;
}
//}
var ww = 160 / 1.3;
var hh = 120 / 1.3;
var top = 0;
if (enemy_player.type == 50 && images.get(enemy_player.id + "_stay_top") != null) {
top = images.get1(enemy_player.id + "_stay_top")
}
if (enemy_player.type == 51 && images.get(enemy_player.id + "_run_top") != null) {
top = images.get1(enemy_player.id + "_run_top")
}
for (l in 0..20) {
if (enemy_player.type == l) {
if (images.get(enemy_player.id + "_" + l + "_top") != null)
top = images.get1(enemy_player.id + "_" + l + "_top")
}
}
// data.drawImage(this.player.animate, 0, 0, this.player.animate.width, this.player.animate.height, Gdx.graphics.width / 3 - ((ww - player.w) / 2 / dt), Gdx.graphics.height / 3 * hightTop - top / dt, ww / dt, hh / dt)
// data.drawImage(enemy_player.animate, 0, 0, enemy_player.animate.width, enemy_player.animate.height, ppx - ((ww - enemy_player.w + 15) / 2 / dt), ppy - (hh - enemy_player.h + 12) / dt, ww / dt, hh / dt)
// draw(enemy_player.animate, (ppx - ((ww - enemy_player.w) / 2 / dt)).toFloat(), (ppy - top / dt).toFloat(),null)
if (enemy_player.side == 1) {
// data.scale(-1, 1)
// ctx.translate(ppx, 0)
// ctx.translate(example.width, 0)
// data.restore();
}
// data.drawImage(enemy_player.animate, 0, 0, enemy_player.animate.width, enemy_player.animate.height, Gdx.graphics.width / 3 - ((ww - enemy_player.w) / 2 / dt), Gdx.graphics.height / 3 * hightTop - top / dt, ww / dt, hh / dt)
// data.drawImage(this.player.animate_shot, Gdx.graphics.width / 3 + this.player.animate_shot.width - ((ww - player.w) / 2 / dt), Gdx.graphics.height / 3 * hightTop - top / dt)
/*if (this.player.side == 1) {
data.scale(-1, 1)
ctx.translate(Gdx.graphics.width / 3 * 2 + player.w / dt, 0)
data.restore();
}
*/
}
}
}
Ответы (1 шт):
Я понял ,в методе отрисовки я пробегался по массиву 63х30 и за один раз я отрисовывал 1869 раз игрока и врагов,я просто вынес отрисовку игрока и врагов за пределы циклов
if (System.currentTimeMillis() - time >= 1000) {
time = System.currentTimeMillis();
fps = cadrs;
cadrs = 0;
Log.e("FPS",""+fps)
} else {
cadrs++;
}
Gdx.gl.glClearColor(0f, 0f, 0f, 1f)
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT)
canvas!!.begin()
var startI: Int =
(floor(px / SIZE - Gdx.graphics.width / SIZE / 3) - 8).toInt();
var endI: Int =
floor(px / SIZE + Gdx.graphics.width / SIZE / 3 * 2.1).toInt();
for (i in (startI)..(endI)) {
if (i < 0 || i >= mapController.arr.size) {
continue;
}
var startE: Int =
floor(py / SIZE - Gdx.graphics.height / SIZE / 3 * 1.18 + 0.7).toInt()
var endE: Int =
(floor(py / SIZE + Gdx.graphics.height / SIZE / 3 * (hightTop + 0.7)) + 8).toInt()
for (j in (startE)..(endE)) {
if (j < 0 || j >= mapController.arr[0].size) {
continue;
}
var posx: Float =
(i * size - px + (Gdx.graphics.width / 3))
var posy: Float =
(py * -1 + j * size + Gdx.graphics.height / 3 * hightTop).toFloat();
if (mapController.arr[i][j] == 2 || mapController.arr[i][j] == 1) {
if (mapController.arr[i][j] == 2) {
if (i > 0 && mapController.arr[i - 1][j] == 2 && mapController.arr[i][j - 1] == 2) {
draw(
image_grass_piece,
posx,
posy
)
} else if (1 + i < mapController.arr.size && mapController.arr[i + 1][j] == 2 && mapController.arr[i][j - 1] == 2) {
draw(
image_grass_piece,
posx,
posy
)
} else if (mapController.arr[i][j + 1] == 2 && i + 1 < mapController.arr.size && mapController.arr[i + 1][j] == 2) {
draw(
image_grass_left,
posx,
posy
)
} else if (mapController.arr[i][j + 1] == 2 && j + 1 < mapController.arr[0].size && mapController.arr[i - 1][j] == 2 && i > 0) {
draw(
image_grass_right,
posx,
posy
)
} else {
// data.drawImage()
draw(
image_grass_piece,
posx,
posy
);
// data.drawImage(image_grass_piece,0,0,image_grass_piece.width,image_grass_piece.height,i * size - this.player.position.x + Gdx.graphics.width / 3, this.player.position.y * -1 + j * size + Gdx.graphics.height / 3 * hightTop, SIZE, SIZE)
// data.drawImage(image_grass, 19, 0, 14, 15, i * size - this.player.position.x + Gdx.graphics.width / 3, this.player.position.y * -1 + j * size + Gdx.graphics.height / 3 * hightTop, SIZE, SIZE)
}
}
if (mapController.arr[i][j] == 1) {
// console.log(g)
// data.drawImage(image_ground_piece, i * size - this.player.position.x + Gdx.graphics.width / 3, this.player.position.y * -1 + j * size + Gdx.graphics.height / 3 * hightTop);
// image_ground_piece
draw(
image_ground_tile,
(posx),
(posy)
)
}
}
//код который вынес - отрисовка врагов и игрока
var opx: Float =
posx;
var opy: Float =
posy;
if (mapController.arr[i][j] == 3) {
// console.log("glizinia ...")
draw(
image_glizinia,
opx.toFloat(),
(opy - START_SIZE * 6 / dt).toFloat()
)
// data.drawImage(image_glizinia, 0, 0, image_glizinia.width, image_glizinia.height, i * size - this.player.position.x + Gdx.graphics.width / 3-image_glizinia.width/2/dt, this.player.position.y * -1 + j * size + Gdx.graphics.height / 3 * hightTop - START_SIZE * 6 / dt, START_SIZE * 8 / dt, START_SIZE * 8 / dt);
}
if (mapController.arr[i][j] == 9) {
// console.log("glizinia ...")
draw(
image_glizinia2,
opx.toFloat(),
(opy - START_SIZE * 6.5 / dt).toFloat()
);
//data.drawImage(image_glizinia2, 0, 0, image_glizinia2.width, image_glizinia2.height, i * size - this.player.position.x + Gdx.graphics.width / 3, this.player.position.y * -1 + j * size + Gdx.graphics.height / 3 * hightTop - START_SIZE * 6.5 / dt, START_SIZE * 8 / dt, START_SIZE * 8 / dt);
}
if (mapController.arr[i][j] == 8) {
// data.fillStyle = "#000000"
//data.fillRect( i * size - this.player.position.x + Gdx.graphics.width / 3, this.player.position.y * -1 + j * size + Gdx.graphics.height / 3 * hightTop, SIZE, SIZE)
draw(
image_trees,
opx.toFloat(),
(opy - START_SIZE * 6 / dt).toFloat()
)
// console.log("glizinia ...")
//data.drawImage(image_trees, 0, 0, image_trees.width, image_trees.height, i * size - this.player.position.x + Gdx.graphics.width / 3-image_trees.width/2/dt, this.player.position.y * -1 + j * size + Gdx.graphics.height / 3 * hightTop - START_SIZE * 6 / dt, START_SIZE * 8 / dt, START_SIZE * 8 / dt);
}
if (mapController.arr[i][j] == 200) {
draw(image_coin, posx, posy)
}
if (mapController.arr[i][j] == 4) {
draw(image_health, posx, posy)
}
if (mapController.arr[i][j] == 5) {
draw(image_power, posx, posy)
}
if (mapController.arr[i][j] == 6) {
draw(image_amor, posx, posy)
}
if (mapController.arr[i][j] == 7) {
// console.log("nitro")
draw(image_nitro, posx, posy)
}
if (mapController.arr[i][j] == 11) {
draw(
image_house1,
posx,
(this.player.position.y * -1 + j * size + Gdx.graphics.height / 3 * hightTop - START_SIZE * 7 / dt).toFloat()
)
}
if (mapController.arr[i][j] == 12) {
draw(
image_house2,
posx,
(this.player.position.y * -1 + j * size + Gdx.graphics.height / 3 * hightTop - START_SIZE * 6 / dt).toFloat()
)
}
if (mapController.arr[i][j] == 13) {
draw(
image_house3,
posx,
(this.player.position.y * -1 + j * size + Gdx.graphics.height / 3 * hightTop - START_SIZE * 7 / dt).toFloat()
)
}
}
}
if (System.currentTimeMillis() - time >= 1000) {
time = System.currentTimeMillis();
fps = cadrs;
cadrs = 0;
Log.e("FPS",""+fps)
} else {
cadrs++;
}
Gdx.gl.glClearColor(0f, 0f, 0f, 1f)
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT)
canvas!!.begin()
var startI: Int =
(floor(px / SIZE - Gdx.graphics.width / SIZE / 3) - 8).toInt();
var endI: Int =
floor(px / SIZE + Gdx.graphics.width / SIZE / 3 * 2.1).toInt();
for (i in (startI)..(endI)) {
if (i < 0 || i >= mapController.arr.size) {
continue;
}
var startE: Int =
floor(py / SIZE - Gdx.graphics.height / SIZE / 3 * 1.18 + 0.7).toInt()
var endE: Int =
(floor(py / SIZE + Gdx.graphics.height / SIZE / 3 * (hightTop + 0.7)) + 8).toInt()
for (j in (startE)..(endE)) {
if (j < 0 || j >= mapController.arr[0].size) {
continue;
}
var posx: Float =
(i * size - px + (Gdx.graphics.width / 3))
var posy: Float =
(py * -1 + j * size + Gdx.graphics.height / 3 * hightTop).toFloat();
if (mapController.arr[i][j] == 2 || mapController.arr[i][j] == 1) {
if (mapController.arr[i][j] == 2) {
if (i > 0 && mapController.arr[i - 1][j] == 2 && mapController.arr[i][j - 1] == 2) {
draw(
image_grass_piece,
posx,
posy
)
} else if (1 + i < mapController.arr.size && mapController.arr[i + 1][j] == 2 && mapController.arr[i][j - 1] == 2) {
draw(
image_grass_piece,
posx,
posy
)
} else if (mapController.arr[i][j + 1] == 2 && i + 1 < mapController.arr.size && mapController.arr[i + 1][j] == 2) {
draw(
image_grass_left,
posx,
posy
)
} else if (mapController.arr[i][j + 1] == 2 && j + 1 < mapController.arr[0].size && mapController.arr[i - 1][j] == 2 && i > 0) {
draw(
image_grass_right,
posx,
posy
)
} else {
// data.drawImage()
draw(
image_grass_piece,
posx,
posy
);
// data.drawImage(image_grass_piece,0,0,image_grass_piece.width,image_grass_piece.height,i * size - this.player.position.x + Gdx.graphics.width / 3, this.player.position.y * -1 + j * size + Gdx.graphics.height / 3 * hightTop, SIZE, SIZE)
// data.drawImage(image_grass, 19, 0, 14, 15, i * size - this.player.position.x + Gdx.graphics.width / 3, this.player.position.y * -1 + j * size + Gdx.graphics.height / 3 * hightTop, SIZE, SIZE)
}
}
if (mapController.arr[i][j] == 1) {
// console.log(g)
// data.drawImage(image_ground_piece, i * size - this.player.position.x + Gdx.graphics.width / 3, this.player.position.y * -1 + j * size + Gdx.graphics.height / 3 * hightTop);
// image_ground_piece
draw(
image_ground_tile,
(posx),
(posy)
)
}
}
var opx: Float =
posx;
var opy: Float =
posy;
if (mapController.arr[i][j] == 3) {
// console.log("glizinia ...")
draw(
image_glizinia,
opx.toFloat(),
(opy - START_SIZE * 6 / dt).toFloat()
)
// data.drawImage(image_glizinia, 0, 0, image_glizinia.width, image_glizinia.height, i * size - this.player.position.x + Gdx.graphics.width / 3-image_glizinia.width/2/dt, this.player.position.y * -1 + j * size + Gdx.graphics.height / 3 * hightTop - START_SIZE * 6 / dt, START_SIZE * 8 / dt, START_SIZE * 8 / dt);
}
if (mapController.arr[i][j] == 9) {
// console.log("glizinia ...")
draw(
image_glizinia2,
opx.toFloat(),
(opy - START_SIZE * 6.5 / dt).toFloat()
);
//data.drawImage(image_glizinia2, 0, 0, image_glizinia2.width, image_glizinia2.height, i * size - this.player.position.x + Gdx.graphics.width / 3, this.player.position.y * -1 + j * size + Gdx.graphics.height / 3 * hightTop - START_SIZE * 6.5 / dt, START_SIZE * 8 / dt, START_SIZE * 8 / dt);
}
if (mapController.arr[i][j] == 8) {
// data.fillStyle = "#000000"
//data.fillRect( i * size - this.player.position.x + Gdx.graphics.width / 3, this.player.position.y * -1 + j * size + Gdx.graphics.height / 3 * hightTop, SIZE, SIZE)
draw(
image_trees,
opx.toFloat(),
(opy - START_SIZE * 6 / dt).toFloat()
)
// console.log("glizinia ...")
//data.drawImage(image_trees, 0, 0, image_trees.width, image_trees.height, i * size - this.player.position.x + Gdx.graphics.width / 3-image_trees.width/2/dt, this.player.position.y * -1 + j * size + Gdx.graphics.height / 3 * hightTop - START_SIZE * 6 / dt, START_SIZE * 8 / dt, START_SIZE * 8 / dt);
}
if (mapController.arr[i][j] == 200) {
draw(image_coin, posx, posy)
}
if (mapController.arr[i][j] == 4) {
draw(image_health, posx, posy)
}
if (mapController.arr[i][j] == 5) {
draw(image_power, posx, posy)
}
if (mapController.arr[i][j] == 6) {
draw(image_amor, posx, posy)
}
if (mapController.arr[i][j] == 7) {
// console.log("nitro")
draw(image_nitro, posx, posy)
}
if (mapController.arr[i][j] == 11) {
draw(
image_house1,
posx,
(this.player.position.y * -1 + j * size + Gdx.graphics.height / 3 * hightTop - START_SIZE * 7 / dt).toFloat()
)
}
if (mapController.arr[i][j] == 12) {
draw(
image_house2,
posx,
(this.player.position.y * -1 + j * size + Gdx.graphics.height / 3 * hightTop - START_SIZE * 6 / dt).toFloat()
)
}
if (mapController.arr[i][j] == 13) {
draw(
image_house3,
posx,
(this.player.position.y * -1 + j * size + Gdx.graphics.height / 3 * hightTop - START_SIZE * 7 / dt).toFloat()
)
}
}
}
for (entry in mapController.npcMap.entries.iterator()) {
// print("${entry.key} : ${entry.value}")
//entry.value.draw(data)
}
if ( this.player != null && this.player.animate != null) {
var ww = 160 / 1.3;
var hh = 120 / 1.3;
var top = 0;
if (this.player.type == 50 && images.get1(this.player.id + "_stay_top") != null) {
top = images.get1(this.player.id + "_stay_top");
}
if (this.player.type == 51 && images.get1(this.player.id + "_run_top") != null) {
top = images.get1(this.player.id + "_run_top");
}
//for (l in 0..20 - 1) {
// if (this.player.type == l) {
//if (images.get1(this.player.id + "_" + l + "_top") != null)
// top = images.get1(this.player.id + "_" + l + "_top")
// }
// }
if(animate!=null){
var playerX = Gdx.graphics.width / 3 - ((ww - player.w) / 2 / dt)
var playerY = Gdx.graphics.height / 3 * hightTop - top / dt
/* draw(
player.animate,
(playerX).toFloat(),
(playerY).toFloat(),
paint )
*/
}
}
for (i in 0..mapController.anotherPlayers.size-1) {
var enemy_player = this.mapController.anotherPlayers[i];
if (enemy_player.animate == null) continue;
//data.fillRect(this.posx - this.player.position.x + Gdx.graphics.width / 3, this.posy - this.player.position.y + Gdx.graphics.height / 3 * hightTop, this.sizeX / dt, this.sizeY / dt);
var ppx = enemy_player.position.x - this.player.position.x + Gdx.graphics.width / 3;
var ppy = enemy_player.position.y - this.player.position.y + Gdx.graphics.height / 3 * hightTop;
// data.fillStyle = "#ff0101"
//console.log(enemy_player.idPlayer+" "+(enemy_player.position.x - this.player.position.x + Gdx.graphics.width / 3)+";"+(enemy_player.position.y - this.player.position.y + Gdx.graphics.height / 3 * hightTop));
// data.fillRect(enemy_player.position.x - this.player.position.x + Gdx.graphics.width / 3, enemy_player.position.y - this.player.position.y + Gdx.graphics.height / 3 * hightTop, enemy_player.w / dt, enemy_player.h / dt);
//data.fillRect(posx, posy, 32 / dt, 48 / dt);
// if(this.lll !=0){
if (enemy_player.side == 1) {
// data.save()
// data.scale(-1, 1)
// data.translate(-example.width - (example.width - (example.width - ppx) * 2) - enemy_player.w / 3 * 2 / dt, 0);
// console.log((example.width-(example.width-ppx)*2))
//console.log(-example.width+ppx)
//if(ppx<0 ||ppx>window.innerWidth)return;
// if(ppy<0 ||ppy>window.innerHeight)return;
// ctx.translate(-example.width+ppx, 0)
// this.lll=0;
}
//}
var ww = 160 / 1.3;
var hh = 120 / 1.3;
var top = 0;
if (enemy_player.type == 50 && images.get(enemy_player.id + "_stay_top") != null) {
top = images.get1(enemy_player.id + "_stay_top")
}
if (enemy_player.type == 51 && images.get(enemy_player.id + "_run_top") != null) {
top = images.get1(enemy_player.id + "_run_top")
}
for (l in 0..20) {
if (enemy_player.type == l) {
if (images.get(enemy_player.id + "_" + l + "_top") != null)
top = images.get1(enemy_player.id + "_" + l + "_top")
}
}
// data.drawImage(this.player.animate, 0, 0, this.player.animate.width, this.player.animate.height, Gdx.graphics.width / 3 - ((ww - player.w) / 2 / dt), Gdx.graphics.height / 3 * hightTop - top / dt, ww / dt, hh / dt)
// data.drawImage(enemy_player.animate, 0, 0, enemy_player.animate.width, enemy_player.animate.height, ppx - ((ww - enemy_player.w + 15) / 2 / dt), ppy - (hh - enemy_player.h + 12) / dt, ww / dt, hh / dt)
// draw(enemy_player.animate, (ppx - ((ww - enemy_player.w) / 2 / dt)).toFloat(), (ppy - top / dt).toFloat(),null)
if (enemy_player.side == 1) {
// data.scale(-1, 1)
// ctx.translate(ppx, 0)
// ctx.translate(example.width, 0)
// data.restore();
}
// data.drawImage(enemy_player.animate, 0, 0, enemy_player.animate.width, enemy_player.animate.height, Gdx.graphics.width / 3 - ((ww - enemy_player.w) / 2 / dt), Gdx.graphics.height / 3 * hightTop - top / dt, ww / dt, hh / dt)
// data.drawImage(this.player.animate_shot, Gdx.graphics.width / 3 + this.player.animate_shot.width - ((ww - player.w) / 2 / dt), Gdx.graphics.height / 3 * hightTop - top / dt)
/*if (this.player.side == 1) {
data.scale(-1, 1)
ctx.translate(Gdx.graphics.width / 3 * 2 + player.w / dt, 0)
data.restore();
}
*/
}