import pygame, math, random
from game import map, objects, entities, ui
from game.objects import towerimages
from game.ui import Text, TextR, Effect

pygame.init()
pygame.display.init()

window = pygame.display.set_mode([1296, 960])
pygame.display.set_caption("Attack of the Goo")

pygame.time.set_timer(pygame.USEREVENT, 1000)

w = [255, 255, 255]
b = [0, 0, 0]
ui.FontInit(24, window)
ui.window = window
logo = pygame.image.load("./images/font/logo.png")

running = True
screen = "menu"
mouse = 0, 0
m = 0
mb = 0
ms = 0
wavestarted = False
enablegrid = False
info = None
spawning = False

cash = 150
health = 100

building = False
buildindex = 0
grid = pygame.image.load("./images/grid.png")
grid.set_colorkey([0,0,0])
bimg = pygame.image.load("./images/towers/gs.png")
bigimg = pygame.transform.scale(bimg, [100, 100])
builds = ["gs", "gds", "grs", "gcs", "gss",
          "ws", "wds", "wrs", "wcs", "wss",
          "fs", "fds", "frs", "fcs", "fss"]
pricing = {"gs":75, "gds":100, "grs":120, "gcs":175, "gss":150,
           "ws":100, "wds":135, "wrs":215, "wcs":200, "wss":165,
           "fs":150, "fds":135, "frs":175, "fcs":250, "fss":200}
names = {"gs":"single barrel turret", "gds":"double barrel turret", "grs":"rapid fire turret", "gcs":"cannon turret", "gss":"sniper turret",
         "ws":"single barrel soaker", "wds":"double barrel soaker", "wrs":"rapid fire soaker", "wcs":"cannon soaker", "wss":"sniper soaker",
         "fs":"flamethrower", "fds":"double flamethrower", "frs":"rapid flamethrower", "fcs":"fireball turret", "fss":"sniper flamethrower"}
reqstrs = {"g" : "regular tower", "f" : "fire tower", "w" : "soaker tower", "a" : "any tower",
           "s" : "single barrel type", "ds" : "double barrel type", "rs":"rapid fire type", "cs":"cannon type", "ss":"sniper type"}

#Format = [Type, Ammount, Delay (in ms)]
basewaves = [[["goo", 5, 800]],
            [["goo", 15, 800]],
            [["goo", 10, 600], ["goo", 10, 800]],
            [["goo", 50, 500]],
            [["goo", 15, 333], ["cube", 2, 500]],
            [["cube", 10, 500]],
            [["cube", 10, 333], ["goo", 20, 250]],
            [["cube", 30, 250]],
            [["cube", 50, 250]],
            [["cube", 10, 333], ["skater", 3, 600], ["goo", 10, 250]],
            [["goo", 5, 500], ["skater", 5, 500]],
            [["skater", 20, 750]],
            [["skater", 25, 500], ["cube", 25, 250]],
            [["skater", 10, 600], ["skater", 10, 450], ["skater", 10, 333], ["skater", 10, 250]],
            [["skater", 20, 333], ["jetpack", 3, 500]],
            [["jetpack", 5, 400], ["cube", 25, 250]],
            [["jetpack", 15, 450], ["goo", 15, 333]],
            [["jetpack", 35, 250]],
            [["goo", 20, 250], ["jetpack", 10, 450], ["jetpack", 10, 333], ["jetpack", 10, 250]],
            [["jetpack", 3, 250], ["jetpack", 2, 500], ["mini", 5, 333], ["cube", 15, 350]],
            [["goo", 20, 250], ["mini", 10, 333]],
            [["mini", 25, 500]],
            [["mini", 10, 450], ["goo", 5, 150], ["mini", 10, 300]],
            [["mini", 30, 333], ["cube", 30, 400], ["goo", 10, 400]],
            [["mini", 10, 333], ["jetpack", 10, 333], ["skater", 10, 333], ["cube", 10, 333], ["goo", 10, 333], ["giant", 2, 750]],
            [["cube", 25, 333], ["goo", 25, 333], ["jetpack", 5, 333]],
            [["cube", 20, 333], ["giant", 5, 1000], ["cube", 20, 333]],
            [["jetpack", 50, 333]],
            [["mini", 25, 333], ["jetpack", 25, 333]],
            [["jetpack", 33, 333], ["mini", 33, 333], ["skater", 33, 333]],
            [["cube", 50, 166], ["goo", 50, 166]],
            [["skater", 25, 450], ["cube", 50, 450], ["skater", 25, 450]],
            [["cube", 50, 450], ["goo", 50, 450], ["mini", 25, 450]],
            [["cube", 100, 150]],
            [["cube", 99, 150], ["cube", 1, 3000], ["goo", 100, 100]],
            [["cube", 50, 100], ["giant", 2, 1500], ["goo", 50, 100], ["giant", 2, 1500]],
            [["jetpack", 100, 150], ["giant", 1, 3000], ["mini", 100, 150], ["giant", 1, 3000], ["goo", 100, 100]],
            [["jetpack", 100, 150], ["giant", 2, 2000], ["mini", 100, 150], ["giant", 2, 2000], ["skater", 100, 150]],
            [["jetpack", 200, 150], ["giant", 1, 5000]],
            [["jetpack", 50, 150], ["giant", 4, 1000], ["giant", 1, 5000], ["jetpack", 50, 150], ["giant", 9, 1000], ["giant", 1, 5000], ["jetpack", 50, 150], ["giant", 14, 1000], ["giant", 1, 5000], ["jetpack", 50, 150], ["giant", 20, 1500]]]
waves = list(basewaves)
waveindex = 0
wave = -1
wavecycle = None

r = 0
radius = None
ctower = None
cfield = None
cr = None

maxmaps = 9
currentmap = random.randint(1, 9)
gmap, fields = map.loadmap(currentmap)
enemies = pygame.sprite.Group()
towers = pygame.sprite.Group()
bullets = pygame.sprite.Group()

clock = pygame.time.Clock()
fps = 60

ui.color = [200, 200, 200]
back = ui.Button("back", [15,15], hcolor=[255, 255, 255], bkgcolor=[200, 0, 0])
ui.color = w

menupos = False #False = Bottom, True = Top
boxbottom = pygame.surface.Surface([648, 120])
boxtop = pygame.surface.Surface([648, 120])
boxbottom = boxbottom.get_rect()
boxtop = boxtop.get_rect()
boxbottom.center = [648, 890]
boxtop.center = [648, 70]

