Commit 165caf5c authored by Ankita Tiwari's avatar Ankita Tiwari
Browse files

Merge branch 'top-secret' of...

Merge branch 'top-secret' of https://agile.bu.edu/gitlab/ec327_projects/group7project into top-secret

# Conflicts:
#	app/src/main/java/com/example/game2d/Game.java
parents 7e26a006 4ecc6f19
Loading
Loading
Loading
Loading
+32 −27
Original line number Diff line number Diff line
@@ -177,33 +177,16 @@ public class ChalkActivity extends AppCompatActivity implements View.OnClickList

        questionTextView.setText(ChalkQuestionAnswer.question[currentQuestionIndex]);

        // Randomize orders of choices displayed
        int[] orders = new int[]{0, 1, 2, 3};
        // Randomize orders[]
        Random rand = new Random();

        for (int i = 0; i < orders.length; i++) {
            // Switch i and randomIndexToSwap
            int randomIndexToSwap = rand.nextInt(orders.length);
        int[] randomized = randomizeOrders();

            // temp vars to store element at randomIndex
            int tempOrder = orders[randomIndexToSwap];

            // element at randomIndex is now element at i (2 i duplicates)
            orders[randomIndexToSwap] = orders[i];

            // element at i is now element at randomIndex (via temp vars)
            orders[i] = tempOrder;
        }

        /*ansA.setText(ChalkQuestionAnswer.choices[currentQuestionIndex][orders[0]]);
        ansB.setText(ChalkQuestionAnswer.choices[currentQuestionIndex][orders[1]]);
        ansC.setText(ChalkQuestionAnswer.choices[currentQuestionIndex][orders[2]]);
        ansD.setText(ChalkQuestionAnswer.choices[currentQuestionIndex][orders[3]]);*/
        ansA.setText(ChalkQuestionAnswer.choices[currentQuestionIndex][0]);
        ansA.setText(ChalkQuestionAnswer.choices[currentQuestionIndex][randomized[0]]);
        ansB.setText(ChalkQuestionAnswer.choices[currentQuestionIndex][randomized[1]]);
        ansC.setText(ChalkQuestionAnswer.choices[currentQuestionIndex][randomized[2]]);
        ansD.setText(ChalkQuestionAnswer.choices[currentQuestionIndex][randomized[3]]);
        /*ansA.setText(ChalkQuestionAnswer.choices[currentQuestionIndex][0]);
        ansB.setText(ChalkQuestionAnswer.choices[currentQuestionIndex][1]);
        ansC.setText(ChalkQuestionAnswer.choices[currentQuestionIndex][2]);
        ansD.setText(ChalkQuestionAnswer.choices[currentQuestionIndex][3]);
        ansD.setText(ChalkQuestionAnswer.choices[currentQuestionIndex][3]);*/
    }

    void finishQuiz(){
@@ -220,6 +203,28 @@ public class ChalkActivity extends AppCompatActivity implements View.OnClickList
        finish();
    }

    public int[] randomizeOrders() {
        int[] randomized = { 0, 1, 2, 3 };

        // Randomize orders[]
        Random rand = new Random();

        for (int i = 0; i < randomized.length; i++) {
            // Switch i and randomIndexToSwap
            int randomIndexToSwap = rand.nextInt(randomized.length);

            // temp vars to store element at randomIndex
            int tempOrder = randomized[randomIndexToSwap];

            // element at randomIndex is now element at i (2 i duplicates)
            randomized[randomIndexToSwap] = randomized[i];

            // element at i is now element at randomIndex (via temp vars)
            randomized[i] = tempOrder;
        }

        return randomized;
    }
    protected void onPause() {
        super.onPause();
        backgroundMusic.stop();
+8 −8
Original line number Diff line number Diff line
@@ -10,16 +10,16 @@ public class ChalkQuestionAnswer {
    };

    public static String[][] choices = {
        {"501B50797001", "501C50767001", "501C50757001", "501B50897001"},
        {"C0017001C0017001", "B0017001D0017001", "C0016001C0016001", "B0017001D0018001"},
        {"5000504a50947040", "5000504b50957040", "5000504a50947040", "5000504b50947040"},
        {"c000c0014042d7fc", "c000d0024042d7fc", "c000d0014042d7fb", "c000c0014042d7fc"},
        {"/501B50797001", "501C50767001", "501C50757001", "501B50897001"},
        {"/C0017001C0017001", "B0017001D0017001", "C0016001C0016001", "B0017001D0018001"},
        {"/5000504a50947040", "5000504b50957040", "5000504a50947040", "5000504b50947040"},
        {"/c000c0014042d7fc", "c000d0024042d7fc", "c000d0014042d7fb", "c000c0014042d7fc"},
    };

    public static String[] correctAnswers = {
        "501B50797001",
        "C0017001C0017001",
        "5000504a50947040",
        "c000c0014042d7fc"
        "/501B50797001",
        "/C0017001C0017001",
        "/5000504a50947040",
        "/c000c0014042d7fc"
    };
}
+15 −0
Original line number Diff line number Diff line
@@ -32,6 +32,7 @@ public class Game extends SurfaceView implements SurfaceHolder.Callback {
    private final Detector detector1;
    private final Detector detector2;
    private final Detector detector3;
    private final Detector detector4;

    private GameLoop gameLoop;
    private Context gameContext;
@@ -71,6 +72,7 @@ public class Game extends SurfaceView implements SurfaceHolder.Callback {
        detector1 = new Detector(getContext(), player, (float) (width * 0.25), (float) (height * 0.17), 100);
        detector2 = new Detector(getContext(), player, (float) (width * 0.47), (float) (height * 0.17), 100);
        detector3 = new Detector(getContext(), player, (float) (width * 0.75), (float) (height * 0.17), 100);
        detector4 = new Detector(getContext(), player, (float) (width * 0.1), (float) (height * 0.17), 100);

        // copy other developers lol
        setFocusable(true);
@@ -137,6 +139,7 @@ public class Game extends SurfaceView implements SurfaceHolder.Callback {
        detector1.draw(canvas);
        detector2.draw(canvas);
        detector3.draw(canvas);
        detector4.draw(canvas);
    }
    // method to display how many updates per second (UPS)
    public void drawUPS(Canvas canvas) {
@@ -170,6 +173,7 @@ public class Game extends SurfaceView implements SurfaceHolder.Callback {
        detector1.update();
        detector2.update();
        detector3.update();
        detector4.update();
        // Check for collision with detectors
        if (Circle.isColliding(player, detector1)) {
            if (canMove) {
@@ -192,6 +196,13 @@ public class Game extends SurfaceView implements SurfaceHolder.Callback {
            }
            canMove = false;
        }
        if (Circle.isColliding(player, detector4)) {
            if (canMove) {
                // call method to start art activity
                startArtActivity();
            }
            canMove = false;
        }
    }

    // check screen width and height
@@ -216,4 +227,8 @@ public class Game extends SurfaceView implements SurfaceHolder.Callback {
        Intent intent = new Intent(gameContext, FirebaseActivity.class);
        gameContext.startActivity(intent);
    }
    public void startArtActivity() {
        Intent intent = new Intent(gameContext, ArtActivity.class);
        gameContext.startActivity(intent);
    }
}
+4 −4
Original line number Diff line number Diff line
@@ -16,9 +16,9 @@ public abstract class Circle extends GameObject{
    /** Constructs a circle that can be drawn to the screen.
     * @param context the current context
     * @param color the color of the drawn circle, defined in the res/values/colors.xml file
     * @param positionX an x-coordinate for the center of the circle
     * @param positionY a y-coordinate for the center of the circle
     * @param radius the radius (in pixels) of the circle
     * @param positionX an x-coordinate for the circle's center
     * @param positionY a y-coordinate for the circle's center
     * @param radius the circle's radius (in pixels)
     * @return the newly constructed Circle object
     */
    public Circle(Context context, int color, float positionX, float positionY, double radius) {
@@ -56,7 +56,7 @@ public abstract class Circle extends GameObject{

    /**
     * Abstract function to draw Circle objects to the screen.
     * See Player and Detecter classes for implementations.
     * See Player and Detector classes for implementations.
     * @param canvas the canvas to which the object will be drawn
     */
    public abstract void draw(Canvas canvas);
+23 −1
Original line number Diff line number Diff line
@@ -7,14 +7,31 @@ import androidx.core.content.ContextCompat;

import com.example.game2d.R;

/**
 * Detector is a circle that is not drawn to the screen. It is used to detect collisions with the
 * player.
 */
public class Detector extends Circle {
    private final Player player;

    /**
     * Constructs a detector with the specified position and radius.
     * @param context the current context
     * @param player the player object to detect collisions with
     * @param positionX the x-coordinate for the circle's center
     * @param positionY the y-coordinate for the circle's center
     * @param radius the circle's radius (in pixels)
     * @return the newly constructed Detector object
     */
    public Detector(Context context, Player player, float positionX, float positionY, double radius) {
        super(context, ContextCompat.getColor(context, R.color.detector), positionX, positionY, radius);
        this.player = player;
    }

    /**
     * Updates the position of the detector based on its velocity.
     * Velocity is always set to zero.
     */
    public void update() {
        velocityX = 0;
        velocityY = 0;
@@ -22,6 +39,11 @@ public class Detector extends Circle {
        positionY += velocityY;
    }

    /**
     * Can draw the detector circle to the screen.
     * Uncomment to make the detector visible for testing and debugging.
     * @param canvas the canvas to which the object will be drawn
     */
    public void draw(Canvas canvas) {
        // canvas.drawCircle((float) positionX, (float) positionY, (float) radius, paint);
    }
Loading