HTML preprocessors can make writing HTML more powerful or convenient. For instance, Markdown is designed to be easier to write and read for text documents and you could write a loop in Pug.
In CodePen, whatever you write in the HTML editor is what goes within the <body>
tags in a basic HTML5 template. So you don't have access to higher-up elements like the <html>
tag. If you want to add classes there that can affect the whole document, this is the place to do it.
In CodePen, whatever you write in the HTML editor is what goes within the <body>
tags in a basic HTML5 template. If you need things in the <head>
of the document, put that code here.
The resource you are linking to is using the 'http' protocol, which may not work when the browser is using https.
CSS preprocessors help make authoring CSS easier. All of them offer things like variables and mixins to provide convenient abstractions.
It's a common practice to apply CSS to a page that styles elements such that they are consistent across all browsers. We offer two of the most popular choices: normalize.css and a reset. Or, choose Neither and nothing will be applied.
To get the best cross-browser support, it is a common practice to apply vendor prefixes to CSS properties and values that require them to work. For instance -webkit-
or -moz-
.
We offer two popular choices: Autoprefixer (which processes your CSS server-side) and -prefix-free (which applies prefixes via a script, client-side).
Any URLs added here will be added as <link>
s in order, and before the CSS in the editor. You can use the CSS from another Pen by using its URL and the proper URL extension.
You can apply CSS to your Pen from any stylesheet on the web. Just put a URL to it here and we'll apply it, in the order you have them, before the CSS in the Pen itself.
You can also link to another Pen here (use the .css
URL Extension) and we'll pull the CSS from that Pen and include it. If it's using a matching preprocessor, use the appropriate URL Extension and we'll combine the code before preprocessing, so you can use the linked Pen as a true dependency.
JavaScript preprocessors can help make authoring JavaScript easier and more convenient.
Babel includes JSX processing.
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.
You can apply a script from anywhere on the web to your Pen. Just put a URL to it here and we'll add it, in the order you have them, before the JavaScript in the Pen itself.
If the script you link to has the file extension of a preprocessor, we'll attempt to process it before applying.
You can also link to another Pen here, and we'll pull the JavaScript from that Pen and include it. If it's using a matching preprocessor, we'll combine the code before preprocessing, so you can use the linked Pen as a true dependency.
Search for and use JavaScript packages from npm here. By selecting a package, an import
statement will be added to the top of the JavaScript editor for this package.
Using packages here is powered by esm.sh, which makes packages from npm not only available on a CDN, but prepares them for native JavaScript ESM usage.
All packages are different, so refer to their docs for how they work.
If you're using React / ReactDOM, make sure to turn on Babel for the JSX processing.
If active, Pens will autosave every 30 seconds after being saved once.
If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.
If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.
Visit your global Editor Settings.
<head>
<title id="tabname">Taco Tapper</title>
</head>
<body id="body">
<h1 id="title" class="center exo">Taco Tapper</h1>
<hr />
<br /><br />
<button class="center q" onclick="shop.buy(shop.grandpas, 1, grandpas);"><h1>Buy Grandpa</h1><h5>$100 - 1 tps - <div id="grandpas">0</div></h5></button>
<button class="center q" onclick="shop.buy(shop.stands, 1, stands);"><h1>Buy Stand</h1><h5>$500 - 5 tps - <div id="stands">0</div></h5></button>
<button class="center q" onclick="shop.buy(shop.trucks, 1, trucks);"><h1>Buy Truck</h1><h5>$1000 - 10 tps - <div id="trucks">0</div></h5></button>
<button class="center q" onclick="shop.buy(shop.shacks, 1, shacks);"><h1>Buy Shack</h1><h5>$5000 - 50 tps - <div id="shacks">0</div></h5></button>
<button class="center q" onclick="shop.buy(shop.counties, 1, counties);"><h1>Buy County</h1><h5>$10000 - 100 tps - <div id="counties">0</div></h5></button>
<button class="center q" onclick="shop.buy(shop.states, 1, states);"><h1>Buy State</h1><h5>$50000 - 500 tps - <div id="states">0</div></h5></button>
<button class="center q" onclick="shop.buy(shop.countries, 1, countries);"><h1>Buy Country</h1><h5>$100000 - 1000 tps - <div id="countries">0</div></h5></button>
<button class="center q" onclick="shop.buy(shop.planets, 1, planets);"><h1>Buy Planet</h1><h5>$500000 - 5000 tps - <div id="planets">0</div></h5></button>
<button class="center q" onclick="shop.buy(shop.solarsystems, 1, solarsystems);"><h1>Buy Solar System</h1><h5>$1000000 - 10000 tps - <div id="solarsystems">0</div></h5></button>
<button class="center q" onclick="shop.buy(shop.galaxies, 1, galaxies);"><h1>Buy Galaxy</h1><h5>$5000000 - 50000 tps - <div id="galaxies">0</div></h5></button>
<button class="center q" onclick="shop.buy(shop.universes, 1, universes);"><h1>Buy Universe</h1><h5>$10000000 - 100000 tps - <div id="universes">0</div></h5></button>
<button class="center q" onclick="shop.buy(shop.growthrays, 1, growthrays);"><h1>Buy Growth Ray</h1><h5>$50000000 - 500000 tps - <div id="growthrays">0</div></h5></button>
<button class="center q" onclick="shop.buy(shop.lettucelasers, 1, lettucelasers);"><h1>Buy Lettuce Laser</h1><h5>$100000000 - 1000000 tps - <div id="lettucelasers">0</div></h5></button>
<button class="center q" onclick="shop.buy(shop.meatmountains, 1, meatmountains);"><h1>Buy Meat Mountains</h1><h5>$500000000 - 5000000 tps - <div id="meatmountains">0</div></h5></button>
<div onclick="taco.click();" id="taco"><img src="http://ex-games.org/dev/010111O01O010000110000O00011100111I1001000O0/Taco_Tapper/taco.png" class="imgcenter"></img></div>
<h4 class="exo">Require $1000 Purchase:</h4>
<button class="center h" onclick="boosts.buy(boosts.doubletappers, 1, doubletappers);"><h1>Buy Double Tapper</h1><h5>$10000 - +1 tpc - <div id="doubletappers">0</div></h5></button>
<button class="center h" onclick="boosts.buy(boosts.duplicators, 1, duplicators);"><h1>Buy Duplicator</h1><h5>$1000000 - +100 tpc - <div id="duplicators">0</div></h5></button>
<h3 class="center exo">Tacos: </h3><h1 id="tacocounter" class="center exo">0</h1>
<br />
<h3 class="center exo">TPS: </h3><h1 id="tpscounter" class="center exo">0</h1>
<footer><h4 class="exo">v0.1.5 Pen</h4></footer><h4 class="center exo">View complete version at <a href="http://ex-games.org/dev/010111O01O010000110000O00011100111I1001000O0/Taco_Tapper/">my website</a>.</h4>
<script src="index.js"></script>
</body>
.center {
text-align: center;
}
@font-face {
font-family: Exo;
src: url(http://ex-games.org/dev/010111O01O010000110000O00011100111I1001000O0/Taco_Tapper/Exo-Regular.otf);
}
.exo {
font-family: Exo;
}
body {
background-color: #DCFCE0;
}
#taco:active {
border-style: ridge;
border-color: lightblue;
}
#taco {
border-style: groove;
border-color: black;
background-color: #CCFFD2;
}
.left {
text-align: left;
}
.right {
text-align: right;
}
.imgcenter {
display: block;
margin-left: auto;
margin-right: auto;
}
@font-face {
font-family: Quicksand;
src: url(http://ex-games.org/dev/010111O01O010000110000O00011100111I1001000O0/Taco_Tapper/Quicksand-Regular.otf);
}
button.q {
color: darkgreen;
}
button {
font-family: Quicksand;
}
button.h {
color: darkblue;
}
// getting elements
var tacocounter = document.getElementById("tacocounter");
var tpscounter = document.getElementById("tpscounter");
var body = document.getElementById("body");
var title = document.getElementById("tabname");
// and now for the shop
var grandpas = document.getElementById("grandpas");
var stands = document.getElementById("stands");
var trucks = document.getElementById("trucks");
var shacks = document.getElementById("shacks");
var counties = document.getElementById("counties");
var states = document.getElementById("states");
var countries = document.getElementById("countries");
var planets = document.getElementById("planets");
var solarsystems = document.getElementById("solarsystems");
var galaxies = document.getElementById("galaxies");
var universes = document.getElementById("universes");
var growthrays = document.getElementById("growthrays");
var lettucelaser = document.getElementById("lettucelasers");
var meatmountains = document.getElementById("meatmountains");
// and now for the boosts
var doubletappers = document.getElementById("doubletappers");
var duplicators = document.getElementById("duplicators");
// boost affordality
var boostAfford = false;
// defining taco (the main object of the code)
var taco = {tacos: 0, el: document.getElementById("taco"), click: function() {this.tacos = this.tacos + boosts.tpc;}};
// defining shop (things that make tacos for you)
var shop = {};
shop.buy = function(item, amount, minus){if (taco.tacos >= item.cost) {minus.innerHTML = item.num; item.num = item.num + amount; taco.tacos = taco.tacos - item.cost; this.tps = this.tps + item.prod;} if (item.cost >= 1000) {boostAfford = true;}};
shop.tps = 0;
shop.grandpas = {num: 1, cost: 100, prod: 1};
shop.stands = {num: 1, cost: 500, prod: 5};
shop.trucks = {num: 1, cost: 1000, prod: 10};
shop.shacks = {num: 1, cost: 5000, prod: 50};
shop.counties = {num: 1, cost: 10000, prod: 100};
shop.states = {num: 1, cost: 50000, prod: 500};
shop.countries = {num: 1, cost: 100000, prod: 1000};
shop.planets = {num: 1, cost: 500000, prod: 5000};
shop.solarsystems = {num: 1, cost: 1000000, prod: 10000};
shop.galaxies = {num: 1, cost: 5000000, prod: 50000};
shop.universes = {num: 1, cost: 10000000, prod: 100000};
shop.growthrays = {num: 1, cost: 50000000, prod: 500000};
shop.lettucelasers = {num: 1, cost: 100000000, prod: 1000000};
shop.meatmountains = {num: 1, cost: 500000000, prod: 5000000};
// defining boosts (things that give you more tpc)
var boosts = {};
boosts.buy = function(item, amount, minus) {if (taco.tacos >= item.cost * amount && boostAfford === true) {minus.innerHTML = item.num; item.num = item.num + amount; taco.tacos = taco.tacos - item.cost * amount; this.tpc = this.tpc + item.prod;}};
boosts.tpc = 1;
boosts.doubletappers = {num: 1, cost: 10000, prod: 1};
boosts.duplicators = {num: 1, cost: 1000000, prod: 100};
// sending tacos and tps to html
setInterval(function(){tacocounter.innerHTML = taco.tacos; title.innerHTML = taco.tacos + " Tacos";}, 10);
setInterval(function(){tpscounter.innerHTML = shop.tps;}, 10);
// adding tacos for tps (tacos per second) or tacos made by workers
setInterval(function(){taco.tacos = taco.tacos + shop.tps;}, 1000);
// keydowns
window.addEventListener("keydown", function(evt) {
//defining all the keys
// numbers:
//0
if (evt.keyCode == 48) {shop.buy(shop.galaxies, 1, galaxies);}
//1
if (evt.keyCode == 49) {shop.buy(shop.grandpas, 1, grandpas);}
//2
if (evt.keyCode == 50) {shop.buy(shop.stands, 1, stands);}
//3
if (evt.keyCode == 51) {shop.buy(shop.trucks, 1, trucks);}
//4
if (evt.keyCode == 52) {shop.buy(shop.shacks, 1, shacks);}
//5
if (evt.keyCode == 53) {shop.buy(shop.counties, 1, counties);}
//6
if (evt.keyCode == 54) {shop.buy(shop.states, 1, states);}
//7
if (evt.keyCode == 55) {shop.buy(shop.countries, 1, countries);}
//8
if (evt.keyCode == 56) {shop.buy(shop.planets, 1, planets);}
//9
if (evt.keyCode == 57) {shop.buy(shop.solarsystems, 1, solarsystems);}
});
//key ups
window.addEventListener("keyup", function(evt) {
// space
if (evt.keyCode == 32) {taco.click();}
});
// to be continued...
Also see: Tab Triggers