fixed an issue I had with the landing platform and added a way to go between scenes on the planet
This commit is contained in:
parent
c3a2bb55c5
commit
b4851409e2
5 changed files with 63 additions and 27 deletions
|
|
@ -50,6 +50,7 @@ public class Game extends JPanel implements ActionListener {
|
|||
public static BufferedImage playerRight0;
|
||||
public static BufferedImage playerRight1;
|
||||
public static BufferedImage playerRight2;
|
||||
public static BufferedImage planetZX311Land;
|
||||
|
||||
// sets the FPS up (its 16 because 1000/60 is around 16.666 but it only accepts integers so its just rounded to 60)
|
||||
public Timer timer = new Timer(16, this); // 60 FPS (actually more so around 62.5 but thats kinda irrelevant)
|
||||
|
|
@ -112,18 +113,17 @@ public class Game extends JPanel implements ActionListener {
|
|||
public double playerXVelocity = 0;
|
||||
public double playerYVelocity = 0;
|
||||
public boolean leftHeld, rightHeld, upHeld, downHeld;
|
||||
|
||||
public static final double acceleration = 0.6;
|
||||
public final double friction = 0.6;
|
||||
public final double maxSpeed = 6.0;
|
||||
public final double gravity = 1.0;
|
||||
public final double jumpSpeed = -12.6;
|
||||
public final double maxFall = 20.0;
|
||||
|
||||
public int playerSizeX = 14*4;
|
||||
public int playerSizeY = 18*4;
|
||||
public String playerFacing = "forward";
|
||||
public BufferedImage playerCurrentSprite;
|
||||
public String currentPlayerLocation = "landingPlatformZX311";
|
||||
public boolean playerOnFeet = true;
|
||||
public boolean playerActive = false;
|
||||
public int walkTick;
|
||||
|
|
|
|||
|
|
@ -43,6 +43,7 @@ public class loadAssets {
|
|||
m.playerRight0 = ImageIO.read(Game.class.getResource("/assets/player/playerSpriteRight.png"));
|
||||
m.playerRight1 = ImageIO.read(Game.class.getResource("/assets/player/playerSpriteRightWalk0.png"));
|
||||
m.playerRight2 = ImageIO.read(Game.class.getResource("/assets/player/playerSpriteRightWalk1.png"));
|
||||
m.planetZX311Land = ImageIO.read(Game.class.getResource("/assets/planetZX311Land.png"));
|
||||
|
||||
m.playerCurrentSprite = m.playerForward0;
|
||||
} catch (IOException e) {
|
||||
|
|
|
|||
|
|
@ -15,8 +15,10 @@ public class update {
|
|||
};
|
||||
}
|
||||
public static double getGroundY(Game m) {
|
||||
if (m.level == 3) {
|
||||
if (m.playerX > 290 && m.playerX < 572) { return 338; } else { return 370; }
|
||||
if (m.currentPlayerLocation.equals("landingPlatformZX311")) {
|
||||
if (m.playerX > 290 && m.playerX < 572) { return 358; } else { return 385; }
|
||||
} else if (m.currentPlayerLocation.equals("observatoryZX311") || m.currentPlayerLocation.equals("villageEntranceZX311")) {
|
||||
return 385;
|
||||
} else {
|
||||
return m.windowHeight-m.playerSizeY;
|
||||
}
|
||||
|
|
@ -104,8 +106,32 @@ public class update {
|
|||
|
||||
// update the player sprite based on direction and if he's walking and frame
|
||||
m.playerCurrentSprite = spriteFor(m, m.playerFacing, frame);
|
||||
// first ship
|
||||
if (m.playerX < -m.playerSizeX || m.playerX > m.windowWidth) { m.level = 4; }
|
||||
// player moving between locations on planets
|
||||
if (m.currentPlayerLocation.equals("landingPlatformZX311")) {
|
||||
if (m.playerX < -m.playerSizeX) {
|
||||
m.currentPlayerLocation = "observatoryZX311";
|
||||
m.playerX = m.windowWidth - m.playerSizeX;
|
||||
} else if (m.playerX > m.windowWidth) {
|
||||
m.currentPlayerLocation = "villageEntranceZX311";
|
||||
m.playerX = m.playerSizeX;
|
||||
}
|
||||
} else if (m.currentPlayerLocation.equals("observatoryZX311")) {
|
||||
if (m.playerX < -m.playerSizeX) {
|
||||
m.currentPlayerLocation = "villageEntranceZX311";
|
||||
m.playerX = m.windowWidth - m.playerSizeX;
|
||||
} else if (m.playerX > m.windowWidth) {
|
||||
m.currentPlayerLocation = "landingPlatformZX311";
|
||||
m.playerX = m.playerSizeX;
|
||||
}
|
||||
} else if (m.currentPlayerLocation.equals("villageEntranceZX311")) {
|
||||
if (m.playerX < -m.playerSizeX) {
|
||||
m.currentPlayerLocation = "landingPlatformZX311";
|
||||
m.playerX = m.windowWidth - m.playerSizeX;
|
||||
} else if (m.playerX > m.windowWidth) {
|
||||
m.currentPlayerLocation = "observatoryZX311";
|
||||
m.playerX = m.playerSizeX;
|
||||
}
|
||||
}
|
||||
}
|
||||
// triggers render
|
||||
m.repaint();
|
||||
|
|
@ -203,7 +229,7 @@ public class update {
|
|||
g.fillOval(m.starX[i] - m.starSize, m.starY[i] - m.starSize, m.starSize, m.starSize);
|
||||
}
|
||||
}
|
||||
if ((m.rocketYPre + (m.actionTimer -321)/5) <= 300){
|
||||
if ((m.rocketYPre + (m.actionTimer -321)/5) <= 320){
|
||||
g.drawImage(m.parachute, m.windowWidth / 2 - 73, m.rocketY - m.hoverYOffset / 3 - 42 + (m.actionTimer -321)/5, 147, 90, m);
|
||||
g.drawImage(m.rocketTop, m.windowWidth / 2 - 73, m.rocketY - m.hoverYOffset / 3 + (m.actionTimer -321)/5, 147, 84, m);
|
||||
} else {
|
||||
|
|
@ -212,24 +238,23 @@ public class update {
|
|||
g2.drawImage(m.sun, 600, -80, 384, 384, m);
|
||||
g2.setComposite(AlphaComposite.SrcOver); // reset so nothing else is transparent
|
||||
if (m.actionTimer < 1200) {
|
||||
g.drawImage(m.parachute, m.windowWidth / 2 - 73, 258, 147, 90, m);
|
||||
g.drawImage(m.rocketTop, m.windowWidth / 2 - 73, 300, 147, 84, m);
|
||||
g.drawImage(m.parachute, m.windowWidth / 2 - 73, 278, 147, 90, m);
|
||||
g.drawImage(m.rocketTop, m.windowWidth / 2 - 73, 320, 147, 84, m);
|
||||
} else if (1400 > m.actionTimer && m.actionTimer >= 1200) {
|
||||
g.drawImage(m.parachute, m.windowWidth / 2 - 73, 258, 147, 90, m);
|
||||
g.drawImage(m.rocketLanding0, m.windowWidth / 2 - 73, 300, 147, 111, m);
|
||||
g.drawImage(m.parachute, m.windowWidth / 2 - 73, 278, 147, 90, m);
|
||||
g.drawImage(m.rocketLanding0, m.windowWidth / 2 - 73, 320, 147, 111, m);
|
||||
} else if (1400 <= m.actionTimer && m.actionTimer < 1550) {;
|
||||
g.drawImage(m.parachute, m.windowWidth / 2 - 73, 258, 147, 90, m);
|
||||
g.drawImage(m.rocketLanding1, m.windowWidth / 2 - 73, 300, 147, 111, m);
|
||||
g.drawImage(m.parachute, m.windowWidth / 2 - 73, 278, 147, 90, m);
|
||||
g.drawImage(m.rocketLanding1, m.windowWidth / 2 - 73, 320, 147, 111, m);
|
||||
} else {
|
||||
g.drawImage(m.parachute, m.windowWidth / 2 - 73, 258+(m.actionTimer -1550)*3/2, 147, 90, m); // parachute is falling!
|
||||
g.drawImage(m.rocketLanding1, m.windowWidth / 2 - 73, 300, 147, 111, m);
|
||||
g.drawImage(m.parachute, m.windowWidth / 2 - 73, 278+(m.actionTimer -1550)*3/2, 147, 90, m); // parachute is falling!
|
||||
g.drawImage(m.rocketLanding1, m.windowWidth / 2 - 73, 320, 147, 111, m);
|
||||
}
|
||||
|
||||
// (windowHeight-210) is the desired height
|
||||
if ((1100-(m.actionTimer / 2 )) >= 340) {
|
||||
g.drawImage(m.landingPlatform, 0, 1100-(m.actionTimer /2), m.windowWidth, m.windowWidth/128*30, m);
|
||||
if ((1100-(m.actionTimer / 2 )) >= 370) {
|
||||
g.drawImage(m.landingPlatform, 0, 1100-(m.actionTimer /2), m.windowWidth, m.windowWidth/256*60, m);
|
||||
} else {
|
||||
g.drawImage(m.landingPlatform, 0, 340, m.windowWidth, m.windowWidth/128*30, m);
|
||||
g.drawImage(m.landingPlatform, 0, 370, m.windowWidth, m.windowWidth/256*60, m);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -254,14 +279,24 @@ public class update {
|
|||
}
|
||||
}
|
||||
else if (m.level == 3) {
|
||||
g.setColor(new Color(127, 127,255));
|
||||
g.fillRect(0,0,m.windowWidth,m.windowHeight);
|
||||
if (m.currentPlayerLocation.equals("landingPlatformZX311")) {
|
||||
g.setColor(new Color(127, 127, 255));
|
||||
g.fillRect(0, 0, m.windowWidth, m.windowHeight);
|
||||
Graphics2D g2 = (Graphics2D) g;
|
||||
g2.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, m.opacityAnimation));
|
||||
g2.drawImage(m.sun, 600, -80, 384, 384, m);
|
||||
g2.setComposite(AlphaComposite.SrcOver); // reset so nothing else is transparent
|
||||
g.drawImage(m.landingPlatform, 0, 340, m.windowWidth, m.windowWidth/128*30, m);
|
||||
g.drawImage(m.rocketLanding1, m.windowWidth / 2 - 73, 300, 147, 111, m);
|
||||
g.drawImage(m.landingPlatform, 0, 370, m.windowWidth, m.windowWidth / 256 * 60, m);
|
||||
g.drawImage(m.rocketLanding1, m.windowWidth / 2 - 73, 320, 147, 111, m);
|
||||
} else if (m.currentPlayerLocation.equals("observatoryZX311")) {
|
||||
g.setColor(new Color(127, 127, 255));
|
||||
g.fillRect(0, 0, m.windowWidth, m.windowHeight);
|
||||
g.drawImage(m.planetZX311Land, 0, 457, m.windowWidth, m.windowWidth/256*31, m);
|
||||
} else if (m.currentPlayerLocation.equals("villageEntranceZX311")) {
|
||||
g.setColor(new Color(127, 127, 255));
|
||||
g.fillRect(0, 0, m.windowWidth, m.windowHeight);
|
||||
g.drawImage(m.planetZX311Land, 0, 457, m.windowWidth, m.windowWidth/256*31, m);
|
||||
}
|
||||
}
|
||||
else {
|
||||
g.setColor(Color.BLACK);
|
||||
|
|
|
|||
Binary file not shown.
BIN
src/main/resources/assets/planetZX311Land.png
Normal file
BIN
src/main/resources/assets/planetZX311Land.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.2 KiB |
Loading…
Add table
Add a link
Reference in a new issue