Fix bugs
parent
02ef7f3292
commit
7b7821faed
|
@ -30,6 +30,7 @@ public class GamePanel extends JPanel implements Runnable, KeyListener, Serializ
|
|||
public transient Thread gameThread;
|
||||
public transient Image image;
|
||||
public transient Graphics graphics;
|
||||
public transient boolean isNewStart = false;
|
||||
public Player player;
|
||||
public BackgroundImage background, cloudOneBackground, cloudTwoBackground, cloudThreeBackground;
|
||||
public int playerFrame, enemyFrame;
|
||||
|
@ -113,6 +114,7 @@ public class GamePanel extends JPanel implements Runnable, KeyListener, Serializ
|
|||
// the height of 35 is set because it is half of the original tile height (i.e., 70px)
|
||||
addUserInterface();
|
||||
this.setPreferredSize(new Dimension(GAME_WIDTH, GAME_HEIGHT));
|
||||
isNewStart = true;
|
||||
}
|
||||
|
||||
public void addUserInterface() {
|
||||
|
@ -316,8 +318,10 @@ public class GamePanel extends JPanel implements Runnable, KeyListener, Serializ
|
|||
|
||||
//run() method is what makes the game continue running without end. It calls other methods to move objects, check for collision, and update the screen
|
||||
public void run() {
|
||||
if (isNewStart) {
|
||||
LevelManager.setLevel(1);
|
||||
isDialogue = true;
|
||||
}
|
||||
//the CPU runs our game code too quickly - we need to slow it down! The following lines of code "force" the computer to get stuck in a loop for short intervals between calling other methods to update the screen.
|
||||
long lastTime = System.nanoTime();
|
||||
double amountOfTicks = 60;
|
||||
|
|
|
@ -225,8 +225,10 @@ public class Player extends GenericSprite {
|
|||
y-=1;
|
||||
isGrounded = false;
|
||||
if(canUpdate(0,-8)) {
|
||||
if (jump != null) {
|
||||
jump.start();
|
||||
}
|
||||
}
|
||||
yVelocity = -10;
|
||||
}
|
||||
xVelocity *= 0.93;
|
||||
|
|
Loading…
Reference in New Issue