Advertisement
Guest User

Untitled

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