예제 #1
0
def draw_shop_button(x, y, r, tower, text):
    global mouseX
    global mouseY
    global money
    global tower_select
    window.drawRect(x - r / 2 - 2, y - r / 2 - 2, r + 4, r + 4, 0.0, 0.0, 0.0)
    window.drawRect(x - r / 2, y - r / 2, r, r, 0.2, 0.6, 0.5)
    font1.draw(text, x - r * 2 / 5, y - r / 3, r / 20, 0.8, 0.5, 0.6)
    font1.draw("$ " + str(towerPrice[tower]), x - r * 2 / 5, y - r / 8, r / 20,
               0.8, 0.5, 0.6)
    stower = Basic_Tower_Class.Tower(x, y + 20, 0, tower, images)
    stower.draw()
    downis = ccircle.isMouseDown('left')
    if x + r / 2 > mouseX > x - r / 2 and y + r / 2 > mouseY > y - r / 2:
        window.drawRect(x - r / 2 - 10, y - r / 2 - 10, r + 20, r + 20, 0.0,
                        0.0, 0.0)
        window.drawRect(x - r / 2 - 8, y - r / 2 - 8, r + 16, r + 16, 0.2, 0.6,
                        0.5)
        font1.draw(text, x - r / 2, y - r / 3, r / 14, 0.8, 0.5, 0.6)
        font1.draw("$ " + str(towerPrice[tower]), x - r / 2, y - r / 8, r / 14,
                   0.8, 0.5, 0.6)
        stower.draw()
        if downis and tower_select == -1 and money >= towerPrice[tower]:
            money = money - towerPrice[tower]
            stower.draw()
            tower_select = tower
예제 #2
0
def settings_page():
    global difficulty
    window.clear(0.3, 0.6, 0.5)
    draw_button(800, 750, 70, 1, "BACK")
    draw_button(600, 300, 80, 3, "EASY")
    draw_button(1000, 300, 80, 3, "MEDIUM")
    draw_button(600, 500, 80, 3, "HARD")
    draw_button(1000, 500, 80, 3, "DEATH")
    if dst(mouseX, 600, mouseY, 300) <= 80:
        window.drawCircle(600, 300, 90, 0.0, 0.0, 0.0)
        window.drawCircle(600, 300, 86, 0.35, 0.45, 0.85)
        font1.draw("EASY", 560, 300, 15, 0.8, 0.5, 0.6)
        if ccircle.isMouseDown('left'):
            difficulty = 1
    elif dst(mouseX, 1000, mouseY, 300) <= 80:
        window.drawCircle(1000, 300, 90, 0.0, 0.0, 0.0)
        window.drawCircle(1000, 300, 86, 0.35, 0.45, 0.85)
        font1.draw("MEDIUM", 960, 300, 15, 0.8, 0.5, 0.6)
        if ccircle.isMouseDown('left'):
            difficulty = 2
    elif dst(mouseX, 600, mouseY, 500) <= 80:
        window.drawCircle(600, 500, 90, 0.0, 0.0, 0.0)
        window.drawCircle(600, 500, 86, 0.35, 0.45, 0.85)
        font1.draw("HARD", 560, 500, 15, 0.8, 0.5, 0.6)
        if ccircle.isMouseDown('left'):
            difficulty = 3
    elif dst(mouseX, 1000, mouseY, 500) <= 80:
        window.drawCircle(1000, 500, 90, 0.0, 0.0, 0.0)
        window.drawCircle(1000, 500, 86, 0.35, 0.45, 0.85)
        font1.draw("DEATH", 960, 500, 15, 0.8, 0.5, 0.6)
        if ccircle.isMouseDown('left'):
            difficulty = 4
    if difficulty == 1:
        window.drawCircle(600, 300, 80, 0.5, 0.6, 1.0, 0.4)
    elif difficulty == 2:
        window.drawCircle(1000, 300, 80, 0.5, 0.6, 1.0, 0.4)
    elif difficulty == 3:
        window.drawCircle(600, 500, 80, 0.5, 0.6, 1.0, 0.4)
    elif difficulty == 4:
        window.drawCircle(1000, 500, 80, 0.5, 0.6, 1.0, 0.4)
