Merge remote-tracking branch 'origin/master'

# Conflicts:
#	out/production/final/GamePanel.class
#	out/production/final/GenericSprite.class
master
John 2022-06-01 14:53:24 -04:00
commit 7914a78522
3 changed files with 8 additions and 8 deletions

View File

@ -48,9 +48,7 @@ public class GamePanel extends JPanel implements Runnable, KeyListener{
e.printStackTrace(); e.printStackTrace();
} }
} }
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 screenk
map.add(new Tile(1000, 700));
map.add(new Tile(700, 600));
map.add(new Tile(1000, 500)); map.add(new Tile(1000, 500));
map.add(new Tile(700, 400)); map.add(new Tile(700, 400));
map.add(new Tile(1000, 300)); map.add(new Tile(1000, 300));

View File

@ -31,20 +31,21 @@ public class GenericSprite extends Rectangle{
public void keyPressed(KeyEvent e){ public void keyPressed(KeyEvent e){
if(e.getKeyChar() == 'd'){ if(e.getKeyChar() == 'd'){
rightPressed = true; rightPressed = true;
move();
} }
if(e.getKeyChar() == 'a'){ if(e.getKeyChar() == 'a'){
leftPressed = true; leftPressed = true;
move();
} }
if(e.getKeyChar() == 'w'){ if(e.getKeyChar() == 'w'){
upPressed = true; upPressed = true;
move();
} }
if(e.getKeyChar() == 's'){ if(e.getKeyChar() == 's'){
downPressed = true; downPressed = true;
move();
} }
move();
} }
//called from GamePanel when any key is released (no longer being pressed down) //called from GamePanel when any key is released (no longer being pressed down)

View File

@ -14,7 +14,7 @@ public class MenuPanel extends JFrame implements ActionListener {
this.setTitle("First"); this.setTitle("First");
this.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); this.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
this.setSize(280, 200); this.setSize(280, 200);
this.setVisible(true);
launchGame = new JButton("Click"); launchGame = new JButton("Click");
launchGame.addActionListener(this); launchGame.addActionListener(this);
@ -22,6 +22,7 @@ public class MenuPanel extends JFrame implements ActionListener {
menuContainer = getContentPane(); menuContainer = getContentPane();
menuContainer.setLayout(new FlowLayout()); menuContainer.setLayout(new FlowLayout());
menuContainer.add(launchGame); menuContainer.add(launchGame);
this.setVisible(true);
} }
public void paint(Graphics g) { public void paint(Graphics g) {