Tips for own Java engine

Started by
5 comments, last by kunos 9 years, 9 months ago

Hi everybody,

I'm a computer science student and have already programmed some simple games (10-15 classes).

Now I want to make something bigger this time.
The problem is, that I don't know how to properly structure my own engine.
At the moment, it's a simple, tile based 2D engine with pathfinding and some early game logic,
but it gets more and more messy, when I add stuff.
Is there any book, or tutorial, which can give me some tips?

Thanks in advance!

Advertisement

Hi,

I feel like I can offer some advice for this project as I have been in your position before, and have undergone a similar project. In regards to your question about books I am unaware of any java game engine books, but a couple that helped me was

Programming Game AI by Example - Matt Buckland and "2D Game Collision Detection: An introduction to clashing geometry in games" (that second one is rather simple but nice to have as a reference). Also the Articles section on this website was a big help to me, you may want to check it out.

(I post this part because you posted in beginners)

I believe your workflow is important too. The problem with rushing in and developing new systems/mechanics to your dreams, is that often a system may become overlooked and become under developed, which can be a pain in the ass further down the line. Get a clear idea of the basic things you need to put into the engine, and create a framework from those features, and try to keep everything level(in terms of how developed a system is). At first it may seem your engine isn't going anywhere, but after you have the framework to build upon, (In my experience) development of the engine was a lot quicker, and new features where easily/quickly implemented.

Mobile Developer at PawPrint Games ltd.

(Not "mobile" as in I move around a lot, but as in phones, mobile phone developer)

(Although I am mobile. no, not as in a babies mobile, I move from place to place)

(Not "place" as in fish, but location.)


I'm a computer science student and have already programmed some simple games (10-15 classes).

How many of these games did you finish? By "finish" I mean a polished, playable game that could have been dropped into an arcade in the 80s and got people to play it?

There are so many things you'll learn by actually completing a project.

Having said that, this is not a game programming problem. Any large project written by one person needs something to keep it from growing into a tangled mess of crap that you no longer understand and can't debug. If you find that every time you change something something else breaks, or you're just randomly changing stuff guessing at the problem and you find yourself saying "Well, I guess it worked. I wonder what I just broke?" then there is an answer (but you're not going to like it).

Testing!

http://junit.org/

http://sourceforge.net/projects/cppunit/

http://www.nunit.org/

Every time something breaks, add a test that would have caught the problem. The more tests you have, the more stable your code is, and the better you feel about it. It also gives you the courage to try some refactoring to clean up the messy code without breaking stuff.

I think, therefore I am. I think? - "George Carlin"
My Website: Indie Game Programming

My Twitter: https://twitter.com/indieprogram

My Book: http://amzn.com/1305076532

Thank you two for your answers, I guess I have something to read now.

How many of these games did you finish?

I have made clones of Tetris, Snake, Minesweeper and a basic side scrolling shooter.

I mean a polished, playable game that could have been dropped into an arcade in the 80s and got people to play it

They all are playable, but they don't look very nice, because I'm no artist biggrin.png
With this new project, I want to work with some people, who are.

If you find that every time you change something something else breaks, or you're just randomly changing stuff guessing at the problem

No, that's fortunately not the problem. I have a very clean coding style, where every class just does its own job and when I change something, it usually just affects the class itself.

I just would like some basic ideas on how "professional" programmers structure their classes, maybe just a class diagram of a bigger game could do it, but I haven't found a good one yet.

Game Engine Architecture, Second Edition

by Jason Gregory

I didn't even know the 2nd edition was coming out. So now I'm really excited. This book goes into depth about creating a practical engine for large games. It is expensive, but worth the money. I have the 1st edition, and will no doubt be buying this one soon.

Also, this is worth study: http://fabiensanglard.net/ This guy has commented and broken down the source code for games like Doom and Quake, if you're looking for something that only costs time.

I think, therefore I am. I think? - "George Carlin"
My Website: Indie Game Programming

My Twitter: https://twitter.com/indieprogram

My Book: http://amzn.com/1305076532

Your number one best bet is to look at the source code for an existing 2D java engine like LibGDX, Slick or AndEngine.

Specific to Java, be careful with allocations. Persistent pre-allocated temps are your friend.

Follow your own way.. don't overthink, make things work. Making things work should always be the first priority. Once it's working, have a look at the code, find the patterns, see the structure.. refactor... your next attempt will be better.

Meanwhile, read books, look at some other's people code, listen to talks.

It's all a parallel process.. doing only one of these things won't bring you anywhere. If you don't have a messy code to refactor, you will never understand what books about software architecture talk about.

Stefano Casillo
TWITTER: [twitter]KunosStefano[/twitter]
AssettoCorsa - netKar PRO - Kunos Simulazioni

This topic is closed to new replies.

Advertisement