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.
<div class="container">
<h1>Player Experience Equations</h1>
<section>
<div>
<p>
The purpose here is to show how an algorithm could prevent the problem of overpowered players in a VRMMO like Domino Finn's "Reboot" series.
</p>
<p>
Even if the player at the top gained an enormous amount of experience, they wouldn't level until the average of other players started to rise.
</p>
<p>Conversely, a newbie would have a much easier time leveling.</p>
<h2>Base Experience Equation</h2>
<p>
Let the base experience (b) equal 1000 * the level of the player (cpl).
</p>
<p>$$b = 1000 * cpl$$</p>
<p>In the event that the character's level is the same as the average level of other characters, the base experience equation shall be used.</p>
<h2>Base Equation for Highest Level Player</h2>
<p>For the highest leveled player who is not equal to the average level, let experience equal the base experience (b) times the highest level player (h) divided by the average level of other players (avl) raised to the power of (h) minus the next highest leveled player (nh) + 1.</p>
</div>
<div class="equation">
<p>$$exp = b({({h \over avl})^{(h-nh+1)}})$$</p>
</div>
<div class="equation">
<h2>Base Equation for Other Players</h2>
<p>For a player who is not the highest leveled player and is not at the same level as the average player, let experience (exp) equal the base experience (b) divided by the current player level (cpl) over the average player's level (avl)</p>
<p>
$$exp = {b({cpl \over avl})} $$
</p>
</div>
</section>
<section class="col col-sm-12">
<div class="input col">
<label class="col-sm-9" for="highestLevelPlayer">
Highest Level Player
</label>
<input class="col-sm-3" type="number" id='highestLevelPlayer' value='10' min='0'>
</div>
<div class="input col">
<label class="col-sm-9" for="nextHighestLevelPlayer">Next Highest Level Player</label>
<input class="col-sm-3" type="number" id='nextHighestLevelPlayer' value='8' min='0'>
</div>
<div class="input col">
<label class="col-sm-9" for="averagePlayerLevel">Average Player Level</label>
<input class="col-sm-3" type="number" id='averagePlayerLevel' value='5' min='0'>
</div>
<div class="input col">
<label class="col-sm-9" for="otherPlayerLevel">Other Player Level</label>
<input class="col-sm-3" type="number" id='otherPlayerLevel' value='1' min='0'>
</div>
</section>
<section>
<section>
<h2>Results:</h2>
<div>
For the highest level player with a level of <span id="hplayer"></span>, the experience required will be <output id='highestLevelPlayerResult'></output> out of a base experience of <output id='baseExperienceHighestOutput2'></output>
</div>
<div>
For the other player with a level of <span id="oplayer"></span>, the experience required will be <output id="otherPlayerResult"></output> out of a base experience of <output id="otherPlayerOutput2"></output>
</div>
<div>
<br/>
<p>Equation visualized:</p>
<p><strong>Highest Player Formula: </strong><output id='totalExpHighestOutput'></output> = <output id='baseExperienceHighestOutput'></output>((<output id='highestLevelPlayerLevelOutput1'></output> / <output id='averagePlayerLevelOutput'></output>)<sup>(<output id='highestLevelPlayerLevelOutput2'></output>-<output id='nextHighestLevelOutput'></output>+1)</sup>)</p>
</div>
</section>
</section>
</div>
const d = document
const highestPlayerLevel = d.querySelector('#highestLevelPlayer')
const nextHighestPlayerLevel = d.querySelector('#nextHighestLevelPlayer')
const averagePlayerLevel = d.querySelector('#averagePlayerLevel')
const otherPlayerLevel = d.querySelector('#otherPlayerLevel')
const highestPlayerSpan = d.querySelector('#hplayer')
const playerResult = d.querySelector('#highestLevelPlayerResult')
const otherPlayerSpan = d.querySelector('#oplayer')
const otherPlayerResult = d.querySelector('#otherPlayerResult')
const otherPlayerOutput2 = d.querySelector('#otherPlayerOutput2')
const baseExperienceFunc = (level) => {
return Number(level) * 1000
}
const playerOutput = () => {
highestPlayerSpan.innerHTML = highestPlayerLevel.value
}
const otherPlayerOutput = () => {
otherPlayerSpan.innerHTML = otherPlayerLevel.value
}
const otherPlayerEquation = () => {
const playerLevel = Number(otherPlayerLevel.value)
const highestLevel = Number(highestPlayerLevel.value)
const averageLevel = Number(averagePlayerLevel.value)
const baseExperience = baseExperienceFunc(playerLevel)
if (playerLevel === highestLevel) {
return baseExperience
}
if (playerLevel > highestLevel) {
alert("ERROR! The other player cannot be higher leveled than the highest player!")
return
}
otherPlayerOutput2.innerHTML = baseExperience.toLocaleString()
otherPlayerResult.innerHTML = Number(Math.round(baseExperience * (playerLevel / averageLevel))).toLocaleString()
}
const highestLevelPlayerEquation = () => {
const playerLevel = Number(highestPlayerLevel.value)
const baseExperience = baseExperienceFunc(playerLevel)
const nextHighestLevel = Number(nextHighestPlayerLevel.value)
const averageLevel = Number(averagePlayerLevel.value)
if (playerLevel === averageLevel) {
return baseExperience
}
if (playerLevel < averageLevel) {
alert("ERROR! The average level cannot be higher than the highest leveled player!")
return
}
const base = (playerLevel / averageLevel)
const expo = (playerLevel - nextHighestLevel + 1)
const exponent = Math.pow(base, expo)
const result = Math.round(baseExperience * exponent)
playerResult.innerHTML = result.toLocaleString()
}
highestLevelPlayerEquation()
otherPlayerEquation()
playerOutput()
otherPlayerOutput()
highestPlayerLevel.addEventListener('change', playerOutput)
otherPlayerLevel.addEventListener('change', otherPlayerOutput)
highestPlayerLevel.addEventListener('change', highestLevelPlayerEquation)
nextHighestPlayerLevel.addEventListener('change', highestLevelPlayerEquation)
averagePlayerLevel.addEventListener('change', highestLevelPlayerEquation)
averagePlayerLevel.addEventListener('change', otherPlayerEquation)
otherPlayerLevel.addEventListener('change', otherPlayerEquation)
const totalExpHighestOutput = d.querySelector('#totalExpHighestOutput')
const baseExperienceHighestOutput = d.querySelector('#baseExperienceHighestOutput')
highestLevelOutput1 = d.querySelector('#highestLevelPlayerLevelOutput1')
highestLevelOutput2 = d.querySelector('#highestLevelPlayerLevelOutput2')
averagePlayerOutput = d.querySelector('#averagePlayerLevelOutput')
nextHighestLevelOutput = d.querySelector('#nextHighestLevelOutput')
const baseExperienceHighestOutput2 = d.querySelector('#baseExperienceHighestOutput2')
const changeHighestLevelFormula = () => {
const playerLevel = Number(highestPlayerLevel.value)
const baseExperience = baseExperienceFunc(playerLevel)
const nextHighestLevel = Number(nextHighestPlayerLevel.value)
const averageLevel = Number(averagePlayerLevel.value)
const base = (playerLevel / averageLevel)
const expo = (playerLevel - nextHighestLevel + 1)
const exponent = Math.pow(base, expo)
const result = Math.round(baseExperience * exponent)
totalExpHighestOutput.innerHTML = result.toLocaleString()
baseExperienceHighestOutput.innerHTML = baseExperience.toLocaleString()
baseExperienceHighestOutput2.innerHTML = baseExperience.toLocaleString()
highestLevelOutput1.innerHTML = playerLevel
highestLevelOutput2.innerHTML = playerLevel
averagePlayerOutput.innerHTML = averageLevel
nextHighestLevelOutput.innerHTML = nextHighestLevel
}
changeHighestLevelFormula()
highestPlayerLevel.addEventListener('change', changeHighestLevelFormula)
nextHighestPlayerLevel.addEventListener('change', changeHighestLevelFormula)
averagePlayerLevel.addEventListener('change', changeHighestLevelFormula)
Also see: Tab Triggers