<!DOCTYPE html>
<html>
<head>
<body>
<h1>mining game</h1>
<p>by frogggeee</p>
<p id = "loading" ></p>
<p id = "energy"></p>
<p id = "storage"></p>
<canvas id = "canvas" width = "480" height = "360"></canvas>
<script>
let page = 1;
let onShop = false;
let efficiency = 1; // for every 1 upgraded energy storage upgrade efficiency by 0.1. when the battery storage is at 20 the efficiency should be at 2 so the energy is decreased the same as if the energy storage was at 10.
let moveTimer = 0;
let hitboxX = 0;
let hitboxY = 0;
let energyEfficiencyCost = 100;
let energyStorageCost = 80;
let energyStorage = 10; // should be 10 to start out the game
let energyChangeCost = 20;
let over = false;
let digSpeedCost = 60;
let infoOn = true;
let infoOpen = true;
let mouseX = 0;
let mouseY = 0;
let clicked = false;
let shopOpen = false;
let energyChange = 10;
let energy = 0;
let touchingDugDirt = false;
let touchingDirt = false;
let touchingRock1 = false;
let touchingRock2 = false;
let touchingRock3 = false;
let touchingRight = false;
let touchingLeft = false;
let touchingUp = false;
let touchingDown = false;
let rockHardness = 0;
let money = 100;
let mainDigSpeed = 4;
let digSpeed = 0;
let playerX = 200;
let playerY = 200;
let canvas = document.getElementById("canvas");
let ctx = canvas.getContext("2d");
let worldType = [];
let worldX = [];
let worldY = [];
let loading = true;
let mainX = -2000;
let mainY = 90;
let trump = new Image();
trump.src = "https://clipart.info/images/ccovers/1495816049surprised-face-trump-png-transparent-clip-art.png";
let shop = new Image();
shop.src = "https://d3itj9t5jzykfd.cloudfront.net/ui/152759/image_5b746e2d32b94.ico";
// world is 200x549 blocks not including lava
let rightPressed = false;
let leftPressed = false;
let upPressed = false;
let downPressed = false;
document.addEventListener('mousedown', onDown, false);
document.addEventListener('mousemove', function(e) {mouseX = e.clientX; mouseY = e.clientY;});
let cX = 0;
let cY = 0;
function...
Please Whitelist JSFiddle in your content blocker.
Help keep JSFiddle free for always by one of two ways:
Whitelist JSFiddle in your content blocker (two clicks)
Go PRO and get access to additional PRO features →
Join the 4+ million users, and keep the JSFiddle dream alive.
Ad-free
All ads in the editor and listing pages are turned completely off.
Use pre-released features
You get to try and use features (like the Palette Color Generator) months before everyone else.
Fiddle collections
Sort and categorize your Fiddles into multiple collections.
Private collections and fiddles
You can make as many Private Fiddles, and Private Collections as you wish!
Console
Debug your Fiddle with a minimal built-in JavaScript console.