Skip to content

Commit

Permalink
chore: Release Magus Parvus v0.2.0
Browse files Browse the repository at this point in the history
No new features, just bumped Bevy version and fixed some minor issues.
  • Loading branch information
PraxTube committed Jul 19, 2024
1 parent 6853418 commit 11de736
Show file tree
Hide file tree
Showing 5 changed files with 112 additions and 5 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 9 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "magus-parvus"
version = "0.1.6"
version = "0.2.0"
edition = "2021"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
Expand All @@ -13,6 +13,14 @@ opt-level = 1
[profile.dev.package."*"]
opt-level = 3

# https://github.com/rust-lang/cargo/issues/4897
[profile.wasm]
inherits = "release"
panic = "abort"
opt-level = 'z'
lto = true
codegen-units = 1

[dependencies]
rand = "0.8.5"
chrono = "0.4.31"
Expand Down
5 changes: 4 additions & 1 deletion src/world/camera.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,16 @@ use bevy::prelude::*;
use bevy::render::camera::ScalingMode;
#[cfg(not(target_arch = "wasm32"))]
use bevy::render::view::screenshot::ScreenshotManager;
#[cfg(not(target_arch = "wasm32"))]
use bevy::window::{PrimaryWindow, WindowMode};
use bevy_kira_audio::prelude::AudioReceiver;
use bevy_rapier2d::plugin::PhysicsSet;

use super::camera_shake::{update_camera, CameraShake};
use crate::player::input::PlayerInput;
use crate::player::{Player, PlayerState};
use crate::player::Player;
#[cfg(not(target_arch = "wasm32"))]
use crate::player::PlayerState;
use crate::spell::debug_spell::DebugSpell;
use crate::GameState;

Expand Down
44 changes: 42 additions & 2 deletions wasm/index.html
Original file line number Diff line number Diff line change
@@ -1,8 +1,21 @@
<!doctype html>
<html lang="en">

<body style="margin: 0px;">
<head>
<meta charset="utf-8" />
<link rel="stylesheet" href="styles.css" />
</head>

<body>
<div class="game-container">
<div id="canvas-container"></div>
<div id="loading">
<span class="loader"></span>
</div>
</div>

<script type="module">
console.log("initiating bevy game");
import './restart-audio-context.js'
import init from './bevy_game.js'

Expand All @@ -11,7 +24,34 @@
throw error;
}
});

console.log("loaded bevy game now");

// Function to move canvas to the specified container
function moveCanvas() {
const canvas = document.querySelector('canvas');
const canvasContainer = document.getElementById('canvas-container');
if (canvas && canvasContainer) {
canvasContainer.appendChild(canvas);
}
}

// Hide loading screen and move canvas when the game starts
const loading = document.getElementById('loading');
const observer = new MutationObserver(() => {
console.log("checkign for canvas");
const canvas = document.querySelector('canvas');
if (canvas) {
loading.style.display = 'none';
moveCanvas();
observer.disconnect();
} else {
console.warn("no canvas item");
}
});

// Start observing the document for changes
observer.observe(document.body, { childList: true, subtree: true });
</script>
</body>

</html>
56 changes: 56 additions & 0 deletions wasm/styles.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
* {
margin: 0;
padding: 0;
border: 0;
}

html,
body {
width: 100%;
height: 100%;
}

.game-container {
width: 100%;
height: 100%;
display: flex;
justify-content: center;
align-items: center;
flex-direction: column;

/* Background pattern from https://css-pattern.com/ */
--s: 200px;
--c1: #1d1d1d;
--c2: #4e4f51;
--c3: #3c3c3c;
background:
repeating-conic-gradient(from 30deg, #0000 0 120deg, var(--c3) 0 180deg) calc(.5*var(--s)) calc(.5*var(--s)*0.577),
repeating-conic-gradient(from 29.5deg, var(--c1) 0 60deg, var(--c2) 0 120deg, var(--c3) 0 180deg);
background-size: var(--s) calc(var(--s)*0.577);
}

#bevy {
height: 0;
}

/* Loader from https://cssloaders.github.io/ */
.loader {
width: 128px;
height: 128px;
border: 16px solid #FFF;
border-bottom-color: #FF3D00;
border-radius: 50%;
display: inline-block;
box-sizing: border-box;
animation: rotation 1s linear infinite;
}

@keyframes rotation {
0% {
transform: rotate(0deg);
}

100% {
transform: rotate(360deg);
}
}

0 comments on commit 11de736

Please sign in to comment.