2/2 of the optimisation commit, and also 1/2 commits of the simplification of the code (im just moving stuff from Game.java so that not everything is in one file and its easier to read, for example all of the input handling is now in input.java)

This commit is contained in:
dvorakmortonxd 2026-10-21 19:41:55 +02:00
commit c74c316932
4 changed files with 249 additions and 228 deletions

View file

@ -4,148 +4,89 @@ import javax.swing.*;
import java.awt.*; import java.awt.*;
import java.awt.event.*; import java.awt.event.*;
import java.awt.Font; import java.awt.Font;
import java.awt.FontFormatException;
import java.io.File;
import java.io.IOException;
import javax.imageio.ImageIO;
import java.awt.image.BufferedImage; import java.awt.image.BufferedImage;
import java.util.Random; import java.util.Random;
public class Game extends JPanel implements ActionListener, KeyListener { public class Game extends JPanel implements ActionListener {
// defines the window dimensions // defines the window dimensions
private final int windowWidth = 900; public final int windowWidth = 900;
private final int windowHeight = 550; public final int windowHeight = 550;
// defines the star count for the main menu and also creates the arrays for the star positions // defines the star count for the main menu and also creates the arrays for the star positions
private final int MENU_STAR_COUNT = 96; public final int MENU_STAR_COUNT = 96;
private final int[] starX = new int[MENU_STAR_COUNT]; public final int[] starX = new int[MENU_STAR_COUNT];
private final int[] starY = new int[MENU_STAR_COUNT]; public final int[] starY = new int[MENU_STAR_COUNT];
private int starSize = 1; public int starSize = 1;
private final Timer timer = new Timer(16, this); // 60 FPS // Font
public static Font caveat;
private Font caveat; public static Font titleCaveat;
private Font titleCaveat;
private int level = 1;
private boolean levelProgress = false; // this is used to make the transition from the main menu to the game level look cool
private int fadeAnimation = 0;
private int mouseX, mouseY;
// predefines all the image assets used // predefines all the image assets used
private BufferedImage rocket; public static BufferedImage rocket;
private BufferedImage rocketTop; public static BufferedImage rocketTop;
private BufferedImage rocketBottom; public static BufferedImage rocketBottom;
private BufferedImage rocketLanding0; public static BufferedImage rocketLanding0;
private BufferedImage rocketLanding1; public static BufferedImage rocketLanding1;
private BufferedImage rocketExhaust; public static BufferedImage rocketExhaust;
private BufferedImage parachute; public static BufferedImage parachute;
private BufferedImage button; public static BufferedImage button;
private BufferedImage buttonH; public static BufferedImage buttonH;
private BufferedImage planetZX311; public static BufferedImage planetZX311;
private BufferedImage planetZX311H; public static BufferedImage planetZX311H;
private BufferedImage landingPlatform; public static BufferedImage landingPlatform;
private BufferedImage sun; public static BufferedImage sun;
// predefines all the player sprites (tabbed because its technically a part of the last comment lol) // predefines all the player sprites (tabbed because its technically a part of the last comment lol)
private BufferedImage playerForward0; public static BufferedImage playerForward0;
private BufferedImage playerForward1; public static BufferedImage playerForward1;
private BufferedImage playerForward2; public static BufferedImage playerForward2;
private BufferedImage playerBackward0; public static BufferedImage playerBackward0;
private BufferedImage playerBackward1; public static BufferedImage playerBackward1;
private BufferedImage playerBackward2; public static BufferedImage playerBackward2;
private BufferedImage playerLeft0; public static BufferedImage playerLeft0;
private BufferedImage playerLeft1; public static BufferedImage playerLeft1;
private BufferedImage playerLeft2; public static BufferedImage playerLeft2;
private BufferedImage playerRight0; public static BufferedImage playerRight0;
private BufferedImage playerRight1; public static BufferedImage playerRight1;
private BufferedImage playerRight2; public static BufferedImage playerRight2;
private int hoverYOffset = 0; public final Timer timer = new Timer(16, this); // 60 FPS
private String hoverDirection = "up"; // this makes the cool floating animation on the main menu
private int planetX = 450; public int mouseX, mouseY;
private int planetYPre = 140;
private int planetY = planetYPre + hoverYOffset /6; public int level = 1;
private int planetSize = 128*3; public boolean levelProgress = false; // this is used to make the transition from the Game menu to the game level look cool
private Rectangle planetCollision = new Rectangle(planetX, planetY, planetSize, planetSize); public int fadeAnimation = 0;
private boolean hoveringOverPlanet = false;
public int hoverYOffset = 0;
public String hoverDirection = "up"; // this makes the cool floating animation on the Game menu
public int planetX = 450;
public int planetYPre = 140;
public int planetY = planetYPre + hoverYOffset /6;
public int planetSize = 128*3;
public Rectangle planetCollision = new Rectangle(planetX, planetY, planetSize, planetSize);
public boolean hoveringOverPlanet = false;
int hoverModifier; int hoverModifier;
double opacityModifier; double opacityModifier;
private int playButtonX = 70; public int playButtonX = 70;
private int quitButtonX = 70; public int quitButtonX = 70;
private int playButtonY = 210; public int playButtonY = 210;
private int quitButtonY = 350; public int quitButtonY = 350;
private int buttonWidth = 108*3; public int buttonWidth = 108*3;
private int buttonHeight = 108; public int buttonHeight = 108;
private Rectangle playButtonCollision = new Rectangle(playButtonX, playButtonY, buttonWidth, buttonHeight); public Rectangle playButtonCollision = new Rectangle(playButtonX, playButtonY, buttonWidth, buttonHeight);
private Rectangle quitButtonCollision = new Rectangle(quitButtonX, quitButtonY, buttonWidth, buttonHeight); public Rectangle quitButtonCollision = new Rectangle(quitButtonX, quitButtonY, buttonWidth, buttonHeight);
private boolean hoveringOverPlayButton = false; public boolean hoveringOverPlayButton = false;
private boolean hoveringOverQuitButton = false; public boolean hoveringOverQuitButton = false;
private int rocketYPre = windowHeight/2-125;
private int rocketY = windowHeight/2-125;
private int rocketExhaustY = rocketY;
private int rocketBottomX;
private int rocketBottomY;
private float opacityAnimation = 0.03f;
private int detachTimer = 0;
public Game() {
// sets the window size
setPreferredSize(new Dimension(windowWidth,windowHeight));
// sets the star count for the main menu
Random rand = new Random();
for (int i = 0; i < MENU_STAR_COUNT; i++) {
starX[i] = rand.nextInt(windowWidth);
starY[i] = rand.nextInt(windowHeight);
}
// loads up the fonts
try {
caveat = Font.createFont(Font.TRUETYPE_FONT, new File("assets/CaveatBrush-Regular.ttf"));
titleCaveat = caveat.deriveFont(Font.BOLD, 100f);
} catch (FontFormatException | IOException e) {
e.printStackTrace();
caveat = new Font("Arial", Font.PLAIN, 12);
}
// loads up the image assets
try {
planetZX311 = ImageIO.read(new File("assets/planetZX311.png"));
planetZX311H = ImageIO.read(new File("assets/planetZX311Highlighted.png"));
button = ImageIO.read(new File("assets/button.png"));
buttonH = ImageIO.read(new File("assets/buttonHighlighted.png"));
rocket = ImageIO.read(new File("assets/rocket.png"));
rocketExhaust = ImageIO.read(new File("assets/rocketExhaust.png"));
rocketTop = ImageIO.read(new File("assets/rocketTop.png"));
rocketBottom = ImageIO.read(new File("assets/rocketBottom.png"));
parachute = ImageIO.read(new File("assets/parachute.png"));
landingPlatform = ImageIO.read(new File("assets/landingPlatform.png"));
rocketLanding0 = ImageIO.read(new File("assets/rocketLanding0.png"));
rocketLanding1 = ImageIO.read(new File("assets/rocketLanding1.png"));
sun = ImageIO.read(new File("assets/sun.png"));
playerForward0 = ImageIO.read(new File("assets/player/playerSpriteForward.png"));
playerForward1 = ImageIO.read(new File("assets/player/playerSpriteForwardWalk0.png"));
playerForward2 = ImageIO.read(new File("assets/player/playerSpriteForwardWalk1.png"));
playerBackward0 = ImageIO.read(new File("assets/player/playerSpriteBackward.png"));
playerBackward1 = ImageIO.read(new File("assets/player/playerSpriteBackwardWalk0.png"));
playerBackward2 = ImageIO.read(new File("assets/player/playerSpriteBackwardWalk1.png"));
playerLeft0 = ImageIO.read(new File("assets/player/playerSpriteLeft.png"));
playerLeft1 = ImageIO.read(new File("assets/player/playerSpriteLeftWalk0.png"));
playerLeft2 = ImageIO.read(new File("assets/player/playerSpriteLeftWalk1.png"));
playerRight0 = ImageIO.read(new File("assets/player/playerSpriteRight.png"));
playerRight1 = ImageIO.read(new File("assets/player/playerSpriteRightWalk0.png"));
playerRight2 = ImageIO.read(new File("assets/player/playerSpriteRightWalk1.png"));
} catch (IOException e) {
e.printStackTrace();
}
initMouse();
setBackground(Color.BLACK);
setFocusable(true);
addKeyListener(this);
timer.start();
}
public int rocketYPre = windowHeight/2-125;
public int rocketY = windowHeight/2-125;
public int rocketExhaustY = rocketY;
public int rocketBottomX;
public int rocketBottomY;
public float opacityAnimation = 0.03f;
public int actionTimer = 0;
@Override @Override
public void actionPerformed(ActionEvent e) { // update step public void actionPerformed(ActionEvent e) { // update step
Random rand = new Random(); Random rand = new Random();
@ -164,7 +105,7 @@ public class Game extends JPanel implements ActionListener, KeyListener {
if (hoverYOffset <= 0) { hoverDirection = "up"; } if (hoverYOffset <= 0) { hoverDirection = "up"; }
} }
hoverYOffset += hoverModifier; hoverYOffset += hoverModifier;
if (opacityAnimation < 1.00f && opacityAnimation > 0.01f) { opacityAnimation += opacityModifier; } opacityAnimation = (float) Math.max(0.01, Math.min(1.0, opacityAnimation + opacityModifier)); // I've replaced this used-to-be if statement with Math.min/max function which makes it so it never goes below 0.01 and above 1.00
if (level == 1) { if (level == 1) {
planetY = planetYPre + hoverYOffset / 6; planetY = planetYPre + hoverYOffset / 6;
if (levelProgress) { if (levelProgress) {
@ -172,7 +113,18 @@ public class Game extends JPanel implements ActionListener, KeyListener {
} }
if (windowWidth - fadeAnimation <= 0) { level = 2; } if (windowWidth - fadeAnimation <= 0) { level = 2; }
} }
if (level == 2) { rocketY = rocketYPre + hoverYOffset / 3; rocketExhaustY = rocketYPre + 150 + hoverYOffset / 2; detachTimer++;} if (level == 2) {
if (actionTimer < 1200) {
opacityAnimation = 0.01f;
}
rocketY = rocketYPre + hoverYOffset / 3;
rocketExhaustY = rocketYPre + 150 + hoverYOffset / 2;
actionTimer++;
fadeAnimation += 20;
if (actionTimer > 1760) {
level = 3;
}
}
repaint(); // triggers render repaint(); // triggers render
} }
@ -184,7 +136,6 @@ public class Game extends JPanel implements ActionListener, KeyListener {
for (int i = 0; i < MENU_STAR_COUNT; i++) { // drawing the stars for (int i = 0; i < MENU_STAR_COUNT; i++) { // drawing the stars
g.fillOval(starX[i]-starSize, starY[i]-starSize, starSize, starSize); g.fillOval(starX[i]-starSize, starY[i]-starSize, starSize, starSize);
} }
g.setColor(Color.GRAY); g.setColor(Color.GRAY);
g.setFont(titleCaveat); g.setFont(titleCaveat);
g.drawString("Very Cool Space Sim", 72, 100); g.drawString("Very Cool Space Sim", 72, 100);
@ -227,7 +178,7 @@ public class Game extends JPanel implements ActionListener, KeyListener {
} }
} }
else if (level == 2) { else if (level == 2) {
if (detachTimer < 260) { if (actionTimer < 260) {
g.setColor(Color.GRAY); g.setColor(Color.GRAY);
for (int i = 0; i < 16; i++) { // drawing the stars for (int i = 0; i < 16; i++) { // drawing the stars
g.fillOval(starX[i]-starSize, starY[i]-starSize, starSize, starSize); g.fillOval(starX[i]-starSize, starY[i]-starSize, starSize, starSize);
@ -238,56 +189,44 @@ public class Game extends JPanel implements ActionListener, KeyListener {
g2.setComposite(AlphaComposite.SrcOver); // reset so nothing else is transparent g2.setComposite(AlphaComposite.SrcOver); // reset so nothing else is transparent
g.drawImage(rocket, windowWidth / 2 - 73, rocketY, 147, 234, this); g.drawImage(rocket, windowWidth / 2 - 73, rocketY, 147, 234, this);
} else { } else {
if (detachTimer > 320) { if (actionTimer > 320) {
if ((detachTimer-320) / 4 <= 255) { if ((actionTimer -320) / 4 <= 255) {
g.setColor(new Color((detachTimer - 320) / 8, (detachTimer - 320) / 8, (detachTimer - 320) / 4)); g.setColor(new Color((actionTimer - 320) / 8, (actionTimer - 320) / 8, (actionTimer - 320) / 4));
} else { } else {
g.setColor(new Color(127, 127,255)); g.setColor(new Color(127, 127,255));
} }
g.fillRect(0,0,windowWidth,windowHeight); g.fillRect(0,0,windowWidth,windowHeight);
if (detachTimer < 1000) { if (actionTimer < 1000) {
g.setColor(Color.GRAY); g.setColor(Color.GRAY);
for (int i = 0; i < 16; i++) { // drawing the stars for (int i = 0; i < 16; i++) { // drawing the stars
g.fillOval(starX[i] - starSize, starY[i] - starSize, starSize, starSize); g.fillOval(starX[i] - starSize, starY[i] - starSize, starSize, starSize);
} }
} }
if ((rocketYPre + (detachTimer-321)/5) <= 300){ if ((rocketYPre + (actionTimer -321)/5) <= 300){
g.drawImage(parachute, windowWidth / 2 - 73, rocketY - hoverYOffset / 3 - 42 + (detachTimer-321)/5, 147, 90, this); g.drawImage(parachute, windowWidth / 2 - 73, rocketY - hoverYOffset / 3 - 42 + (actionTimer -321)/5, 147, 90, this);
g.drawImage(rocketTop, windowWidth / 2 - 73, rocketY - hoverYOffset / 3 + (detachTimer-321)/5, 147, 84, this); g.drawImage(rocketTop, windowWidth / 2 - 73, rocketY - hoverYOffset / 3 + (actionTimer -321)/5, 147, 84, this);
} else { } else {
Graphics2D g2 = (Graphics2D) g;
if (detachTimer < 1200) { g2.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, opacityAnimation));
opacityAnimation = 0.01f; g2.drawImage(sun, 600, -80, 384, 384, this);
Graphics2D g2 = (Graphics2D) g; g2.setComposite(AlphaComposite.SrcOver); // reset so nothing else is transparent
g2.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, opacityAnimation)); if (actionTimer < 1200) {
g2.drawImage(sun, 600, -80, 384, 384, this); g.drawImage(parachute, windowWidth / 2 - 73, 258, 147, 90, this);
g2.setComposite(AlphaComposite.SrcOver); // reset so nothing else is transparent
g.drawImage(rocketTop, windowWidth / 2 - 73, 300, 147, 84, this); g.drawImage(rocketTop, windowWidth / 2 - 73, 300, 147, 84, this);
} else if (1400 > actionTimer && actionTimer >= 1200) {
g.drawImage(parachute, windowWidth / 2 - 73, 258, 147, 90, this); g.drawImage(parachute, windowWidth / 2 - 73, 258, 147, 90, this);
} else if (1400 > detachTimer && detachTimer >= 1200) {
Graphics2D g2 = (Graphics2D) g;
g2.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, opacityAnimation));
g2.drawImage(sun, 600, -80, 384, 384, this);
g2.setComposite(AlphaComposite.SrcOver); // reset so nothing else is transparent
g.drawImage(rocketLanding0, windowWidth / 2 - 73, 300, 147, 111, this); g.drawImage(rocketLanding0, windowWidth / 2 - 73, 300, 147, 111, this);
} else if (1400 <= actionTimer && actionTimer < 1550) {;
g.drawImage(parachute, windowWidth / 2 - 73, 258, 147, 90, this); g.drawImage(parachute, windowWidth / 2 - 73, 258, 147, 90, this);
} else if (1400 <= detachTimer && detachTimer < 1700) {;
Graphics2D g2 = (Graphics2D) g;
g2.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, opacityAnimation));
g2.drawImage(sun, 600, -80, 384, 384, this);
g2.setComposite(AlphaComposite.SrcOver); // reset so nothing else is transparent
g.drawImage(parachute, windowWidth / 2 - 73, 258+(detachTimer-1400)/3*2, 147, 90, this);
g.drawImage(rocketLanding1, windowWidth / 2 - 73, 300, 147, 111, this); g.drawImage(rocketLanding1, windowWidth / 2 - 73, 300, 147, 111, this);
} else { } else {
level = 3; g.drawImage(parachute, windowWidth / 2 - 73, 258+(actionTimer -1550)*3/2, 147, 90, this); // parachute is falling!
g.drawImage(rocketLanding1, windowWidth / 2 - 73, 300, 147, 111, this);
} }
// (windowHeight-210) is the desired height // (windowHeight-210) is the desired height
if ((1100-(detachTimer / 2 )) >= 340) { if ((1100-(actionTimer / 2 )) >= 340) {
g.drawImage(landingPlatform, 0, 1100-(detachTimer/2), windowWidth, windowWidth/128*30, this); g.drawImage(landingPlatform, 0, 1100-(actionTimer /2), windowWidth, windowWidth/128*30, this);
} else { } else {
g.drawImage(landingPlatform, 0, 340, windowWidth, windowWidth/128*30, this); g.drawImage(landingPlatform, 0, 340, windowWidth, windowWidth/128*30, this);
} }
@ -303,15 +242,14 @@ public class Game extends JPanel implements ActionListener, KeyListener {
Graphics2D g2 = (Graphics2D) g; Graphics2D g2 = (Graphics2D) g;
rocketBottomX = windowWidth / 2 - 73; rocketBottomX = windowWidth / 2 - 73;
rocketBottomY = rocketY - hoverYOffset / 3 + 64 + (detachTimer - 260) * 2; rocketBottomY = rocketY - hoverYOffset / 3 + 64 + (actionTimer - 260) * 2;
g2.rotate(Math.toRadians((detachTimer-260)/3), rocketBottomX + 147 / 2, rocketBottomY + 171 / 2); g2.rotate(Math.toRadians((actionTimer -260)/3), rocketBottomX + 147 / 2, rocketBottomY + 171 / 2);
g2.drawImage(rocketBottom, rocketBottomX, rocketBottomY, 147, 171, this); g2.drawImage(rocketBottom, rocketBottomX, rocketBottomY, 147, 171, this);
} }
if (levelProgress) { if (levelProgress) {
g.setColor(Color.BLACK); g.setColor(Color.BLACK);
g.fillRect(windowWidth-fadeAnimation, 0, windowWidth, windowHeight); g.fillRect(windowWidth-fadeAnimation, 0, windowWidth, windowHeight);
fadeAnimation += 20;
} }
} }
else if (level == 3) { else if (level == 3) {
@ -339,70 +277,24 @@ public class Game extends JPanel implements ActionListener, KeyListener {
Toolkit.getDefaultToolkit().sync(); Toolkit.getDefaultToolkit().sync();
} }
@Override public Game() {
public void keyPressed(KeyEvent e) { // input // sets the window size
switch (e.getKeyCode()) { setPreferredSize(new Dimension(windowWidth,windowHeight));
case KeyEvent.VK_ESCAPE -> System.exit(0); // sets the star count for the Game menu
Random rand = new Random();
for (int i = 0; i < MENU_STAR_COUNT; i++) {
starX[i] = rand.nextInt(windowWidth);
starY[i] = rand.nextInt(windowHeight);
} }
input in = new input(this);
in.initMouse();
addKeyListener(in);
loadAssets.load(this);
setBackground(Color.BLACK);
setFocusable(true);
timer.start();
} }
private void initMouse() {
addMouseMotionListener(new MouseAdapter() {
@Override
public void mouseMoved(MouseEvent e) {
mouseX = e.getX();
mouseY = e.getY();
}
});
addMouseListener(new MouseAdapter() {
@Override
public void mousePressed(MouseEvent e) {
if (level == 1) {
if (e.getButton() == MouseEvent.BUTTON1 && hoveringOverQuitButton) {
quitButtonX = quitButtonX - 5;
quitButtonY = quitButtonY + 5;
}
if (e.getButton() == MouseEvent.BUTTON1 && hoveringOverPlayButton) {
playButtonX = playButtonX - 5;
playButtonY = playButtonY + 5;
}
if (e.getButton() == MouseEvent.BUTTON1 && hoveringOverPlanet) {
planetX = planetX - 2;
planetYPre = planetYPre + 2;
}
}
}
});
addMouseListener(new MouseAdapter() {
@Override
public void mouseReleased(MouseEvent e) {
if (level == 1) {
if (e.getButton() == MouseEvent.BUTTON1 && hoveringOverQuitButton) {
quitButtonX = quitButtonX + 5;
quitButtonY = quitButtonY - 5;
System.exit(0);
}
if (e.getButton() == MouseEvent.BUTTON1 && hoveringOverPlayButton) {
playButtonX = playButtonX + 5;
playButtonY = playButtonY - 5;
levelProgress = true;
}
if (e.getButton() == MouseEvent.BUTTON1 && hoveringOverPlanet) {
planetX = planetX + 2;
planetYPre = planetYPre - 2;
}
}
}
});
}
@Override
public void keyReleased(KeyEvent e) { // what happens when you let go of a key
}
@Override public void keyTyped(KeyEvent e) {}
public static void main(String[] args) { public static void main(String[] args) {
JFrame frame = new JFrame("My cool space sim"); JFrame frame = new JFrame("My cool space sim");
frame.setResizable(false); // makes it so gamers cant just resize the window and leave black parts of the window frame.setResizable(false); // makes it so gamers cant just resize the window and leave black parts of the window

View file

@ -0,0 +1,76 @@
package dev.dvorakmortonxd;
import java.awt.event.*;
public class input implements KeyListener {
private final Game m;
public input(Game m) {
this.m = m;
}
@Override
public void keyPressed(KeyEvent e) { // input
switch (e.getKeyCode()) {
case KeyEvent.VK_ESCAPE -> System.exit(0);
}
}
@Override public void keyTyped(KeyEvent e) {
}
@Override
public void keyReleased(KeyEvent e) { // what happens when you let go of a key
}
public void initMouse() {
m.addMouseMotionListener(new MouseAdapter() {
@Override
public void mouseMoved(MouseEvent e) {
m.mouseX = e.getX();
m.mouseY = e.getY();
}
});
m.addMouseListener(new MouseAdapter() {
@Override
public void mousePressed(MouseEvent e) {
if (m.level == 1) {
if (e.getButton() == MouseEvent.BUTTON1 && m.hoveringOverQuitButton) {
m.quitButtonX = m.quitButtonX - 5;
m.quitButtonY = m.quitButtonY + 5;
}
if (e.getButton() == MouseEvent.BUTTON1 && m.hoveringOverPlayButton) {
m.playButtonX = m.playButtonX - 5;
m.playButtonY = m.playButtonY + 5;
}
if (e.getButton() == MouseEvent.BUTTON1 && m.hoveringOverPlanet) {
m.planetX = m.planetX - 2;
m.planetYPre = m.planetYPre + 2;
}
}
}
});
m.addMouseListener(new MouseAdapter() {
@Override
public void mouseReleased(MouseEvent e) {
if (m.level == 1) {
if (e.getButton() == MouseEvent.BUTTON1 && m.hoveringOverQuitButton) {
m.quitButtonX = m.quitButtonX + 5;
m.quitButtonY = m.quitButtonY - 5;
System.exit(0);
}
if (e.getButton() == MouseEvent.BUTTON1 && m.hoveringOverPlayButton) {
m.playButtonX = m.playButtonX + 5;
m.playButtonY = m.playButtonY - 5;
m.levelProgress = true;
}
if (e.getButton() == MouseEvent.BUTTON1 && m.hoveringOverPlanet) {
m.planetX = m.planetX + 2;
m.planetYPre = m.planetYPre - 2;
}
}
}
});
}
}

View file

@ -0,0 +1,49 @@
package dev.dvorakmortonxd;
import javax.imageio.ImageIO;
import java.awt.*;
import java.io.File;
import java.io.IOException;
public class loadAssets {
public static void load(Game m) {
// loads up the fonts
try {
m.caveat = Font.createFont(Font.TRUETYPE_FONT, new File("assets/CaveatBrush-Regular.ttf"));
m.titleCaveat = m.caveat.deriveFont(Font.BOLD, 100f);
} catch (FontFormatException | IOException e) {
e.printStackTrace();
m.caveat = new Font("Arial", Font.PLAIN, 12);
}
// loads up the image assets
try {
m.planetZX311 = ImageIO.read(new File("assets/planetZX311.png"));
m.planetZX311H = ImageIO.read(new File("assets/planetZX311Highlighted.png"));
m.button = ImageIO.read(new File("assets/button.png"));
m.buttonH = ImageIO.read(new File("assets/buttonHighlighted.png"));
m.rocket = ImageIO.read(new File("assets/rocket.png"));
m.rocketExhaust = ImageIO.read(new File("assets/rocketExhaust.png"));
m.rocketTop = ImageIO.read(new File("assets/rocketTop.png"));
m.rocketBottom = ImageIO.read(new File("assets/rocketBottom.png"));
m.parachute = ImageIO.read(new File("assets/parachute.png"));
m.landingPlatform = ImageIO.read(new File("assets/landingPlatform.png"));
m.rocketLanding0 = ImageIO.read(new File("assets/rocketLanding0.png"));
m.rocketLanding1 = ImageIO.read(new File("assets/rocketLanding1.png"));
m.sun = ImageIO.read(new File("assets/sun.png"));
m.playerForward0 = ImageIO.read(new File("assets/player/playerSpriteForward.png"));
m.playerForward1 = ImageIO.read(new File("assets/player/playerSpriteForwardWalk0.png"));
m.playerForward2 = ImageIO.read(new File("assets/player/playerSpriteForwardWalk1.png"));
m.playerBackward0 = ImageIO.read(new File("assets/player/playerSpriteBackward.png"));
m.playerBackward1 = ImageIO.read(new File("assets/player/playerSpriteBackwardWalk0.png"));
m.playerBackward2 = ImageIO.read(new File("assets/player/playerSpriteBackwardWalk1.png"));
m.playerLeft0 = ImageIO.read(new File("assets/player/playerSpriteLeft.png"));
m.playerLeft1 = ImageIO.read(new File("assets/player/playerSpriteLeftWalk0.png"));
m.playerLeft2 = ImageIO.read(new File("assets/player/playerSpriteLeftWalk1.png"));
m.playerRight0 = ImageIO.read(new File("assets/player/playerSpriteRight.png"));
m.playerRight1 = ImageIO.read(new File("assets/player/playerSpriteRightWalk0.png"));
m.playerRight2 = ImageIO.read(new File("assets/player/playerSpriteRightWalk1.png"));
} catch (IOException e) {
e.printStackTrace();
}
}
}

View file

@ -0,0 +1,4 @@
package dev.dvorakmortonxd;
public class update {
}