setup wasm

This commit is contained in:
Schrottkatze 2024-05-12 12:03:50 +02:00
parent 7de16e410e
commit 7be75ce106
Signed by: schrottkatze
SSH key fingerprint: SHA256:hXb3t1vINBFCiDCmhRABHX5ocdbLiKyCdKI4HK2Rbbc
7 changed files with 57 additions and 11 deletions

1
.gitignore vendored
View file

@ -1,3 +1,4 @@
.direnv/ .direnv/
.devenv/ .devenv/
/target /target
dist/

10
Cargo.lock generated
View file

@ -293,7 +293,6 @@ version = "0.13.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "65b9eadaacf8fe971331bc3f250f35c18bc9dace3f96b483062f38ac07e3a1b4" checksum = "65b9eadaacf8fe971331bc3f250f35c18bc9dace3f96b483062f38ac07e3a1b4"
dependencies = [ dependencies = [
"bevy_dylib",
"bevy_internal", "bevy_internal",
] ]
@ -470,15 +469,6 @@ dependencies = [
"sysinfo", "sysinfo",
] ]
[[package]]
name = "bevy_dylib"
version = "0.13.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "922826e3b8f37c19836b49e18ceca662260cce87ab8faa4db6df8433903660cc"
dependencies = [
"bevy_internal",
]
[[package]] [[package]]
name = "bevy_ecs" name = "bevy_ecs"
version = "0.13.2" version = "0.13.2"

View file

@ -4,7 +4,8 @@ version = "0.1.0"
edition = "2021" edition = "2021"
[dependencies] [dependencies]
bevy = {version = "0.13.2", features = ["dynamic_linking"]} # bevy = {version = "0.13.2", features = ["dynamic_linking"]}
bevy = "0.13.2"
bevy_rand = { version = "0.6.0", features = ["wyrand"] } bevy_rand = { version = "0.6.0", features = ["wyrand"] }
bevy_rapier2d = "0.26.0" bevy_rapier2d = "0.26.0"
rand = "0.8.5" rand = "0.8.5"
@ -18,3 +19,7 @@ opt-level = 3
[profile.dev.package.bevy_rapier2d] [profile.dev.package.bevy_rapier2d]
opt-level = 3 opt-level = 3
[profile.release]
lto = true

View file

@ -31,6 +31,7 @@
rs-toolchain = with fenix.packages.${system}; rs-toolchain = with fenix.packages.${system};
combine [ combine [
complete.toolchain complete.toolchain
targets.wasm32-unknown-unknown.latest.rust-std
# rust-analyzer # rust-analyzer
]; ];
my-crate = craneLib.buildPackage { my-crate = craneLib.buildPackage {
@ -71,6 +72,8 @@
wayland wayland
mold-wrapped mold-wrapped
clang clang
trunk
binaryen
]; ];
LD_LIBRARY_PATH = pkgs.lib.makeLibraryPath buildInputs; LD_LIBRARY_PATH = pkgs.lib.makeLibraryPath buildInputs;

15
index.html Normal file
View file

@ -0,0 +1,15 @@
<html>
<head>
<link data-trunk rel="css" href="main.css"/>
</head>
<body>
<section>
<h1>Keybinds:</h1>
<ul>
<li>W: Jump</li>
<li>A: Walk left</li>
<li>D: Walk right</li>
</ul>
</section>
</body>
</html>

5
justfile Normal file
View file

@ -0,0 +1,5 @@
deploy-katzencafe: build-wasm
rsync dist/* root@katzen.cafe:/var/www/miau/evader
build-wasm:
trunk build --release --public-url "/evader"

27
main.css Normal file
View file

@ -0,0 +1,27 @@
html,
body {
margin: 0;
padding: 0;
background-color: #222;
}
body {
height: 100vh;
width: 100vw;
display: flex;
flex-direction: column-reverse;
justify-content: center;
align-items: center;
}
canvas:focus {
border: none;
outline: none;
}
h1,
li,
ul {
font-family: sans-serif;
color: white;
}