- import time
- amount = 0
- message.show("Myszką- Chodzisz, SPACJA- Strzelasz, Aby kontynuować kliknij- Enter")
- message.show("Aby wygrać musisz zdobyć 100 punktów powodzenia :D, Aby rozpocząć grę kliknij- Enter")
- class Ochrona(Sprite):
- def __init__(self):
- self.image = 56
- self.size = 30
- self.color=Color(255,51,0)
- def update(self):
- self.position = game.mouse.position
- class Player(Sprite):
- def __init__(self):
- self.color=Color(51,153,0)
- self.position = Vector(0, -50)
- self.size = 20
- self.image=7
- self.reloading = 0
- def update(self):
- self.position = game.mouse.position
- self.reloading +=1
- if((game.key("space")) and (self.reloading > 10)):
- game.add(Pocisk())
- self.reloading = 0
- if(self.collide(pocisk)):
- self.color=Color(255,0,0)
- game.stop()
- message.show('Zdobyłeś tyle punktów ' + str(wynik) + ' brawo!')
- if(self.collide(po)):
- self.color=Color(255,0,0)
- game.stop()
- message.show('Zdobyłeś tyle punktów ' + str(wynik) + ' brawo!')
- if(self.collide(boss)):
- self.color=Color(255,0,0)
- game.stop()
- class Pocisk(Sprite):
- def __init__(self):
- self.size = 10
- self.image=68
- self.angle = 90
- self.position = player.position
- poc.append(self)
- def update(self):
- self.position.y += 3
- if(self.position.y == 100):
- game.remove(self)
- if(self.collide(Boss())):
- game.remove(self)
- if(self.collide(po)):
- game.remove(self)
- class Pociskina(Sprite):
- def __init__(self):
- self.size = 15
- self.image = 67
- boss = Boss()
- self.position = boss.position
- po.append(self)
- def update(self):
- self.move(4)
- self.angle = (game.mouse.position - self.position).angle
- if(random.randint(0,150)==0):
- game.add(Power(self.position))
- game.remove(self)
- if(self.collide(poc)):
- game.remove(self)
- if(self.collide(och)):
- game.remove(och)
- game.remove(self)
- class Pociski(Sprite):
- def __init__(self,pos):
- self.size = 15
- self.image = 67
- self.color=Color(255,0,0)
- self.position=pos
- pocisk.append(self)
- def update(self):
- self.position.y -= 3
- if(self.position.y<-90):
- game.remove(self)
- global amount
- amount += 1
- if(amount==2):
- game.remove(self)
- if(self.collide(poc)):
- game.remove(self)
- if(self.collide(och)):
- game.remove(och)
- class Boss(Sprite):
- def __init__(self):
- self.size = 50
- self.image=14
- self.color=Color(0,51,255)
- self.position = Vector(0,75)
- self.przelad = 0
- self.przeladd = 0
- amount = 0
- def update(self):
- self.przeladd += 1
- self.przelad += 1
- if (self.flip):
- self.move(-2)
- else:
- self.move(2)
- if (self.position.x==100):
- self.flip=True
- if (self.position.x==-100):
- self.flip=False
- if(self.przelad > 10):
- game.add(Pociski(self.position))
- self.przelad = 0
- if(random.randint(0,1)==0):
- self.color=Color(0,51,255)
- if(self.przeladd > 60):
- game.add(Pociskina())
- self.przeladd = 0
- global wynik
- if(self.collide(poc)):
- self.color=Color(255,0,0)
- wynik += 1
- global punkty
- punkty += 1
- pokaz_punkty()
- game.remove(Pocisk())
- if(wynik == 100):
- game.remove(self)
- message.show('Wygrales!, aby kontynuować kliknij- Enter')
- game.stop()
- class Gwiazdy(Sprite):
- def __init__(self):
- self.size = 5
- self.image = 71
- self.color=Color(204,255,0)
- self.position = Vector(random.randint(-100,100),random.randint(-100,100))
- class Power(Sprite):
- def __init__(self,position):
- self.image=36
- self.size=1
- self.color=Color(51,255,0)
- self.position = Vector(random.randint(-100,100),random.randint(-100,100))
- self.is_tam=True
- def update(self):
- self.size=math.min(15,self.size+0.2)
- if (self.collide(player)):
- self.is_tam=False
- if (self.is_tam==False):
- self.size-=3
- if(self.size==0):
- game.add(och)
- game.remove(self)
- def pokaz_punkty():
- punkt1.image=94+(punkty//10)
- punkt2.image=94+(punkty%10)
- player = Player()
- po=[]
- poc=[]
- pocisk=[]
- poo = Pocisk()
- boss = Boss()
- och = Ochrona()
- wynik = 0
- punkty = 0
- namierzenie = 0
- game.background=Color(0,0,0)
- for i in range(20):
- game.add(Gwiazdy())
- game.add(Boss())
- game.add(player)
- punkt1=Sprite()
- punkt1.image=94
- punkt1.position=Vector(-90,90)
- punkt1.size=15
- punkt1.color=Color(255,255,255)
- game.add(punkt1)
- punkt2=Sprite()
- punkt2.image=94
- punkt2.position=Vector(-80,90)
- punkt2.size=15
- punkt2.color=Color(255,255,255)
- game.add(punkt2)
- game.start()