Facebook
From Walloping Pheasant, 4 Years ago, written in Plain Text.
Embed
Download Paste or View Raw
Hits: 128
  1. from processing import *
  2. import random
  3. x = [50,100,150,200,250,300,350,400,450,500,550,600,650,700]
  4. y = [0,150,200,300,350,450,500,550]
  5. player_x = 250
  6. player_y = 150
  7.  
  8. strawberry_x =(random.choice(x))
  9. strawberry_y =(random.choice(y))
  10.  
  11. width = 800
  12. height = 600
  13.  
  14.  
  15.  
  16. score = 0
  17. lives = 5
  18.  
  19. strawberry_width = 50
  20. strawberry_height = 50
  21.  
  22. player_width = 50
  23. player_height = 50
  24.        
  25. def setup():
  26.         global q
  27.        
  28.         global w
  29.         global s
  30.        
  31.     global player
  32.        
  33.         global strawberry
  34.         global strawberry_x
  35.         global strawberry_y
  36.         size(800,600)
  37.         s = loadImage("ocean.jpg")
  38.        
  39.         player = loadImage("player.png")
  40.  
  41.         strawberry = loadImage("strawberry.png")
  42.         q = loadImage("forest.jpg")
  43.        
  44.        
  45. def draw():
  46.         background(190,270,290)
  47.         global score
  48.         global strawberry_x
  49.         global strawberry_y
  50.         global s
  51.        
  52.        
  53.         image(player, player_x, player_y)
  54.         fill(0,400,0)
  55.         text("Score: {}".format(score), 10, 25)
  56.         text("Lives: {}".format(lives), 10, 45)
  57.         image(strawberry,strawberry_x,strawberry_y)
  58.        
  59.  
  60.        
  61.    
  62.         if score == 0:
  63.                 fill(300,100,150)
  64.                 rect(250,50,290,50)
  65.                 fill(0,250,300)
  66.                 textSize(20)
  67.                 text("Collect the  strawberries !",250,90)
  68.                
  69.         if score == 2:
  70.                 fill(250,150,210)
  71.                 rect(200,50,330,50)
  72.                 fill(0,250,300)
  73.                 textSize(20)
  74.                 text("Do not touch the  lines!",200,90)
  75.        
  76.         if score >= 4: 
  77.                 fill(330,400,7)
  78.                 rect(0,110,140,40)
  79.                 rect(200,110,200,40)
  80.                 rect(450,110,350,40)
  81.                
  82.                 fill(78,150,158)
  83.                 rect(0,250,300,40)
  84.                 rect(350,250,100,40)
  85.                 rect(500,250,290,40)
  86.                
  87.                 fill(300,200,250)
  88.                 rect(0,400,140,40)
  89.                 rect(200,400,200,40)
  90.                 rect(450,400,350,40)
  91.        
  92.         if lives <= 0:
  93.                 image(s,0,0)
  94.                 textSize(90)
  95.                 fill(300,0,50)
  96.                 text("Game Over",165,220)
  97.  
  98.  
  99.  
  100.        
  101.         if score >= 40:
  102.                 image(q,0,0)
  103.                 textSize(90)
  104.                 fill(0,300,50)
  105.                 text("you win",200,200)
  106.        
  107. def keyPressed():
  108.         global player_x
  109.         global player_y
  110.         global score
  111.         global strawberry_x
  112.         global strawberry_y
  113.         global lives
  114.        
  115.        
  116.         if keyboard.keyCode == RIGHT:
  117.                 player_x = player_x + 50       
  118.         if keyboard.keyCode == LEFT:
  119.                 player_x = player_x - 50
  120.         if keyboard.keyCode == UP:
  121.                 player_y = player_y - 50
  122.         if keyboard.keyCode == DOWN:
  123.                 player_y = player_y + 50
  124.                
  125.  
  126.        
  127.        
  128.        
  129.        
  130.         if score == 1:
  131.                 strawberry_x =(random.choice(x))
  132.                 strawberry_y =(random.choice(y))
  133.                 score = score +1
  134.                
  135.         if score == 3:
  136.                 strawberry_x =(random.choice(x))
  137.                 strawberry_y =(random.choice(y))
  138.                 score = score +1
  139.                
  140.         if score == 4:
  141.                 strawberry_x =(random.choice(x))
  142.                 strawberry_y =(random.choice(y))
  143.                 score = score +1
  144.         if score == 6:
  145.                 strawberry_x =(random.choice(x))
  146.                 strawberry_y =(random.choice(y))
  147.                 score = score +1
  148.                
  149.         if score == 8:
  150.                 strawberry_x =(random.choice(x))
  151.                 strawberry_y =(random.choice(y))
  152.                 score = score +1
  153.                
  154.         if score == 10:
  155.                 strawberry_x =(random.choice(x))
  156.                 strawberry_y =(random.choice(y))
  157.                 score = score +1
  158.                
  159.         if score == 12:
  160.                 strawberry_x =(random.choice(x))
  161.                 strawberry_y =(random.choice(y))
  162.                 score = score +1
  163.                
  164.         if score == 14:
  165.                 strawberry_x =(random.choice(x))
  166.                 strawberry_y =(random.choice(y))
  167.                 score = score +1
  168.         if score == 16:
  169.                 strawberry_x =(random.choice(x))
  170.                 strawberry_y =(random.choice(y))
  171.                 score = score +1       
  172.                
  173.         if score == 18:
  174.                 strawberry_x =(random.choice(x))
  175.                 strawberry_y =(random.choice(y))
  176.                 score = score +1
  177.                
  178.                
  179.                
  180.         if score == 20:
  181.                 strawberry_x =(random.choice(x))
  182.                 strawberry_y =(random.choice(y))
  183.                 score = score +1
  184.                
  185.                
  186.                
  187.        
  188.         if score == 22:
  189.                 strawberry_x =(random.choice(x))
  190.                 strawberry_y =(random.choice(y))
  191.                 score = score +1       
  192.                
  193.        
  194.         if score == 24:
  195.                 strawberry_x =(random.choice(x))
  196.                 strawberry_y =(random.choice(y))
  197.                 score = score +1       
  198.        
  199.        
  200.         if score == 26:
  201.                 strawberry_x =(random.choice(x))
  202.                 strawberry_y =(random.choice(y))
  203.                 score = score +1
  204.        
  205.         if score == 28:
  206.                 strawberry_x =(random.choice(x))
  207.                 strawberry_y =(random.choice(y))
  208.                 score = score +1
  209.                
  210.                
  211.                
  212.         if score == 30:
  213.                 strawberry_x =(random.choice(x))
  214.                 strawberry_y =(random.choice(y))
  215.                 score = score +1       
  216.        
  217.         if score == 32:
  218.                 strawberry_x =(random.choice(x))
  219.                 strawberry_y =(random.choice(y))
  220.                 score = score +1
  221.        
  222.         if score == 34:
  223.                 strawberry_x =(random.choice(x))
  224.                 strawberry_y =(random.choice(y))
  225.                 score = score +1
  226.        
  227.         if score == 36:
  228.                 strawberry_x =(random.choice(x))
  229.                 strawberry_y =(random.choice(y))
  230.                 score = score +1
  231.        
  232.         if score == 36:
  233.                 strawberry_x =(random.choice(x))
  234.                 strawberry_y =(random.choice(y))
  235.                 score = score +1
  236.        
  237.         if score == 38:
  238.                 strawberry_x =(random.choice(x))
  239.                 strawberry_y =(random.choice(y))
  240.                 score = score +1
  241.        
  242.         if player_x < 0 or player_x > width:
  243.                 player_x = 0
  244.                 player_y = 0
  245.         if player_y < 0 or player_y > height:
  246.                 player_x = 0
  247.                 player_y = 0
  248.        
  249.         if player_x == strawberry_x and player_y == strawberry_y :
  250.                 score = score +1
  251.  
  252.         if score >= 4:
  253.                 if 0<=player_x<=140   and player_y == 100 :
  254.                                 lives = lives - 1
  255.  
  256.                 if 200 <=player_x<=390   and player_y == 100 :
  257.                         lives = lives - 1
  258.                
  259.                 if 450<=player_x<=800   and player_y == 100 :
  260.                         lives = lives - 1      
  261.        
  262.                 if 0 <= player_x <= 290  and player_y ==250:
  263.                         lives = lives - 1
  264.                 if 350<=player_x <= 400   and player_y ==250:
  265.                         lives = lives - 1
  266.                 if 500<=player_x <= 750  and player_y ==250:
  267.                         lives = lives - 1
  268.        
  269.                 if 0<=player_x<=130   and player_y ==400:
  270.                         lives = lives - 1
  271.                 if 200<=player_x<=390   and player_y ==400:
  272.                         lives = lives - 1
  273.                 if 450 <=player_x<=800  and player_y ==400:
  274.                         lives = lives - 1
  275.  
  276. run()