(As you said, this is not specifically a WordPress question except for how to hook into WordPress functionality with users. Here are some thoughts)
I think there are some design questions you need to have clear in order to make it easy figuring out the order to build things:
-
Users signing up and signing in to your WordPress website is easy, WordPress does that. But how are you going to facilitate users signing up in an external application? Maybe you need to have a look at https://developer.wordpress.org/rest-api/reference/users/ to make sure you’re clear on how that could happen.
-
It sounds like WordPress is about to become the authoritative database for your user records. I.e. for the User ID in your game database to be valid, there must be a row in the WordPress users tables. This is something to be aware of because it means your other application’s data will be dependent on WordPress’s database. This is fine and probably not a bad design given that I’m assuming you need WordPress features for your website.
-
I’d strongly recommend you try and keep the application code for your game separate from WordPress as much as possible. That means put it in separate PHP files as much as possible. The more you mix in WordPress PHP with your application PHP the harder your life will be in building features that are specific to your game. You can achieve this by writing all the code for your game in separate files then making the ‘glue’ that connects WordPress to your game as small as possible. This also means you can build and test a function to e.g. add a user with ID 123 and score 456 to your game database completely separately, then figure out how to add it to WordPress once it’s done.
-
If you solve item 1, then you could use e.g. the
user_register
hook (see here) to do stuff when a new user is registered, and the hook will send you the new user ID so you automatically have that in order to make the new row in your other database.
These are just some ideas to start you off, I would recommend that you try to break your question up into smaller pieces if you’re looking for more specific answers.
HTH