File size: 3,627 Bytes
0dd88bc
29b64bf
0dd88bc
 
 
 
29b64bf
 
 
 
 
0dd88bc
 
 
 
29b64bf
0dd88bc
 
 
 
 
29b64bf
 
 
0dd88bc
 
 
 
 
 
29b64bf
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
0dd88bc
 
 
 
 
 
 
 
29b64bf
0dd88bc
50ba38e
0dd88bc
 
29b64bf
 
 
 
 
0dd88bc
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
84965fb
0dd88bc
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
<script lang="ts">

	// Svelte
	import { onMount } from "svelte";
	import { page } from "$app/stores";

	// Components
	import StarTrace from "$lib/components/StarTrace.svelte";

	// Types
	import type { Star } from "$lib/types/Star";

	// Variables
	let isMobile: boolean = false;
	let isLinkCopied: boolean = false;
	let stars: Star[] = [];

	onMount(() => {
		if (window.innerWidth < 768) {
			isMobile = true;
		}
		setInterval(() => {
			spawnStar();
		}, 5000);
	});

	function copyToClipboard(): void {
		navigator.clipboard.writeText($page.url.toString());
		isLinkCopied = true;
	}

	function getRandomArbitrary(min: number, max: number) {
    	return Math.random() * (max - min) + min;
	}

	function spawnStar() {

		const length = getRandomArbitrary(800, 1500);
		const angle = 135 * (Math.PI / 180);

		const startX = Math.random() * window.innerWidth;
		const startY = Math.random() * window.innerHeight;

		const endX = startX + Math.cos(angle) * length;
		const endY = startY + Math.sin(angle) * length;
		
		stars = [...stars, {
			start: {
				x: startX,
				y: startY
			},
			end: {
				x: endX,
				y: endY
			},
		}];

	}

	function removeStar(e: CustomEvent) {
		stars = stars.filter(s => s !== e.detail);
	}

</script>

<!--Main container-->
<div
	class="flex flex-col justify-center text-slate-100 font-Hellovetica items-center p-4 w-full"
>
	<!--Title container-->
	<div
		class="flex flex-col justify-center items-center space-y-4 text-center mt-12 z-50"
	>
		<img src="images/png_title.png" alt="Game title" class="h-40">
	</div>

	<!--Stars-->
	{#each stars as star}
		<StarTrace {star} on:remove={removeStar} />
	{/each}

	{#if !isMobile}
		<div class="relative mt-6 border-slate-800 border-[3px]">
			<!--Game-->
			<iframe
				src="smg/index.html"
				frameborder="0"
				title="Spaceship Drift"
				height="512"
				width="768"
				class=""
			/>
			<!--Corners-->
			<div
				class="h-[3px] bg-[#0C0F19] w-[3px] z-10 absolute -top-[3px] -left-[3px]"
			/>
			<div
				class="h-[3px] bg-[#0C0F19] w-[3px] z-10 absolute -bottom-[3px] -left-[3px]"
			/>
			<div
				class="h-[3px] bg-[#0C0F19] w-[3px] z-10 absolute -top-[3px] -right-[3px]"
			/>
			<div
				class="h-[3px] bg-[#0C0F19] w-[3px] z-10 absolute -bottom-[3px] -right-[3px]"
			/>
		</div>

		<!--Infos-->
		<div
			class="flex flex-row justify-center items-center text-[9px] mt-4 text-slate-500"
		>
			<p>ZQD to move SPACE to jump. <a href="https://x.com/HugoDuprez/status/1712093324528541831?s=20" target="_blank" class="underline">Full shaders game demo</a></p>
		</div>
	{/if}

	{#if isMobile}
		<div class="flex flex-col justify-center items-center mt-10 text-center">
			<p class="text-xs text-slate-500 mt-6">
				Looks like you're on mobile! Please visit on your laptop.
			</p>
			<button
				on:click|preventDefault={copyToClipboard}
				class="flex flex-row justify-center items-center px-3 py-5 text-xs w-full bg-slate-800 mt-6"
			>
				<p class="mt-1">
					{isLinkCopied ? "Copied!" : "Copy the link for later"}
				</p>
			</button>
		</div>
	{/if}

	<!--Credits-->
	<div
		class="flex flex-row justify-center items-center text-center {isMobile ? "mt-20" : "fixed bottom-6"} text-[9px] text-slate-500"
	>
		<p>
			Made by <a href="https://www.hugoduprez.com/" target="_blank" class="underline">Hugo</a
			>
			with
			<a href="https://godotengine.org/" target="_blank" class="underline"
				>Godot</a
			>,
			<a href="https://svelte.dev/" target="_blank" class="underline">Svelte</a
			>, and
			<a href="https://www.kenney.nl/tools" target="_blank" class="underline"
				>Kenney assets</a
			>
		</p>
	</div>
</div>