game
by paperelectron
HTML
<script src="//ajax.googleapis.com/ajax/libs/angularjs/1.2.0-rc.3/angular.min.js"></script>
<div ng-controller="game">
<p>money: {{money | number:6}} growth: {{growthRate | number:4}}</p>
<button ng-click="growCounter()">Limit</button>
<span>Add {{counterNextValue |number:4}} to limit for {{counterCost| number:4}}.</span>
<br>
<button ng-click="growMoney()">Bank</button>
<span>Add {{clickValue |number:4}} to the bank.</span>
<div ng-repeat="b in multipliers">
<button ng-bind="b.name" ng-click="growBigger(b)" ng-disabled="disable(b)"></button>
<span>Owned: {{b.count}} |</span>
<span>Cost: {{b.cCost | number:2}} |</span>
<span>Multiplier: {{b.multi}}</span>
</div>
</div>
CSS
h3 {font-size: 5em; }
span {color: red;}
.rate ul li { display: inline; color: blue; }
.rate li {
color: blue;
list-style-type: none;
padding-right: 20px;
float: left;}
JavaScript
var app = angular.module('App', []);
var counter = 0
function sigmoid(x, p) {
return p / (1 + Math.exp(-x));
};
function game($scope, $timeout) {
var lastClicked = false;
$scope.money = 1000000000.0
$scope.clickValue = .00000001
$scope.counterValue = 1
$scope.counterNextValue = 1
$scope.counterCost = 50
$scope.growthRate = 0
$scope.multipliers = [
{name: "tiny bucket",visible: false,count: 0,cCost: 1, multi: .0001, growth: .01},
{name: "small bucket",visible: true,count: 0,cCost: 10, multi: .001, growth: .03},
{name: "medium bucket",visible: false,count: 0,cCost: 100, multi: .003, growth: .05},
{name: "large bucket",visible: false,count: 0,cCost: 300, multi: .05, growth: .07},
{name: "huge bucket",visible: false,count: 0,cCost: 700, multi: .07, growth: .07},
{name: "gigantic bucket",visible: false,count: 0,cCost: 1000, multi: .09, growth: .11},]
$scope.growMoney = function(){
$scope.money += $scope.clickValue
$scope.clickValue = .000001
counter = 0
}
$scope.growCounter = function(){
if($scope.counterCost <= $scope.money){
$scope.money -= $scope.counterCost
$scope.counterCost += $scope.counterCost
$scope.counterValue += $scope.counterNextValue -= .001
}
}
$scope.growBigger = function(r){
if(r.cCost <= $scope.money){
$scope.growthRate += r.multi
$scope.money -= r.cCost
r.visible = true
r.growth += r.growth
r.cCost += r.growth
r.count++
}
}
$scope.disable = function(item){
return !(item.cCost <= $scope.money);
}
$scope.showItem = function(item){
if(item.visible)
return true;
else {
return item.cCost <= $scope.money;
}
}
derp = function(){
var newVal;
newVal = sigmoid(-6 + counter / 100,...