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

Started by
15 comments, last by 3Ddreamer 11 years ago

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.

Advertisement

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.

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)

Stay gold, Pony Boy.

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).

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.

Stay gold, Pony Boy.

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.

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.

Personal life and your private thoughts always effect your career. Research is the intellectual backbone of game development and the first order. Version Control is crucial for full management of applications and software. The better the workflow pipeline, then the greater the potential output for a quality game. Completing projects is the last but finest order.

by Clinton, 3Ddreamer

This topic is closed to new replies.

Advertisement