Sign in to follow this  
mk.jr.fan

Starting a game in Java, ideas on where to begin?

Recommended Posts

Hi! I was going to start making my first game in Java and I was unsure of how I should plan this out. For now I am building the game for PC but if successful I will try to port it over to android so that my friends can also play as well. My java experience is some what new as I am taking a class in java now, but I have taken a summer course on it before. For game making experience I have worked with GameMaker (mostly coding not drag and drop) and about a year in Unity.

 

The point of this game is mostly be a learning experience of trying to make a game without an engine such as GM or Unity. Would it be a good idea to use just java or get other sdks or libraries? Also is there anything I should know or keep in mind if I am building as  a PC game first and then porting it over  to android or mac?

 

Any suggestions or tips would be helpful. Thanks!

 

This will be a 2d platforming game.

Edited by mk.jr.fan

Share this post


Link to post
Share on other sites

If you look around on the Web I am sure you can find some good libraries for java. I recommend http://www.slick2d.org I don't know if it will work on Android, but I know it will work on Windows, Linux and OSX if they have java installed.

Well I am not just looking for libraries, I wondering if it would be a good idea to use just java instead of libraries to make a game. 

I am asking this because I want to know how much harder is it without a library or sdk to make a full game.

Share this post


Link to post
Share on other sites


If you look around on the Web I am sure you can find some good libraries for java. I recommend http://www.slick2d.org I don't know if it will work on Android, but I know it will work on Windows, Linux and OSX if they have java installed.

Well I am not just looking for libraries, I wondering if it would be a good idea to use just java instead of libraries to make a game.
I am asking this because I want to know how much harder is it without a library or sdk to make a full game.
unless you know really much about graphic hardware and stuff, it's really hard to make a game, library or engine. And yes, java is a good language!

Share this post


Link to post
Share on other sites

Also is there anything I should know or keep in mind if I am building as  a PC game first and then porting it over  to android or mac?

 

PC and Mac will be quite similar with Java and OpenGL. However, for android, you will most likely have to rewrite a huge portion of the game either for optimization reasons or because of different APIs. Android does not use Oracle's Java Virtual Machine.

Share this post


Link to post
Share on other sites

unless you know really much about graphic hardware and stuff, it's really hard to make a game, library or engine. And yes, java is a good language!

So I guess a library or sdk will do the graphics thing for me or at least make it easier? Also would you know if that could be implemented for android if a library is used or would that be library specific?

Edited by mk.jr.fan

Share this post


Link to post
Share on other sites



unless you know really much about graphic hardware and stuff, it's really hard to make a game, library or engine. And yes, java is a good language!

So I guess a library or sdk will do the graphics thing for me or at least make it easier? Also would you know if that could be implemented for android if a library is used or would that be library specific?
If you are going to use slick2d you have to keep in mind that it isn't going to work on Android, so if you really want that look for another library.

Because this is the first game you are making its better to just focus on getting a game working and worry about making games for phones, like android, later.

Share this post


Link to post
Share on other sites

I would recommend focusing on game mechanics: health system, collision detection and moving objects around. Java has a built-in library to do this. I spend time coding Java for 3 months really helps build my algorithmic problem solving skills in Java.

 

Take a look at the Canvas, JPanel, Component and Graphics2D class in the Java API. You will need these classes to form the base of a 2D game.

Share this post


Link to post
Share on other sites

unless you know really much about graphic hardware and stuff, it's really hard to make a game, library or engine. And yes, java is a good language!

So I guess a library or sdk will do the graphics thing for me or at least make it easier? Also would you know if that could be implemented for android if a library is used or would that be library specific?

It is quite complicated to make a multi platform title with a low level library. Say that you want to do it all yourself, grab LWJGL and code the OpenGL stuff by your own. You'd have to make several renderers for your target platforms (mobile, desktop, etc) which it gets complicated really fast.

 

If you're going for multi platform from the start, better grab a library that already can do that stuff for you (I've heard good things from what Olaf Van Schlacht suggested, libgdx, though I haven't used it).

Share this post


Link to post
Share on other sites

I would recommend focusing on game mechanics: health system, collision detection and moving objects around. Java has a built-in library to do this. I spend time coding Java for 3 months really helps build my algorithmic problem solving skills in Java.

 

Take a look at the Canvas, JPanel, Component and Graphics2D class in the Java API. You will need these classes to form the base of a 2D game.

Interesting, I like your idea of just using plain java. I think what I might do is like you said get the basic game mechanics down first and maybe later on use the libraries and other stuff later on for the graphics.

Share this post


Link to post
Share on other sites

It is quite complicated to make a multi platform title with a low level library. Say that you want to do it all yourself, grab LWJGL and code the OpenGL stuff by your own. You'd have to make several renderers for your target platforms (mobile, desktop, etc) which it gets complicated really fast.
 
If you're going for multi platform from the start, better grab a library that already can do that stuff for you (I've heard good things from what Olaf Van Schlacht suggested, libgdx, though I haven't used it).

 

Well I was thinking of coding just for pc and was wondering if I needed to keep anything else in mind if I were to later port to mac or android.

Share this post


Link to post
Share on other sites