gb = pygame.sprite.Group() #this definitely means great britain it totally doesn't mean game buttons
menubuttons = pygame.sprite.Group()
ui.color = [200, 200, 200]
ui.Font(32)
waveb = ui.Button("start wave", [436, 850], centered=True, hcolor=[255, 255, 255])
shop = ui.Button("build mode", [853, 850], centered=True, hcolor=[255, 255, 255])
ui.Font(24)
move = ui.Button("move menu", [644, 830], centered=True, hcolor=[255, 255, 255])
gb.add(waveb, shop, move)
exitshop = ui.Button("exit shop", [853, 830], centered=True, hcolor=[255, 255, 255], bkgcolor=[200,0,0])
selltower = ui.Button("sell tower", [853, 910], centered=True, hcolor=[255, 255, 255], bkgcolor=[200,0,0])
retarget = ui.Button("toggle target", [853, 860], centered=True, hcolor=[255, 255, 255])
ui.Font(40)
nextlevel = ui.Button("   next level   ", [648, 360], True, hcolor=[255, 255, 255])
replay = ui.Button("  replay level  ", [648, 480], True, hcolor=[255, 255, 255])
resume = ui.Button(" resume game ", [648, 336], True, hcolor=[255, 255, 255], bkgcolor=[0, 200, 0])
howtoplayb = ui.Button("  how to play  ", [648, 432], True, hcolor=[255, 255, 255])
settingsb = ui.Button("     settings     ", [648, 528], True, hcolor=[255, 255, 255])
gotomenu = ui.Button("return to menu", [648, 624], True, hcolor=[255, 255, 255], bkgcolor=[200, 0, 0])
exitbutton = ui.Button("   exit game   ", [648, 624], True, hcolor=[255, 255, 255], bkgcolor=[200, 0, 0])
playbutton = ui.Button("   play game   ", [648, 336], True, hcolor=[255, 255, 255], bkgcolor=[0, 200, 0])
menubuttons.add(howtoplayb, settingsb)
ui.Font(48)

sb = pygame.sprite.Group() #sad britain :(
muteaudio = ui.Button("toggle", [15, 100], False, hcolor=[255, 255, 255])
mutesettings = ui.Button("toggle", [15, 180], False, hcolor=[255, 255, 255])
hotkeys = ui.Button("toggle", [15, 260], False, hcolor=[255, 255, 255])
fullscreenb = ui.Button("toggle", [15, 340], False, hcolor=[255, 255, 255])
sb.add(muteaudio, mutesettings, hotkeys, fullscreenb)

ui.Font(32)
howtoplay = {"gotg" : pygame.image.load("./images/howtoplay/gotg.png"),
             "controls" : pygame.image.load("./images/howtoplay/controls.png"),
             "towers" : pygame.image.load("./images/howtoplay/towers.png"),
             "fields" : pygame.image.load("./images/howtoplay/fields.png"),
             "enemies" : pygame.image.load("./images/howtoplay/enemies.png"),
             "gameplay" : pygame.image.load("./images/howtoplay/gameplay.png")}
htp = "select"
hb = pygame.sprite.Group() #happy britain :)
gotg = ui.Button("goal of the game", [15, 120], False, hcolor=[255, 255, 255])
controls = ui.Button("controls", [15, 170], False, hcolor=[255, 255, 255])
towersb = ui.Button("towers", [15, 220], False, hcolor=[255, 255, 255])
fieldsb = ui.Button("fields", [15, 270], False, hcolor=[255, 255, 255])
enemiesb = ui.Button("enemies", [15, 320], False, hcolor=[255, 255, 255])
gameplay = ui.Button("gameplay / progression", [15, 370], False, hcolor=[255, 255, 255])
hb.add(gotg, controls, towersb, fieldsb, enemiesb, gameplay)

lastscreen = "menu"
settings = {"muteaudio" : False, "mutemusic" : False, "hotkeys" : True, "fullscreen" : False}

sounds = {"build":pygame.mixer.Sound("./audio/sfx/build.wav"),
          "end":pygame.mixer.Sound("./audio/sfx/endreached.wav"),
          "gameover":pygame.mixer.Sound("./audio/sfx/gameover.wav"),
          "kill":pygame.mixer.Sound("./audio/sfx/kill.wav"),
          "nextwave":pygame.mixer.Sound("./audio/sfx/nextwave.wav"),
          "select":pygame.mixer.Sound("./audio/sfx/select.wav"),
          "shoot":pygame.mixer.Sound("./audio/sfx/shoot.wav")}
sounds["kill"].set_volume(0.3)
sfx = pygame.mixer.Channel(1)
pygame.mixer.music.load("./audio/music/menu.wav")
pygame.mixer.music.play(25)

levelimages = []
levelrects = []
for i in range(9):
    levelimages.append(pygame.transform.scale(pygame.image.load("./images/maps/"+str(i+1)+".png"), [185, 137]))
    levelrects.append(levelimages[i].get_rect())
    if i == 0:
        levelrects[i].topleft = [185, 137]
    elif i == 1:
        levelrects[i].topleft = [555, 137]
    elif i == 2:
        levelrects[i].topleft = [925, 137]
    elif i == 3:
        levelrects[i].topleft = [185, 411]
    elif i == 4:
        levelrects[i].topleft = [555, 411]
    elif i == 5:
        levelrects[i].topleft = [925, 411]
    elif i == 6:
        levelrects[i].topleft = [185, 685]
    elif i == 7:
        levelrects[i].topleft = [555, 685]
    elif i == 8:
        levelrects[i].topleft = [925, 685]

def MoveButtons():
    if menupos:
        waveb.rect.centery = 100
        shop.rect.centery = 100
        move.rect.centery = 120
        exitshop.rect.centery = 120
        selltower.rect.centery = 90
        retarget.rect.centery = 40
    else:
        waveb.rect.centery = 850
        shop.rect.centery = 850
        move.rect.centery = 830
        exitshop.rect.centery = 830
        selltower.rect.centery = 910
        retarget.rect.centery = 860

class Passables():
    def __init__(self):
        self.health = 100
        self.highlightedtower = None
        self.htile = None
        self.hfield = None
        self.addcash = 0
        self.screen = "menu"
    def update(self):
        self.health = health
        self.highlightedtower = None
        self.htile = None
        self.hfield = None
        self.addcash = 0
        self.screen = screen
    def unpack(self):
        health = self.health

pa = Passables()

