home *** CD-ROM | disk | FTP | other *** search
/ All for Cell Phones: Sony Ericsson / Sony-Ericsson 2004.iso / Java / HTetris / htetris.jar / tetris / GameScreen.class (.txt) < prev    next >
Encoding:
Java Class File  |  2002-07-19  |  16.7 KB  |  641 lines

  1. package tetris;
  2.  
  3. import java.io.ByteArrayInputStream;
  4. import java.io.ByteArrayOutputStream;
  5. import java.io.DataInputStream;
  6. import java.io.DataOutputStream;
  7. import java.util.Random;
  8. import java.util.Timer;
  9. import javax.microedition.lcdui.Canvas;
  10. import javax.microedition.lcdui.Command;
  11. import javax.microedition.lcdui.CommandListener;
  12. import javax.microedition.lcdui.Display;
  13. import javax.microedition.lcdui.Displayable;
  14. import javax.microedition.lcdui.Form;
  15. import javax.microedition.lcdui.Graphics;
  16. import javax.microedition.rms.RecordStore;
  17.  
  18. public class GameScreen extends Canvas implements CommandListener, Runnable {
  19.    static int cols = 11;
  20.    static int rows;
  21.    static int blockSize;
  22.    // $FF: renamed from: oX int
  23.    static int field_0 = 1;
  24.    // $FF: renamed from: oY int
  25.    static int field_1;
  26.    // $FF: renamed from: nX int
  27.    static int field_2;
  28.    // $FF: renamed from: nY int
  29.    static int field_3 = 1;
  30.    // $FF: renamed from: sX int
  31.    static int field_4;
  32.    // $FF: renamed from: sY int
  33.    static int field_5;
  34.    static boolean colored;
  35.    static int[][][] blocks = new int[][][]{{{1, 0}, {1, 1}, {1, 2}, {1, 3}}, {{0, 1}, {1, 1}, {2, 1}, {3, 1}}, {{1, 0}, {1, 1}, {1, 2}, {2, 2}}, {{0, 1}, {1, 1}, {2, 1}, {2, 0}}, {{1, 0}, {2, 0}, {2, 1}, {2, 2}}, {{0, 0}, {1, 0}, {2, 0}, {0, 1}}, {{2, 0}, {2, 1}, {2, 2}, {1, 2}}, {{0, 1}, {1, 1}, {2, 1}, {2, 2}}, {{1, 0}, {1, 1}, {1, 2}, {2, 0}}, {{0, 0}, {0, 1}, {1, 1}, {2, 1}}, {{0, 0}, {1, 0}, {1, 1}, {2, 1}}, {{1, 0}, {1, 1}, {0, 1}, {0, 2}}, {{0, 1}, {1, 1}, {1, 0}, {2, 0}}, {{0, 0}, {0, 1}, {1, 1}, {1, 2}}, {{1, 0}, {1, 1}, {2, 1}, {1, 2}}, {{0, 1}, {1, 0}, {1, 1}, {2, 1}}, {{0, 1}, {1, 0}, {1, 1}, {1, 2}}, {{0, 0}, {1, 0}, {2, 0}, {1, 1}}, {{0, 0}, {1, 0}, {1, 1}, {0, 1}}};
  36.    static int[] blockClass = new int[]{2, 4, 4, 2, 2, 4, 1};
  37.    static int[] blockClassCount = new int[]{0, 2, 6, 10, 12, 14, 18};
  38.    static int[] colors = new int[]{16711680, 16711680, 16711935, 16711935, 16711935, 16711935, 65535, 65535, 65535, 65535, 65280, 65280, 255, 255, 16744384, 16744384, 16744384, 16744384, 16744192};
  39.    static int[] rotation = new int[]{1, 0, 3, 4, 5, 2, 7, 8, 9, 6, 11, 10, 13, 12, 15, 16, 17, 14, 18};
  40.    static int[][] nextIndent = new int[][]{{1, 0}, {0, 1}, {0, 1}, {1, 2}, {0, 1}, {1, 2}, {0, 1}, {1, 0}, {0, 1}, {1, 2}, {1, 2}, {2, 1}, {1, 2}, {2, 1}, {0, 1}, {1, 2}, {2, 1}, {1, 2}, {2, 2}};
  41.    static int scoreFontSize = 3;
  42.    static int nrRowsOutToChangeLevel = 25;
  43.    static int defaultGameSpeed = 500;
  44.    static Random gameRND = new Random();
  45.    static int startItemX;
  46.    static int startItemY = 0;
  47.    static int keyLeft;
  48.    static int keyRight;
  49.    static int keyUp;
  50.    static int keyDown;
  51.    static Command pauseCommand = new Command("Pause", 1, 1);
  52.    static Command unpauseCommand = new Command("Unpause", 4, 1);
  53.    static Command backCommand = new Command("Menu", 7, 2);
  54.    static RecordStore gameRS;
  55.    Timer gameTimer;
  56.    int gameSpeed = 500;
  57.    int gameLevel = 1;
  58.    boolean gameOver;
  59.    boolean paused;
  60.    int currentItem;
  61.    int currentItemX;
  62.    int currentItemY;
  63.    int oldItem;
  64.    int oldItemX;
  65.    int oldItemY;
  66.    int nextItem;
  67.    boolean clearOldItem;
  68.    boolean fullRepaint;
  69.    boolean moved;
  70.    boolean paintNext;
  71.    boolean itemStopped;
  72.    byte[][] playField;
  73.    int gameScore;
  74.    int gameLines;
  75.  
  76.    public GameScreen() {
  77.       try {
  78.          this.jbInit();
  79.       } catch (Exception e) {
  80.          ((Throwable)e).printStackTrace();
  81.       }
  82.  
  83.    }
  84.  
  85.    private void jbInit() throws Exception {
  86.       ((Displayable)this).setCommandListener(this);
  87.       if (((Canvas)this).getWidth() >= 96 && ((Canvas)this).getHeight() >= 54) {
  88.          blockSize = 4;
  89.          field_1 = (((Canvas)this).getHeight() - blockSize * cols) / 1 - 1;
  90.       } else {
  91.          blockSize = 2;
  92.          field_1 = 1;
  93.       }
  94.  
  95.       rows = (((Canvas)this).getWidth() - 8 - 4) / blockSize;
  96.       startItemX = (cols - 4) / 2 + 1;
  97.       field_2 = ((Canvas)this).getWidth() - 8 - 1;
  98.       field_4 = ((Canvas)this).getWidth() - 2 * scoreFontSize - 2;
  99.       field_5 = field_3 + 8 + 2 + scoreFontSize;
  100.       if (!Options.readKeys()) {
  101.          Options.keyLeft = ((Canvas)this).getKeyCode(1);
  102.          Options.keyRight = ((Canvas)this).getKeyCode(6);
  103.          Options.keyUp = 53;
  104.          Options.keyDown = ((Canvas)this).getKeyCode(2);
  105.       }
  106.  
  107.       this.playField = new byte[rows][cols];
  108.    }
  109.  
  110.    protected int getGameSpeed(int level) {
  111.       int speed = defaultGameSpeed;
  112.  
  113.       for(int i = 1; i < level; ++i) {
  114.          speed -= speed > 100 ? 100 : 10;
  115.       }
  116.  
  117.       return speed;
  118.    }
  119.  
  120.    protected void initGame() {
  121.       if (Options.optDefaultKeys) {
  122.          keyLeft = ((Canvas)this).getKeyCode(1);
  123.          keyRight = ((Canvas)this).getKeyCode(6);
  124.          keyUp = 53;
  125.          keyDown = ((Canvas)this).getKeyCode(2);
  126.       } else {
  127.          keyLeft = Options.keyLeft;
  128.          keyRight = Options.keyRight;
  129.          keyUp = Options.keyUp;
  130.          keyDown = Options.keyDown;
  131.       }
  132.  
  133.       this.fullRepaint = true;
  134.       colored = Display.getDisplay(TetrisMIDlet.instance).numColors() > 2;
  135.    }
  136.  
  137.    private void createGameTimer() {
  138.       this.gameTimer = new Timer();
  139.       this.gameTimer.scheduleAtFixedRate(new GameTimerTask(this), 0L, (long)this.gameSpeed);
  140.    }
  141.  
  142.    private void startGameTimer() {
  143.       ((Displayable)this).removeCommand(unpauseCommand);
  144.       ((Displayable)this).removeCommand(backCommand);
  145.       ((Displayable)this).addCommand(pauseCommand);
  146.       ((Displayable)this).addCommand(backCommand);
  147.       this.gameOver = false;
  148.       this.createGameTimer();
  149.       this.paused = false;
  150.    }
  151.  
  152.    public void startGame() {
  153.       this.initGame();
  154.  
  155.       for(int i = 0; i < rows; ++i) {
  156.          for(int j = 0; j < cols; ++j) {
  157.             this.playField[i][j] = 0;
  158.          }
  159.       }
  160.  
  161.       this.generateNextItem();
  162.       this.newItem();
  163.       this.gameScore = 0;
  164.       this.gameLines = 0;
  165.       this.gameLevel = Options.startLevel + 1;
  166.       this.gameSpeed = this.getGameSpeed(this.gameLevel);
  167.  
  168.       for(int i = 1; i <= Options.garbageLevel * 2; ++i) {
  169.          boolean full = true;
  170.  
  171.          while(full) {
  172.             for(int j = 0; j < cols; ++j) {
  173.                int b;
  174.                for(b = -1; b < 0; b = gameRND.nextInt() % (blocks.length + blocks.length / 3)) {
  175.                }
  176.  
  177.                this.playField[rows - i][j] = (byte)(b < blocks.length ? b + 1 : 0);
  178.                if (b == 0) {
  179.                   full = false;
  180.                }
  181.             }
  182.          }
  183.       }
  184.  
  185.       this.startGameTimer();
  186.    }
  187.  
  188.    public void resumeGame() {
  189.       this.initGame();
  190.       if (Options.optProgressive) {
  191.          for(int x = this.gameLines - (this.gameLevel - 1) * nrRowsOutToChangeLevel; x >= nrRowsOutToChangeLevel; x -= nrRowsOutToChangeLevel) {
  192.             ++this.gameLevel;
  193.          }
  194.  
  195.          this.gameSpeed = this.getGameSpeed(this.gameLevel);
  196.       }
  197.  
  198.       this.startGameTimer();
  199.    }
  200.  
  201.    public void stopGame() {
  202.       if (!this.gameOver) {
  203.          this.saveGame();
  204.       }
  205.  
  206.       this.gameTimer.cancel();
  207.       this.paused = true;
  208.    }
  209.  
  210.    protected static void openStore() {
  211.       try {
  212.          gameRS = RecordStore.openRecordStore("savegame", true);
  213.       } catch (Exception e) {
  214.          ((Throwable)e).printStackTrace();
  215.       }
  216.  
  217.    }
  218.  
  219.    protected static void closeStore() {
  220.       try {
  221.          gameRS.closeRecordStore();
  222.       } catch (Exception e) {
  223.          ((Throwable)e).printStackTrace();
  224.       }
  225.  
  226.    }
  227.  
  228.    static boolean existsSavedGame() {
  229.       openStore();
  230.       boolean b = false;
  231.  
  232.       try {
  233.          int x = gameRS.getNumRecords();
  234.          b = x > 0;
  235.       } catch (Exception e) {
  236.          ((Throwable)e).printStackTrace();
  237.       }
  238.  
  239.       closeStore();
  240.       return b;
  241.    }
  242.  
  243.    public boolean loadGame() {
  244.       openStore();
  245.       boolean success = true;
  246.  
  247.       try {
  248.          if (gameRS.getNumRecords() > 0) {
  249.             byte[] b = gameRS.getRecord(1);
  250.             ByteArrayInputStream bais = new ByteArrayInputStream(b);
  251.             DataInputStream dis = new DataInputStream(bais);
  252.  
  253.             for(int i = 0; i < rows; ++i) {
  254.                dis.read(this.playField[i], 0, this.playField[i].length);
  255.             }
  256.  
  257.             this.nextItem = dis.readInt();
  258.             this.currentItem = dis.readInt();
  259.             this.currentItemX = dis.readInt();
  260.             this.currentItemY = dis.readInt();
  261.             this.clearOldItem = dis.readInt() == 1;
  262.             this.paintNext = dis.readInt() == 1;
  263.             this.moved = dis.readInt() == 1;
  264.             this.gameScore = dis.readInt();
  265.             this.gameLines = dis.readInt();
  266.             this.gameLevel = dis.readInt();
  267.             this.gameSpeed = this.getGameSpeed(this.gameLevel);
  268.             this.fullRepaint = true;
  269.          }
  270.       } catch (Exception e) {
  271.          success = false;
  272.          ((Throwable)e).printStackTrace();
  273.       }
  274.  
  275.       try {
  276.          gameRS.deleteRecord(1);
  277.       } catch (Exception e) {
  278.          ((Throwable)e).printStackTrace();
  279.       }
  280.  
  281.       closeStore();
  282.  
  283.       try {
  284.          RecordStore.deleteRecordStore("savegame");
  285.       } catch (Exception e) {
  286.          ((Throwable)e).printStackTrace();
  287.       }
  288.  
  289.       return success;
  290.    }
  291.  
  292.    public void saveGame() {
  293.       openStore();
  294.  
  295.       try {
  296.          ByteArrayOutputStream baos = new ByteArrayOutputStream();
  297.          DataOutputStream dos = new DataOutputStream(baos);
  298.  
  299.          for(int i = 0; i < rows; ++i) {
  300.             dos.write(this.playField[i], 0, this.playField[i].length);
  301.          }
  302.  
  303.          dos.writeInt(this.nextItem);
  304.          dos.writeInt(this.currentItem);
  305.          dos.writeInt(this.currentItemX);
  306.          dos.writeInt(this.currentItemY);
  307.          dos.writeInt(this.clearOldItem ? 1 : 0);
  308.          dos.writeInt(this.paintNext ? 1 : 0);
  309.          dos.writeInt(this.moved ? 1 : 0);
  310.          dos.writeInt(this.gameScore);
  311.          dos.writeInt(this.gameLines);
  312.          dos.writeInt(this.gameLevel);
  313.          byte[] b = baos.toByteArray();
  314.          if (gameRS.getNumRecords() > 0) {
  315.             gameRS.setRecord(1, b, 0, b.length);
  316.          } else {
  317.             gameRS.addRecord(b, 0, b.length);
  318.          }
  319.       } catch (Exception e) {
  320.          ((Throwable)e).printStackTrace();
  321.       }
  322.  
  323.       closeStore();
  324.    }
  325.  
  326.    public void run() {
  327.       this.downItem();
  328.    }
  329.  
  330.    public void commandAction(Command command, Displayable displayable) {
  331.       if (command.getCommandType() == 7) {
  332.          this.stopGame();
  333.          if (!this.gameOver) {
  334.             TetrisMIDlet.mainMenu.addContinue();
  335.          }
  336.  
  337.          Display.getDisplay(TetrisMIDlet.instance).setCurrent(TetrisMIDlet.mainMenu);
  338.       }
  339.  
  340.       if (command.getCommandType() == 1) {
  341.          this.stopGame();
  342.          ((Displayable)this).removeCommand(pauseCommand);
  343.          ((Displayable)this).removeCommand(backCommand);
  344.          ((Displayable)this).addCommand(unpauseCommand);
  345.          ((Displayable)this).addCommand(backCommand);
  346.       }
  347.  
  348.       if (command.getCommandType() == 4) {
  349.          this.resumeGame();
  350.       }
  351.  
  352.       if (command.getCommandType() == 2) {
  353.          if (TetrisMIDlet.highScores.checkScore(this.gameScore)) {
  354.             TetrisMIDlet.highScores.getName();
  355.          } else {
  356.             Display.getDisplay(TetrisMIDlet.instance).setCurrent(TetrisMIDlet.mainMenu);
  357.          }
  358.       }
  359.  
  360.    }
  361.  
  362.    protected void keyPressed(int keyCode) {
  363.       if (!this.paused) {
  364.          if (keyCode == keyLeft) {
  365.             this.moveItem(-1);
  366.          } else if (keyCode == keyRight) {
  367.             this.moveItem(1);
  368.          } else if (keyCode == keyUp) {
  369.             this.rotateItem();
  370.          } else if (keyCode == keyDown) {
  371.             this.dropItem();
  372.          }
  373.       }
  374.  
  375.    }
  376.  
  377.    public void generateNextItem() {
  378.       int nextClass;
  379.       for(nextClass = -1; nextClass < 0; nextClass = gameRND.nextInt() % blockClass.length) {
  380.       }
  381.  
  382.       int nextMember;
  383.       for(nextMember = -1; nextMember < 0; nextMember = gameRND.nextInt() % blockClass[nextClass]) {
  384.       }
  385.  
  386.       this.nextItem = blockClassCount[nextClass] + nextMember;
  387.    }
  388.  
  389.    public void newItem() {
  390.       this.currentItem = this.nextItem;
  391.       this.generateNextItem();
  392.       this.currentItemX = startItemX;
  393.       this.currentItemY = startItemY;
  394.       this.clearOldItem = false;
  395.       this.paintNext = true;
  396.       this.moved = false;
  397.       this.fullRepaint = true;
  398.    }
  399.  
  400.    public boolean checkItemPos(int item, int x, int y) {
  401.       for(int i = 0; i < 4; ++i) {
  402.          if (x + blocks[item][i][0] < 0 || x + blocks[item][i][0] >= cols || y + blocks[item][i][1] >= rows) {
  403.             return false;
  404.          }
  405.  
  406.          if (this.playField[y + blocks[item][i][1]][x + blocks[item][i][0]] != 0) {
  407.             return false;
  408.          }
  409.       }
  410.  
  411.       return true;
  412.    }
  413.  
  414.    public void downItem() {
  415.       int rowsOut = 0;
  416.       if (this.checkItemPos(this.currentItem, this.currentItemX, this.currentItemY + 1)) {
  417.          ++this.currentItemY;
  418.          this.moved = true;
  419.          this.clearOldItem = true;
  420.          ((Canvas)this).repaint();
  421.       } else {
  422.          this.itemStopped = true;
  423.  
  424.          for(int i = 0; i < 4; ++i) {
  425.             this.playField[this.currentItemY + blocks[this.currentItem][i][1]][this.currentItemX + blocks[this.currentItem][i][0]] = (byte)(this.currentItem + 1);
  426.          }
  427.  
  428.          boolean check = true;
  429.  
  430.          while(check) {
  431.             check = false;
  432.  
  433.             for(int i = rows - 1; i >= 0; --i) {
  434.                boolean full = true;
  435.  
  436.                for(int j = 0; j < cols; ++j) {
  437.                   if (this.playField[i][j] == 0) {
  438.                      full = false;
  439.                      break;
  440.                   }
  441.                }
  442.  
  443.                if (full) {
  444.                   this.moved = true;
  445.                   ++rowsOut;
  446.  
  447.                   for(int k = i; k > 0; --k) {
  448.                      for(int l = 0; l < cols; ++l) {
  449.                         this.playField[k][l] = this.playField[k - 1][l];
  450.                      }
  451.                   }
  452.  
  453.                   for(int l = 0; l < cols; ++l) {
  454.                      this.playField[0][l] = 0;
  455.                   }
  456.  
  457.                   this.fullRepaint = true;
  458.                   check = true;
  459.                   break;
  460.                }
  461.             }
  462.          }
  463.  
  464.          if (rowsOut > 0) {
  465.             boolean empty = true;
  466.  
  467.             for(int i = 0; i < cols; ++i) {
  468.                if (this.playField[rows - 1][i] != 0) {
  469.                   empty = false;
  470.                   break;
  471.                }
  472.             }
  473.  
  474.             if (empty) {
  475.                this.gameScore += 25;
  476.             }
  477.  
  478.             this.gameScore += rowsOut * (this.gameLevel - 1);
  479.             if (Options.optProgressive) {
  480.                this.gameScore += rowsOut * 2 - 1;
  481.             } else {
  482.                this.gameScore += rowsOut;
  483.             }
  484.  
  485.             this.gameLines += rowsOut;
  486.             if (Options.optProgressive) {
  487.                for(int x = this.gameLines - (this.gameLevel - 1) * nrRowsOutToChangeLevel; x >= nrRowsOutToChangeLevel; x -= nrRowsOutToChangeLevel) {
  488.                   ++this.gameLevel;
  489.                }
  490.  
  491.                int newSpeed = this.getGameSpeed(this.gameLevel);
  492.                if (this.gameSpeed != newSpeed) {
  493.                   this.gameTimer.cancel();
  494.                   this.gameSpeed = newSpeed;
  495.                   this.createGameTimer();
  496.                }
  497.             }
  498.          }
  499.  
  500.          if (this.moved) {
  501.             this.newItem();
  502.             ((Canvas)this).repaint();
  503.          } else {
  504.             this.gameOver = true;
  505.             this.stopGame();
  506.             Form go = new Form("");
  507.             go.append("GAME OVER\n ");
  508.             go.append("\nScore:".concat(String.valueOf(String.valueOf(Integer.toString(this.gameScore)))));
  509.             go.append("\nLines:".concat(String.valueOf(String.valueOf(Integer.toString(this.gameLines)))));
  510.             ((Displayable)go).setCommandListener(this);
  511.             ((Displayable)go).addCommand(new Command("OK", 2, 1));
  512.             Display.getDisplay(TetrisMIDlet.instance).setCurrent(go);
  513.          }
  514.       }
  515.  
  516.    }
  517.  
  518.    public void moveItem(int changeX) {
  519.       if (!this.itemStopped && this.checkItemPos(this.currentItem, this.currentItemX + changeX, this.currentItemY)) {
  520.          this.currentItemX += changeX;
  521.          this.clearOldItem = true;
  522.          ((Canvas)this).repaint();
  523.       }
  524.  
  525.    }
  526.  
  527.    public void rotateItem() {
  528.       if (!this.itemStopped && this.checkItemPos(rotation[this.currentItem], this.currentItemX, this.currentItemY)) {
  529.          this.currentItem = rotation[this.currentItem];
  530.          this.clearOldItem = true;
  531.          ((Canvas)this).repaint();
  532.       }
  533.  
  534.    }
  535.  
  536.    public void dropItem() {
  537.       while(!this.itemStopped) {
  538.          this.downItem();
  539.       }
  540.  
  541.    }
  542.  
  543.    protected void paintNextBlock(Graphics g, int item, int x, int y, int color) {
  544.       if (colored) {
  545.          g.setColor(color);
  546.       } else {
  547.          g.setColor(color == 16777215 ? color : 0);
  548.       }
  549.  
  550.       g.fillRect(field_2 + (4 - y - 1) * 2 - nextIndent[item][1], field_3 + x * 2 + nextIndent[item][0], 2, 2);
  551.    }
  552.  
  553.    protected void paintBlock(Graphics g, int x, int y, int color) {
  554.       if (colored) {
  555.          g.setColor(color);
  556.       } else {
  557.          g.setColor(color == 16777215 ? color : 0);
  558.       }
  559.  
  560.       g.fillRect(field_0 + (rows - y - 1) * blockSize, field_1 + x * blockSize, blockSize, blockSize);
  561.    }
  562.  
  563.    protected void paintItem(Graphics g, int item, int x, int y, int color) {
  564.       for(int i = 0; i < 4; ++i) {
  565.          this.paintBlock(g, x + blocks[item][i][0], y + blocks[item][i][1], color);
  566.       }
  567.  
  568.    }
  569.  
  570.    protected void drawItem(Graphics g, int item, int x, int y) {
  571.       this.paintItem(g, item, x, y, colors[item]);
  572.    }
  573.  
  574.    protected void clearItem(Graphics g, int item, int x, int y) {
  575.       this.paintItem(g, item, x, y, 16777215);
  576.    }
  577.  
  578.    protected void paint(Graphics g) {
  579.       if (this.fullRepaint) {
  580.          g.setColor(16777215);
  581.          g.fillRect(0, 0, ((Canvas)this).getWidth(), ((Canvas)this).getHeight());
  582.          g.setColor(0);
  583.  
  584.          for(int i = 0; i < rows; ++i) {
  585.             for(int j = 0; j < cols; ++j) {
  586.                if (this.playField[i][j] != 0) {
  587.                   this.paintBlock(g, j, i, colors[this.playField[i][j] - 1]);
  588.                }
  589.             }
  590.          }
  591.  
  592.          g.setColor(0);
  593.          g.drawRect(field_0 - 1, field_1 - 1, rows * blockSize + 1, cols * blockSize + 1);
  594.          Digit.drawVNumber(g, field_4, field_5, (long)this.gameScore, scoreFontSize);
  595.          if (Options.optProgressive) {
  596.             g.setColor(0);
  597.             g.drawLine(1, 1, 1, 5);
  598.             g.drawLine(2, 5, 3, 5);
  599.             g.drawLine(5, 1, 7, 1);
  600.             g.drawLine(5, 2, 5, 5);
  601.             g.drawLine(6, 3, 6, 3);
  602.             g.drawLine(6, 5, 7, 5);
  603.             g.drawLine(11, 5, 9, 1);
  604.             g.drawLine(11, 5, 13, 1);
  605.             g.drawLine(15, 1, 17, 1);
  606.             g.drawLine(15, 2, 15, 5);
  607.             g.drawLine(16, 3, 16, 3);
  608.             g.drawLine(16, 5, 17, 5);
  609.             g.drawLine(19, 1, 19, 5);
  610.             g.drawLine(20, 5, 21, 5);
  611.             Digit.drawHNumber(g, 25, 1, (long)this.gameLevel, 2);
  612.          }
  613.       }
  614.  
  615.       if (Options.optPreview && (this.fullRepaint || this.paintNext)) {
  616.          g.setColor(16777215);
  617.          g.fillRect(field_2, field_3, 8, 8);
  618.          g.setColor(0);
  619.          g.drawRect(field_2 - 1, field_3 - 1, 9, 9);
  620.  
  621.          for(int i = 0; i < 4; ++i) {
  622.             this.paintNextBlock(g, this.nextItem, blocks[this.nextItem][i][0], blocks[this.nextItem][i][1], colors[this.nextItem]);
  623.          }
  624.  
  625.          this.paintNext = false;
  626.       }
  627.  
  628.       this.fullRepaint = false;
  629.       if (this.clearOldItem) {
  630.          this.clearItem(g, this.oldItem, this.oldItemX, this.oldItemY);
  631.          this.clearOldItem = false;
  632.       }
  633.  
  634.       this.drawItem(g, this.currentItem, this.currentItemX, this.currentItemY);
  635.       this.oldItem = this.currentItem;
  636.       this.oldItemX = this.currentItemX;
  637.       this.oldItemY = this.currentItemY;
  638.       this.itemStopped = false;
  639.    }
  640. }
  641.