예제 #3
0
def game_page():
    global enemies
    global enemy
    global tower
    global wave
    global load
    global load2
    global pg
    global lives
    global tower_select
    global money
    global dst
    if load >= 0 and load % waves[wave][
            1] == 0 and waves[wave][1] * waves[wave][2] - load >= 0:
        enemy = Basic_Enemy_Class.Enemy(135, 0, 'down', waves[wave][0])
        enemies.append(enemy)
    elif waves[wave][1] * waves[wave][2] - load < 0:
        wave = wave + 1
        load = -3000
    if wave > len(waves):
        pg = 5

    window.clear(0.0, 1.0, 0.5)
    for i in range(0, 10):
        for j in range(0, 10):
            if grids[difficulty - 1][i][j] == "e":
                window.drawRect(80 * j + 20, 80 * i + 20, 70, 70, 0.1, 0.8,
                                0.2)
                if tower_select != -1 and 80 * j < mouseX < 80 * j + 80 and 80 * i < mouseY < 80 * i + 80:
                    window.drawRect(80 * j + 20, 80 * i + 20, 70, 70, 0.0, 0.6,
                                    0.0)
                    if ccircle.isMouseDown('left'):
                        t = Basic_Tower_Class.Tower(j * 80 + 55, i * 80 + 55,
                                                    0, tower_select, images)
                        grids[difficulty - 1][i][j] = t
                        towers.append(t)
                        tower_select = -1
            if grids[difficulty - 1][i][j] == "t":
                window.drawRect(80 * j + 20, 80 * i + 20, 70, 70, 0.1, 0.5,
                                0.5)
            if grids[difficulty - 1][i][j] != "t" and grids[difficulty -
                                                            1][i][j] != "e":
                t = grids[difficulty - 1][i][j]
                window.drawRect(80 * j + 20, 80 * i + 20, 70, 70, 0.1, 0.8,
                                0.2)
                t.draw()
                if 80 * j < mouseX < 80 * j + 80 and 80 * i < mouseY < 80 * i + 80:
                    window.drawCircle(80 * j + 60, 80 * i + 60, t.rng, 0.4,
                                      0.4, 0.4, 0.4)
                    if t.lvl == 0:
                        if money >= towerUpgrade[t.which]:
                            font1.draw("$ " + str(towerUpgrade[t.which]),
                                       80 * j + 40, 80 * i + 60, 6, 0.0, 0.8,
                                       0.4)
                            if ccircle.isMouseDown('right'):
                                t.lvl = 1
                                money = money - towerUpgrade[t.which]
                                t.refresh()
                        if money <= towerUpgrade[t.which]:
                            font1.draw("$ " + str(towerUpgrade[t.which]),
                                       80 * j + 40, 80 * i + 60, 6, 1.0, 0.1,
                                       0.1)
    for enemy in list(enemies):
        enemy.draw(window)
        enemy.update(dst, difficulty)
        if enemy.x > 800:
            enemies.remove(enemy)
            lives = lives - 1
        if enemy.hp <= 0:
            enemies.remove(enemy)
            money = money + 15

    if tower_select != -1:
        tower = Basic_Tower_Class.Tower(mouseX, mouseY, 0, tower_select,
                                        images)
        tower.draw()

    font1.draw(str(lives) + " LIVES", 850, 100, 20, 1.0, 0.0, 0.0)
    font1.draw("$ " + str(money), 1100, 100, 20, 0.8, 1.0, 0.2)
    font1.draw("WAVE " + str(wave + 1), 1300, 100, 20, 0.0, 0.0, 1.0)
    for a in range(6):
        draw_shop_button(900 + 120 * a, 200, 100, a, towerNam[a])
    for a in range(6, 8):
        draw_shop_button(900 + 120 * (a - 6), 350, 100, a, towerNam[a])
    for tower in towers:
        not_shot = True
        tower.closest = tower.rng
        for enemy in enemies:
            if dst(tower.x, enemy.x, tower.y, enemy.y) < tower.closest:
                tower.closest = dst(tower.x, enemy.x, tower.y, enemy.y)
        for enemy in enemies:
            if dst(tower.x, enemy.x, tower.y, enemy.y) <= tower.rng and \
                    load2 % tower.rof == 0 and \
                    dst(tower.x, enemy.x, tower.y, enemy.y) <= tower.closest and \
                    not_shot:
                tower.closest = dst(tower.x, enemy.x, tower.y, enemy.y)
                bullet = Basic_Ammo_Class.Ammo(
                    tower.x, tower.y,
                    tower.spd * ((enemy.x - tower.x) /
                                 dst(tower.x, enemy.x, tower.y, enemy.y)),
                    tower.spd * ((enemy.y - tower.y) /
                                 dst(tower.x, enemy.x, tower.y, enemy.y)),
                    tower.which,
                    atan2((tower.x - enemy.x),
                          (tower.y - enemy.y)) * (360 / (2 * pi)), tower, imgs)
                if tower.which == 4:
                    spray1 = Basic_Ammo_Class.Ammo(
                        tower.x - 20, tower.y,
                        tower.spd * ((enemy.x - tower.x) /
                                     dst(tower.x, enemy.x, tower.y, enemy.y)),
                        tower.spd * ((enemy.y - tower.y) /
                                     dst(tower.x, enemy.x, tower.y, enemy.y)),
                        tower.which,
                        atan2((tower.x - enemy.x),
                              (tower.y - enemy.y)) * (360 / (2 * pi)), tower,
                        imgs)
                    spray2 = Basic_Ammo_Class.Ammo(
                        tower.x + 20, tower.y,
                        tower.spd * ((enemy.x - tower.x) /
                                     dst(tower.x, enemy.x, tower.y, enemy.y)),
                        tower.spd * ((enemy.y - tower.y) /
                                     dst(tower.x, enemy.x, tower.y, enemy.y)),
                        tower.which,
                        atan2((tower.x - enemy.x),
                              (tower.y - enemy.y)) * (360 / (2 * pi)), tower,
                        imgs)
                    ammos.append(spray1)
                    ammos.append(spray2)

                not_shot = False
                tower.angle = atan2((tower.x - enemy.x),
                                    (tower.y - enemy.y)) * (360 / (2 * pi))
                ammos.append(bullet)

    for bullet in list(ammos):
        bullet.draw(window)
        bullet.update(enemies)
        if bullet.deleted:
            ammos.remove(bullet)
