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.
%img.m{:src => 'https://s3-us-west-2.amazonaws.com/s.cdpn.io/217233/pixelTest.png'}
.floor
.overlay
.options
.options_sf
%img{:src => 'https://s3-us-west-2.amazonaws.com/s.cdpn.io/217233/sfIcon.png'}
.options_bg
%img{:src => 'https://s3-us-west-2.amazonaws.com/s.cdpn.io/217233/bgIcon.png'}
.name_modal
.pixelsTop
.pixelsBottom
.intro_modal__header
%p Welcome
%img{:src => 'https://s3-us-west-2.amazonaws.com/s.cdpn.io/217233/featuredHeader.png'}
%h3 Enter your name, developer
%hr
%input{:type => 'text', :placeholder => 'Your Name'}
.next
.pixelsTop
.pixelsBottom
Next
.intro_modal
.pixelsTop
.pixelsBottom
.intro_modal__header
%p Welcome
%img{:src => 'https://s3-us-west-2.amazonaws.com/s.cdpn.io/217233/featuredHeader.png'}
%h3 Welcome to codepen simulator
%hr
%p.text Your aim is to see how many followers you can get in 1 year!
%p.text Create pens by simply typing randomly. The pen will gain stats in html, css, js and design based on your skill level. Use your followers to unlock research which improves your skills!
%p.text If good enough, your pen will be featured and that will boost your views.
.go
.pixelsTop
.pixelsBottom
Let's go
.endGame
.pixelsTop
.pixelsBottom
.endGame__header
%p Finished
%img{:src => 'https://s3-us-west-2.amazonaws.com/s.cdpn.io/217233/featuredHeader.png'}
%h3 Congratulations! You've done 1 year on Codepen!
%hr
%h2 You managed to get
%h1 100000
%p Followers
%p
You released
%span.pencount 1
pen(s)
%p
Your most viewed pen was
%span.mostName x
which had
%span.mostViews x
views!
%a{:href => 'http://www.codepen.io/jcoulterdesign', :target => '_blank'}
.restart
.pixelsTop
.pixelsBottom
See more cool stuff
.share
.pixelsTop
.pixelsBottom
Share on twitter
.researchProgress
%h2 Researching...
.bar
.bar_inner
.pixelsTop
.pixelsBottom
.featured_modal
.pixelsTop
.pixelsBottom
.featured_modal__header
%p Featured
%img{:src => 'https://s3-us-west-2.amazonaws.com/s.cdpn.io/217233/featuredHeader.png'}
%h3 Your pen has been picked!
%hr
.featured_modal__image
%img{:src => 'https://s3-us-west-2.amazonaws.com/s.cdpn.io/217233/cPreview.png'}
.featured_modal__text
%p
your pen '
%span.name example pen
'
%p has been picked by
%p.picker
%p that should help boost your views!
.awesome
.pixelsTop
.pixelsBottom
awesome
.research_modal
.research_modal__header
%p research
%img{:src => 'https://s3-us-west-2.amazonaws.com/s.cdpn.io/217233/researchHeader.png'}
%h3.hide Improve your skills
%hr.hide
.close.hide
.pixelsTop
.pixelsBottom
x
.pixelsTop
.pixelsBottom
.research_modal__list.hide
.complete_modal
.pixelsTop
.pixelsBottom
.complete_modal__header
%img{:src => 'https://s3-us-west-2.amazonaws.com/s.cdpn.io/217233/penCompleteHeader.png'}
%p pen complete
%div.hide
%img
%h2 You completed a pen!
%hr
%h3 lets see how you did
.complete_modal__stats.hide
.html
%h4 html
%img{:src => 'https://s3-us-west-2.amazonaws.com/s.cdpn.io/217233/gHtml.png'}
%span
.swatch.html
%span 103
.css
%h4 css
%img{:src => 'https://s3-us-west-2.amazonaws.com/s.cdpn.io/217233/gCSS.png'}
%span
.swatch.css
%span 103
.js
%h4 js
%img{:src => 'https://s3-us-west-2.amazonaws.com/s.cdpn.io/217233/gJS.png'}
%span
.swatch.js
%span 103
.design
%h4 Design
%img{:src => 'https://s3-us-west-2.amazonaws.com/s.cdpn.io/217233/gDesign.png'}
%span
.swatch.design
%span 103
.scrap.hide
.pixelsTop
.pixelsBottom
scrap pen
%img.icon{:src => 'https://s3-us-west-2.amazonaws.com/s.cdpn.io/217233/scrapCross.png'}
.release.hide
.pixelsTop
.pixelsBottom
release pen
%img.icon{:src => 'https://s3-us-west-2.amazonaws.com/s.cdpn.io/217233/releaseArrow.png'}
.pen
.pixelsTop
.pixelsBottom
%h2 progress:
.date
%img{:src => 'https://s3-us-west-2.amazonaws.com/s.cdpn.io/217233/gCalendar.png'}
%span
.followers
%img{:src => 'https://s3-us-west-2.amazonaws.com/s.cdpn.io/217233/followersIcon.png'}
.pixelsTop
.pixelsBottom
FOLLOWERS:
%span 0
.pen_bar
.pen_bar_progress
.pen_html
.pixelsTop
.pixelsBottom
.swatch
%span HTML
.sep
%span.val 0
.pen_css
.pixelsTop
.pixelsBottom
.swatch
%span CSS
.sep
%span.val 0
.pen_js
.pixelsTop
.pixelsBottom
.swatch
%span JS
.sep
%span.val 0
.pen_design
.pixelsTop
.pixelsBottom
.swatch
%span DESIGN
.sep
%span.val 0
.releasedHeader
.pixelsTop
.pixelsBottom
%img.icon{:src => 'https://s3-us-west-2.amazonaws.com/s.cdpn.io/217233/codepenIcon.png'}
Released Pens
%img.arrow{:src => 'https://s3-us-west-2.amazonaws.com/s.cdpn.io/217233/downArrow.png'}
.releasedEmpty
.pixelsTop
.pixelsBottom
%h2 You haven't released any pens yet
.released
.username
.pixelsTop
.pixelsBottom
%img{:src => 'https://s3-us-west-2.amazonaws.com/s.cdpn.io/217233/userIcon.png'}
%h2 Developer
.mystats
%img{:src => 'https://s3-us-west-2.amazonaws.com/s.cdpn.io/217233/skilsIcon.png'}
.pixelsTop
.pixelsBottom
%h2 skills
.mystats_html
.swatch
HTML:
%span lv
%span.val 0
.mystats_css
.swatch
CSS:
%span lv
%span.val 0
.mystats_js
.swatch
JAVASCRIPT:
%span lv
%span.val 0
.mystats_design
.swatch
DESIGN:
%span lv
%span.val 0
.research
.researchButton
.pixelsTop
.pixelsBottom
.researchButton_counter
%span 0
.pixelsTop
.pixelsBottom
Research
%img{:src => 'https://s3-us-west-2.amazonaws.com/s.cdpn.io/217233/buttonArrow.png'}
.achievementsButton
.pixelsTop
.pixelsBottom
Achievments
%img{:src => 'https://s3-us-west-2.amazonaws.com/s.cdpn.io/217233/buttonArrow.png'}
%a{:href => 'http://www.codepen.io/jcoulterdesign', :target => '_blank'}
.followButton
.pixelsTop
.pixelsBottom
Follow me on codepen
.startMashing
.auto.off
auto
%img.cross{:src => 'https://s3-us-west-2.amazonaws.com/s.cdpn.io/217233/autoCross.png'}
%img.tick{:src => 'https://s3-us-west-2.amazonaws.com/s.cdpn.io/217233/autoTick.png'}
.pixelsTop
.pixelsBottom
.pixelsTop
.pixelsBottom
%h2
%span Start pressing keys
%img{:src => 'https://s3-us-west-2.amazonaws.com/s.cdpn.io/217233/gKey.png'}
%canvas.grain
@font-face {
font-family: pixles;
src: url(https://s3-us-west-2.amazonaws.com/s.cdpn.io/217233/04B_03__.TTF);
}
// boxes
// Each elemenmt that has the pixel outline, needs the 2 divs inside called pixelsTop and pixlesBottom
$pixelWidth : 3px;
$pixelWidthAlt : -3px;
$pixelBorderColor : #b6a695;
$pixelHighlightColor : #e7e7e7;
$pixelShadowColor : rgba(0 , 0, 0, 0.1);
%pixelsTop {
display: block;
content: '';
position: absolute;
width: $pixelWidth;
height: $pixelWidth;
top: 0;
}
%pixelsBottom {
display: block;
content: '';
position: absolute;
width: $pixelWidth;
height: $pixelWidth;
top: 0;
}
@mixin make_box($bg, $borderColor, $highlightColor, $shadowColor) {
background: $bg;
box-shadow: 0px $pixelWidth $highlightColor, 0px $pixelWidthAlt $bg, $pixelWidth 0px $bg, $pixelWidthAlt 0px $bg, 0px $pixelWidthAlt * 2 $borderColor, 0px $pixelWidth * 2 $borderColor, $pixelWidth * 2 0px $borderColor, $pixelWidthAlt * 2 0px $borderColor, $pixelWidth * 3 0px $shadowColor, 0px $pixelWidth * 3 $shadowColor;
position: relative;
padding: 12px;
& .pixelsBottom {
width: calc(100% + #{$pixelWidth * 4});
position: absolute;
left: -$pixelWidth * 2;
bottom: 0;
&::after {
@extend %pixelsTop;
right: $pixelWidth;
top: -$pixelWidth;
background: $highlightColor;
box-shadow: 0px $pixelWidth $borderColor, 0px $pixelWidth * 2 $shadowColor, $pixelWidth $pixelWidth $shadowColor;
}
&::before {
@extend %pixelsBottom;
left: $pixelWidth;
top: -$pixelWidth;
background: $highlightColor;
box-shadow: 0px $pixelWidth $borderColor, 0px $pixelWidth * 2 $shadowColor, $pixelWidthAlt $pixelWidth $shadowColor;
}
}
& .pixelsTop {
width: calc(100% + #{$pixelWidth * 4});
position: absolute;
left: -$pixelWidth * 2;
top: -$pixelWidth;
&::after {
@extend %pixelsTop;
right: $pixelWidth;
background: $borderColor;
}
&::before {
@extend %pixelsTop;
left: 3px;
background: $borderColor;
}
}
}
%box {
@include make_box(white, $pixelBorderColor, $pixelHighlightColor, $pixelShadowColor);
}
%box-orange {
@include make_box(#fcab0b, #e8861c, #fdbc3d, $pixelShadowColor);
}
%box-green {
@include make_box(#a5da60, #89b74c, #c4ed8e, $pixelShadowColor);
}
%box-red {
@include make_box(#df644c, #ba513d, #ea7f6a, $pixelShadowColor);
}
%box-grey {
@include make_box(#d1d1d1, #c4c4c4, #e0e0e0, $pixelShadowColor);
}
%box-purple {
@include make_box(#c557e1, #a848c0, #d77ded, $pixelShadowColor);
}
%box-blue {
@include make_box(#1e4b56, #16414c, #315962, $pixelShadowColor);
}
%box-twitter {
@include make_box(#55c6e2,#439db3, #94e5f9, $pixelShadowColor);
}
%button {
position: relative;
// overflow: hidden;
&:active {
transform: translateY(2px)
}
&::after {
content: '';
display: block;
width: 30px;
-webkit-filter: blur(24px);
height: 30px;
background: rgba(255, 255, 255, 0.3);
position: absolute;
height: 50px;
-webkit-transform: rotate(-30deg);
transform: rotate(-30deg) skewy(31deg);
color: white;
top: -5px;
right: 100%;
transition: all .4s;
}
&:hover {
&::after {
right: 0px;
}
}
}
.magic {
position: fixed;
left: 0;
right: 0;
margin: auto;
top: 50%;
transform: translateY(-50%);
z-index: 10;
width: 100%;
height: 100%;
background: black;
display: none;
img {
width: 100%;
}
}
// -----------------------------------------------------------------------------------------------------------------
.grain {
position: fixed;
top: 0;
left: 0;
z-index: 4;
pointer-events: none;
}
.swatch {
box-shadow: inset 3px 0 rgba(0, 0, 0, 0.1), inset -3px 0 rgba(255, 255, 255, 0.3) !important;
width: 12px !important;
height: 11px;
&.html {
background: #f1753f;
}
&.css {
background: #2965f1;
}
&.js {
background: #f3e273;
}
&.design {
background: #9d28e0;
}
}
/* Let's get this party started */
::-webkit-scrollbar {
width: 3px;
}
/* Track */
::-webkit-scrollbar-track {
background: transparent;
}
/* Handle */
::-webkit-scrollbar-thumb {
background: #cabcae;
}
.auto {
@extend %box;
text-align: left;
position: absolute;
bottom: -12px;
height: 6px;
z-index: 2;
line-height: 7px;
left: 0;
right: -480px;
margin: auto;
cursor: pointer;
width: 80px;
img {
width: 15px;
position: absolute;
right: 6px;
top: 7px;
}
&.off {
.tick {
display: none;
}
.cross {
display: block;
}
}
&.on {
.tick {
display: block;
}
.cross {
display: none;
}
}
}
.startMashing {
@extend %box;
text-align: center;
position: absolute;
bottom: 40px;
height: 160px; z-index: 2;
line-height: 160px;
left: 0;
right: 0;
margin: auto;
width: 500px;
h2 {
position: relative;
top: -13px;
img {
width: 20px;
position: absolute;
left: 0;
right: 0;
margin: auto;
top: 100px;
animation: key .3s linear infinite;
}
@keyframes key {
from{top: 100px;}
to{top: 102px;}
}
}
}
.researchButton {
@extend %box-green;
width: 203px;
color: #476323;
@extend %button;
float: left;
clear: left;
margin-top: 27px;
cursor: pointer;
&_counter {
@extend %box-green;
@extend %button;
right: -20px;
width: 30px;
color: #476323;
float: left;
text-align: center;
clear: left;
margin-top: 27px;
top: -55px;
height: 30px;
line-height: 31px;
cursor: pointer;
padding: 0px;
position: absolute;
z-index: 1;
}
img {
width: 4px * 3;
position: absolute;
top: 18px;
right: 18px;
}
}
.username {
@extend %box;
float: left;
padding: 8px 12px 0px 10px;
position: relative;
top: 30px;
img {
width: 15px * 3;
position: absolute;
left: -24px;
top: -36px;
}
}
.achievementsButton {
@extend %button;
@extend %box-purple;
width: 203px;
display: none;
color: #75168d;
float: left;
clear: left;
margin-top: 27px;
cursor: pointer;
img {
width: 4px * 3;
position: absolute;
top: 18px;
right: 18px;
}
}
.followButton {
@extend %button;
@extend %box-blue;
width: 203px;
color: #75168d;
float: left;
clear: left;
margin-top: 27px;
cursor: pointer;
color: #c4ebfd;
}
.date {
float: right;
position: absolute;
right: 40px;
top: 10px;
img {
width: 21px;
position: relative;
top: 2px;
}
}
.floor {
background: #e1dac5;
position: fixed;
bottom: 0;
height: 36%;
width: 100%;
left: 0;
z-index: -1;
border-top: 30px solid white;
}
.options{
position: absolute;
right: 34px;
top: 81px;
&_bg {
img {
width: 21px;
}
}
&_sf {
img {
width: 18px;
margin-right:10px;
}
}
div
{ float: left;
transition: all 1s;
cursor: pointer;
}
}
.overlay {
//display: none;
position: fixed;
left: 0;
top: 0;
width: 100%;
cursor: pointer;
height: 100%;
background: #675a4c;
z-index: 3;
opacity: 0.89;
// display: none;
}
.researchProgress {
@extend %box;
position: absolute;
left: 0;
right: 0;
margin: auto;
top: 50%;
width: 200px;
transform: translateY(-50%);
display: none;
.bar {
width: 100%;
height: 6px;
border-bottom: 3px solid #d6c9bc;
position: relative;
&_inner {
width: 0%;
height: 6px;
position: absolute;
left: 0;
background: #fcab0b;
box-shadow: 0px 3px inset #fdbc3d;
&.animate {
animation: bar 2s linear;
}
@keyframes bar {
from {
width: 0%;
}
to {
width: 100%
}
}
}
}
}
.endGame {
display: none;
@extend %box;
.mostName,
.mostViews {
font-weight: bold;
}
hr {
border: none;
width: 95%;
border-top: 3px solid #efedea;
margin-bottom: 30px;
box-shadow: 0 3px rgba(0, 0, 0, 0.02);
z-index: 2;
position: relative;
}
h3 {
text-align: center;
font-weight: normal;
font-size: 16px;
margin: 15px 24px 23px 24px;
}
h1 {
font-size: 41px;
margin-bottom: 15px;
color: #f8ab12;
margin-top: 19px;
}
//display: none;
text-align: center;
width: 600px;
height: 250px;
position : absolute !important;
z-index: 3;
left: 0;
right: 0;
margin: auto;
top: 50%;
transform: translateY(-50%);
padding: 40px;
text-align: ceter;
.restart {
@extend %box-green;
color: #476323;
position: absolute;
bottom: -26px;
width: 170px;
@extend %button;
text-align: center;
margin: auto;
left: 220px;
cursor: pointer;
right: 0;
}
.share {
@extend %box-twitter;
@extend %button;
color: #1c3940;
position: absolute;
bottom: -26px;
width: 170px;
text-align: center;
margin: auto;
left: -240px;
cursor: pointer;
right: 0;
}
&__header{
position: absolute;
left: 0;
right: 0;
margin: auto;
width: 282px;
top: -87px;
p {
position: absolute;
width: 100%;
text-align: center;
top: 71px;
color: #c4ebfd;
left: 4px;
}
img {
width: 94px * 3
}
}
}
.name_modal {
@extend %box;
//display: none;
text-align: center;
width: 600px;
transition: all 0.5s;
height: 250px;
hr {
border: none;
width: 95%;
border-top: 3px solid #efedea;
margin-bottom: -1px;
box-shadow: 0 3px rgba(0, 0, 0, 0.02);
z-index: 2;
position: relative;
}
h3 {
text-align: center;
font-weight: normal;
font-size: 16px;
margin: 15px 24px 23px 24px;
}
.text {
margin: 20px 0;
}
position : absolute !important;
z-index: 3;
left: 0;
right: 0;
margin: auto;
top: 50%;
transform: translateY(-50%);
padding: 40px;
text-align: center;
input {
font-family: pixles;
font-size: 16px;
font-weight: normal;
outline: none;
text-align: center;
padding: 19px;
width: 360px;
border-radius: 5px;
color: #352c22;
margin-top: 67px;
border: 3px solid #f0eeeb;
}
.next {
@extend %box-green;
color: #476323;
position: absolute;
bottom: -26px;
width: 140px;
@extend %button;
text-align: center;
margin: auto;
left: 0;
cursor: pointer;
right: 0;
}
&__header{
position: absolute;
left: 0;
right: 0;
margin: auto;
width: 282px;
top: -87px;
p {
position: absolute;
width: 100%;
text-align: center;
top: 71px;
color: #c4ebfd;
left: 4px;
}
img {
width: 94px * 3
}
}
}
.intro_modal {
@extend %box;
left: 200%;
text-align: center;
width: 600px;
height: 250px;
hr {
border: none;
width: 95%;
border-top: 3px solid #efedea;
margin-bottom: -1px;
box-shadow: 0 3px rgba(0, 0, 0, 0.02);
z-index: 2;
position: relative;
}
h3 {
text-align: center;
font-weight: normal;
font-size: 16px;
margin: 15px 24px 23px 24px;
}
.text {
margin: 20px 0;
}
position : absolute !important;
z-index: 3;
transition: all 0.5s;
right: 0;
margin: auto;
top: 50%;
transform: translateY(-50%);
padding: 40px;
text-align: center;
.go {
@extend %box-green;
color: #476323;
position: absolute;
bottom: -26px;
width: 140px;
@extend %button;
text-align: center;
margin: auto;
left: 0;
cursor: pointer;
right: 0;
}
&__header{
position: absolute;
left: 0;
right: 0;
margin: auto;
width: 282px;
top: -87px;
p {
position: absolute;
width: 100%;
text-align: center;
top: 71px;
color: #c4ebfd;
left: 4px;
}
img {
width: 94px * 3
}
}
}
.featured_modal {
@extend %box;
display: none;
text-align: center;
width: 600px;
height: 250px;
position : absolute !important;
z-index: 3;
left: 0;
right: 0;
margin: auto;
top: 50%;
transform: translateY(-50%);
padding: 40px;
text-align: left;
h3 {
text-align: center;
font-weight: normal;
font-size: 16px;
margin: 24px;
}
hr {
border: none;
border-top: 3px solid #efedea;
margin-bottom: 40px;
}
&__header{
position: absolute;
left: 0;
right: 0;
margin: auto;
width: 282px;
top: -87px;
p {
position: absolute;
width: 100%;
text-align: center;
top: 71px;
color: #c4ebfd;
left: 4px;
}
img {
width: 94px * 3
}
}
.name {
color: #29241f;
}
.picker {
color: orange;
}
&__text {
padding-top: 15px;
}
.awesome {
@extend %box-green;
color: #476323;
position: absolute;
bottom: -26px;
width: 140px;
@extend %button;
text-align: center;
margin: auto;
left: 0;
cursor: pointer;
right: 0;
}
&__image {
float: left;
margin-right: 30px;
img {
width: 66px * 3;
}
}
}
.research_modal {
@extend %box;
.hide {
display: none;
}
transition: all .7s;
width: 300px;
height: 40px;
display: none;
text-align: center;
position : absolute !important;
z-index: 3;
left: 0;
right: 0;
margin: auto;
top: 50%;
transform: translateY(-50%);
h3 {
text-align: center;
font-weight: normal;
font-size: 16px;
margin: 40px 24px 24px 24px;
}
hr {
border: none;
width: 95%;
border-top: 3px solid #efedea;
margin-bottom: -1px;
box-shadow: 0 3px rgba(0, 0, 0, 0.02);
z-index: 2;
position: relative;
}
&__header{
position: absolute;
left: 0;
right: 0;
margin: auto;
width: 282px;
top: -87px;
p {
position: absolute;
width: 100%;
text-align: center;
top: 67px;
color: #c4ebfd;
left: 1px;
}
img {
width: 94px * 3
}
}
.close {
@extend %box-red;@extend %button;
color: #892e1f;
cursor: pointer;
position: absolute;
right: -22px;
top: -22px;
width: 10px;
height: 10px;
z-index: 3;
line-height: 11px;
}
&::after {
position: fixed;
bottom: 15px;
left: 0;
width: 98%;
height: 40px;
display: block;
background: -webkit-linear-gradient(top, rgba(255,255,255,0) 0%,rgba(255,255,255,1) 100%);
content: '';
}
&__list {
padding: 1px 20px 20px 20px;
overflow-y: scroll;
height: 288px;
position: relative;
}
& .item {
float: left;
clear: left;
border-top: 3px solid #f2f2f2;
padding: 24px 0px 21px 0px;
width: 95%;
position: relative;
left: 11px;
&:first-child {
border: none;
}
&.unavailable {
.research_button {
@extend %box-red;
color: #782e1f;
}
}
&.researched {
&::after {
display: block;
position: absolute;
right: -16px;
top: 6px;
content: url(https://s3-us-west-2.amazonaws.com/s.cdpn.io/217233/rTick.png);
}
.name,
.stat{
opacity: 0.45;
}
.research_button {
@extend %box-grey;
color: #959595;
}
}
}
.sep {
margin: 0 6px;
}
.name {
float: left;
}
.green {
color: #89b74c;
}
.stat {
float: left;
img {
width: 6px;
margin-left: 4px;
}
}
.research_button {
@extend %button;
@extend %box-green;
right: 0px;
color: #476323;
float: right;
cursor: pointer;
top: -6px;
padding: 4px !important;
float: right;
position: absolute !important;
top: 18px;
width: 150px;
img {
width: 5px * 2;
position: relative;
left:-4px
}
.cost {
color: white;
}
}
}
.complete_modal {
.swatch {
position: relative;
left: 49px;
top: 3px;
}
@extend %box;
display: none;
opacity: 0;
text-align: center;
transition: all .7s;
width: 300px;
height: 40px;
position : absolute !important;
z-index: 3;
left: 0;
right: 0;
margin: auto;
top: 50%;
transform: translateY(-50%);
h4 {
font-weight: normal;
font-size: 16px;
}
div.hide {
display: none;
}
&__header {
position: absolute;
left: 0;
right: 0;
margin: auto;
width: 282px;
top: -87px;
p {
position: absolute;
width: 100%;
text-align: center;
top: 68px;
color: #c4ebfd;
left: 1px;
}
img {
width: 94px * 3
}
}
.scrap {
@extend %button;
@extend %box-red;
position: absolute;
bottom: 0;
text-align: left;
width: 240px;
bottom: -25px;
color: #782e1f;
cursor: pointer;
left: 30px;
img{
width: 15px;
float: right;
position: relative;
top: 1px;
}
}
hr {
border: none;
border-top: 3px solid #efedea;
margin-bottom: 20px;
margin-top: 22px;
width: 60%;
}
h2 {
margin: 20px 0 6px 0;
}
.release {
@extend %button;
@extend %box-green;
cursor: pointer;color: #476323;
position: absolute;
bottom: 0;
width: 240px;
right:30px;
bottom: -25px;
img{
width: 18px;
float: right;
position: relative;
top: 6px;
}
}
h3 {
font-size: 16px;
font-weight: normal;
margin: 30px 0;
}
&__stats {
.html {
img {
width: 48px;
margin-top: -5px;
}
}
.css {
img {
width: 48px;
margin-top: -5px;
}
}
.js {
img {
width: 48px;
margin-top: -5px;
}
}
.design {
img {
width: 36px;
margin-top: -5px;
}
}
div {
float: left;
text-align: center;
width: 25%;
box-shadow: inset -3px 0px #f1ebe4;
&:last-child {
box-shadow: none;
}
span {
display: block;
margin-top: 17px;
position: relative;
left: 4px;
}
}
}
}
.make {
@extend %box;
position: absolute !important;
left: 0;
right: 0;
width: 200px;
margin: auto;
bottom: 40px;
border: none;
cursor: pointer;
outline: none;
}
body {
background: url('https://s3-us-west-2.amazonaws.com/s.cdpn.io/217233/gBg.png');
color: #594c3d;
margin: 50px;
// height: 100vh;
overflow: hidden;
}
img {
image-rendering: auto;
image-rendering: crisp-edges;
image-rendering: pixelated;
}
img.m {
position: absolute;
left: 0;
right: 0;
margin: auto;
top: 50%;
left: -40px;
transform: translateY(-50%);
width: 252px * 3;
}
.followers {
@extend %box-orange;
color: #9b5c19;
float: right;
transform: translateX(calc(100% + -3px));
right: 0;
z-index:3;
bottom: 12px;
position: absolute !important;
padding: 13px 50px !important;
span {
color: #fff;
}
img {
width: 42px;
left: -25px;
top: -18px;
z-index: 2;
position: absolute;
}
}
h2 {
font-weight: normal;
margin:0 0 6px 0;
font-size: 16px;
}
body,
button {
font-family: pixles;
text-transform: uppercase;
font-size: 16px;
line-height: 20px;
-webkit-user-select: none; /* Chrome all / Safari all */
-moz-user-select: none; /* Firefox all */
-ms-user-select: none; /* IE 10+ */
user-select: none; /* Likely future */
}
.pen {
height: 52px;
//display: none;
@extend %box;
&_bar {
width: 100%;
height: 6px;
border-bottom: 3px solid #d6c9bc;
position: relative;
&_progress {
width: 0%;
height: 6px;
position: absolute;
left: 0;
background: #fcab0b;
box-shadow: 0px 3px inset #fdbc3d;
}
}
}
.mystats {
@extend %box;
margin-top: 110px;
float: left;
padding: 30px;
clear: left;
img {
width: 15px * 3;
position: absolute;
left: -24px;
top: -24px;
z-index: 1;
}
.pixelsBottom,
.pixelsTop {
width: calc(100% + -4px);
}
& .swatch {
width: 12px;
height: 11px;
position: relative;
top: 3px;
left: -16px;
margin-right: 6px;
padding: 0;
float: left;
margin-right: -10px
}
div {
padding-left: 16px;
}
&_html {
clear: left;
& .swatch {
background: #f1753f;
}
}
&_css {
clear: left;
& .swatch {
background: #2965f1;
}
}
&_js {
clear: left;
& .swatch {
background: #f3e273;
}
}
&_design {
clear: left;
& .swatch {
background: #9d28e0;
}
}
h2 {
border-bottom: 3px solid #d6c9bc;
float: left;
margin-bottom: 16px;
}
span.val {
display: inline-block;
position: relative;
left: -8px;
color: #594c3d;
}
span {
color: #d6c9bc;
}
}
p {
margin: 0;
}
.pip {
@extend %box;
background: white;
position: absolute;
left: 0;
line-height: 0px;
right: 0;
margin: auto;
text-align: center;
width: 30px;
padding: 11px 7px 2px 7px;
height: 10px;
top: 50%;
}
.sep {
display: inline-block;
width: 2px;
height: 10px;
background: #d6c9bc;
}
.releasedEmpty {
@extend %box;
clear: both;
float: right;
margin-top: 249px;
height: 60px;
line-height: 61px;
position: absolute;
right: 53px;
width: 303px;
}
.pen {
position: absolute;
left: 0;
right: 0;
margin: auto;
width: 728px;
& .swatch {
width: 12px;
height: 11px;
position: relative;
top: 3px;
margin-left: 2px;
float: left;
margin-right: -10px;
}
&_html {
& .swatch {
background: #f1753f;
}
}
&_css {
& .swatch {
background: #2965f1;
}
}
&_js {
& .swatch {
background: #f3e273;
}
}
&_design {
& .swatch {
background: #9d28e0;
}
}
&_html,
&_css,
&_js,
&_design {
@extend %box;
float: left;
position: relative;
top: 18px;
margin-right: 27px;
padding: 3px;
width: 149px;
left: 13px;
text-align: center;
}
}
.releasedHeader {
@extend %box-blue;
float: right;
color: #c4ebfd;
position: absolute;
margin-top: 195px;
top: 15px;
right: 194px;
img.icon {
width: 7px * 3;
top: 4px;
position: relative;
}
img.arrow {
width: 2px * 3;
top: 0px;
position: relative;
}
}
.released {
clear: both;
float: right;
margin-top: 228px;
height: 420px;
overflow: scroll;
padding: 0px 40px 20px 6px;
position: relative;
left: 20px;
width: 310px;
overflow-x: hidden;
border-top: 3px solid #bfaf9d;
&::after {
display: block;
content: '';
position: fixed;
right: 0;
top: 641px;
background: -webkit-linear-gradient(top, rgba(0, 0, 0, 0) 10%, rgba(225, 218, 197, 01) 100%);
width: 390px;
height: 80px;
z-index: 2;
}
&_pen {
transition: all 1s;
float: left;
clear: left;
margin-top: 17px;
height:0;
&__top {
@extend %box;
z-index:2;
height: 66px;
padding: 10px;
}
&__bottom {
@extend %box;
height: 20px;
top:-72px;
transition: all 1s;
padding-top:30px;
width: calc(100% - 48px);
left: 12px;
.sep {
margin: 0 9px;
}
img {
margin-right: 6px;
position: relative;
}
img.views {
width: 7px * 3;
top: 2px;
}
img.likes {
width: 5px * 3;
top: 3px;
}
img.comments {
width: 6px * 3;
top: 3px;
}
}
.star{
position: absolute;
right: 10px;
top: 9px;
img {
width: 15px;
}
}
&__graph {
height: 34px;
position: relative;
width: 300px;
border-left: $pixelWidth solid #e7e7e7;
border-bottom: $pixelWidth solid #e7e7e7;
margin: 8px 0;
& .line {
width: 10px;
height: 40px;
max-height: 34px;
float: left;
//min-height: 4px;
position: relative;
bottom: 0;
background: #ff992c;
}
}
}
}
bg = new Audio('https://s3-us-west-2.amazonaws.com/s.cdpn.io/217233/bgG.mp3');
buttonClick = new Audio('https://s3-us-west-2.amazonaws.com/s.cdpn.io/217233/Buttonclick.mp3');
featured = new Audio('https://s3-us-west-2.amazonaws.com/s.cdpn.io/217233/featured.mp3');
slideSlow = new Audio('https://s3-us-west-2.amazonaws.com/s.cdpn.io/217233/slideSlow.mp3');
countStats = new Audio('https://s3-us-west-2.amazonaws.com/s.cdpn.io/217233/Countupstats.mp3');
researchClick = new Audio('https://s3-us-west-2.amazonaws.com/s.cdpn.io/217233/researchClick.mp3');
researchInactive = new Audio('https://s3-us-west-2.amazonaws.com/s.cdpn.io/217233/researchInactive.mp3');
slideFast = new Audio('https://s3-us-west-2.amazonaws.com/s.cdpn.io/217233/slideFast.mp3');
featuredModal = new Audio('https://s3-us-west-2.amazonaws.com/s.cdpn.io/217233/featuredModal.mp3');
researchComplete = new Audio('https://s3-us-west-2.amazonaws.com/s.cdpn.io/217233/researchComplete.mp3');
const penProgressEl = $('.pen');
const statAddSounds = []
for(i = 0; i < 10; i++) {
let a = new Audio('https://s3-us-west-2.amazonaws.com/s.cdpn.io/217233/statAdd.mp3');
statAddSounds.push(a)
}
function twShare(url, title, winWidth, winHeight) {
const winTop = 100;
const winLeft = 100;
window.open(`https://twitter.com/intent/tweet?text=${title}`, 'sharer', `top=${winTop},left=${winLeft},toolbar=0,status=0,width=${winWidth},height=${winHeight}`);
}
pen_id = $('._pen_id').text();
$('body').on('click', '.share', () => {
twShare(`https://codepen.io/jcoulterdesign/full/a1b3ea524ead4700015153bb95b881c3`, `I managed to get ${developer.followers.toLocaleString()} followers on the Codepen Simulator Game by @jamiecoulter89. https://bit.ly/2LyxS71 %23codepenSimGame`, 520, 350);
return false;
});
function updateMyStatsUi() {
$('.mystats_css span.val').html(developer.css.toLocaleString());
$('.mystats_html span.val').html(developer.html.toLocaleString());
$('.mystats_js span.val').html(developer.js.toLocaleString());
$('.mystats_design span.val').html(developer.design.toLocaleString());
}
const globals = {
'timerTick' : 120,
'keyTick' : 110,
'penStatAddChance' : 4,
'typeIncrement' : 1.1,
'makingPen' : true,
'penInProgress' : false,
'viewDecay' : 1.1,
'maxBars' : 30,
'followerFriction' : 50,
'viewMultiplier' : 1.15,
'researchTime' : 2000,
'researching' : false,
'featuredMinStats' : 500,
'featuredBoost' : 3.1,
'featureChance' : 10,
'paused' : true,
'gameLength' : 365,
'audio' : true,
'auto' : false
}
const penNames = [
'Swanky text inputs',
'Three.js Interactive Unicorn',
'Overly animated login box',
'Yet another CSS grid',
'Pure CSS Widget',
'Pure CSS illustration',
'Persistant cookie policy modal',
'Overly complex 3D menu',
'I could not stop',
'Music player widget',
'Codepen Simulation game',
'Gross color combinations',
'JS scratch and sniff',
'Canvas and audio api thingy',
'Giant animated cat',
'Password strength indicator',
'One element RPG game',
'Pure CSS MMORPG',
'Something with Google Maps',
'Responsive responsivity checker',
'Kill the King',
'Pure CSS backend',
'Procedurally generated cupcakes',
'Unsubmittable form',
'Never ending loading bar',
'Invisible check boxes',
'HTML Scrolling marquee',
'Directly injected CSS',
'No element element',
'Three.JS Shooter game',
'SVG animations',
'Codepen challenge',
'Pass the pen',
'Edible code',
'React calendar widget',
'Square div that look round',
'Netscape compatible CSS game',
'Another User Interface',
'Self learning AI in CSS',
'HTML alternative',
'Codepenception'
]
const research = [
{
'index' : 1,
'name' : 'Learn basic HTML',
'cost' : 10,
'increaseCss' : 0,
'increaseJs' : 0,
'increaseHtml' : 10,
'increaseDesign' : 0,
'researched' : false
},{
'index' : 2,
'name' : 'Learn basic CSS',
'cost' : 20,
'increaseCss' : 10,
'increaseJs' : 0,
'increaseHtml' : 0,
'increaseDesign' : 0,
'researched' : false
},{
'index' : 3,
'name' : 'Learn basic JS',
'cost' : 30,
'increaseCss' : 0,
'increaseJs' : 10,
'increaseHtml' : 0,
'increaseDesign' : 0,
'researched' : false
},{
'index' : 4,
'name' : 'Learn basic Design',
'cost' : 50,
'increaseCss' : 0,
'increaseJs' : 0,
'increaseHtml' : 0,
'increaseDesign' : 10,
'researched' : false
},{
'index' : 5,
'name' : 'Find inspiration',
'cost' : 100,
'increaseCss' : 10,
'increaseJs' : 10,
'increaseHtml' :10,
'increaseDesign' : 15,
'researched' : false
},{
'index' : 6,
'name' : 'Learn HAML',
'cost' : 150,
'increaseCss' : 0,
'increaseJs' : 0,
'increaseHtml' : 15,
'increaseDesign' : 0,
'researched' : false
},{
'index' : 7,
'name' : 'Learn CSS animation',
'cost' : 200,
'increaseCss' : 15,
'increaseJs' : 0,
'increaseHtml' : 0,
'increaseDesign' : 0,
'researched' : false
},{
'index' : 8,
'name' : 'Learn jQuery',
'cost' : 300,
'increaseCss' : 0,
'increaseJs' : 15,
'increaseHtml' : 0,
'increaseDesign' : 0,
'researched' : false
},{
'index' : 9,
'name' : 'Learn color theory',
'cost' : 400,
'increaseCss' : 0,
'increaseJs' : 0,
'increaseHtml' : 0,
'increaseDesign' : 15,
'researched' : false
},{
'index' : 10,
'name' : 'Learn how to refactor',
'cost' : 600,
'increaseCss' : 15,
'increaseJs' : 20,
'increaseHtml' : 10,
'increaseDesign' : 0,
'researched' : false
},{
'index' : 11,
'name' : 'Learn BEM',
'cost' : 800,
'increaseCss' : 0,
'increaseJs' : 0,
'increaseHtml' : 20,
'increaseDesign' : 0,
'researched' : false
},{
'index' : 12,
'name' : 'Read CSS Tricks articles',
'cost' : 1150,
'increaseCss' : 20,
'increaseJs' : 0,
'increaseHtml' : 0,
'increaseDesign' : 0,
'researched' : false
},{
'index' : 13,
'name' : 'Learn ES6',
'cost' : 1400,
'increaseCss' : 0,
'increaseJs' : 20,
'increaseHtml' : 0,
'increaseDesign' : 0,
'researched' : false
},{
'index' : 14,
'name' : 'Memorise font names',
'cost' : 1800,
'increaseCss' : 0,
'increaseJs' : 0,
'increaseHtml' : 0,
'increaseDesign' : 20,
'researched' : false
},
{
'index' : 15,
'name' : 'Watch youtube tutorials',
'cost' : 2200,
'increaseCss' : 10,
'increaseJs' : 10,
'increaseHtml' : 10,
'increaseDesign' : 10,
'researched' : false
},{
'index' : 16,
'name' : 'Learn HTML6',
'cost' : 2700,
'increaseCss' : 0,
'increaseJs' : 0,
'increaseHtml' : 25,
'increaseDesign' : 0,
'researched' : false
},{
'index' : 17,
'name' : 'Learn pre-processors',
'cost' : 3200,
'increaseCss' : 25,
'increaseJs' : 0,
'increaseHtml' : 0,
'increaseDesign' : 0,
'researched' : false
},{
'index' : 18,
'name' : 'Learn react',
'cost' : 3800,
'increaseCss' : 0,
'increaseJs' : 25,
'increaseHtml' : 0,
'increaseDesign' : 0,
'researched' : false
},{
'index' : 19,
'name' : 'Photoshop course',
'cost' : 4500,
'increaseCss' : 0,
'increaseJs' : 0,
'increaseHtml' : 0,
'increaseDesign' : 25,
'researched' : false
},{
'index' : 20,
'name' : 'Browse Awwwards',
'cost' : 5200,
'increaseCss' : 10,
'increaseJs' : 10,
'increaseHtml' : 10,
'increaseDesign' : 25,
'researched' : false
},{
'index' : 21,
'name' : 'Browse stack overflow',
'cost' : 6000,
'increaseCss' : 15,
'increaseJs' : 15,
'increaseHtml' : 15,
'increaseDesign' : 10,
'researched' : false
},{
'index' : 22,
'name' : 'Learn angular',
'cost' : 6600,
'increaseCss' : 0,
'increaseJs' : 25,
'increaseHtml' : 0,
'increaseDesign' : 0,
'researched' : false
},{
'index' : 23,
'name' : 'Learn VR technology',
'cost' : 7500,
'increaseCss' : 0,
'increaseJs' : 30,
'increaseHtml' : 0,
'increaseDesign' : 0,
'researched' : false
},{
'index' : 24,
'name' : 'Experiment with latest tech',
'cost' : 9000,
'increaseCss' : 20,
'increaseJs' : 20,
'increaseHtml' : 20,
'increaseDesign' : 10,
'researched' : false
},{
'index' : 25,
'name' : 'take a html master class',
'cost' : 11000,
'increaseCss' : 0,
'increaseJs' : 0,
'increaseHtml' : 60,
'increaseDesign' : 0,
'researched' : false
},{
'index' : 26,
'name' : 'take a CSS master class',
'cost' : 12000,
'increaseCss' : 60,
'increaseJs' : 0,
'increaseHtml' : 0,
'increaseDesign' : 0,
'researched' : false
},{
'index' : 27,
'name' : 'take a JS master class',
'cost' : 13000,
'increaseCss' : 0,
'increaseJs' : 60,
'increaseHtml' : 0,
'increaseDesign' : 0,
'researched' : false
},{
'index' : 28,
'name' : 'take a DESIGN master class',
'cost' : 14000,
'increaseCss' : 0,
'increaseJs' : 0,
'increaseHtml' : 0,
'increaseDesign' : 60,
'researched' : false
},{
'index' : 29,
'name' : 'dO SOME CODE ACADEMY',
'cost' : 15000,
'increaseCss' : 30,
'increaseJs' : 30,
'increaseHtml' : 30,
'increaseDesign' : 20,
'researched' : false
}
]
research.forEach(function(r) {
$('.research_modal__list').append(`
<div class="item">
<div class="name">${r.name}<div class="sep"></div></div>
<div class="stat">
${r.increaseHtml > 0 ? `html <span class="green">+ ${r.increaseHtml}<img src="https://s3-us-west-2.amazonaws.com/s.cdpn.io/217233/arrowUpStat.png"/></span><div class="sep"></div>` : ''}
${r.increaseCss > 0 ? `css <span class="green">+ ${r.increaseCss}<img src="https://s3-us-west-2.amazonaws.com/s.cdpn.io/217233/arrowUpStat.png"/></span><div class="sep"></div>` : ''}
${r.increaseJs > 0 ? `js <span class="green">+ ${r.increaseJs}<img src="https://s3-us-west-2.amazonaws.com/s.cdpn.io/217233/arrowUpStat.png"/></span><div class="sep"></div>` : ''}
${r.increaseDesign > 0 ? `design <span class="green">+ ${r.increaseDesign}<img src="https://s3-us-west-2.amazonaws.com/s.cdpn.io/217233/arrowUpStat.png"/></span><div class="sep"></div>` : ''}
<div class="research_button" data-index="${r.index}"><div class="pixelsTop"></div>
<div class="pixelsBottom"></div>Research <img src="https://s3-us-west-2.amazonaws.com/s.cdpn.io/217233/rCost.png" /><span class="cost">${r.cost.toLocaleString()}</div></div>
</div>`)
})
$('.auto').click(function(){
playSound(buttonClick);
if(globals.auto) {
$(this).removeClass('on');
$(this).addClass('off');
globals.auto = false;
} else {
$(this).removeClass('off');
$(this).addClass('on');
globals.auto = true;
}
})
$('.researchButton').click(function() {
if(!globals.researching) {
globals.paused = true;
$('.overlay, .research_modal').show();
playSound(buttonClick);
playSound(slideFast);
$('.research_modal').show();
setTimeout(function() {
$('.research_modal').css('opacity', '1');
},300)
$('.overlay').fadeIn(function() {
setTimeout(function() {
$('.research_modal').css('height' , '400px');
$('.research_modal').css('width' , '920px');
setTimeout(function() {
$('.research_modal .hide').fadeIn();
}, 400)
},100)
});
} else {
playSound(researchInactive);
}
$('.research_modal .item').each(function() {
let index = $(this).find('.research_button').data('index') - 1;
if(developer.followers >= research[index].cost && research[index].researched == false) {
$(this).addClass('available')
$(this).removeClass('unavailable')
$(this).removeClass('researched')
}
if(developer.followers < research[index].cost && research[index].researched == false) {
$(this).addClass('unavailable')
$(this).removeClass('available')
$(this).removeClass('researched')
}
if(research[index].researched == true) {
$(this).addClass('researched')
$(this).removeClass('available')
$(this).removeClass('unavailable')
}
})
})
audioSwitch = 0;
sfxSwitch = 0;
$('.options_sf').click(function() {
if(sfxSwitch == 0) {
globals.audio = false;
sfxSwitch = 1;
$(this).css('opacity','0.4');
} else {
globals.audio = true;
sfxSwitch = 0;
$(this).css('opacity','1');
}
});
$('.options_bg').click(function() {
if(audioSwitch == 0) {
$(bg).animate({volume: 0}, 600);
audioSwitch = 1;
$(this).css('opacity','0.4')
} else {
$(bg).animate({volume: 1}, 600);
audioSwitch = 0;
$(this).css('opacity','1')
}
})
$('.research_modal .close').click(function() {
playSound(buttonClick)
$('.research_modal').css('opacity', '0');
setTimeout(function(){
$('.overlay').fadeOut();
},450)
setTimeout(function(){
$('.research_modal').attr('style', '');
$('.research_modal .hide').attr('style', '');
},1000)
globals.paused = false;
})
$('body').on('click', '.research_button', function() {
globals.paused = false;
let r = $(this).data('index') - 1;
let stat = research[r].stat;
let increaseCss = research[r].increaseCss;
let increaseJs = research[r].increaseJs;
let increaseHtml = research[r].increaseHtml;
let increaseDesign = research[r].increaseDesign;
if(developer.followers > research[r].cost && research[r].researched == false && !globals.researching) {
globals.researching = true;
$('.overlay, .research_modal').fadeOut();
$('.researchProgress').show();
$('.researchProgress').show()
playSound(researchClick)
rp = setInterval(function(){
$('.bar_inner').addClass('animate')
},1)
setTimeout(function() {
clearInterval(rp)
developer.css += increaseCss
developer.js += increaseJs
developer.html += increaseHtml
developer.design += increaseDesign
research[r].researched = true;
$('.researchProgress').hide()
globals.researching = false;
playSound(researchComplete)
updateMyStatsUi();
}, globals.researchTime)
} else {
playSound(researchInactive)
}
})
const statColors = {
'html' : '#f16529',
'css' : '#2965f1',
'js' : '#d87b17',
'design' : '#9d28e0'
}
var developer = {
'name' : 'Jamie',
'level' : 1,
'html' : 3,
'css' : 3,
'js' : 3,
'design' : 3,
'followers' : 0
}
var pen = {
'name' : 'Pen',
'css' : 0,
'html' : 0,
'js' : 0,
'design': 0
}
var pens = [];
updateMyStatsUi()
document.addEventListener("keyup", keyPress, false);
var progress = 0;
kS = 0;
function keyPress() {
if(progress > 0) {
$('.startMashing h2 span').html("that's it, keep going")
}
if(progress > 20) {
$('.startMashing h2 span').html("Now we are getting somewhere")
}
if(progress > 40) {
$('.startMashing h2 span').html("iron out those bugs")
}
if(progress > 70) {
$('.startMashing h2 span').html("Almost finished")
}
if(progress > 99) {
$('.startMashing h2 span').html("done!")
}
if(globals.makingPen && progress < 100 ) {
if(!globals.researching && !globals.paused) {
progress += globals.typeIncrement
$('.pen_bar_progress').width(progress + '%');
// Create a random number between 0 and the penStatChance variable
let add = Math.floor(Math.random() * globals.penStatAddChance) + (globals.penStatAddChance - 2);
if(add == globals.penStatAddChance) {
// Each keystroke, IF random check passes, pick a number between 1 and 3
let stat = Math.floor(Math.random() * 4) + 1;
if(kS < statAddSounds.length - 1) {
kS++
} else {
kS = 0
}
playSound(statAddSounds[kS])
// Assign a stat based on the integer
if(stat == 1) {
let htmlStat = Math.floor(Math.random() * developer.html) + 1;
pen.html = pen.html + htmlStat;
makePip(statColors.html, htmlStat, 'html');
}
if(stat == 2) {
let cssStat = Math.floor(Math.random() * developer.css) + 1;
pen.css = pen.css + cssStat;
makePip(statColors.css, cssStat, 'css');
}
if(stat == 3) {
let jsStat = Math.floor(Math.random() * developer.js) + 1;
pen.js = pen.js + jsStat;
makePip(statColors.js, jsStat, 'js');
}
if(stat == 4) {
let designStat = Math.floor(Math.random() * developer.design) + 1;
pen.design = pen.design + designStat;
makePip(statColors.design, designStat, 'design');
}
}
updateStatUi();
}
} else {
$('.complete_modal').show();
playSound(featured)
setTimeout(function(){
playSound(slideFast)
},400)
setTimeout(function(){
$('.complete_modal').css('opacity', '1')
},300)
$('.overlay').fadeIn(function(){
setTimeout(function(){
$('.complete_modal').css('height' , '370px')
$('.complete_modal').css('width' , '600px')
setTimeout(function(){
$('.complete_modal div.hide').fadeIn();
}, 300)
},100)
});
$('.complete_modal .html span span').html(pen.html)
$('.complete_modal .css span span').html(pen.css)
$('.complete_modal .js span span').html(pen.js)
$('.complete_modal .design span span').html(pen.design)
globals.paused = true;
}
}
function updateStatUi() {
$('.pen_css span.val').html(pen.css.toLocaleString());
$('.pen_html span.val').html(pen.html.toLocaleString());
$('.pen_js span.val').html(pen.js.toLocaleString());
$('.pen_design span.val').html(pen.design.toLocaleString());
}
$('.make').click(function() {
globals.makingPen = true;
penProgressEl.show();
$('.make').hide();
});
function makePip(stat, int, type) {
$('body').append(`<div class="pip" data-type="${type}"><div class="pixelsTop"></div><div class="pixelsBottom"></div><p style="color:${stat};">${int}</p></div>`);
}
$('.release').click(function() {
playSound(buttonClick)
release(pen)
globals.paused = false;
playSound(slideSlow)
})
$('.scrap').click(function(){
playSound(buttonClick)
globals.paused = false;
$('.startMashing h2 span').html("start pressing keys")
$('.complete_modal').fadeOut();
setTimeout(function(){
$('.overlay').fadeOut()
}, 450)
progress = 0;
$('.pen_bar_progress').width(0);
pen.css = 0;
pen.html = 0;
pen.js = 0;
pen.design = 0;
setTimeout(function(){
$('.complete_modal').attr('style', '');
$('.complete_modal div').attr('style', '');
},2000)
updateStatUi();
})
function release(p) {
$('.startMashing h2 span').html("start pressing keys")
progress = 0;
$('.releasedEmpty').remove()
$('.overlay').fadeOut();
$('.complete_modal').css('height','61px')
$('.complete_modal').css('width','299px')
$('.complete_modal').css( 'top', '298px')
$('.complete_modal').css( 'left', '100%')
$('.complete_modal').css( 'transform', 'translateX(calc(-100% - 57px))')
setTimeout(function(){
$('.released_pen').css('height', '150px')
},210)
setTimeout(function(){
$('.released_pen').css('opacity', '1');
$('.released_pen__bottom').css('top','-10px')
},510)
setTimeout(function(){
$('.complete_modal').css('opacity', '0');
},850)
setTimeout(function(){
$('.complete_modal').attr('style', '');
$('.complete_modal div').attr('style', '');
},2000)
$('.complete_modal div').css('opacity', '0')
let name = Math.floor(Math.random() * penNames.length);
let newPen = {
'name' : penNames[name],
'css' : p.css,
'html' : p.html,
'js' : p.js,
'design' : p.design,
'views' : 0,
'maxViews' : ((Math.ceil((p.css + p.js + p.html + p.design) * globals.viewMultiplier) + 1) * (pens.length + 1 / 35)),
'dailyViews' : ((Math.ceil((p.css + p.js + p.html + p.design) * globals.viewMultiplier) + 1) * (pens.length + 1/ 35)),
'comments' : 0,
'likes' : 0,
'featured' : false,
'featuredBoosted' : false,
'featuredCheck' : false,
'featuredCheckCount' : 0
}
pens.push(newPen);
$('.pen_bar_progress').width(0);
pen.css = 0;
pen.html = 0;
pen.js = 0;
pen.design = 0;
updateStatUi();
setTimeout(function(){
$('.released').prepend(`<div class="released_pen" style="opacity:0"><div class="released_pen__top"><div class="pixelsTop"></div><div class="pixelsBottom"></div><span class="name">${pens[pens.length - 1].name}</span><div class="star"></div><div class="released_pen__graph"></div></div><div class="released_pen__bottom"><div class="pixelsTop"></div><div class="pixelsBottom"></div><img class="views" src="https://s3-us-west-2.amazonaws.com/s.cdpn.io/217233/codepenViews.png" /><span class="view_count">${pens[pens.length - 1].views}</span><div class="sep"></div><img class="likes" src="https://s3-us-west-2.amazonaws.com/s.cdpn.io/217233/codepenLikes.png" /><span class="like_count"> ${pens[pens.length - 1].likes}</span><div class="sep"></div><img class="comments" src="https://s3-us-west-2.amazonaws.com/s.cdpn.io/217233/codepenComments.png" /><span class="comment_count"> ${pens[pens.length - 1].comments}</span></div></div>`)
}, 1)
}
const monthNames = ["January", "February", "March", "April", "May", "June",
"July", "August", "September", "October", "November", "December"
];
var time = 0;
const rootStatElementPosition = {
'design' : '550px',
'html' : '-550px',
'css' : '-176px',
'js' : '180px'
}
const pickers = [
'marie mosely',
'tim holman',
'chris coyier',
'codepen',
'jamie coulter',
'stephen shaw'
]
d = 0;
$('.awesome').click(function(){
playSound(buttonClick)
$('.overlay, .featured_modal').fadeOut();
globals.paused = false;
})
function feature(penName) {
globals.paused = true;
$('.overlay, .featured_modal').show();
let p = Math.floor(Math.random() * pickers.length);
$('.featured_modal .picker').html(pickers[p])
$('.featured_modal .name').html(penName)
}
function gameLoop() {
if(d == globals.gameLength) {
globals.paused = true;
$('.endGame, .overlay').show()
$('.pencount').html(pens.length + ' ')
let bestPen = '';
if(pens.length > 1) {
for(let i = 0; i < pens.length; i++) {
if(pens[i + 1]) {
if(pens[i + 1].views > pens[i].views) {
bestPen = pens[i + 1]
}
}
}
} else {
bestPen = pens[0]
}
$('.mostName').html(bestPen.name)
$('.mostViews').html(Math.ceil(bestPen.views).toLocaleString())
globals.paused = true;
}
if(!globals.paused){
time++;
$('.researchButton_counter span').html($('.available').length)
$('.pip').each(function() {
if($(this).data('type') == 'html') {
$(this).animate({ left: rootStatElementPosition.html, top: '140px' }, 2000, function(){
$(this).remove();
});
}
if($(this).data('type') == 'css') {
$(this).animate({ left: rootStatElementPosition.css, top: '140px' }, 1000, function(){
$(this).remove();
});
}
if($(this).data('type') == 'js') {
$(this).animate({ left: rootStatElementPosition.js, top: '140px' }, 1000, function(){
$(this).remove();
});
}
if($(this).data('type') == 'design') {
$(this).animate({ left: rootStatElementPosition.design, top: '140px' }, 1000, function(){
$(this).remove();
});
}
})
if(globals.auto && !globals.researching && !globals.paused) {
if(time > globals.keyTick) {
keyPress()
}
}
if(time > globals.timerTick) {
time = 0;
d++;
var day = new Date();
var nextDay = new Date(day);
nextDay.setDate(day.getDate() + d);
let month = nextDay.getUTCMonth();
let days = nextDay.getDate();
let year = nextDay.getFullYear();
$('.date span').html(`${monthNames[month]} ${days}, ${year}`)
$('.research_modal .item').each(function() {
let index = $(this).find('.research_button').data('index') - 1;
if(developer.followers > research[index].cost && research[index].researched == false) {
$(this).addClass('available')
$(this).removeClass('unavailable')
$(this).removeClass('researched')
}
if(developer.followers < research[index].cost && research[index].researched == false) {
$(this).addClass('unavailable')
$(this).removeClass('available')
$(this).removeClass('researched')
}
if(research[index].researched == true) {
$(this).addClass('researched')
$(this).removeClass('available')
$(this).removeClass('unavailable')
}
})
$('.released_pen').each(function() {
let index = pens.length - $(this).index() - 1;
let height = Math.ceil(pens[index].dailyViews / pens[index].maxViews * 100);
if(pens[index].featured) {
$(this).find('.star').html('<img src="https://s3-us-west-2.amazonaws.com/s.cdpn.io/217233/gStar.png" />')
}
if(height > 100) {
$(this).find('.released_pen__graph').append(`<div class="line" style="height:${height}%; top:${0}%"></div>`);
} else {
$(this).find('.released_pen__graph').append(`<div class="line" style="height:${height}%; top:${100 - height}%"></div>`);
}
let el = $(this);
if(el.find('.line').length > globals.maxBars) {
el.find('.line:first-child').remove();
}
let final = Math.ceil(pens[index].views).toLocaleString();
$(this).find('.view_count').html(final);
let comment = Math.ceil(pens[index].comments).toLocaleString();
$(this).find('.comment_count').html(comment);
let like = Math.ceil(pens[index].likes).toLocaleString();
$(this).find('.like_count').html(like);
});
var dailyFollowers = 0;
pens.forEach(function(p) {
if(p.css + p.html + p.css + p.design > globals.featuredMinStats) {
let f = Math.floor(Math.random() * globals.featureChance);
if(f == 0 && !p.featuredCheck){
if(p.featuredCheckCount < 14) {
p.featured = true;
}
} else {
p.featuredCheckCount++;
}
}
if(p.featured && !p.featuredBoosted) {
p.dailyViews = p.dailyViews * globals.featuredBoost;
p.featuredBoosted = true;
feature(p.name)
playSound(featuredModal)
}
p.dailyViews = (p.dailyViews / globals.viewDecay);
p.likes += Math.floor((p.dailyViews / globals.viewDecay) / 40);
p.comments += Math.floor((p.dailyViews / globals.viewDecay) / 2000);
p.views += p.dailyViews;
dailyFollowers += p.dailyViews
});
developer.followers += Math.floor((dailyFollowers / globals.followerFriction) / ((developer.html + developer.css +developer.js + developer.design) / 10) );
$('.followers span').html(developer.followers.toLocaleString());
$('.endGame h1').html(developer.followers.toLocaleString());
}
}
window.requestAnimationFrame(gameLoop);
}
$('.go').click(function(){
playSound(buttonClick)
$('.intro_modal').fadeOut(function(){
$('.overlay').fadeOut();
globals.paused = false
})
})
window.requestAnimationFrame(gameLoop);
class Grain {
constructor (el) {
this.patternSize = 150;
this.patternScaleX = 1;
this.patternScaleY = 1;
this.patternRefreshInterval = 3; // 8
this.patternAlpha = 12; // int between 0 and 255,
this.canvas = el;
this.ctx = this.canvas.getContext('2d');
this.ctx.scale(this.patternScaleX, this.patternScaleY);
this.patternCanvas = document.createElement('canvas');
this.patternCanvas.width = this.patternSize;
this.patternCanvas.height = this.patternSize;
this.patternCtx = this.patternCanvas.getContext('2d');
this.patternData = this.patternCtx.createImageData(this.patternSize, this.patternSize);
this.patternPixelDataLength = this.patternSize * this.patternSize * 4; // rgba = 4
this.resize = this.resize.bind(this);
this.loop = this.loop.bind(this);
this.frame = 0;
window.addEventListener('resize', this.resize);
this.resize();
window.requestAnimationFrame(this.loop);
}
resize () {
this.canvas.width = window.innerWidth * devicePixelRatio;
this.canvas.height = window.innerHeight * devicePixelRatio;
}
update () {
const {patternPixelDataLength, patternData, patternAlpha, patternCtx} = this;
// put a random shade of gray into every pixel of the pattern
for (let i = 0; i < patternPixelDataLength; i += 4) {
// const value = (Math.random() * 255) | 0;
const value = Math.random() * 255;
patternData.data[i] = value;
patternData.data[i + 1] = value;
patternData.data[i + 2] = value;
patternData.data[i + 3] = patternAlpha;
}
patternCtx.putImageData(patternData, 0, 0);
}
draw () {
const {ctx, patternCanvas, canvas, viewHeight} = this;
const {width, height} = canvas;
// clear canvas
ctx.clearRect(0, 0, width, height);
// fill the canvas using the pattern
ctx.fillStyle = ctx.createPattern(patternCanvas, 'repeat');
ctx.fillRect(0, 0, width, height);
}
loop () {
// only update grain every n frames
const shouldDraw = ++this.frame % this.patternRefreshInterval === 0;
if (shouldDraw) {
this.update();
this.draw();
}
window.requestAnimationFrame(this.loop);
}
}
const el = document.querySelector('.grain');
const grain = new Grain(el);
$('input').keydown(function(e){
if (!e) e = window.event;
var keyCode = e.keyCode || e.which;
if (keyCode == '13'){
if($('input').val() != '') {
playSound(buttonClick)
$('.name_modal').css('left','-200%');
$('.intro_modal').css('left','0%');
$('.username h2').html($('input').val())
playAudio(bg)
} else {
$('input').css('border-color', '#f16059')
}
return false;
}
})
$('.next').click(function() {
if($('input').val() != '') {
playSound(buttonClick)
$('.name_modal').css('left','-200%');
$('.intro_modal').css('left','0%');
$('.username h2').html($('input').val())
playAudio(bg)
} else {
$('input').css('border-color', '#f16059')
}
})
function animateValue(c, start, end, duration) {
var range = end - start;
var current = start;
var increment = end > start? 1 : -1;
var stepTime = Math.abs(Math.floor(duration / range));
var obj = $('.' + c)
var timer = setInterval(function() {
current += increment;
obj.innerHTML = current;
if (current == end) {
clearInterval(timer);
}
}, stepTime);
}
// ## Create a function to play our sounds
function playSound(sound) {
if (globals.audio) {
sound.play(); // Play sound
}
}
function playAudio(sound) {
sound.loop = true;
sound.volume = 0.5;
sound.play(); // Play sound
}
Also see: Tab Triggers