Jump to content
  • Advertisement

Need help with adding multiplayer to my Pokémon style rpg

Recommended Posts

I'm making a Pokémon clone in java as a student project. I'm using javafx for this. One of the features I need to work on is letting players play against each others. Only local multiplayer is required. Implement other words, the players can open up 2 instances of the game on the same pc and be able to play against each other.

I'm done with implementing the logic necessary for the core game but I'm not sure about how to connect it to networking. In my game their is a trainer class. I have a loop for battle where I wait for commands ( an object) each trainer has chosen for the turn. For players, that's the move they selected. For the ai, it's a move chosen at random. The loop will end only when all trainers ( including player) has chosen commands and the turn will play out.

I'm a novice at network programming but here's what I want to try. I know that you can send strings through sockets. The networked trainer class will work like the player trainer class but will wait for instructions from the other player's socket and convert them to commands which my game loop can use. Is this a viable approach?

Share this post

Link to post
Share on other sites

You'll probably do better if you separate the GUI from the game logic, such that the game logic doesn't "wait" for anything, but instead is "told" (or "triggered") to do things. Whenever more input is available, call into the simulation function with a function that does "Input + Previous State -> New State + Events"

Then, it doesn't matter if the "input" comes from a network, or a local GUI, or a random action from the AI.

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!