Compare commits

...

4 Commits

@ -0,0 +1 @@
use flake

9
.gitignore vendored

@ -1,6 +1,3 @@
# Generated by Cargo
# will have compiled files and executables
/target/
# These are backup files generated by rustfmt
**/*.rs.bk
/target
.direnv
result

@ -0,0 +1,5 @@
{
"rust-analyzer.linkedProjects": [
"./septadrop/Cargo.toml",
]
}

113
Cargo.lock generated

@ -16,18 +16,18 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
[[package]]
name = "const_format"
version = "0.2.22"
version = "0.2.31"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "22bc6cd49b0ec407b680c3e380182b6ac63b73991cb7602de350352fc309b614"
checksum = "c990efc7a285731f9a4378d81aff2f0e85a2c8781a05ef0f8baa8dac54d0ff48"
dependencies = [
"const_format_proc_macros",
]
[[package]]
name = "const_format_proc_macros"
version = "0.2.22"
version = "0.2.31"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ef196d5d972878a48da7decb7686eded338b4858fbabeed513d63a7c98b2b82d"
checksum = "e026b6ce194a874cb9cf32cd5772d1ef9767cc8fcb5765948d74f37a9d8b2bf6"
dependencies = [
"proc-macro2",
"quote",
@ -76,12 +76,9 @@ dependencies = [
[[package]]
name = "gcd"
version = "2.1.0"
version = "2.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f37978dab2ca789938a83b2f8bc1ef32db6633af9051a6cd409eff72cbaaa79a"
dependencies = [
"paste",
]
checksum = "1d758ba1b47b00caf47f24925c0074ecb20d6dfcffe7f6d53395c0465674841a"
[[package]]
name = "getrandom"
@ -96,11 +93,11 @@ dependencies = [
[[package]]
name = "home"
version = "0.5.3"
version = "0.5.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2456aef2e6b6a9784192ae780c0f15bc57df0e918585282325e8c8ac27737654"
checksum = "5444c27eef6923071f7ebcc33e3444508466a76f7a2b93da00ed6e19f30c1ddb"
dependencies = [
"winapi",
"windows-sys",
]
[[package]]
@ -115,12 +112,6 @@ version = "1.10.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "87f3e037eac156d1775da914196f0f37741a274155e34a0b7e427c35d2a2ecb9"
[[package]]
name = "paste"
version = "1.0.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0744126afe1a6dd7f394cb50a716dbe086cb06e255e53d8d0185d82828358fb5"
[[package]]
name = "ppv-lite86"
version = "0.2.16"
@ -129,18 +120,18 @@ checksum = "eb9f9e6e233e5c4a35559a617bf40a4ec447db2e84c20b55a6f83167b7e57872"
[[package]]
name = "proc-macro2"
version = "1.0.36"
version = "1.0.66"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c7342d5883fbccae1cc37a2353b09c87c9b0f3afd73f5fb9bba687a1f733b029"
checksum = "18fb31db3f9bddb2ea821cde30a9f70117e3f119938b5ee630b7403aa6e2ead9"
dependencies = [
"unicode-xid",
"unicode-ident",
]
[[package]]
name = "quote"
version = "1.0.16"
version = "1.0.33"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b4af2ec4714533fcdf07e886f17025ace8b997b9ce51204ee69b6da831c3da57"
checksum = "5267fca4496028628a95160fc423a33e8b2e6af8a5302579e322e4b520293cae"
dependencies = [
"proc-macro2",
]
@ -223,11 +214,17 @@ dependencies = [
"serde",
]
[[package]]
name = "unicode-ident"
version = "1.0.11"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "301abaae475aa91687eb82514b328ab47a211a533026cb25fc3e519b86adfc3c"
[[package]]
name = "unicode-xid"
version = "0.2.2"
version = "0.2.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8ccb82d61f80a663efe1f787a51b16b5a51e3314d6ac365b08639f52387b33f3"
checksum = "f962df74c8c05a667b5ee8bcf162993134c104e96440b663c8daa176dc772d8c"
[[package]]
name = "wasi"
@ -242,26 +239,70 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c168940144dd21fd8046987c16a46a33d5fc84eec29ef9dcddc2ac9e31526b7c"
[[package]]
name = "winapi"
version = "0.3.9"
name = "windows-sys"
version = "0.48.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419"
checksum = "677d2418bec65e3338edb076e806bc1ec15693c5d0104683f2efe857f61056a9"
dependencies = [
"winapi-i686-pc-windows-gnu",
"winapi-x86_64-pc-windows-gnu",
"windows-targets",
]
[[package]]
name = "winapi-i686-pc-windows-gnu"
version = "0.4.0"
name = "windows-targets"
version = "0.48.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9a2fa6e2155d7247be68c096456083145c183cbbbc2764150dda45a87197940c"
dependencies = [
"windows_aarch64_gnullvm",
"windows_aarch64_msvc",
"windows_i686_gnu",
"windows_i686_msvc",
"windows_x86_64_gnu",
"windows_x86_64_gnullvm",
"windows_x86_64_msvc",
]
[[package]]
name = "windows_aarch64_gnullvm"
version = "0.48.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6"
checksum = "2b38e32f0abccf9987a4e3079dfb67dcd799fb61361e53e2882c3cbaf0d905d8"
[[package]]
name = "winapi-x86_64-pc-windows-gnu"
version = "0.4.0"
name = "windows_aarch64_msvc"
version = "0.48.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "dc35310971f3b2dbbf3f0690a219f40e2d9afcf64f9ab7cc1be722937c26b4bc"
[[package]]
name = "windows_i686_gnu"
version = "0.48.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a75915e7def60c94dcef72200b9a8e58e5091744960da64ec734a6c6e9b3743e"
[[package]]
name = "windows_i686_msvc"
version = "0.48.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8f55c233f70c4b27f66c523580f78f1004e8b5a8b659e05a4eb49d4166cca406"
[[package]]
name = "windows_x86_64_gnu"
version = "0.48.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "53d40abd2583d23e4718fddf1ebec84dbff8381c07cae67ff7768bbf19c6718e"
[[package]]
name = "windows_x86_64_gnullvm"
version = "0.48.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0b7b52767868a23d5bab768e390dc5f5c55825b6d30b86c844ff2dc7414044cc"
[[package]]
name = "windows_x86_64_msvc"
version = "0.48.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f"
checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538"
[[package]]
name = "winres"

@ -1,22 +1,3 @@
[package]
name = "septadrop"
version = "1.1.0"
edition = "2021"
build = "build.rs"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[profile.release]
strip = true
lto = true
codegen-units = 1
[dependencies]
sfml = "0.16.0"
rand = "0.8.5"
home = "0.5.3"
gcd = "2.1.0"
const_format = "0.2.22"
[build-dependencies]
winres = "0.1"
[workspace]
members = ["septadrop"]
resolver = "2"

@ -0,0 +1,96 @@
{
"nodes": {
"flake-utils": {
"inputs": {
"systems": "systems"
},
"locked": {
"lastModified": 1681202837,
"narHash": "sha256-H+Rh19JDwRtpVPAWp64F+rlEtxUWBAQW28eAi3SRSzg=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "cfacdce06f30d2b68473a46042957675eebb3401",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "flake-utils",
"type": "github"
}
},
"nixpkgs": {
"locked": {
"lastModified": 1693663421,
"narHash": "sha256-ImMIlWE/idjcZAfxKK8sQA7A1Gi/O58u5/CJA+mxvl8=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "e56990880811a451abd32515698c712788be5720",
"type": "github"
},
"original": {
"owner": "NixOS",
"ref": "nixos-unstable",
"repo": "nixpkgs",
"type": "github"
}
},
"nixpkgs_2": {
"locked": {
"lastModified": 1681358109,
"narHash": "sha256-eKyxW4OohHQx9Urxi7TQlFBTDWII+F+x2hklDOQPB50=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "96ba1c52e54e74c3197f4d43026b3f3d92e83ff9",
"type": "github"
},
"original": {
"owner": "NixOS",
"ref": "nixpkgs-unstable",
"repo": "nixpkgs",
"type": "github"
}
},
"root": {
"inputs": {
"nixpkgs": "nixpkgs",
"rust-overlay": "rust-overlay"
}
},
"rust-overlay": {
"inputs": {
"flake-utils": "flake-utils",
"nixpkgs": "nixpkgs_2"
},
"locked": {
"lastModified": 1693879802,
"narHash": "sha256-f+ceOsPpyiuExQIubKkLkyTZZiza1qJQGou4FZu9q1A=",
"owner": "oxalica",
"repo": "rust-overlay",
"rev": "8a1d1bbe4c13eeb518e6159dd122c4f721f7543e",
"type": "github"
},
"original": {
"owner": "oxalica",
"repo": "rust-overlay",
"type": "github"
}
},
"systems": {
"locked": {
"lastModified": 1681028828,
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
"owner": "nix-systems",
"repo": "default",
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
"type": "github"
},
"original": {
"owner": "nix-systems",
"repo": "default",
"type": "github"
}
}
},
"root": "root",
"version": 7
}

@ -0,0 +1,66 @@
/*
Some utility commands:
- `nix flake update --commit-lock-file`
- `nix flake lock update-input <input>`
- `nix build .#septadrop` or `nix build .`
- `nix run .#septadrop` or `nix run .`
*/
{
description = "A block game made in Rust and SFML.";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
rust-overlay.url = "github:oxalica/rust-overlay";
};
outputs = { self, nixpkgs, rust-overlay }:
let
overlays = [ (import rust-overlay) ];
system = "x86_64-linux";
pkgs = import nixpkgs {
inherit system overlays;
};
rustSettings = with pkgs; {
src = ./.;
cargoHash = nixpkgs.lib.fakeHash;
};
meta = with nixpkgs.lib; {
homepage = "https://git.elnu.com/ElnuDev/septadrop";
license = [ licenses.gpl3 ];
platforms = [ system ];
maintainers = with maintainers; [ elnudev ];
};
in {
devShells.${system}.default = with pkgs; mkShell {
packages = [
(pkgs.rust-bin.stable.latest.default.override {
extensions = [ "rust-src" ];
})
cargo-edit
bacon
];
inputsFrom = with self.packages.${system}; [ septadrop ];
};
packages.${system} = {
default = self.packages.${system}.septadrop;
septadrop = pkgs.rustPlatform.buildRustPackage (rustSettings // {
pname = "septadrop";
version = "1.1.0";
buildAndTestSubdir = "septadrop";
buildInputs = with pkgs; [ csfml ];
cargoHash = "sha256-1Eis+FuISmv1bn4TvOdKDxxjk/ypNqyqzLoqfmXaEVQ=";
postPatch = ''
pushd septadrop
sed -i -E "s|\"res\"|\"''${out}\/share\"|" src/config.rs
mkdir -p $out/share
cp -r res/* $out/share
popd
'';
meta = meta // {
description = "A block game made in Rust and SFML.";
};
});
};
};
}

@ -0,0 +1,22 @@
[package]
name = "septadrop"
version = "1.1.0"
edition = "2021"
build = "build.rs"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[profile.release]
strip = true
lto = true
codegen-units = 1
[dependencies]
sfml = "0.16.0"
rand = "0.8.5"
home = "0.5.5"
gcd = "2.3.0"
const_format = "0.2.31"
[build-dependencies]
winres = "0.1"

Before

Width:  |  Height:  |  Size: 2.9 KiB

After

Width:  |  Height:  |  Size: 2.9 KiB

Before

Width:  |  Height:  |  Size: 8.8 KiB

After

Width:  |  Height:  |  Size: 8.8 KiB

Before

Width:  |  Height:  |  Size: 2.5 KiB

After

Width:  |  Height:  |  Size: 2.5 KiB

Before

Width:  |  Height:  |  Size: 308 B

After

Width:  |  Height:  |  Size: 308 B

Before

Width:  |  Height:  |  Size: 540 B

After

Width:  |  Height:  |  Size: 540 B

Before

Width:  |  Height:  |  Size: 2.5 KiB

After

Width:  |  Height:  |  Size: 2.5 KiB

@ -23,7 +23,7 @@ pub fn texture(name: &str) -> String {
}
fn get_level(lines: u32) -> u32 {
return std::cmp::min(lines / LINES_PER_LEVEL, 15);
std::cmp::min(lines / LINES_PER_LEVEL, 15)
}
fn get_update_interval(level: u32) -> u32 {
@ -53,7 +53,7 @@ fn handle_resize_events(code: Key, current_scale: &mut u32, render_window: &mut
render_window.set_size(Vector2u::new(WINDOW_WIDTH, WINDOW_HEIGHT) * new_current_scale);
let mut file = std::fs::OpenOptions::new()
.write(true)
.open(&scale_file_path)
.open(scale_file_path)
.unwrap();
file.write_all(new_current_scale.to_string().as_bytes()).unwrap();
file.flush().unwrap();
@ -206,67 +206,64 @@ fn main() {
let mut new_highscore_sound = Sound::with_buffer(&new_highscore_buffer);
while window.is_open() {
loop {
match window.poll_event() {
Some(event) => match event {
Event::Closed | Event::KeyPressed {
code: Key::Q,
alt: _,
ctrl: true,
shift: _,
system: _,
} => window.close(),
Event::LostFocus => {
toggle_pause = true;
paused_from_lost_focus = true;
while let Some(event) = window.poll_event() {
match event {
Event::Closed | Event::KeyPressed {
code: Key::Q,
alt: _,
ctrl: true,
shift: _,
system: _,
} => window.close(),
Event::LostFocus => {
toggle_pause = true;
paused_from_lost_focus = true;
}
Event::KeyPressed {
code,
alt: _,
ctrl: true,
shift: _,
system: _,
} => {
handle_resize_events(code, &mut current_scale, &mut window, &scale_file_path);
},
Event::KeyPressed {
code,
alt: _,
ctrl: _,
shift: _,
system: _,
} => match code {
Key::ESCAPE => toggle_pause = true,
Key::SPACE => snap = true,
Key::UP => rotate = true,
Key::DOWN => fast_forward = true,
Key::LEFT => {
move_left = true;
move_left_immediate = true;
move_clock.restart();
}
Key::RIGHT => {
move_right = true;
move_right_immediate = true;
move_clock.restart();
}
Event::KeyPressed {
code,
alt: _,
ctrl: true,
shift: _,
system: _,
} => {
handle_resize_events(code, &mut current_scale, &mut window, &scale_file_path);
},
Event::KeyPressed {
code,
alt: _,
ctrl: _,
shift: _,
system: _,
} => match code {
Key::ESCAPE => toggle_pause = true,
Key::SPACE => snap = true,
Key::UP => rotate = true,
Key::DOWN => fast_forward = true,
Key::LEFT => {
move_left = true;
move_left_immediate = true;
move_clock.restart();
}
Key::RIGHT => {
move_right = true;
move_right_immediate = true;
move_clock.restart();
}
_ => {}
},
Event::KeyReleased {
code,
alt: _,
ctrl: _,
shift: _,
system: _,
} => match code {
Key::DOWN => fast_forward = false,
Key::LEFT => move_left = false,
Key::RIGHT => move_right = false,
_ => {}
},
_ => {}
},
None => break,
Event::KeyReleased {
code,
alt: _,
ctrl: _,
shift: _,
system: _,
} => match code {
Key::DOWN => fast_forward = false,
Key::LEFT => move_left = false,
Key::RIGHT => move_right = false,
_ => {}
},
_ => {}
}
}
@ -297,8 +294,8 @@ fn main() {
if paused {
loop {
match window.wait_event() {
Some(event) => match event {
if let Some(event) = window.wait_event() {
match event {
Event::Closed | Event::KeyPressed {
code: Key::Q,
alt: _,
@ -332,7 +329,6 @@ fn main() {
},
_ => {}
}
_ => {}
}
}
}

@ -29,7 +29,7 @@ impl<'a> Block<'a> {
if !cell {
continue;
}
let mut rotated = Vector2i::new(x as i32, y as i32);
let mut rotated = Vector2i::new(x, y);
if self.block_type.rotate {
let center_x = row.len() as i32 / 2;
let center_y = self.block_type.grid.len() as i32 / 2;
Loading…
Cancel
Save