Starting a Java Game, Where to Start? Eventually want to be network multiplayer

I don’t have a lot of Java experience, but I’ve had a course on it. Will be taking another course next semester. However, I would like to keep learning on my own, and try things that I have not yet been taught.

The project I’d like to start is a turn-based card game. I eventually want it to be an applet, be ported to android, maybe iOS, and be completely cross-compatible.

I’ve read into some about networking java games, etc. However, I’m not sure where to start. Most will start a single player version of the game, and then focus on the networking. However, I’m not really interested in developing an AI.

I know networked games are split into a server portion and client portion, how can I plan for that? Do I write the classes as normal?

What’s the best course of action here? Would I be better off developing a dumb AI that will just play a legal card to play, to help step through things?

Also, I don’t know much at all about GUI or any graphics in Java. So at first, I will just make it text based. Is there anything I need to keep in mind so that it will be easy to implement graphics later on?

Please, don’t tell me I’m in over my head. I am going to do this, and it would be much easier with your help :slight_smile:

Thank you!
Cody

You’re are over your head.

Make single player pong, then try multiplayer local pong then finally networking pong.

Thank me later, either take the advice or prepare for your project to crash and burn.

Harsh but yeah, I’m Scottish I can get away with it. Usually :p.

EDIT: For the record I speak from personal experience, not only that your definitely not the first person to come in with this question, maybe you are the first that takes advice though.

SECOND EDIT : on the other side of the situation, welcome to the forum mate. You will enjoy it here, great guys and plenty of experience/knowledge to spread around.

But I don’t want Pong… Lol

I appreciate your feedback. I do expect my project to crash, but if it burns, I’ll put it out and re-build.
I have plenty of time for this project, I will research and test things out as I go. If that means building a simple game to test, I will but right now, I would just like advice on where to start with this one.

Any more advice?

If you need advice you are not ready for this.

You should start with pong. It will teach you a lot of stuff if you will make it multiplayer. Also, stick with 1 platform for now, say Windows. Making everything cross platform is hard work.

Read up and do what you want. I don’t know what you are expecting from this.

Google networking in java for games
Google AI in java for games
Google Game Libraries in Java

This question is really broad and pointless. No one is gonna write you an entire book on this forum with all the information you need. People have already done that, go read up in books or online.

I don’t know how pong would be different than cards? The only difference would be the simplicity of the game. What would I learn from Pong that I can’t learn from a card game?

I have researched quite a bit. I don’t expect entire books with all the information teaching me how to do everything.
The question is broad, because I’m looking for general advice, not tutorials.

-I don’t want to do the networking part yet, I just wanted to make sure that what I write now can be modified for network play without rewriting everything.
-I don’t want to learn how to write an AI, I don’t want to make a single player game. I don’t know how a single player pong would be any easier than a local two player pong. Instead of programming logic for the opponent, you just use different keys to control the other paddle?

I will look into libraries more, but I would like to stay away from them as much as possible, and write everything from scratch.

In the coming semester, one of my assignments will be a card game. That won’t even be considered a large project, I don’t know why you all are making it out so hard? If you have no helpful advice, please feel free to ignore the thread.

Maybe it is a bit exaggerated but supporting both desktop environments and embedded environments can be tricky. I would rather advise him to stick with computers before aiming Android.

morgancj, in my humble opinion, you should start with a smaller project first. If you don’t like Pong, choose something as simple as it but less challenging than the one you mention in your first post. Why not making an offline text based turn based card game first? Then, you can turn it into an offline graphical turn based card game and after that, you can turn it into an online graphical turn based card game. If you don’t mix up everything, using a networking framework later won’t require tons of changes.

Ah, the “I am not going to use any libraries”

Good luck with that, as you actually can not make any GUI in java without using a library. So embrace libraries.

Also, please don’t say you have researched quite a bit, it is quite a bit obvious you have not researched that thoroughly into the subjects at hand.

The card game doesn’t have to be that hard actually, in some ways its easier than pong, and it is multitudes easier than a multiplayer pong game as it is state based. avoid animation keep it really simple with GUI stuff. I would recommend libGDX for something this simple.

Look into using Sockets, TCP fits state based games better. Since it is state based you can create the game in a single player type mode first than move on to a multiplayer mode with networking without much re write, assuming you know how to write relatively clean, modular code.

@gouessej

If it is tricky for you, it will be a disaster for a first timer.

For now, it will of course be, PC only. (probably not Windows, I work on mainly linux machines)
I said in my original post that I would start with a text based game, until I learn graphics, that only makes sense, right?

I can do the game, I’m only seeking advice for structure. For instance, "Keep blah in a separate class from bleh, but in the same class as bluh. That way when you add server/client … " any experienced positive advice is helpful!

The only real question is whether or not I should start with a singleplayer, since I don’t want to end with a single-player. I don’t want to code a competitive AI, but would it be in my best interest to program a simple AI that can follow the rules of the game?

