{"id":17040973,"url":"https://github.com/uggla/fztaosi","last_synced_at":"2026-04-29T08:09:06.784Z","repository":{"id":61322034,"uuid":"493008256","full_name":"uggla/fztaosi","owner":"uggla","description":null,"archived":false,"fork":false,"pushed_at":"2023-04-30T17:07:56.000Z","size":1501,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-03-14T19:59:23.094Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/uggla.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-05-16T21:42:34.000Z","updated_at":"2023-01-02T17:07:08.000Z","dependencies_parsed_at":"2024-10-14T09:11:05.868Z","dependency_job_id":"b3cb33fe-0d3c-4ae1-b3c4-568a8ad8790d","html_url":"https://github.com/uggla/fztaosi","commit_stats":{"total_commits":28,"total_committers":2,"mean_commits":14.0,"dds":0.0714285714285714,"last_synced_commit":"f262bc49c2db6a0c2385499f2bb6864b91664d1a"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/uggla%2Ffztaosi","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/uggla%2Ffztaosi/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/uggla%2Ffztaosi/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/uggla%2Ffztaosi/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/uggla","download_url":"https://codeload.github.com/uggla/fztaosi/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245040189,"owners_count":20551301,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-14T09:11:01.033Z","updated_at":"2026-04-29T08:09:01.749Z","avatar_url":"https://github.com/uggla.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# From Zero To A Old School Intro\n\nThis is a live demo/lab to discover Rust smoothly by creating an\n[intro](https://en.wikipedia.org/wiki/Crack_intro).\n\nOptions have been passed to Cargo.toml to reduce the size of the binary.\nAs well all assets are embedded into the binary to deploy it easilly.\nA rpm can be built for the project using `cargo rpm build`.\n\n## Authors\n\n- [@Uggla](https://www.github.com/Uggla)\n\n## Run Locally (mainly for development purposes)\n\n1. Clone the project\n\n```bash\n  git clone https://github.com/uggla/fztaosi\n```\n\n2. Go to the project directory\n\n```bash\n  cd fztaosi\n```\n\n### Native\n1. Install Rust following the instructions [here](https://www.rust-lang.org/fr/learn/get-started).\n\n   *Tips: the rustup method is the simplest one.*\n\n2. Install required library for macroquad\n\n* Ubuntu system dependencies\n```bash\napt install pkg-config libx11-dev libxi-dev libgl1-mesa-dev libasound2-dev\n```\n\n* Fedora system dependencies\n```bash\ndnf install libX11-devel libXi-devel mesa-libGL-devel alsa-lib-devel\n```\n\n* Windows and MacOS system\n```\nNo dependencies are required for Windows or MacOS\n```\n\n3. Run\n```bash\ncargo run --release\n```\n\n#### Wasm32 client\n\n1. Follow the above instruction of the native build.\n\n2. Install basic-http-server\n```bash\ncargo install basic-http-server\n```\n\n3. Add the wasm32 compilation target\n```bash\nrustup target add wasm32-unknown-unknown\n```\n\n4. Run\n```bash\ncargo build --target wasm32-unknown-unknown --release\n```\n\n5. Serve the files and open the browser\n```bash\nbasic-http-server\nxdg-open http://127.0.0.1:4000\n```\n\n## Lab steps:\n\n1. Welcome, goal of the lab\n    * Show that rust is not so difficult\n    * Learn some rust concept working on a simple visual program\n    * Disclaimer, we can not go into all details, some parts will not be\n      explained\n\n2. Audience question about people backgroud in order adapt speed and details\n\n2. Quickly explain what is an intro\n\n3. Quickly explain Rust benefits and particularities\n    * alternative to C and C++ Mozilla\n    * safety, strict, try to avoid developer mistakes\n    * no GC\n    * fast ideal for Game, OS, mainly low level programming...\n\n4. Quickly explain Macroquad\n\n5. Install rustup, cargo, rust and clippy.\n\n6. Explain rust-analyzer and editor integration.\n\n7. cargo init --bin\n\n8. Hello world, cargo build, cargo run\n\n9. Hello macroquad\n    * dep in Cargo.toml\n    * dep for Linux\n    * prelude\n    * main loop\n\n    See \"initial commit\" commit\n\n10. Draw a first star\n    * introduce let\n    * introduce screen_width(), screen_height()\n    * float\n    * draw_circle\n    * color ?\n\n11. Center function\n    * introduce function\n    * introduce Vec2 -\u003e show doc src ?\n\n12. Create a star object\n    * introduce struct\n    * introduce impl, constructor and methods\n    * introduce mutability\n    * create update_pos method\n    * create gen_val function\n\n    See \"Create star object\" commit\n\n13. Update color and size of object\n\n14. Create starfield\n    * iterate over a Vec  --\u003e show pb we need a reference\n    * start introducing block and explain objects deletion\n    ```rust\n    fn main() {\n    let myvec = vec![1, 2, 3, 4];\n\n    dbg!(myvec);\n    }\n    ```\n\n    ```rust\n    fn main() {\n        {\n            let myvec = vec![1, 2, 3, 4];\n        }\n\n    dbg!(myvec);\n    }\n    ```\n    Above code doesn't compile myvec out of scope\n\n    * Explain 1 memory problem (double free)\n        * Explain memory is organized in 2 parts stack (stack of plates), heap (shelve)\n        * stack --\u003e known + fixed size heap --\u003e unknow size, or size that can change.\n        * schema showing type on the head (Vec) use a pointer on the stack and are shallow copy to save perf\n        ```rust\n\n        fn main() {\n            let myvec = vec![1, 2, 3, 4];\n            let myvec2 = myvec;\n\n            dbg!(myvec2);\n            dbg!(myvec);\n        }\n        ```\n        Above code without ownership will free twice the same memory\n\n    * Explain ownership prevent above error kind and more\n        * Above code will not compile as myvec is moved\n        * Ownership is a set of rules to avoid memory errors.\n            * Each value in Rust has a variable that’s called its owner.\n            * There can only be one owner at a time.\n            * When the owner goes out of scope, the value will be dropped.\n            * Assigning a value to a new variable will move ownership.\n        * How to deal with ownership\n            * cloning (deep copy)\n            ```rust\n            fn main() {\n                let myvec = vec![1, 2, 3, 4];\n                let myvec2 = myvec.clone();\n\n                dbg!(myvec2);\n                dbg!(myvec);\n            }\n            ```\n            * borrowing\n            ```rust\n            fn main() {\n                let myvec = vec![1, 2, 3, 4];\n                let myvec2 = \u0026myvec;\n\n                dbg!(myvec2);\n                dbg!(myvec);\n            }\n            ```\n            * At any given time, you can have either one mutable reference or any number of immutable references.\n            * References must always be valid.\n            * update memory schema ref --\u003e stack --\u003e heap\n            ```rust\n            fn main() {\n                let mut myvec = vec![1, 2, 3, 4];\n                let myvec2 = \u0026mut myvec;\n\n                myvec2.push(5);\n                dbg!(myvec2);\n                dbg!(myvec);\n            }\n            ```\n\n    * Conclusion: do not fight compiler use it as a pair.\n\n15. Refactor starfield as a module.\n\n16. Add a horizontal scrolling\n\n17. Extend to sinus scrolling\n    * Use standard loop with indices for rainbow loop.\n    * Refactor loop to use an iterator and cycle.\n    * Add a unitary test.\n    ```rust\n    #[cfg(test)]\n    mod tests {\n        use super::*;\n\n        #[test]\n        fn fake_test(){\n            assert_eq!(1,1);\n        }\n    ```\n\n18. Add balls / ferris (if time)\n\n19. Add music\n    * Show diff beetween cargo build and cargo build --release\n\n20. Show a debug session with gdb. (if time)\n\n21. Compile to wasm and run in a browser\n\n22. Show Bastien's games\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fuggla%2Ffztaosi","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fuggla%2Ffztaosi","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fuggla%2Ffztaosi/lists"}