Дело в том, что с моим кодом, полагаю, всё в порядке...
Вот как организовано:
- архитектура: MVC + ECS
- в моем методе рендеринга класса GameView все отображается
li>
Я использую базы и веторов для преобразования между двумя базами (ортогональной и изометрической)
Код: Выделить всё
public void render() {
try {
final Entity[] entities = this.controller.getEntities();
// Sort entities by isometric depth
Arrays.sort(entities, (e1, e2) -> {
PositionComponent p1 = e1.getComponent(PositionComponent.class);
PositionComponent p2 = e2.getComponent(PositionComponent.class);
// Calculate depth as the sum of cartesian x + y
double depth1 = p1.getX() + p1.getY();
double depth2 = p2.getX() + p2.getY();
// Primary sorting criterion: depth
int result = Double.compare(depth1, depth2);
// Secondary sorting: cartesian Y coordinate
if (result == 0) {
result = Double.compare(p1.getY(), p2.getY());
}
// Tertiary sorting: cartesian X coordinate
if (result == 0) {
result = Double.compare(p1.getX(), p2.getX());
}
// Fallback sorting: hashCode
if (result == 0) {
result = Integer.compare(e1.hashCode(), e2.hashCode());
}
return result;
});
for (Entity entity : entities) {
// Get position component
PositionComponent position = entity.getComponent(PositionComponent.class);
// Convert to isometric coordinates
Vector isoPos = this.gameBase.mulByVect(
new Vector2D(position.getX(), position.getY())
);
// Debug: print isometric position
// System.out.println("Isometric Position: " + isoPos);
// Get texture component
ImageIcon image = entity.getComponent(TextureComponent.class).getTexture();
// Create label for the entity
JLabel label = new JLabel(image);
// Set bounds based on isometric position
label.setBounds(
(int) isoPos.getEntry(0),
(int) isoPos.getEntry(1),
image.getIconWidth(),
image.getIconHeight()
);
this.panel.add(label);
}
// Revalidate and repaint after adding all entities
this.panel.revalidate();
this.panel.repaint();
} catch (Exception e) {
e.printStackTrace();
}
}
У вас есть идеи?
Конечно, если нужно, не стесняйтесь задавать столько вопросов, сколько захотите!
Большое спасибо!
Подробнее здесь: https://stackoverflow.com/questions/792 ... tric-tiles
Мобильная версия