I have researched. I’ve looked into socket programming and what not. Not too extensively, but some. I figured it would be best to get the basics of the game down first, then learn more about the graphics and the networking.

I know some libraries are required. I want to use as few as possible, because I am learning, and most of my assignments require us to write as much code ourselves without using libraries.

I just wanted experienced advice. I can do the game. Just wanted to save myself any potential headaches in the future.

I’m not dumb. I have a high GPA and am in the honors programming course. I will figure this out. Was simply looking for advice. Not alternatives.

Me neither. :smiley: You’re not planning to write Quake or Civilization or anything! You sound like a can-do kind of person who knows that a simple card game cannot be that hard. It isn’t! Don’t listen to posters trying to make out there are a million things you need to know before you can get started.

Depending on what you’re most interested in I would either:

  • Start with the text-only card game where players take turns on the same screen (or you play against yourself of course), then extend it later for net connected players, and/or AI players which is a somewhat similar kind of extension, assuming you have a “Player” class which the game core interacts with. This way you get a playable game soonest.
  • Start with a simple client/server chat system to get the net code - find server, connect, join table etc. - working (remember to check a version of the code at this point into your repository as you can reuse it for other games later!) Then add the card game onto that as something the clients can do other than chat. The downside is network code is a bit fiddly for a beginner (although for a simple card game not nearly as difficult as for a realtime game, which is what some of the links posted above will concentrate on).

If it ever comes to a GUI, despite what people have said, the most rudimentary graphics available on whatever platform you write clients for will be able to show card pictures and buttons for “hit” or whatever just fine. The trade-off with learning to use a third-party layer like libGDX is it’ll support more client platforms with the same code. But if you’re a beginner you need to keep it simple - assuming you’re coding on a desktop machine, just use the simple built-in Swing graphics.

if you want to get into networking, start at the beginning and write a chat server+client as everybody else did :wink:

Avoiding libraries is only going to hinder you. It is not possible that you finish your project and find you did not learn enough. Having never created a game, you have an enormous amount to learn. Trying to do everything from scratch is going to slow you down considerably. It is a much better idea to get some (a lot) of general experience first before thinking about what happens at a low level. It’s the same reason people are suggesting to make a simpler, non-networked game first. You may not like this advice, but you asked for experienced advice and that is what you got.

My advice: use libgdx, specifically scene2d.ui for the UI and SpriteBatch for drawing. Don’t use scene2d for the game, only for the UI. Use KryoNet for networking. Organize your code using loose MVC, this will allow you to develop the game as text and later make it graphical, as well as allow you to easily serialize game state and generally keep your code sane.

Thanks guys!

Maybe what I wrote was confusing, sorry. What is tricky is the support of iOS for a beginner. I didn’t understand why you advised the original poster to target only Windows whereas targetting GNU Linux, OpenIndiana and Mac would require (almost?) no effort, especially if he just makes a fat JAR (even though it isn’t the “smartest” solution).

morgancj, you should at least separate the representation of the data from the data and implement a bot. This bot would probably force you to structure your code in a way that would allow you to replace the (silly?) bot by a real player.

I disagree a bit with Nate. Don’t try to do too much things but using middle and high level libraries from the very beginning is only one viable option, it’s not the single one. It depends on what you want to learn. For example, as I decided not to learn OpenAL, I just use Paul Lamb Sound Library with its JOAL plugin and I preferred learning JOGL before using lots of 3D Java engines. It depends on how you learn, maybe Nate’s suggestion would be more efficient in your case, only you can know that. There are some experienced developers here, some of them don’t go “deep”, some do, some of them started by using high level APIs first, some did the opposite.

My advice… use Unity. Strange but true.

Until someone bright sorts out the whole end-to-end thing with Java… it’s still back where it was in 2002 as far as games is concerned. Almost zero movement in 12 years.

Cas :slight_smile:

Keep turning folks away and it’ll stay at zero. :stuck_out_tongue:

Another vote for LibGDX. If your goal is to eventually be cross platform, LibGDX handles all of that for you. From one code base you can compile to Java SE for desktop (which covers Windows, Linux, and Mac), HTML5, Android, Blackberry, and iOS (but you need a Mac for that unfortunately and I believe you may even need to be an “iOS developer” but I’m not positive on that).

LibGDX was recommended to me when I ran into some animation problems with Java SE and it was the best move I ever made.

Advanced warning…the initial setup is kind of a nightmare, but it’s definitely worth it! :slight_smile:

There’s a gui

It all depends on what you value most: the result and a community of players, or the learning experience across the whole process. It is appealing to start by mining your own sand, but not if you actually expect to love the first few castles you build.

You won’t find a lot of formal teaching materials, but there are a bunch of open source frameworks you can either use or just study.