Beispiel #1
0
 def events(self, event_list):
     for event in event_list:
         if event.type == pygame.QUIT:
             pygame.quit()
             quit()
         if event.type == pygame.KEYDOWN:
             if self.wsk_ind == 1:
                 if event.key == pygame.K_UP:
                     self.col1, self.col3 = self.col3, self.col1
                     self.wsk_ind = 3
                 if event.key == pygame.K_DOWN:
                     self.col1, self.col2 = self.col2, self.col1
                     self.wsk_ind = 2
             elif self.wsk_ind == 2:
                 if event.key == pygame.K_UP:
                     self.col2, self.col1 = self.col1, self.col2
                     self.wsk_ind = 1
                 if event.key == pygame.K_DOWN:
                     self.col2, self.col3 = self.col3, self.col2
                     self.wsk_ind = 3
             elif self.wsk_ind == 3:
                 if event.key == pygame.K_UP:
                     self.col3, self.col2 = self.col2, self.col3
                     self.wsk_ind = 2
                 if event.key == pygame.K_DOWN:
                     self.col3, self.col1 = self.col1, self.col3
                     self.wsk_ind = 1
             if event.key == pygame.K_RETURN:
                 if self.wsk_ind == 1: self.carryOn = False
                 if self.wsk_ind == 3: fun.quitgame()
                 if self.wsk_ind == 2: return True
Beispiel #2
0
 def update(self):
     pygame.display.set_caption("River Raid")
     #self.screen.fill(self.BLUE)
     self.screen.blit(self.image, (0, 0))
     pygame.draw.rect(self.screen, self.GREEN,
                      [0, 0, 70, self.SCREENHEIGHT])
     pygame.draw.rect(self.screen, self.GREEN,
                      [self.SCREENWIDTH - 70, 0, 100, self.SCREENHEIGHT])
     #draw all the map elements
     self.island_list.update()
     self.island_list.draw(self.screen)
     self.cros_list.update()
     for c in self.cros_list:
         c.draw(self.screen)
     self.barrel_list.update()
     self.barrel_list.draw(self.screen)
     #draw all the 'moving' objects
     self.all_sprites_list.update()
     self.all_sprites_list.draw(self.screen)
     #cooldown measurement
     self.cmeter.crate = self.spaceship.crate
     self.cmeter.draw(self.screen)
     #fuel measurement
     if self.ex is None: self.fmeter.frate = self.spaceship.frate
     self.fmeter.draw(self.screen)
     #podliczenie wyniku i zmiana trudnosci na jego podstawie
     self.dist += 1
     fun.objects_hit(self.count, self.screen)
     if self.heli_freq > 1000:
         self.heli_freq -= 0.01 * self.count
     if self.heli_speedy < 5:
         self.heli_speedy += 0.0000001 * self.dist
     #Refresh Screen
     pygame.display.update()
Beispiel #3
0
 def naPionku(self, *mouse, screen, turn):
     for raw in self.field:
         for pole in raw:
             x, y = pole.posX, pole.posY
             if (pole.naPolu == turn or pole.naPolu == turn + 2) and x < mouse[0] < x + FLD and y < mouse [1] < y + FLD:
                 Funkcje.draw(x, y, screen, 'podswietlenie.png')
                 return pole
     return
Beispiel #4
0
 def draw(self, surf):
     pygame.draw.rect(surf, BLACK, self.rect, 2)
     pygame.draw.rect(
         surf, (242, 227, 109),
         pygame.Rect(self.SCREENWIDTH - 24,
                     self.SCREENHEIGHT - 6 - self.frate, 21, self.frate))
     for i in range(len(self.letters)):
         fun.message_display(self.letters[i], surf, 30, False, RED,
                             self.rect.x + 8, self.rect.y + 22 * i)
Beispiel #5
0
 def draw(self, surf):
     pygame.draw.rect(surf, BLACK, self.rect, 2)
     if self.crate <= 70:
         pygame.draw.rect(
             surf, L_BLUE,
             pygame.Rect(5, self.SCREENHEIGHT - 6 - self.crate, 21,
                         self.crate))
     else:
         pygame.draw.rect(
             surf, RED,
             pygame.Rect(5, self.SCREENHEIGHT - 6 - self.crate, 21,
                         self.crate))
     for i in range(len(self.letters)):
         fun.message_display(self.letters[i], surf, 30, False, YELLOW,
                             self.rect.x + 8, self.rect.y + 22 * i)
Beispiel #6
0
    def __init__(self):

        self.c_ind = [int(i) for i in fun.read_floats('options.txt', 3, 6)]
        self.carryOn = False
        self.SCREENWIDTH = 500
        self.SCREENHEIGHT = 600
        self.size = (self.SCREENWIDTH, self.SCREENHEIGHT)
        self.screen = pygame.display.set_mode(self.size)
        self.image = pygame.image.load("graphic/background.png")
        self.orange = (242, 136, 15)
        self.gold = (232, 229, 28)
        self.text1 = "VOLUME"
        if self.c_ind[0] == 1: self.text1op = " >low  medium  high"
        elif self.c_ind[0] == 2: self.text1op = "  low >medium  high"
        elif self.c_ind[0] == 3: self.text1op = "  low  medium >high"
        self.col1 = self.gold
        self.text2 = "HELICOPTER FREQ."
        self.col2 = self.orange
        if self.c_ind[1] == 1: self.text2op = " >low  medium  high"
        elif self.c_ind[1] == 2: self.text2op = "  low >medium  high"
        elif self.c_ind[1] == 3: self.text2op = "  low  medium >high"
        self.text3 = "ISLAND FREQ."
        self.col3 = self.orange
        if self.c_ind[2] == 1: self.text3op = " >low  medium  high"
        elif self.c_ind[2] == 2: self.text3op = "  low >medium  high"
        elif self.c_ind[2] == 3: self.text3op = "  low  medium >high"
        self.text4 = "BACK"
        self.col4 = self.orange
        self.r_ind = 1  #na co ostatnio wskazywalem; 1 - o1, 2 - o2, 3 o3, 4- back; oi == textiop
        #self.c_ind = [2,2,2] #na ktorym slowie w opcjach jest > (1,2,3)
        self.val = [[0.5, 1, 1.5], [4500, 3000, 1500], [16500, 11000, 5500]]
Beispiel #7
0
 def update(self):
     pygame.display.set_caption("River Raid")
     self.screen.blit(self.image, (0, 0))
     fun.message_display(self.wsk, self.screen, 100, False, self.colw, 50,
                         50 + (self.wsk_ind - 1) * 150)
     fun.message_display(self.text1, self.screen, 100, False, self.col1,
                         100, 50)
     fun.message_display(self.text2, self.screen, 100, False, self.col2,
                         100, 200)
     fun.message_display(self.text3, self.screen, 100, False, self.col3,
                         100, 350)
     pygame.display.update()
Beispiel #8
0
    def __init__(self):

        self.opt = fun.read_floats('options.txt', 0, 3)
        self.carryOn = True
        self.count = 0
        self.dist = 0
        self.heli_speedy = 1
        self.heli_speedx = 2
        self.heli_freq = self.opt[1]  #co ile milisekund pojawia sie helikopter
        self.isl_freq = self.opt[2]
        self.cros_freq = 29000
        self.bar_freq = 5000
        self.vol_cof = self.opt[0]
        self.plane_freq = 4000
        self.SCREENWIDTH = 500
        self.SCREENHEIGHT = 600
        self.size = (self.SCREENWIDTH, self.SCREENHEIGHT)
        self.screen = pygame.display.set_mode(self.size)
        self.image = pygame.image.load("graphic/background2.png")
        self.GREEN = (20, 255, 140)
        self.BLUE = (100, 100, 255)
        self.PURPLE = (255, 0, 255)
        #generuje statek
        self.spaceship = Spaceship()
        self.spaceship.rect.x = 160
        self.spaceship.rect.y = self.SCREENHEIGHT - 100
        #tworze wskazniki stanu statku
        self.cmeter = Cooldown()
        self.fmeter = Fuelmeter()
        #tworze zdarzenie
        self.gen_heli = pygame.USEREVENT + 1
        self.gen_isl = pygame.USEREVENT + 2
        self.gen_cros = pygame.USEREVENT + 3
        self.gen_bar = pygame.USEREVENT + 4
        self.gen_plane = pygame.USEREVENT + 5
        #listy obiektów
        self.all_sprites_list = pygame.sprite.Group(
        )  #self.all_sprites_list.add(spaceship)
        self.all_heli_list = pygame.sprite.Group()
        self.bullet_list = pygame.sprite.Group()
        self.island_list = pygame.sprite.Group()
        self.cros_list = pygame.sprite.Group()
        self.barrel_list = pygame.sprite.Group()
        self.plane_list = pygame.sprite.Group()
        self.ex = None
Beispiel #9
0
 def update(self):
     pygame.display.set_caption("River Raid")
     self.screen.blit(self.image, (0, 0))
     fun.message_display(self.text1, self.screen, 60, False, self.col1, 50,
                         30)
     fun.message_display(self.text1op, self.screen, 50, False, self.col1,
                         50, 115)
     fun.message_display(self.text2, self.screen, 60, False, self.col2, 50,
                         190)
     fun.message_display(self.text2op, self.screen, 50, False, self.col2,
                         50, 275)
     fun.message_display(self.text3, self.screen, 60, False, self.col3, 50,
                         350)
     fun.message_display(self.text3op, self.screen, 50, False, self.col3,
                         50, 435)
     fun.message_display(self.text4, self.screen, 60, False, self.col4, 50,
                         510)
     pygame.display.update()
Beispiel #10
0
    def gamelogic(self):

        #paliwo
        if self.spaceship.frate == 0:
            self.ex = Explosion(self.spaceship.rect.x, self.spaceship.rect.y)
            self.all_sprites_list.add(self.ex)
            self.spaceship.frate = -1
            self.spaceship.kill()

        #wpadanie w sciany
        if ((self.spaceship.rect.y < 0
             or self.spaceship.rect.y > self.SCREENHEIGHT) or
            (self.spaceship.rect.x < 70 - self.spaceship.rect.width / 2
             or self.spaceship.rect.x + self.spaceship.rect.width / 2 >
             self.SCREENWIDTH - 70)) and self.ex is None:
            fun.message_display('Crush!', self.screen, 115, True, self.PURPLE)
            pygame.display.update()
            time.sleep(2)
            self.carryOn = False

        #wpadanie w wyspy
        for m in self.island_list:
            if pygame.sprite.collide_mask(m, self.spaceship):
                fun.message_display('Crush!', self.screen, 115, True,
                                    self.PURPLE)
                pygame.display.update()
                time.sleep(2)
                self.carryOn = False
            for bar in self.barrel_list:
                if pygame.sprite.collide_rect(m, bar): bar.kill()
            if m.rect.y > self.SCREENHEIGHT:
                self.island_list.remove(m)

        #wpadanie w mosty
        for c in self.cros_list:
            for ci in c.list:
                if pygame.sprite.collide_mask(ci, self.spaceship):
                    fun.message_display('Crush!', self.screen, 115, True,
                                        self.PURPLE)
                    pygame.display.update()
                    time.sleep(2)
                    self.carryOn = False
            if c.lhill.rect.y > self.SCREENHEIGHT:
                self.cros_list.remove(c)

        #wpadanie w samoloty
        for s in self.plane_list:
            if pygame.sprite.collide_mask(s, self.spaceship):
                fun.message_display('Crush!', self.screen, 115, True,
                                    self.PURPLE)
                pygame.display.update()
                time.sleep(2)
                self.carryOn = False
            elif s.rect.y > self.SCREENHEIGHT:
                s.kill()

        #przesuwam Helikoptery w dol i horyzontalnie
        for h in self.all_heli_list:
            h.moveForward(self.heli_speedy)
            if h.rect.y > 0:
                h.move()
            if pygame.sprite.collide_mask(h, self.spaceship):
                fun.message_display('Crush!', self.screen, 115, True,
                                    self.PURPLE)
                pygame.display.update()
                time.sleep(2)
                self.carryOn = False
            elif h.rect.y > self.SCREENHEIGHT or h.rect.x > self.SCREENWIDTH:
                h.kill()

        # ruch kul i interakcje z obiektami
        for b in self.bullet_list:
            hit_list = pygame.sprite.spritecollide(b, self.all_heli_list, True)
            #True == trafione zostan usuniete
            for h in hit_list:  #100 pkt za helikopter
                b.kill()
                E = Explosion(h.rect.x, h.rect.y)
                self.all_sprites_list.add(E)
                E.music.set_volume(0.2 * self.vol_cof)
                pygame.mixer.Sound.play(E.music)
                self.count += 100

        for b in self.bullet_list:
            hit_list = pygame.sprite.spritecollide(b, self.plane_list, True)
            #True == trafione zostan usuniete
            for h in hit_list:  #150 pkt za samolot
                b.kill()
                E = Explosion(h.rect.x, h.rect.y)
                self.all_sprites_list.add(E)
                E.music.set_volume(0.2 * self.vol_cof)
                pygame.mixer.Sound.play(E.music)
                self.count += 150

        for b in self.bullet_list:
            for c in self.cros_list:  #200 za most
                if pygame.sprite.collide_rect(b, c.bridge) and c.list.has(
                        c.bridge):
                    b.kill()
                    c.list.remove(c.bridge)
                    E = Explosion(c.bridge.rect.x, c.bridge.rect.y)
                    self.all_sprites_list.add(E)
                    E.music.set_volume(0.2 * self.vol_cof)
                    pygame.mixer.Sound.play(E.music)
                    self.count += 200

        for b in self.bullet_list:
            for bar in self.barrel_list:
                if pygame.sprite.collide_rect(b, bar):
                    b.kill()
                    E = Explosion(bar.rect.x, bar.rect.y)
                    self.all_sprites_list.add(E)
                    E.music.set_volume(0.2 * self.vol_cof)
                    pygame.mixer.Sound.play(E.music)
                    bar.kill()
                    if self.ex is None:
                        self.spaceship.frate += min(50,
                                                    100 - self.spaceship.frate)

        for b in self.bullet_list:
            if b.rect.y < -10:
                b.kill()

        #self explosion
        if self.ex is not None and self.ex.index == 4:
            fun.message_display('You Run Out of Fuel!', self.screen, 45, True,
                                self.PURPLE)
            pygame.display.update()
            time.sleep(2)
            self.carryOn = False