def loadmap(map_):
    global gmap, fields, enemies, towers, bullets, waveindex, wave, wavecycle, health, ctower, info, cfield, pa, cash, waves, wavestarted, gb, waveb
    map_ = str(map_)
    gmap, fields = map.loadmap(map_)
    enemies = pygame.sprite.Group()
    towers = pygame.sprite.Group()
    bullets = pygame.sprite.Group()
    waveindex = 0
    wave = -1
    waves = list(basewaves)
    wavecycle = waves[wave][waveindex]
    wavestarted = False
    health = 100
    cash = 150
    pa.update()
    ctower = None
    info = None
    cfield = None
    gb.add(waveb)

def highlighttower():
    global pa, window
    if pa.highlightedtower != None:
        ui.Font(24)
        render = ui.font.render(names[pa.highlightedtower.type], 1, w)
        rect = render.get_rect()
        if rect.width+rect.height+30 > 253:
            surface = pygame.surface.Surface([rect.width + rect.height + 30, rect.height + 48])
        else:
            surface = pygame.surface.Surface([253, rect.height + 48])
        surface.set_alpha(192)
        window.blit(surface, [mouse[0]+15, mouse[1]+15])
        window.blit(render, [mouse[0]+rect.height+35, mouse[1]+20])
        window.blit(pygame.transform.scale(pa.highlightedtower.image, [rect.height+10, rect.height+10]), [mouse[0]+20,mouse[1]+34])
        ui.Font(16)
        render = ui.font.render("target: " + str(pa.highlightedtower.targettype) + " - kills: " + str(pa.highlightedtower.kills), 1, w)
        window.blit(render, [mouse[0]+rect.height+35, mouse[1]+45])
        ui.Font(20)
        ui.color = [71, 221, 255]
        Text("left click for more info", [mouse[0]+rect.height+35, mouse[1]+63])
        h = rect.height+48
        if pa.hfield != None:
            ui.Font(24)
            ui.color = [255, 255, 255]
            render = ui.font.render(pa.hfield.type + " field", 1, w)
            rect = render.get_rect()
            if rect.width + 20 >= 188:
                ui.Box([rect.width + 20, 100], [mouse[0] + 15, mouse[1] + 20 + h])
            else:
                ui.Box([188, 100], [mouse[0] + 15, mouse[1] + 20 + h])
            window.blit(render, [mouse[0] + 25, mouse[1] + 23 + h])
            ui.Font(16)
            if pa.hfield.requirements_met():
                ui.color = [0, 255, 0]
                Text("currently active", [mouse[0] + 25, mouse[1] + 45 + h])
            else:
                ui.color = [255, 0, 0]
                Text("currently inactive", [mouse[0] + 25, mouse[1] + 45 + h])
            ui.color = [255, 255, 255]
            Text(str(pa.hfield.boost) + "x boost when active", [mouse[0] + 25, mouse[1] + 60 + h])
            ui.Font(20)
            ui.color = [71, 221, 255]
            Text("right click for", [mouse[0] + 25, mouse[1] + 78 + h])
            Text("more information", [mouse[0] + 25, mouse[1] + 95 + h])
    elif pa.hfield != None:
        ui.Font(24)
        ui.color = [255, 255, 255]
        render = ui.font.render(pa.hfield.type + " field", 1, w)
        rect = render.get_rect()
        if rect.width+20 >= 188:
            ui.Box([rect.width+20, 100], [mouse[0] + 10, mouse[1] + 20])
        else:
            ui.Box([188, 100], [mouse[0]+10, mouse[1]+20])
        window.blit(render, [mouse[0]+20, mouse[1]+23])
        ui.Font(16)
        if pa.hfield.requirements_met():
            ui.color = [0, 255, 0]
            Text("currently active", [mouse[0] + 20, mouse[1] + 45])
        else:
            ui.color = [255, 0, 0]
            Text("currently inactive", [mouse[0] + 20, mouse[1] + 45])
        ui.color = [255, 255, 255]
        Text(str(pa.hfield.boost)+"x boost when active", [mouse[0] + 20, mouse[1] + 60])
        ui.Font(20)
        ui.color = [71, 221, 255]
        Text("right click for", [mouse[0]+20, mouse[1]+78])
        Text("more information", [mouse[0] + 20, mouse[1] + 95])

def clicktoplace():
    global pa, window
    ui.Font(24)
    if cash < pricing[builds[buildindex]]:
        render = ui.font.render("you can't afford this!", 1, [255, 0, 0])
    elif pa.htile.occupied:
        render = ui.font.render("tile is occupied!", 1, [255, 0, 0])
    elif pa.htile.type.startswith("path"):
        render = ui.font.render("cannot place on a path!", 1, [255, 0, 0])
    else:
        ui.color = [255, 255, 255]
        render = ui.font.render("left click to place", 1, w)
    rect = render.get_rect()
    surface = pygame.surface.Surface([rect.width + 10, rect.height + 10])
    surface.set_alpha(192)
    window.blit(surface, [mouse[0] + 15, mouse[1] + 15])
    window.blit(render, [mouse[0] + 20, mouse[1] + 20])

def bidx(change):
    global buildindex, bimg, bigimg, radius, r
    buildindex += change
    if buildindex > len(builds) - 1:
        buildindex = 0
    elif buildindex < 0:
        buildindex = len(builds) - 1
    bimg = towerimages[builds[buildindex]]
    bigimg = pygame.transform.scale(bimg, [100, 100])
    bimg.set_alpha(192)
    radius = pygame.surface.Surface([objects.props[str(builds[buildindex])][1], objects.props[str(builds[buildindex])][1]])
    r = objects.props[str(builds[buildindex])][1]/2
    pygame.draw.circle(radius, [255,255,255], [r,r], r, 0)
    radius.set_colorkey([0,0,0])
    radius.set_alpha(128)

def DrawRadius():
    global ctower, window
    if cr == None:
        radius = pygame.surface.Surface([objects.props[ctower.type][1], objects.props[ctower.type][1]])
        r = objects.props[ctower.type][1] / 2
    else:
        radius = pygame.surface.Surface([cr, cr])
        r = cr/2
    pygame.draw.circle(radius, [255, 255, 255], [r, r], r, 0)
    radius.set_colorkey([0, 0, 0])
    radius.set_alpha(128)
    window.blit(radius, [ctower.rect.centerx-r, ctower.rect.centery-r])

def snaptogrid(c):
    coords = math.floor(c[0]/48), math.floor(c[1]/48)
    coords = coords[0]*48, coords[1]*48
    return coords

