Created first panel and added it to window

This commit is contained in:
2025-11-26 20:19:17 +01:00
parent fb9ccc1d35
commit ac076e90b5
2 changed files with 20 additions and 0 deletions

View File

@@ -10,6 +10,11 @@ public class Boot {
window.setResizable(false);
window.setTitle("JGame2D");
GamePanel gamePanel = new GamePanel();
window.add(gamePanel);
window.pack();
window.setLocationRelativeTo(null);
window.setVisible(true);
}

View File

@@ -1,10 +1,25 @@
package de.mp.jgame2d.core;
import javax.swing.*;
import java.awt.*;
public class GamePanel extends JPanel {
// SCREEN SETTINGS
final int originalTileSize = 16; //16x16 tile
final int scale = 3;
final int tileSize = originalTileSize * scale; //48x48 tile
// 4:3 ratio
final int maxScreenCol = 16;
final int maxScreenRow = 12;
final int screenWidth = tileSize * maxScreenCol; // 768 pixels
final int screenHeight = tileSize * maxScreenRow; // 576 pixels
public GamePanel() {
this.setPreferredSize(new Dimension(screenWidth, screenHeight));
this.setBackground(Color.black);
this.setDoubleBuffered(true);
}
}