• Announcements

    • khawk

      Download the Game Design and Indie Game Marketing Freebook   07/19/17

      GameDev.net and CRC Press have teamed up to bring a free ebook of content curated from top titles published by CRC Press. The freebook, Practices of Game Design & Indie Game Marketing, includes chapters from The Art of Game Design: A Book of Lenses, A Practical Guide to Indie Game Marketing, and An Architectural Approach to Level Design. The GameDev.net FreeBook is relevant to game designers, developers, and those interested in learning more about the challenges in game development. We know game development can be a tough discipline and business, so we picked several chapters from CRC Press titles that we thought would be of interest to you, the GameDev.net audience, in your journey to design, develop, and market your next game. The free ebook is available through CRC Press by clicking here. The Curated Books The Art of Game Design: A Book of Lenses, Second Edition, by Jesse Schell Presents 100+ sets of questions, or different lenses, for viewing a game’s design, encompassing diverse fields such as psychology, architecture, music, film, software engineering, theme park design, mathematics, anthropology, and more. Written by one of the world's top game designers, this book describes the deepest and most fundamental principles of game design, demonstrating how tactics used in board, card, and athletic games also work in video games. It provides practical instruction on creating world-class games that will be played again and again. View it here. A Practical Guide to Indie Game Marketing, by Joel Dreskin Marketing is an essential but too frequently overlooked or minimized component of the release plan for indie games. A Practical Guide to Indie Game Marketing provides you with the tools needed to build visibility and sell your indie games. With special focus on those developers with small budgets and limited staff and resources, this book is packed with tangible recommendations and techniques that you can put to use immediately. As a seasoned professional of the indie game arena, author Joel Dreskin gives you insight into practical, real-world experiences of marketing numerous successful games and also provides stories of the failures. View it here. An Architectural Approach to Level Design This is one of the first books to integrate architectural and spatial design theory with the field of level design. The book presents architectural techniques and theories for level designers to use in their own work. It connects architecture and level design in different ways that address the practical elements of how designers construct space and the experiential elements of how and why humans interact with this space. Throughout the text, readers learn skills for spatial layout, evoking emotion through gamespaces, and creating better levels through architectural theory. View it here. Learn more and download the ebook by clicking here. Did you know? GameDev.net and CRC Press also recently teamed up to bring GDNet+ Members up to a 20% discount on all CRC Press books. Learn more about this and other benefits here.

Archived

This topic is now archived and is closed to further replies.

sckime

[java] MemoryImageSource vs. Image

4 posts in this topic

I have been working on a pure Java game for some time now. However, I have some advanced questions about AWT graphics processing that I was going to throw out to everyone here. 1) I have read about MemoryImageSource, but when I have implemented basic trials of it, I see a halving of my frame rate. I use the setAnimated function to have it redisplay itself whenever a call to newPixels is made. Does anyone have any suggestions or comments on the performance of MemoryImageSource in their games. 2)I recently reread the Javadocs on graphics.. It says that drawImage returns immediately. If this is the case, how does one accurately get a frame rate? The method that I''ve been using is to get the time via system calls and subtract the time before the call from after the call to drawImage. 3) Other than using JNI to augment AWT, does anyone know of any ways of increasing performance in a Java game application? I know this is a broad question, but I''m not terribly sure of what tricks people have come up with.
0

Share this post


Link to post
Share on other sites
1. I don''t print a memoryimagesource to the screen, I always make an Image from it first.

2. I don''t know.

3. Only draw what you absolutely have to. Use clipping regions. Optimize your code.
0

Share this post


Link to post
Share on other sites
1) Jim_Ross: He is drawing an Image that has been created from a MemoryImageSource with the animated flag set. The resulting Image gets automatically updated when you call newPixels method in the MemoryImageSource. This allows doing some of those fine effects seen in Java demos that require heavy pixel tweaking.

As for the original question, sorry can''t help. Have you looked into some Java demo''s source codes? Maybe you could find out some tricks from there? What are you doing with the MemoryImageSource anyway, are you implementing alpha blitting of bitmaps or what? Maybe you could optimize those needed calculations somehow...

2) This is a good question, I noticed this when I benchmarked my library and got some insane numbers (around 150 FPS). I don''t know any complete cure to this.

The first step (that you propably are using allready) is to not use the normal repaint()-updated()-paint() cycle, but to getGraphics() and paint directly to the graphics. At least this way your game logic and your graphics are more in sync with eachother.

One caveat though: when you call the getGraphics method you are creating a new graphics object, if you do this for a while (around 10 seconds of 50 FPS game) you will get some serious garbage collector trashing that will ruin your game.
The key here is to use the once gotten Graphics object until it turns bad (at least it does this under Win32-JDK 1.1, for some reason the Graphics context changes during the lifetime of a component irregularly) and then get a new one. This involves a simple try-catch setup.

3) I''d advice against using clip regions heavily. I noticed a major slowdown when I started using clip regions in my library code, unfortunately I''m stuck with them for now. The reason for this slowdown is that when you change the clip region, drawing colour, used font etc. you are changing the state of the graphics object and as in OpenGL these state changes are expensive when compared to the basic drawing operations. So the way to get the most speed out of pure Java based game is to minimize these state changes. E.g. if you have to draw several blue, red and white lines first set the color to blue and draw the blues lines, then change the color to red and draw the red lines and finally change the color to white and draw the white lines.
0

Share this post


Link to post
Share on other sites
Thoughts on Question 2:

as long as you aren''t using null as your last argument on drawImage, you could override

imageUpdate(Image img, int infoflags, int x, int y,
int width, int height)

and probably check certain flags (maybe ALLBITS) to see when your current frame is actually drawn...maybe get the current time before your call to drawImage and then subtract from the current time in imageUpdate when the whole image is available.
0

Share this post


Link to post
Share on other sites
Wouldn''t this approach (using the imageUpdated method) measure the loading speed of the image, not the speed of the game loop (that is what sckime is wanting to measure, I think)?

I mean the imageUpdated is invoked until all image bits have arrived and after that (even if you keep drawing that image) it doesn''t get invoked anymore.

But using this approach with the MemoryImageSource (where the actual Image object gets updated and thus the image updated method gets invoked upon redraw) might have some use...
0

Share this post


Link to post
Share on other sites