with cooler fwoosh
Created
October 10, 2016 16:00
-
-
Save shuuki/5f646a6f0cff36ea9ea895f5e7978ac7 to your computer and use it in GitHub Desktop.
dawg rising 2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#interface | |
#seed.button.alternate seed | |
//span.dawgverse-dawg | |
#play.button ▶ | |
#tardis.button ▶▶ | |
//#pause.button ❚❚ | |
//#update.button ¿? update | |
table | |
tr#output |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// angel says to the dawg: "listen. listen to the earth." | |
// global variables | |
var interface = document.getElementById("interface"); | |
var output = document.getElementById("output"); | |
// seed time | |
var timeSeed, | |
timeClock, | |
timeAlive, | |
timeDay, | |
timeMonth, | |
timeYear; | |
var seed = document.getElementById("seed"); | |
seed.onclick = seedTime; | |
function seedTime() { | |
timeClock = Math.ceil(Math.random()*8764); | |
timeSeed = timeClock; | |
timeAlive = 0; | |
updateTime(); | |
} | |
// advance timers | |
var play = document.getElementById("play"); | |
play.onclick = advanceTime; | |
function advanceTime() { | |
timeClock ++; | |
timeAlive ++; | |
updateTime(); | |
} | |
var tardis = document.getElementById("tardis"); | |
tardis.onclick = fwoosh; | |
// A cooler fwoosh /d | |
var fwooshing; // Are we fwooshing? | |
var fwooshRemaining = 0; // How much fwoosh is in the tank? | |
function fastForward(x) // Start the fwoosh! | |
{ | |
fwooshRemaining += x; // Increase request fwoosh | |
if (!fwooshing) // Do stuff if we're not already fwooshing | |
{ | |
// fwooshing is an ID matching this call to set interval | |
fwooshing = setInterval(function() // Start a new interval => fn called over and over | |
{ | |
fwooshRemaining--; // Consume some fwooshtank | |
timeClock++; // The times, they are a changin' | |
updateTime(); // And someone needs to listen | |
if (fwooshRemaining <= 0) // If we've emptied our fwooshtank | |
{ | |
clearInterval(fwooshing); // Stop the fwoosh interval | |
fwooshing = undefined; // And clear it so it can be used again | |
} | |
}, 20); // fwoosh speed in ms, 0 means max speed (as soon as DOM is done and JS is ticked) | |
} | |
} | |
// Let's let fwooshing happen | |
function fwoosh() { | |
fastForward(Math.ceil(Math.random()*720)); | |
} | |
// timers | |
function updateTime() { | |
timeDay = timeClock % 24; | |
timeMonth = timeClock % 720; | |
timeYear = timeClock % 8764; | |
updateSky(); | |
updateMoon(); | |
updateSeason(); | |
printClocks(); | |
} | |
function printClocks() { | |
output.innerHTML = "<li>seed: " + timeSeed + "</li>"; | |
output.innerHTML += "<li>alive: " + timeAlive + "</li>"; | |
output.innerHTML += "<li>clock: " + timeClock + "</li>"; | |
output.innerHTML += "<li>day: " + timeDay + "</li>"; | |
output.innerHTML += "<li>sky: " + currentSky + "</li>"; | |
output.innerHTML += "<li>month: " + timeMonth + "</li>"; | |
output.innerHTML += "<li>moon: " + currentMoon + "</li>"; | |
output.innerHTML += "<li>year: " + timeYear + "</li>"; | |
output.innerHTML += "<li>season: " + currentSeason + "</li>"; | |
} | |
// sun | |
var sky = [ | |
"night", | |
"dawn", | |
"morning", | |
"afternoon", | |
"evening", | |
"twilight" | |
] | |
var currentSky; | |
function updateSky() { | |
if (timeDay < 5) {currentSky = sky[0]} | |
else if(timeDay < 7) {currentSky = sky[1]} | |
else if(timeDay < 11) {currentSky = sky[2]} | |
else if(timeDay < 15) {currentSky = sky[3]} | |
else if(timeDay < 19) {currentSky = sky[4]} | |
else if(timeDay < 21) {currentSky = sky[5]} | |
else if(timeDay < 24) {currentSky = sky[0]}; | |
}; | |
// moon | |
var moon = [ | |
"new", | |
"crescent", | |
"first quarter", | |
"gibbous", | |
"full", | |
"disseminating", | |
"last quarter", | |
"balsamic" | |
]; | |
var currentMoon; | |
function updateMoon() { | |
if (timeMonth < 89) {currentMoon = moon[0]} | |
else if(timeMonth < 179) {currentMoon = moon[1]} | |
else if(timeMonth < 269) {currentMoon = moon[2]} | |
else if(timeMonth < 359) {currentMoon = moon[3]} | |
else if(timeMonth < 449) {currentMoon = moon[4]} | |
else if(timeMonth < 539) {currentMoon = moon[5]} | |
else if(timeMonth < 629) {currentMoon = moon[0]} | |
else if(timeMonth < 720) {currentMoon = moon[0]}; | |
}; | |
// seasons | |
var season = [ | |
"summer", | |
"autumn", | |
"winter", | |
"spring" | |
]; | |
var currentSeason; | |
function updateSeason() { | |
if (timeYear < 2191) {currentSeason = season[0]} | |
else if(timeYear < 4382) {currentSeason = season[1]} | |
else if(timeYear < 6572) {currentSeason = season[2]} | |
else if(timeYear < 8764) {currentSeason = season[3]}; | |
//updateWeather(); | |
}; | |
/* | |
var weather; | |
var currentWeather; | |
function updateWeather() { | |
if(currentSeason === season[0]) { | |
output.innerHTML += "summer weather"; | |
//currentWeather = weather.summer; | |
} | |
else if(currentSeason === season[1]) { output.innerHTML += "autumn weather"; } | |
else if(currentSeason === season[2]) { output.innerHTML += "winter weather"; } | |
else if(currentSeason === season[3]) { output.innerHTML += "spring weather"; } | |
} | |
*/ | |
var weather = { | |
"summer" : { | |
"temp": { | |
"cold": 0, | |
"cool": 0, | |
"mild": 0, | |
"warm": 1, | |
"hot": 12, | |
"scorching": 78 | |
}, | |
"precip" : { | |
"rain": 11, | |
"snow": 1 | |
}, | |
"wind" : { | |
"calm": 53, | |
"breezy": 12, | |
"windy": 12, | |
"gusty": 15 | |
}, | |
"clouds" : { | |
"clear": 55, | |
"hazy": 5, | |
"cloudy": 14, | |
"overcast": 4 | |
} | |
}, | |
"autumn" : { | |
"temp": { | |
"cold": 0, | |
"cool": 12, | |
"mild": 22, | |
"warm": 22, | |
"hot": 35, | |
"scorching": 1 | |
}, | |
"precip" : { | |
"rain": 8, | |
"snow": 2 | |
}, | |
"wind" : { | |
"calm": 59, | |
"breezy": 32, | |
"windy": 1, | |
"gusty": 1 | |
}, | |
"clouds" : { | |
"clear": 57, | |
"hazy": 4, | |
"cloudy": 12, | |
"overcast": 9 | |
} | |
}, | |
"winter" : { | |
"temp": { | |
"cold": 52, | |
"cool": 38, | |
"mild": 1, | |
"warm": 0, | |
"hot": 0, | |
"scorching": 0 | |
}, | |
"precip" : { | |
"rain": 5, | |
"snow": 9 | |
}, | |
"wind" : { | |
"calm": 80, | |
"breezy": 10, | |
"windy": 0, | |
"gusty": 0 | |
}, | |
"clouds" : { | |
"clear": 57, | |
"hazy": 3, | |
"cloudy": 12, | |
"overcast": 12 | |
} | |
}, | |
"spring" : { | |
"temp": { | |
"cold": 0, | |
"cool": 14, | |
"mild": 36, | |
"warm": 19, | |
"hot": 22, | |
"scorching": 0 | |
}, | |
"precip" : { | |
"rain": 6, | |
"snow": 1 | |
}, | |
"wind" : { | |
"calm": 0, | |
"breezy": 66, | |
"windy": 11, | |
"gusty": 15 | |
}, | |
"clouds" : { | |
"clear": 51, | |
"hazy": 5, | |
"cloudy": 15, | |
"overcast": 10 | |
} | |
} | |
}; | |
/* // ugh weather things what | |
var currentWeather; | |
function updateWeather(temp, precip, wind, clouds) { | |
this.temp = temp; | |
this.precip = precip; | |
this.wind = wind; | |
this.clouds = clouds; | |
}; | |
*/ | |
/* | |
// script to print out a line | |
//for each key in weather | |
weatherSeason = Object.keys(weather); | |
weatherSeason.forEach(ShowResults); | |
function ShowResults(value, index, key) { | |
document.write("<br />"); | |
document.write(value); | |
} | |
/* | |
/* | |
// script that iterates over the top level of weather and makes seasons uppercase | |
var weatherUpper = Object.keys(weather).map(function(x){ return x.toUpperCase(); Object.keys(x); }) | |
document.write(weatherUpper); | |
*/ | |
/* | |
// traversal script that prints out everything in weather | |
traverse(weather, process); | |
function traverse(weather, find) { | |
for (var i in weather) { | |
find.apply(this,[i,weather[i]]); | |
if(weather[i] !== null && typeof(weather[i]) == "object") { | |
traverse(weather[i],find); | |
} | |
} | |
} | |
function process(key, value) { | |
document.write(key + ": "+value + "<br>"); | |
} | |
*/ | |
//the only thing that ever works | |
//document.write(weather.summer.temp.hot+weather.summer.temp.warm+weather.summer.temp.scorching); | |
//Object.keys(weather).map(function(weatherSomething) {return weatherSomething.toUpperCase(); | |
//}); | |
//Object.keys(weather).map(function(x){ return x.toUpperCase(); }) | |
//document.write(Object.keys(weather)); | |
//run a check on season | |
// grab season attributes | |
// grab each of atributes | |
// document.write("value: " + value); | |
// document.write(" index: " + index); | |
// sun | |
// weather | |
// drag butt | |
// eat grass | |
//var update = document.getElementById("update"); | |
//update.onclick = updateTime; | |
// need time buffer, iterate through for update after actions | |
//pause.onclick = window.clearTimeout(advanceTime); | |
//play.onclick = window.setTimeout(advanceTime, 1000); | |
//var pause = document.getElementById("pause"); | |
// needs, todo | |
// visible, not visible for sun and moon | |
// if timeAlive = 8 years, old dawg : ages? | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//@import url(https://i.icomoon.io/public/188ac2dd2d/DAWG/style.css); | |
@color-dark: #393939; | |
@color-light: #eee; | |
@color-alternate: yellow; | |
body { | |
background-color: @color-dark; | |
color: @color-light; | |
font-family: "M+ 2m", monospace; | |
letter-spacing: 0.5px; | |
line-height: 1.4; | |
margin: 1em; | |
-webkit-font-smoothing: antialiased; | |
} | |
&::selection { | |
background: @color-alternate; | |
color: @color-dark; | |
} | |
hr { | |
border: 1px solid; | |
} | |
table { | |
td { | |
border: 1px solid @color-light; | |
padding: 0.5em; | |
} | |
} | |
.button { | |
background: @color-light; | |
color: @color-dark; | |
cursor: pointer; | |
display: inline-block; | |
font-weight: bold; | |
padding: 0 0.5em; | |
position: relative; | |
user-select: none; | |
&:hover { | |
background: darken(@color-light, 10%); | |
} | |
&:active { | |
top: 1px; | |
} | |
&.disabled { | |
cursor: default; | |
opacity: 0.5; | |
} | |
&.alternate { | |
background: @color-alternate; | |
} | |
} | |
.glyph { | |
font-family: "dawgverse"; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment