This commit is contained in:
pro.boooooo 2023-04-01 22:16:26 +02:00
parent eb826b077a
commit 5e948c9041
23 changed files with 291 additions and 48 deletions

View File

@ -26,14 +26,12 @@ android {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
buildToolsVersion '33.0.0'
}
dependencies {
implementation 'androidx.appcompat:appcompat:1.6.1'
implementation 'com.google.android.material:material:1.8.0'
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.5'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1'

View File

@ -6,25 +6,29 @@
android:allowBackup="true"
android:dataExtractionRules="@xml/data_extraction_rules"
android:fullBackupContent="@xml/backup_rules"
android:icon="@mipmap/ic_launcher"
android:icon="@drawable/logo"
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@style/Theme.JMastermind"
tools:targetApi="31">
<activity
android:name=".MainActivity"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<activity
android:name=".Prologue"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".Game.SoloGame"
android:exported="true">
</activity>
<activity
android:name=".Game.SoloGame"
android:exported="true">
</activity>
<activity
android:name=".Menu.Menu"
android:exported="true">
</activity>
</application>
</manifest>

View File

@ -92,7 +92,7 @@ public class ColorSelectorEvent extends View implements View.OnClickListener {
Popup popup = new Popup(this.context, opts, (10 - this.tentative));
popup.show();
} else if(this.tentative == 0) {
Popup popup = new Popup(this.context, opts);
Popup popup = new Popup(this.context, opts, -1);
popup.show();
}

View File

@ -1,25 +1,31 @@
package com.example.jmastermind.Events;
import android.content.Intent;
import android.media.MediaPlayer;
import android.view.View;
import androidx.appcompat.app.AppCompatActivity;
public class MenuEvent implements View.OnClickListener {
private Class option;
private AppCompatActivity ac;
private MediaPlayer mp;
/**
* Event lié au menu de depart
* @param ac Le contexte
* @param option La class de l'activité a demarrer
* @param mp Couper le son d'une activite
* */
public MenuEvent(AppCompatActivity ac, Class option) {
public MenuEvent(AppCompatActivity ac, Class option, MediaPlayer mp) {
this.ac = ac;
this.option = option;
this.mp = mp;
}
@Override
public void onClick(View view) {
this.mp.stop();
Intent i = new Intent(this.ac, this.option);
this.ac.startActivity(i);
}

View File

@ -2,18 +2,20 @@ package com.example.jmastermind.Events;
import android.content.DialogInterface;
import android.content.Intent;
import android.media.MediaPlayer;
import android.view.View;
import android.widget.Button;
import android.widget.PopupMenu;
import androidx.appcompat.app.AppCompatActivity;
import com.example.jmastermind.Game.Popup;
import com.example.jmastermind.Game.SoloGame;
import com.example.jmastermind.MainActivity;
import com.example.jmastermind.Menu.Menu;
import com.example.jmastermind.Prologue;
import com.example.jmastermind.R;
public class PopupEvent implements DialogInterface.OnClickListener, View.OnClickListener {
private MediaPlayer mp;
private int tentative;
private AppCompatActivity context;
@ -22,15 +24,17 @@ public class PopupEvent implements DialogInterface.OnClickListener, View.OnClick
* @param context Le context
* @param tentative Le nombre de tentative
* */
public PopupEvent(AppCompatActivity context, int tentative) {
public PopupEvent(AppCompatActivity context, int tentative, MediaPlayer mp) {
this.context = context;
this.tentative = tentative;
this.mp = mp;
}
@Override
public void onClick(DialogInterface dialogInterface, int i) {
switch(i) {
case 0: {
this.mp.stop();
Intent a = new Intent(this.context, SoloGame.class);
this.context.startActivity(a);
break;
@ -46,7 +50,8 @@ public class PopupEvent implements DialogInterface.OnClickListener, View.OnClick
}
case 2: {
Intent c = new Intent(this.context, MainActivity.class);
this.mp.stop();
Intent c = new Intent(this.context, Menu.class);
this.context.startActivity(c);
break;
}

View File

@ -0,0 +1,35 @@
package com.example.jmastermind.Events;
import android.content.Intent;
import android.media.MediaPlayer;
import android.view.animation.Animation;
import androidx.appcompat.app.AppCompatActivity;
import com.example.jmastermind.Menu.Menu;
import com.example.jmastermind.R;
public class PrologueAnimation implements Animation.AnimationListener {
private AppCompatActivity context;
private MediaPlayer mp;
public PrologueAnimation(AppCompatActivity context) {
this.context = context;
}
@Override
public void onAnimationStart(Animation animation) {
}
@Override
public void onAnimationEnd(Animation animation) {
Intent i = new Intent(this.context, Menu.class);
this.context.startActivity(i);
this.mp.stop();
}
@Override
public void onAnimationRepeat(Animation animation) {
}
}

View File

@ -1,5 +1,6 @@
package com.example.jmastermind.Game;
import android.media.MediaPlayer;
import android.widget.Button;
import androidx.appcompat.app.AlertDialog;
@ -8,6 +9,7 @@ import com.example.jmastermind.Events.PopupEvent;
import com.example.jmastermind.R;
public class Popup extends AlertDialog.Builder {
private MediaPlayer mp;
private AppCompatActivity context;
/**
@ -20,12 +22,20 @@ public class Popup extends AlertDialog.Builder {
super(context);
this.context = context;
if(tentative.length > 0) {
if(tentative[0] > 0) {
this.mp = MediaPlayer.create(this.context, R.raw.winningsong);
this.mp.setLooping(true);
this.mp.start();
this.setTitle("Félicitation ! Vous avez gagner en : " + tentative[0] + " coup(s).");
} else {
this.mp = MediaPlayer.create(this.context, R.raw.loosegamesong);
this.mp.setLooping(true);
this.mp.start();
this.setTitle("Perdu !");
}
this.setItems(options, new PopupEvent(this.context, tentative[0]));
this.setItems(options, new PopupEvent(this.context, tentative[0], this.mp));
}
}

View File

@ -47,9 +47,10 @@ public class Circle extends View {
canvas.drawCircle(centerX, centerY, radius-2, this.picasso);
this.picasso.setColor(Color.GRAY);
int corail = Color.rgb(255, 127, 80);
this.picasso.setColor(corail);
this.picasso.setStyle(Paint.Style.STROKE);
this.picasso.setStrokeWidth(5f);
this.picasso.setStrokeWidth(2f);
canvas.drawCircle(centerX, centerY, radius-3, this.picasso);
}

View File

@ -0,0 +1,36 @@
package com.example.jmastermind.Menu;
import android.media.MediaPlayer;
import android.os.Bundle;
import android.widget.Button;
import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;
import com.example.jmastermind.Events.MenuEvent;
import com.example.jmastermind.Game.MultiGame;
import com.example.jmastermind.Game.SoloGame;
import com.example.jmastermind.R;
public class Menu extends AppCompatActivity {
private MediaPlayer mp;
/**
* Le jeu mode SOLO
* */
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.menu);
this.mp = MediaPlayer.create(this, R.raw.menusong);
this.mp.setLooping(true);
this.mp.start();
Button btnSoloGame = (Button) findViewById(R.id.robotselect);
btnSoloGame.setOnClickListener(new MenuEvent(this, SoloGame.class, this.mp));
Button btnMultiGame = (Button) findViewById(R.id.jcjselect);
btnMultiGame.setOnClickListener(new MenuEvent(this, MultiGame.class, this.mp));
}
}

View File

@ -0,0 +1,62 @@
package com.example.jmastermind;
import androidx.appcompat.app.AppCompatActivity;
import android.media.MediaPlayer;
import android.os.Bundle;
import android.view.animation.Animation;
import android.view.animation.AnimationSet;
import android.view.animation.LinearInterpolator;
import android.view.animation.TranslateAnimation;
import android.widget.LinearLayout;
import android.widget.TextView;
import com.example.jmastermind.Events.MenuEvent;
import com.example.jmastermind.Events.PrologueAnimation;
import com.example.jmastermind.Menu.Menu;
public class Prologue extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.prologue);
MediaPlayer mp = MediaPlayer.create(this, R.raw.prologuesong);
mp.setLooping(true);
mp.start();
LinearLayout prologue = (LinearLayout) findViewById(R.id.prologue);
prologue.setOnClickListener(new MenuEvent(this, Menu.class, mp));
TextView tx = (TextView) findViewById(R.id.prologuetext);
AnimationSet animationSet = new AnimationSet(true);
animationSet.setInterpolator(new LinearInterpolator());
TranslateAnimation animationUp = new TranslateAnimation(
Animation.RELATIVE_TO_SELF, 0f,
Animation.RELATIVE_TO_SELF, 0f,
Animation.RELATIVE_TO_SELF, 0f,
Animation.RELATIVE_TO_SELF, -1f
);
animationUp.setDuration(20000);
animationUp.setFillAfter(true);
animationSet.addAnimation(animationUp);
TranslateAnimation animationDown = new TranslateAnimation(
Animation.RELATIVE_TO_SELF, 0f,
Animation.RELATIVE_TO_SELF, 0f,
Animation.RELATIVE_TO_SELF, 1f,
Animation.RELATIVE_TO_SELF, 0f
);
animationDown.setDuration(20000);
animationDown.setFillAfter(true);
animationSet.addAnimation(animationDown);
PrologueAnimation pa = new PrologueAnimation(this);
animationSet.setAnimationListener(pa);
tx.startAnimation(animationSet);
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 55 KiB

Binary file not shown.

Binary file not shown.

View File

@ -6,8 +6,8 @@
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal"
tools:context=".MainActivity"
android:background="@drawable/space"
tools:context=".Prologue"
android:background="@drawable/game"
>
<LinearLayout

View File

@ -4,7 +4,7 @@
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity"
tools:context=".Prologue"
android:screenOrientation="portrait"
android:background="@drawable/space"
android:gravity="center"

File diff suppressed because one or more lines are too long

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -1,8 +1,8 @@
<resources xmlns:tools="http://schemas.android.com/tools">
<!-- Base application theme. -->
<style name="Theme.JMastermind" parent="Theme.MaterialComponents.DayNight.DarkActionBar">
<style name="Theme.JMastermind" parent="Theme.AppCompat.Light.NoActionBar">
<!-- Primary brand color. -->
<item name="colorPrimary">@color/purple_200</item>
<item name="colorPrimary">@color/black</item>
<item name="colorPrimaryVariant">@color/purple_700</item>
<item name="colorOnPrimary">@color/black</item>
<!-- Secondary brand color. -->

View File

@ -1,8 +1,8 @@
<resources xmlns:tools="http://schemas.android.com/tools">
<!-- Base application theme. -->
<style name="Theme.JMastermind" parent="Theme.MaterialComponents.DayNight.DarkActionBar">
<style name="Theme.JMastermind" parent="Theme.AppCompat.Light.NoActionBar">
<!-- Primary brand color. -->
<item name="colorPrimary">@color/purple_500</item>
<item name="colorPrimary">@color/black</item>
<item name="colorPrimaryVariant">@color/purple_700</item>
<item name="colorOnPrimary">@color/white</item>
<!-- Secondary brand color. -->