it runs very slow. i use a java.awt.Window with a size of 640x480. what am i wrong about?

the second thing i want to ask:what is (in general) a good way or technique to do these image stuff (scrolling and drawing sprites)? i do not want to use a third-party api like gage cos i want to learn how it works .

actually i'm doing nearly the same in my little experiment (i took a look around here before i did post ). i was just wondering about scrolling a big background image around, which seemed a bit slow to me. hm, maybe i should use tiles for the background also. i was maybe expecting too much concerning speed . i did a small j'n'r game ages ago in pascal on a 386dx40 in 320x200 and the background scrolling was very fast, but that was done by directly modifying the linear vga memory (mode13, $0a000 and y*320+x, these things i won't forget for a lifetime ).

as a start i wanted to create a similar game using my native tongue, because j'n'r games are so damn addictive .

Whats the size of your background image (kb)? Reducing the size of the image file or tweaking the Image loading could help.

it's a 30kb jpeg. but doesn't java convert it into it's own data format when it's loaded? and what do you mean by "tweaking the image loading"? i use getResourceAsStream() and a MediaTracker, but the loading time does not matter (display a fancy progress bar and the player is content ).

Try http://wiki.java.net/bin/view/Games/LoadingSpritesWithImageIO for better image loading. Also see if you can make the image file size smaller. There was a difference for me displaying a few 20 kb tiles and a few 10 kb tiles 85 frames a second. Also g.darwImage() is the way to draw it but the type of image you have (volatile, automatic, buffered) and weather your app is windowed or fullscreen makes all the difference. Other things to think about: if your game is in a window then you cannot do page flipping or blitting, so your game will have performance problems.

Well if you are running with the Sun VM, try it with -Xcompile and see if that helps. if so then what you are seeing is the initial uncompiled code and aren't running it long enough to see the compiled execution. (-Xcompile forces it to compile right away)

Also, I see you are using absolute sizes, not your image size, in your BLT. If you are trying to scale each time you BLT that will slow you down a lot. Pre-scale the image into a new image thats the right size and do an unscaled BLT on each update.

Got a question about Java and game programming? Just new to the Java Game Development Community? Try my FAQ. Its likely you'll learn something!

Frame flipping is almost the same for windows or full screen in Java and you can do it with either.

If you flip frames for a window, then flipping is done with an (unsynchronized on Win32) BLT to the screen. If you flip frames in full screen then its done with video page flipping and may be scan synchronized depending on video driver settings and behavior.

Got a question about Java and game programming? Just new to the Java Game Development Community? Try my FAQ. Its likely you'll learn something!

K, I will stop writing as if I am chat with friends in a MMORPG, will be more simply to read for the normal ones :-)

Quote

If you flip frames for a window, then flipping is done with an (unsynchronized on Win32) BLT to the screen. If you flip frames in full screen then its done with video page flipping [...]

if you make your bufferstrategy withcreateBufferStrategy(2)then it will be done like that, but furthermore you can create the bufferstrategy withcreateBufferStrategy(2, BufferCapabilities)then you can select between page flipping and page blitting.

If we are already at Hardwarefeatures, which methods from Graphics2D (got with createGraphics from a BufferedImage which was got with createCompatibleImage) are Hardwareaccelerated?All of them or only drawImage(). And if only drawImage is accelerated, what happens if I call (e.g.) drawLine()?Is the line drawn on the BufferedImage in the VRAM, or is the (BufferedImage in) VRAM copied to SystemRAM, the line drawn and the result copied back to VRAM?

And what happens if I call setRGB() from the BufferedImage?

I hope my grammar is understandably ... to read some english text and to write some is a a larger difference than I thought **

K, I will stop writing as if I am chat with friends in a MMORPG, will be more simply to read for the normal ones :-)

if you make your bufferstrategy withcreateBufferStrategy(2)then it will be done like that, but furthermore you can create the bufferstrategy withcreateBufferStrategy(2, BufferCapabilities)then you can select between page flipping and page blitting.

You can force fullscreen to BLT, but I don't know why you would want to.

You cannot make windowed do anything but BLT because thats the nature of windows on a Win32 box, they are BLTd. There is no hardware windowing support on WIntel graphics cards.

In general the code picks the best method for your situation, so let it unless you have a really strong reason to want to defeat it.

Quote

If we are already at Hardwarefeatures, which methods from Graphics2D (got with createGraphics from a BufferedImage which was got with createCompatibleImage) are Hardwareaccelerated?

I believe this depends on the abilities of your graphics card and driver. If you post questions like this to the Java 2D category you can get answers from people like Dmitri who actually work on that code inside of the JDK.

And your english grammer is just fine

Got a question about Java and game programming? Just new to the Java Game Development Community? Try my FAQ. Its likely you'll learn something!

java-gaming.org is not responsible for the content posted by its members, including references to external websites,
and other references that may or may not have a relation with our primarily
gaming and game production oriented community.
inquiries and complaints can be sent via email to the info‑account of the
company managing the website of java‑gaming.org