From eaaaa5b2996d78d90212b89f2dfd955fd7bf2628 Mon Sep 17 00:00:00 2001 From: William Toohey Date: Mon, 25 May 2015 01:02:53 +1000 Subject: [PATCH] Waifus won't repeat as often, keyboard shortcuts, preloader works better --- 0x40.js | 8 ++++- index_canvas.html | 80 +++++++++++++++++++++++++++++++++-------------- style_canvas.css | 51 +++++++++++++++++------------- waifuCanvas.js | 13 ++++++++ 4 files changed, 106 insertions(+), 46 deletions(-) diff --git a/0x40.js b/0x40.js index a1bfe02..435bdda 100644 --- a/0x40.js +++ b/0x40.js @@ -1400,6 +1400,8 @@ var rgSongs = [ var nCurrentColor = 63; // start white var nCurrentWaifu = 0; +// initially hold megumi +var lastWaifus = [0]; var nColorX, nColorY, nColorZ; @@ -1407,9 +1409,13 @@ var nColorX, nColorY, nColorZ; function GetRandomWaifu() { var tmp = Math.round((Math.random() * (waifus.length - 1))); - if(tmp == nCurrentWaifu) { + if(lastWaifus.indexOf(tmp) != -1) { return GetRandomWaifu(); } + lastWaifus.push(tmp); + while(lastWaifus.length > waifus.length / 2) { + lastWaifus.shift(); + } nCurrentWaifu = tmp; return waifus[tmp]; } diff --git a/index_canvas.html b/index_canvas.html index 945a5eb..94043d3 100644 --- a/index_canvas.html +++ b/index_canvas.html @@ -9,8 +9,7 @@ Volume controls Prettier ui Song shuffle - Image pause - Keyboard shortcuts + Image pause / manual advance Different colour palettes External respacks Change short blackout to beat length / 1.7 @@ -24,10 +23,9 @@ -
0x00 -
+ +
.xoxoxoxoxoxo
+
stop play @@ -302,7 +337,6 @@
B=0x0000
T=0x0000
-
white
@@ -311,7 +345,5 @@
- - \ No newline at end of file diff --git a/style_canvas.css b/style_canvas.css index 22e2794..eedc1ca 100644 --- a/style_canvas.css +++ b/style_canvas.css @@ -1,17 +1,37 @@ +html, body { + height: 100%; + margin: 0; padding: 0; +} + body { background-color:#ffffff; - height: 100%; - min-height: 100%; - margin: 0px; +} + +#controls { + font-family: monospace; + background-color:#ffffff; + position: absolute; + bottom: 0px; + left: 50%; + z-index: 3; +} + +#beets { + font-family: monospace; + background-color:#ffffff; + position: absolute; + top: 0px; + left: 50%; + z-index: 3; } #waifu { - width: 100%; - - #position: absolute; + display: block; + height: 100%; + margin-left: auto; + margin-right: auto; padding: 0; - top: 0; - left: 0; + z-index: -10; opacity: 0; } @@ -32,7 +52,7 @@ body { position: absolute; top: 0; left: 0; - z-index: -5; + z-index: 1; } #blackout { @@ -44,7 +64,7 @@ body { position: absolute; top: 0; left: 0; - z-index: 1; + z-index: 2; } #preloader { @@ -65,23 +85,12 @@ body { #preloader.loaded { opacity: 0; - pointer-events:none; animation-name: fadeout; animation-duration: 3s; -webkit-animation-name: fadeout; -webkit-animation-duration: 3s; } -#controls { - font-family: monospace; - background-color:#ffffff; - width:800px; - #position: absolute; - top: 10px; - left: 10px; - z-index: 2; -} - @keyframes fadein { from {opacity: 0;} to {opacity: 1;} diff --git a/waifuCanvas.js b/waifuCanvas.js index 8c4aeaa..a315e00 100644 --- a/waifuCanvas.js +++ b/waifuCanvas.js @@ -64,6 +64,19 @@ waifuCanvas.animationLoop = function() { waifuCanvas.newWaifu = function() { GetRandomWaifu(); // increments the waifu counter + var style = document.getElementById("waifu").style; + style["margin-right"] = "auto"; + style["margin-left"] = "auto"; + switch(waifus[nCurrentWaifu].align) { + case "left": + style["margin-left"] = "0"; + break; + case "right": + style["margin-right"] = "0"; + break; + default: + break; + } needsRedraw = true; }