Compare commits
2 commits
7de16e410e
...
a0f66f4fd0
Author | SHA1 | Date | |
---|---|---|---|
a0f66f4fd0 | |||
7be75ce106 |
12 changed files with 79 additions and 38 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -1,3 +1,4 @@
|
||||||
.direnv/
|
.direnv/
|
||||||
.devenv/
|
.devenv/
|
||||||
/target
|
/target
|
||||||
|
dist/
|
||||||
|
|
10
Cargo.lock
generated
10
Cargo.lock
generated
|
@ -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"
|
||||||
|
|
|
@ -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
|
||||||
|
|
||||||
|
|
|
@ -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
15
index.html
Normal 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
5
justfile
Normal 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
27
main.css
Normal 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;
|
||||||
|
}
|
16
src/drops.rs
16
src/drops.rs
|
@ -147,8 +147,8 @@ struct CrateCollision {
|
||||||
}
|
}
|
||||||
|
|
||||||
enum CollisionType {
|
enum CollisionType {
|
||||||
Player(Entity),
|
Player,
|
||||||
Scene(Entity),
|
Scene,
|
||||||
}
|
}
|
||||||
|
|
||||||
fn crate_collisions(
|
fn crate_collisions(
|
||||||
|
@ -165,13 +165,13 @@ fn crate_collisions(
|
||||||
match collision_event {
|
match collision_event {
|
||||||
CollisionEvent::Started(e1, e2, _) if crates.contains(e1) || crates.contains(e2) => {
|
CollisionEvent::Started(e1, e2, _) if crates.contains(e1) || crates.contains(e2) => {
|
||||||
let (coll_type, crate_) = if scene_objs.contains(e1) {
|
let (coll_type, crate_) = if scene_objs.contains(e1) {
|
||||||
(CollisionType::Scene(*e1), e2)
|
(CollisionType::Scene, e2)
|
||||||
} else if scene_objs.contains(e2) {
|
} else if scene_objs.contains(e2) {
|
||||||
(CollisionType::Scene(*e2), e1)
|
(CollisionType::Scene, e1)
|
||||||
} else if *e2 == p {
|
} else if *e2 == p {
|
||||||
(CollisionType::Player(*e2), e1)
|
(CollisionType::Player, e1)
|
||||||
} else if *e1 == p {
|
} else if *e1 == p {
|
||||||
(CollisionType::Player(*e1), e2)
|
(CollisionType::Player, e2)
|
||||||
} else if crates.contains(e1) && crates.contains(e2) {
|
} else if crates.contains(e1) && crates.contains(e2) {
|
||||||
continue;
|
continue;
|
||||||
} else {
|
} else {
|
||||||
|
@ -192,7 +192,7 @@ fn crate_collisions(
|
||||||
|
|
||||||
fn delete_on_env_coll(mut ev_colls: EventReader<CrateCollision>, mut commands: Commands) {
|
fn delete_on_env_coll(mut ev_colls: EventReader<CrateCollision>, mut commands: Commands) {
|
||||||
for CrateCollision { coll_crate, with } in ev_colls.read() {
|
for CrateCollision { coll_crate, with } in ev_colls.read() {
|
||||||
if let CollisionType::Player(_) = with {
|
if let CollisionType::Player = with {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -208,7 +208,7 @@ fn player_coll(
|
||||||
mut commands: Commands,
|
mut commands: Commands,
|
||||||
) {
|
) {
|
||||||
for CrateCollision { coll_crate, with } in ev_colls.read() {
|
for CrateCollision { coll_crate, with } in ev_colls.read() {
|
||||||
if let CollisionType::Scene(_) = with {
|
if let CollisionType::Scene = with {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,12 +1,15 @@
|
||||||
use bevy::{app::AppExit, prelude::*};
|
use bevy::prelude::*;
|
||||||
|
|
||||||
use crate::{game_state::GameTimer, GameState};
|
use crate::{game_state::GameTimer, main_menu::button_color_system, GameState};
|
||||||
pub fn game_over_menu_plugin(app: &mut App) {
|
pub fn game_over_menu_plugin(app: &mut App) {
|
||||||
app.add_systems(
|
app.add_systems(
|
||||||
OnEnter(GameState::GameOver),
|
OnEnter(GameState::GameOver),
|
||||||
game_over_menu_setup.in_set(GameOverMenuSet),
|
game_over_menu_setup.in_set(GameOverMenuSet),
|
||||||
)
|
)
|
||||||
.add_systems(Update, button_action.in_set(GameOverMenuSet))
|
.add_systems(
|
||||||
|
Update,
|
||||||
|
(button_action, button_color_system).in_set(GameOverMenuSet),
|
||||||
|
)
|
||||||
.add_systems(OnExit(GameState::GameOver), exit_menu);
|
.add_systems(OnExit(GameState::GameOver), exit_menu);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -103,7 +106,6 @@ fn game_over_menu_setup(mut commands: Commands, timer: Query<&GameTimer>) {
|
||||||
|
|
||||||
fn button_action(
|
fn button_action(
|
||||||
interaction_query: Query<(&Interaction, &ButtonAction), (Changed<Interaction>, With<Button>)>,
|
interaction_query: Query<(&Interaction, &ButtonAction), (Changed<Interaction>, With<Button>)>,
|
||||||
mut ev_exit: EventWriter<AppExit>,
|
|
||||||
mut game_state: ResMut<NextState<GameState>>,
|
mut game_state: ResMut<NextState<GameState>>,
|
||||||
) {
|
) {
|
||||||
for (interaction, action) in &interaction_query {
|
for (interaction, action) in &interaction_query {
|
||||||
|
|
12
src/main.rs
12
src/main.rs
|
@ -1,14 +1,12 @@
|
||||||
|
#![allow(clippy::type_complexity)]
|
||||||
use crate::main_menu::main_menu_plugin;
|
use crate::main_menu::main_menu_plugin;
|
||||||
use bevy::{
|
use bevy::prelude::*;
|
||||||
prelude::*,
|
|
||||||
sprite::{MaterialMesh2dBundle, Mesh2dHandle},
|
|
||||||
};
|
|
||||||
use bevy_rapier2d::prelude::*;
|
use bevy_rapier2d::prelude::*;
|
||||||
use drops::spawner_plugin;
|
use drops::spawner_plugin;
|
||||||
use game_over_menu::{game_over_menu_plugin, GameOverMenuSet};
|
use game_over_menu::{game_over_menu_plugin, GameOverMenuSet};
|
||||||
use game_state::state_and_ui_plugin;
|
use game_state::state_and_ui_plugin;
|
||||||
use main_menu::MainMenuSet;
|
use main_menu::MainMenuSet;
|
||||||
use player::{player_plugin, GameOverEvent, LifeChangeEvent};
|
use player::{player_plugin, GameOverEvent};
|
||||||
use scene::scene_plugin;
|
use scene::scene_plugin;
|
||||||
|
|
||||||
const METER: f32 = 48.;
|
const METER: f32 = 48.;
|
||||||
|
@ -28,7 +26,7 @@ fn main() {
|
||||||
rapier_config.timestep_mode = TimestepMode::Variable {
|
rapier_config.timestep_mode = TimestepMode::Variable {
|
||||||
max_dt: 1.0 / 60.0,
|
max_dt: 1.0 / 60.0,
|
||||||
time_scale: 1.0,
|
time_scale: 1.0,
|
||||||
substeps: 4,
|
substeps: 1,
|
||||||
};
|
};
|
||||||
App::new()
|
App::new()
|
||||||
.add_plugins(DefaultPlugins)
|
.add_plugins(DefaultPlugins)
|
||||||
|
@ -63,7 +61,7 @@ fn handle_game_over(
|
||||||
mut ev_gameover: EventReader<GameOverEvent>,
|
mut ev_gameover: EventReader<GameOverEvent>,
|
||||||
mut game_state: ResMut<NextState<GameState>>,
|
mut game_state: ResMut<NextState<GameState>>,
|
||||||
) {
|
) {
|
||||||
for ev in ev_gameover.read() {
|
for _ in ev_gameover.read() {
|
||||||
game_state.set(GameState::GameOver)
|
game_state.set(GameState::GameOver)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
use bevy::{app::AppExit, prelude::*};
|
use bevy::{app::AppExit, prelude::*};
|
||||||
|
|
||||||
use crate::game_over_menu::GameOverMenuSet;
|
|
||||||
use crate::GameState;
|
use crate::GameState;
|
||||||
|
|
||||||
#[derive(SystemSet, Debug, Clone, PartialEq, Eq, Hash)]
|
#[derive(SystemSet, Debug, Clone, PartialEq, Eq, Hash)]
|
||||||
|
@ -12,12 +11,7 @@ pub fn main_menu_plugin(app: &mut App) {
|
||||||
setup_main_menu_ui.in_set(MainMenuSet),
|
setup_main_menu_ui.in_set(MainMenuSet),
|
||||||
)
|
)
|
||||||
.add_systems(Update, button_action.in_set(MainMenuSet))
|
.add_systems(Update, button_action.in_set(MainMenuSet))
|
||||||
.add_systems(
|
.add_systems(Update, button_color_system.in_set(MainMenuSet))
|
||||||
Update,
|
|
||||||
button_color_system
|
|
||||||
.in_set(MainMenuSet)
|
|
||||||
.in_set(GameOverMenuSet),
|
|
||||||
)
|
|
||||||
.add_systems(OnExit(GameState::MainMenu), exit_menu.in_set(MainMenuSet));
|
.add_systems(OnExit(GameState::MainMenu), exit_menu.in_set(MainMenuSet));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
use bevy::{
|
use bevy::{
|
||||||
prelude::*,
|
prelude::*,
|
||||||
sprite::{MaterialMesh2dBundle, Mesh2dHandle},
|
sprite::{MaterialMesh2dBundle, Mesh2dHandle},
|
||||||
utils::{HashMap, HashSet},
|
utils::HashSet,
|
||||||
};
|
};
|
||||||
use bevy_rapier2d::prelude::*;
|
use bevy_rapier2d::prelude::*;
|
||||||
|
|
||||||
|
@ -14,6 +14,7 @@ pub struct Player {
|
||||||
lives: u8,
|
lives: u8,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[allow(unused)]
|
||||||
#[derive(Event)]
|
#[derive(Event)]
|
||||||
pub enum LifeChangeEvent {
|
pub enum LifeChangeEvent {
|
||||||
Gained,
|
Gained,
|
||||||
|
|
Loading…
Reference in a new issue