🎉 Celebrating 25 Years of GameDev.net! 🎉

Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!

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

Started by
1 comment, last by hplus0603 5 years, 5 months ago

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?

Advertisement

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.

enum Bool { True, False, FileNotFound };

This topic is closed to new replies.

Advertisement