cssAudio - Activefile-genericCSS - ActiveGeneric - ActiveHTML - ActiveImage - ActiveJS - ActiveSVG - ActiveText - Activefile-genericVideo - ActiveLovehtmlicon-new-collectionicon-personicon-teamlog-outoctocatpop-outspinnerstartv

Pen Settings

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

Quick-add: + add another resource

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

Quick-add: + add another resource

Code Indentation

     

Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

            
              <div class="row header">
    <div class="col-md-12">
         <h1>GAME</h1>

    </div>
</div>
<div class="container">
    <div class="row">
        <div class="col-md-6">
            <div class="row">
                <div class="col-xs-4">
                    <button type="button" id="chopWood" class="btn btn-primary btn-block">Chop Wood</button>
                </div>
                <div class="col-xs-4"> <span id="woodAmount" class="btn btn-default btn-block disabled">0</span>

                </div>
                <div class="col-xs-4"> <span class="btn btn-default btn-block disabled">
            <span id="woodIncrement">0</span><span>/5s</span>
</span>
                </div>
            </div>
            <!--.row-->
            <div class="row">
                <div class="col-xs-4">
                    <button type="button" id="mineStone" class="btn btn-primary btn-block">Mine Stone</button>
                </div>
                <div class="col-xs-4"> <span id="stoneAmount" class="btn btn-default btn-block disabled">0</span>

                </div>
                <div class="col-xs-4"> <span class="btn btn-default btn-block disabled">
            <span id="stoneIncrement">0</span><span>/5s</span>
</span>
                </div>
            </div>
            <!--.row-->
            <div class="row">
                <div class="col-xs-4">
                    <button type="button" id="gatherFood" class="btn btn-primary btn-block">Gather Food</button>
                </div>
                <div class="col-xs-4"> <span id="foodAmount" class="btn btn-default btn-block disabled">0</span>

                </div>
                <div class="col-xs-4"> <span class="btn btn-default btn-block disabled">
            <span id="foodIncrement">0</span><span>/5s</span>
</span>
                </div>
            </div>
            <!--.row-->
            <hr>
        </div>
        <!---->
        <div class="col-md-6">
            <div class="row">
                <div class="col-xs-6">
                    <div class="btn-group btn-group-justified"> <span class="btn btn-default disabled">Population</span>
 <span id="workerAmount" class="btn btn-default btn-block disabled">0</span>

                    </div>
                </div>
                <div class="col-xs-6">
                    <div class="btn-group btn-group-justified"> <span class="btn btn-default disabled">Max</span>
 <span id="maxPop" class="btn btn-default disabled">0</span>

                    </div>
                </div>
            </div>
            <!--.row-->
            <div class="row" style="margin-right:-1px; margin-left:-1px;">
                <div class="col-xs-4 more-workers">
                    <button type="button" id="createLumberjack" class="btn btn-block btn-success">Create Lumberjack (10 Food)</button>
                </div>
                <div class="col-xs-4 more-workers">
                    <button type="button" id="createMiner" class="btn btn-block btn-success">Create Miner (10 Food)</button>
                </div>
                <div class="col-xs-4 more-workers">
                    <button type="button" id="createHunter" class="btn btn-block btn-success">Create Hunter (10 Food)</button>
                </div>
            </div>
            <!--.row-->
            <div class="row" style="margin-right:-1px; margin-left:-1px;">
                <div class="col-xs-4 more-workers">
                    <button type="button" id="lumberjackAmount" class="btn btn-block btn-default disabled">0</button>
                </div>
                <div class="col-xs-4 more-workers">
                    <button type="button" id="minerAmount" class="btn btn-block btn-default disabled">0</button>
                </div>
                <div class="col-xs-4 more-workers">
                    <button type="button" id="hunterAmount" class="btn btn-block btn-default disabled">0</button>
                </div>
            </div>
            <!--.row-->
            <hr>
        </div>
        <!--.col-md-6-->
    </div>
    <!--.row-->
    <div class="row">
        <div class="col-md-6">
            <div class="row">
                <div class="col-xs-4">
                    <button type="button" id="buildTent" class="btn btn-danger btn-block">Build Tent</button>
                </div>
                <div class="col-xs-4">
                    <button type="button" id="tentAmount" class="btn btn-default btn-block disabled">0</button>
                </div>
                <div class="col-xs-4">
                     <h6>Cost: <span id="tentCostWood">0</span> Wood | +<span id="tentResidents">0</span> Population</h6>

                </div>
            </div>
            <!--.row-->
            <div class="row">
                <div class="col-xs-4">
                    <button type="button" id="buildHouse" class="btn btn-danger btn-block">Build House</button>
                </div>
                <div class="col-xs-4">
                    <button type="button" id="houseAmount" class="btn btn-default btn-block disabled">0</button>
                </div>
                <div class="col-xs-4">
                     <h6>Cost: <span id="houseCostWood">0</span> Wood, <span id="houseCostStone">0</span> Stone | +<span id="houseResidents">0</span> Population</h6>

                </div>
            </div>
            <!--.row-->
            <hr>
        </div>
        <!--.col-md-6-->
        <div class="col-md-6 well">
            <h3>Information</h3>

            <div id="info"></div>
        </div>
        <!--.col-md-6-->
    </div>
    <!--.row-->