def cashbox():
    ui.Font(24)
    render = ui.font.render("cash: "+ str(cash), 1, w)
    rect = render.get_rect()
    dimensions = rect.width+10, rect.height
    surface = pygame.surface.Surface(dimensions)
    surface.set_alpha(192)
    if cash == 0:
        surface.fill([200, 0, 0])
    else:
        surface.fill([0,200,0])
    if menupos:
        window.blit(surface, [324, 106 + dimensions[1]])
        window.blit(render, [329, 107 + dimensions[1]])
    else:
        window.blit(surface, [324, 830-dimensions[1]])
        window.blit(render, [329, 831 - dimensions[1]])

while running:
    for event in pygame.event.get():
        if event.type == pygame.QUIT:
            running = False
        elif event.type == pygame.MOUSEMOTION:
            mouse = pygame.mouse.get_pos()
        elif event.type == pygame.MOUSEBUTTONDOWN:
            pressed = pygame.mouse.get_pressed()
            if pressed[0]: #left click
                if building and screen == "game":
                    if move.click(mouse):
                        menupos = not menupos
                        MoveButtons()
                        if menupos:
                            m = 820
                            ms = 840
                        else:
                            m = 0
                            ms = 0
                        sfx.play(sounds["select"])
                    elif exitshop.click(mouse) and building:
                        building = False
                        enablegrid = False
                        sfx.play(sounds["select"])
                    elif cash >= pricing[str(builds[buildindex])] and not pa.htile.type.startswith("path") and not pa.htile.occupied:
                        cash -= pricing[str(builds[buildindex])]
                        pos = snaptogrid(mouse)
                        t = objects.Tower(str(builds[buildindex]), [pos[0]+24, pos[1]+24])
                        towers.add(t)
                        gmap.update(pa, mouse, "occupy")
                        sfx.play(sounds["build"])
                elif not building and screen == "game":
                    if move.click(mouse):
                        menupos = not menupos
                        MoveButtons()
                        sfx.play(sounds["select"])
                        if menupos:
                            m = 820
                            ms = 840
                        else:
                            m = 0
                            ms = 0
                    elif waveb.click(mouse) and info == None:
                        if not wavestarted:
                            sfx.play(sounds["nextwave"])
                            wave += 1
                            wavestarted = True
                            spawning = True
                            waveindex = 0
                            wavecycle = waves[wave][waveindex]
                            pygame.time.set_timer(pygame.USEREVENT, wavecycle[2])
                            waveb.kill()
                            pygame.mixer.music.stop()
                            pygame.mixer.music.load("./audio/music/attackofthegoo.wav")
                            pygame.mixer.music.play(25)
                    elif shop.click(mouse) and not building and info == None:
                        bidx(0)
                        building = True
                        enablegrid = True
                        sfx.play(sounds["select"])
                    elif info == "tower" and not building and ctower != None:
                        if retarget.click(mouse):
                            sfx.play(sounds["select"])
                            if ctower.targettype == "close":
                                ctower.targettype = "strong"
                                ctower.target = None
                            elif ctower.targettype == "strong":
                                ctower.targettype = "close"
                                ctower.target = None
                            else:
                                ctower.targettype = "close"
                                ctower.target = None
                        elif selltower.click(mouse):
                            cash += pricing[ctower.type]/2
                            ctower.kill()
                            gmap.update(pa, mouse, "unoccupy", ctower.rect.center)
                            sfx.play(sounds["kill"])
                            ctower = None
                            info = None
                        elif not boxbottom.collidepoint(mouse) and not menupos:
                            info = None
                            ctower = None
                            cfield = None
                        elif not boxtop.collidepoint(mouse) and menupos:
                           info = None
                           ctower = None
                           cfield = None
                    elif pa.highlightedtower != None and not building:
                        info = "tower"
                        ctower = pa.highlightedtower
                        sfx.play(sounds["select"])
                    else:
                        info = None
                        ctower = None
                        cfield = None
                elif screen == "gameover":
                    if replay.click(mouse):
                        loadmap(currentmap)
                        screen = "game"
                        sfx.play(sounds["select"])
                    elif gotomenu.click(mouse):
                        currentmap = random.randint(1, 9)
                        loadmap(currentmap)
                        screen = "menu"
                        sfx.play(sounds["select"])
                elif screen == "levelcomplete":
                    if nextlevel.click(mouse) and not currentmap+1 > maxmaps:
                        currentmap += 1
                        loadmap(currentmap)
                        screen = "game"
                        sfx.play(sounds["select"])
                    if replay.click(mouse):
                        loadmap(currentmap)
                        screen = "game"
                        sfx.play(sounds["select"])
                    elif gotomenu.click(mouse):
                        currentmap = random.randint(1, 9)
                        loadmap(currentmap)
                        screen = "menu"
                        sfx.play(sounds["select"])
                elif screen == "pause":
                    if resume.click(mouse):
                        screen = "game"
                        pygame.mixer.music.unpause()
                        sfx.play(sounds["select"])
                    if howtoplayb.click(mouse):
                        lastscreen = "pause"
                        screen = "howtoplay"
                        htp = "select"
                        sfx.play(sounds["select"])
                    if settingsb.click(mouse):
                        lastscreen = "pause"
                        screen = "settings"
                        sfx.play(sounds["select"])
                    if gotomenu.click(mouse):
                        loadmap(random.randint(1, 9))
                        screen = "menu"
                        sfx.play(sounds["select"])
                elif screen == "settings":
                    if back.click(mouse):
                        screen = lastscreen
                        sfx.play(sounds["select"])
                    elif fullscreenb.click(mouse):
                        settings["fullscreen"] = not settings["fullscreen"]
                        if settings["fullscreen"]:
                            pygame.display.set_mode([1296, 960], pygame.FULLSCREEN)
                        else:
                            pygame.display.set_mode([1296, 960])
                    elif muteaudio.click(mouse):
                        settings["muteaudio"] = not settings["muteaudio"]
                        if settings["muteaudio"]:
                            sfx.set_volume(0)
                        else:
                            sfx.set_volume(1)
                        sfx.play(sounds["select"])
                    elif mutesettings.click(mouse):
                        settings["mutemusic"] = not settings["mutemusic"]
                        if settings["mutemusic"]:
                            pygame.mixer.music.set_volume(0)
                        else:
                            pygame.mixer.music.set_volume(1)
                        sfx.play(sounds["select"])
                    elif hotkeys.click(mouse):
                        settings["hotkeys"] = not settings["hotkeys"]
                        sfx.play(sounds["select"])
                elif screen == "howtoplay":
                    if back.click(mouse):
                        if htp == "select":
                            screen = lastscreen
                        else:
                            htp = "select"
                        sfx.play(sounds["select"])
                    elif gotg.click(mouse) and htp == "select":
                        htp = "gotg"
                        sfx.play(sounds["select"])
                    elif controls.click(mouse) and htp == "select":
                        htp = "controls"
                        sfx.play(sounds["select"])
                    elif towersb.click(mouse) and htp == "select":
                        htp = "towers"
                        sfx.play(sounds["select"])
                    elif fieldsb.click(mouse) and htp == "select":
                        htp = "fields"
                        sfx.play(sounds["select"])
                    elif enemiesb.click(mouse) and htp == "select":
                        htp = "enemies"
                        sfx.play(sounds["select"])
                    elif gameplay.click(mouse) and htp == "select":
                        htp = "gameplay"
                        sfx.play(sounds["select"])
                elif screen == "menu":
                    if playbutton.click(mouse):
                        screen = "levelselect"
                        sfx.play(sounds["select"])
                    elif howtoplayb.click(mouse):
                        screen = "howtoplay"
                        htp = "select"
                        lastscreen = "menu"
                        sfx.play(sounds["select"])
                    elif settingsb.click(mouse):
                        screen = "settings"
                        lastscreen = "menu"
                        sfx.play(sounds["select"])
                    elif exitbutton.click(mouse):
                        running = False
                elif screen == "levelselect":
                    if back.click(mouse):
                        screen = "menu"
                        sfx.play(sounds["select"])
                        currentmap = random.randint(1, 9)
                        loadmap(currentmap)
                    elif levelrects[0].collidepoint(mouse):
                        screen = "game"
                        currentmap = 1
                        loadmap(currentmap)
                        sfx.play(sounds["select"])
                    elif levelrects[1].collidepoint(mouse):
                        screen = "game"
                        currentmap = 2
                        loadmap(currentmap)
                        sfx.play(sounds["select"])
                    elif levelrects[2].collidepoint(mouse):
                        screen = "game"
                        currentmap = 3
                        loadmap(currentmap)
                        sfx.play(sounds["select"])
                    elif levelrects[3].collidepoint(mouse):
                        screen = "game"
                        currentmap = 4
                        loadmap(currentmap)
                        sfx.play(sounds["select"])
                    elif levelrects[4].collidepoint(mouse):
                        screen = "game"
                        currentmap = 5
                        loadmap(currentmap)
                        sfx.play(sounds["select"])
                    elif levelrects[5].collidepoint(mouse):
                        screen = "game"
                        currentmap = 6
                        loadmap(currentmap)
                        sfx.play(sounds["select"])
                    elif levelrects[6].collidepoint(mouse):
                        screen = "game"
                        currentmap = 7
                        loadmap(currentmap)
                        sfx.play(sounds["select"])
                    elif levelrects[7].collidepoint(mouse):
                        screen = "game"
                        currentmap = 8
                        loadmap(currentmap)
                        sfx.play(sounds["select"])
                    elif levelrects[8].collidepoint(mouse):
                        screen = "game"
                        currentmap = 9
                        loadmap(currentmap)
                        sfx.play(sounds["select"])
            elif pressed[2]:
                if not building and screen == "game":
                    if pa.hfield != None:
                        info = "field"
                        cfield = pa.hfield
                        sfx.play(sounds["select"])
            elif event.button == 4: #scroll up
                if building and screen == "game":
                    bidx(1)
                    sfx.play(sounds["select"])
            elif event.button == 5: #scroll down
                if building and screen == "game":
                    bidx(-1)
                    sfx.play(sounds["select"])
        elif event.type == pygame.KEYDOWN:
            if screen == "pause":
                if event.key == pygame.K_ESCAPE:
                    screen = "game"
                    sfx.play(sounds["select"])
                    pygame.mixer.music.unpause()
            elif screen == "game":
                if event.key == pygame.K_ESCAPE:
                    screen = "pause"
                    sfx.play(sounds["select"])
                    pygame.mixer.music.pause()
                elif event.key == pygame.K_m and settings["hotkeys"]:
                    menupos = not menupos
                    MoveButtons()
                    if menupos:
                        m = 820
                        ms = 840
                    else:
                        m = 0
                        ms = 0
                    sfx.play(sounds["select"])
                elif event.key == pygame.K_g and settings["hotkeys"]:
                    if screen == "game" and not building:
                        enablegrid = not enablegrid
                        sfx.play(sounds["select"])
                elif event.key == pygame.K_w and settings["hotkeys"]:
                    if screen == "game":
                        if not wavestarted:
                            sfx.play(sounds["nextwave"])
                            wave += 1
                            if wave > len(waves)-1:
                                screen = "levelcomplete"
                            else:
                                wavestarted = True
                                spawning = True
                                waveindex = 0
                                wavecycle = waves[wave][waveindex]
                                pygame.time.set_timer(pygame.USEREVENT, wavecycle[2])
                                waveb.kill()
                                pygame.mixer.music.stop()
                                pygame.mixer.music.load("./audio/music/attackofthegoo.wav")
                                pygame.mixer.music.play(25)
                elif event.key == pygame.K_b and settings["hotkeys"]:
                    if screen == "game":
                        sfx.play(sounds["select"])
                        building = not building
                        if building:
                            enablegrid = True
                            bidx(0)
                        else:
                            enablegrid = False
            if event.key == pygame.K_F11:
                settings["fullscreen"] = not settings["fullscreen"]
                if settings["fullscreen"]:
                    window = pygame.display.set_mode([1296, 960], pygame.FULLSCREEN)
                else:
                    window = pygame.display.set_mode([1296, 960])
                    pygame.display.set_caption("Attack of the Goo")
        elif event.type == pygame.USEREVENT:
            if wavestarted and screen == "game" and spawning:
                #this is really inefficient but for whatever reason it's the only way that works w/the paths
                if currentmap == 1:
                    e = entities.Enemy(wavecycle[0], [-48/48, 192/48], [[336/48 , 192/48], [336/48, 480/48], [528/48, 480/48], [528/48, 720/48], [720/48, 720/48], [720/48, 240/48], [1344/48, 240/48]])
                elif currentmap == 2:
                    e = entities.Enemy(wavecycle[0], [-48/48, 96/48],
                                       [[1200/48, 96/48], [1200/48, 288/48], [96/48, 288/48], [96/48, 480/48], [1200/48, 480/48], [1200/48, 672/48], [96/48, 672/48], [96/486, 864/48], [1344/48, 864/48]])
                elif currentmap == 3:
                    e = entities.Enemy(wavecycle[0], [-1, 10], [[5, 10], [5, 3], [24, 3], [24, 15], [13, 15], [13, 21]])
                elif currentmap == 4:
                    e = entities.Enemy(wavecycle[0], [-1, 5], [[3, 5], [3, 3], [7, 3], [7, 5], [11, 5], [11, 3], [15, 3], [15, 5], [19, 5], [19, 3], [23, 3], [23, 17], [19, 17], [19, 15], [15, 15], [15, 17], [11, 17], [11, 15], [7, 15], [7, 17], [3, 17], [3, 15] , [-1, 15]])
                elif currentmap == 5:
                    e = entities.Enemy(wavecycle[0], [-1, 3], [[11, 3], [11, 9], [3, 9], [3, 17], [24, 17], [24, 9], [16, 9], [16, 3], [28, 3]])
                elif currentmap == 6:
                    e = entities.Enemy(wavecycle[0], [-1, 3], [[5, 3], [5, 17], [11, 17], [11, 3], [16, 3], [16, 17], [22, 17], [22, 3], [28, 3]])
                elif currentmap == 7:
                    e = entities.Enemy(wavecycle[0], [-1, 6], [[7, 6], [7, 3], [24, 3], [24, 17], [7, 17], [7, 14], [-1, 14]])
                elif currentmap == 8:
                    e = entities.Enemy(wavecycle[0], [-1, 3], [[3, 3], [3, 5], [7, 5], [7, 7], [11, 7], [11, 9], [16, 9], [16, 11], [20, 11], [20, 13], [24, 13], [24, 15], [28, 15]])
                elif currentmap == 9:
                    e = entities.Enemy(wavecycle[0], [-1, 7], [[5, 7], [5, 3], [24, 3], [24, 8], [11, 8], [11, 12], [24, 12], [24, 17], [11, 17], [11, 21]])
                enemies.add(e)
                wavecycle[1] -= 1
                if wavecycle[1] <= 0:
                    waveindex += 1
                    if waveindex > len(waves[wave]) - 1:
                        spawning = False
                    else:
                        wavecycle = waves[wave][waveindex]
                        pygame.time.set_timer(pygame.USEREVENT, wavecycle[2])
                else:
                    pygame.time.set_timer(pygame.USEREVENT, wavecycle[2])
            elif screen == "menu":
                if currentmap == 1:
                    e = entities.Enemy(random.choice(["goo", "cube", "skater", "jetpack", "mini", "giant"]), [-48/48, 192/48], [[336/48 , 192/48], [336/48, 480/48], [528/48, 480/48], [528/48, 720/48], [720/48, 720/48], [720/48, 240/48], [1344/48, 240/48]])
                elif currentmap == 2:
                    e = entities.Enemy(random.choice(["goo", "cube", "skater", "jetpack", "mini", "giant"]), [-48/48, 96/48],
                                       [[1200/48, 96/48], [1200/48, 288/48], [96/48, 288/48], [96/48, 480/48], [1200/48, 480/48], [1200/48, 672/48], [96/48, 672/48], [96/486, 864/48], [1344/48, 864/48]])
                elif currentmap == 3:
                    e = entities.Enemy(random.choice(["goo", "cube", "skater", "jetpack", "mini", "giant"]), [-1, 10], [[5, 10], [5, 3], [24, 3], [24, 15], [13, 15], [13, 21]])
                elif currentmap == 4:
                    e = entities.Enemy(random.choice(["goo", "cube", "skater", "jetpack", "mini", "giant"]), [-1, 5], [[3, 5], [3, 3], [7, 3], [7, 5], [11, 5], [11, 3], [15, 3], [15, 5], [19, 5], [19, 3], [23, 3], [23, 17], [19, 17], [19, 15], [15, 15], [15, 17], [11, 17], [11, 15], [7, 15], [7, 17], [3, 17], [3, 15] , [-1, 15]])
                elif currentmap == 5:
                    e = entities.Enemy(random.choice(["goo", "cube", "skater", "jetpack", "mini", "giant"]), [-1, 3], [[11, 3], [11, 9], [3, 9], [3, 17], [24, 17], [24, 9], [16, 9], [16, 3], [28, 3]])
                elif currentmap == 6:
                    e = entities.Enemy(random.choice(["goo", "cube", "skater", "jetpack", "mini", "giant"]), [-1, 3], [[5, 3], [5, 17], [11, 17], [11, 3], [16, 3], [16, 17], [22, 17], [22, 3], [28, 3]])
                elif currentmap == 7:
                    e = entities.Enemy(random.choice(["goo", "cube", "skater", "jetpack", "mini", "giant"]), [-1, 6], [[7, 6], [7, 3], [24, 3], [24, 17], [7, 17], [7, 14], [-1, 14]])
                elif currentmap == 8:
                    e = entities.Enemy(random.choice(["goo", "cube", "skater", "jetpack", "mini", "giant"]), [-1, 3], [[3, 3], [3, 5], [7, 5], [7, 7], [11, 7], [11, 9], [16, 9], [16, 11], [20, 11], [20, 13], [24, 13], [24, 15], [28, 15]])
                elif currentmap == 9:
                    e = entities.Enemy(random.choice(["goo", "cube", "skater", "jetpack", "mini", "giant"]), [-1, 7], [[5, 7], [5, 3], [24, 3], [24, 8], [11, 8], [11, 12], [24, 12], [24, 17], [11, 17], [11, 21]])
                enemies.add(e)
                pygame.time.set_timer(pygame.USEREVENT, 1000)
    if screen == "game":
        if not pygame.mixer.music.get_busy():
            if wavestarted:
                pygame.mixer.music.load("./audio/music/attackofthegoo.wav")
                pygame.mixer.music.play(25)
            else:
                pygame.mixer.music.load("./audio/music/menu.wav")
                pygame.mixer.music.play(25)
        pa.update()

        ui.color = [0,0,0]
        window.fill(w)
        gmap.draw(window)
        if enablegrid:
            window.blit(grid, [0, 0])
        if ctower != None and info == "tower":
            DrawRadius()
        bullets.draw(window)
        towers.draw(window)
        fields.draw(window)
        enemies.draw(window)

        bullets.update(enemies, pa, sounds, sfx)
        enemies.update(pa, fps, sounds, sfx)
        if pa.health != health:
            health = pa.health
        fields.update(pa, mouse, towers, window, clock, enemies, bullets, fields, sounds, sfx)
        if not ctower == None and info == "tower":
            cr = ctower.props[1]
        else:
            cr = None
        towers.update(pa, mouse, clock, enemies, bullets, fields, sounds, sfx)
        gb.update(mouse)

        if pa.addcash > 0:
            cash += pa.addcash
            pa.addcash = 0
        if not spawning and wavestarted and waveindex > len(waves[wave]) - 2:
            if len(enemies) == 0:
                wavestarted = False
                gb.add(waveb)
                cash += 50
                pygame.mixer.music.stop()
                pygame.mixer.music.load("./audio/music/menu.wav")
                pygame.mixer.music.play()
        cash = int(round(cash))

        if pa.highlightedtower != None or pa.hfield != None:
            if not building:
                highlighttower()
        if building:
            ctower = None
            info = None
            gmap.update(pa, mouse)
            clicktoplace()
            window.blit(radius, [snaptogrid(mouse)[0]+24-r, snaptogrid(mouse)[1]+24-r])
            window.blit(bimg, snaptogrid(mouse))
            ui.Box([648, 120], [648, 890-m], True)
            if builds[buildindex].startswith("f"):
                ui.color = [216, 60, 0]
            elif builds[buildindex].startswith("w"):
                ui.color = [15, 110, 192]
            else:
                ui.color = [255, 255, 255]
            ui.Font(32)
            tr = TextR(str(names[builds[buildindex]])+"", [444, 855-ms])
            move.draw()
            exitshop.update(mouse)
            exitshop.draw()
            cashbox()
            window.blit(bigimg, [334, 840-m])
            if pricing[builds[buildindex]] > cash:
                ui.color = [255, 0, 0]
            else:
                ui.color = [0, 255, 0]
            ui.Font(24)
            tr1 = TextR("costs "+str(pricing[builds[buildindex]])+" cash ", [444, 885-ms])
            firerate = round((1000/objects.props[builds[buildindex]][0])*100)/100
            ui.color = [255, 255, 255]
            ui.Font(15)
            if len(builds[buildindex]) == 2:
                Text("[" + str(reqstrs[builds[buildindex][0]]) + " / " + str(reqstrs[builds[buildindex][1]]) + "]", [444 + tr1.width, 888-ms])
            else:
                Text("[" + str(reqstrs[builds[buildindex][0]]) + " / " + str(reqstrs[builds[buildindex][1:len(builds[buildindex])]]) + "]", [444+tr1.width, 888-ms])
            ui.Font(20)
            Text(str(firerate)+" shots/sec", [495+48, 935-ms],True)
            rng = round((objects.props[builds[buildindex]][1]/48)*100)/100
            Text(str(rng) + " tiles", [666+48, 935-ms],True)
            damage = objects.props[builds[buildindex]][2]
            Text(str(damage)+" hp", [837+48, 935-ms],True)
            ui.Font(15)
            Text("rate of fire", [495 + 48, 918-ms], True)
            Text("range", [666 + 48, 918-ms], True)
            Text("damage", [837 + 48, 918-ms], True)
        elif info == "tower":
            ui.Box([648, 120], [648, 890-m], True)
            move.draw()
            window.blit(pygame.transform.scale(ctower.image, [100, 100]), [334, 840-m])
            ui.color = [255, 255, 255]
            ui.Font(32)
            Text(str(names[ctower.type]), [444, 855-ms])
            ui.Font(22)
            Text("target: " + str(ctower.targettype), [444, 890-ms])
            Text("kills: " + str(ctower.kills), [444, 910-ms])
            selltower.update(mouse)
            selltower.draw()
            retarget.update(mouse)
            retarget.draw()
        elif info == "field":
            ui.Box([648, 120], [648, 890-m], True)
            move.draw()
            ui.Font(28)
            ui.color = [255, 255, 255]
            tr = TextR(str(cfield.type)+" field - " + str(cfield.boost) + "x boost ", [334, 855-ms])
            if cfield.requirements_met():
                ui.color = [0, 255, 0]
                Text("[active]", [tr.width+334, 855-ms])
            else:
                ui.color = [255, 0, 0]
                Text("[inactive]", [tr.width+334, 855-ms])
            ui.Font(16)
            ui.color = [255, 255, 255]
            Text("to get this boost, you need to have the following inside the field:", [334, 880-ms])
            brs = ""
            for i in cfield.oreq.keys():
                brs = str(brs) + str(cfield.oreq[i]) + "x " + str(reqstrs[i])
                if cfield.oreq[i] > 1:
                    brs = str(brs) + "s"
                if len(cfield.oreq.keys()) > 1:
                    brs = str(brs) + ", "
            if brs.endswith(","):
                brs = brs[0:len(brs)-2]
            ui.Font(14)
            Text(brs, [334, 895-ms])
            ui.Font(16)
            ui.color = [255, 255, 255]
            Text("currently, you have the following inside the field:", [334, 914-ms])
            mrs = ""
            for i in cfield.requirements.keys():
                mrs = str(mrs) + str(int(cfield.oreq[i] - cfield.requirements[i])) + "x " + str(reqstrs[i])
                if int(cfield.oreq[i] - cfield.requirements[i]) > 1 or int(cfield.oreq[i] - cfield.requirements[i]) == 0:
                    mrs = str(mrs) + "s"
                if len(cfield.requirements.keys()) > 1:
                    mrs = str(mrs) + ", "
            if mrs.endswith(","):
                mrs = mrs[0:len(mrs) - 2]
            ui.Font(14)
            Text(mrs, [334, 928-ms])
        else:
            ui.Box([648, 120], [648, 890-m], True)
            ui.color = [255, 255, 255]
            gb.draw(window)
            ui.Font(24)
            Text("cash: "+str(cash), [436, 905-ms], True)
            ui.color = [255-(255*(health/100)), 255*(health/100), 0]
            if ui.color[0] < 0 or ui.color[0] > 255:
                ui.color = [255, 255, 255]
            elif ui.color[1] < 0 or ui.color[1] > 255:
                ui.color = [255, 255, 255]
            Text("health: " + str(math.floor(health)), [853, 905-ms], True)
            ui.color = [255, 255, 255]
            if not wavestarted:
                Text("wave " + str(wave + 2), [648, 890-ms], True)
                ui.Font(12)
                Text("(not started)", [648, 910-ms], True)
            else:
                ui.Font(32)
                Text("wave " + str(wave + 1), [648, 905-ms], True)
                ui.color = [200, 200, 200]
                ui.Font(28)
                if menupos:
                    Text("wave started", [436, 110], True)
                else:
                    Text("wave started", [436, 856], True)
                ui.Font(32)
                ui.color = [255, 255, 255]

        if health <= 0:
            screen = "gameover"
            replay.rect.centerx, replay.rect.centery = [648, 400]
            gotomenu.rect.centerx, gotomenu.rect.centery = [648, 560]
            pygame.mixer.music.stop()
            sfx.play(sounds["gameover"])
            pygame.mixer.music.fadeout(500)
        elif wave > 40 and len(enemies) == 0:
            screen = "levelcomplete"
            nextlevel.rect.centerx, nextlevel.rect.centery = [648, 360]
            replay.rect.centerx, replay.rect.centery = [648, 480]
            gotomenu.rect.centerx, gotomenu.rect.centery = [648, 600]
            pygame.mixer.music.fadeout(500)
    elif screen == "menu":
        window.fill(w)
        gmap.draw(window)
        bullets.draw(window)
        towers.draw(window)
        sfx.set_volume(0)
        enemies.update(pa, fps, sounds, sfx)
        if not settings["muteaudio"]:
            sfx.set_volume(1)
        enemies.draw(window)
        ui.Box([324, 480], [648, 480], True)
        ui.color = [255, 255, 255]
        ui.Font(32)
        window.blit(logo, [525, 245])
        menubuttons.update(mouse)
        menubuttons.draw(window)
        exitbutton.update(mouse)
        exitbutton.draw()
        playbutton.update(mouse)
        playbutton.draw()
    elif screen == "levelselect":
        window.fill(w)
        gmap.draw(window)
        ui.Box([1286, 950], [5, 5], False)
        for i in range(9):
            window.blit(levelimages[i], levelrects[i].topleft)
        ui.color = [255, 255, 255]
        ui.Font(60)
        Text("select map", [648, 35], True)
        back.update(mouse)
        back.draw()
        ui.Font(24)
        Text("map 1", [277, 304], True)
        Text("map 2", [647, 304], True)
        Text("map 3", [1017, 304], True)
        Text("map 4", [277, 578], True)
        Text("map 5", [647, 578], True)
        Text("map 6", [1017, 578], True)
        Text("map 7", [277, 852], True)
        Text("map 8", [647, 852], True)
        Text("map 9", [1017, 852], True)
    elif screen == "gameover":
        ui.color = [0, 0, 0]
        window.fill(w)
        gmap.draw(window)
        bullets.draw(window)
        towers.draw(window)
        fields.draw(window)
        enemies.draw(window)
        ui.Box([324, 480], [648, 480], True)
        ui.color = [255, 0, 0]
        ui.Font(48)
        Text("game over!", [648, 270], True)
        gotomenu.update(mouse)
        gotomenu.draw()
        replay.update(mouse)
        replay.draw()
    elif screen == "levelcomplete":
        ui.color = [0, 0, 0]
        window.fill(w)
        gmap.draw(window)
        bullets.draw(window)
        towers.draw(window)
        fields.draw(window)
        enemies.draw(window)
        ui.color = [255, 255, 255]
        ui.Box([324, 480], [648, 480], True)
        ui.Font(40)
        Text("level complete!", [648, 270], True)
        if not currentmap+1 > maxmaps:
            nextlevel.update(mouse)
            nextlevel.draw()
        gotomenu.update(mouse)
        gotomenu.draw()
        replay.update(mouse)
        replay.draw()
    elif screen == "pause":
        ui.color = [0, 0, 0]
        window.fill(w)
        gmap.draw(window)
        bullets.draw(window)
        towers.draw(window)
        fields.draw(window)
        enemies.draw(window)
        ui.color = [255, 255, 255]
        ui.Box([324, 480], [648, 480], True)
        ui.Font(48)
        Text("paused", [648, 270], True)
        resume.update(mouse)
        gotomenu.update(mouse)
        menubuttons.update(mouse)
        menubuttons.draw(window)
        resume.draw()
        gotomenu.draw()
    elif screen == "howtoplay":
        ui.color = [0, 0, 0]
        window.fill(w)
        gmap.draw(window)
        bullets.draw(window)
        towers.draw(window)
        if lastscreen == "pause":
            fields.draw(window)
        enemies.draw(window)
        ui.color = [255, 255, 255]
        ui.Box([1286, 950], [5, 5])
        ui.Font(60)
        hb.update(mouse)
        if htp == "select":
            Text("how to play", [648, 35], True)
            ui.Font(32)
            Text("click on a topic below to learn more about it.", [15, 80])
            hb.draw(window)
        else:
            window.blit(howtoplay[str(htp)], [15,0])
        back.update(mouse)
        back.draw()
    elif screen == "settings":
        ui.color = [0, 0, 0]
        window.fill(w)
        gmap.draw(window)
        bullets.draw(window)
        towers.draw(window)
        if lastscreen == "pause":
            fields.draw(window)
        enemies.draw(window)
        ui.color = [255, 255, 255]
        ui.Box([1286, 950], [5, 5])
        ui.Font(60)
        Text("settings", [648, 35], True)
        back.update(mouse)
        back.draw()
        sb.update(mouse)
        sb.draw(window)
        ui.Font(48)
        tr = TextR("sound effects: ", [170, 105]).width
        if settings["muteaudio"]:
            ui.color = [255, 0, 0]
            Text("[muted]", [170+tr, 105])
        else:
            ui.color = [0, 255, 0]
            Text("[enabled]", [170 + tr, 105])
        ui.color = [255, 255, 255]
        tr = TextR("music: ", [170, 185]).width
        if settings["mutemusic"]:
            ui.color = [255, 0, 0]
            Text("[muted]", [170 + tr, 185])
        else:
            ui.color = [0, 255, 0]
            Text("[enabled]", [170 + tr, 185])
        ui.color = [255, 255, 255]
        tr = TextR("hotkeys: ", [170, 265]).width
        if not settings["hotkeys"]:
            ui.color = [255, 0, 0]
            Text("[disabled]", [170 + tr, 265])
        else:
            ui.color = [0, 255, 0]
            Text("[enabled]", [170 + tr, 265])
        ui.color = [255, 255, 255]
        tr = TextR("fullscreen mode: ", [170, 345]).width
        if not settings["fullscreen"]:
            ui.color = [255, 0, 0]
            Text("[disabled]", [170 + tr, 345])
        else:
            ui.color = [0, 255, 0]
            Text("[enabled]", [170 + tr, 345])
    pygame.display.flip()
    clock.tick(60)
    fps = clock.get_fps()
    pa.screen = screen
pygame.quit()