Created first panel and added it to window
This commit is contained in:
@@ -10,6 +10,11 @@ public class Boot {
|
|||||||
window.setResizable(false);
|
window.setResizable(false);
|
||||||
window.setTitle("JGame2D");
|
window.setTitle("JGame2D");
|
||||||
|
|
||||||
|
GamePanel gamePanel = new GamePanel();
|
||||||
|
window.add(gamePanel);
|
||||||
|
|
||||||
|
window.pack();
|
||||||
|
|
||||||
window.setLocationRelativeTo(null);
|
window.setLocationRelativeTo(null);
|
||||||
window.setVisible(true);
|
window.setVisible(true);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,10 +1,25 @@
|
|||||||
package de.mp.jgame2d.core;
|
package de.mp.jgame2d.core;
|
||||||
|
|
||||||
import javax.swing.*;
|
import javax.swing.*;
|
||||||
|
import java.awt.*;
|
||||||
|
|
||||||
public class GamePanel extends JPanel {
|
public class GamePanel extends JPanel {
|
||||||
|
|
||||||
// SCREEN SETTINGS
|
// SCREEN SETTINGS
|
||||||
final int originalTileSize = 16; //16x16 tile
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user