Advertisement
Guest User

asdfe

a guest
Jul 30th, 2015
263
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.44 KB | None | 0 0
  1. package mario;
  2.  
  3. import java.awt.Image;
  4.  
  5. import processing.core.PApplet;
  6. import processing.core.PImage;
  7.  
  8.  
  9.  
  10. public class Mario extends PApplet {
  11. PImage background;
  12.  
  13. public boolean moveCircle = false;
  14. public boolean moveCircleRight= false;
  15. public boolean moveCircleLeft = false;
  16. public boolean moveCircleDown = false;
  17.  
  18. public int startX = 0+25;
  19. public int startY = 1000-173;
  20. public int Xblock = 580;
  21. public int Yblock = 800;
  22.  
  23. public int jump;
  24.  
  25. public void setup() {
  26. size(2000,1000);
  27. background = loadImage("background.jpg");
  28. }
  29.  
  30. public void draw() {
  31. image(background, 0, 0);
  32. clouds();
  33. move();
  34. ground();
  35. circle();
  36. System.out.println("mouse X" + mouseX + "mouse Y" + mouseY);
  37.  
  38. }
  39.  
  40. public void clouds(){
  41. stroke(255,255,255);
  42. fill(255,255,255);
  43. ellipse(50,80,75,50);
  44. ellipse(100,60,75,50);
  45. ellipse(115,90,75,50);
  46. ellipse(150,83,75,50);
  47. }
  48.  
  49. public void ground(){
  50. stroke(0,225,0);
  51. fill(0,225,0);
  52. rect(0,570,800,30);
  53.  
  54. rect(100,450,150,30);
  55. rect(275,380,75,30);
  56.  
  57. }
  58.  
  59.  
  60. public void circle(){
  61. stroke(255,0,0);
  62. fill(255,0,0);
  63. ellipse(startX, startY, 50,50);
  64. }
  65.  
  66.  
  67. public void keyPressed(){
  68. if(key == 'w'){ //&& jump == 1){
  69. moveCircle = true;
  70. }
  71. if(key == 'd'){
  72. moveCircleRight = true;
  73. }
  74. if(key == 'a'){
  75. moveCircleLeft = true;
  76. }
  77. if(key == 's'){
  78. moveCircleDown = true;
  79. }
  80. }
  81.  
  82. public void keyReleased(){
  83. if(key == 'w'){
  84. moveCircle=false;
  85. //jump++;
  86. //System.out.println(jump);
  87. }
  88. if(key == 'd'){
  89. moveCircleRight = false;
  90. }
  91. if(key == 'a'){
  92. moveCircleLeft = false;
  93. }
  94. if(key == 's'){
  95. moveCircleDown = false;
  96. }
  97. }
  98.  
  99. public void move(){
  100. if(moveCircle){
  101. if(startY >0 +25){
  102. startY -= 25 ;
  103. }
  104. else{
  105. startY -= 0;
  106. }
  107. }
  108. if(moveCircleRight){
  109. if(startX <2000-118 && (startX < 560)){
  110. startX += 25;
  111. }
  112.  
  113. }
  114. else{
  115. startX += 0;
  116. }
  117.  
  118. if(moveCircleLeft){
  119. if(startX>0+25){
  120. startX -=25;
  121. }
  122. else{
  123. startX -=0;
  124. }
  125. }
  126. if(moveCircleDown){
  127. if(startY<1000-173){
  128. startY +=25;
  129. }
  130. else{
  131. startY-=0;
  132. }
  133. }
  134. }
  135.  
  136.  
  137.  
  138. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement