Base game template
This commit is contained in:
parent
d946e026c6
commit
f83c7c0781
7 changed files with 6158 additions and 0 deletions
3
.gitignore
vendored
3
.gitignore
vendored
|
|
@ -1 +1,4 @@
|
||||||
|
/build/*
|
||||||
|
!/build/index.html
|
||||||
|
|
||||||
/target
|
/target
|
||||||
|
|
|
||||||
6045
Cargo.lock
generated
Normal file
6045
Cargo.lock
generated
Normal file
File diff suppressed because it is too large
Load diff
24
Cargo.toml
24
Cargo.toml
|
|
@ -4,3 +4,27 @@ version = "0.1.0"
|
||||||
edition = "2024"
|
edition = "2024"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
|
bevy = "0.19.0"
|
||||||
|
chacha20 = { version = "0.10.1", default-features = false, features = ["rng"] }
|
||||||
|
getrandom = "0.4.3"
|
||||||
|
rand = "0.10.2"
|
||||||
|
|
||||||
|
[features]
|
||||||
|
default = ["debug"]
|
||||||
|
debug = ["bevy/debug"]
|
||||||
|
wasm = ["getrandom/wasm_js"]
|
||||||
|
|
||||||
|
# Enable some optimization in development so the game runs well.
|
||||||
|
# Enable more optimization for dependencies because they change less often.
|
||||||
|
[profile.dev]
|
||||||
|
opt-level = 1
|
||||||
|
package."*".opt-level = 3
|
||||||
|
|
||||||
|
[profile.release]
|
||||||
|
codegen-units = 1
|
||||||
|
lto = "thin"
|
||||||
|
|
||||||
|
[profile.wasm-release]
|
||||||
|
inherits = "release"
|
||||||
|
opt-level = "s" # TODO: compare with "z"
|
||||||
|
strip = "debuginfo"
|
||||||
|
|
|
||||||
16
Makefile
Normal file
16
Makefile
Normal file
|
|
@ -0,0 +1,16 @@
|
||||||
|
.DEFAULT_GOAL := help
|
||||||
|
|
||||||
|
.PHONY: help
|
||||||
|
help: ## List targets in this Makefile
|
||||||
|
@awk 'BEGIN { FS = ":|:.*?## "; OFS="\t" }; /^[0-9a-zA-Z_-]+?:/ { print $$1, $$2 }' $(MAKEFILE_LIST) \
|
||||||
|
| column --separator $$'\t' --table --table-wrap 2 --output-separator ' ' \
|
||||||
|
| sort --dictionary-order
|
||||||
|
|
||||||
|
.PHONY: build
|
||||||
|
build:
|
||||||
|
cargo build --release --target wasm32-unknown-unknown --no-default-features --features wasm
|
||||||
|
wasm-bindgen --target web --out-dir build target/wasm32-unknown-unknown/release/breakout.wasm
|
||||||
|
|
||||||
|
.PHONY: publish
|
||||||
|
publish:
|
||||||
|
rsync --verbose --checksum --recursive --safe-links --delete --progress build/ root@lab:/www/games/breakout
|
||||||
23
build/index.html
Normal file
23
build/index.html
Normal file
|
|
@ -0,0 +1,23 @@
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<style>
|
||||||
|
body {
|
||||||
|
height: 100vh;
|
||||||
|
width: 100vw;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
background-color: #aaaaaa;
|
||||||
|
}
|
||||||
|
canvas {
|
||||||
|
background-color: black;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
<title>Pong</title>
|
||||||
|
</head>
|
||||||
|
<script type="module">
|
||||||
|
import init from './breakout.js';
|
||||||
|
init();
|
||||||
|
</script>
|
||||||
|
</html>
|
||||||
5
clippy.toml
Normal file
5
clippy.toml
Normal file
|
|
@ -0,0 +1,5 @@
|
||||||
|
# Bevy query types can get a bit more complicated than usual Rust code.
|
||||||
|
type-complexity-threshold = 1000
|
||||||
|
|
||||||
|
# Bevy systems sometimes rely on a lot of different entities.
|
||||||
|
too-many-arguments-threshold = 10
|
||||||
42
src/main.rs
42
src/main.rs
|
|
@ -1,3 +1,45 @@
|
||||||
|
use bevy::camera::ScalingMode;
|
||||||
|
use bevy::prelude::*;
|
||||||
|
|
||||||
|
pub const WORLD_SIZE: Vec2 = Vec2::new(480., 640.);
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
|
App::new()
|
||||||
|
.insert_resource(ClearColor(Color::BLACK))
|
||||||
|
.add_plugins(DefaultPlugins.set(WindowPlugin {
|
||||||
|
// Until there's a reliable way to hint that a game window should
|
||||||
|
// float on tiling window managers, the most reliable way to achieve
|
||||||
|
// that is to define a fixed non-resizable window.
|
||||||
|
//
|
||||||
|
// https://github.com/rust-windowing/winit/issues/862#issuecomment-2047791401
|
||||||
|
primary_window: Some(Window {
|
||||||
|
resize_constraints: WindowResizeConstraints {
|
||||||
|
min_width: WORLD_SIZE.x,
|
||||||
|
min_height: WORLD_SIZE.y,
|
||||||
|
max_width: WORLD_SIZE.x,
|
||||||
|
max_height: WORLD_SIZE.y,
|
||||||
|
},
|
||||||
|
..default()
|
||||||
|
}),
|
||||||
|
..default()
|
||||||
|
}))
|
||||||
|
.add_systems(Startup, (setup, greet).chain())
|
||||||
|
.run();
|
||||||
|
}
|
||||||
|
|
||||||
|
fn setup(mut commands: Commands) {
|
||||||
|
commands.spawn((
|
||||||
|
Camera2d,
|
||||||
|
Projection::Orthographic(OrthographicProjection {
|
||||||
|
scaling_mode: ScalingMode::Fixed {
|
||||||
|
width: WORLD_SIZE.x,
|
||||||
|
height: WORLD_SIZE.y,
|
||||||
|
},
|
||||||
|
..OrthographicProjection::default_2d()
|
||||||
|
}),
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
|
fn greet() {
|
||||||
println!("Hello, world!");
|
println!("Hello, world!");
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue