如何在图像旁边的我的cookie点击器游戏流程中进行升级?

时间:2018-04-16 12:16:55

标签: html css

所以,我正在制作一个cookie点击器,我希望我的升级能够放在我的cookie旁边,这个cookie位于中心位置。如何让我的升级继续进行并让cookie仍然居中?如果可以的话,它看起来会好得多。如果您有任何想法,请快速回复。

帮助将不胜感激! :^)

<script>
        function update() {
            document.getElementById('text').value = cookiecount;
            document.title = cookiecount + " Cookies";

            document.getElementById('ammountMultiplier').innerHTML = "Multiplier Upgrade x" + (multiplier+1);
            document.getElementById('ammountMultiplier2').innerHTML = "x" + (multiplier+1);
            document.getElementById('costMultiplier').innerHTML = ((multiplier+1) * 100) + " Cookies";
            document.getElementById('currentMultiplier').innerHTML = "Your current Multiplier is x" + (multiplier);

            document.getElementById('ammountAutoClick').innerHTML = "You Own " + autoClick + " Auto Clickers";
            document.getElementById('costAutoClick').innerHTML = ((autoClick+1) * 12) + " Cookies";

            document.getElementById('ammountFarms').innerHTML = "You Own " + farms + " Farms";
            document.getElementById('costFarms').innerHTML = ((farms+1) * 15) + " Cookies";

        document.getElementById('ammountGrandma').innerHTML = "You Own " + grandma +" Grandmas";
        document.getElementById('costGrandma').innerHTML = ((grandma+1) * 15) + "Cookies";  

            document.getElementById('cookiespersecond').innerHTML = "You are gaining " + (((autoClick)+(farms*2)+(grandma*2))*multiplier) + " Cookies per/s";
        }

        var multiplier = 1;
        var cookiecount = 0;
        var autoClick = 0;
        var farms = 0;
        var grandma = 0;
        function timer() {
            cookiecount = cookiecount + autoClick*multiplier;
            cookiecount = cookiecount + farms*2*multiplier;
            cookiecount = cookiecount + grandma*2*multiplier;
        update()
        }
        setInterval(timer, 1000)
    </script>
    <html>

    <style>
    body{
        background-image: url('http://pa1.narvii.com/6718/86e6473ccdc4cfefcb427d96def5cf6917d481f4_00.gif');
        background-size: cover;
    }
    </style>
    <center>
    <head><title>0 Cookies</title></head>
    <body>

        <p id="cookiespersecond">You are gaining 0 Cookies per/s</p>

        <a href=# onclick="add()"><img src="cookie.jpg"></a>

        <br><br>
        You got:
        <input type="text" id="text" disabled style= text-align:center value=0>
        <script>
        function add() {
            cookiecount = cookiecount + 1
            update()
        }
        </script>
         Cookies
        <br><br></center>

        <button><a href="#" onClick="save()">Save</a></button>
        <button><a href="#" onclick="load()">Load</a></button>
        <br><br>

        <p id="ammountMultiplier">Multiplier Upgrade x2</p>
        <button><a href="#" onClick="buyMultiplier()"><span id="ammountMultiplier2">x2</span></a></button>
        <p id="costMultiplier">200 Cookies</p>
        <p id="currentMultiplier">Your current Multiplier is x1</p>
        <br>

        <p>Buy 1 Auto Clicker</p>
        <button><a href="#" onClick="buyAutoClick()"><img src=mouse.jpg width="30px" height="40px"></a></button>
        <p id="costAutoClick">12 Cookies</p>
        <p id="ammountAutoClick">You Own 0 Auto Clickers</p>

        <br>

        <p>Buy 1 Farm</p>
        <button><a href="#" onClick="buyFarm()"><img src="farm.jpg" width="50px" height="50px"></a></button>
        <p id="costFarms">15 Cookies</p>
        <p id="ammountFarms">You Own 0 Farms</p>


        <br>

        <p>Buy 1 Grandma</p>
        <button><a href="#" onClick="buyGrandma()"><img src="grandma.jpg" width="50px" height="50px"></a></button>
        <p id="costGrandma">15 Cookies</p>
        <p id="ammountGrandma">You own 0 Grandmas</p>



        <script>
        function save() {
            localStorage.setItem("cookiecount", cookiecount);
            localStorage.setItem("autoClick", autoClick);
            localStorage.setItem("farms", farms);
            localStorage.setItem("multiplier", multiplier);
        }
        function load() {
            cookiecount = localStorage.getItem("cookiecount");
            cookiecount = parseInt(cookiecount);
            autoClick = localStorage.getItem("autoClick");
            autoClick = parseInt(autoClick);
            farms = localStorage.getItem("farms");
            farms = parseInt(farms);
            multiplier = localStorage.getItem("multiplier");
            multiplier = parseInt(multiplier);        

        update()
        }

        function buyAutoClick() {
            if (cookiecount >= ((autoClick+1) * 12)) {
                cookiecount = cookiecount - ((autoClick+1) * 12);
                autoClick = autoClick + 1;
                update()
            }
        }

        function buyFarm() {
            if (cookiecount >= ((farms+1) * 15)) {
                cookiecount = cookiecount - ((farms+1) * 15);
                farms = farms + 1;
                update()
            }
        }

        function buyMultiplier() {
            if (cookiecount >= ((multiplier+1) * 100)) {
                cookiecount = cookiecount - ((multiplier+1) * 50);
                multiplier = multiplier + 1;
                update()
            }
        }
        function buyGrandma() {
        if (cookiecount >= ((grandma+1) * 15)) {
        cookiecount = cookiecount - ((grandma+1) * 15);
        grandma = grandma + 1;
        update()
        }
        }





    </script>

    </html>

请帮忙!

0 个答案:

没有答案