building new engine from scratch, networking/GUI questions

Greetings!

I am looking to start developing a game for this summer and I would like some assistance on how to approach a few things. I’ve had some experience with Java through school, and we have not covered some of these topics so I’m not sure how to approach it.

the game itself is going to be isometric and either 2d or 3d. I’m not sure how that part will work in Java and I may need help locating resources on how to work a UI and how to interact with graphics. The game I am thinking of is going to be a roleplaying game on one gigantic map, and possibly with sub maps.

I want to build this game so that if I DO use multiplayer, it will be easier to implement. This is something ABSOLUTELY not covered yet in my classes. What I want to do is have each game be it’s own individual server, hosted on the computer itself.

As a bonus to myself, I want to make this game so it works on both PC and Android tablets, and can play cross platform.

sooo, any suggestions?
Also if there is a free(mostly free?) engine which will do the job, let me know.

BTW, try looking to JGO tutorials, they are very good! :slight_smile:

That’s a good one, i’ll have to save that for my club.

Basically what you’re saying is you want to reinvent everything and you have no idea where to start… ::slight_smile:

It will probably take you the entire summer just to program a solid GUI library; even then, it probably won’t be as good as others that exist already (like TWL) since those have been maturing over time with plenty of testing and very experienced programmers. And GUI is simple compared to programming a full-blown 3D engine that works on android and desktop!

My suggestion would be to start by programming some simple 2D games with LibGDX, and try getting them to work on Android and Desktop. Once you are comfortable with that, you can try making a simple 3D game. And then… only then… you can try to tackle the “awesome 3D multiplayer game” idea.

Well, I’m not looking for “ZOMG AWESOME” Graphics, nor am I really looking to re-invent anything.
I’ll check out the library you mentioned, should be helpful…

Basic networking is pretty easy. The challenge is in designing your client/server model to suit your needs and not have lag.
In my junior year of college, our class was split into two groups of four and each group had to design and build its own mini mmorpg. We had one person do the web site, one do databases, and me and another guy coded the client and server. The trick is to keep the number of objects on your server as low as possible. Like don’t concatenate string literals. That’s a lot of overhead and it can crash the server. We made that mistake and our server couldnt support more than 15 people. Granted we still got a goodgrade because the other teams wouldn’t even run.

It came out pretty cool though. You could walk around, cha, fight monsters, and pick up gold andweapons.

Concatenating string literals is free, and even a big chain of “foo” + bar + “baz” + mumble + “frotz” is smart enough to get turned into a Stringbuilder internally. It’s when you repeatedly append to strings in a loop that God kills a kitten.

Oh god…so many dead kittens… T_______T

Really??

I do that all the time… :o

Why is it bad?

It’s creating a StringBuilder every single time it loops :wink:

Ie.

String str = "";
for(int i=0; i < 100; i++)
{
  str + = "Bla " + i;
}

What’s the correct way of doing this sort of thing?

Now look at what you did to the kittens!

Something like this :slight_smile:

StringBuilder sB=new StringBuilder();
for (int i=0; i<100; i++){
    sB.append("Bla ");
    sB.append(i);
}

What your code actually does is:

String str="";
for (int i=0; i<100; i++){
    str=new StringBuilder(str).append("Bla ").append(i).toString();
}

That’s a lot of StringBuilder objects created.

Mike

Or no need for any creation of objects:


String str = "";
for(int i = 0; i < 100; i++)
    str = str.concat("Blah").concat(String.valueOf(i));

I see. Thanks for the clear explanations!

Is it me or is this a feature the java compiler could/should do for you?

Oh and, about the dead cats - cats are bastards, kittens are just soon to be egoistic sociopaths. :}

Dogs are way better:D


    str = str.concat("Blah").concat(String.valueOf(i));

Very very wrong, loses even the benefits of a StringBuilder. Create a StringBuilder outside of the loop, use it in the loop. You may see older guides that tell you to use a StringBuffer, just s/Buffer/Builder/ and use the same API and you’re fine (StringBuffer is overly synchronized which is why it was superceded by StringBuilder).

I see no benefits of StringBuilder over concat.

StringBuilder uses an internal buffer that is resized as needed, using overextension to avoid too many reallocations. str.concat(a).concat(b) creates two new new intermediate strings. Doing it in a loop n times creates n times that many.

Oh I forgot about the String allocation part. I was thinking about both using char arrays anyways. Gotcha. :stuck_out_tongue:

Yay, I was right! :slight_smile: (in regards to a java question, I think I’m getting a hang of this!) :slight_smile:

So in regards to the follow up question:

Isn’t this an optimization the java compiler could (should) do for you?

If not, why shouldn’t it?