I am trying to create a game with markers and I ran into a problem. I can’t get more than 17 frames per second after about 500 bullets. The update logic code takes about 1-4 ms for all of them, while the visualization code takes about 40 ms
At the moment, my code
private void drawEntities(Canvas canvas) {
for (HashMap<UUID, Spatial> h: spatialList) {
for (Spatial spatial: h.values()) {
spatial.render(canvas);
if(spatial.life > 0)
spatial.life--;
else if (spatial.life == 0)
engine.deleteEntity(spatial.owner);
}
}
}
spacesList is an array in which each index is a zLevel
The space that displays the actual bullet,
public void render(Canvas canvas) {
float angle = (float) (vel.getAngle() * (180 / Math.PI));
matrix.reset();
matrix.setTranslate(pos.x - bullet.getWidth() / 2, pos.y - bullet.getHeight() / 2);
matrix.postRotate(angle + 90, pos.x, pos.y);
canvas.drawBitmap(bullet, matrix, paint);
canvas.drawCircle(pos.x, pos.y, col.getRadius(), paint);
}
I can provide more code, but this is apparently the main problem. I have tried everything that I can think of and can no longer find it on the Internet. The only thing I can think of to fix this is to switch from surface view to GLSurfaceview, but I really think there is a better way, and I'm just using bad code.
: , drawcircle, 40 ~ 500, - .
TL;DR; 500 = 17 fps.