diff --git a/src/GameConfig.java b/src/GameConfig.java new file mode 100644 index 0000000..57266fa --- /dev/null +++ b/src/GameConfig.java @@ -0,0 +1,146 @@ +package com.snakegame; + +import java.awt.Color; + +public class GameConfig { + private final int tileSize = 20; + private final int width = 30; + private final int height = 20; + private final int startX1 = 15; + private final int startY1 = 10; + private final int startX2 = 15; + private final int startY2 = 15; + private Color[] snakeColors1 = new Color[]{new Color(46, 204, 113), new Color(39, 174, 96)}; + private Color[] snakeColors2 = new Color[]{new Color(231, 76, 60), new Color(192, 57, 43)}; + private Color foodColor = new Color(231, 76, 60); + private Color backgroundColor = new Color(236, 240, 241); + private boolean gradientEnabled = true; + private String mode = "简单"; + private String gameMode = "单人"; + private boolean wallCollisionEnabled = true; + private int speed = 150; + + public GameConfig() { + } + + public void setMode(String mode) { + this.mode = mode; + byte var3 = -1; + switch(mode.hashCode()) { + case 714415: + if (mode.equals("地域")) { + var3 = 2; + } + break; + case 728526: + if (mode.equals("困难")) { + var3 = 1; + } + break; + case 1001429: + if (mode.equals("简单")) { + var3 = 0; + } + } + + switch(var3) { + case 0: + this.speed = 150; + break; + case 1: + this.speed = 100; + break; + case 2: + this.speed = 80; + } + + } + + public void setGameMode(String gameMode) { + this.gameMode = gameMode; + } + + public void setWallCollisionEnabled(boolean wallCollisionEnabled) { + this.wallCollisionEnabled = wallCollisionEnabled; + } + + public void setBackgroundColor(Color backgroundColor) { + this.backgroundColor = backgroundColor; + } + + public void setSnakeColors1(Color[] snakeColors1) { + this.snakeColors1 = (Color[])snakeColors1.clone(); + } + + public void setSnakeColors2(Color[] snakeColors2) { + this.snakeColors2 = (Color[])snakeColors2.clone(); + } + + public void setFoodColor(Color foodColor) { + this.foodColor = foodColor; + } + + public int getTileSize() { + return 20; + } + + public int getWidth() { + return 30; + } + + public int getHeight() { + return 20; + } + + public int getStartX1() { + return 15; + } + + public int getStartY1() { + return 10; + } + + public int getStartX2() { + return 15; + } + + public int getStartY2() { + return 15; + } + + public Color[] getSnakeColors1() { + return (Color[])this.snakeColors1.clone(); + } + + public Color[] getSnakeColors2() { + return (Color[])this.snakeColors2.clone(); + } + + public Color getFoodColor() { + return this.foodColor; + } + + public Color getBackgroundColor() { + return this.backgroundColor; + } + + public boolean isGradientEnabled() { + return this.gradientEnabled; + } + + public String getMode() { + return this.mode; + } + + public String getGameMode() { + return this.gameMode; + } + + public boolean isWallCollisionEnabled() { + return this.wallCollisionEnabled; + } + + public int getSpeed() { + return this.speed; + } +} \ No newline at end of file