예제 #4
0
lives = 50
wave = 0

pause = 0

difficulty = 1


def draw_button(x, y, r, case, text):
    global pg
    global mouseX
    global mouseY
    window.drawCircle(x, y, r + 4, 0.0, 0.0, 0.0)
    window.drawCircle(x, y, r, 0.3, 0.4, 0.8)
    font1.draw(text, x - r / 2, y, r / 7, 0.8, 0.5, 0.6)
    isdown = ccircle.isMouseDown('left')
    if dst(mouseX, x, mouseY, y) <= r:
        window.drawCircle(x, y, r + 10, 0.0, 0.0, 0.0)
        window.drawCircle(x, y, r + 6, 0.35, 0.45, 0.85)
        font1.draw(text, x - r / 2, y, r / 6, 0.8, 0.5, 0.6)
        if isdown:
            pg = case


def draw_shop_button(x, y, r, tower, text):
    global mouseX
    global mouseY
    global money
    global tower_select
    window.drawRect(x - r / 2 - 2, y - r / 2 - 2, r + 4, r + 4, 0.0, 0.0, 0.0)
    window.drawRect(x - r / 2, y - r / 2, r, r, 0.2, 0.6, 0.5)
예제 #5
0
import ccircle

window = ccircle.Window()
window.toggleMaximized()
window.hideMouse()

points = []

while window.isOpen():
    window.clear(0.2, 0.2, 0.3)
    mx, my = window.getMousePos()

    if ccircle.isMouseDown('left'):
        points.append((mx, my))

    for point in points:

        window.drawCircle(point[0], point[1], 7, 0.3, 0.5, 0.9)

        if len(points) >= 21:
            window.drawCircle(points[20][0], points[6][1], 16, 1.0, 0.3, 0.1)

        window.drawCircle(mx, my, 8, 0.1, 0.3, 0.5)
    window.update()
예제 #6
0
파일: Sounds.py 프로젝트: jd2004/ccircle
from math import *
import time

window = ccircle.Window('keebored')
mysound = ccircle.Sound()

b = 1

window.toggleMaximized()


def sound1(t, f):
    return sin(2 * pi * f * t)


while window.isOpen():
    window.clear(0.0, 0.0, 0.0)
    mouseX, mouseY = window.getMousePos()
    for i in range(10):
        window.drawRect(300 + i * 105, 250, 100, 300, 1.0, 1.0, 1.0)
        if ccircle.isMouseDown(
                'left') and 1350 > mouseX > 300 and 550 > mouseY > 250:
            mysound.addSample(sound1(t, 500 * i))
            mysound.play()
            time.sleep(1)
    for i in range(9):
        window.drawRect(370 + i * 105, 250, 60, 160, 0.0, 0.0, 0.0)
    for m in range(44100):
        t = m / 44100
    window.update()
