Skip to content

Commit

Permalink
fix run on windows
Browse files Browse the repository at this point in the history
  • Loading branch information
LOSEARDES77 committed May 13, 2024
1 parent 36a8124 commit a52c44f
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions JuegoCliente/src/main/java/org/example/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,16 @@
import javax.swing.UIManager;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.Toolkit;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;

public class Main {
public static void main(String[] args) {

if ((System.getProperty("os.name").equals("Linux") && System.getenv("__GLX_VENDOR_LIBRARY_NAME") == null) || !System.getenv("__GLX_VENDOR_LIBRARY_NAME").equals("nvidia")) // If not nvidia and linux
if ((System.getProperty("os.name").equals("Linux") && System.getenv("__GLX_VENDOR_LIBRARY_NAME") == null) || System.getenv("__GLX_VENDOR_LIBRARY_NAME") != null && !System.getenv("__GLX_VENDOR_LIBRARY_NAME").equals("nvidia")) // If not nvidia and linux
System.setProperty("sun.java2d.opengl", "True");

try {
Expand Down Expand Up @@ -94,8 +96,11 @@ private static void newGame(JFrame[] gameFrame, JFrame menuFrame, Color playerCo
if (gameFrame[0] != null)
gameFrame[0].dispose();
gameFrame[0] = new JFrame("Game");
int frameWidth = 1900;
int frameHeight = 1060;
Dimension display = Toolkit.getDefaultToolkit().getScreenSize();
int frameWidth = display.width;
int frameHeight = display.height;


Game game = new Game(frameWidth, frameHeight, gameFrame[0], menuFrame, (int) (Math.random() * 1000) + 1, (int) (Math.random() * 1000) + 1);
game.getPlayer().setBackground(playerColor);
float[] hsb = Color.RGBtoHSB(playerColor.getRed(), playerColor.getGreen(), playerColor.getBlue(), null);
Expand All @@ -112,6 +117,7 @@ private static void newGame(JFrame[] gameFrame, JFrame menuFrame, Color playerCo
gameFrame[0].setUndecorated(true);
gameFrame[0].setResizable(false);
gameFrame[0].setLocationRelativeTo(null);
gameFrame[0].setExtendedState(JFrame.MAXIMIZED_BOTH);

gameFrame[0].addWindowListener(new WindowAdapter() {
@Override
Expand All @@ -128,6 +134,7 @@ private static void newMultiPlayer(JFrame menuFrame) {
int frameWidth = 1900;
int frameHeight = 1060;


JFrame[] gameFrame = new JFrame[1];
gameFrame[0] = new JFrame("Game");
gameFrame[0].setVisible(false);
Expand Down

0 comments on commit a52c44f

Please sign in to comment.