Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package Main;
- import java.awt.*;
- import java.awt.event.*;
- import javax.swing.*;
- public class GamePanel extends JPanel implements ActionListener {
- private static final long serialVersionUID = 1L;
- private static int STEP = 1;
- private Timer timer;
- private Background bg;
- private boolean win=false, isFirst=true;
- private Graphics g;
- private Player p;
- private KeyHandler keyHandler;
- public GamePanel(){
- bg=new Background();
- timer = new Timer(45,this);
- timer.start();
- p= new Player();
- }
- public void paint(Graphics g){
- super.paint(g);
- if(!win){
- for(int x=0; x<17; x++){
- for(int y=0; y<13; y++){
- if(bg.getMap(x, y).equals("0")){
- g.drawImage(bg.getPath(), (x/2)*64, (y/2)*64, null);
- }
- if(bg.getMap(x, y).equals("1")){
- g.drawImage(bg.getWall1(), (x/2)*64-5, (y/2)*64, null);
- }
- if(bg.getMap(x, y).equals("2")){
- g.drawImage(bg.getWall2(), (x/2)*64, (y/2)*64-5, null);
- }
- }
- }
- g.drawImage(p.getPlayer(),p.getTileX()*64,p.getTileY()*64,null);
- }
- }
- public void actionPerformed(ActionEvent e) {
- if(isFirst){
- g=getGraphics();
- }
- repaint();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement