Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int Dice1;
- int Dice2;
- int Dice3;
- IntList DiceList;
- int DiceSize = 160; // Valeur de la taille des dés (Max: 200)
- int PointSize = 20; // Valeur de la taille des points
- int ScoreJ1 = 0;
- int ScoreJ2 = 0;
- boolean SelectorD1 = true;
- boolean SelectorD2 = true;
- boolean SelectorD3 = true;
- boolean PlayAgain = true;
- //String NameJ1 = "";
- //String NameJ2 = "";
- void setup() {
- size(800, 400);
- surface.setTitle("Jeu du 421 - Grimaud Industry");
- background(0, 153, 0);
- //noLoop();
- DiceList = new IntList();
- }
- void draw() {
- //InputPlayer();
- if (PlayAgain == true){
- DisplayDice();
- Randomizer();
- DisplayNumber();
- }
- DispStopButton();
- ButtonDetector();
- DiagnosticVoid();
- }
- void DiagnosticVoid() {
- println(DiceList); // Valeur des dés Sorted
- //println(NameJ1);
- String LenghtStr = "Relancer"; // Longueur en pixel d'un String
- println(textWidth(LenghtStr));
- }
- /*void InputPlayer() {
- String TJ1 = input("Entrer le nombre du joueur 1:");
- String TJ2 = input("Entrer le nombre du joueur 1:");
- int RandomStartOrder = int(random(0,1));
- if (RandomStartOrder == 0) {
- NameJ1 = TJ1;
- NameJ2 = TJ2;
- }
- else {
- NameJ1 = TJ2;
- NameJ2 = TJ1;
- }
- }*/
- void DisplayDice() {
- generateDice(200, 200, DiceSize);
- generateDice(400, 200, DiceSize);
- generateDice(600, 200, DiceSize);
- }
- void generateDice(int XLocation, int YLocation, int SquareSize) {
- rectMode(CENTER);
- fill(255);
- rect(XLocation, YLocation, SquareSize, SquareSize, 7);
- }
- void Randomizer() {
- if (SelectorD1 == true) {
- Dice1 = int(random(1, 6));
- SelectorD1 = false;
- }
- if (SelectorD2 == true) {
- Dice2 = int(random(1, 6));
- SelectorD2 = false;
- }
- if (SelectorD3 == true) {
- Dice3 = int(random(1, 6));
- SelectorD3 = false;
- }
- DiceList.clear();
- DiceList.append(Dice1);
- DiceList.append(Dice2);
- DiceList.append(Dice3);
- DiceList.sort();
- PlayAgain = false;
- }
- void DisplayNumber() {
- dispFace(200, 200, DiceSize, Dice1);
- dispFace(400, 200, DiceSize, Dice2);
- dispFace(600, 200, DiceSize, Dice3);
- }
- void dispFace(int XLocation, int YLocation, int DiceSize, int DiceValue) {
- switch(DiceValue) {
- case 1:
- Disp1(XLocation, YLocation);
- break;
- case 2:
- Disp2(XLocation, YLocation);
- break;
- case 3:
- Disp1(XLocation, YLocation);
- Disp2(XLocation, YLocation);
- break;
- case 4:
- Disp2(XLocation, YLocation);
- Disp4(XLocation, YLocation);
- break;
- case 5:
- Disp1(XLocation, YLocation);
- Disp2(XLocation, YLocation);
- Disp4(XLocation, YLocation);
- break;
- case 6:
- Disp2(XLocation, YLocation);
- Disp4(XLocation, YLocation);
- Disp6(XLocation, YLocation);
- break;
- }
- }
- void Disp1(int XLocation, int YLocation) {
- fill(0);
- ellipse(XLocation, YLocation, PointSize, PointSize);
- }
- void Disp2(int XLocation, int YLocation) {
- fill(0);
- ellipse(XLocation+int(0.25*DiceSize), YLocation-int(0.25*DiceSize),PointSize, PointSize);
- fill(0);
- ellipse(XLocation-int(0.25*DiceSize), YLocation+int(0.25*DiceSize), PointSize, PointSize);
- }
- void Disp4(int XLocation, int YLocation) {
- fill(0);
- ellipse(XLocation+int(0.25*DiceSize), YLocation+int(0.25*DiceSize), PointSize, PointSize);
- fill(0);
- ellipse(XLocation-int(0.25*DiceSize), YLocation-int(0.25*DiceSize), PointSize, PointSize);
- }
- void Disp6(int XLocation, int YLocation) {
- fill(0);
- ellipse(XLocation+int(0.25*DiceSize), YLocation, PointSize, PointSize);
- fill(0);
- ellipse(XLocation-int(0.25*DiceSize), YLocation, PointSize, PointSize);
- }
- void DispStopButton() {
- if (SelectorD1 == false) {
- StopButtonDrawer(200, int(200+(DiceSize/2)+25), DiceSize, 20, 64);
- }
- else {
- StopButtonDrawer(200, int(200+(DiceSize/2)+25), DiceSize, 20, 255);
- }
- if (SelectorD2 == false) {
- StopButtonDrawer(400, int(200+(DiceSize/2)+25), DiceSize, 20, 64);
- }
- else {
- StopButtonDrawer(400, int(200+(DiceSize/2)+25), DiceSize, 20, 255);
- }
- if (SelectorD3 == false) {
- StopButtonDrawer(600, int(200+(DiceSize/2)+25), DiceSize, 20, 64);
- }
- else {
- StopButtonDrawer(600, int(200+(DiceSize/2)+25), DiceSize, 20, 255);
- }
- rectMode(CENTER);
- fill(255);
- rect(400, int((200+(DiceSize/2)+25)+35), int(400+(DiceSize)), 20, 3);
- }
- void StopButtonDrawer(int XLocation, int YLocation, int SquareSize, int HighSize, int DiceSelected) {
- rectMode(CENTER);
- fill(DiceSelected,0,0);
- rect(XLocation, YLocation, SquareSize, HighSize, 1);
- }
- void ButtonDetector() {
- if (mousePressed) {
- if (int(200-int(DiceSize/2)) < mouseX && mouseX < int(200+int(DiceSize/2)) && int(200+(DiceSize/2)+15) < mouseY && mouseY < int(200+(DiceSize/2)+35)) {
- delay(125);
- if (SelectorD1 == false) {
- SelectorD1 = true;
- }
- else {
- SelectorD1 = false;
- }
- }
- if (int(400-int(DiceSize/2)) < mouseX && mouseX < int(400+int(DiceSize/2)) && int(200+(DiceSize/2)+15) < mouseY && mouseY < int(200+(DiceSize/2)+35)) {
- delay(125);
- if (SelectorD2 == false) {
- SelectorD2 = true;
- }
- else {
- SelectorD2 = false;
- }
- }
- if (int(600-int(DiceSize/2)) < mouseX && mouseX < int(600+int(DiceSize/2)) && int(200+(DiceSize/2)+15) < mouseY && mouseY < int(200+(DiceSize/2)+35)) {
- delay(125);
- if (SelectorD3 == false) {
- SelectorD3 = true;
- }
- else {
- SelectorD3 = false;
- }
- }
- if ((400-int((400+(DiceSize))/2)) < mouseX && mouseX < (400+int((400+(DiceSize))/2)) && int((200+(DiceSize/2)+25)+25) < mouseY && mouseY < int((200+(DiceSize/2)+25)+45)) {
- delay(125);
- if (PlayAgain == false) {
- PlayAgain = true;
- }
- else {
- PlayAgain = false;
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement