|
||
|
GP Mailing List
ATXGPSIG List
|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [gameprogrammer] Re: A newbie Java Question - GUI/Animation etc...
Richard: Java is viewed generally as slow; but in my tests so far, frame rates of up to 100 fps are possible with simple scene graphs, but I have a 2GHz machine with an ATI x1050 vid card (not the most powerful). I think it will be considered more in the near future, especially for its cross- platform capabilities. I'm currently experimenting with a messaging system, and viewplatform entry/exit behaviors. Once I get something presentable for simple gaming concepts, I'll publish it for review. But currently, some are available: http://www.frontiernet.net/~imaging/games_with_java3d.html http://www.java.com/en/games/ http://www.java-gaming.com/ If I come across more, I'll let everyone know. Thanks....Tom --- richard sabbarton <richard.sabbarton@gmail.com> wrote: > Hi Tom, > > Ahhh... OK. So I could potentially use JPanel to > create a double > buffer for drawing. I guess that would be a lot > quicker because I am > assuming it would switch pointer of the JPanel > rather than, in my > example, copying the pixel data from one buffer to > another. > > I will certainly look at it for my next project but > I don't believe I > will be pushing the boundries with my current task. > I am really only > doing it to get the hang of Java. (I'm normally a > C++ Win32 kinda > guy!) > > Can I ask... What your thoughts on the suitability > of Java for Game > Development? I think I might just be having trouble > shaking some > preconceptions I have through other (non-game > related) experiences. > > Regards > > Richard > > On 05/02/2008, Tom Clifford <tjclifford@yahoo.com> > wrote: > > Hello Richard. > > > > I know that in the Killer Game Programming code > the > > author used a double-buffering command: > > > > setDoubleBuffered(true/false); > > > > which is from JPanel/JComponent, and this is also > > supposed to eliminate flicker, I believe. > > > > Anyway, a custom paint function would also work. > > > > I'm working on making some techniques work for a > > java game. I wish you luck with your efforts. > > > > Tom. > > > > > > --- richard sabbarton > <richard.sabbarton@gmail.com> > > wrote: > > > > > Hi Tom, > > > > > > I downloaded the Java3D API from Sun. It looks > good > > > but I think it > > > was a bit much for what I was looking for. > Anyway, > > > after a little > > > further digging I managed to work out how to do > what > > > I was trying to > > > do. > > > > > > The key to getting rid of the flicker was not > using > > > the paint() > > > function but instead, using my own. > > > > > > Firstly, I created a new Image and then obtained > the > > > Graphics > > > interface for the image. This gave me my > offscreen > > > location to > > > assemble my GUI. I then use this image and draw > it > > > to the Graphics > > > interface of my Applet > > > > > > // Variables and members > > > Image offScreenImage; > > > Graphics offScreenGraphics; > > > Graphics onScreenGraphics; > > > > > > In the init function I run the following: > > > > > > offScreenImage = createImage( width, height > ); > > > offScreenGraphics = > > > offScreenImage.getGraphics(); > > > onScreenGraphics = this.getGraphics(); > > > > > > > > > I then setup a timer to keep the screen > up-to-date > > > every xxx > > > milliseconds which basically runs the following: > > > > > > // Draw everything I need to my offscreen > > > Graphics Interface > > > offScreenGraphics.drawImage( etc. etc. etc. > ); > > > offScreenGraphics.drawImage( etc. etc. etc. > ); > > > offScreenGraphics.drawImage( etc. etc. etc. > ); > > > > > > // Then draw the whole thing to screen with > the > > > Image Interface > > > onScreenGraphics.drawImage(offScreenImage, > xxx , > > > yyyy , this ); > > > > > > Seems to work quite well for simple graphics and > GUI > > > etc. If I want > > > anything more complex then I will go down the > Java3D > > > route but for now > > > this will do. > > > > > > Regards > > > > > > Richard > > > > > > > > > > > > On 04/02/2008, Tom Clifford > <tjclifford@yahoo.com> > > > wrote: > > > > Java has it's own Java3D interface, found at: > > > > > > > > http://java.sun.com/products/java-media/3D/ > > > > > > > > It allows you to do what is called active > > > rendering, > > > > which is similar to the c/c++ WinMain/WndProc > > > loops, > > > > that uses double-buffering, > > > > or you can create the objects you want and > allow > > > > Java3D to do the looping for you, while doing > > > > animation with their Behavior objects. > > > > > > > > There are some good java examples with source > > > > code, at Killer Game Programming with Java, by > > > > Andrew Davison > > > > O'Reilly, May 2005 > > > > ISBN: 0-596-00730-2 > > > > http://www.oreilly.com/catalog/killergame/ > > > > Web Site for the book: > > > > http://fivedots.coe.psu.ac.th/~ad/jg > > > > > > > > code downloads and instructions at: > > > > > > > > http://fivedots.coe.psu.ac.th/~ad/jg/code/ > > > > > > > > Tom C. > > > > > > > > > > > > --- richard sabbarton > > > <richard.sabbarton@gmail.com> > > > > wrote: > > > > > > > > > Hi Guys, > > > > > > > > > > In C++ on windows I would use animation by > > > creating > > > > > a compatible > > > > > device context in memory with > > > CreateCompatibleDC(). > > > > > I would write my > > > > > game and all of its elements to the MemoryDC > and > > > > > then use something > > > > > like BitBlt() to push it to my main DC. > > > > > > > > > > I have recently started learning Java and I > want > > > to > > > > > perform a similar > > > > > function. I want to write all of the > elements > > > to > > > > > memory and then > > > > > transfer it to the screen every x > milliseconds. > > > > > This is to eliminate > > > > > flicker etc. > > > > > > > > > > I have been looking online through tutorials > > > etc. > > > > > and I can't seem to > > > > > find a description of how to do this. Do I > need > === message truncated === ____________________________________________________________________________________ Never miss a thing. Make Yahoo your home page. http://www.yahoo.com/r/hs --------------------- To unsubscribe go to http://gameprogrammer.com/mailinglist.html
|
|