Computer Science Canada Game Graphics Wont Appear - Rared up for ur convenience. Donation if successfully helped. |
| Author: | gsquare567 [ Sun Feb 04, 2007 12:07 am ] |
| Post subject: | Game Graphics Wont Appear - Rared up for ur convenience. Donation if successfully helped. |
Rared up all files for you. Thanks a lot! |
|
| Author: | wtd [ Sun Feb 04, 2007 10:09 am ] |
| Post subject: | RE:Game Graphics Wont Appear - Rared up for ur convenience. Donation if successfully helped. |
Perhaps if you provided more information on where you're encountering the error. Which images won't load and all that... |
|
| Author: | gsquare567 [ Sun Feb 04, 2007 11:07 pm ] |
| Post subject: | Re: Game Graphics Wont Appear - Rared up for ur convenience. Donation if successfully helped. |
the first thing thats supposed to appear is the background, and that doesnt even appear. i've block-tested it all. the main class is galacticwar, so you should look at that, or maybe im missing something in the game class. i've checked the paint, update, init, and run methods. they all look fine. so, first the background is supposed to appear, then the game menu stuff after it. there arent any errors too, so im stumped. |
|
| Author: | ericfourfour [ Sun Feb 04, 2007 11:25 pm ] |
| Post subject: | RE:Game Graphics Wont Appear - Rared up for ur convenience. Donation if successfully helped. |
I have not looked at your code but if nothing appears you could be doing something wrong with the backbuffer. Are you sure you are drawing everything at the correct time? |
|
| Author: | gsquare567 [ Mon Feb 05, 2007 10:28 pm ] |
| Post subject: | Re: Game Graphics Wont Appear - Rared up for ur convenience. Donation if successfully helped. |
umm... yeah. i've used a backbuffer b4. can u check it out? |
|
| Author: | ericfourfour [ Mon Feb 05, 2007 10:59 pm ] |
| Post subject: | RE:Game Graphics Wont Appear - Rared up for ur convenience. Donation if successfully helped. |
Just ensure you are clearing before you draw and drawing onto the backbuffer image before you draw it. I don't have to look at your code for you to do that. |
|
| Author: | gsquare567 [ Tue Feb 06, 2007 1:19 pm ] |
| Post subject: | Re: Game Graphics Wont Appear - Rared up for ur convenience. Donation if successfully helped. |
i dont clear the screen, i just draw the background over it. as for the backbuffer drawing, i use g2d = backbuffer.createGraphics(), so anything i draw on my g2d variable is drawn. trust me, i'm no noob, if u wanna help, ur gonna hafta take a peek at the code. |
|
| Author: | ericfourfour [ Tue Feb 06, 2007 11:25 pm ] | ||||
| Post subject: | Re: Game Graphics Wont Appear - Rared up for ur convenience. Donation if successfully helped. | ||||
I looked at your code, and I have a few comments before I begin. gsquare567 wrote: i dont clear the screen, i just draw the background over it
That is how you clear the screen. gsquare567 wrote: trust me, i'm no noob
I never implied that. On the other hand, there are some pretty ugly spots in your program. First thing's first. Please don't indent using tab. Use spaces. 4 is recommended. You can set your tab to do this if you desire. You should never have to assign a value to a parameter. Parameters are usually constant and should be left that way (why would you bother with a parameter if you are just going to use a different value anyway).
I think I found your problem. You are not drawing anything except the backbuffer (unless everything else is hidden elsewhere and it is more difficult to find). The paint method is where all rendering should go (it wasn't created for no reason). It is one centralized location where you can look to see how your program is being rendered. If you spread it all through your program it makes it much more difficult to debug.
You should also look into commenting. If you do it right, a program can generate javadoc for your classes. Just more fun stuff. I would go on further but it is getting pretty late. Good luck! |
|||||
| Author: | gsquare567 [ Wed Feb 07, 2007 9:57 pm ] | ||
| Post subject: | Re: Game Graphics Wont Appear - Rared up for ur convenience. Donation if successfully helped. | ||
a) how do u get the java text? b) indenting is faster + easier to avoid mistakes c) curly braces under are neater and easier to count; its more preferance than right and wrong now... ontopic
taken from the Game class |
|||
| Author: | Hikaru79 [ Thu Feb 08, 2007 2:18 am ] |
| Post subject: | Re: Game Graphics Wont Appear - Rared up for ur convenience. Donation if successfully helped. |
gsquare567 @ Wed Feb 07, 2007 10:57 pm wrote: a) how do u get the java text?
Use [ syntax="java ] [ /syntax ] (but without the spaces obviously.) gsqaure567 wrote: b) indenting is faster + easier to avoid mistakes
Oh, believe me, he's not saying you shouldn't indent gsquare567 wrote: c) curly braces under are neater and easier to count; its more preferance than right and wrong
Of course, the code will compile either way. But when things of preference come along, its usually a good idea for the community to establish a convention that they all follow. In this case, the de facto convention is the Sun Java Code Style Guidelines (that's a link there). It seems that curly braces on the same line are prefferred (check the sample file, for example). |
|
| Author: | gsquare567 [ Thu Feb 08, 2007 5:19 pm ] |
| Post subject: | Re: Game Graphics Wont Appear - Rared up for ur convenience. Donation if successfully helped. |
Hikaru79 @ Thu Feb 08, 2007 2:18 am wrote: gsquare567 @ Wed Feb 07, 2007 10:57 pm wrote: a) how do u get the java text?
Use [ syntax="java ] [ /syntax ] (but without the spaces obviously.) gsqaure567 wrote: b) indenting is faster + easier to avoid mistakes
Oh, believe me, he's not saying you shouldn't indent gsquare567 wrote: c) curly braces under are neater and easier to count; its more preferance than right and wrong
Of course, the code will compile either way. But when things of preference come along, its usually a good idea for the community to establish a convention that they all follow. In this case, the de facto convention is the Sun Java Code Style Guidelines (that's a link there). It seems that curly braces on the same line are prefferred (check the sample file, for example). dang. i was expecting something on-topic... also, the word 'preference' implies that it doesnt follow a convention. end of story. |
|
| Author: | gsquare567 [ Tue Feb 13, 2007 4:48 pm ] | ||
| Post subject: | Re: Game Graphics Wont Appear - Rared up for ur convenience. Donation if successfully helped. | ||
found in printstacktrace: Exception in thread "AWT-EventQueue-3" java.lang.NullPointerException at ImageEntity.transform(ImageEntity.java:94) at Sprite.transform(Sprite.java:229) at Game.drawSprites(Game.java:120) at Game.update(Game.java:245) at sun.awt.RepaintArea.updateComponent(Unknown Source) at sun.awt.RepaintArea.paint(Unknown Source) at sun.awt.windows.WComponentPeer.handleEvent(Unknown Source) at java.awt.Component.dispatchEventImpl(Unknown Source) at java.awt.Container.dispatchEventImpl(Unknown Source) at java.awt.Component.dispatchEvent(Unknown Source) at java.awt.EventQueue.dispatchEvent(Unknown Source) at java.awt.EventDispatchThread.pumpOneEventForHierarchy(Unknown Source) at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source) at java.awt.EventDispatchThread.pumpEvents(Unknown Source) at java.awt.EventDispatchThread.pumpEvents(Unknown Source) at java.awt.EventDispatchThread.run(Unknown Source)
|
|||
| Author: | HellblazerX [ Tue Feb 13, 2007 5:02 pm ] |
| Post subject: | Re: Game Graphics Wont Appear - Rared up for ur convenience. Donation if successfully helped. |
Did you properly implement your aTransform variable? (I'm assuming that its an AffineTransform object) If you did, then it wouldn't make any sense why the method wouldn't work, seeing as it doesn't return anything. Post the section of code where you declared aTransform. |
|
| Author: | McKenzie [ Tue Feb 13, 2007 9:24 pm ] | ||
| Post subject: | Re: Game Graphics Wont Appear - Rared up for ur convenience. Donation if successfully helped. | ||
I think the problem is with use of getImage(). getImage doesn't actually load the image at the time you call it. It queues it up to be loaded when needed. The problem, of course, when you are using active rendering (as you are) you can get a null pointer. There are a few ways to force the image to load at initialization. I personally like to load it up in an ImageIcon then use getImage(). e.g.
|
|||
| Author: | OneOffDriveByPoster [ Tue Feb 13, 2007 11:28 pm ] |
| Post subject: | Re: Game Graphics Wont Appear - Rared up for ur convenience. Donation if successfully helped. |
gsquare567 @ Sun Feb 04, 2007 12:07 am wrote: Rared up all files for you. Thanks a lot!
RAR does not help--ZIP is nice because it is more widely supported. Your graphics do not show because your buffer draws back to itself... Try making a getBuffer() function for your other class to draw to and leave getGraphics() alone. After that check Game.update() for odd code. You get lots of exceptions because you are not using AnimatedSprite, etc. properly. Try using AnimatedSprite.load()--that seems to set things up. If this code is not off the Internet or someone else--I hope you learned not to use "big bang" programming from this. |
|
| Author: | gsquare567 [ Wed Feb 14, 2007 1:19 pm ] |
| Post subject: | Re: Game Graphics Wont Appear - Rared up for ur convenience. Donation if successfully helped. |
OneOffDriveByPoster @ Tue Feb 13, 2007 11:28 pm wrote: gsquare567 @ Sun Feb 04, 2007 12:07 am wrote: Rared up all files for you. Thanks a lot!
RAR does not help--ZIP is nice because it is more widely supported. Your graphics do not show because your buffer draws back to itself... Try making a getBuffer() function for your other class to draw to and leave getGraphics() alone. After that check Game.update() for odd code. You get lots of exceptions because you are not using AnimatedSprite, etc. properly. Try using AnimatedSprite.load()--that seems to set things up. If this code is not off the Internet or someone else--I hope you learned not to use "big bang" programming from this. ur wrong... i found the error. and RAR is newer and most people have it. stay ontopic. you can read more than just the first post, yanoe. also, i dont know why the aTransform is null because when i use load(String filename) it initializes it to the image's filename, then use transform(), and for that instance of the object it is already set. maybe i forgot to load one of them? i doubt its with the getImage() because i've used that before in the same way and this works just fine. |
|