Advertisement
Guest User

Untitled

a guest
Nov 22nd, 2014
169
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.25 KB | None | 0 0
  1. while (tiley <= 14) {
  2. tilex++;
  3. if (tilex >= 15) {
  4. tilex = 0;
  5. tiley++;
  6. }
  7. if (tiley >= 15) {
  8. break;
  9. }
  10. if (first == true) {
  11. tilex = 0;
  12. tiley = 0;
  13. first = false;
  14. }
  15. if (tilex != px || tiley != py) {
  16. canvas[tilex][tiley][frame] = new JPanel() {
  17. @Override
  18. public void paint(Graphics g) {
  19. super.paint(g);
  20. Graphics g2d = (Graphics2D) g;
  21. if (background == "grass") {
  22. g2d.drawImage(grass, 0, 0, null);
  23. }
  24. if (background == "mount") {
  25. g2d.drawImage(mounts, 0, 0, null);
  26. }
  27. if (background == "stone") {
  28. g2d.drawImage(stone, 0, 0, null);
  29. }
  30. }
  31. };
  32. canvas[tilex][tiley][frame].setBounds(tilex * 32, tiley * 32,
  33. 32, 32);
  34. canvas[tilex][tiley][frame].setOpaque(true);
  35. canvas[tilex][tiley][frame].setBackground(Color.WHITE);
  36. window.add(canvas[tilex][tiley][frame]);
  37. System.out.println("Loaded" + Integer.toString(tilex)
  38. + Integer.toString(tiley));
  39. }
  40. if (tilex == px && tiley == py) {
  41. canvas[tilex][tiley][frame] = new JPanel() {
  42. @Override
  43. public void paint(Graphics g) {
  44. super.paint(g);
  45. Graphics g2d = (Graphics2D) g;
  46. if (background == "grass") {
  47. g2d.drawImage(grass, 0, 0, null);
  48. }
  49. if (background == "mount") {
  50. g2d.drawImage(mounts, 0, 0, null);
  51. }
  52. if (background == "stone") {
  53. g2d.drawImage(stone, 0, 0, null);
  54. }
  55. if (direct == "back") {
  56. g2d.drawImage(overlayback, 12, 0, null);
  57. }
  58. if (direct == "face") {
  59. g2d.drawImage(overlayface, 12, 0, null);
  60. }
  61. if (direct == "left") {
  62. g2d.drawImage(overlayleft, 12, 0, null);
  63. }
  64. if (direct == "right") {
  65. g2d.drawImage(overlayright, 12, 0, null);
  66. }
  67. }
  68. };
  69. canvas[tilex][tiley][frame].setBounds(px * 32, py * 32,
  70. 32, 32);
  71. canvas[tilex][tiley][frame].setOpaque(true);
  72. canvas[tilex][tiley][frame].setBackground(Color.WHITE);
  73. window.add(canvas[tilex][tiley][frame]);
  74. }
  75. }
  76. }
  77.  
  78. //Even with px set to 10, and py set to 3, the player never moves from the center init position, but he does change
  79. //between the different types (front, back. left, right)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement