[Java] Draw something more than once?

Started by
13 comments, last by rockstar8577 11 years, 6 months ago

Maybe a picture to see exactly what's wrong?


Sorry.

Before: http://i.imgur.com/tsy2M.png

After: http://i.imgur.com/DflSe.png
Advertisement
Okay i could totally be wrong on this, but isn't the color globally used? So once you change it to purple for the bullet it changes it when you draw the ship? It is totally possible that i am wrong on this.

Okay i could totally be wrong on this, but isn't the color globally used? So once you change it to purple for the bullet it changes it when you draw the ship? It is totally possible that i am wrong on this.


That is correct, within the context.
adding a glColor3f(1.0f,1.0f,1.0f); to the top of the render ship function would solve this.


Also for the op,

don't pass dx,dy to the bullets update method(this will require you to track the direction of the bullets separatly which isn't a good idea), pass it to the constructor and add dx,dy as private member variables. (This way your bullet can keep track of its own direction)
to add a constructor that sets the direction of the bullet you add (in the Bullet class):

private float dx,dy;
public Bullet(float dx, float dy, etc) {
this.dx = dx;
this.dy = dy;
}
[size="1"]I don't suffer from insanity, I'm enjoying every minute of it.
The voices in my head may not be real, but they have some good ideas!

private float dx,dy;
public Bullet(float dx, float dy, etc) {
this.dx = dx;
this.dy = dy;
}


Okay, so instead of calling update when I hit space, I would do Bullet(dx, dy)?
Try it, see if it works.

This topic is closed to new replies.

Advertisement