added combos
This commit is contained in:
		@@ -17,6 +17,7 @@ public class TetrisGame {
 | 
				
			|||||||
    private int level = 1;
 | 
					    private int level = 1;
 | 
				
			||||||
    private int lines = 0;
 | 
					    private int lines = 0;
 | 
				
			||||||
    private int score = 0;
 | 
					    private int score = 0;
 | 
				
			||||||
 | 
					    private int combo = 0;
 | 
				
			||||||
    private int attackingLines = 0;
 | 
					    private int attackingLines = 0;
 | 
				
			||||||
    public boolean lost = false;
 | 
					    public boolean lost = false;
 | 
				
			||||||
    public boolean paused = true;
 | 
					    public boolean paused = true;
 | 
				
			||||||
@@ -279,7 +280,9 @@ public class TetrisGame {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
        int removedLines = this.playfield.removeFullLines();
 | 
					        int removedLines = this.playfield.removeFullLines();
 | 
				
			||||||
        int combatLines = 0;
 | 
					        int combatLines = 0;
 | 
				
			||||||
 | 
					        this.combo += 1;
 | 
				
			||||||
        switch (removedLines) {
 | 
					        switch (removedLines) {
 | 
				
			||||||
 | 
					            case 0 -> this.combo = 0;
 | 
				
			||||||
            case 1 -> {
 | 
					            case 1 -> {
 | 
				
			||||||
                this.lines += 1;
 | 
					                this.lines += 1;
 | 
				
			||||||
                this.score += 40 * this.level;
 | 
					                this.score += 40 * this.level;
 | 
				
			||||||
@@ -301,6 +304,11 @@ public class TetrisGame {
 | 
				
			|||||||
            }
 | 
					            }
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        this.score += 50 * this.combo * this.level;
 | 
				
			||||||
 | 
					        if(this.combo >= 2) {
 | 
				
			||||||
 | 
					            combatLines += (int) Math.floor((double) this.combo /2);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if(this.hasCombat && this.attackingLines > 0) {
 | 
					        if(this.hasCombat && this.attackingLines > 0) {
 | 
				
			||||||
            if(combatLines > 0 && this.attackingLines >= combatLines) {
 | 
					            if(combatLines > 0 && this.attackingLines >= combatLines) {
 | 
				
			||||||
                this.attackingLines -= combatLines;
 | 
					                this.attackingLines -= combatLines;
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user