Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package mygame;
- import java.awt.Graphics;
- import java.awt.Graphics2D;
- import java.awt.Image;
- import javax.swing.ImageIcon;
- import javax.swing.JPanel;
- import GameState.MenuState;
- // moteur Graphique et physique
- @SuppressWarnings("serial")
- public class Scene extends JPanel {
- public MenuPause menu;
- private ImageIcon icoFond;
- private Image imgFond1;
- private ImageIcon icoPlayer;
- private Image imgPlayer;
- private ImageIcon icoPorte;
- private Image imgPorte;
- private int xFond1;
- private int dx;
- private int pause;
- private int xPos;
- //CONSTRUCTEUR
- public Scene(){
- super();
- this.xFond1 = 50;
- this.pause = 0;
- this.dx = 0;
- this.xPos = -1 ;
- icoFond = new ImageIcon(getClass().getResource("/Images/FondEcranFinal1.jpg"));
- this.imgFond1 = this.icoFond.getImage();
- icoPlayer = new ImageIcon(getClass().getResource("/Images/PlayerStandDroitFinal.png"));
- this.imgPlayer = this.icoPlayer.getImage();
- icoPorte = new ImageIcon(getClass().getResource("/Images/Porte.png"));
- this.imgPorte = this.icoPorte.getImage();
- this.setFocusable(true);
- this.requestFocusInWindow();
- this.addKeyListener(new InputGame());
- Thread ChronoEcran = new Thread(new Chrono());
- ChronoEcran.start();
- }
- //GETTERS
- public int getDx() {return dx;}
- public int getxPos() {return xPos;}
- //SETTERS
- public void setDx(int dx) {this.dx = dx;}
- public void setxPos(int xPos) {this.xPos = xPos;}
- public void setxFond1(int xFond1) {this.xFond1 = xFond1;}
- //METHODS
- public void deplacementFond(){
- if(this.xPos >=0 ){
- this.xPos = this.xPos +this.dx;
- this.xFond1 = this.xFond1 - this.dx;;
- }
- if(this.xFond1 == -1485){this.xFond1 = 1485;}
- else if (this.xFond1 == 1485){this.xFond1 = -1485;}
- }
- public void paintComponent(Graphics g){
- super.paintComponent(g);
- Graphics g2 =(Graphics2D)g;
- this.deplacementFond();
- g2.drawImage(this.imgFond1, this.xFond1, 0, null);
- g2.drawImage(imgPlayer,300, 485, null);
- g2.drawImage(imgPorte,600 - this.xPos, 298, null);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement