Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
JessCai06 authored Nov 30, 2022
1 parent 71f0031 commit cde8d91
Show file tree
Hide file tree
Showing 2 changed files with 72 additions and 50 deletions.
52 changes: 47 additions & 5 deletions AzulPanel.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,13 @@ public class AzulPanel extends JPanel{
static Boolean firstTake = AzulWindow.firstTake;
static Boolean endgame = AzulWindow.endgame;
static Boolean roundscore = AzulWindow.roundscore;
String output;

//animations
private static AzulPanel azulPanel;
private ArrayList<AnimatableObject> animatableObjectList;


public AzulPanel(){

animatableObjectList = new ArrayList<>();
Expand Down Expand Up @@ -61,7 +63,7 @@ public void paint(Graphics g) {
//2. CURRENT PLAYER TAG - FINAL
g.setFont(new Font("Algerian", Font.PLAIN, 45));
int id = allPlayer[0].ID;
g.drawString("Player "+ id + " "+allPlayer[0].score, 1500,985);
g.drawString("Player "+ id , 1500,985);

//3. FACTORY FLOOR NUMBER INDECATORS - FINAL
int xinc = 85+10;
Expand Down Expand Up @@ -92,14 +94,53 @@ else if (b==2)
}
}
}
//4.5 CURRENT PLAYER SCORES
if (allPlayer[0].score == 0)
g.fillRect(685-10, 350-10, 30, 30);
else {
for (int c = 1; c<= 20; c++) {
for (int r = 1; r<=5; r++) {
if (allPlayer[0].score == (r-1)*20+c)
g.fillRect(673+(c-1)*2+(c-1)*30, 378+8*(r-1)+(r-1)*30, 26, 26);
}
}
}

//5. BUFFER ZONE BIG TILE + NUMBER INDECATOR - FINAL
if (!allPlayer[0].BufferZone.isEmpty()) {
g.setFont(new Font("Algerian", Font.PLAIN, 60));
g.drawImage(tileimage[allPlayer[0].BufferZone.get(0)], 1460,662,150,150,null);
g.drawString("x" + allPlayer[0].BufferZone.size(),1460+150+40,662+150/2+20);
g.drawImage(tileimage[allPlayer[0].BufferZone.get(0)], 1480,650,120,120,null);
g.drawString("x" + allPlayer[0].BufferZone.size(),1460+150+40,650+120/2+20);
g.setFont(new Font("Algerian", Font.PLAIN, 45));
}
if (output!=null) {
g.setFont(new Font("Algerian", Font.PLAIN, 25));
//g.drawString(output + output.length(),1420,650+200);
if(output.equals("2")) {
g.drawString("Selection:",1420,650+200-10);
g.setFont(new Font("Dialog", Font.PLAIN, 15));
g.drawString("any colored tiles",1420,650+200+20-10);
}
else if(output.equals("1")) {
g.drawString("Placement:",1420,650+200-10);
g.setFont(new Font("Dialog", Font.PLAIN, 15));
g.drawString("the arrows near the pattern lines or the area in the floor line",1420,650+200+20-10);
}
else if(output.equals("3")) {
g.drawString("Scoring:",1420,650+200-10);
g.setFont(new Font("Dialog", Font.PLAIN, 15));
g.drawString("Player Directions?",1420,650+200+20-10);
}

g.setFont(new Font("Algerian", Font.PLAIN, 45));
}
g.setColor(Color.GRAY);
g.setFont(new Font("Algerian", Font.PLAIN, 20));
//g.drawString("Copyright 2022",1375,565+10);
g.setFont(new Font("Dialog", Font.PLAIN, 15));
//g.drawString("Jess Luc Omar Josh",1375+220,565+10);
g.setFont(new Font("Algerian", Font.PLAIN, 45));
g.setColor(Color.BLACK);
//5.5 FINAL GAME VICTORS AND SCORE COMPARISON
if (endgame) {
g.setFont(new Font("Algerian", Font.ITALIC, 45));
Expand Down Expand Up @@ -228,14 +269,15 @@ public static void drawRotate(Graphics g, double x, double y, int angle, String
g2d.rotate(-Math.toRadians(angle));
g2d.translate(-(float)x,-(float)y);
}
public void updateAll(Factory[] af, FactoryFloor f, ArrayList<Integer> b, Player [] a,Boolean s, Boolean e, Boolean start) {
public void updateAll(Factory[] af, FactoryFloor f, ArrayList<Integer> b, Player [] a,Boolean s, Boolean e, Boolean start, String out) {
allFactory = af;
factoryFloor = f;
bag = b;
allPlayer = a;
roundscore = s;
endgame = e;
strt = start;
output = out;
}

}
}
70 changes: 25 additions & 45 deletions AzulWindow.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ public class AzulWindow extends JFrame implements ItemListener, ActionListener{
static Boolean firstTake, endgame, roundscore;
static ArrayList <Player> victors;
static PlainButton startB;
static String output;


//players
Expand Down Expand Up @@ -150,8 +151,9 @@ public class AzulWindow extends JFrame implements ItemListener, ActionListener{

@Override
public void actionPerformed(ActionEvent e) {
output = "2";
strt = false;
panel.updateAll(allFactory,factoryFloor,bag, allPlayer, roundscore,endgame,strt);
panel.updateAll(allFactory,factoryFloor,bag, allPlayer, roundscore,endgame,strt, output);
c.validate();
c.repaint();

Expand Down Expand Up @@ -202,7 +204,10 @@ public void setFactoryTileFunction(PlainButton temp) {
temp.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {


output = "1";
System.out.println(output);
panel.updateAll(allFactory,factoryFloor,bag, allPlayer, roundscore,endgame,strt, output);
//REPAINT EVERYTHING
c.validate();
c.repaint();
Expand All @@ -219,15 +224,10 @@ public void actionPerformed(ActionEvent e) {
//BUTTON FUNCTION
ArrayList <Integer>list = allFactory[temp.factoryID].takeAll();
color = list.get(temp.ID);
/*System.out.println(list);
System.out.println(color);*/
while(list.contains(color))
allPlayer[0].addBufferZone(list.remove(list.indexOf(color)));
//System.out.println(list + "---"+allPlayer[0].BufferZone);
factoryFloor.add(list);
/*for (int i: factoryFloor.colors)
System.out.print(i+" ");*/


// ANIMATE LUC
//from:
int x = temp.getBounds().x;
Expand All @@ -238,21 +238,11 @@ public void actionPerformed(ActionEvent e) {

//to: 1460,662
//final size: 150
/*AnimatableObject ani = new AnimatableObject(tileimage[0],0 , 0, tilesize, tilesize, null);
try {
Thread.sleep(1000);
Animate.animate(ani, 1460,662,150,150, 2000, 120);
} catch (InterruptedException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}*/
/*s = new Screen(tileimage[color],x,y,1460,662,60,150);
s.setBounds(0,0,width, height);
c.add(s);
s = null;*/


//DISABLE ALL OF FACTORY AND ENABLE ALL OF CURRENT PLAYER PATTERNLINE & FLOOR

for (Factory f: allFactory)
Expand All @@ -275,7 +265,8 @@ public void setFactFloorFunction(PlainButton temp) {
@Override
public void actionPerformed(ActionEvent e) {
System.out.println("OFFER: Factory Floor Tile clicked " + temp.ID +" ");

output = "1";
panel.updateAll(allFactory,factoryFloor,bag, allPlayer, roundscore,endgame,strt, output);
//REPAINT EVERYTHING
c.validate();
c.repaint();
Expand Down Expand Up @@ -309,16 +300,6 @@ public void actionPerformed(ActionEvent e) {
//color of tile: color
//to: 1460,662
//final size: 150
/*AnimatableObject ani = new AnimatableObject(tileimage[0],0 , 0, tilesize, tilesize, null);
try {
Thread.sleep(1000);
Animate.animate(ani, 1460,662,150,150, 2000, 120);
} catch (InterruptedException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}*/


// NEXT ACTION
//DISABLE ALL OF FACTORY AND ENABLE ALL OF CURRENT PLAYER PATTERNLINE & FLOOR
Expand All @@ -333,8 +314,6 @@ public void actionPerformed(ActionEvent e) {
c.validate();
c.repaint();
c.add(panel);
//allPlayer[0]
//c.removeAll();
}});
}

Expand All @@ -344,6 +323,7 @@ public void setPlayerPatternFunction(PlainButton temp) {
@Override
public void actionPerformed(ActionEvent e) {
System.out.println("PLACEMENT: Placement Clicked " + temp.ID +" " +temp.factoryID + "");
output = "2";

//REPAINT EVERYTHING
c.validate();
Expand Down Expand Up @@ -386,15 +366,7 @@ public void actionPerformed(ActionEvent e) {
//to:
int x = temp.getBounds().x;
int y = temp.getBounds().y;
/*AnimatableObject ani = new AnimatableObject(tileimage[0],0 , 0, tilesize, tilesize, null);
try {
Thread.sleep(1000);
Animate.animate(ani, 1460,662,150,150, 2000, 120);
} catch (InterruptedException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
/*
for (ArrayList<Integer> d: allPlayer[0].wall) {
for (int n: d)
System.out.print(n+" ");
Expand Down Expand Up @@ -433,9 +405,15 @@ public void actionPerformed(ActionEvent e) {
p.wall.set(i,arr);
p.scoreWall.get(i).set(col, score);
}

try {
Thread.sleep(2000);
} catch (InterruptedException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
c.validate();
c.repaint();

}
int i = 0;
while(i <7 && p.floorLine[i]!=-1 ) {
Expand Down Expand Up @@ -574,7 +552,9 @@ public void setPlayerFloorFunction(PlainButton temp) {
@Override
public void actionPerformed(ActionEvent e) {
System.out.println("PLACEMENT: player floor Clicked " + temp.ID +" " +temp.factoryID + "");
//REPAINT EVERYTHING
output = "2";

//REPAINT EVERYTHING
c.validate();
c.repaint();
c.add(panel);
Expand Down Expand Up @@ -726,7 +706,7 @@ public void rotateTurn() {
}
allPlayer = temp;
System.out.println("---------------------------------player:" + allPlayer[0].ID);
panel.updateAll(allFactory,factoryFloor,bag, allPlayer, roundscore,endgame,strt);
panel.updateAll(allFactory,factoryFloor,bag, allPlayer, roundscore,endgame,strt, output);
c.validate();
c.repaint();
c.add(panel);
Expand All @@ -745,7 +725,7 @@ public void rotateRound(int first) {
temp[j] = allPlayer[(index+j)%4];
}
allPlayer = temp;
panel.updateAll(allFactory,factoryFloor,bag, allPlayer, roundscore,endgame,strt);
panel.updateAll(allFactory,factoryFloor,bag, allPlayer, roundscore,endgame,strt, output);
c.validate();
c.repaint();
c.add(panel);
Expand Down Expand Up @@ -775,4 +755,4 @@ public void itemStateChanged(ItemEvent e) {
}


}
}

0 comments on commit cde8d91

Please sign in to comment.