Hi,
I’m not new to programming or game development, but I’ve never wrote a game in Java. So I was wondering how much are some of the techniques different from those in C++.
For example, let’s say I have a chessboard. When I click on a figure, something needs to know that figure is selected. In C++ I would have had a list of all the figures sorted by Y, and when the mouseclick occurs I iterate through the list and see if there is a figure underneith the mouse cursor.
In Java, I could just inherit a Component class and make itself draw on the screen, and when the mouseClick() event occurs the component will handle that event by itself. No need to iterate through a list.
Is this how this is done? Or is it more common to have a list?
Second question: GUI. In C++ I would take one of the GUI libraries or draw the buttons myself. I would have to implement what happens when the mouse is above a button, when the mouse is down, when it’s up, when it’s double-clicked etc. First I would check which button was selected by iterating through a list containing the buttons of course.
In Java I have Swing components that again handle the events for themselves. Is it better (faster in performance) to use Swing GUI classes than to draw my own sprites on the screen?
Third question: how are animations done? Do I need a separate thread for animations, or perhaps I can have an ImageManager that will contain all the images in itself, and during each frame it will iterate through all the images and check if it’s time for them to move to the next sprite?
Fourth question: I know Java is slower than C++, I can see that by just starting up the Java2D demos that came with the SDK. I also don’t intend to use OpenGL which I understand can be reached through Java classes. What I’d like to know is how significantly is it slower? Will a game that runs at 100 fps and is written in C++ run at 50 fps? I’m mostly concerned about the game being sluggish, like I move a tank to coordinate (x,y) and the tank will move, then stop, then move, then stop again… or will it go smooth? The same goes for screen scrolling.
And the final question: how significantly will the scripts reduce my game speed. I chose to use Pnuts cause I like its syntax and I’ve seen from a benchmark that it’s the 2nd fastest Java scripting language. However when I ran a test that wrote out random numbers, and then the 100th number would be queried from invoking a script, the program halted for a (very short) moment there. And this was just a script that calculated 2+2. When during gameplay I have to invoke massive scripts that control the AI all the time, will this degrade the gameplay to becoming unplayable?
Just to mention for the end this is not a provocation. I intend to make a game in Java and I need to know what I will be dealing with.
Waiting for your reply 


