Friday, April 29, 2011

Regarding Poll

I just realized something about the poll I put up, trying to see what people are interested in so I can focus on those snippets first. Whether it be collision detection, effects (particle system, animational effects etc.), game mechanics (scoring, acheivement systems, quests, stat systems, etc.), content tools would be like map editors, file format converters, asset building tools, particle engine editors, model viewers etc. And of course it isn't hard to guess what I meant with full game tutorials.

Anyways, what I realized is that I could probably use more of all of them, so I just wanted to see which ones I should work on first. Life being busy doesn't really leave me much time to work up solid snippets to help other developers.

Enough lamenting, on to more important issues, achievements, saw a good article for those of you who are interested and don't watch gamasutra, like I do, here it is:
The Cake Is Not a Lie: How to Design Effective Achievements

Some things to keep in mind if you are considering adding achievements to a game, some thought provoking analysis of games as always from the articles at gamasutra.

Thursday, April 21, 2011

Status & Poll

Been kind of busy lately with life, attempting to get into the android market but still have a lot of knowledge to share on making games in Java, I've been wanting to do more jogl and step up to some of the changes in jogl 2.0. I thought I would create a poll to help give me a little direction on what I should post here that would be the most useful for readers.

One of the big issues I have been wrestling with is making games vs. engines it's a tough thing. Especially since my engine is 90% there and almost ready to start being used to make complete games, I have had a few setbacks with select pieces of the design. Aside from that, my day job has been cutting into the amount of energy and desire I have to code when I get home.

This is probably the first actual blog post I've written, weird but it's the truth. Mainly I started this blog to post snippets I wanted to save and to help other developers to see how I solve some of the problems in making Java games. So I figured what the hell I'll actually start blogging instead of letting this blog just sit around idling in the blog'o'sphere.

So please take a second to vote on the poll for the things you are looking for and I will do what I can to help.

Friday, April 8, 2011

TapMania: First Android Test App

I have been getting into Android application development and wrote a small application to get my feet wet. This application just tests some OpenGL render capabilities, touch screen functionality, displays some text output for debugging purposes, and gives some basic menu options.

If you wanna try it out and test your phones touch screen and also help me determine how well it runs on other devices, I would greatly appreciate it. This will also help me to create some snippets for android and let you know what issues I find and things about performance for android games. So far the OpenGL-ES on android is working great on my phone I would love to know how it works on others.

I am still going through the process of setting the application up for publication to the android market as a demo to get more feedback and to grow the application into a game.

Let me know what you think!

Link to apk:
  • TapMania.apk (link now removed, app available on the android market)
Note: After realizing that the link to my google sites did not successfully allow you to install from your phone I finished the publishing process and got it up on the android market. I have a few small updates that I will publish this weekend.

Saturday, April 2, 2011

Response: Debugging High CPU Usage

Answer to: a comment posted on Double Buffering and Timed Rendering and on Game State Machine about 100% CPU usage with those samples.

Disclaimer: If you modified the examples, I can't help you, lol just kidding, it's a silly thing to have to say but try just redownloading and running the examples without any modifications.

The answer is a bit complicated, high CPU usage might be due to a few things.

Note: One thing I did not do that might make a difference is to use the createCompatibleImage method, this might make all the difference but I've never seen it have any effect. Or you could try using a VolatileImage it has it's own issues though, and I've never seen it have any effect either. If that doesn't work turn on java2D logging using the system properties see link below and look to see how long drawing operations are taking.

Another Note: If not on windows, try turning on opengl rendering and make sure it's actually on, you can verify it by using the "True" string for turning it on, with the capital "T" it will output whether opengl or directx rendering are being used.


Java Version Issues
Using your own buffer and repaint should work decently in Java versions on windows greater than 1.4.1 update 2, when directx support was added and turned on by default. Opengl support was added as of 1.5 but is not turned on by default on any platform, so you'd want to try fiddling with some of these properties. See System Properties docs

Problem with Repaint
In earlier versions of Java using repaint would result in tearing issues, because old swing versions would be not be double buffered. Thus the example with their own double buffering.

Hardware Acceleration Issues
No hardware acceleration will be available if you don't have some type of graphics card or if java has issues with the drivers, so it will only go as fast as the underlining computers CPU can handle in that case. Another issue using BufferedImages is the hardware acceleration can be lost if the bufferedimage raster is modified. Another choice is to use the Canvas approach with BufferStrategy which I have seen much much better performance than either creating a buffer myself .

I haven't seen 100% constant CPU usage with this example myself. If repaint works I do suggest going with what you know works well until you find something better. In the end if looks good and feels good for your game then it doesn't matter which method you use.

Things I tried
Trying to duplicate the 100% CPU usage with the Double Buffering and the Game State Machine examples was unsuccessful. I tried turning off hardware acceleration -Dsun.java2d.noddraw=True still performed as expected. I didn't change any of the code so it was left as is, still no 100% CPU usage, on an old 2.66 GHZ pentium 4 with a NVIDIA GeForce 8400 GS graphics card and tested with Java versions 1.5, 1.6, and 1.7ea without issue.

The only thing I could think of that would cause 100% CPU usage with these examples in their unmodified state is if the TimerTask run method takes more than 16 milliseconds. That would bog down the timer with continuous tasks needing to be fired since the java.awt.Timer is a single threaded queue based task scheduler. I was able to bog down the Timer and see high cpu usage. Haven't tried forcibly making the bufferedimage non-hardware accelerated yet. You could implement your own timer and see if that makes a difference.

I am meaning to work up a new snippet with better rendering methods, and updated code. The BufferStrategy approach link above is a good alternative and much better frame rates. Give that a try if your having trouble, I would also like to know if that works better for most systems. It's been a long time since I did those snippets back in 2007 I have learned a lot since then, still there is much much more to learn.

One Last Thing
I do remember that there was some issues I had on windows with a graphics card installed that slowed my rendering significantly, those were the options in the Display Properties -> Settings (tab) -> Advanced -> Troubleshoot (tab) the Hardware Acceleration, I have seen it have interesting effects at different levels with some of my Java games projects.

For further help just ask and you shall receive, of course more details next time would help tremendously.

Good Luck!