I did a bit of testing with Java and its ability to draw different graphics on the screen. I used the BufferStrategy example that Jeff has posted many times before (the one in his shooter). In the main thread’s loop, I made many images fly and bounce accross the screen. These images varied in size and shape. With 100’s of images on the screen, I didn’t notice any slowdown- this was even with a rotating image (using code found in Abuse’s 4k shooter- from a post depicting a bug in java 1.5 with rotating images- see below link). There wasn’t any slowdown assuming that the graphics had already been preloaded-That is, before the main thread was started, these 100’s of images had been stored in memory one way or another.
I am developing a type of scroller game that requires many images on the screen at once. Rather than develop a method of pre-loading images (this could be a huge strain on memory), is there a fast and reliable way of drawing images that I could do on the fly? For example, ten seconds into the first level of the scroller, monster B shows up- monster B’s graphics are stored and loaded the instant monster B is spawned. The alternative to this would be to load monster B’s graphics at the start of the level. However, what if I have 100’s of monsters? What if there are 45 variations on monster B? What if monster B has 60 different frames of sprites to animate? Pre-loading all of these images seems clunky and inefficient.
If this is not possible to do these on the fly, is there a better method to “pre-load” images than to store them all in a vector/array type object? Perhaps level one requires that monster A, B, and C’s graphics need to be preloaded- Is there a way I can do so without the need to keep reference to these images. Does the virtual machine keep track of which image files have been loaded so the next time they’re used it is done faster? Even moreso, is there a way that I can specify to load images in video memory rather somewhere else? (Worst case is I cannot load images on the fly, so perhaps they can be stored in VMem.)
When creating rotations of an image, one method is to have Java store each possible angle as another image object. (see http://www.java-gaming.org/cgi-bin/JGNetForums/YaBB.cgi?board=2D;action=display;num=1076627809) for code reference.) How processor intense is this code? Would it be too much to request the virtual machine to create and rotate an image on the fly depending on where a certain object (monster) is looking? If these image rotations need to be preloaded as well, this only inflates the already huge pre-load buffer. I don’t want to have to create and store 360 image objects for every possible angle my monster could be looking. Not to mention, if that monster had 30 unique frames of idle animation, that’s 30 * 360 images to store! It would make more sense to do such on the fly, however, I do not have the environment created to test this situation under computational stress. Has anyone had experience in this with care to speed?
I appreciate any help you guys could give me. I’m not asking for a handout- rather conceptual goals. Perhaps I can chat one on one with somebody about my full design path to see if I’m on the right track? Bear in mind that this is my first venture into Java gaming. Right now I am trying to conceptualize how I am to code everything. It makes more sense to get important ideas such as image loading out of the way before they become an issue. Sure I can create simple cliche Java game with two slow moving monsters on the screen- but that is not my goal. It would be silly to travel down an inefficient coding path directed at such an example only to have my “image loading methods” not work as fast when I want to have more than 2 monsters on the screen. Perhaps I am expecting too much of Java to have 10-20 monsters flying around the screen, flashing lights, blaring sounds, and 30 or so bullets flying at a speedy player-controlled ship? (See the game Cho Ren Sha 68k for an example of my intended gameplay.)