1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105
| package com.test;
import java.io.IOException;
import java.util.Scanner;
import javax.swing.JFrame;
import javax.swing.JFrame;
public class main {
public static void main(String[] args) {
// ON CREE LA FENETRE
/*
* JFrame fenetre = new JFrame(); fenetre.setTitle("ESROK GAME");
* fenetre.setSize(800,600); fenetre.setLocationRelativeTo(null);
* fenetre.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
* fenetre.setVisible(true);
*/
// ON CREE LA GRILLE
Grille g1 = new Grille(12, 8);
// ON PLACE LES ELEMENTS
g1.placer(4, 5, 'J');
g1.placer(12, 1, 'O');
g1.placer(1, 1, 'O');
g1.placer(1, 8, 'O');
g1.placer(12, 8, 'O');
g1.placer(3, 5, 'M');
// AFFICHAGE
// Création de perso
System.out.println("Bienvenue..");
System.out.println("Creation du personnage..");
g1.afficher();
System.out.println("______________________________________________");
System.out.println("______________________________________________");
Perso p1 = new Perso();
System.out.println(p1.toString());
// creation du monstre
Monstre m1 = new Monstre();
System.out.println("Quel est ton nom ?");
Scanner sc2 = new Scanner(System.in);
String str = sc2.nextLine();
// Deplacement (+ s'il y a un monstre)
int i = 0;
while (i < 200) {
System.out.println("\nOu veux tu aller " + str + "? 1 = HAUT , 2 = BAS , 3 = GAUCHE , 4 = DROITE");
Scanner sc1 = new Scanner(System.in);
int nb = sc1.nextInt();
switch (nb) {
case 1:
if (g1.deplacerH() == 1)
break;
else {
System.out.println("DEBUT DU COMBAT :");
// if (g1.[i][j] == 'J'){ // On cherche le joueur
while (p1.recupVie() > 0 && m1.recupVie() > 0) {
System.out.println("Caracteristiques du monstre : ||" + "Vos Caracteristiques :");
System.out.println(m1.toString() + "|" + p1.toString());
System.out.println("Vous n'avez qu'un sort,vous attaquez avec Foudre");
System.out.println("Caracteristiques du monstre : ||" + "Vos Caracteristiques :");
m1.definirVie(m1.recupVie() - p1.degatSort1());
System.out.println(m1.toString() + "|" + p1.toString());
if (p1.recupVie() > 0 && m1.recupVie() > 0) {
System.out.println("FIN DU COMBAT !");
if (m1.recupVie() == 0) {
System.out.println("VOUS AVEZ GAGNE !");
System.out.println("Le monstre attaque");
p1.definirVie(m1.recupVie() - m1.attaquer());
}
}
}
}
break;
case 2:
g1.deplacerB();
break;
case 3:
g1.deplacerG();
break;
case 4:
g1.deplacerD();
break;
default:
System.out.println("Mauvais chiffre !");
}
for (int k = 0; k < 85; k++) {
System.out.println();
}
g1.afficher();
i++;
}
}
} |
Partager