Fixing merge conflicts

master
bob 2022-05-31 13:31:58 -04:00
parent dee2e612d3
commit 2d24fe98fa
1 changed files with 20 additions and 20 deletions

View File

@ -50,7 +50,6 @@ public class GamePanel extends JPanel implements Runnable, KeyListener{
} }
player = new Player(GAME_WIDTH/2, GAME_HEIGHT/2, 'W', 'A', 'S', 'D', spriteArray); //create a player controlled player, set start location to middle of screen player = new Player(GAME_WIDTH/2, GAME_HEIGHT/2, 'W', 'A', 'S', 'D', spriteArray); //create a player controlled player, set start location to middle of screen
map.add(new Tile(1000, 700)); map.add(new Tile(1000, 700));
ball = new PlayerBall(GAME_WIDTH/2, GAME_HEIGHT/2); //create a player controlled ball, set start location to middle of screen
this.setFocusable(true); //make everything in this class appear on the screen this.setFocusable(true); //make everything in this class appear on the screen
this.addKeyListener(this); //start listening for keyboard input this.addKeyListener(this); //start listening for keyboard input
@ -80,11 +79,10 @@ public class GamePanel extends JPanel implements Runnable, KeyListener{
//call the draw methods in each class to update positions as things move //call the draw methods in each class to update positions as things move
public void draw(Graphics g, int frame){ public void draw(Graphics g, int frame){
frameCounter += player.draw(g, frame); frameCounter += player.draw(g, frame);
public void draw(Graphics g){
ball.draw(g);
for(Tile i: map){ for(Tile i: map){
i.draw(g); i.draw(g);
} }
} }
//call the move methods in other classes to update positions //call the move methods in other classes to update positions
@ -106,21 +104,23 @@ public class GamePanel extends JPanel implements Runnable, KeyListener{
} }
if (player.y >= GAME_HEIGHT - Player.PLAYER_HEIGHT) { if (player.y >= GAME_HEIGHT - Player.PLAYER_HEIGHT) {
player.y = GAME_HEIGHT - Player.PLAYER_HEIGHT; player.y = GAME_HEIGHT - Player.PLAYER_HEIGHT;
if(ball.y >= GAME_HEIGHT - PlayerBall.BALL_DIAMETER){ if (player.y >= GAME_HEIGHT - Player.BALL_DIAMETER) {
ball.y = GAME_HEIGHT-PlayerBall.BALL_DIAMETER; player.y = GAME_HEIGHT - Player.BALL_DIAMETER;
ball.yVelocity = 0; player.yVelocity = 0;
ball.isGrounded = true; player.isGrounded = true;
} }
if (player.x <= 0) { if (player.x <= 0) {
player.x = 0; player.x = 0;
if(ball.x <= 0){ if (player.x <= 0) {
ball.x = 0; player.x = 0;
} }
if (player.x + Player.PLAYER_WIDTH >= GAME_WIDTH) { if (player.x + Player.PLAYER_WIDTH >= GAME_WIDTH) {
player.x = GAME_WIDTH - Player.PLAYER_WIDTH; player.x = GAME_WIDTH - Player.PLAYER_WIDTH;
} }
} }
}
}
//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 //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(){ public void run(){