niksa.lovrinic
Lurker
Hello everybody,
I've been playing with the LunarLander example and tried to make my own thing out of it...
On the right bottom screen, I've got a tank that is not moving and his turret that's moving up and down. It's supposed to shoot missiles at different angles.
I've got a tank, turret and a bullet and they are a Bitmap image.
private Bitmap tank;
private Bitmap turret;
private Bitmap bullet;
Turret only rotates from angle 0 to angle 75, and I did that with the update...
I managed to get the turret moving but now I'm finding it hard to shoot missiles.
doDraw method
Update method
Thank you so much guys,
Nick
I've been playing with the LunarLander example and tried to make my own thing out of it...
On the right bottom screen, I've got a tank that is not moving and his turret that's moving up and down. It's supposed to shoot missiles at different angles.
I've got a tank, turret and a bullet and they are a Bitmap image.
private Bitmap tank;
private Bitmap turret;
private Bitmap bullet;
Turret only rotates from angle 0 to angle 75, and I did that with the update...
I managed to get the turret moving but now I'm finding it hard to shoot missiles.
doDraw method
Code:
private void doDraw(Canvas canvas) {
canvas.drawBitmap(backgroundImage, 0, 0, null);
canvas.drawBitmap(tank, x_tank, y_tank, new Paint());
//Rotating the turret
canvas.rotate((float) mHeading, (float) x_turret + mTurretWidth, y_turret);
canvas.drawBitmap(turret, x_turret, y_turret, new Paint());
??? what should I write here for the bullet to be seen shooting out of that turret
}
Update method
Code:
private void updateGame() {
long now = System.currentTimeMillis();
if (mLastTime > now)
return;
double elapsed = (now - mLastTime) / 1000.0;
if (dUp) // UP key
mHeading += 1 * (PHYS_SLEW_SEC * elapsed);
if (mHeading >= 75) mHeading = 75;
if (dDown) // DOWN key
mHeading += (-1) * (PHYS_SLEW_SEC * elapsed);
if (mHeading < 0) mHeading = 0;
i f (dSpace){
// Fire bullet SPACE key
??? what should I write here for the bullet to be seen shooting out of that turret
??? When is the method doDraw being called??
}
mLastTime = now;
}
Thank you so much guys,
Nick