package tw.edu.hust.bn98036;


import android.app.Activity;
import android.media.MediaPlayer;
import android.os.Bundle;
import android.view.SurfaceHolder;
import android.view.SurfaceHolder.Callback;

public class BallGameActivity extends Activity implements Callback {
	//
	private SurfaceHolder sHolder;
	private MediaPlayer mp3;

	//
	/** Called when the activity is first created. */
	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		// setContentView(R.layout.main);

		final GameSView gv = new GameSView(this);
		sHolder = gv.getHolder();
		sHolder.addCallback(this);
		setContentView(gv);
		//

		new Thread() {
			public void run() {
				// TODO Auto-generated method stub
				while (true) {
					gv.moveBall(sHolder);
					try {
						sleep(30);
					} catch (InterruptedException e) {
						// TODO Auto-generated catch block
						e.printStackTrace();
					}
				}
			}
		}.start();
		//
		mp3 = MediaPlayer.create(this,R.raw.asd);
		mp3.start();
	}

	public void surfaceChanged(SurfaceHolder holder, int format, int width,
			int height) {
		// TODO Auto-generated method stub

	}

	public void surfaceCreated(SurfaceHolder holder) {
		// TODO Auto-generated method stub

	}

	public void surfaceDestroyed(SurfaceHolder holder) {
		// TODO Auto-generated method stub

	}
}