Advertisement
Guest User

Untitled

a guest
Jun 23rd, 2017
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.70 KB | None | 0 0
  1. float Stage;
  2. PVector Position;
  3. int X;
  4. //PFont font;
  5. void setup(){
  6. size(900,800);
  7. Position = new PVector (10,height/2);
  8. Stage = 0;
  9. rectMode(CENTER);
  10. X = round(random(0,day()));
  11. //font = createFont("BAUHS93", 32);
  12. }
  13.  
  14. void draw(){
  15. if(Stage == 0){
  16. background(0,0,255);
  17. }
  18. if(Stage == 1){
  19. background(0,255,0);
  20. fill(0);
  21. rect(width/2,height/2,50,300);
  22. }
  23. if(Stage == 2){
  24. background(255,0,0);
  25. fill(10,200,10);
  26. noStroke();
  27. rect(600,height/2,100,100);
  28. }
  29. fill(255);
  30. ellipse(Position.x,Position.y,20,20);
  31. if(keyPressed){
  32. if (key == CODED) {
  33. if (keyCode == RIGHT) {
  34. Position.x+=10;
  35. }
  36. if (keyCode == LEFT) {
  37. Position.x-=10;
  38. }
  39. if (keyCode == UP) {
  40. Position.y-=10;
  41. }
  42. if (keyCode == DOWN) {
  43. Position.y+=10;
  44. }
  45. }
  46. }
  47. if (Position.x>=width && !(Stage == 2)){
  48. Position.x = 1;
  49. Stage += 1;
  50. }
  51. if (Position.x<=0 && !(Stage == 0)){
  52. Position.x = width-1;
  53. Stage -= 1;
  54. }
  55. if (Position.y <=0){
  56. Position.y = 0;
  57. }
  58. if (Position.y >=height){
  59. Position.y = height;
  60. }
  61. if (Stage == 0 && Position.x <= 0){
  62. Position.x = 0;
  63. }
  64. if (Stage == 2 && Position.x >= width){
  65. Position.x = width;
  66. }
  67. if (Stage == 1 && Position.x >= ((width/2)-25) && Position.x <= ((width/2)+25) && Position.y <= ((height/2)+150) && Position.y >= ((height/2)-150)){
  68. Position.x = ((width/2)-25);
  69. }
  70. if (Stage == 2 && Position.y >= ((height/2)-50) && Position.y <= ((height/2)+50) && Position.x <= 650 && Position.x >= 550){
  71. //textFont(font,32);
  72. text("You Win!", width/2, 300);
  73. text("Score:", width/2, 340);
  74. text(X,(width/2)+40,340);
  75. }
  76. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement