Esempio n. 1
0
def buy_coal():
    BUY = pygame.image.load('../media/images/buy.gif')

    SCREEN.blit(BUY, (0, 0))
    text = drawtext('BUY COAL POWER PLANT: 100000/-', 20)
    SCREEN.blit(text, (250, 200))

    while True:

        process()
        pygame.display.update()

        clicked = pygame.mouse.get_pressed()
        pos = pygame.mouse.get_pos()

        if clicked[0] is 1:

            if 660 < pos[0] < 715 and 190 < pos[1] < 220:

                break

            elif 420 < pos[0] < 540 and 350 < pos[1] < 400:

                a = []
                a = chkavail()

                if a[1] is 1:
                    text1 = drawtext('You have already got one unit', 20)
                    SCREEN.blit(text1, (300, 320))
                else:
                    f = open('../data_files/money.txt', 'r')

                    for line in f:
                        line = line[:-1]

                    f.close()
                    b = int(line)

                    if b > 100000:

                        b -= 100000

                        f = open('../data_files/money.txt', 'w')

                        f.write(str(b) + '\n')

                        text1 = drawtext('You bought one Coal Power Plant', 20)
                        SCREEN.blit(text1, (300, 300))
                        a[1] = 1

                        f = open('../data_files/availability.txt', 'w')

                        for i in range(12):
                            f.write(str(a[i]) + '\n')

                        f.close()

                        pygame.time.delay(200)

                    else:
                        tr = drawtext('You dont have enough money', 20)
                        SCREEN.blit(tr, (300, 320))

        CLOCK.tick(FPS)
Esempio n. 2
0
    for line in f:
        line = line[:-1]

    a = int(line)
    a += 1

    f1 = open('../data_files/money.txt', 'w')

    f1.write(str(a) + '\n')

    t1 = drawtext(str(a), 16)
    SCREEN.blit(t1, (830, 25))

    # power plant availability
    arr = []
    arr = chkavail()

    if arr[0] is 1:
        bug = Bug(228, 121, 40, 40, 'atomic_power_plant1.gif')

    if arr[1] is 1:
        bug1 = Bug(332, 202, 40, 40, 'coal_power_plant.gif')

    if arr[2] is 1:
        bug2 = Bug(454, 132, 40, 40, 'natural_gas_power_plant.gif')

    if arr[3] is 1:
        bug3 = Bug(226, 267, 40, 40, 'natural_gas_power_plant.gif')

    if arr[4] is 1:
        bug4 = Bug(533, 240, 40, 40, 'solar_power_plant.gif')
Esempio n. 3
0
def click():

    clicked = pygame.mouse.get_pressed()

    pos = pygame.mouse.get_pos()

    a = []

    a = chkavail()

    if clicked[0] is 1:

        if 284 < pos[0] < 388 and 184 < pos[1] < 241:

            if a[0] is 1:
                pressed_atomic()

        elif 397 < pos[0] < 511 and 251 < pos[1] < 313:
            if a[1] is 1:
                pressed_coal()

        elif 500 < pos[0] < 649 and 184 < pos[1] < 249:
            if a[2] is 1:
                pressed_natural1()

        elif 272 < pos[0] < 392 and 320 < pos[1] < 383:
            if a[3] is 1:
                pressed_natural2()

        elif 580 < pos[0] < 700 and 280 < pos[1] < 340:
            if a[4] is 1:
                pressed_solar1()

        elif 436 < pos[0] < 573 and 367 < pos[1] < 426:
            if a[5] is 1:
                pressed_solar2()

        elif 781 < pos[0] < 907 and 266 < pos[1] < 343:
            if a[6] is 1:
                pressed_wind1()

        elif 480 < pos[0] < 620 and 480 < pos[1] < 550:
            if a[7] is 1:
                pressed_wind2()

        elif 644 < pos[0] < 760 and 375 < pos[1] < 440:
            if a[8] is 1:
                pressed_hydro1()

        elif 74 < pos[0] < 190 and 137 < pos[1] < 200:
            if a[9] is 1:
                pressed_hydro2()

        elif 410 < pos[0] < 526 and 88 < pos[1] < 156:
            if a[10] is 1:
                pressed_geothermal1()

        elif 144 < pos[0] < 260 and 249 < pos[1] < 313:
            if a[11] is 1:
                pressed_geothermal2()

        elif 24 < pos[0] < 76 and 17 < pos[1] < 50:

            resume()

        elif 900 < pos[0] < 940 and 10 < pos[1] < 50:

            inventory()
Esempio n. 4
0
def inventory():

    INVENT = pygame.image.load('../media/images/inventory.jpg')



    #file operations







    while True:

        process()
        SCREEN.blit(INVENT, (0, 0))
        a = []
        a = chkavail()

        text1 = drawtext(str(a[0])+'/1', 20)
        SCREEN.blit(text1, (250, 217))

        text1 = drawtext(str(a[1])+'/1', 20)
        SCREEN.blit(text1, (530, 220))

        text1 = drawtext(str(a[2]+a[3])+'/2', 20)
        SCREEN.blit(text1, (810, 215))

        text1 = drawtext(str(a[4]+a[5])+'/2', 20)
        SCREEN.blit(text1, (200, 480))

        text1 = drawtext(str(a[6]+a[7])+'/2', 20)
        SCREEN.blit(text1, (410, 480))

        text1 = drawtext(str(a[8]+a[9])+'/2', 20)
        SCREEN.blit(text1, (640, 480))

        text1 = drawtext(str(a[10]+a[11])+'/2', 20)
        SCREEN.blit(text1, (860, 480))



        pygame.display.update()

        clicked = pygame.mouse.get_pressed()
        pos = pygame.mouse.get_pos()

        if clicked[0] is 1:

            if 20 < pos[0] < 70 and 20 < pos[1] < 55:

                break

            elif 120 < pos[0] < 280 and 247 < pos[1] < 290:
                buy_atomic()

            elif 400 < pos[0] < 560 and 250 < pos[1] < 290:

                buy_coal()

            elif 680 < pos[0] < 845 and 245 < pos[1] < 294:

                buy_natural()

            elif 75 < pos[0] < 240 and 500 < pos[1] < 560:

                buy_solar()

            elif 290 < pos[0] < 450 and 500 < pos[1] < 560:

                buy_wind()

            elif 517 < pos[0] < 650 and 510 < pos[1] < 560:

                buy_hydro()

            elif 740 < pos[0] < 900 and 510 < pos[1] < 560:

                buy_geothermal()

        CLOCK.tick(FPS)