From 60ecb6336025e3bf4ae6be0a9122e1abd06895ac Mon Sep 17 00:00:00 2001 From: ZennDev1337 Date: Mon, 4 Sep 2023 09:22:04 +0200 Subject: [PATCH] added demo 7 pong to the repo --- Cargo.lock | 14 ++++++------- Cargo.toml | 2 +- .../demo7}/Cargo.toml | 4 ++-- .../demo7}/src/lib.rs | 0 Project/game/src/lib.rs | 10 ++++++++++ README.md | 20 +++---------------- run | 6 +++--- run.bat | 2 ++ 8 files changed, 28 insertions(+), 30 deletions(-) rename Examples/{pong => Arduboy-Tutorials/demo7}/Cargo.toml (73%) rename Examples/{pong => Arduboy-Tutorials/demo7}/src/lib.rs (100%) diff --git a/Cargo.lock b/Cargo.lock index b667302..2e93f88 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -72,6 +72,13 @@ dependencies = [ "arduboy-rust", ] +[[package]] +name = "demo7" +version = "0.1.0" +dependencies = [ + "arduboy-rust", +] + [[package]] name = "drboy" version = "0.1.0" @@ -138,13 +145,6 @@ version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "de96540e0ebde571dc55c73d60ef407c653844e6f9a1e2fdbd40c07b9252d812" -[[package]] -name = "pong" -version = "0.1.0" -dependencies = [ - "arduboy-rust", -] - [[package]] name = "progmem" version = "0.1.0" diff --git a/Cargo.toml b/Cargo.toml index 19e2408..535e69e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -10,7 +10,7 @@ members = [ "Examples/Arduboy-Tutorials/demo4", "Examples/Arduboy-Tutorials/demo5", "Examples/Arduboy-Tutorials/demo6", - "Examples/pong", + "Examples/Arduboy-Tutorials/demo7", "Examples/drboy", "Examples/rustacean", "Examples/snake", diff --git a/Examples/pong/Cargo.toml b/Examples/Arduboy-Tutorials/demo7/Cargo.toml similarity index 73% rename from Examples/pong/Cargo.toml rename to Examples/Arduboy-Tutorials/demo7/Cargo.toml index 032498e..6947122 100644 --- a/Examples/pong/Cargo.toml +++ b/Examples/Arduboy-Tutorials/demo7/Cargo.toml @@ -1,5 +1,5 @@ [package] -name = "pong" +name = "demo7" version = "0.1.0" authors = ["Brian Bowman "] license = "MIT OR Apache-2.0" @@ -9,4 +9,4 @@ edition = "2021" crate-type = ["staticlib"] [dependencies] -arduboy-rust = { path = "../../arduboy-rust" } +arduboy-rust = { path = "../../../arduboy-rust" } diff --git a/Examples/pong/src/lib.rs b/Examples/Arduboy-Tutorials/demo7/src/lib.rs similarity index 100% rename from Examples/pong/src/lib.rs rename to Examples/Arduboy-Tutorials/demo7/src/lib.rs diff --git a/Project/game/src/lib.rs b/Project/game/src/lib.rs index ff15aa6..dd16bbd 100644 --- a/Project/game/src/lib.rs +++ b/Project/game/src/lib.rs @@ -15,6 +15,10 @@ const arduboy: Arduboy2 = Arduboy2::new(); #[no_mangle] pub unsafe extern "C" fn setup() { // put your setup code here, to run once: + arduboy.begin(); + arduboy.init_random_seed(); + arduboy.set_frame_rate(60); + arduboy.clear(); } // The loop() function repeats forever after setup() is done @@ -22,4 +26,10 @@ pub unsafe extern "C" fn setup() { #[export_name = "loop"] pub unsafe extern "C" fn loop_() { // put your main code here, to run repeatedly: + if !arduboy.next_frame() { + return; + } + arduboy.clear(); + + arduboy.display(); } diff --git a/README.md b/README.md index 3b93274..9437ade 100644 --- a/README.md +++ b/README.md @@ -100,22 +100,6 @@ Windows: .\run.bat snake ``` -### Pong - -To upload pong to the Arduboy use: - -Linux: - -```bash -./run pong -``` - -Windows: - -```ps1 -.\run.bat pong -``` - ### I'm now a Rustacean <3 To upload rustacean to the Arduboy use: @@ -141,7 +125,7 @@ Windows: - [demo5] [Make Your Own Arduboy Game: Part 5 - Your First Game!](https://community.arduboy.com/t/make-your-own-arduboy-game-part-5-your-first-game/7928) - [demo6] [Make Your Own Arduboy Game: Part 6 - Graphics!](https://community.arduboy.com/t/make-your-own-arduboy-game-part-6-graphics/7929) Link for the [arduboy-tile-converter](https://github.com/Team-ARG-Museum/arduboy-tile-converter) -- not done [demo7] [Make Your Own Arduboy Game: Part 7 - Make Pong From Scratch!](https://community.arduboy.com/t/make-your-own-arduboy-game-part-7-make-pong-from-scratch/7930) +- [demo7] [Make Your Own Arduboy Game: Part 7 - Make Pong From Scratch!](https://community.arduboy.com/t/make-your-own-arduboy-game-part-7-make-pong-from-scratch/7930) - not done [demo8] [Make Your Own Arduboy Game: Part 8 - Starting DinoSmasher](https://community.arduboy.com/t/make-your-own-arduboy-game-part-8-starting-dinosmasher/7932) - [eeprom] [Help, I’m struggling with EEPROM!](https://community.arduboy.com/t/help-im-struggling-with-eeprom/7178) - [progmem] Usage of the big 28'000 Bytes flash memory for Bitmaps Sound sequeces and Text. @@ -157,6 +141,7 @@ Linux: ./run demo4 ./run demo5 ./run demo6 +./run demo7 ./run eeprom ./run eeprom-byte ./run progmem @@ -171,6 +156,7 @@ Windows: .\run.bat demo4 .\run.bat demo5 .\run.bat demo6 +.\run.bat demo7 .\run.bat eeprom .\run.bat eeprom-byte .\run.bat progmem diff --git a/run b/run index 7742601..ed6bf41 100755 --- a/run +++ b/run @@ -13,9 +13,6 @@ elif [ "$option" = "doc" ] then cargo doc -p arduboy-rust && rm -r ./docs/doc/ && cp -r ./target/arduboy/doc ./docs/ elif [ "$option" = "snake" ] -then - upload -elif [ "$option" = "pong" ] then upload elif [ "$option" = "drboy" ] @@ -49,6 +46,9 @@ elif [ "$option" = "demo5" ] then upload elif [ "$option" = "demo6" ] +then + upload +elif [ "$option" = "demo7" ] then upload else diff --git a/run.bat b/run.bat index e4dc655..d035a50 100644 --- a/run.bat +++ b/run.bat @@ -37,6 +37,8 @@ goto :eof goto :run ) else if %option%==demo6 ( goto :run +) else if %option%==demo7 ( + goto :run ) else ( goto :help )