Android Open Source - CoreGame Android Game






From Project

Back to project page CoreGame.

License

The source code is released under:

Copyright (c) 2011 Andrey Moiseev, http://o2genum.ru Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"),...

If you think the Android project CoreGame 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 ru.o2genum.coregame.framework.impl;
/*from  ww w.j  a v a  2s  . co  m*/
import android.app.Activity;
import android.content.Context;
import android.content.res.Configuration;
import android.content.pm.ActivityInfo;
import android.graphics.Bitmap;
import android.graphics.Bitmap.Config;
import android.os.Bundle;
import android.os.PowerManager;
import android.os.PowerManager.WakeLock;
import android.view.Window;
import android.view.WindowManager;

import ru.o2genum.coregame.framework.*;

public abstract class AndroidGame extends Activity implements Game
{
  AndroidFastRenderView renderView;
  Graphics graphics;
  Audio audio;
  Input input;
  FileIO fileIO;
  Vibration vibration;
  Screen screen;

  @Override
  public void onCreate(Bundle savedInstanceState)
  {
    super.onCreate(savedInstanceState);

    requestWindowFeature(Window.FEATURE_NO_TITLE);
    getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
        WindowManager.LayoutParams.FLAG_FULLSCREEN);
    setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
    Bitmap frameBuffer = 
      Bitmap.createBitmap(
          getWindowManager().getDefaultDisplay().getWidth(),
          getWindowManager().getDefaultDisplay().getHeight(),
          Config.RGB_565);
    renderView = new AndroidFastRenderView(this, frameBuffer);
    graphics = new AndroidGraphics(frameBuffer);
    fileIO = new AndroidFileIO(getAssets());
    audio = new AndroidAudio(this);
    input = new AndroidInput(this, renderView);
    vibration = new AndroidVibration(this);
    screen = getStartScreen();
    setContentView(renderView);

    PowerManager powerManager = 
      (PowerManager) getSystemService(Context.POWER_SERVICE);
  }

  @Override
  public void onResume()
  {
    super.onResume();
    screen.resume();
    renderView.resume();
  }

  @Override
  public void onPause()
  {
    super.onPause();
    renderView.pause();
    screen.pause();

    if(isFinishing())
      screen.dispose();
  }

  @Override
  public Input getInput()
  {
    return input;
  }

  @Override
  public FileIO getFileIO()
  {
    return fileIO;
  }

  @Override
  public Graphics getGraphics()
  {
    return graphics;
  }

  @Override
  public Audio getAudio()
  {
    return audio;
  }

  @Override
  public void setScreen(Screen screen)
  {
    if(screen == null)
      throw new IllegalArgumentException("Screen must not be null");

    this.screen.pause();
    this.screen.dispose();
    screen.resume();
    screen.update(0);
    this.screen = screen;
  }

  public Screen getCurrentScreen()
  {
    return screen;
  }

  public Vibration getVibration()
  {
    return vibration;
  }
}




Java Source Code List

ru.o2genum.coregame.framework.Audio.java
ru.o2genum.coregame.framework.FileIO.java
ru.o2genum.coregame.framework.Game.java
ru.o2genum.coregame.framework.Graphics.java
ru.o2genum.coregame.framework.Input.java
ru.o2genum.coregame.framework.Pool.java
ru.o2genum.coregame.framework.Screen.java
ru.o2genum.coregame.framework.Sound.java
ru.o2genum.coregame.framework.Vibration.java
ru.o2genum.coregame.framework.impl.AndroidAudio.java
ru.o2genum.coregame.framework.impl.AndroidFastRenderView.java
ru.o2genum.coregame.framework.impl.AndroidFileIO.java
ru.o2genum.coregame.framework.impl.AndroidGame.java
ru.o2genum.coregame.framework.impl.AndroidGraphics.java
ru.o2genum.coregame.framework.impl.AndroidInput.java
ru.o2genum.coregame.framework.impl.AndroidOrientationHandler.java
ru.o2genum.coregame.framework.impl.AndroidSound.java
ru.o2genum.coregame.framework.impl.AndroidVibration.java
ru.o2genum.coregame.framework.impl.KeyboardHandler.java
ru.o2genum.coregame.framework.impl.MultiTouchHandler.java
ru.o2genum.coregame.framework.impl.OrientationHandler.java
ru.o2genum.coregame.framework.impl.SingleTouchHandler.java
ru.o2genum.coregame.framework.impl.TouchHandler.java
ru.o2genum.coregame.game.Core.java
ru.o2genum.coregame.game.Dot.java
ru.o2genum.coregame.game.GameActivity.java
ru.o2genum.coregame.game.GameScreen.java
ru.o2genum.coregame.game.VectorF.java
ru.o2genum.coregame.game.World.java