Merge branch 'master' of https://git.txmn.tk/tuxmain/bevyjam into nixon-main

This commit is contained in:
Nixon 2022-08-28 17:27:06 +08:00
commit b45f052e5a
15 changed files with 173 additions and 81 deletions

46
Cargo.lock generated
View file

@ -923,24 +923,6 @@ dependencies = [
"winit",
]
[[package]]
name = "bevyjam"
version = "0.1.0"
dependencies = [
"bevy",
"bevy-inspector-egui",
"bevy_common_assets",
"bevy_mod_picking",
"bevy_rapier2d",
"crossbeam-channel",
"rand",
"rand_distr",
"rapier2d",
"serde",
"serde_json",
"ticktock",
]
[[package]]
name = "bindgen"
version = "0.59.2"
@ -2182,9 +2164,9 @@ dependencies = [
[[package]]
name = "lock_api"
version = "0.4.7"
version = "0.4.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "327fa5b6a6940e4699ec49a9beae1ea4845c6bab9314e4f84ac68742139d8c53"
checksum = "9f80bf5aacaf25cbfc8210d1cfb718f2bf3b11c4c54e5afe36c236853a8ec390"
dependencies = [
"autocfg",
"scopeguard",
@ -2199,6 +2181,24 @@ dependencies = [
"cfg-if 1.0.0",
]
[[package]]
name = "lux-synthese"
version = "0.1.0"
dependencies = [
"bevy",
"bevy-inspector-egui",
"bevy_common_assets",
"bevy_mod_picking",
"bevy_rapier2d",
"crossbeam-channel",
"rand",
"rand_distr",
"rapier2d",
"serde",
"serde_json",
"ticktock",
]
[[package]]
name = "mach"
version = "0.3.2"
@ -3654,7 +3654,7 @@ dependencies = [
"js-sys",
"log",
"naga",
"parking_lot 0.11.2",
"parking_lot 0.12.1",
"raw-window-handle",
"smallvec",
"wasm-bindgen",
@ -3679,7 +3679,7 @@ dependencies = [
"fxhash",
"log",
"naga",
"parking_lot 0.11.2",
"parking_lot 0.12.1",
"profiling",
"raw-window-handle",
"smallvec",
@ -3715,7 +3715,7 @@ dependencies = [
"metal",
"naga",
"objc",
"parking_lot 0.11.2",
"parking_lot 0.12.1",
"profiling",
"range-alloc",
"raw-window-handle",

View file

@ -1,5 +1,5 @@
[package]
name = "bevyjam"
name = "lux-synthese"
version = "0.1.0"
authors = ["tuxmain <tuxmain@zettascript.org>"]
license = "AGPL-3.0-only"

View file

@ -1,4 +1,6 @@
# Bevyjam
# Lux synthesĕ
[Play in browser](https://txmn.tk/projects/lux-synthese/)
## Controls
@ -6,20 +8,19 @@
* **Switch character**: Tab
* **Level up**: Enter (when character is white)
* **Reset**: R
* **Fullscreen**: F11
* **Exit**: Escape
## TODO
* name
* more filters
* despawn black characters
* despawn character when too far
* more levels
* (?) multiplayer
* more audio
* "jumpable" component to avoid jumping on sensors
* bug: in level2, move the blue character to win, then reset. The characters are lighter than expected. (also level 4)
* redshift warning
* itchio test
## Build
@ -66,6 +67,6 @@ Edit the level `N: u32` with the command `bevyjam <N> e`.
GNU AGPL v3, CopyLeft 2022 Pascal Engélibert, Nixon Cheng
This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, version 3 of the License.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License along with this program. If not, see https://www.gnu.org/licenses/.
_Lux synthesĕ_ is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, version 3 of the License.
_Lux synthesĕ_ is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License along with _Lux synthesĕ_. If not, see https://www.gnu.org/licenses/.

Binary file not shown.

Binary file not shown.

View file

@ -59,10 +59,10 @@
{
"pos": [
0.0,
0.0
64.0
],
"font_size": 32.0,
"text": "Combine the colors to synthetize a white light.\nUse arrows to move."
"text": "Combine the colors\nto synthetize a white light.\nUse arrows to move."
}
]
},
@ -374,11 +374,11 @@
"texts": [
{
"pos": [
0.0,
-304.0,
-64.0
],
"font_size": 32.0,
"text": "Too much light\ncause some platforms to melt."
"text": "Too much light\ncauses some platforms to melt."
}
]
},

13
build-itchio.sh Normal file
View file

@ -0,0 +1,13 @@
sh build-wasm.sh || exit 1
mkdir -p target/itchio/wasm/target
mkdir -p target/itchio/wasm/assets
cp assets/* target/itchio/wasm/assets/
cp index.html target/itchio/wasm/
cp target/lux-synthese.js target/itchio/wasm/target/
cp target/lux-synthese_bg.wasm target/itchio/wasm/target/
jq -c < assets/game.levels.json > target/itchio/wasm/assets/game.levels.json
cd target/itchio/wasm
zip -r ../wasm.zip .

View file

@ -1,3 +1,3 @@
cargo build --release --target wasm32-unknown-unknown || exit 1
echo "==> wasm-bindgen..."
wasm-bindgen --out-name bevyjam --out-dir target --target web target/wasm32-unknown-unknown/release/bevyjam.wasm || exit 1
wasm-bindgen --out-name lux-synthese --out-dir target --target web target/wasm32-unknown-unknown/release/lux-synthese.wasm || exit 1

BIN
cover.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

BIN
cover.xcf Normal file

Binary file not shown.

View file

@ -2,12 +2,88 @@
<html lang="en">
<head>
<meta charset="UTF-8"/>
<title>Bevyjam</title>
<title>Lux synthesĕ</title>
<style type="text/css">
@font-face {
font-family: UacariLegacy;
font-weight: normal;
src: url("assets/UacariLegacy-Regular.ttf");
}
@font-face {
font-family: UacariLegacy;
font-weight: bold;
src: url("assets/UacariLegacy-Bold.ttf");
}
@font-face {
font-family: UacariLegacy-Thin;
src: url("assets/UacariLegacy-Thin.ttf");
}
html, body {
font-family: UacariLegacy;
margin: 0;
padding: 0;
background-color: #222;
}
body {
display: flex;
flex-flow: column;
color: white;
}
h1, h2 {
font-family: UacariLegacy-Thin;
font-weight: normal;
}
canvas {
order: 1;
max-width: 100vw;
max-height: 100vh;
margin: auto;
}
#readme {
order: 2;
width: 640px;
max-width: 100vw;
padding: 8px;
margin: auto;
}
a, a:visited {
color: #f80;
}
</style>
</head>
<body>
<script type="module">
<<<<<<< HEAD
import init from './target/bevyjam.js'
init()
=======
import init from './target/lux-synthese.js'
init()
>>>>>>> 0ee61d808ef10de7f38fe9755931893b647e0ab2
</script>
<div id="readme">
<h1>Lux synthesĕ</h1>
<p>
<strong>Note</strong>: audio does not work in the WASM build.
</p>
<h2>Controls</h2>
<ul>
<li><strong>Move</strong>: Arrows</li>
<li><strong>Switch</strong>: Tab</li>
<li><strong>Level up</strong>: Enter</li>
<li><strong>Reset</strong>: R</li>
</ul>
<h2>Source</h2>
<p>
The source code of this free software is available in our <a href="https://git.txmn.tk/tuxmain/bevyjam/">Git repository</a>.
</p>
<p>
GNU AGPL v3: CopyLeft 2022 Pascal Engélibert, Nixon Cheng<br/>
Lux synthesĕ is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, version 3 of the License.<br/>
Lux synthesĕ is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details.<br/>
You should have received a copy of the GNU Affero General Public License along with Lux synthesĕ. If not, see <a href="https://www.gnu.org/licenses/">https://www.gnu.org/licenses/</a>.
</p>
</div>
</body>
</html>

View file

@ -54,7 +54,10 @@ impl Plugin for GamePlugin {
.add_system_to_stage(CoreStage::PostUpdate, char_char_collision_event_system)
.add_system_to_stage(CoreStage::PostUpdate, char_platform_collision_event_system)
// collision event system might remove items, therefore, we should detect platforms first before removing them
.add_system_to_stage(CoreStage::PostUpdate, collision_event_system.after(char_platform_collision_event_system));
.add_system_to_stage(
CoreStage::PostUpdate,
collision_event_system.after(char_platform_collision_event_system),
);
}
}
@ -118,7 +121,7 @@ impl PlatformCount {
}
fn is_landed(&self) -> bool {
return self.0 != 0;
self.0 != 0
}
}
@ -280,7 +283,7 @@ pub fn spawn_melty_platform(
.insert(Collider::cuboid(48., 8.))
.insert(Melty(color))
.insert(Level)
.insert(Platform)
.insert(Platform)
.with_children(|c| {
c.spawn_bundle(SpriteBundle {
texture: asset_server.get_handle("melty.png"),
@ -294,12 +297,7 @@ fn char_char_collision_event_system(
mut commands: Commands,
mut collision_events: EventReader<CollisionEvent>,
character_query: Query<(
&mut CharacterColor,
&Transform,
&mut Handle<ColorMaterial>,
Option<&Player>,
)>,
character_query: Query<(&CharacterColor, &Transform, Option<&Player>)>,
mut character_list: ResMut<CharacterList>,
mut app_state: ResMut<State<AppState>>,
@ -311,16 +309,16 @@ fn char_char_collision_event_system(
for collision_event in collision_events.iter() {
if let CollisionEvent::Started(e1, e2, _flags) = collision_event {
if let (
Ok((c1_color, c1_transform, _c1_material, c1_player)),
Ok((c2_color, c2_transform, _c2_material, c2_player)),
Ok((c1_color, c1_transform, c1_player)),
Ok((c2_color, c2_transform, c2_player)),
) = (character_query.get(*e1), character_query.get(*e2)) {
character_list.0.remove(e1);
character_list.0.remove(e2);
commands.entity(*e1).despawn_recursive();
commands.entity(*e2).despawn_recursive();
let new_color = (Vec4::from(c1_color.0) + Vec4::from(c2_color.0))
.clamp(Vec4::ZERO, Vec4::ONE);
let new_color =
(Vec4::from(c1_color.0) + Vec4::from(c2_color.0)).clamp(Vec4::ZERO, Vec4::ONE);
// If color approximately white
if app_state.current() == &AppState::Game && new_color.min_element() >= 0.9 {
@ -359,36 +357,32 @@ fn char_platform_collision_event_system(
) {
// detect platform + player collisions only
for collision_event in collision_events.iter() {
match collision_event {
match collision_event {
CollisionEvent::Started(e1, e2, flags) => {
if *flags == CollisionEventFlags::SENSOR {
if let (Ok(mut platform_count), Ok(_)) = (
platform_count_query.get_mut(*e1),
platform_query.get(*e2),
) {
if let (Ok(mut platform_count), Ok(_)) =
(platform_count_query.get_mut(*e1), platform_query.get(*e2))
{
platform_count.increment();
} else if let (Ok(mut platform_count), Ok(_)) = (
platform_count_query.get_mut(*e2),
platform_query.get(*e1),
) {
} else if let (Ok(mut platform_count), Ok(_)) =
(platform_count_query.get_mut(*e2), platform_query.get(*e1))
{
platform_count.increment();
}
}
}
}
CollisionEvent::Stopped(e1, e2, flags) => {
if *flags == CollisionEventFlags::SENSOR {
if let (Ok(mut platform_count), Ok(_)) = (
platform_count_query.get_mut(*e1),
platform_query.get(*e2),
) {
platform_count.decrement();
} else if let (Ok(mut platform_count), Ok(_)) = (
platform_count_query.get_mut(*e2),
platform_query.get(*e1),
) {
platform_count.decrement();
}
if let (Ok(mut platform_count), Ok(_)) =
(platform_count_query.get_mut(*e1), platform_query.get(*e2))
{
platform_count.decrement();
} else if let (Ok(mut platform_count), Ok(_)) =
(platform_count_query.get_mut(*e2), platform_query.get(*e1))
{
platform_count.decrement();
}
}
}
}

View file

@ -13,7 +13,7 @@ mod audio_system;
use bevy::{
asset::{Asset, HandleId, LoadState},
prelude::*,
window::{WindowId, WindowMode},
window::{WindowMode, WindowResizeConstraints},
};
use bevy_common_assets::json::JsonAssetPlugin;
use bevy_rapier2d::prelude::*;
@ -52,6 +52,19 @@ fn main() {
let mut app = App::new();
app.insert_resource(Msaa { samples: 4 })
.insert_resource(WindowDescriptor {
width: 640.0,
height: 480.0,
resize_constraints: WindowResizeConstraints {
min_width: 256.,
min_height: 256.,
max_width: f32::INFINITY,
max_height: f32::INFINITY,
},
resizable: true,
title: "Lux synthesĕ".into(),
..Default::default()
})
.insert_resource(UseEditor(use_editor))
.add_state(AppState::Loading)
.insert_resource(game::FirstLevel(first_level))
@ -82,12 +95,7 @@ fn main() {
.run();
}
fn setup(mut commands: Commands, mut windows: ResMut<Windows>, asset_server: Res<AssetServer>) {
windows
.get_mut(WindowId::primary())
.unwrap()
.set_title(String::from("Bevyjam"));
fn setup(mut commands: Commands, asset_server: Res<AssetServer>) {
let mut assets = LoadingAssets(Vec::new());
commands.insert_resource(
assets.add(asset_server.load::<levels::StoredLevels, _>("game.levels.json")),

View file

@ -39,7 +39,7 @@ fn setup(mut commands: Commands, asset_server: Res<AssetServer>) {
commands
.spawn_bundle(Text2dBundle {
text: Text::from_section(
"BEVYJAM",
"Lux synthesĕ",
TextStyle {
font: font.clone(),
font_size: 96.0,

View file

@ -143,6 +143,6 @@ fn particle_effect_system(
/ particle_effect.radius_squared,
);
}
transform.translation.z = 0.005;
transform.translation.z = 0.005;
}
}