Posted: 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...
gsquare567
Posted: 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.
ericfourfour
Posted: 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?
gsquare567
Posted: 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?
ericfourfour
Posted: 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.
gsquare567
Posted: 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.
ericfourfour
Posted: 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).
Java:
publicvoid update(Graphics g){// I put the curly bracket where it is supposed to be!
g = (Graphics) g2d;
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!
Sponsor Sponsor
gsquare567
Posted: 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
Posted: 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 Of course, everyone should. It's just that a lot of people prefer, instead of using the tab character to indent, you use four seperate spaces instead. It looks the same to you, but the computer represents those two things very differently, and while not all text editors implement tab characters the same way, they all pretty much implement spaces right (one would hope ) Of course, most editors have an option to bind the Tab key to four seperate spaces, since it would be a pain to type them all yourself.
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).
gsquare567
Posted: 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 Of course, everyone should. It's just that a lot of people prefer, instead of using the tab character to indent, you use four seperate spaces instead. It looks the same to you, but the computer represents those two things very differently, and while not all text editors implement tab characters the same way, they all pretty much implement spaces right (one would hope ) Of course, most editors have an option to bind the Tab key to four seperate spaces, since it would be a pain to type them all yourself.
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.
gsquare567
Posted: 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)
Posted: 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.
McKenzie
Posted: 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.
Posted: 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.