Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -46,3 +46,4 @@ Network Trash Folder
Temporary Items
.apdisk
SimongGame/.idea/vcs.xml
SimongGame/.idea/gradle.xml
2 changes: 1 addition & 1 deletion SimongGame/.idea/gradle.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion SimongGame/.idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import android.os.Bundle;
import android.app.Activity;
import android.view.Window;
import android.view.WindowManager;

import cyril.simonggame.view.Game_View;

Expand All @@ -13,8 +14,12 @@ public class GameActivity extends Activity {
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE); //retire le titre (Toolbar)
setInfullScreen();
game_View = new Game_View(this);
setContentView(game_View);
}

public void setInfullScreen(){
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import android.app.Activity;
import android.os.Bundle;
import android.view.Window;
import android.view.WindowManager;

import cyril.simonggame.view.Menu_view;

Expand All @@ -15,8 +16,13 @@ public class Menu_Activity extends Activity {
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE); //retire le titre (Toolbar)
setInfullScreen();
menu_view = new Menu_view(this);
setContentView(menu_view);
}

public void setInfullScreen(){
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import android.app.Activity;
import android.os.Bundle;
import android.view.Window;
import android.view.WindowManager;

import cyril.simonggame.view.Menu_view;
import cyril.simonggame.view.Setting_View;
Expand All @@ -16,7 +17,13 @@ public class Setting_Activity extends Activity {
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE); //retire le titre (Toolbar)
setInfullScreen();
setting_view = new Setting_View(this);
setContentView(setting_view);
}

public void setInfullScreen(){
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,24 +16,9 @@ public Game_Controller(Game_View view){
this.game_View = view;
this.simonGame = game_View.simonGame;
}

public void onClick(View v) {
Button currentButton = (Button)v;
game_View.doAnimationBounce(currentButton);
System.out.println(simonGame.getgameStarted());
if(simonGame.getgameStarted() && !simonGame.getInAnimation()){

if(currentButton == simonGame.getPattern().get(simonGame.getRound())){

simonGame.setRound(simonGame.getRound()+1);
}else{
simonGame.setGameStarted(false);
System.out.println("GameOver");
}

if(simonGame.getPattern().size() == simonGame.getRound()){
System.out.println("GG");
game_View.startGamePartternAnimation();
}
}
simonGame.userHadClick(currentButton);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,18 @@ public class Menu_Controller implements View.OnClickListener {
public Menu_Controller(Menu_view view){
this.menu_view = view;
}
ActivityOptionsCompat compat = ActivityOptionsCompat.makeSceneTransitionAnimation((Activity) menu_view.getContext(), null);
ActivityOptionsCompat compat ;
@Override
public void onClick(View v) {
switch (v.getId()){
case R.id.btPlay :
compat = ActivityOptionsCompat.makeSceneTransitionAnimation((Activity) menu_view.getContext(), null);
Intent intent = new Intent(menu_view.getContext(), GameActivity.class);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
menu_view.getContext().startActivity(intent,compat.toBundle());
break;
case R.id.btSetting :
compat = ActivityOptionsCompat.makeSceneTransitionAnimation((Activity) menu_view.getContext(), null);
Intent intent2 = new Intent(menu_view.getContext(), Setting_Activity.class);
intent2.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
menu_view.getContext().startActivity(intent2,compat.toBundle());
Expand Down
57 changes: 46 additions & 11 deletions SimongGame/app/src/main/java/cyril/simonggame/model/SimonGame.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,10 @@ public class SimonGame {
private Game_View game_View;
private boolean gameStarted = false;
private boolean inAnimation = false;
private Handler mainHandle;

private Button buttons[];
private boolean canPlay = false;
private int round;
private int currentTurn;
private int score;
private int tour;
private ArrayList<Button> pattern = new ArrayList<Button>();
public SimonGame(Game_View game_View,Button buttons[]){
this.buttons = buttons;
Expand All @@ -36,11 +35,16 @@ public SimonGame(Game_View game_View,Button buttons[]){
public void startGame(){
pattern.clear();
gameStarted = true;
round = 0;
currentTurn = 0;
score = 0;
tour = 0;
game_View.updateScore(0);
game_View.startGamePartternAnimation();
}

public void addColorToPattern(){
setTour(0);
int randnb = random(0,3);
pattern.add(buttons[randnb]);
}
public Integer random(int min, int max){
return min + (int)(Math.random() * ((max - min) + 1));
}
Expand All @@ -52,11 +56,11 @@ public Button getButtonAt(int index){
return buttons[index];
}

public void setRound(int round){
this.round = round;
public void setTour(int tour){
this.tour = tour;
}
public int getRound(){
return round;
public int getTour(){
return tour;
}


Expand All @@ -73,4 +77,35 @@ public boolean getgameStarted(){
public void setGameStarted(boolean gameStarted){
this.gameStarted = gameStarted;
}

public void scoreUp(){
score++;
}
public int getScore(){return score;}

public void userHadClick(Button currentButton){
if(gameStarted && !inAnimation){
game_View.doAnimationBounce(currentButton);
if(currentButton == pattern.get(tour)){
tour++;
}else{
gameOver();
System.out.println("GameOver");
}

if(pattern.size() == tour){
scoreUp();
game_View.updateScore(score);
System.out.println("GG");
inAnimation = true;
game_View.startGamePartternAnimation();
}
}
}
public void gameOver(){
gameStarted = false;
game_View.setTextViewFinalScore(score);
game_View.doGameOverAnimation();

}
}
Loading