Android Open Source - BulletsForever Draw Object Bullet






From Project

Back to project page BulletsForever.

License

The source code is released under:

GNU General Public License

If you think the Android project BulletsForever listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package com.bulletsforever.bullets;
//  w  w w.  j  a  va 2 s.c  o m
import android.graphics.Canvas;

/**
 * This is the player!
 * This should be instantiated by GameMain's setupWorld()
 * Only a single instance should exist per GameMain instance
 */
public class DrawObjectBullet extends DrawObject {
  
  public boolean remove;
  public boolean boss, suicide;
  //private Paint bulletPaint;
  
  public DrawObjectBullet(DrawWorld dw, boolean boss, boolean suicide,
      float x, float y, float v, float a, float gx, float gy, float angle, float angle_v) {
    super(dw, x, y, v, a, gx, gy, angle, angle_v, 5f, 5f);
    
    this.remove = false;
    this.boss = boss;
    this.suicide = suicide;
    if(!boss)
      this.bitmap = dw.bl.getBitmap(R.drawable.bullet, hitboxHalfWidth, hitboxHalfHeight);
    else if(boss & !suicide)
      this.bitmap = dw.bl.getBitmap(R.drawable.bossbullet, hitboxHalfWidth, hitboxHalfHeight);
    else if(boss & suicide)
      this.bitmap = dw.bl.getBitmap(R.drawable.bossbulletsuicide, hitboxHalfWidth, hitboxHalfHeight);
    
    //bulletPaint = new Paint();
    //bulletPaint.setColor(Color.WHITE);
  }
  
  @Override
  public void nextFrame() {
    super.nextFrame();
    
    // If off-screen
    if (x < Settings.screenXMin ||
      x > Settings.screenXMax ||
      y < Settings.screenYMin ||
      y > Settings.screenYMax
      ) {
      remove = true;
    }
  }
  
  @Override
  public void draw(Canvas canvas) {
    /*
    canvas.drawRect(
        x - hitboxHalfWidth, y - hitboxHalfHeight,
        x + hitboxHalfWidth, y + hitboxHalfHeight,
        bulletPaint
        );
    */
    canvas.drawBitmap(bitmap, x - hitboxHalfWidth, y - hitboxHalfHeight, null);
  }

  @Override
  public void onCollision(DrawObject object) {
    // TODO Auto-generated method stub
    
  }

}




Java Source Code List

com.bulletsforever.bullets.AudioMusicPlayer.java
com.bulletsforever.bullets.AudioSoundPool.java
com.bulletsforever.bullets.DrawBitmapLoader.java
com.bulletsforever.bullets.DrawKeyHandler.java
com.bulletsforever.bullets.DrawObjectBackground.java
com.bulletsforever.bullets.DrawObjectBoss.java
com.bulletsforever.bullets.DrawObjectBullet.java
com.bulletsforever.bullets.DrawObjectDynamicArm.java
com.bulletsforever.bullets.DrawObjectDynamicBoss.java
com.bulletsforever.bullets.DrawObjectHUD.java
com.bulletsforever.bullets.DrawObjectPlayer.java
com.bulletsforever.bullets.DrawObject.java
com.bulletsforever.bullets.DrawRefreshHandler.java
com.bulletsforever.bullets.DrawTouchHandler.java
com.bulletsforever.bullets.DrawWorld.java
com.bulletsforever.bullets.GameMain.java
com.bulletsforever.bullets.GameScore.java
com.bulletsforever.bullets.MenuHome.java
com.bulletsforever.bullets.MenuSettings.java
com.bulletsforever.bullets.Settings.java
com.bulletsforever.bullets.ToolsFPSCounter.java
com.bulletsforever.bullets.ToolsRandomizer.java
com.bulletsforever.bullets.ToolsScoreboard.java
com.bulletsforever.bullets.ToolsTracker.java
com.bulletsforever.bullets.ToolsVibrator.java