Advertisement
Guest User

Untitled

a guest
Jul 30th, 2015
220
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.56 KB | None | 0 0
  1.  
  2. package mario;
  3.  
  4. import processing.core.PApplet;
  5. import processing.core.PImage;
  6.  
  7. public class Mario extends PApplet {
  8.  
  9. public boolean moveCircle = false;
  10. public boolean moveCircleRight= false;
  11. public boolean moveCircleLeft = false;
  12.  
  13. public void setup() {
  14. size(800,600);
  15.  
  16. }
  17.  
  18. public void draw(){
  19. background(0, 0, 255);
  20. clouds();
  21. move();
  22. ground();
  23. circle();
  24. }
  25.  
  26. public void clouds(){
  27. stroke(255,255,255);
  28. fill(255,255,255);
  29. ellipse(50,80,75,50);
  30. ellipse(100,60,75,50);
  31. ellipse(115,90,75,50);
  32. ellipse(150,83,75,50);
  33. }
  34.  
  35. public void ground(){
  36. stroke(0,225,0);
  37. fill(0,225,0);
  38. rect(0,570,800,30);
  39.  
  40. rect(100,450,150,30);
  41. rect(275,380,75,30);
  42.  
  43. }
  44.  
  45. public int startX = 25;
  46. public int startY = 570-25;
  47.  
  48. public void circle(){
  49. stroke(255,0,0);
  50. fill(255,0,0);
  51. ellipse(startX, startY, 50,50);
  52. }
  53.  
  54.  
  55. public void keyPressed(){
  56. if(key == 'w'){
  57. moveCircle = true;
  58. }
  59. if(key == 'd'){
  60. moveCircleRight = true;
  61. }
  62. if(key == 'a'){
  63. moveCircleLeft = true;
  64. }
  65. }
  66.  
  67. public void keyReleased(){
  68. if(key == 'w'){
  69. moveCircle=false;
  70. }
  71. if(key == 'd'){
  72. moveCircleRight = false;
  73. }
  74. if(key == 'a'){
  75. moveCircleLeft = false;
  76. }
  77. }
  78.  
  79. public void move(){
  80. if(moveCircle){
  81. startY -= 25 ;
  82. }
  83. if(moveCircleRight){
  84. startX += 25;
  85. }
  86. if(moveCircleLeft){
  87. startX -=25;
  88. }
  89. }
  90.  
  91. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement