Commit aa39114f authored by Ankita Tiwari's avatar Ankita Tiwari
Browse files

Added ChalkRIP page

parent becb892e
Loading
Loading
Loading
Loading
+1 −3
Original line number Diff line number Diff line
@@ -156,12 +156,10 @@ public class ChalkActivity extends AppCompatActivity implements View.OnClickList
                Log.d("QUESTION", "totalWrong++");
                Intent spawnGame = new Intent(getApplicationContext(), QuizToChalkActivity.class);
                spawnGame.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
                spawnGame.putExtra("QuestionCount", currentQuestionIndex);
                Log.d("QUESTION", "Starting chalk game...");
                getApplicationContext().startActivity(spawnGame);
                currentQuestionIndex++;
                if (currentQuestionIndex != 4) {
                    loadNewQuestion();
                }
            }
        } else {
            //choices button clicked
+15 −0
Original line number Diff line number Diff line
@@ -18,6 +18,9 @@ public class ChalkGameActivity extends AppCompatActivity {
    private ChalkGameClass gameView;
    private Handler handler = new Handler();
    private final static long Interval = 50;
    private boolean timeup = true;



    @Override
    protected void onCreate(Bundle savedInstanceState) {
@@ -44,6 +47,18 @@ public class ChalkGameActivity extends AppCompatActivity {
            }
        }, 0, Interval);

        Timer timer2 = new Timer();
        timer2.schedule(
                handler.post(new Runnable() {
                    @Override
                    public void run() {

                    }
                })
        );


    }


}
 No newline at end of file
+16 −10
Original line number Diff line number Diff line
package com.example.game2d;

import static android.content.Intent.getIntent;

import android.content.Context;
import android.content.Intent;
import android.graphics.Bitmap;
@@ -9,7 +11,7 @@ import android.graphics.Matrix;
import android.media.MediaPlayer;
import android.view.MotionEvent;
import android.view.View;
import "ChalkActivity.java";


public class ChalkGameClass extends View {
    //PLAYER
@@ -27,7 +29,7 @@ public class ChalkGameClass extends View {
    private Bitmap backgroundImage ;

    //MEDIA
    MediaPlayer bonk, oof;
   // MediaPlayer bonk,  oof;

    //CHALK
    private Bitmap chalk[] = new Bitmap[5];
@@ -55,7 +57,6 @@ public class ChalkGameClass extends View {
        private int hintY = 20;



    public ChalkGameClass(Context context)
    {
        super(context);
@@ -106,6 +107,7 @@ public class ChalkGameClass extends View {
        pauseButton = BitmapFactory.decodeResource(getResources(), R.drawable.pause_new);
        hintButton = BitmapFactory.decodeResource(getResources(), R.drawable.question_new);


    }

    @Override
@@ -114,12 +116,15 @@ public class ChalkGameClass extends View {
        canvasWidth = canvas.getWidth();
        canvasHeight = canvas.getHeight();

        bonk = MediaPlayer.create(getContext(), R.raw.bonk);
        oof = MediaPlayer.create(getContext(), R.raw.oof);
       // bonk = MediaPlayer.create(getContext(), R.raw.bonk);
        //oof = MediaPlayer.create(getContext(), R.raw.oof);

        if (backgroundImage == null) return;
        // Use the same Matrix over and over again to minimize
        // allocation in onDraw.

        //getting the question index

        Matrix matrix = new Matrix();

        canvas.drawBitmap(backgroundImage, matrix, null);
@@ -142,7 +147,7 @@ public class ChalkGameClass extends View {
            if(normGravity)
            {
                playerSpeed = 125;
                bonk.start();
               // bonk.start();
            }
        }       //limiting the player's y to the top of the screen

@@ -174,7 +179,7 @@ public class ChalkGameClass extends View {
            if (hitChalkChecker(chalkX[ii], chalkY[ii])) //if player collides with chalk
            {
                chalkX[ii] = chalkX[ii] - 200; //makes chalk disappear
                oof.start();
                //oof.start();
                lifecounter--; //reduces health;

                if(lifecounter == 0)  //if all lives used up
@@ -201,9 +206,10 @@ public class ChalkGameClass extends View {
            {
                chalkX[ii] = chalkX[ii] - 200;
                chalkPassed = 0;
                Intent chalkQuestionIntent  = new Intent(getContext(), ChalkToQuizActivity.class);
                chalkQuestionIntent.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
                getContext().startActivity(chalkQuestionIntent);
                Intent returnQuiz = new Intent(getContext(), ChalkToQuizActivity.class);
                returnQuiz.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
                getContext().startActivity(returnQuiz);

            }
            chalkCol = ii;
            while(chalkCol > 4) //keeping chalkCol between 0 and 4;
+2 −2
Original line number Diff line number Diff line
@@ -17,8 +17,8 @@ public class ChalkGameRIPActivity extends AppCompatActivity {
        resButton.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Intent ChalkRIPtrns = new Intent(ChalkGameRIPActivity.this,ChalkGameActivity.class);
                ChalkRIPtrns.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
                Intent ChalkRIPtrns = new Intent(ChalkGameRIPActivity.this,MainActivity.class);
                ChalkRIPtrns.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK| Intent.FLAG_ACTIVITY_CLEAR_TASK);
                startActivity(ChalkRIPtrns);
            }
        });
+1 −0
Original line number Diff line number Diff line
@@ -10,6 +10,7 @@ import android.widget.Button;
public class ChalkToQuizActivity extends AppCompatActivity {
    private Button resButton;


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