Tvick22 / platformer3x

Student repository for Trimester 3, Spring 2024. (Leaderboard Team)
https://tvick22.github.io/platformer3x/
Apache License 2.0
0 stars 0 forks source link

SettingsControl dim completed #45

Closed andrewzcsse closed 1 month ago

andrewzcsse commented 1 month ago

Adding the Dim

const backgroundDim = {
    create () {
        this.dim = true // sets the dim to be true when settingControl is opened
        console.log("CREATE DIM")
        const dimDiv = document.createElement("div");
        dimDiv.id = "dim";
        dimDiv.style.backgroundColor = "black";
        dimDiv.style.width = "100%";
        dimDiv.style.height = "100%";
        dimDiv.style.position = "absolute";
        dimDiv.style.opacity = "0.8";
        document.body.append(dimDiv);
        dimDiv.style.zIndex = "9998"
        dimDiv.addEventListener("click", this.remove)
    },
    remove () {
        this.dim = false
        console.log("REMOVE DIM");
        const dimDiv = document.getElementById("dim");
        dimDiv.remove();
        isOpen = false
        const sidebar = document.getElementById("sidebar")
        sidebar.style.width = isOpen?"70%":"0px";
        sidebar.style.top = isOpen?"15%":"0px";
        sidebar.style.left = isOpen?"15%":"0px";
    }
}
<div id="sidebar" class="sidebar" style="z-index: 9999">
 isOpen = true;
            // open and close properties for sidebar based on isOpen
            backgroundDim.create()
            var sidebar = document.querySelector('.sidebar');
            sidebar.style.width = isOpen?"200px":"0px";
            sidebar.style.paddingLeft = isOpen?"10px":"0px";
            sidebar.style.paddingRight = isOpen?"10px":"0px";
            sidebar.style.top = `calc(${submenuHeight}px + ${GameEnv.top}px)`;

Screenshot 2024-05-16 2 05 40 PM

andrewzcsse commented 1 month ago

Merging 5/17 so we can present on this during team teach