
-----------------------------------
gsquare567
Sun Feb 04, 2007 12:07 am

Game Graphics Wont Appear - Rared up for ur convenience. Donation if successfully helped.
-----------------------------------
Rared up all files for you. Thanks a lot!

-----------------------------------
wtd
Sun Feb 04, 2007 10:09 am

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
Sun Feb 04, 2007 11:07 pm

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
Sun Feb 04, 2007 11:25 pm

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
Mon Feb 05, 2007 10:28 pm

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
Mon Feb 05, 2007 10:59 pm

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
Tue Feb 06, 2007 1:19 pm

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
Tue Feb 06, 2007 11:25 pm

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.

i dont clear the screen, i just draw the background over it
That is how you clear the screen.

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).
public void 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.
public void paint(Graphics g) {
    g.drawImage(backBuffer, 0, 0, this);
}

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! :)

-----------------------------------
gsquare567
Wed Feb 07, 2007 9:57 pm

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 :D
	public void update(Graphics g)
	{
		g = (Graphics) g2d;
		// calculate frame rate
		frameCount++;
		if(System.currentTimeMillis() > startTime + 1000)
		{
			startTime = System.currentTimeMillis();
			frameRate = frameCount;
			frameCount = 0;

			purgeSprites();// delete dead sprites from array
		}

		gameRefreshScreen();// implemented by subclass

		if(!isGamePaused())
		{
			drawSprites();
		}

		// redraw the screen
		paint(g);
	}
     // ...
	protected void drawSprites()
	{
		for(int i = 0; i < sprites.size(); i++)
		{
			AnimatedSprite sprite = (AnimatedSprite) sprites.get(i);
			if(sprite.isAlive())
			{
				sprite.updateAnimation();
				sprite.transform();
				sprite.draw();
			}
		}
	}

taken from the Game class

-----------------------------------
Hikaru79
Thu Feb 08, 2007 2:18 am

Re: Game Graphics Wont Appear - Rared up for ur convenience. Donation if successfully helped.
-----------------------------------
a) how do u get the java text?
Use 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 :P) 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.
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 [url=http://java.sun.com/docs/codeconv/html/CodeConvTOC.doc.html]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
Thu Feb 08, 2007 5:19 pm

Re: Game Graphics Wont Appear - Rared up for ur convenience. Donation if successfully helped.
-----------------------------------
a) how do u get the java text?
Use 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 :P) 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.
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 

dang. i was expecting something on-topic... also, the word 'preference' implies that it doesnt follow a convention. end of story.

-----------------------------------
gsquare567
Tue Feb 13, 2007 4:48 pm

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)


	public void transform()
	{
		aTransform.setToIdentity();// THIS LINE
		aTransform.translate((int) getX() + getWidth() / 2, (int) getY() + getHeight() / 2);
		aTransform.rotate(Math.toRadians(getFaceAngle()));
		aTransform.translate(-getWidth() / 2, -getHeight() / 2);
	}


-----------------------------------
HellblazerX
Tue Feb 13, 2007 5:02 pm

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
Tue Feb 13, 2007 9:24 pm

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.
            shipPic = new ImageIcon("ship.png").getImage();

-----------------------------------
OneOffDriveByPoster
Tue Feb 13, 2007 11:28 pm

Re: Game Graphics Wont Appear - Rared up for ur convenience. Donation if successfully helped.
-----------------------------------
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.

-----------------------------------
gsquare567
Wed Feb 14, 2007 1:19 pm

Re: Game Graphics Wont Appear - Rared up for ur convenience. Donation if successfully helped.
-----------------------------------
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.
