Hello guys.
I'm working on a simple space shooter kind of game where you are supposed to shoot enemy ships that are coming towards you. I have the code working to the point where you can fire a single bullet but if you fire again the coordinats reset to the ship so there can't be multiple bullets on screen.
I know that you can use an array to hold all of the bullet positions and such but I'm never really worked with arrays and such. So I was wondering if someone could potentially help me figure it out or atleast point me towards a tutorial that would help....
I don't really think that the code I have, other than perhaps the bullet class, will really be needed for assistance but I will post it if asked to.
Bullet.java
EDIT: fixed code tags
I'm working on a simple space shooter kind of game where you are supposed to shoot enemy ships that are coming towards you. I have the code working to the point where you can fire a single bullet but if you fire again the coordinats reset to the ship so there can't be multiple bullets on screen.
I know that you can use an array to hold all of the bullet positions and such but I'm never really worked with arrays and such. So I was wondering if someone could potentially help me figure it out or atleast point me towards a tutorial that would help....
I don't really think that the code I have, other than perhaps the bullet class, will really be needed for assistance but I will post it if asked to.
Bullet.java
public class PlayerLazer {
private Bitmap bitmap;
private int x;
private int y;
public PlayerLazer(Bitmap bitmap, int x, int y){
this.bitmap = bitmap;
this.x = x;
this.y = y;
}
public Bitmap getBitmap(){
return bitmap;
}
public void setBitmap(Bitmap bitmap){
this.bitmap = bitmap;
}
public int getX(){
return x;
}
public int getY(){
return y;
}
public void setX(int x){
this.x = x;
}
public void setY(int y){
this.y = y;
}
public void draw(Canvas canvas){
canvas.drawBitmap(bitmap, x-(bitmap.getWidth()/2), y-(bitmap.getHeight()/2), null);
}
}
EDIT: fixed code tags