</div>
<!--.container-->
            
          
!
            
              .header {
    text-align:center;
}
.container {
    padding:25px;
}
.row {
    margin-bottom:2px;
    text-align:center;
}
.col.md-6, .col-xs-4, col-xs-3, col-xs-6 {
    padding-left:1px;
    padding-right:1px;
}
#info {
    overflow:hidden;
    max-height:200px;
}
#info p {
    text-align:left;
}
.well {
    padding-top:0;
}
            
          
!
            
              // Variables
var wood = {
    name: "wood",
    amount: 0,
    increment: 0
  },
  stone = {
    name: "stone",
    amount: 0,
    increment: 0
  },
  food = {
    name: "food",
    amount: 0,
    increment: 0
  },
  worker = {
    name: "worker",
    amount: 0,
    lumberjack: {
      increment: 1,
      amount: 0
    },
    miner: {
      increment: 1,
      amount: 0
    },
    hunter: {
      increment: 1,
      amount: 0
    }
  }, // Buildings
  tent = {
    amount: 0,
    residents: 1,
    cost: {
      wood: 30
    }
  },
  house = {
    amount: 0,
    residents: 4,
    cost: {
      wood: 75,
      stone: 25
    }
  };

var maxPop = (tent.residents * tent.amount) + (house.residents * house.amount);
var clickIncrement = 1;

$(document).ready(function() {
  (function() {
    updateValues()
    setTimeout(arguments.callee, 100);
  })();
});

// Display the correct values.
function updateValues() {
  //document.getElementById("woodAmount").innerHTML = wood.amount;
  $("#woodAmount").html(wood.amount);
  $("#stoneAmount").html(stone.amount);
  $("#foodAmount").html(food.amount);
  $("#woodIncrement").html(wood.increment);
  $("#stoneIncrement").html(stone.increment);
  $("#foodIncrement").html(food.increment);
  $("#workerAmount").html(worker.amount);
  $("#maxPop").html(maxPop);
  $("#lumberjackAmount").html(worker.lumberjack.amount);
  $("#minerAmount").html(worker.miner.amount);
  $("#hunterAmount").html(worker.hunter.amount);
  $("#tentAmount").html(tent.amount);
  $("#tentCostWood").html(tent.cost.wood);
  $("#tentResidents").html(tent.residents);
  $("#houseAmount").html(house.amount);
  $("#houseCostWood").html(house.cost.wood);
  $("#houseCostStone").html(house.cost.stone);
  $("#houseResidents").html(house.residents);
}

// Click to Chop, Mine, Gather
$('#chopWood').click(function() {
  wood.amount = wood.amount + clickIncrement;
});

$('#mineStone').click(function() {
  stone.amount = stone.amount + clickIncrement;
});

$('#gatherFood').click(function() {
  food.amount = food.amount + clickIncrement;
});

// Create Workers
$('#createLumberjack').click(function() {
  if (worker.amount < maxPop) {
    if (food.amount >= 10) {
      food.amount = food.amount - 10;
      worker.amount++;
      worker.lumberjack.amount++;
      beginGatherWood();
    } else {
      $("#info").prepend($('<p>You need more food.</p>').fadeIn('slow'));
    }
  } else {
    $("#info").prepend($('<p>You need to build more accommodation.</p>').fadeIn('slow'));
  }
});

