Commit 7e26a006 authored by Ankita Tiwari's avatar Ankita Tiwari
Browse files

Merge remote-tracking branch 'origin/top-secret' into top-secret

# Conflicts:
#	app/src/main/AndroidManifest.xml
#	app/src/main/java/com/example/game2d/Game.java
parents ce29125a 55502466
Loading
Loading
Loading
Loading
+1 −4
Original line number Diff line number Diff line
@@ -11,9 +11,6 @@
        android:supportsRtl="true"
        android:theme="@style/Theme.Game2D"
        tools:targetApi="31">
        <activity
            android:name=".MenuPause"
            android:exported="false" />
        <activity
            android:name=".ChalkGameRIPActivity"
            android:exported="false"
+1 −1
Original line number Diff line number Diff line
@@ -31,7 +31,7 @@ public class ArtActivity extends AppCompatActivity { //
            @Override
            public void onClick(View view) {
                // switch back to main activity
                Intent intent = new Intent(ArtActivity.this, StartActivity.class);
                Intent intent = new Intent(ArtActivity.this, MainActivity.class);
                startActivity(intent);
            }
        });
+2 −32
Original line number Diff line number Diff line
@@ -26,10 +26,6 @@ and rendering all objects to the screen.
 */
public class Game extends SurfaceView implements SurfaceHolder.Callback {
    Bitmap background;
    Bitmap pauseButton;
    private boolean pauseTouch;
    private int pauseX = 1800;
    private int pauseY = 20;
    private final Joystick joystick;
    private final Player player;
    public static boolean canMove;
@@ -57,10 +53,10 @@ public class Game extends SurfaceView implements SurfaceHolder.Callback {
        Log.d("DIMENSION", String.valueOf(height));
        Log.d("DIMENSION", String.valueOf(width));

        // Set background and pause Button
        // Set background
        Bitmap original = BitmapFactory.decodeResource(context.getResources(), R.drawable.new_classroom_spots_scaled);
        background = Bitmap.createScaledBitmap(original, width, height, false);
        pauseButton = BitmapFactory.decodeResource(context.getResources(), R.drawable.pause_new);

        // Initialize game objects
        // initialize joystick
        int joystickX = 150;
@@ -84,7 +80,6 @@ public class Game extends SurfaceView implements SurfaceHolder.Callback {
    @Override
    public boolean onTouchEvent(MotionEvent event) {
        // handle touch event actions
        pauseTouch = onSingleTap(event);
        switch(event.getAction()) {
            // when user presses down
            case MotionEvent.ACTION_DOWN:
@@ -142,7 +137,6 @@ public class Game extends SurfaceView implements SurfaceHolder.Callback {
        detector1.draw(canvas);
        detector2.draw(canvas);
        detector3.draw(canvas);
        canvas.drawBitmap(pauseButton, pauseX, pauseY, null);
    }
    // method to display how many updates per second (UPS)
    public void drawUPS(Canvas canvas) {
@@ -198,11 +192,6 @@ public class Game extends SurfaceView implements SurfaceHolder.Callback {
            }
            canMove = false;
        }

        if(pauseTouch)
        {
            startPauseActivity();
        }
    }

    // check screen width and height
@@ -227,23 +216,4 @@ public class Game extends SurfaceView implements SurfaceHolder.Callback {
        Intent intent = new Intent(gameContext, FirebaseActivity.class);
        gameContext.startActivity(intent);
    }

    public void startPauseActivity() {
        Intent intent = new Intent(gameContext, MenuPause.class);
        intent.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
        gameContext.startActivity(intent);
    }
    public boolean onSingleTap(MotionEvent event) {
        int x = (int) event.getX();
        int y = (int) event.getY();

        if (pauseX < x && x < (pauseX + pauseButton.getWidth()) //if user touches pause button
                && pauseY < y && y < (pauseY + pauseButton.getHeight()))

        {
            return true;
        }

        return false;
    }
}
+8 −1
Original line number Diff line number Diff line
@@ -5,6 +5,7 @@ import static com.example.game2d.MapUtil.sortByValue;

import android.annotation.SuppressLint;
import android.content.Intent;
import android.graphics.Color;
import android.graphics.Typeface;
import android.os.Build;
import android.os.Bundle;
@@ -91,6 +92,7 @@ public class LeaderboardActivity extends AppCompatActivity {
            rankView.setFontFeatureSettings("press_start_2p");
            rankView.setText(String.format("%d",ranking));


            TextView nameView = new TextView(this);
            nameView.setTextSize(20);
            nameView.setTextAlignment(View.TEXT_ALIGNMENT_CENTER);
@@ -103,7 +105,12 @@ public class LeaderboardActivity extends AppCompatActivity {
            scoreView.setFontFeatureSettings("press_start_2p");
            scoreView.setText(String.format("%f",  scoreboardObj.scoreboard.get(username)));


            if(ranking <=3)
            {
                rankView.setTextColor(Color.RED);
                nameView.setTextColor(Color.RED);
                scoreView.setTextColor(Color.RED);
            }

            // Add the TextView to the LinearLayout
            scoreListLayout.addView(rankView);
+1 −1
Original line number Diff line number Diff line
@@ -75,7 +75,7 @@
                android:layout_marginStart="10dp"
                android:layout_centerHorizontal="true"
                android:fontFamily="@font/press_start_2p"
                android:text="(press sync to sync data)"
                android:text="(press sync data)"
                android:textSize="10dp" />