예제 #7
0
파일: A nu fyl.py 프로젝트: jd2004/ccircle
     cloudY.append(random.randint(1, 300))
     cloudSize.append(random.randint(60, 140))
     cloudSpeed.append(random.randint(1, 3))
     window.drawCircle(cloudX[i], cloudY[i], cloudSize[i], 1.0, 1.0, 1.0,
                       0.3)
     cloudX[i] += cloudSpeed[i]
     if cloudX[i] > 1600:
         cloudX[i] = 1
 for i in range(50):
     window.hideMouse()
     mouseX, mouseY = window.getMousePos()
     bouncyX.append(random.randint(1, 1600))
     bouncyY.append(random.randint(20, 600))
     bouncySpeed.append(random.randint(1, 3))
     wind.append(random.randint(-2, 2))
     if ccircle.isMouseDown(
             'left') and bouncyY[i] - 15 <= mouseY <= bouncyY[i] + 15:
         bouncySpeed[i] = bouncySpeed[i] + 6
         if bouncyX[i] + 15 >= mouseX >= bouncyX[i]:
             wind[i] = wind[i] + 10
         if bouncyX[i] - 15 <= mouseX < bouncyX[i]:
             wind[i] = wind[i] - 10
         '''if bouncyY[i] + 15 >= mouseX >= bouncyY[i]:
            bouncySpeed[i] = bouncySpeed[i] + 6
         if bouncyY[i] - 15 <= mouseX < bouncyY[i]:
            bouncySpeed[i] = bouncySpeed[i] + 6'''
     bouncyX[i] = bouncyX[i] + wind[i]
     bouncySpeed[i] = bouncySpeed[i] + 0.1
     if bouncyY[i] < 650:
         bouncyY[i] = bouncyY[i] + bouncySpeed[i]
     elif bouncyY[i] >= 650:
         bouncySpeed[i] = bouncySpeed[i] * -0.95
예제 #8
0
color = 50
dotY = [
    0, -100, -240, -150, -70, -90, -210, -110, -40, -50, -69, -508, -57, -954,
    -195
]

dotX = [
    593, 105, 729, 345, 645, 893, 294, 169, 671, 716, 201, 801, 395, 487, 58
]
while window.isOpen():
    length, height = window.getSize()
    window.clear(0.01 * color, 0.01 * color, 0.02 * color)
    mouseX, mouseY = window.getMousePos()
    window.hideMouse()
    window.drawCircle(mouseX, mouseY, 100, 0.5, 1, 0.5)
    if ccircle.isMouseDown('left') == True:
        window.drawCircle(mouseX, mouseY + 30, size / 1.2, 0, 0, 0)
    else:
        window.drawCircle(mouseX, mouseY + 20, size, 0, 0, 0)
        window.drawCircle(mouseX, mouseY, size, 0.5, 1, 0.5)
    window.drawCircle(mouseX - 40, mouseY - 20, 16, 1, 1, 1)
    window.drawCircle(mouseX + 40, mouseY - 20, 16, 1, 1, 1)
    window.drawCircle(mouseX - 40, mouseY - 20, size / 5 + 2, 0, 0, 0)
    window.drawCircle(mouseX + 40, mouseY - 20, size / 5 + 2, 0, 0, 0)
    if bigger == True:
        size += 0.003
        if size >= 52:
            bigger = False
    if bigger == False:
        size -= 0.003
        if size <= 48:
예제 #9
0
    draw_boss(enemyX[22], enemyY[22], enemyHP[22])
    enemyY[22] = enemyY[22] + enemySpeed[22] / 2
    for m in range(0, 25):
        if dst(enemyX[22], towerX[m], enemyY[22], towerY[m]) < 15:
            enemyHP[22] = enemyHP[22] - 0.3
            if enemyDead[22] != 1:
                window.drawLine(towerX[m], towerY[m], enemyX[22], enemyY[22],
                                2, 1.0, 0.0, 0.0)
    if enemyHP[22] <= 0:
        enemyHP[22] = 0
        enemyDead[22] = 1
        window.drawCircle(enemyX[22], enemyY[22], 55, 0.0, 1.0, 0.4)
        window.drawRect(enemyX[22] - 510, enemyY[22] - 55, 1020, 30, 0.0, 1.0,
                        0.4)

    if ccircle.isMouseDown('left') and money >= 100:
        if mouseY < 168:
            if mouseX < 320 and towers1[0] != 1:
                towers1[0] = 1
                money = money - 100
            elif 320 < mouseX < 640 and towers1[1] != 1:
                towers1[1] = 1
                money = money - 100
            elif 640 < mouseX < 960 and towers1[2] != 1:
                towers1[2] = 1
                money = money - 100
            elif 960 < mouseX < 1280 and towers1[3] != 1:
                towers1[3] = 1
                money = money - 100
            elif 1280 < mouseX < 1600 and towers1[4] != 1:
                towers1[4] = 1