$('#createMiner').click(function() {
  if (worker.amount < maxPop) {
    if (food.amount >= 10) {
      food.amount = food.amount - 10;
      worker.amount++;
      worker.miner.amount++;
      beginGatherStone();
    } else {
      $("#info").prepend($('<p>You need more food.</p>').fadeIn('slow'));
    }
  } else {
    $("#info").prepend($('<p>You need to build more accommodation.</p>').fadeIn('slow'));
  }
});

$('#createHunter').click(function() {
  if (worker.amount < maxPop) {
    if (food.amount >= 10) {
      food.amount = food.amount - 10;
      worker.amount++;
      worker.hunter.amount++;
      beginGatherFood();
    } else {
      $("#info").prepend($('<p>You need more food.</p>').fadeIn('slow'));
    }
  } else {
    $("#info").prepend($('<p>You need to build more accommodation.</p>').fadeIn('slow'));
  }
});

// Lumberjacks Gather Wood
function beginGatherWood() {
  nIntervId = setInterval(gatherWood, 5000);
}

function gatherWood() {
  wood.increment = worker.lumberjack.increment * worker.lumberjack.amount;
  wood.amount = wood.amount + wood.increment;
}

// Miner Gather Stone
function beginGatherStone() {
  nIntervId = setInterval(gatherStone, 5000);
}

function gatherStone() {
  stone.increment = worker.miner.increment * worker.miner.amount;
  stone.amount = stone.amount + stone.increment;
}

// Hunter Gather Food
function beginGatherFood() {
  nIntervId = setInterval(gatherFood, 5000);
}

function gatherFood() {
  food.increment = worker.hunter.increment * worker.hunter.amount;
  food.amount = food.amount + food.increment;
}

// Build a tent
$('#buildTent').click(function() {
  if (wood.amount >= tent.cost.wood) {
    wood.amount = wood.amount - tent.cost.wood;
    tent.amount++;
    tent.cost.wood = tent.cost.wood * 1.2;
    tent.cost.wood = tent.cost.wood.toFixed(0);
    maxPop = maxPop + tent.residents;
  } else {
    $("#info").prepend($('<p>You need more wood.</p>').fadeIn('slow'));
  }
});

// Build a house
$('#buildHouse').click(function() {
  if (wood.amount >= house.cost.wood && stone.amount >= house.cost.stone) {
    wood.amount = wood.amount - house.cost.wood;
    stone.amount = stone.amount - house.cost.stone;
    house.amount++;
    house.cost.wood = house.cost.wood * 1.2;
    house.cost.stone = house.cost.stone * 1.2;
    house.cost.wood = house.cost.wood.toFixed(0);
    house.cost.stone = house.cost.stone.toFixed(0);
    maxPop = maxPop + house.residents;
  } else {
    $("#info").prepend($('<p>You need more building materials.</p>').fadeIn('slow'));
  }
});

// Upgrades
$('#upgradeTwoFingers').click(function() {
  if (wood.amount >= 100 && stone.amount >= 100 && food.amount >= 100) {
    wood.amount = wood.amount - 100;
    stone.amount = stone.amount - 100;
    food.amount = food.amount - 100;
    clickIncrement = clickIncrement + 1;
    $('.upgradeTwoFingers').addClass('hidden');
  } else {
    $("#info").prepend($('<p>You need more resources.</p>').fadeIn('slow'));
  }
});

$('#upgradeBunkBeds').click(function() {
  if (wood.amount >= 100 && stone.amount >= 100 && food.amount >= 100) {
    wood.amount = wood.amount - 100;
    stone.amount = stone.amount - 100;
    food.amount = food.amount - 100;
    house.residents = 5;
    maxPop = maxPop + house.amount;
    $('.upgradeBunkBeds').addClass('hidden');
  } else {
    $("#info").prepend($('<p>You need more resources.</p>').fadeIn('slow'));
  }
});

$('#upgradeGymWorkout').click(function() {
  if (wood.amount >= 100 && stone.amount >= 100 && food.amount >= 100) {
    wood.amount = wood.amount - 100;
    stone.amount = stone.amount - 100;
    food.amount = food.amount - 100;
    worker.lumberjack.increment = 2;
    worker.miner.increment = 2;
    worker.hunter.increment = 2;
    $('.upgradeGymWorkout').addClass('hidden');
  } else {
    $("#info").prepend($('<p>You need more resources.</p>').fadeIn('slow'));
  }
});

/* TESTING VALUES
wood.amount = 500;
stone.amount = 500;
food.amount = 500;*/
            
          
!
999px
Loading ..................

Console