Skip to content

Commit

Permalink
chore: commit everything from repl environment
Browse files Browse the repository at this point in the history
  • Loading branch information
Ray Arayilakath committed Jun 8, 2021
1 parent 08e7e99 commit cfd7c69
Show file tree
Hide file tree
Showing 8 changed files with 107 additions and 8 deletions.
Binary file added icons/android-icon-144x144.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion index.html

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions offline/index.html

Large diffs are not rendered by default.

34 changes: 34 additions & 0 deletions service-worker.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
const cacheName = 'tether_cache_v1';
const precacheResources = [
'/',
'/offline.html',
'/fonts/Quantico400.woff2',
'/fonts/Quantico700.woff2',
'/fonts/Tulpen-One400.woff2',
'/favicon.ico',
'/libs/font-awesome.min.css',
'/libs/fontawesome-webfont.woff'
];

// When the service worker is installing, open the cache and add the precache resources to it
self.addEventListener('install', (event) => {
console.log('Service worker install event!');
event.waitUntil(caches.open(cacheName).then((cache) => cache.addAll(precacheResources)));
});

self.addEventListener('activate', (event) => {
console.log('Service worker activate event!');
});

// When there's an incoming fetch request, try and respond with a precached resource, otherwise fall back to the network
self.addEventListener('fetch', (event) => {
console.log('Fetch intercepted for:', event.request.url);
event.respondWith(
caches.match(event.request).then((cachedResponse) => {
if (cachedResponse) {
return cachedResponse;
}
return fetch(event.request);
}),
);
});
28 changes: 23 additions & 5 deletions source/source.js → source/game.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ var DEBUG = window.location.hash === '#DEBUG',
lastDayCookieKey = 'tetherLastDate',
streakCountCookieKey = 'tetherStreakCount',
streakCount = localStorage.getItem(streakCountCookieKey) ?? 0,
subtitleText = "",
lastDate = new Date(Number(localStorage.getItem(lastDayCookieKey))),
lastTouchStart,
uidCookieKey = 'tetherId',
Expand All @@ -30,6 +31,9 @@ var DEBUG = window.location.hash === '#DEBUG',
shouldUnmuteImmediately = false,
cookieExpiryDate = new Date();

if(window.location.pathname === '/source/') subtitleText = 'Source Development Mode. #OpenSource';
else subtitleText = 'Swing around a ball and cause pure destruction.';

cookieExpiryDate.setFullYear(cookieExpiryDate.getFullYear() + 50);
var cookieSuffix = '; expires=' + cookieExpiryDate.toUTCString();

Expand Down Expand Up @@ -541,8 +545,8 @@ function Music() {
var self = this,
path;

if (INFO) path = 'bgm.mp3';
else path = 'bgm.mp3';
if (INFO) path = '../tether_theme.mp3';
else path = '../tether_theme.mp3';

self.element = new Audio(path);

Expand All @@ -563,7 +567,7 @@ function Music() {

Music.prototype = {
bpm: 90,
url: 'bgm.mp3',
url: 'tether_theme.mp3',
delayCompensation: 0.03,

totalBeat: function () {
Expand Down Expand Up @@ -1911,7 +1915,7 @@ function Game() {

draw({
type: 'text',
text: 'Swing around a ball and cause pure destruction.',
text: subtitleText ?? 'Swing around a ball and cause pure destruction.',
fillStyle: rgbWithOpacity([0, 0, 0], opacity),
fontSize: 30,
textPosition: {
Expand Down Expand Up @@ -2371,7 +2375,21 @@ function handleClick(e) {
}
}

var konamiLength = 0;
var konamiSequence = ['ArrowUp', 'ArrowUp', 'ArrowDown', 'ArrowDown', 'ArrowLeft', 'ArrowRight', 'ArrowLeft', 'ArrowRight', 'KeyB', 'KeyA', 'Space'];

function konamiSeq(requiredKey, givenKey) {
if(requiredKey === givenKey) konamiLength++;
else konamiLength = 0;

if(konamiLength === 11) {
subtitleText = 'Special Cheats Activated. Have fun!';
playerRGB = 'Rainbow';
}
}

function handleKey(e) {
konamiSeq(konamiSequence[konamiLength], e.code);
if (e.code === 'KeyP') paused = !paused;
}

Expand Down Expand Up @@ -2445,4 +2463,4 @@ window.addEventListener('scroll', function (e) {
});
window.scrollTo(0, 0);

animate();
animate();
16 changes: 14 additions & 2 deletions source/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@
<link href="../icons/favicon-16x16.png" rel="icon" sizes="16x16" type="image/png" />

<meta content="#ffffff" name="msapplication-TileColor" />
<meta content="icons/ms-icon-144x144.png" name="msapplication-TileImage" />
<meta content="../icons/ms-icon-144x144.png" name="msapplication-TileImage" />
<meta content="#ffffff" name="theme-color" />

<link href="../manifest.json" rel="manifest" />
Expand All @@ -168,8 +168,20 @@
});
})();
</script>
<script>
if ('serviceWorker' in navigator) {
window.addEventListener('load', async () => {
try {
const reg = await navigator.serviceWorker.register('service-worker.js');
console.log('Service worker registered! 😎', reg);
} catch (err) {
console.log('😥 Service worker registration failed: ', err);
}
});
}
</script>
<body>
<noscript>Hey there, this game needs Javascript. Turn it on to experience the excitement!</noscript><canvas id="game"></canvas>
<script src="source.js"></script>
<script src="game.js"></script>
</body>
</html>
34 changes: 34 additions & 0 deletions source/source-service-worker.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
const cacheName = 'tether_source_cache-v2';
const precacheResources = [
'/',
'/offline.html',
'/fonts/Quantico400.woff2',
'/fonts/Quantico700.woff2',
'/fonts/Tulpen-One400.woff2',
'/icons/favicon.ico',
'/libs/font-awesome.min.css',
'/libs/fontawesome-webfont.woff'
];

// When the service worker is installing, open the cache and add the precache resources to it
self.addEventListener('install', (event) => {
console.log('Service worker install event!');
event.waitUntil(caches.open(cacheName).then((cache) => cache.addAll(precacheResources)));
});

self.addEventListener('activate', (event) => {
console.log('Service worker activate event!');
});

// When there's an incoming fetch request, try and respond with a precached resource, otherwise fall back to the network
self.addEventListener('fetch', (event) => {
console.log('Fetch intercepted for:', event.request.url);
event.respondWith(
caches.match(event.request).then((cachedResponse) => {
if (cachedResponse) {
return cachedResponse;
}
return fetch(event.request);
}),
);
});
File renamed without changes.

0 comments on commit cfd7c69

Please sign in to comment.