Facebook
From Jakub Wiloch, 3 Years ago, written in Plain Text.
Embed
Download Paste or View Raw
Hits: 130
  1. import time
  2.  
  3.  
  4. amount = 0
  5.  
  6. message.show("Myszką- Chodzisz, SPACJA- Strzelasz, Aby kontynuować kliknij- Enter")
  7. message.show("Aby wygrać musisz zdobyć 100 punktów powodzenia :D, Aby rozpocząć grę kliknij- Enter")
  8.  
  9. class Ochrona(Sprite):
  10.   def __init__(self):
  11.    self.image = 56
  12.    self.size = 30
  13.    self.color=Color(255,51,0)
  14.   def update(self):
  15.    self.position = game.mouse.position
  16.  
  17. class Player(Sprite):
  18.   def __init__(self):
  19.    self.color=Color(51,153,0)
  20.    self.position = Vector(0, -50)
  21.    self.size = 20
  22.    self.image=7
  23.    self.reloading = 0
  24.   def update(self):
  25.      self.position = game.mouse.position
  26.      self.reloading +=1
  27.      if((game.key("space")) and (self.reloading > 10)):
  28.        game.add(Pocisk())
  29.        self.reloading = 0
  30.      if(self.collide(pocisk)):
  31.       self.color=Color(255,0,0)
  32.       game.stop()
  33.       message.show('Zdobyłeś tyle punktów ' + str(wynik) + ' brawo!')
  34.      if(self.collide(po)):
  35.       self.color=Color(255,0,0)
  36.       game.stop()
  37.       message.show('Zdobyłeś tyle punktów ' + str(wynik) + ' brawo!')
  38.      if(self.collide(boss)):
  39.       self.color=Color(255,0,0)
  40.       game.stop()
  41. class Pocisk(Sprite):
  42.   def __init__(self):
  43.    self.size = 10
  44.    self.image=68
  45.    self.angle = 90
  46.    self.position = player.position
  47.    poc.append(self)
  48.   def update(self):
  49.    self.position.y += 3
  50.    if(self.position.y == 100):
  51.     game.remove(self)
  52.    if(self.collide(Boss())):
  53.     game.remove(self)
  54.    if(self.collide(po)):
  55.     game.remove(self)
  56. class Pociskina(Sprite):
  57.  def __init__(self):
  58.   self.size = 15
  59.   self.image = 67
  60.   boss = Boss()
  61.   self.position = boss.position
  62.   po.append(self)
  63.  def update(self):
  64.   self.move(4)
  65.   self.angle = (game.mouse.position - self.position).angle
  66.   if(random.randint(0,150)==0):
  67.    game.add(Power(self.position))
  68.    game.remove(self)
  69.   if(self.collide(poc)):
  70.     game.remove(self)
  71.   if(self.collide(och)):
  72.     game.remove(och)
  73.     game.remove(self)
  74. class Pociski(Sprite):
  75.  def __init__(self,pos):
  76.   self.size = 15
  77.   self.image = 67
  78.   self.color=Color(255,0,0)
  79.   self.position=pos
  80.   pocisk.append(self)
  81.  def update(self):
  82.    self.position.y -= 3
  83.    if(self.position.y<-90):
  84.     game.remove(self)
  85.    global amount
  86.    amount += 1
  87.    if(amount==2):
  88.     game.remove(self)
  89.    if(self.collide(poc)):
  90.     game.remove(self)
  91.    if(self.collide(och)):
  92.     game.remove(och)
  93. class Boss(Sprite):
  94.  def __init__(self):
  95.   self.size = 50
  96.   self.image=14
  97.   self.color=Color(0,51,255)
  98.   self.position = Vector(0,75)
  99.   self.przelad = 0
  100.   self.przeladd = 0
  101.   amount = 0
  102.  def update(self):
  103.   self.przeladd += 1
  104.   self.przelad += 1
  105.   if (self.flip):
  106.         self.move(-2)
  107.   else:
  108.         self.move(2)
  109.   if (self.position.x==100):
  110.         self.flip=True
  111.   if (self.position.x==-100):
  112.         self.flip=False
  113.   if(self.przelad > 10):
  114.    game.add(Pociski(self.position))
  115.    self.przelad = 0
  116.   if(random.randint(0,1)==0):
  117.     self.color=Color(0,51,255)
  118.   if(self.przeladd > 60):
  119.     game.add(Pociskina())
  120.     self.przeladd = 0
  121.   global wynik
  122.   if(self.collide(poc)):
  123.     self.color=Color(255,0,0)
  124.     wynik += 1
  125.     global punkty
  126.     punkty += 1
  127.     pokaz_punkty()
  128.     game.remove(Pocisk())
  129.   if(wynik == 100):
  130.     game.remove(self)
  131.     message.show('Wygrales!, aby kontynuować kliknij- Enter')
  132.     game.stop()
  133.    
  134.    
  135.                
  136. class Gwiazdy(Sprite):
  137.  def __init__(self):
  138.   self.size = 5
  139.   self.image = 71
  140.   self.color=Color(204,255,0)
  141.   self.position = Vector(random.randint(-100,100),random.randint(-100,100))
  142. class Power(Sprite):
  143.   def __init__(self,position):
  144.                 self.image=36
  145.                 self.size=1
  146.                 self.color=Color(51,255,0)
  147.                 self.position = Vector(random.randint(-100,100),random.randint(-100,100))
  148.                 self.is_tam=True
  149.   def update(self):
  150.                 self.size=math.min(15,self.size+0.2)
  151.                 if (self.collide(player)):
  152.                         self.is_tam=False
  153.                 if (self.is_tam==False):
  154.                         self.size-=3
  155.                 if(self.size==0):
  156.                         game.add(och)
  157.                         game.remove(self)
  158.  
  159. def pokaz_punkty():
  160.         punkt1.image=94+(punkty//10)
  161.         punkt2.image=94+(punkty%10)
  162.  
  163.  
  164. player = Player()
  165. po=[]
  166. poc=[]
  167. pocisk=[]
  168. poo = Pocisk()
  169. boss = Boss()
  170. och = Ochrona()
  171. wynik = 0
  172. punkty = 0
  173. namierzenie = 0
  174. game.background=Color(0,0,0)
  175. for i in range(20):
  176.         game.add(Gwiazdy())
  177. game.add(Boss())
  178. game.add(player)
  179. punkt1=Sprite()
  180. punkt1.image=94
  181. punkt1.position=Vector(-90,90)
  182. punkt1.size=15
  183. punkt1.color=Color(255,255,255)
  184. game.add(punkt1)
  185. punkt2=Sprite()
  186. punkt2.image=94
  187. punkt2.position=Vector(-80,90)
  188. punkt2.size=15
  189. punkt2.color=Color(255,255,255)
  190. game.add(punkt2)
  191. game.start()