10 Replies - 11161 Views - Last Post: 30 November 2009 - 04:28 AM Rate Topic: -----

#1 llemes4011  Icon User is offline

  • New D.I.C Head

Reputation: 2
  • View blog
  • Posts: 33
  • Joined: 05-November 09

Java Game Engine

Posted 26 November 2009 - 04:56 PM

Hello. I'm considering writing my own Game Engine, in Java. I know lots of people frown upon Game Programming in Java, but here's why I'm choosing Java:
  • I'm MUCH more comfortable programming in Java than C/C++
  • Java has more built in features (Images, Sound, Utilities, ect)
  • Java is entirely platform-independent (if coded right)

I know C/C++ is platform-independent, to an extent, and that Game Programming is primarily done in those languages, but I'm a non-conformist.

I'm very confident with my programming skills, and don't have trouble grasping new concepts. I've written a couple small games (Tetris, Pong, Asteroids, Battleship) in small groups, and on my own. Now, I want to write a larger game, and my own engine to go along with it. Here's what I know has to be in the engine:
1) Resource Loader (Images, Sounds, Save States, ect)
2) Frame Rate calculator
3) Drawing Methods
4) Class Abstractions
5) Interfaces

I'm sure that I'm missing quite a few important items, if I am, can you please point them out? Thanks! =)

Is This A Good Question/Topic? 0
  • +

Replies To: Java Game Engine

#2 SixOfEleven  Icon User is offline

  • using Caffeine;
  • member icon

Reputation: 945
  • View blog
  • Posts: 6,342
  • Joined: 18-October 08

Re: Java Game Engine

Posted 26 November 2009 - 06:50 PM

I see no reason why you shouldn't program your games with Java. If Java is what you like and your are comfortable writing your code with Java then that would be the best language for you to write your games with. I don't like that some people get tunnel vision and say that if you want to write games you HAVE to use C or C++ to do it. Not everybody is comfortable with those languages and there are many languages out there. I've always said that you can use any language to write a game. It is up to the programmer to choose the language to write their game in. Each language does have its benefits and drawbacks.

How are you controlling the flow of your game? It is usually best to use a game loop. In each frame of the game, each pass through the loop, you would do 4 basic things:
  • Update game objects
  • Render game objects
  • Preform events in the queue of events
  • Preform timing

As long as you are handling those 4 things I don't think there is much of a problem. You will want to write classes to handle the updating of objects and the rendering of objects. In the updating and rendering it would probably be best to use abstract classes that you would have to inherit from to use them. You will probably want to create a package to do common tasks like you mentioned: loading resources, rendering, updating, etc.

In any event, good luck with your game programming adventures. :)
Was This Post Helpful? 0
  • +
  • -

#3 llemes4011  Icon User is offline

  • New D.I.C Head

Reputation: 2
  • View blog
  • Posts: 33
  • Joined: 05-November 09

Re: Java Game Engine

Posted 26 November 2009 - 07:58 PM

View PostSixOfEleven, on 26 Nov, 2009 - 07:50 PM, said:

How are you controlling the flow of your game? It is usually best to use a game loop. In each frame of the game, each pass through the loop, you would do 4 basic things:
  • Update game objects
  • Render game objects
  • Preform events in the queue of events
  • Preform timing
As long as you are handling those 4 things I don't think there is much of a problem. You will want to write classes to handle the updating of objects and the rendering of objects. In the updating and rendering it would probably be best to use abstract classes that you would have to inherit from to use them. You will probably want to create a package to do common tasks like you mentioned: loading resources, rendering, updating, etc.

In any event, good luck with your game programming adventures. :)


Thanks for the tips! I forgot that I would have to implement my own event queue XD. I do agree that abstract classes would be best - they are very useful, especially in this case.

Thanks again!
Was This Post Helpful? 0
  • +
  • -

#4 WolfCoder  Icon User is offline

  • Isn't a volcano just an angry hill?
  • member icon


Reputation: 786
  • View blog
  • Posts: 7,618
  • Joined: 05-May 05

Re: Java Game Engine

Posted 27 November 2009 - 06:18 PM

You won't really be able to write fast games in any language if you haven't studied what goes on behind the scenes. Learning C is good for helping with this, along with some good algorithms and data practice. You've got to move out of your comfort zone or you won't get better as an engine programmer.

However, JAVA itself will do the trick for 2D games (or 3D if you're willing to mess with the library loader). The only problem is that you will have to deploy a product, and people want a Windows .exe file (sadly, of those people who even play indie games at all, only 10% of those will play your game if they can just click on the entry in their start menu and play).

So think of how you're going to get it to launch on end-users and solve that problem. JAVA being an order less efficient doesn't seem to be your concern, but don't forget the deployment problems.

Just remember, if your game runs just fine without requiring crazy hardware or eating tons of RAM (watch out for this in JAVA) and it runs when you click the entry in the start menu, it doesn't really matter WHAT you use. Most people playing your game won't even know what JAVA is unless they don't have it and your program tells them that they need the JRE first and gives them the link.

This post has been edited by WolfCoder: 27 November 2009 - 06:18 PM

Was This Post Helpful? 0
  • +
  • -

#5 llemes4011  Icon User is offline

  • New D.I.C Head

Reputation: 2
  • View blog
  • Posts: 33
  • Joined: 05-November 09

Re: Java Game Engine

Posted 27 November 2009 - 06:40 PM

I know that there are some decent jar to exe converters out there that can either load the jar through the exe, or package it inside the exe. Either way it works for Windows users.

My goal is to make it efficient enough that it can run complex games, without requiring a lot of RAM/CPU usage. I'll look into some C Game Tutorials, and see what I can get out of them. Do you know of any good ones?
Was This Post Helpful? 0
  • +
  • -

#6 WolfCoder  Icon User is offline

  • Isn't a volcano just an angry hill?
  • member icon


Reputation: 786
  • View blog
  • Posts: 7,618
  • Joined: 05-May 05

Re: Java Game Engine

Posted 27 November 2009 - 07:32 PM

Well, first you must learn C itself. Please learn C to its fullest. And then you look at tutorials. I don't know any good ones off the top of my head, but I've got a whole series slowly going on for Linux (but it doesn't always use C, there's a JAVA one for some command line JAVA stuff) of tutorials I have written.

The problem is that you want to make a complex game. In JAVA it will eat RAM, no matter what you do. You must start making more specialized data structures in something like C/C++ to make a complex game. However, I don't think you're making any complex games so don't worry.

This post has been edited by WolfCoder: 27 November 2009 - 07:33 PM

Was This Post Helpful? 0
  • +
  • -

#7 SixOfEleven  Icon User is offline

  • using Caffeine;
  • member icon

Reputation: 945
  • View blog
  • Posts: 6,342
  • Joined: 18-October 08

Re: Java Game Engine

Posted 27 November 2009 - 07:58 PM

WolfCoder is right. If you are looking to build a heavy duty game like the Halo series you would be best to go with C, or C++. If you want to go the C++ route then learn how to code with just plain, ordinary C first. C++ adds a little overhead compared to just C.

You should be able to create a lot of games with just Java though. You have said you like Java, you understand Java, and are very comfortable with Java. Those are the three best reasons to use Java.

Like WolfCoder said, there is also the exe issue. Using jar files can be a pain for people who just want to play your game. You have mentioned that you knows of ways around that so that would solve that.

Try your games in Java. If you find that it is too slow to do what you want to do then move to C/C++.
Was This Post Helpful? 0
  • +
  • -

#8 WolfCoder  Icon User is offline

  • Isn't a volcano just an angry hill?
  • member icon


Reputation: 786
  • View blog
  • Posts: 7,618
  • Joined: 05-May 05

Re: Java Game Engine

Posted 27 November 2009 - 08:44 PM

Don't forget to take a look at OpenGL libraries for JAVA if you want to make 3D games.
Was This Post Helpful? 0
  • +
  • -

#9 llemes4011  Icon User is offline

  • New D.I.C Head

Reputation: 2
  • View blog
  • Posts: 33
  • Joined: 05-November 09

Re: Java Game Engine

Posted 27 November 2009 - 09:03 PM

View PostWolfCoder, on 27 Nov, 2009 - 09:44 PM, said:

Don't forget to take a look at OpenGL libraries for JAVA if you want to make 3D games.


Yeah, I've looked into the J3D Library, which is a wrapper for OGL (I believe). I actually turned my teachers 2d maze program into a 3d maze program (I just have to fix the camera stuff...)
Was This Post Helpful? 0
  • +
  • -

#10 aod6060  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 6
  • Joined: 29-November 09

Re: Java Game Engine

Posted 29 November 2009 - 11:16 PM

Java 3D is a high level scene graph which allows you to do 3D stuff alot ease than just strait Open GL Code, if you want to go low level there's jogl and lwjgl, if you don't want to go low level then there is also jME engine.
Was This Post Helpful? 0
  • +
  • -

#11 Mercurial  Icon User is offline

  • D.I.C Head

Reputation: 18
  • View blog
  • Posts: 178
  • Joined: 06-November 09

Re: Java Game Engine

Posted 30 November 2009 - 04:28 AM

IMHO, if you feel comfortable working in Java, do it. I've made a few games in Java and C++ (in that order) myself. If you're not familiar with c/c++, try making one game in java, to learn about more complex geometry problems that can occur when various movement algorythms are needed (world/level AI communication with character AI, in order to be able to avoid obstacles etc.).

I think that is the main reason you should start by making a game in a language you are familiar with. I know I had problems trying to learn both C++ and how the movement algorythms work while making a (not so) simple 2d game.

I hope it helped :^:
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1