Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE html>
- <html>
- <head>
- <link rel="stylesheet" href="style.css" />
- <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
- <title>Clicker!</title>
- </head>
- <body>
- <h3 id="head1"><span id="Aliens">0</span> aliens</h3>
- <h3 id="head2"><span id="Empires">0</span> empires</h3>
- <h3 id="head3"><span id="Spaceships">0</span> spaceships</h3>
- <h3 id="head4"><span id="Planets">0</span> planets</h3>
- <h3 id="head5"><span id="SolarSystems">0</span> solarsystems</h3>
- <h3 id="head6"><span id="Galaxies">0</span> galaxies</h3>
- <h3 id="head7"><span id="Workers">0</span> workers</h3>
- <!--<p>You need <span id="test">0</span> aliens to hire a worker!</p>--> <!--Need to make dynamic-->
- <img id="Alien" src="alien.png">
- <img id="whirl" src="galaxy.jpg" style="width:25em; height:25em;">
- <button id="Purchase">Hire Workers</button>
- </body>
- <script>
- $(function() {
- $('#Alien').click(function() {
- incrementCounter();
- });
- function incrementCounter() {
- var previousCounter = parseInt($("#Aliens").text());
- previousCounter = isNaN(previousCounter) ? 0: ++previousCounter;
- $("#Aliens").text(previousCounter);
- if(previousCounter % 25 === 0) {
- $("#Empires").text(previousCounter/25);
- }
- if(previousCounter % 100 === 0) {
- $("#Spaceships").text(previousCounter/100);
- }
- if(previousCounter % 1000 === 0) {
- $("#Planets").text(previousCounter/1000);
- }
- if(previousCounter % 10000 === 0) {
- $("#SolarSystems").text(previousCounter/10000);
- }
- if(previousCounter % 100000 === 0) {
- $("#Galaxies").text(previousCounter/100000);
- }
- }
- function resetCounter() {
- $("#Aliens").text(0);
- }
- });
- </script>
- <script id="s2">
- $(function() {
- $('#Purchase').click(function() {
- automaticCounter();
- });
- function automaticCounter() {
- var workers = parseInt($("#Workers").text());
- workers = isNaN(workers) ? 0: ++workers;
- $("#Workers").text(workers);
- var autoCounter = parseInt($("#Aliens").text());
- autoCounter = isNaN(autoCounter) ? 0: autoCounter - 10 * workers;
- $("#Aliens").text(autoCounter);
- var workerCheck = setInterval(function(){
- var workers = parseInt($("#Workers").text());
- if( workers > 0 ){
- for(var i = 0; i < workers; i++){
- $("#Alien").click();
- }
- }
- },5000);
- }
- });
- </script>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement