Android Open Source - BulletsForever Game Main






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;
/*  ww w  .  jav a 2s .c om*/
import android.app.Activity;
import android.os.Bundle;
import android.util.Log;
import android.view.KeyEvent;
import android.view.Window;
import android.view.WindowManager;

/**
 * This is the app's main game Activity
 * This should be instantiated by MenuHome's startGame()
 * Multiple instances can be created/destroyed per app session, but only one can exist at a time 
 */
public class GameMain extends Activity {
  
  private DrawWorld dw;
  private AudioMusicPlayer mp;
  
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    Settings.reload(this);
    //Settings.setScreenDimensions(this);
    System.gc(); // Cleanup before setup
    
    // Fullscreen
    // This also solves the header problem
    requestWindowFeature(Window.FEATURE_NO_TITLE); 
    getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
    
    // Music Player
    int bgmusic = -1;
    switch (Settings.getInt(R.string.bgmusic)) {
      case 1: //Techno
        bgmusic = R.raw.techno;
        break;
      case 2:  //Classical
        bgmusic = R.raw.classical;
        break;
      case 0:
      default:
        break;
    }
    if (bgmusic != -1) {
      try {
        mp = new AudioMusicPlayer();
        mp.load(getBaseContext(), bgmusic);
        mp.start();
      } catch (Exception e) {
        Log.v(e.getClass().getName(), e.getMessage());
      }
    }
    
    // Welcome, to the World
    dw = new DrawWorld(this);
    setContentView(dw);
    
    // Start updating the screen
    dw.startUpdating();
  }
  
  @Override
  protected void onDestroy() {
    if (dw != null) dw.onDestroy();
    if (mp != null) mp.onDestroy();
    super.onDestroy();
  }
  
  @Override
  public boolean onKeyDown(int keyCode, KeyEvent event) {
    if (dw.onKeyDown(keyCode, event)) {
      return true;
    } else {
      return super.onKeyDown(keyCode, event);
    }
  }
  
  @Override
  public boolean onKeyUp(int keyCode, KeyEvent event) {
    if (dw.onKeyUp(keyCode, event)) {
      return true;
    } else {
      return super.onKeyUp(keyCode, event);
    }
  }
}




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