Beispiel #11
0
    pygame.time.set_timer(G.gen_heli, int(G.heli_freq))
    pygame.time.set_timer(G.gen_cros, int(G.cros_freq))
    pygame.time.set_timer(G.gen_isl, int(G.isl_freq))
    pygame.time.set_timer(G.gen_bar, int(G.bar_freq))
    pygame.time.set_timer(G.gen_plane, int(G.plane_freq))

    while G.carryOn:
        event_list = pygame.event.get()
        for e in event_list:
            if e.type == G.gen_isl:
                ti = pygame.time.get_ticks()
            if e.type == G.gen_cros:
                tc = pygame.time.get_ticks()
        if abs(ti - tc) < 3000:
            event_list = [
                e for e in event_list
                if e.type != G.gen_cros and e.type != G.gen_isl
            ]
        if previous_freq - 500 >= G.heli_freq:
            pygame.time.set_timer(G.gen_heli, int(G.heli_freq))
            previous_freq = G.heli_freq
        G.events(event_list, pygame.key.get_pressed())
        G.gamelogic()
        G.update()
        clock.tick(60)

    G.carryOn = True

fun.quitgame()
Beispiel #12
0
)
zad = int(input())
print(
    "Czy chcesz rozróżnienie na płeć?\n1.Nie\n2.Tak - tylko kobiety\n3.Tak - tylko mężczyźni"
)
filtr = int(input())

if zad == 1:
    print(
        "Wybierz województwo: \n1.Zachodniopomorskie \n2.Śląskie \n3.Łódzkie \n4.Lubelskie \n5.Dolnośląskie \n6.Opolskie \n7.Podkarpackie \n8.Podlaskie \n9.Mazowieckie\n10.Małopolskie \n11.Pomorskie \n12.Warmińsko-Mazurskie \n13.Kujawsko-pomorskie \n14.Lubuskie \n15.Wielkopolskie\n16.Świętokrzyskie"
    )
    w = int(input())
    woj = Base.Konwertuj(w)
    print("Podaj rok:")
    rok = str(input())
    f.Srednia(filtr, woj, rok)
elif zad == 2:
    print(
        "Wybierz województwo: \n1.Zachodniopomorskie \n2.Śląskie \n3.Łódzkie \n4.Lubelskie \n5.Dolnośląskie \n6.Opolskie \n7.Podkarpackie \n8.Podlaskie \n9.Mazowieckie\n10.Małopolskie \n11.Pomorskie \n12.Warmińsko-Mazurskie \n13.Kujawsko-pomorskie \n14.Lubuskie \n15.Wielkopolskie\n16.Świętokrzyskie"
    )
    w = int(input())
    woj = Base.Konwertuj(w)
    temp = f.Procent_zdawalnosc(filtr, woj)
    for i in range(len(temp)):
        print(temp[i][0][1], temp[i][0][2], "%")
elif zad == 3:
    print("Podaj rok: ")
    rok = str(input())
    f.Najlepsza_zdawalnosc(filtr, rok)
elif zad == 4:
    f.Regresja(filtr)
Beispiel #13
0
import datetime
import Funkcje

pesel = []
pesel_number = input("Enter your pesel number: ")

if len(pesel_number) != 11 or pesel_number.isdigit() == False:
    raise IOError("PESEL incorrect")

for index in pesel_number:
    index = int(index)
    pesel.append(index)
print(pesel)

print("You age is:", Funkcje.get_date(pesel))

print(Funkcje.whats_your_gender(pesel))

print("If control number is -", Funkcje.is_pesel_correct(pesel),
      "PESEL is correct.")