Android Open Source - BarrelRace Game Activity






From Project

Back to project page BarrelRace.

License

The source code is released under:

MIT License

If you think the Android project BarrelRace 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.app.ui.assignment.barrelrace;
/*from  w  w w .  j av  a2  s . co m*/
import android.app.Activity;
import android.graphics.Point;
import android.os.Bundle;
import android.view.Display;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.TextView;

import com.app.ui.assignment.barrelrace.views.BarrelRaceView;

/**
* @author Sudharsanan Muralidharan
* @description Barrel Race Game for Android
* @module GameActivity: Main Game Activity
*/

/*Main Game Activity*/
public class GameActivity extends Activity implements OnClickListener {

    /*Initialize BarrelRaceView*/
    private BarrelRaceView barrelRaceView;
    private TextView textViewTime;
    private Button buttonStart;
    
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        // TODO Auto-generated method stub
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_game);
        
        /*Get width and height of the Screen using point*/
        Display display = getWindowManager().getDefaultDisplay();
        Point point = new Point();
        display.getSize(point);
        
        barrelRaceView = (BarrelRaceView) findViewById(R.id.barrelRaceView);
        textViewTime = (TextView) findViewById(R.id.textViewTime);
        buttonStart = (Button) findViewById(R.id.buttonStart);
        barrelRaceView.initialize(this, point.x, point.y, textViewTime);
    
        buttonStart.setOnClickListener(this);
    }

    /*Handle onResume*/
    @Override
    protected void onResume() {
        // TODO Auto-generated method stub
        super.onResume();
        barrelRaceView.resume();
    }

    /*Handle onPause*/
    @Override
    protected void onPause() {
        // TODO Auto-generated method stub
        super.onPause();
        barrelRaceView.pause();
    }

    /*Handle start button onClick*/
    @Override
    public void onClick(View v) {
        // TODO Auto-generated method stub
        switch(v.getId()) {
        case R.id.buttonStart:
            /*Start Timer on button click*/
            barrelRaceView.startTimer();
            break;
        }
    }
    
}




Java Source Code List

com.app.ui.assignment.barrelrace.FailureActivity.java
com.app.ui.assignment.barrelrace.GameActivity.java
com.app.ui.assignment.barrelrace.MainActivity.java
com.app.ui.assignment.barrelrace.SettingsActivity.java
com.app.ui.assignment.barrelrace.SuccessActivity.java
com.app.ui.assignment.barrelrace.ViewScoresActivity.java
com.app.ui.assignment.barrelrace.objects.Barrel.java
com.app.ui.assignment.barrelrace.objects.Fence.java
com.app.ui.assignment.barrelrace.objects.Horse.java
com.app.ui.assignment.barrelrace.objects.Score.java
com.app.ui.assignment.barrelrace.util.CustomAdapter.java
com.app.ui.assignment.barrelrace.util.FileUtil.java
com.app.ui.assignment.barrelrace.util.ScoreComparator.java
com.app.ui.assignment.barrelrace.util.TimerUtil.java
com.app.ui.assignment.barrelrace.views.BarrelRaceView.java