├── .gitattributes ├── README.md ├── Tetris .docx ├── TetrisTheGame.iml ├── pom.xml ├── src ├── main │ └── java │ │ ├── Tetris.java │ │ ├── model │ │ ├── Coord.java │ │ ├── Figures.java │ │ ├── Mapable.java │ │ ├── Refreshable.java │ │ └── Startable.java │ │ ├── service │ │ └── FlyFigure.java │ │ └── ui │ │ ├── Box.java │ │ ├── Config.java │ │ ├── InfoWindow.java │ │ ├── RefreshWindow.java │ │ ├── StartingWindow.java │ │ └── Window.java └── ru │ └── spbstu │ └── Main.java └── target └── classes ├── META-INF └── TetrisTheGame.kotlin_module ├── Tetris.class ├── model ├── Coord.class ├── Figures$1.class ├── Figures.class ├── Mapable.class ├── Refreshable.class └── Startable.class ├── service └── FlyFigure.class └── ui ├── Box.class ├── Config.class ├── InfoWindow.class ├── RefreshWindow$ButtonEventListener.class ├── RefreshWindow.class ├── StartingWindow$ButtonEventListener.class ├── StartingWindow.class ├── Window$KeyAdapter.class ├── Window$TimeAdapter.class └── Window.class /.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto 3 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Tetris 2 | # Task 3 | Целью данной работы является разработка игры "Тетрис". Она относится к логическим играм, которые помогают развить реакцию, тренируют логику. При длительной работе за компьютером возникает усталость и необходимость отвлечься на 5-10 минут. Для этой цели вполне подойдет именно «Тетрис». В стандартной поставке операционных систем 4 | данной игры нет, поэтому возникла необходимость в ее создании. Задачами курсовой работы является изучение объектноориентированного языка программирования Java, рассмотрение игры Тетрис, и создание программного кода на языке Java. 5 | # Requirements 6 | К играм такого типа предъявляются следующие требования: 7 | * использование простых средств управления; 8 | * удобный графический интерфейс; 9 | * постепенное усложнение игры при наборе определенного количества 10 | очков; 11 | * корректное выполнение программы. 12 | 13 | Смысл игры заключается в стремлении плотно занять игровое поле падающими геометрическими фигурами, изменяя их ориентацию в 14 | пространстве, добиваясь отсутствия пробелов в каждой строке. 15 | Фигуры не должны выходить за пределы игрового поля, они 16 | перемещаться и переворачиваться. Для придания большей 17 | привлекательности внешнему виду игрового поля при написании игры нужно 18 | использовать яркую графику. Интерфейс программы, разрабатываемой 19 | должен быть удобен и понятен пользователю. 20 | Программа должна реагировать на нажатие клавиш клавиатуры, 21 | выводя требуемое изображение на экран. 22 | # Report 23 | Check Tetris.docx 24 | # Author 25 | Dat Pavel 26 | -------------------------------------------------------------------------------- /Tetris .docx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/paveldat/Tetris/4914f5eb57015d1686680ca9b8d39320f4083d42/Tetris .docx -------------------------------------------------------------------------------- /TetrisTheGame.iml: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 6 | 4.0.0 7 | 8 | ru.spbstu 9 | TetrisTheGame 10 | 1.0-SNAPSHOT 11 | 12 | 13 | 14 | 15 | org.jetbrains.kotlin 16 | kotlin-maven-plugin 17 | ${kotlin.version} 18 | 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /src/main/java/Tetris.java: -------------------------------------------------------------------------------- 1 | import ui.InfoWindow; 2 | import ui.StartingWindow; 3 | import ui.Window; 4 | 5 | public class Tetris { 6 | public static void main(String[] args) { 7 | Window window = new Window(); 8 | // StartingWindow startingWindow = new StartingWindow(); 9 | // javax.swing.SwingUtilities.invokeLater(startingWindow); 10 | javax.swing.SwingUtilities.invokeLater(window); 11 | window.addFigure(); 12 | } 13 | } -------------------------------------------------------------------------------- /src/main/java/model/Coord.java: -------------------------------------------------------------------------------- 1 | package model; 2 | 3 | public class Coord { 4 | 5 | public final int x; 6 | public final int y; 7 | 8 | public Coord(int x, int y) { 9 | this.x = x; 10 | this.y = y; 11 | } 12 | 13 | public Coord plus(int sx, int sy) { 14 | return new Coord(x + sx, y + sy); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /src/main/java/model/Figures.java: -------------------------------------------------------------------------------- 1 | package model; 2 | 3 | import java.util.ArrayList; 4 | import java.util.List; 5 | 6 | import static java.lang.Math.*; 7 | 8 | public enum Figures { 9 | I1(0, 1, 1, 1, 2, 1, 3, 1), 10 | I2(1, 0, 11 | 1, 1, 12 | 1, 2, 13 | 1, 3), 14 | 15 | J1(1, 0, 16 | 1, 1, 17 | 0, 2, 1, 2), 18 | J2(0, 0, 19 | 0, 1, 1, 1, 2, 1), 20 | J3(1, 0, 2, 0, 21 | 1, 1, 22 | 1, 2), 23 | J4(0, 1, 1, 1, 2, 1, 24 | 3, 1), 25 | 26 | L1(1, 0, 27 | 1, 1, 28 | 1, 2, 2, 2), 29 | L2(0, 1, 1, 1, 2, 1, 30 | 0, 2), 31 | L3(0, 0, 1, 0, 32 | 1, 1, 33 | 1, 2), 34 | L4( 2, 0, 35 | 0, 1, 1, 1, 2, 1), 36 | 37 | O(0, 0, 1, 0, 38 | 0, 1, 1, 1), 39 | 40 | S1(1, 1, 2, 1, 41 | 0, 2, 1, 2), 42 | S2(0, 0, 43 | 0, 1, 1, 1, 44 | 1, 2), 45 | T1(0, 1, 1, 1, 2, 1, 46 | 1, 2), 47 | T2(1, 0, 48 | 0, 1, 1, 1, 49 | 1, 2), 50 | T3( 1, 0, 51 | 0, 1, 1, 1, 2, 1), 52 | T4(1, 0, 53 | 1, 1, 2, 1, 54 | 1, 2), 55 | Z1(0, 1, 1, 1, 56 | 1, 2, 2, 2), 57 | Z2( 2, 0, 58 | 1, 1, 2, 1, 59 | 1, 2); 60 | 61 | public final List dots; 62 | public final Coord top; 63 | public final Coord bottom; 64 | 65 | Figures(int ... coords) { 66 | dots = new ArrayList(); 67 | for (int i = 0; i < coords.length; i += 2) { 68 | dots.add(new Coord(coords[i], coords[i + 1])); 69 | } 70 | top = setTop(); 71 | bottom = setBottom(); 72 | } 73 | 74 | private Coord setTop() { 75 | int x = dots.get(0).x; 76 | int y = dots.get(0).y; 77 | for (Coord coord : dots) { 78 | if (x > coord.x) x = coord.x; 79 | if (y > coord.y) y = coord.y; 80 | } 81 | return new Coord(x, y); 82 | } 83 | 84 | private Coord setBottom() { 85 | int x = dots.get(0).x; 86 | int y = dots.get(0).y; 87 | for (Coord coord : dots) { 88 | if (x < coord.x) x = coord.x; 89 | if (y < coord.y) y = coord.y; 90 | } 91 | return new Coord(x, y); 92 | } 93 | 94 | public Figures turnRight() { 95 | switch (this) { 96 | case I1: return I2; 97 | case I2: return I1; 98 | case J1: return J2; 99 | case J2: return J3; 100 | case J3: return J4; 101 | case J4: return J1; 102 | case L1: return L2; 103 | case L2: return L3; 104 | case L3: return L4; 105 | case L4: return L1; 106 | case O: return O; 107 | case S1: return S2; 108 | case S2: return S1; 109 | case T1: return T2; 110 | case T2: return T3; 111 | case T3: return T4; 112 | case T4: return T1; 113 | case Z1: return Z2; 114 | default: return Z1; 115 | } 116 | } 117 | 118 | public Figures turnLeft() { 119 | return turnRight().turnRight().turnRight(); 120 | } 121 | 122 | public static Figures getRandom() { 123 | int a = (int)(random()) * 7; 124 | switch (a) { 125 | case 0: return I1; 126 | case 1: return J1; 127 | case 2: return L1; 128 | case 3: return O; 129 | case 4: return S1; 130 | case 5: return T1; 131 | case 6: 132 | default: return Z1; 133 | } 134 | } 135 | } 136 | -------------------------------------------------------------------------------- /src/main/java/model/Mapable.java: -------------------------------------------------------------------------------- 1 | package model; 2 | 3 | public interface Mapable { 4 | int getBoxColor(int x, int y); 5 | } 6 | -------------------------------------------------------------------------------- /src/main/java/model/Refreshable.java: -------------------------------------------------------------------------------- 1 | package model; 2 | 3 | public interface Refreshable { 4 | void update(); 5 | } 6 | -------------------------------------------------------------------------------- /src/main/java/model/Startable.java: -------------------------------------------------------------------------------- 1 | package model; 2 | 3 | import java.util.Timer; 4 | 5 | public interface Startable { 6 | void start(String player); 7 | } 8 | -------------------------------------------------------------------------------- /src/main/java/service/FlyFigure.java: -------------------------------------------------------------------------------- 1 | package service; 2 | 3 | import model.Coord; 4 | import model.Figures; 5 | import model.Mapable; 6 | import ui.Config; 7 | 8 | public class FlyFigure { 9 | 10 | private Figures figure; 11 | private Coord coord; 12 | private boolean landed; 13 | private int ticks; 14 | Mapable map; 15 | 16 | public Figures getFigure() { 17 | return figure; 18 | } 19 | 20 | public Coord getCoord() { 21 | return coord; 22 | } 23 | 24 | public FlyFigure(Mapable map) { 25 | this.map = map; 26 | figure = Figures.getRandom(); 27 | coord = new Coord(Config.WIDTH / 2 - 2, -1); 28 | landed = false; 29 | } 30 | 31 | public boolean isLanded() { 32 | return landed; 33 | } 34 | 35 | public boolean canPlaceFigure() { 36 | return canMoveFigure(figure, 0, 0); 37 | } 38 | 39 | private boolean canMoveFigure(Figures figure, int sx, int sy) { 40 | if (coord.x + sx + figure.top.x < 0) return false; 41 | if (coord.x + sx + figure.bottom.x >= Config.WIDTH) return false; 42 | // if (coord.y + sy + figure.top.y < 0) return false; 43 | if (coord.y + sy + figure.bottom.y >= Config.HEIGHT) return false; 44 | for (Coord dot : figure.dots) { 45 | if (map.getBoxColor(coord.x + dot.x + sx, coord.y + dot.y + sy) > 0) { 46 | return false; 47 | } 48 | } 49 | return true; 50 | } 51 | 52 | public void moveFigure(int sx, int sy) { 53 | if (canMoveFigure(figure, sx, sy)) { 54 | coord = coord.plus(sx, sy); 55 | } else { 56 | if (sy == 1) { 57 | if (ticks > 0) { 58 | ticks--; 59 | } else { 60 | landed = true; 61 | } 62 | } 63 | } 64 | } 65 | 66 | public void turnFigure(int direction) { 67 | Figures rotated = direction == 1 ? figure.turnRight() : figure.turnLeft(); 68 | if (canMoveFigure(rotated,0, 0)) { 69 | figure = rotated; 70 | } else 71 | if (canMoveFigure(rotated, 1, 0)) { 72 | figure = rotated; 73 | moveFigure(1, 0); 74 | } else 75 | if (canMoveFigure(rotated, -1, 0)) { 76 | figure = rotated; 77 | moveFigure(-1, 0); 78 | } else 79 | if (canMoveFigure(rotated, 0, -1)) { 80 | figure = rotated; 81 | moveFigure(0, -1); 82 | } 83 | } 84 | } 85 | -------------------------------------------------------------------------------- /src/main/java/ui/Box.java: -------------------------------------------------------------------------------- 1 | package ui; 2 | 3 | import javax.swing.*; 4 | 5 | public class Box extends JPanel { 6 | 7 | private int color; 8 | 9 | public int getColor() { 10 | return color; 11 | } 12 | 13 | public Box(int x, int y) { 14 | color = 0; 15 | setBounds(x * Config.SIZE, y * Config.SIZE, Config.SIZE, Config.SIZE); 16 | setBackground(Config.COLORS[0]); 17 | setVisible(true); 18 | } 19 | 20 | public void setColor(int color) { 21 | this.color = color; 22 | if (color >= 0 && color < Config.COLORS.length) { 23 | setBackground(Config.COLORS[color]); 24 | } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/main/java/ui/Config.java: -------------------------------------------------------------------------------- 1 | package ui; 2 | 3 | import java.awt.*; 4 | 5 | public class Config { 6 | public static final int WIDTH = 10; 7 | public static final int HEIGHT = 20; 8 | 9 | public static final int SIZE = 30; 10 | 11 | public static final Color[] COLORS = { 12 | Color.GRAY, 13 | Color.CYAN, 14 | Color.GREEN 15 | }; 16 | } 17 | -------------------------------------------------------------------------------- /src/main/java/ui/InfoWindow.java: -------------------------------------------------------------------------------- 1 | package ui; 2 | 3 | import javax.swing.*; 4 | import java.awt.*; 5 | import java.util.ArrayList; 6 | import java.util.HashMap; 7 | import java.util.LinkedHashMap; 8 | 9 | public class InfoWindow extends JFrame { 10 | 11 | private ArrayList labels = new ArrayList<>(); 12 | private ArrayList players = new ArrayList<>(); 13 | private ArrayList scores = new ArrayList<>(); 14 | // private LinkedHashMap results = new LinkedHashMap<>(); 15 | private String player; 16 | private Container container; 17 | private int score; 18 | 19 | public InfoWindow() { 20 | super("Game Info"); 21 | this.setBounds(0, 0, 250, 200); 22 | this.setDefaultCloseOperation(EXIT_ON_CLOSE); 23 | 24 | container = this.getContentPane(); 25 | container.setLayout(new GridLayout(5, 2, 2, 2)); 26 | } 27 | 28 | public void updateLabel(int score_) { 29 | score += score_; 30 | setLabelText(); 31 | } 32 | 33 | public void startNewGame(String player) { 34 | // this.player = player; 35 | // if (!results.containsKey(player)) { 36 | //// this.player = player; 37 | // results.put(player, 0); 38 | // addLabel(); 39 | // } 40 | this.player = player; 41 | if (!playerExists(player)) { 42 | players.add(player); 43 | addLabel(); 44 | } 45 | score = 0; 46 | setLabelText(); 47 | } 48 | 49 | private boolean playerExists(String player) { 50 | for (String next : players) { 51 | if (next.equals(player)) { 52 | return true; 53 | } 54 | } 55 | return false; 56 | } 57 | 58 | private void addLabel() { 59 | JLabel newLabel = new JLabel(); 60 | labels.add(newLabel); 61 | container.add(newLabel); 62 | } 63 | 64 | private void setLabelText() { 65 | // int index = players; 66 | JLabel label = labels.get(labels.size() - 1); 67 | label.setText(player + "'s score: " + score); 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /src/main/java/ui/RefreshWindow.java: -------------------------------------------------------------------------------- 1 | package ui; 2 | 3 | import model.Refreshable; 4 | 5 | import javax.swing.*; 6 | import java.awt.*; 7 | import java.awt.event.ActionEvent; 8 | import java.awt.event.ActionListener; 9 | 10 | public class RefreshWindow extends JFrame { 11 | 12 | private JButton button = new JButton("Play again"); 13 | Refreshable refresh; 14 | 15 | public RefreshWindow(Refreshable refresh) { 16 | super("You're loser"); 17 | this.refresh = refresh; 18 | this.setBounds(0, 0, 200, 100); 19 | this.setDefaultCloseOperation(EXIT_ON_CLOSE); 20 | 21 | Container container = this.getContentPane(); 22 | container.setLayout(new GridLayout(1, 1, 2, 2)); 23 | container.add(button); 24 | 25 | button.addActionListener(new ButtonEventListener()); 26 | } 27 | 28 | class ButtonEventListener implements ActionListener { 29 | public void actionPerformed(ActionEvent e) { 30 | refresh.update(); 31 | setVisible(false); 32 | } 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /src/main/java/ui/StartingWindow.java: -------------------------------------------------------------------------------- 1 | package ui; 2 | 3 | import model.Startable; 4 | 5 | import javax.swing.*; 6 | import java.awt.*; 7 | import java.awt.event.ActionEvent; 8 | import java.awt.event.ActionListener; 9 | 10 | public class StartingWindow extends JFrame { 11 | 12 | private JTextField input = new JTextField("Enter your name"); 13 | private JButton button = new JButton("Start the game!"); 14 | private Startable start; 15 | 16 | public StartingWindow(Startable start) { 17 | super("Glad to see you again!"); 18 | this.start = start; 19 | this.setBounds(0, 0, 250, 100); 20 | this.setDefaultCloseOperation(EXIT_ON_CLOSE); 21 | 22 | Container container = this.getContentPane(); 23 | container.setLayout(new GridLayout(2, 1, 2, 2)); 24 | container.add(input); 25 | container.add(button); 26 | 27 | setAlwaysOnTop(true); 28 | setLocationRelativeTo(null); 29 | setVisible(true); 30 | 31 | button.addActionListener(new ButtonEventListener()); 32 | } 33 | 34 | class ButtonEventListener implements ActionListener { 35 | public void actionPerformed(ActionEvent e) { 36 | String player = input.getText(); 37 | start.start(player); 38 | setVisible(false); 39 | } 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /src/main/java/ui/Window.java: -------------------------------------------------------------------------------- 1 | package ui; 2 | 3 | import javax.swing.*; 4 | 5 | import model.Refreshable; 6 | import model.Coord; 7 | import model.Mapable; 8 | import model.Startable; 9 | import service.FlyFigure; 10 | 11 | import java.awt.event.ActionEvent; 12 | import java.awt.event.ActionListener; 13 | import java.awt.event.KeyEvent; 14 | import java.awt.event.KeyListener; 15 | 16 | public class Window extends JFrame implements Runnable, Mapable, Startable, Refreshable { 17 | 18 | private Box[][] boxes; 19 | private FlyFigure fly; 20 | private InfoWindow infoWindow = new InfoWindow(); 21 | private RefreshWindow refreshWindow = new RefreshWindow(this); 22 | private StartingWindow startingWindow = new StartingWindow(this); 23 | private Timer timer; 24 | 25 | public Window() { 26 | setEnabled(false); 27 | boxes = new Box[Config.WIDTH][Config.HEIGHT]; 28 | initForm(); 29 | initBoxes(); 30 | addKeyListener(new KeyAdapter()); 31 | TimeAdapter timeAdapter = new TimeAdapter(); 32 | timer = new Timer(150, timeAdapter); 33 | timer.start(); 34 | infoWindow.setLocation(this.getLocation().x - infoWindow.getWidth(), this.getLocation().y); 35 | infoWindow.setVisible(true); 36 | refreshWindow.setLocationRelativeTo(this); 37 | } 38 | 39 | public void addFigure() { 40 | if (startingWindow.isVisible()) { 41 | timer.stop(); 42 | } 43 | fly = new FlyFigure(this); 44 | if (fly.canPlaceFigure()) { 45 | showFigure(1); 46 | } else { 47 | this.setEnabled(false); 48 | refreshWindow.setVisible(true); 49 | return; 50 | } 51 | } 52 | 53 | public void start(String player) { 54 | timer.start(); 55 | infoWindow.startNewGame(player); 56 | setEnabled(true); 57 | } 58 | 59 | public void update() { 60 | startingWindow.setVisible(true); 61 | clearBoxes(); 62 | setEnabled(true); 63 | addFigure(); 64 | } 65 | 66 | private void clearBoxes() { 67 | for (int x = 0; x < Config.WIDTH; ++x) { 68 | for (int y = 0; y < Config.HEIGHT; ++y) { 69 | boxes[x][y].setColor(0); 70 | } 71 | } 72 | } 73 | 74 | private void initForm() { 75 | setSize(Config.WIDTH * Config.SIZE + 15, 76 | Config.HEIGHT * Config.SIZE + 40); 77 | setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); 78 | setTitle("Tetris the Game"); 79 | setLayout(null); 80 | setLocationRelativeTo(null); 81 | setVisible(true); 82 | } 83 | 84 | private void initBoxes() { 85 | for (int x = 0; x < Config.WIDTH; ++x) { 86 | for (int y = 0; y < Config.HEIGHT; ++y) { 87 | boxes[x][y] = new Box(x, y); 88 | add(boxes[x][y]); 89 | } 90 | } 91 | } 92 | 93 | public void run() { 94 | repaint(); 95 | } 96 | 97 | private void showFigure() { 98 | showFigure(1); 99 | } 100 | 101 | private void hideFigure() { 102 | showFigure(0); 103 | } 104 | 105 | private void showFigure(int color) { 106 | for (Coord dot : fly.getFigure().dots) { 107 | setBoxColor(fly.getCoord().x + dot.x,fly.getCoord().y + dot.y, color); 108 | } 109 | } 110 | 111 | private void setBoxColor(int x, int y, int color) { 112 | if (x < 0 || x >= Config.WIDTH) return; 113 | if (y < 0 || y >= Config.HEIGHT) return; 114 | boxes[x][y].setColor(color); 115 | } 116 | 117 | public int getBoxColor(int x, int y) { 118 | if (x < 0 || x >= Config.WIDTH) return - 1; 119 | if (y < 0 || y >= Config.HEIGHT) return - 1; 120 | return boxes[x][y].getColor(); 121 | } 122 | 123 | private void moveFly(int sx, int sy) { 124 | hideFigure(); 125 | fly.moveFigure(sx, sy); 126 | showFigure(); 127 | } 128 | 129 | private void turnFly(int direction) { 130 | hideFigure(); 131 | fly.turnFigure(direction); 132 | showFigure(); 133 | } 134 | 135 | class KeyAdapter implements KeyListener { 136 | @Override 137 | public void keyTyped(KeyEvent e) {} 138 | 139 | @Override 140 | public void keyPressed(KeyEvent e) { 141 | 142 | switch (e.getKeyCode()) { 143 | case KeyEvent.VK_LEFT: moveFly(-1, 0); break; 144 | case KeyEvent.VK_RIGHT: moveFly(+1, 0); break; 145 | case KeyEvent.VK_UP: turnFly(1); break; 146 | case KeyEvent.VK_DOWN: turnFly(2); break; 147 | case KeyEvent.VK_U: moveFly(0, -1); break; 148 | case KeyEvent.VK_D: moveFly(0, +1); break; 149 | } 150 | } 151 | 152 | @Override 153 | public void keyReleased(KeyEvent e) {} 154 | } 155 | 156 | private void stripLines() { 157 | int counter = 0; 158 | for (int y = Config.HEIGHT - 1; y >= 0; --y) { 159 | while (isFullLine(y)) { 160 | counter++; 161 | dropLine(y); 162 | } 163 | } 164 | switch (counter) { 165 | case 1: 166 | infoWindow.updateLabel(100); 167 | break; 168 | case 2: 169 | infoWindow.updateLabel(200); 170 | break; 171 | case 3: 172 | infoWindow.updateLabel(700); 173 | break; 174 | case 4: 175 | infoWindow.updateLabel(1500); 176 | break; 177 | default: 178 | break; 179 | } 180 | } 181 | 182 | private void dropLine(int y) { 183 | for (int my = y - 1; my >= 0; --my) { 184 | for (int x = 0; x < Config.WIDTH; ++x) { 185 | setBoxColor(x, my + 1, getBoxColor(x, my)); 186 | } 187 | } 188 | for (int x = 0; x < Config.WIDTH; ++x) { 189 | setBoxColor(x, 0, 0); 190 | } 191 | } 192 | 193 | private boolean isFullLine(int y) { 194 | for (int x = 0; x < Config.WIDTH; ++x) { 195 | if (getBoxColor(x, y) != 2) { 196 | return false; 197 | } 198 | } 199 | return true; 200 | } 201 | 202 | class TimeAdapter implements ActionListener { 203 | 204 | @Override 205 | public void actionPerformed(ActionEvent e) { 206 | moveFly(0, 1); 207 | if (fly.isLanded()) { 208 | showFigure(2); 209 | stripLines(); 210 | addFigure(); 211 | } 212 | } 213 | } 214 | } 215 | -------------------------------------------------------------------------------- /src/ru/spbstu/Main.java: -------------------------------------------------------------------------------- 1 | package ru.spbstu; 2 | 3 | public class Main { 4 | 5 | public static void main(String[] args) { 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /target/classes/META-INF/TetrisTheGame.kotlin_module: -------------------------------------------------------------------------------- 1 |  -------------------------------------------------------------------------------- /target/classes/Tetris.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/paveldat/Tetris/4914f5eb57015d1686680ca9b8d39320f4083d42/target/classes/Tetris.class -------------------------------------------------------------------------------- /target/classes/model/Coord.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/paveldat/Tetris/4914f5eb57015d1686680ca9b8d39320f4083d42/target/classes/model/Coord.class -------------------------------------------------------------------------------- /target/classes/model/Figures$1.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/paveldat/Tetris/4914f5eb57015d1686680ca9b8d39320f4083d42/target/classes/model/Figures$1.class -------------------------------------------------------------------------------- /target/classes/model/Figures.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/paveldat/Tetris/4914f5eb57015d1686680ca9b8d39320f4083d42/target/classes/model/Figures.class -------------------------------------------------------------------------------- /target/classes/model/Mapable.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/paveldat/Tetris/4914f5eb57015d1686680ca9b8d39320f4083d42/target/classes/model/Mapable.class -------------------------------------------------------------------------------- /target/classes/model/Refreshable.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/paveldat/Tetris/4914f5eb57015d1686680ca9b8d39320f4083d42/target/classes/model/Refreshable.class -------------------------------------------------------------------------------- /target/classes/model/Startable.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/paveldat/Tetris/4914f5eb57015d1686680ca9b8d39320f4083d42/target/classes/model/Startable.class -------------------------------------------------------------------------------- /target/classes/service/FlyFigure.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/paveldat/Tetris/4914f5eb57015d1686680ca9b8d39320f4083d42/target/classes/service/FlyFigure.class -------------------------------------------------------------------------------- /target/classes/ui/Box.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/paveldat/Tetris/4914f5eb57015d1686680ca9b8d39320f4083d42/target/classes/ui/Box.class -------------------------------------------------------------------------------- /target/classes/ui/Config.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/paveldat/Tetris/4914f5eb57015d1686680ca9b8d39320f4083d42/target/classes/ui/Config.class -------------------------------------------------------------------------------- /target/classes/ui/InfoWindow.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/paveldat/Tetris/4914f5eb57015d1686680ca9b8d39320f4083d42/target/classes/ui/InfoWindow.class -------------------------------------------------------------------------------- /target/classes/ui/RefreshWindow$ButtonEventListener.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/paveldat/Tetris/4914f5eb57015d1686680ca9b8d39320f4083d42/target/classes/ui/RefreshWindow$ButtonEventListener.class -------------------------------------------------------------------------------- /target/classes/ui/RefreshWindow.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/paveldat/Tetris/4914f5eb57015d1686680ca9b8d39320f4083d42/target/classes/ui/RefreshWindow.class -------------------------------------------------------------------------------- /target/classes/ui/StartingWindow$ButtonEventListener.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/paveldat/Tetris/4914f5eb57015d1686680ca9b8d39320f4083d42/target/classes/ui/StartingWindow$ButtonEventListener.class -------------------------------------------------------------------------------- /target/classes/ui/StartingWindow.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/paveldat/Tetris/4914f5eb57015d1686680ca9b8d39320f4083d42/target/classes/ui/StartingWindow.class -------------------------------------------------------------------------------- /target/classes/ui/Window$KeyAdapter.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/paveldat/Tetris/4914f5eb57015d1686680ca9b8d39320f4083d42/target/classes/ui/Window$KeyAdapter.class -------------------------------------------------------------------------------- /target/classes/ui/Window$TimeAdapter.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/paveldat/Tetris/4914f5eb57015d1686680ca9b8d39320f4083d42/target/classes/ui/Window$TimeAdapter.class -------------------------------------------------------------------------------- /target/classes/ui/Window.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/paveldat/Tetris/4914f5eb57015d1686680ca9b8d39320f4083d42/target/classes/ui/Window.class --------------------------------------------------------------------------------