Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to play Instructions and button Animation #88

Merged
merged 27 commits into from
May 28, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
05cfd7c
Keep changes when switching branch
faisal1201 May 22, 2022
c878404
Merge remote-tracking branch 'origin/master' into HOW_TO_PLAY_SCREEN
faisal1201 May 24, 2022
86a1bf1
Include How to play Button
faisal1201 May 24, 2022
392c7fb
Merge branch 'master' of https://github.com/DIT113-V22/group-08 into …
faisal1201 May 25, 2022
9b90be0
Add how to play Button on activity_main
faisal1201 May 25, 2022
c3d4f1a
Finish Getting Started screen
faisal1201 May 25, 2022
08458c7
Add instruction for controls and game modes
faisal1201 May 25, 2022
687362b
Add "How to play ?" instructions
faisal1201 May 26, 2022
cddaaea
Button Enhancement
faisal1201 May 26, 2022
e17bb1a
Fix some Layouts for PIXEL 3 XL API 31
faisal1201 May 27, 2022
635207a
Merge remote-tracking branch 'origin/master' into HOW_TO_PLAY_SCREEN
faisal1201 May 27, 2022
aac2b0f
Merge branch 'master' into HOW_TO_PLAY_SCREEN
faisal1201 May 27, 2022
9373dd6
just updating some methods name
May 27, 2022
6f7112a
Merge remote-tracking branch 'origin/HOW_TO_PLAY_SCREEN' into HOW_TO_…
faisal1201 May 27, 2022
87d70b5
Fix main Layout and add button enhancements to credits button
faisal1201 May 27, 2022
b011cec
Fixed the constraint for the main activity after the merge of credit …
May 27, 2022
fa5ab1d
Merge branch 'master' into HOW_TO_PLAY_SCREEN
Quinstedt May 27, 2022
5a89ebf
Fixed the Constraint
May 27, 2022
bfc4838
Game mode text view Title changed
faisal1201 May 27, 2022
8d844b5
Game mode text view Title changed
faisal1201 May 27, 2022
c185295
fixed the constraintof the scoreboard
May 27, 2022
e1fd59d
Merge remote-tracking branch 'origin/master' into HOW_TO_PLAY_SCREEN
May 28, 2022
88c07fa
Merge remote-tracking branch 'origin/master' into HOW_TO_PLAY_SCREEN
faisal1201 May 28, 2022
b1cbf88
Merge master to how to play screen
faisal1201 May 28, 2022
ee2642d
updated some comments, all test passing manually
May 28, 2022
738d3fb
Merge remote-tracking branch 'origin/HOW_TO_PLAY_SCREEN' into HOW_TO_…
May 28, 2022
57b1227
updated some comments, all test passing manually
May 28, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ import org.junit.runners.Suite
ScoreboardTest::class
)

*/

*/
class ActivityTestSuite {

}
Expand Down
13 changes: 12 additions & 1 deletion Android/islandRush/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/Theme.IslandRush">

<activity
android:name=".instructionClasses.CheckLeaderboard"
android:exported="false" />
<activity
android:name=".activityClasses.Scoreboard"
android:exported="false" />
Expand Down Expand Up @@ -45,6 +47,15 @@
<activity
android:name=".activityClasses.MainActivity"
android:exported="false" />
<activity
android:name=".instructionClasses.GettingStarted"
android:exported="false" />
<activity
android:name=".instructionClasses.GameModes"
android:exported="false" />
<activity
android:name=".instructionClasses.ControlsInstruction"
android:exported="false" />

<service android:name="org.eclipse.paho.android.service.MqttService" />
</application>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import android.graphics.drawable.AnimationDrawable;
import android.os.Bundle;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
import android.widget.Button;
import android.widget.CompoundButton;
import android.widget.ImageButton;
Expand All @@ -22,6 +23,7 @@ public class ControlChoice extends AppCompatActivity {
Animation scaleUp,scaleDown;
Boolean isOnRaceMode = false;


@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Expand All @@ -37,6 +39,9 @@ protected void onCreate(Bundle savedInstanceState) {
animationBackground.setExitFadeDuration(5000);
animationBackground.start();

scaleUp= AnimationUtils.loadAnimation(this, R.anim.scale_up);
scaleDown= AnimationUtils.loadAnimation(this, R.anim.scale_down);

escapeHash = findViewById(R.id.controlChoice_escapeHash);
escapeHash.setOnClickListener(view -> goBack());

Expand Down Expand Up @@ -66,6 +71,8 @@ public void onCheckedChanged(CompoundButton compoundButton, boolean raceModeIsON
* Method for the escape Hash that launches MainActivity
*/
private void goBack() {
escapeHash.startAnimation(scaleUp);
escapeHash.startAnimation(scaleDown);
Intent goToMain = new Intent(this, MainActivity.class);
startActivity(goToMain);
}
Expand All @@ -78,6 +85,8 @@ public void openButtonControl() {
if(isOnRaceMode){
buttonControlIntent.putExtra("RaceMode", "Race Mode is on" );
}
controlPad.startAnimation(scaleUp);
controlPad.startAnimation(scaleDown);
startActivity(buttonControlIntent);
}
/**
Expand All @@ -88,6 +97,8 @@ public void openJoystick() {
if(isOnRaceMode){
joystickIntent.putExtra("RaceMode", "Race Mode is on");
}
joystick.startAnimation(scaleUp);
joystick.startAnimation(scaleDown);
startActivity(joystickIntent);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import static com.quinstedt.islandRush.BrokerConnection.Topics.Race.SET_CAR_SPEED;


import android.annotation.SuppressLint;
import android.content.Intent;
import android.graphics.Color;
import android.os.Bundle;
Expand Down Expand Up @@ -56,7 +55,6 @@ public class ControlPad extends AppCompatActivity {
Button reset;
Chronometer simpleChronometer;

@SuppressLint("ClickableViewAccessibility")
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Expand Down Expand Up @@ -221,7 +219,7 @@ public void afterTextChanged(Editable editable) {
}
});

speedometer = findViewById(R.id.speedometerControlPad);
speedometer = findViewById(R.id.speedometerControlPad);
speedometer.setLabelConverter((progress, maxProgress) -> String.valueOf((int) Math.round(progress)));

/**
Expand All @@ -240,7 +238,6 @@ public void afterTextChanged(Editable editable) {
speedometer.addColoredRange(75, 100, Color.RED);

}

/**
* Sets the car to full speed, depending on if in reverse is active to make sure
* that if we are on reverse the cars can continue in that direction.
Expand Down Expand Up @@ -305,16 +302,16 @@ public void stopCar() {
}

/**
* Sets the car to move forward, if onReverse is on before moving forward
* and car keeps the speed that was before and changes only the direction of the car
* <p>
* sets the direction directionIndirection in the controlPad to show which mode is active.
* <p>
* the same for moveBackward()
* Sets the car to move forward, if onReverse is on before moving forward
* and car keeps the speed that was before and changes only the direction of the car
*
* sets the direction directionIndirection in the controlPad to show which mode is active.
*
* the same for moveBackward()
*/

public void moveForward() {
if (running) {
if(running) {
setUpDirectionIndicator(REVERSE_IS_OFF);
if (onReverse && counter > 0) {
setupSpeedometer(0, 800, CHANGE_DIRECTION_DELAY);
Expand Down Expand Up @@ -371,6 +368,10 @@ public void moveInReverse() {
}
}

/**
* This method updates the car speed depending on if the car is moving in reverse or forward.
* @param counter
*/
public void changeCurrentSpeed(int counter) {
int SPEED = 10;
if (onReverse) {
Expand All @@ -390,7 +391,7 @@ private void goBack() {
}

/**
* One drive method for the movement of the car and one for the speed
* Both this method are forwarding the publish method from brokerConnection, each of them has it own topic to publish
* See BrokerConnection.
*
* @param message - the message that we send to the broker
Expand All @@ -407,7 +408,10 @@ public void sendMqttSpeedMessage(String message, String actionDescription) {
brokerConnection.mqttClient.publish(SET_CAR_SPEED, message, QOS, null);
}


/**
* Method that makes sure that the speed is printed and sends the MQTT message.
* @param description
*/
public void sendCarSpeed(String description) {

String velocityText = "Velocity: " + currentSpeed;
Expand Down Expand Up @@ -435,6 +439,9 @@ public void setUpDirectionIndicator(String direction) {
}
}

/**
* makes sure that the value in the speedometer is always a positive value.
*/
public void setupSpeedometer(int speed, int duration, int delay) {
if (speed == 0) {
// must be a number close to zero, because the speedometer doest allow the value 0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@
public class CreditsActivity extends AppCompatActivity {

private TextView txt;

Animation scaleUp,scaleDown;
ImageButton escapeHash;
private final String authors = "Credits: \n\n Safa Youssef \n\n Sergey Balan \n\n Andreea Lavinia Fulger \n\n Nicole Andrea Quinstedt \n\n Faisal Sayed \n\n Danesh Mohammadi \n\n";

@Override
Expand All @@ -23,19 +24,22 @@ protected void onCreate(Bundle savedInstanceState) {
setContentView(R.layout.activity_credits);
Animation animation= AnimationUtils.loadAnimation(getApplicationContext(),R.anim.credits);


scaleUp= AnimationUtils.loadAnimation(this, R.anim.scale_up);
scaleDown= AnimationUtils.loadAnimation(this, R.anim.scale_down);

txt =(TextView) findViewById(R.id.txtView);
txt.setText(authors);

txt.startAnimation(animation);

ImageButton escapeHash = findViewById(R.id.credits_escapeHash);
escapeHash = findViewById(R.id.credits_escapeHash);
escapeHash.setOnClickListener(view -> goBack());

}

private void goBack() {
escapeHash.startAnimation(scaleUp);
escapeHash.startAnimation(scaleDown);
Intent goToMain = new Intent(this, MainActivity.class);
startActivity(goToMain);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
public class Joystick extends AppCompatActivity {

private int counter = 0;
private MqttClient mMqttClient;
private BrokerConnection brokerConnection;
private SpeedometerView speedometer;
private final int DURATION = 2000;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,24 @@
import android.content.Intent;
import android.graphics.drawable.AnimationDrawable;
import android.os.Bundle;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
import android.view.inputmethod.EditorInfo;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;

import com.quinstedt.islandRush.GlobalData;
import com.quinstedt.islandRush.R;
import com.quinstedt.islandRush.SplashScreens.LeaderboardAnimation;
import com.quinstedt.islandRush.Utils;
import com.quinstedt.islandRush.instructionClasses.GettingStarted;

public class MainActivity extends AppCompatActivity {
private EditText editText;
private Button openCredits;

String playerNameInput;
Animation scaleUp,scaleDown;
Button enterRace,leaderboard,howToPlayBtn,openCredits;

@Override
protected void onCreate(Bundle savedInstanceState) {
Expand All @@ -34,9 +38,11 @@ protected void onCreate(Bundle savedInstanceState) {
animationBackground.setExitFadeDuration(5000);
animationBackground.start();

scaleUp= AnimationUtils.loadAnimation(this, R.anim.scale_up);
scaleDown= AnimationUtils.loadAnimation(this, R.anim.scale_down);

// On Click goes to Controller choice
Button enterRace = findViewById(R.id.button_enterRace);
enterRace = findViewById(R.id.button_enterRace);
enterRace.setOnClickListener(view -> openControlChoice());


Expand Down Expand Up @@ -64,13 +70,30 @@ protected void onCreate(Bundle savedInstanceState) {
*/


Button leaderboard = findViewById(R.id.button_Leaderboard);
leaderboard = findViewById(R.id.button_Leaderboard);
leaderboard.setOnClickListener(view -> openLeaderboard());

howToPlayBtn = findViewById(R.id.howToPlayBtn);
howToPlayBtn.setOnClickListener(view -> openTutorial());
}

/**
* Opens Instruction screen when the EnterRace button has been pressed
*/
private void openTutorial() {
Intent tutorialIntent = new Intent(this, GettingStarted.class);
howToPlayBtn.startAnimation(scaleUp);
howToPlayBtn.startAnimation(scaleDown);
startActivity(tutorialIntent);
}

/**
* Opens Scoreboard when the Leaderboard button has been pressed
*/
public void openLeaderboard() {
Intent leadIntent = new Intent(this, Scoreboard.class);
leaderboard.startAnimation(scaleUp);
leaderboard.startAnimation(scaleDown);
startActivity(leadIntent);
}

Expand All @@ -80,10 +103,14 @@ public void openLeaderboard() {

public void openCredits() {
Intent leadIntent = new Intent(this, CreditsActivity.class);
openCredits.startAnimation(scaleUp);
openCredits.startAnimation(scaleDown);
startActivity(leadIntent);
}

public void openControlChoice() {
enterRace.startAnimation(scaleUp);
enterRace.startAnimation(scaleDown);
if(playerNameInput.isEmpty()){
String happyEmoji = Utils.getEmoji(Utils.HAPPY);
String toastMessage = "Enter a name " +happyEmoji;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

import android.content.Intent;
import android.os.Bundle;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
import android.widget.ImageButton;

import androidx.appcompat.app.AppCompatActivity;
Expand All @@ -24,6 +26,7 @@ public class Scoreboard extends AppCompatActivity {
private RecyclerView RV;
private ViewModal viewmodal;
private ImageButton resetBtn,backToHome;
Animation scaleUp,scaleDown;



Expand All @@ -43,6 +46,10 @@ protected void onCreate(Bundle savedInstanceState) {
RV.setLayoutManager(new LinearLayoutManager(this));
RV.setHasFixedSize(true);

scaleUp= AnimationUtils.loadAnimation(this, R.anim.scale_up);
scaleDown= AnimationUtils.loadAnimation(this, R.anim.scale_down);


// initializing adapter for recycler view.
final PlayerScoreRVAdapter adapter = new PlayerScoreRVAdapter();

Expand All @@ -66,11 +73,14 @@ public void onChanged(List<PlayerScore> playerScores) {

private void goToHome() {
Intent goToMainIntent=new Intent(this, MainActivity.class);
backToHome.startAnimation(scaleUp);
backToHome.startAnimation(scaleDown);
startActivity(goToMainIntent);
}

private void deleteLeaderboard() {
resetBtn.startAnimation(scaleUp);
resetBtn.startAnimation(scaleDown);
viewmodal.deleteAllScores();

}
}
Loading