bytemunchdotdev slashblog
theme toggle
dodgeball returns
it's back. hopefully better.
09/05/2023
The resurrection
After a while learning Rust, Bevy, and Blender, I'm actively developing my multiplayer dodgeball game again! This is where I'll write about any interesting challenges I face, along with whatever hacks or solutions I use to overcome them.
Menu State Machine
I've blocked out the main states and transitions for the game's menus.
Hopefully this will assist in creating the state machine in engine, rather than getting buried in ever-expanding spaghetti.
User Auth
If I wanted to roll my own server systems, it might go something like this: But I'm not sure, and I do not want to roll my own auth at all if I can help it. So instead I'll be looking into using Firebase from Rust. With no official SDK this could be a fun challenge.
With game logic being P2P with GGRS, this is what the network should look like.
According to Google I should be able to use the REST API for auth, and it seems like I'll be able to use only REST for firestore too! That's the goal. For now I'll settle on getting any application signed in with google, and try to print the email address to console.
~I have been buried in docs for hours.~
After learning how to use oauth2 at surface level I've got...
Hmm. The info is there, but that formatting is pretty special. I'll look into getting JSON data back.
Further investigation reveals that it's already JSON. But it's escaped? This was all much easier in Typescript!
More research lead me to serde_json, and now I'm getting Rusty types in the terminal...
After a bit of hacking around:
// Access email address endpoint
let email_res = http_client(HttpRequest {
body: vec![],
headers: HeaderMap::new(),
method: Method::GET,
url: Url::parse(
&("https://openidconnect.googleapis.com/v1/userinfo?access_token=".to_string()
+ token_response.as_ref().unwrap().access_token().secret()),
)
.unwrap(),
});
let body = email_res.unwrap().body;
let json = match str::from_utf8(body.as_ref()) {
Ok(v) => serde_json::from_str::<serde_json::Value>(v).unwrap(),
Err(e) => panic!("Invalid UTF-8. {:?}", e),
};
let email = match json.get("email") {
Some(e) => e,
None => &Value::Null,
};
println!("Email: {:?}\n", email);
Extracted the email address!
That'll do for now, I need a nap to let all the OAuth2 and Google API docs sink in. I get the feeling I haven't even scratched the surface with this.