Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- while (tiley <= 14) {
- tilex++;
- if (tilex >= 15) {
- tilex = 0;
- tiley++;
- }
- if (tiley >= 15) {
- break;
- }
- if (first == true) {
- tilex = 0;
- tiley = 0;
- first = false;
- }
- if (tilex != px || tiley != py) {
- canvas[tilex][tiley][frame] = new JPanel() {
- @Override
- public void paint(Graphics g) {
- super.paint(g);
- Graphics g2d = (Graphics2D) g;
- if (background == "grass") {
- g2d.drawImage(grass, 0, 0, null);
- }
- if (background == "mount") {
- g2d.drawImage(mounts, 0, 0, null);
- }
- if (background == "stone") {
- g2d.drawImage(stone, 0, 0, null);
- }
- }
- };
- canvas[tilex][tiley][frame].setBounds(tilex * 32, tiley * 32,
- 32, 32);
- canvas[tilex][tiley][frame].setOpaque(true);
- canvas[tilex][tiley][frame].setBackground(Color.WHITE);
- window.add(canvas[tilex][tiley][frame]);
- System.out.println("Loaded" + Integer.toString(tilex)
- + Integer.toString(tiley));
- }
- if (tilex == px && tiley == py) {
- canvas[tilex][tiley][frame] = new JPanel() {
- @Override
- public void paint(Graphics g) {
- super.paint(g);
- Graphics g2d = (Graphics2D) g;
- if (background == "grass") {
- g2d.drawImage(grass, 0, 0, null);
- }
- if (background == "mount") {
- g2d.drawImage(mounts, 0, 0, null);
- }
- if (background == "stone") {
- g2d.drawImage(stone, 0, 0, null);
- }
- if (direct == "back") {
- g2d.drawImage(overlayback, 12, 0, null);
- }
- if (direct == "face") {
- g2d.drawImage(overlayface, 12, 0, null);
- }
- if (direct == "left") {
- g2d.drawImage(overlayleft, 12, 0, null);
- }
- if (direct == "right") {
- g2d.drawImage(overlayright, 12, 0, null);
- }
- }
- };
- canvas[tilex][tiley][frame].setBounds(px * 32, py * 32,
- 32, 32);
- canvas[tilex][tiley][frame].setOpaque(true);
- canvas[tilex][tiley][frame].setBackground(Color.WHITE);
- window.add(canvas[tilex][tiley][frame]);
- }
- }
- }
- //Even with px set to 10, and py set to 3, the player never moves from the center init position, but he does change
- //between the different types (front, back. left, right)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement