Skip to content

Commit

Permalink
Cleaned javadoc
Browse files Browse the repository at this point in the history
  • Loading branch information
LBF38 committed Jan 3, 2023
1 parent e4d0343 commit fad7860
Show file tree
Hide file tree
Showing 6 changed files with 61 additions and 47 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
/**
* Définition des types d'entités disponibles dans le jeu
*
* @author jufch, LBF38, MathieuDFS
* @since 0.1.0
*/
public enum EntityType {
Expand Down
12 changes: 7 additions & 5 deletions duelinvaders/src/main/java/org/enstabretagne/Core/Constant.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
* Cela permet de centraliser les constantes et configurer le jeu dans son
* ensemble.
*
* @author @jufch, @LBF38, @MathieuDFS
* @author jufch, LBF38, MathieuDFS
* @since 0.1.0
*/
public class Constant {
Expand All @@ -30,7 +30,7 @@ public class Constant {
public static final Double LIFE_DISPLAY_WIDTH = 98.0;
public static final Double LIFE_DISPLAY_HEIGHT = 30.0;

public static final Double ALIENS_NUMBER =15.0;
public static final Double ALIENS_NUMBER = 15.0;

public static final Double SPEED_SPACESHIP = 200.0;
public static final Double SPEED_SHOOT = 200.0;
Expand All @@ -52,9 +52,12 @@ public enum Direction {
public enum AlienColor {
RED, GREEN, BLUE, YELLOW, PURPLE, ORANGE
}
public enum Music{
MUSIC_ACROSS_THE_UNIVERSE,MUSIC_BEYOND_CONSCIOUSNESS,MUSIC_DARK_MATTER,MUSIC_DEGREE_OF_FREEDOM,MUSIC_STELLAR_REMEBER

public enum Music {
MUSIC_ACROSS_THE_UNIVERSE, MUSIC_BEYOND_CONSCIOUSNESS, MUSIC_DARK_MATTER, MUSIC_DEGREE_OF_FREEDOM,
MUSIC_STELLAR_REMEBER
}

public static final Random random = new Random();

// Constantes pour les sons d'ambiance
Expand All @@ -66,5 +69,4 @@ public enum Music{
// autres sons)
public static final int NUMBER_OF_EXPLOSIONS = 7;
public static final int NUMBER_OF_LASER_SOUNDS = 4;

}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* Cela permet d'éviter les risques de fautes de frappe et centralise l'ensemble
* des noms de variables du jeu
*
* @author @jufch, @LBF38, @MathieuDFS
* @author jufch, LBF38, MathieuDFS
* @since 0.1.0
*/
public class GameVariableNames {
Expand Down
78 changes: 41 additions & 37 deletions duelinvaders/src/main/java/org/enstabretagne/Game/GameLauncher.java
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
* Classe principale du jeu
* C'est la classe qui lance le jeu et gère les fonctions principales
*
* @author @jufch, @LBF38, @MathieuDFS
* @author jufch, LBF38, MathieuDFS
* @since 0.1.0
*/
public class GameLauncher extends GameApplication {
Expand All @@ -65,6 +65,7 @@ public class GameLauncher extends GameApplication {

/**
* Initialisation des paramètres du jeu
*
* @param settings
*/
@Override
Expand Down Expand Up @@ -96,7 +97,7 @@ protected void initSettings(GameSettings settings) {
"https://universal-soundbank.com/"));
settings.setEnabledMenuItems(EnumSet.of(MenuItem.EXTRA));
settings.setApplicationMode(ApplicationMode.RELEASE);
//todo : ajouter un bouton pour activer le mode infin
// todo : ajouter un bouton pour activer le mode infin
// i
}

Expand All @@ -119,34 +120,34 @@ protected void initInput() {
});

onKey(KeyCode.SPACE, () -> {
if(GameMode == 2) {
if (GameMode == 2) {
playerComponent1.shoot();
}else {
} else {
playerComponent2.shoot();
}
});

onKey(KeyCode.D, () -> {
if(GameMode == 2) {
if (GameMode == 2) {
playerComponent1.moveRight();
}else {
} else {
playerComponent2.moveRight();
}
});

onKey(KeyCode.Q, () -> {
if(GameMode == 2) {
if (GameMode == 2) {
playerComponent1.moveLeft();
}else {
} else {
playerComponent2.moveLeft();
}
});


}

/**
* Initialisation des variables du jeu
*
* @param vars
*/
@Override
Expand All @@ -166,54 +167,54 @@ protected void initGame() {
play(assetNames.sounds.START_CLAIRON);
getGameWorld().addEntityFactory(new SpaceInvadersFactory());

//spawn Player1
// spawn Player1
player1 = spawn(entityNames.PLAYER);
player1.setX(Constant.GAME_WIDTH / 2);
player1.setY(Constant.GAME_HEIGHT - player1.getHeight());
playerComponent1 = player1.getComponent(PlayerComponent.class);
playerComponent1.setDirection(Constant.Direction.UP);

if(GameMode != 2) {
//spawn Player2
if (GameMode != 2) {
// spawn Player2
player2 = spawn(entityNames.PLAYER);
player2.setX(Constant.GAME_WIDTH / 2);
player2.setY(0);
playerComponent2 = player2.getComponent(PlayerComponent.class);
playerComponent2.setDirection(Constant.Direction.DOWN);
}

if(GameMode== 1) {
//spawn Aliens pour infinity mode
if (GameMode == 1) {
// spawn Aliens pour infinity mode

Entity alien1 = spawn(entityNames.ALIEN, 0, Constant.GAME_HEIGHT/2- Constant.ALIEN_HEIGHT);
Entity alien1 = spawn(entityNames.ALIEN, 0, Constant.GAME_HEIGHT / 2 - Constant.ALIEN_HEIGHT);
alien1.getComponent(AlienComponent.class).initialize(Constant.Direction.UP);
Entity alien2 = spawn(entityNames.ALIEN, 0, Constant.GAME_HEIGHT/2- Constant.ALIEN_HEIGHT);
Entity alien2 = spawn(entityNames.ALIEN, 0, Constant.GAME_HEIGHT / 2 - Constant.ALIEN_HEIGHT);
alien2.getComponent(AlienComponent.class).initialize(Constant.Direction.DOWN);
run(() -> {
Entity alien = spawn(entityNames.ALIEN, 0, Constant.GAME_HEIGHT/2- Constant.ALIEN_HEIGHT);
Entity alien = spawn(entityNames.ALIEN, 0, Constant.GAME_HEIGHT / 2 - Constant.ALIEN_HEIGHT);
alien.getComponent(AlienComponent.class).initialize(Constant.Direction.UP);
}, Duration.seconds(1.4));
run(() -> {
Entity alien = spawn(entityNames.ALIEN, 0, Constant.GAME_HEIGHT/2- Constant.ALIEN_HEIGHT);
Entity alien = spawn(entityNames.ALIEN, 0, Constant.GAME_HEIGHT / 2 - Constant.ALIEN_HEIGHT);
alien.getComponent(AlienComponent.class).initialize(Constant.Direction.DOWN);
}, Duration.seconds(1.5));

} else if (GameMode == 0) {
makeAlienBlock();
} else if (GameMode==2){
} else if (GameMode == 2) {
makeAlienBlockSolo();
}

spawn(entityNames.BACKGROUND);
loopBGM(assetNames.music.MUSIC_ACROSS_THE_UNIVERSE); // TODO: sélectionner la musique via les paramètres

//spawn life
life3 = spawn(entityNames.LIFE,3,0);
// spawn life
life3 = spawn(entityNames.LIFE, 3, 0);
life3.getComponent(LifeComponent.class).initialize(Constant.Direction.UP);
life2 = spawn(entityNames.LIFE,2,0);
life2 = spawn(entityNames.LIFE, 2, 0);
life2.getComponent(LifeComponent.class).initialize(Constant.Direction.UP);
life2.getComponent(LifeComponent.class).updateLife(false);
life1 = spawn(entityNames.LIFE,1,0);
life1 = spawn(entityNames.LIFE, 1, 0);
life1.getComponent(LifeComponent.class).initialize(Constant.Direction.UP);
life1.getComponent(LifeComponent.class).updateLife(false);
}
Expand All @@ -225,14 +226,16 @@ private void makeAlienBlock() {
}
}

private void makeAlienLine(int line,Constant.Direction direction) {
private void makeAlienLine(int line, Constant.Direction direction) {
for (int i = 0; i < Constant.ALIENS_NUMBER; i++) {
if(direction == Constant.Direction.DOWN) {
Entity alien = spawn(entityNames.ALIEN, i * Constant.ALIEN_WIDTH, Constant.GAME_HEIGHT/2+(line-1) * Constant.ALIEN_HEIGHT);
if (direction == Constant.Direction.DOWN) {
Entity alien = spawn(entityNames.ALIEN, i * Constant.ALIEN_WIDTH,
Constant.GAME_HEIGHT / 2 + (line - 1) * Constant.ALIEN_HEIGHT);
alien.getComponent(AlienComponent.class).initialize(direction);
alien.getComponent(AlienComponent.class).setAlienNumber(i);
} else {
Entity alien = spawn(entityNames.ALIEN, i * Constant.ALIEN_WIDTH, Constant.GAME_HEIGHT/2 + (line-2) * Constant.ALIEN_HEIGHT);
Entity alien = spawn(entityNames.ALIEN, i * Constant.ALIEN_WIDTH,
Constant.GAME_HEIGHT / 2 + (line - 2) * Constant.ALIEN_HEIGHT);
alien.getComponent(AlienComponent.class).initialize(direction);
alien.getComponent(AlienComponent.class).setAlienNumber(i);
}
Expand All @@ -241,9 +244,9 @@ private void makeAlienLine(int line,Constant.Direction direction) {
}

private void makeAlienBlockSolo() {
for (int line = 0; line <4; line++) {
for (int line = 0; line < 4; line++) {
for (int k = 0; k < Constant.ALIENS_NUMBER; k++) {
Entity alien = spawn(entityNames.ALIEN, k*Constant.ALIEN_WIDTH, (line-1) * Constant.ALIEN_HEIGHT);
Entity alien = spawn(entityNames.ALIEN, k * Constant.ALIEN_WIDTH, (line - 1) * Constant.ALIEN_HEIGHT);
alien.getComponent(AlienComponent.class).initialize(Constant.Direction.DOWN);
alien.getComponent(AlienComponent.class).setAlienNumber(k);
}
Expand All @@ -258,10 +261,10 @@ protected void initPhysics() {
getPhysicsWorld().addCollisionHandler(new AlienPlayerCollision());
getPhysicsWorld().addCollisionHandler(new AlienBulletCollision());
getPhysicsWorld()
.addCollisionHandler(new EnemyShootPlayerCollision(EntityType.ENEMY_SHOOT, EntityType.PLAYER));
getPhysicsWorld().addCollisionHandler(new BulletPlayerCollision(EntityType.BULLET, EntityType.PLAYER));
getPhysicsWorld().addCollisionHandler(new BulletBulletCollision(EntityType.BULLET, EntityType.BULLET));
getPhysicsWorld().addCollisionHandler(new EnemyShootBulletCollision(EntityType.BULLET, EntityType.ENEMY_SHOOT));
.addCollisionHandler(new EnemyShootPlayerCollision());
getPhysicsWorld().addCollisionHandler(new BulletPlayerCollision());
getPhysicsWorld().addCollisionHandler(new BulletBulletCollision());
getPhysicsWorld().addCollisionHandler(new EnemyShootBulletCollision());
}

/**
Expand All @@ -284,6 +287,7 @@ protected void initUI() {

/**
* Vérification de la fin du jeu et déroulé de la partie en cours
*
* @param tpf
*/
@Override
Expand Down Expand Up @@ -311,15 +315,15 @@ protected void onUpdate(double tpf) {

private void Life_Update() {
int life_number = geti(GameVariableNames.PLAYERS_LIVES);
if(life_number==3){
if (life_number == 3) {
life1.getComponent(LifeComponent.class).updateLife(false);
life2.getComponent(LifeComponent.class).updateLife(false);
life3.getComponent(LifeComponent.class).updateLife(true);
}else if(life_number==2) {
} else if (life_number == 2) {
life1.getComponent(LifeComponent.class).updateLife(false);
life2.getComponent(LifeComponent.class).updateLife(true);
life3.getComponent(LifeComponent.class).updateLife(false);
}else if(life_number==1) {
} else if (life_number == 1) {
life1.getComponent(LifeComponent.class).updateLife(true);
life2.getComponent(LifeComponent.class).updateLife(false);
life3.getComponent(LifeComponent.class).updateLife(false);
Expand Down Expand Up @@ -363,7 +367,7 @@ private void winScreen() {
*/
private void ambientSound() {
String ambientMusic = assetNames.sounds.AMBIENT_SOUNDS
.get(FXGLMath.random(0, Constant.NUMBER_OF_AMBIENT_SOUND-1));
.get(FXGLMath.random(0, Constant.NUMBER_OF_AMBIENT_SOUND - 1));
play(ambientMusic);
}

Expand Down
13 changes: 10 additions & 3 deletions duelinvaders/src/main/java/org/enstabretagne/Utils/assetNames.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,13 @@

import org.enstabretagne.Core.Constant;

/**
* Classe contenant les noms des assets du jeu
* Cela permet d'éviter les risques de fautes de frappe et centralise l'ensemble des noms d'assets du jeu
*
* @author LBF38, MathieuDFS, jufch
* @since 0.2.0
*/
public class assetNames {
public static class textures {
public static final String ALIEN = "alien.png";
Expand All @@ -25,7 +32,6 @@ public static class textures {
static {
for (int i = 1; i <= 3; i++) {
LIFES.add("life" + i + ".png");
System.out.print("life" + i + ".png");
}
}
public static final String FIRE = "fire.png";
Expand All @@ -44,20 +50,21 @@ public static class music {
public static class sounds {
public static final String EXPLOSION_ALIEN = "Explosion/mediumExplosion.wav";
public static final String EXPLOSION_PLAYER_DEATH = "Explosion/finalExplosion.wav";
public static final String EXPLOSION_PLAYER_LIFE = "Explosion/strongExplosion.wav";
public static final String START_CLAIRON = "autre/claironStart.wav";
public static final String DEFEAT_CLAIRON = "autre/claironDefeat.wav";
public static final String VICTORY_CLAIRON = "autre/claironVictory.wav";
public static final ArrayList<String> AMBIENT_SOUNDS = new ArrayList<String>();
static {
for (int i = 1; i < Constant.NUMBER_OF_AMBIENT_SOUND +1 ; i++) {
for (int i = 1; i < Constant.NUMBER_OF_AMBIENT_SOUND + 1; i++) {
AMBIENT_SOUNDS.add("ambiance/ambientSound" + i + ".wav");
}
}
public static final String CANNON_SHOT = "Tir/canon.wav";
public static final ArrayList<String> LASER_SOUNDS = new ArrayList<>();
static {
for (int i = 1; i <= Constant.NUMBER_OF_LASER_SOUNDS; i++) {
LASER_SOUNDS.add("tir/laser" + i + ".wav");
LASER_SOUNDS.add("Tir/laser" + i + ".wav");
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* Définition des noms des entités du jeu.
* Cela permet d'éviter les erreurs de frappe.
*
* @author @LBF38, @jufch, @MathieuDFS
* @author LBF38, jufch, MathieuDFS
* @since 0.1.0
*/
public class entityNames {
Expand Down

0 comments on commit fad7860

Please sign in to comment.