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
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.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
public void draw(Graphics g, int frame){
frameCounter += player.draw(g, frame);
public void draw(Graphics g){
ball.draw(g);
for(Tile i: map){
i.draw(g);
}
}
//call the move methods in other classes to update positions
@ -94,31 +92,33 @@ public class GamePanel extends JPanel implements Runnable, KeyListener{
}
//handles all collision detection and responds accordingly
public void checkCollision(){
public void checkCollision() {
player.isGrounded = false;
for(Tile i: map){
for (Tile i : map) {
}
//force player to remain on screen
if(player.y<= 0){
if (player.y <= 0) {
player.y = 0;
}
if(player.y >= GAME_HEIGHT - Player.PLAYER_HEIGHT){
player.y = GAME_HEIGHT- Player.PLAYER_HEIGHT;
if(ball.y >= GAME_HEIGHT - PlayerBall.BALL_DIAMETER){
ball.y = GAME_HEIGHT-PlayerBall.BALL_DIAMETER;
ball.yVelocity = 0;
ball.isGrounded = true;
}
if(player.x <= 0){
player.x = 0;
if (player.y >= GAME_HEIGHT - Player.PLAYER_HEIGHT) {
player.y = GAME_HEIGHT - Player.PLAYER_HEIGHT;
if (player.y >= GAME_HEIGHT - Player.BALL_DIAMETER) {
player.y = GAME_HEIGHT - Player.BALL_DIAMETER;
player.yVelocity = 0;
player.isGrounded = true;
}
if (player.x <= 0) {
player.x = 0;
if(ball.x <= 0){
ball.x = 0;
}
if(player.x + Player.PLAYER_WIDTH >= GAME_WIDTH){
player.x = GAME_WIDTH- Player.PLAYER_WIDTH;
if (player.x <= 0) {
player.x = 0;
}
if (player.x + Player.PLAYER_WIDTH >= GAME_WIDTH) {
player.x = GAME_WIDTH - Player.PLAYER_WIDTH;
}
}
}
}