To port to Android, you must use the Android SDK or LibGDX or similar library. LibGDX is specially made for porting to multiple platforms. Trying to port a PC version to the MAC is one thing...they are fairly similar systems...but moving a PC version to Android is completely different because you have to worry about touch screens and lots of other Android "stuff". If you want to port to Android, that is something you need to think about now because then you should use LibGDX. In my opinion, since this is your first project in Java(even though you have some prior experience with games) you probably shouldn't worry about being cross platform and just getting your game out there, in which case I would recommend Slick2D over anything else.

So I guess a library or sdk will do the graphics thing for me or at least make it easier? Also would you know if that could be implemented for android if a library is used or would that be library specific?

Slick2D makes the graphics easier and is less laggy than "vanilla" java graphics because Slick has hardware acceleration. Games made in slick are "state based"...your menu, game, game over screen, high score screen, etc. would be different states that have their own independent update and render loops. Slick has lots of cool lighting effects and fade transitions that can make your game look way more polished. (My one problem with Slick is that it has trouble playing MP3 files so you will have to use a separate library for you audio playback and processing)

Edited by minibutmany

Share this post


Link to post
Share on other sites

To port to Android, you must use the Android SDK or LibGDX or similar library. LibGDX is specially made for porting to multiple platforms. Trying to port a PC version to the MAC is one thing...they are fairly similar systems...but moving a PC version to Android is completely different because you have to worry about touch screens and lots of other Android "stuff". If you want to port to Android, that is something you need to think about now because then you should use LibGDX. In my opinion, since this is your first project in Java(even though you have some prior experience with games) you probably shouldn't worry about being cross platform and just getting your game out there, in which case I would recommend Slick2D over anything else.

So I guess a library or sdk will do the graphics thing for me or at least make it easier? Also would you know if that could be implemented for android if a library is used or would that be library specific?

Slick2D makes the graphics easier and is less laggy than "vanilla" java graphics because Slick has hardware acceleration. Games made in slick are "state based"...your menu, game, game over screen, high score screen, etc. would be different states that have their own independent update and render loops. Slick has lots of cool lighting effects and fade transitions that can make your game look way more polished. (My one problem with Slick is that it has trouble playing MP3 files so you will have to use a separate library for you audio playback and processing)

Thank you for the response! I think what I am going to do is make the basic concept of the game first just strictly with java. Later on when the game is pretty much complete I will try using a library later on for the graphics.

 

When that's done I will then try slimming it down for Android(but lets see how far I go first).

Share this post


Link to post
Share on other sites

Later on when the game is pretty much complete I will try using a library later on for the graphics.

 

I wouldn't recommend this. Just go with a library from the start. A library such as slick doesn't just turn graphics into an image that you can willy nilly paint on a JFrame....it has its own windowing system. There is little advantage, even an educational advantage, with trying to go "vanilla" java at the beginning...especially with Sick because it is designed to resemble the Java 2D graphics API and is even easier to use than regular Java. Even if you are just trying to make a basic working plan, Slick and similar libraries are designed for fast development(they write the code so you don't have to), which is what you want in a learning or prototyping environment. 

Edited by minibutmany

Share this post


Link to post
Share on other sites

I wouldn't recommend this. Just go with a library from the start. A library such as slick doesn't just turn graphics into an image that you can willy nilly paint on a JFrame....it has its own windowing system. There is little advantage, even an educational advantage, with trying to go "vanilla" java at the beginning...especially with Sick because it is designed to resemble the Java 2D graphics API and is even easier to use than regular Java. Even if you are just trying to make a basic working plan, Slick and similar libraries are designed for fast development(they write the code so you don't have to), which is what you want in a learning or prototyping environment. 

 

From what you said it sounds like, by using premade scripts it will help me learn how to code games in java.

 

The reason for me making this game is not the game in itself. The game is like the icing on the cake. The cake is that I become a better program so I don't always have to rely on libraries. Now the reason I mention the use of a library is that it seems that coding for graphics is different from coding game logic (I don't know for sure since I have never had a chance to look at it). I feel that it would be best to learn from the ground up, and instead of using premade methods that don't always do what is intended, I can instead make games with my knowledge instead of using someone else's hard work.

 

Now if you disagree that learning from "vanilla" java is not the best solution please tell me why.

Share this post


Link to post
Share on other sites

Hi,

 

 

Okay, let me cover the basics as they connect to one another and also help set your mind at ease on a few things.

 

Sure, Java is a "good" language, whether certain programmers like it or not. Java is powerful and broad in capabilities.  In my opinion it is the best cross-platform language, but I must say that game engines and libraries really make quite a bunch of languages suitable for cross-platform implementation according to what they are designed to use.  This is why many languages are of serious consideration, being that game engines, SDKs, and specialized libraries put ability in your hands.  These tools help you to better learn a language because they frame your coding habits and pipeline.  This is one of the most important strategic thinking points in your whole career to remember and exploit. What makes a language effective for you will be all the support around it, software, tools that you learn to make, and community help - far more than the language itself. 

 

Take a look at jMonkey, for example.  It has some very standard libraries which you really need to learn eventually anyhow, track record of games which demonstrate the game engine, cross-platform built into the development pipeline, and made to guide you in learning version iterations and modularization so you can reuse a lot of existing code which you create.

 

mk.jr.fan, you have some coding experience with languages, so go right to a framework and not flicker around the fundamentals of coding anymore.  Make a very simple 2D game, get it playable ASAP, and implement it cross-platform.  From there, make a second, third, forth game, and so forth.  Rabbit hopping is no good, so lay a foundation and get to building on it.  

Edited by 3Ddreamer

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

Sign in to follow this