Compare commits

..

No commits in common. "82104f7859849316ccfae4305686154574c321f5" and "501cdba9954bf3e51b35d462947e79dd717707f3" have entirely different histories.

3 changed files with 4 additions and 45 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 KiB

View file

@ -29,23 +29,11 @@ public class Game extends JPanel implements ActionListener, KeyListener {
private int planetYOffset = 0;
private String planetYOffsetDirection = "up"; // this makes the cool floating animation on the main menu
private int planetX = 580;
private int planetY = 140 + planetYOffset /6;
private int planetY = 120+ planetYOffset /6;
private int planetSize = 128*3;
private Rectangle planetCollision = new Rectangle(planetX, planetY, planetSize, planetSize);
private boolean hoveringOverPlanet = false;
private BufferedImage button;
private BufferedImage buttonh;
private int buttonX = 130;
private int playButtonY = 210;
private int quitButtonY = 350;
private int buttonWidth = 108*3;
private int buttonHeight = 108;
private Rectangle playButtonCollision = new Rectangle(buttonX, playButtonY, buttonWidth, buttonHeight);
private Rectangle quitButtonCollision = new Rectangle(buttonX, quitButtonY, buttonWidth, buttonHeight);
private boolean hoveringOverPlayButton = false;
private boolean hoveringOverQuitButton = false;
public Game() {
// sets the window size
setPreferredSize(new Dimension(windowWidth,windowHeight));
@ -66,8 +54,6 @@ public class Game extends JPanel implements ActionListener, KeyListener {
try {
planetZX311 = ImageIO.read(new File("assets/planet-ZX311.png"));
planetZX311h = ImageIO.read(new File("assets/planet-ZX311_highlighted.png"));
button = ImageIO.read(new File("assets/button.png"));
buttonh = ImageIO.read(new File("assets/button_highlighted.png"));
} catch (IOException e) {
e.printStackTrace();
}
@ -91,8 +77,6 @@ public class Game extends JPanel implements ActionListener, KeyListener {
@Override
public void actionPerformed(ActionEvent e) { // update step
hoveringOverPlanet = planetCollision.contains(mouseX, mouseY);
hoveringOverPlayButton = playButtonCollision.contains(mouseX, mouseY);
hoveringOverQuitButton = quitButtonCollision.contains(mouseX, mouseY);
if (planetYOffsetDirection == "up") {
planetYOffset++;
if (planetYOffset > 90) {
@ -104,7 +88,7 @@ public class Game extends JPanel implements ActionListener, KeyListener {
planetYOffsetDirection = "up";
}
}
planetY = 140 + planetYOffset /6;
planetY = 120+ planetYOffset /6;
repaint(); // triggers render
}
@ -118,8 +102,8 @@ public class Game extends JPanel implements ActionListener, KeyListener {
}
g.setColor(Color.GRAY);
g.setFont(caveat.deriveFont(Font.BOLD, 100f));
g.drawString("Very Cool Space Sim", 40, 100);
g.setFont(caveat.deriveFont(Font.BOLD, 96f));
g.drawString("Very Cool Space Sim", 136, 96);
if (planetZX311 != null) {
if (!hoveringOverPlanet) {
@ -128,31 +112,6 @@ public class Game extends JPanel implements ActionListener, KeyListener {
g.drawImage(planetZX311h, planetX, planetY, planetSize, planetSize, this);
}
}
if (button != null) {
if (!hoveringOverPlayButton) {
g.drawImage(button, buttonX, playButtonY, buttonWidth, buttonHeight, this);
g.setColor(Color.BLACK);
g.setFont(caveat.deriveFont(Font.BOLD, 48f));
g.drawString("Start the game", buttonX+25, playButtonY+67);
} else {
g.drawImage(buttonh, buttonX, playButtonY, buttonWidth, buttonHeight, this);
g.setColor(Color.WHITE);
g.setFont(caveat.deriveFont(Font.BOLD, 48f));
g.drawString("Start the game", buttonX+25, playButtonY+67);
}
if (!hoveringOverQuitButton) {
g.drawImage(button, buttonX, quitButtonY, buttonWidth, buttonHeight, this);
g.setColor(Color.BLACK);
g.setFont(caveat.deriveFont(Font.BOLD, 40f));
g.drawString("Quit (pretty lame)", buttonX+24, quitButtonY+67);
} else {
g.drawImage(buttonh, buttonX, quitButtonY, buttonWidth, buttonHeight, this);
g.setColor(Color.WHITE);
g.setFont(caveat.deriveFont(Font.BOLD, 40f));
g.drawString("Quit (pretty lame)", buttonX+24, quitButtonY+67);
}
}
}
@Override