11import { component$ , useVisibleTask$ } from '@builder.io/qwik' ;
2- import { QwikCityProvider , RouterOutlet , ServiceWorkerRegister } from '@builder.io/qwik-city' ;
2+ import {
3+ QwikCityProvider ,
4+ RouterOutlet ,
5+ ServiceWorkerRegister ,
6+ } from '@builder.io/qwik-city' ;
37import { RouterHead } from './components/Head' ;
48
59import './global.css' ;
@@ -24,7 +28,13 @@ export default component$(() => {
2428
2529 let frameCount = 0 ;
2630 let idleTime = 0 ;
27- type idleAnimations = 'sleeping' | 'scratchWallN' | 'scratchWallS' | 'scratchWallE' | 'scratchWallW' | 'scratchSelf' ;
31+ type idleAnimations =
32+ | 'sleeping'
33+ | 'scratchWallN'
34+ | 'scratchWallS'
35+ | 'scratchWallE'
36+ | 'scratchWallW'
37+ | 'scratchSelf' ;
2838 let idleAnimation : idleAnimations | null = null ;
2939 let idleAnimationFrame = 0 ;
3040
@@ -131,7 +141,9 @@ export default component$(() => {
131141
132142 function setSprite ( name : keyof typeof spriteSets , frame : number ) {
133143 const sprite = spriteSets [ name ] [ frame % spriteSets [ name ] . length ] ;
134- nekoEl . style . backgroundPosition = `${ sprite [ 0 ] * 32 } px ${ sprite [ 1 ] * 32 } px` ;
144+ nekoEl . style . backgroundPosition = `${ sprite [ 0 ] * 32 } px ${
145+ sprite [ 1 ] * 32
146+ } px`;
135147 }
136148
137149 function resetIdleAnimation ( ) {
@@ -148,12 +160,20 @@ export default component$(() => {
148160 Math . floor ( Math . random ( ) * 200 ) == 0 &&
149161 idleAnimation == null
150162 ) {
151- const avalibleIdleAnimations : idleAnimations [ ] = [ 'sleeping' , 'scratchSelf' ] ;
163+ const avalibleIdleAnimations : idleAnimations [ ] = [
164+ 'sleeping' ,
165+ 'scratchSelf' ,
166+ ] ;
152167 if ( nekoPosX < 32 ) avalibleIdleAnimations . push ( 'scratchWallW' ) ;
153168 if ( nekoPosY < 32 ) avalibleIdleAnimations . push ( 'scratchWallN' ) ;
154- if ( nekoPosX > window . innerWidth - 32 ) avalibleIdleAnimations . push ( 'scratchWallE' ) ;
155- if ( nekoPosY > window . innerHeight - 32 ) avalibleIdleAnimations . push ( 'scratchWallS' ) ;
156- idleAnimation = avalibleIdleAnimations [ Math . floor ( Math . random ( ) * avalibleIdleAnimations . length ) ] ;
169+ if ( nekoPosX > window . innerWidth - 32 )
170+ avalibleIdleAnimations . push ( 'scratchWallE' ) ;
171+ if ( nekoPosY > window . innerHeight - 32 )
172+ avalibleIdleAnimations . push ( 'scratchWallS' ) ;
173+ idleAnimation =
174+ avalibleIdleAnimations [
175+ Math . floor ( Math . random ( ) * avalibleIdleAnimations . length )
176+ ] ;
157177 }
158178
159179 switch ( idleAnimation ) {
@@ -212,7 +232,10 @@ export default component$(() => {
212232 const xDistance = diffX / distance ;
213233 direction += yDistance > 0.5 ? 'N' : yDistance < - 0.5 ? 'S' : '' ;
214234 direction += xDistance > 0.5 ? 'W' : xDistance < - 0.5 ? 'E' : '' ;
215- setSprite ( direction as 'N' | 'S' | 'W' | 'E' | 'NE' | 'SE' | 'SW' | 'NW' , frameCount ) ;
235+ setSprite (
236+ direction as 'N' | 'S' | 'W' | 'E' | 'NE' | 'SE' | 'SW' | 'NW' ,
237+ frameCount ,
238+ ) ;
216239
217240 nekoPosX -= ( diffX / distance ) * nekoSpeed ;
218241 nekoPosY -= ( diffY / distance ) * nekoSpeed ;
@@ -230,11 +253,17 @@ export default component$(() => {
230253 return (
231254 < QwikCityProvider >
232255 < head >
233- < meta charset = "utf-8" />
234- < link rel = "manifest" href = "/manifest.json" />
256+ < meta charset = 'utf-8' />
257+ < link rel = 'manifest' href = '/manifest.json' />
258+ < script
259+ defer
260+ src = 'https://umami.bwmp.dev/script.js'
261+ data-website-id = '3ee57841-ddf7-4d95-80d2-1c1c0beb3386'
262+ data-domains = 'luminescent.dev'
263+ />
235264 < RouterHead />
236265 </ head >
237- < body class = " text-gray-200" >
266+ < body class = ' text-gray-200' >
238267 < RouterOutlet />
239268 < ServiceWorkerRegister />
240269 </ body >
0 commit comments