Source files: 42
Click here to show/hide file namesSource files:
detect/contractionLoop/original/game/JPacmanGame.java,
detect/contractionLoop/original/game/Game.java,
detect/contractionLoop/original/game/GameObject.java,
detect/contractionLoop/original/game/Item.java,
detect/contractionLoop/original/map/Path.java,
detect/contractionLoop/original/map/Map.java,
detect/contractionLoop/original/map/PathFinder.java,
detect/contractionLoop/original/util/RequestedDirectionBuffer.java,
detect/contractionLoop/original/util/Direction.java,
detect/contractionLoop/original/editor/EditorFrame.java,
detect/contractionLoop/original/editor/EditorMarker.java,
detect/contractionLoop/original/actors/Actor.java,
detect/contractionLoop/original/actors/Player.java,
detect/contractionLoop/original/actors/Ghost.java,
detect/contractionLoop/original/state/StateEditor.java,
detect/contractionLoop/original/state/State.java,
detect/contractionLoop/original/state/StateMenu.java,
detect/contractionLoop/original/state/StateGame.java,
detect/contractionLoop/original/state/StateScoreboard.java,
detect/contractionLoop/original/ai/AIManager.java,
detect/contractionLoop/original/ai/AStarHeuristic.java,
detect/contractionLoop/contractionLoop/game/JPacmanGame.java,
detect/contractionLoop/contractionLoop/game/Game.java,
detect/contractionLoop/contractionLoop/game/GameObject.java,
detect/contractionLoop/contractionLoop/game/Item.java,
detect/contractionLoop/contractionLoop/map/Path.java,
detect/contractionLoop/contractionLoop/map/Map.java,
detect/contractionLoop/contractionLoop/map/PathFinder.java,
detect/contractionLoop/contractionLoop/util/RequestedDirectionBuffer.java,
detect/contractionLoop/contractionLoop/util/Direction.java,
detect/contractionLoop/contractionLoop/editor/EditorFrame.java,
detect/contractionLoop/contractionLoop/editor/EditorMarker.java,
detect/contractionLoop/contractionLoop/actors/Actor.java,
detect/contractionLoop/contractionLoop/actors/Player.java,
detect/contractionLoop/contractionLoop/actors/Ghost.java,
detect/contractionLoop/contractionLoop/state/StateEditor.java,
detect/contractionLoop/contractionLoop/state/State.java,
detect/contractionLoop/contractionLoop/state/StateMenu.java,
detect/contractionLoop/contractionLoop/state/StateGame.java,
detect/contractionLoop/contractionLoop/state/StateScoreboard.java,
detect/contractionLoop/contractionLoop/ai/AIManager.java,
detect/contractionLoop/contractionLoop/ai/AStarHeuristic.java
Clones detected: 58
2436 of 3570 lines are duplicates (68.24%)
Parameters
clustering_threshold = 10
distance_threshold = 200
size_threshold = 10
hashing_depth = 1
clusterize_using_hash = False
clusterize_using_dcup = False
Clone # 1
Distance between two fragments = 0
Clone size = 226
Source file "detect/contractionLoop/contractionLoop/editor/EditorFrame.java" The first line is 37 | Source file "detect/contractionLoop/original/editor/EditorFrame.java" The first line is 37 | |
public class EditorFrame extends javax.swing.JFrame { private static final long serialVersionUID = 1L; private final StateEditor editor; private JMenuItem jItemSaveAs; private JTextArea txtTeleportY; private JTextField txtTeleportX; private JLabel lblTeleportY; private JLabel lblTeleportX; private JLabel lblTeleportSettings; private JButton btnTeleport; private JButton btnNew; private JTextField txtFilename; private JButton btnLoad; private JButton btnSave; private JComboBox jWallTypeCombo; private JButton btnGhost; private JComboBox comboGhost; private JCheckBox chkGhostTrapped; private JLabel lblGhosts; private JButton btnPowerup; private JLabel jWallTypeLabel; private JMenuItem jItemExit; private JSeparator jSeperatorFile; private JMenuItem jItemSave; private JMenuItem jItemLoad; private JMenu jMenuFile; private JMenuBar jMenuBar1; private JLabel lblPlaceableObjs; private JSeparator jSeparator1; private JButton btnPacman; private JButton btnDot; private JButton btnWall; public EditorFrame(StateEditor e) { super(); editor = e; initGUI(); } private void initGUI() { try { setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE); getContentPane().setLayout(null); this.setTitle("Pacman Map Editor - Ramsey Kant"); this.addWindowListener(new WindowAdapter() { @Override public void windowClosed(WindowEvent evt) { editor.getGame().requestChangeState(State.STATE_EXITING); } }); { jMenuBar1 = new JMenuBar(); setJMenuBar(jMenuBar1); { jMenuFile = new JMenu(); jMenuBar1.add(jMenuFile); jMenuFile.setText("File"); { jItemLoad = new JMenuItem(); jMenuFile.add(jItemLoad); jItemLoad.setText("Load"); } { jItemSave = new JMenuItem(); jMenuFile.add(jItemSave); jItemSave.setText("Save"); } { jItemSaveAs = new JMenuItem(); jMenuFile.add(jItemSaveAs); jItemSaveAs.setText("Save As.."); } { jSeperatorFile = new JSeparator(); jMenuFile.add(jSeperatorFile); } { jItemExit = new JMenuItem(); jMenuFile.add(jItemExit); jItemExit.setText("Exit"); } } } { btnWall = new JButton(); getContentPane().add(btnWall); btnWall.setText("Wall"); btnWall.setBounds(12, 218, 59, 23); btnWall.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent evt) { editor.setMarkerObjectType(GameObject.OBJECT_WALL); } }); } { btnDot = new JButton(); getContentPane().add(btnDot); btnDot.setText("Dot"); btnDot.setBounds(12, 36, 59, 23); btnDot.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent evt) { editor.setMarkerObjectType(GameObject.OBJECT_DOT); } }); } { btnPacman = new JButton(); getContentPane().add(btnPacman); btnPacman.setText("Pacman"); btnPacman.setBounds(136, 36, 110, 23); btnPacman.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent evt) { editor.setMarkerObjectType(GameObject.OBJECT_PLAYER); } }); } { jSeparator1 = new JSeparator(); getContentPane().add(jSeparator1); jSeparator1.setBounds(12, 301, 360, 10); } { lblPlaceableObjs = new JLabel(); getContentPane().add(lblPlaceableObjs); lblPlaceableObjs.setText("Placeable Objects"); lblPlaceableObjs.setBounds(12, 12, 129, 16); } { jWallTypeLabel = new JLabel(); getContentPane().add(jWallTypeLabel); jWallTypeLabel.setText("Wall Type"); jWallTypeLabel.setBounds(12, 196, 82, 16); } { final ComboBoxModel jWallTypeComboModel = new DefaultComboBoxModel(new String[] { "Vertical", "Horizontal", "Top Left", "Top Right", "Bottom Left", "Bottom Right", "Ghost Barrier" }); jWallTypeCombo = new JComboBox(); getContentPane().add(jWallTypeCombo); jWallTypeCombo.setModel(jWallTypeComboModel); jWallTypeCombo.setBounds(12, 246, 153, 23); jWallTypeCombo.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent evt) { final String sType = (String) jWallTypeCombo.getSelectedItem(); if (sType.equals("Vertical")) { editor.setMarkerWallType(GameObject.WALL_VERTICAL); } else if (sType.equals("Horizontal")) { editor.setMarkerWallType(GameObject.WALL_HORIZONTAL); } else if (sType.equals("Top Left")) { editor.setMarkerWallType(GameObject.WALL_TOPLEFT); } else if (sType.equals("Top Right")) { editor.setMarkerWallType(GameObject.WALL_TOPRIGHT); } else if (sType.equals("Bottom Left")) { editor.setMarkerWallType(GameObject.WALL_BOTTOMLEFT); } else if (sType.equals("Bottom Right")) { editor.setMarkerWallType(GameObject.WALL_BOTTOMRIGHT); } else if (sType.equals("Ghost Barrier")) { editor.setMarkerWallType(GameObject.WALL_GHOSTBARRIER); } else { editor.setMarkerWallType(GameObject.WALL_HORIZONTAL); } } }); } { btnSave = new JButton(); getContentPane().add(btnSave); btnSave.setText("Save"); btnSave.setBounds(12, 317, 70, 23); btnSave.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent evt) { editor.saveMap(txtFilename.getText()); } }); } { btnLoad = new JButton(); getContentPane().add(btnLoad); btnLoad.setText("Load"); btnLoad.setBounds(87, 317, 68, 23); btnLoad.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent evt) { editor.loadMap(txtFilename.getText()); } }); } { txtFilename = new JTextField(); getContentPane().add(txtFilename); txtFilename.setBounds(12, 345, 225, 23); txtFilename.setText("test.map"); } { btnNew = new JButton(); getContentPane().add(btnNew); btnNew.setText("New"); btnNew.setBounds(160, 317, 71, 23); btnNew.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent evt) { editor.newMap(28, 31); } }); } { btnTeleport = new JButton(); getContentPane().add(btnTeleport); btnTeleport.setText("Teleport"); btnTeleport.setBounds(237, 218, 110, 23); btnTeleport.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent evt) { editor.setMarkerObjectType(GameObject.OBJECT_TELEPORT); editor.setMarkerTeleport(Integer.parseInt(txtTeleportX.getText()), Integer.parseInt(txtTeleportY.getText())); } }); } { lblTeleportSettings = new JLabel(); getContentPane().add(lblTeleportSettings); lblTeleportSettings.setText("Teleport Settings"); lblTeleportSettings.setBounds(237, 196, 123, 16); } { lblTeleportX = new JLabel(); getContentPane().add(lblTeleportX); lblTeleportX.setText("Dest X:"); lblTeleportX.setBounds(237, 249, 60, 16); } { lblTeleportY = new JLabel(); getContentPane().add(lblTeleportY); lblTeleportY.setText("Dest Y: "); lblTeleportY.setBounds(235, 279, 52, 16); } { txtTeleportX = new JTextField(); getContentPane().add(txtTeleportX); txtTeleportX.setText("13"); txtTeleportX.setBounds(280, 246, 85, 23); } { txtTeleportY = new JTextArea(); getContentPane().add(txtTeleportY); txtTeleportY.setText("17"); txtTeleportY.setBounds(280, 275, 82, 20); } { btnPowerup = new JButton(); getContentPane().add(btnPowerup); btnPowerup.setText("Powerup"); btnPowerup.setBounds(12, 65, 102, 23); btnPowerup.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent evt) { editor.setMarkerObjectType(GameObject.OBJECT_POWERUP); } }); } { lblGhosts = new JLabel(); getContentPane().add(lblGhosts); lblGhosts.setText("Ghost Settings"); lblGhosts.setBounds(272, 12, 76, 16); } { chkGhostTrapped = new JCheckBox(); getContentPane().add(chkGhostTrapped); chkGhostTrapped.setText("Trapped"); chkGhostTrapped.setBounds(360, 10, 100, 20); chkGhostTrapped.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent evt) { editor.setMarkerGhostTrapped(!editor.getMarkerGhostTrapped()); System.out.println(editor.getMarkerGhostTrapped()); } }); } { final ComboBoxModel comboGhostModel = new DefaultComboBoxModel(new String[] { "Blinky", "Pinky", "Inky", "Clyde" }); comboGhost = new JComboBox(); getContentPane().add(comboGhost); comboGhost.setModel(comboGhostModel); comboGhost.setBounds(272, 65, 146, 23); comboGhost.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent evt) { final String sType = (String) comboGhost.getSelectedItem(); editor.setMarkerGhostType(sType); } }); } { btnGhost = new JButton(); getContentPane().add(btnGhost); btnGhost.setText("Add Ghost"); btnGhost.setBounds(272, 36, 146, 23); btnGhost.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent evt) { editor.setMarkerObjectType(GameObject.OBJECT_GHOST); } }); } pack(); this.setSize(451, 547); } catch (final Exception e) { // add your error handling code here e.printStackTrace(); |
public class EditorFrame extends javax.swing.JFrame { private static final long serialVersionUID = 1L; private final StateEditor editor; private JMenuItem jItemSaveAs; private JTextArea txtTeleportY; private JTextField txtTeleportX; private JLabel lblTeleportY; private JLabel lblTeleportX; private JLabel lblTeleportSettings; private JButton btnTeleport; private JButton btnNew; private JTextField txtFilename; private JButton btnLoad; private JButton btnSave; private JComboBox jWallTypeCombo; private JButton btnGhost; private JComboBox comboGhost; private JCheckBox chkGhostTrapped; private JLabel lblGhosts; private JButton btnPowerup; private JLabel jWallTypeLabel; private JMenuItem jItemExit; private JSeparator jSeperatorFile; private JMenuItem jItemSave; private JMenuItem jItemLoad; private JMenu jMenuFile; private JMenuBar jMenuBar1; private JLabel lblPlaceableObjs; private JSeparator jSeparator1; private JButton btnPacman; private JButton btnDot; private JButton btnWall; public EditorFrame(StateEditor e) { super(); editor = e; initGUI(); } private void initGUI() { try { setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE); getContentPane().setLayout(null); this.setTitle("Pacman Map Editor - Ramsey Kant"); this.addWindowListener(new WindowAdapter() { @Override public void windowClosed(WindowEvent evt) { editor.getGame().requestChangeState(State.STATE_EXITING); } }); { jMenuBar1 = new JMenuBar(); setJMenuBar(jMenuBar1); { jMenuFile = new JMenu(); jMenuBar1.add(jMenuFile); jMenuFile.setText("File"); { jItemLoad = new JMenuItem(); jMenuFile.add(jItemLoad); jItemLoad.setText("Load"); } { jItemSave = new JMenuItem(); jMenuFile.add(jItemSave); jItemSave.setText("Save"); } { jItemSaveAs = new JMenuItem(); jMenuFile.add(jItemSaveAs); jItemSaveAs.setText("Save As.."); } { jSeperatorFile = new JSeparator(); jMenuFile.add(jSeperatorFile); } { jItemExit = new JMenuItem(); jMenuFile.add(jItemExit); jItemExit.setText("Exit"); } } } { btnWall = new JButton(); getContentPane().add(btnWall); btnWall.setText("Wall"); btnWall.setBounds(12, 218, 59, 23); btnWall.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent evt) { editor.setMarkerObjectType(GameObject.OBJECT_WALL); } }); } { btnDot = new JButton(); getContentPane().add(btnDot); btnDot.setText("Dot"); btnDot.setBounds(12, 36, 59, 23); btnDot.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent evt) { editor.setMarkerObjectType(GameObject.OBJECT_DOT); } }); } { btnPacman = new JButton(); getContentPane().add(btnPacman); btnPacman.setText("Pacman"); btnPacman.setBounds(136, 36, 110, 23); btnPacman.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent evt) { editor.setMarkerObjectType(GameObject.OBJECT_PLAYER); } }); } { jSeparator1 = new JSeparator(); getContentPane().add(jSeparator1); jSeparator1.setBounds(12, 301, 360, 10); } { lblPlaceableObjs = new JLabel(); getContentPane().add(lblPlaceableObjs); lblPlaceableObjs.setText("Placeable Objects"); lblPlaceableObjs.setBounds(12, 12, 129, 16); } { jWallTypeLabel = new JLabel(); getContentPane().add(jWallTypeLabel); jWallTypeLabel.setText("Wall Type"); jWallTypeLabel.setBounds(12, 196, 82, 16); } { final ComboBoxModel jWallTypeComboModel = new DefaultComboBoxModel(new String[] { "Vertical", "Horizontal", "Top Left", "Top Right", "Bottom Left", "Bottom Right", "Ghost Barrier" }); jWallTypeCombo = new JComboBox(); getContentPane().add(jWallTypeCombo); jWallTypeCombo.setModel(jWallTypeComboModel); jWallTypeCombo.setBounds(12, 246, 153, 23); jWallTypeCombo.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent evt) { final String sType = (String) jWallTypeCombo.getSelectedItem(); if (sType.equals("Vertical")) { editor.setMarkerWallType(GameObject.WALL_VERTICAL); } else if (sType.equals("Horizontal")) { editor.setMarkerWallType(GameObject.WALL_HORIZONTAL); } else if (sType.equals("Top Left")) { editor.setMarkerWallType(GameObject.WALL_TOPLEFT); } else if (sType.equals("Top Right")) { editor.setMarkerWallType(GameObject.WALL_TOPRIGHT); } else if (sType.equals("Bottom Left")) { editor.setMarkerWallType(GameObject.WALL_BOTTOMLEFT); } else if (sType.equals("Bottom Right")) { editor.setMarkerWallType(GameObject.WALL_BOTTOMRIGHT); } else if (sType.equals("Ghost Barrier")) { editor.setMarkerWallType(GameObject.WALL_GHOSTBARRIER); } else { editor.setMarkerWallType(GameObject.WALL_HORIZONTAL); } } }); } { btnSave = new JButton(); getContentPane().add(btnSave); btnSave.setText("Save"); btnSave.setBounds(12, 317, 70, 23); btnSave.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent evt) { editor.saveMap(txtFilename.getText()); } }); } { btnLoad = new JButton(); getContentPane().add(btnLoad); btnLoad.setText("Load"); btnLoad.setBounds(87, 317, 68, 23); btnLoad.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent evt) { editor.loadMap(txtFilename.getText()); } }); } { txtFilename = new JTextField(); getContentPane().add(txtFilename); txtFilename.setBounds(12, 345, 225, 23); txtFilename.setText("test.map"); } { btnNew = new JButton(); getContentPane().add(btnNew); btnNew.setText("New"); btnNew.setBounds(160, 317, 71, 23); btnNew.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent evt) { editor.newMap(28, 31); } }); } { btnTeleport = new JButton(); getContentPane().add(btnTeleport); btnTeleport.setText("Teleport"); btnTeleport.setBounds(237, 218, 110, 23); btnTeleport.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent evt) { editor.setMarkerObjectType(GameObject.OBJECT_TELEPORT); editor.setMarkerTeleport(Integer.parseInt(txtTeleportX.getText()), Integer.parseInt(txtTeleportY.getText())); } }); } { lblTeleportSettings = new JLabel(); getContentPane().add(lblTeleportSettings); lblTeleportSettings.setText("Teleport Settings"); lblTeleportSettings.setBounds(237, 196, 123, 16); } { lblTeleportX = new JLabel(); getContentPane().add(lblTeleportX); lblTeleportX.setText("Dest X:"); lblTeleportX.setBounds(237, 249, 60, 16); } { lblTeleportY = new JLabel(); getContentPane().add(lblTeleportY); lblTeleportY.setText("Dest Y: "); lblTeleportY.setBounds(235, 279, 52, 16); } { txtTeleportX = new JTextField(); getContentPane().add(txtTeleportX); txtTeleportX.setText("13"); txtTeleportX.setBounds(280, 246, 85, 23); } { txtTeleportY = new JTextArea(); getContentPane().add(txtTeleportY); txtTeleportY.setText("17"); txtTeleportY.setBounds(280, 275, 82, 20); } { btnPowerup = new JButton(); getContentPane().add(btnPowerup); btnPowerup.setText("Powerup"); btnPowerup.setBounds(12, 65, 102, 23); btnPowerup.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent evt) { editor.setMarkerObjectType(GameObject.OBJECT_POWERUP); } }); } { lblGhosts = new JLabel(); getContentPane().add(lblGhosts); lblGhosts.setText("Ghost Settings"); lblGhosts.setBounds(272, 12, 76, 16); } { chkGhostTrapped = new JCheckBox(); getContentPane().add(chkGhostTrapped); chkGhostTrapped.setText("Trapped"); chkGhostTrapped.setBounds(360, 10, 100, 20); chkGhostTrapped.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent evt) { editor.setMarkerGhostTrapped(!editor.getMarkerGhostTrapped()); System.out.println(editor.getMarkerGhostTrapped()); } }); } { final ComboBoxModel comboGhostModel = new DefaultComboBoxModel(new String[] { "Blinky", "Pinky", "Inky", "Clyde" }); comboGhost = new JComboBox(); getContentPane().add(comboGhost); comboGhost.setModel(comboGhostModel); comboGhost.setBounds(272, 65, 146, 23); comboGhost.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent evt) { final String sType = (String) comboGhost.getSelectedItem(); editor.setMarkerGhostType(sType); } }); } { btnGhost = new JButton(); getContentPane().add(btnGhost); btnGhost.setText("Add Ghost"); btnGhost.setBounds(272, 36, 146, 23); btnGhost.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent evt) { editor.setMarkerObjectType(GameObject.OBJECT_GHOST); } }); } pack(); this.setSize(451, 547); } catch (final Exception e) { // add your error handling code here e.printStackTrace(); |
Clone # 2
Distance between two fragments = 0
Clone size = 84
Source file "detect/contractionLoop/contractionLoop/state/StateMenu.java" The first line is 19 | Source file "detect/contractionLoop/original/state/StateMenu.java" The first line is 19 | |
public class StateMenu extends State { // Private instance private int cursorX; private int cursorY; private byte currentOption; private byte currentMapOption; // Corresponds to the index in mapList private String[] mapList; public StateMenu(Game g) { super(g); } @Override public void reset() { // Set cursor & menu position cursorX = 380; cursorY = 310; currentOption = 0; currentMapOption = 0; // Load the map list final File dir = new File(System.getProperty("user.dir")); // It is also possible to filter the list of returned files. // This example does not return any files that start with `.'. final FilenameFilter filter = new FilenameFilter() { @Override public boolean accept(File dir, String name) { return name.endsWith(".map"); } }; // Apply the filter mapList = dir.list(filter); if (mapList == null) { System.out.println("No maps exist!"); game.requestChangeState(STATE_EXITING); return; } } /** * Cleanup Menu objects * * @see State#end() */ @Override public void end() { // do nothing } /** * Logic processing for the Menu. Rendering, Input, screen pointer * manipulation * * @see State#logic() */ @Override public void logic() { final Graphics2D g = game.getGraphicsContext(); // Draw title g.setColor(Color.YELLOW); g.setFont(new Font("Comic Sans MS", Font.BOLD, 50)); g.fillArc(56, 92, 100, 100, 35, 270); // First pacman g.drawString("PACMAN", 350, 180); g.fillArc(780, 92, 100, 100, 35, 270); // Draw menu options g.setFont(new Font("Comic Sans MS", Font.BOLD, 24)); g.drawString("Play Game", 380, 300); //g.drawString("Map Editor", 525, 340); g.drawString("Scoreboard", 380, 340); g.drawString("Exit", 380, 380); if (mapList.length > 0) { g.drawString("Current Map: " + mapList[currentMapOption], 380, 600); } else { g.drawString( "No maps detected. Have you placed the maps file in the same directory as the program?", 100, 600); } // Draw underline cursor g.setColor(Color.RED); g.fillRect(cursorX, cursorY, 150, 5); } @Override public void keyPressed(KeyEvent e) { switch (e.getKeyCode()) { case KeyEvent.VK_RIGHT: if (currentMapOption >= 0 && currentMapOption < (mapList.length - 1)) { currentMapOption++; } break; case KeyEvent.VK_LEFT: if (currentMapOption > 0 && currentMapOption <= (mapList.length - 1)) { currentMapOption--; } break; case KeyEvent.VK_DOWN: if (currentOption >= 0 && currentOption < 2) { currentOption++; cursorY += 38; } break; case KeyEvent.VK_UP: if (currentOption > 0 && currentOption <= 2) { currentOption--; cursorY -= 38; } break; case KeyEvent.VK_ENTER: // Execute the appropriate state change switch (currentOption) { case 0: // Play game if (mapList.length > 0) { game.setStartMap(mapList[currentMapOption]); game.requestChangeState(STATE_GAME); } break; case 1: // Scoreboard game.requestChangeState(STATE_SCOREBOARD); break; case 2: // Exit game.requestChangeState(STATE_EXITING); break; default: break; } break; default: break; |
public class StateMenu extends State { // Private instance private int cursorX; private int cursorY; private byte currentOption; private byte currentMapOption; // Corresponds to the index in mapList private String[] mapList; public StateMenu(Game g) { super(g); } @Override public void reset() { // Set cursor & menu position cursorX = 380; cursorY = 310; currentOption = 0; currentMapOption = 0; // Load the map list final File dir = new File(System.getProperty("user.dir")); // It is also possible to filter the list of returned files. // This example does not return any files that start with `.'. final FilenameFilter filter = new FilenameFilter() { @Override public boolean accept(File dir, String name) { return name.endsWith(".map"); } }; // Apply the filter mapList = dir.list(filter); if (mapList == null) { System.out.println("No maps exist!"); game.requestChangeState(STATE_EXITING); return; } } /** * Cleanup Menu objects * * @see State#end() */ @Override public void end() { // do nothing } /** * Logic processing for the Menu. Rendering, Input, screen pointer * manipulation * * @see State#logic() */ @Override public void logic() { final Graphics2D g = game.getGraphicsContext(); // Draw title g.setColor(Color.YELLOW); g.setFont(new Font("Comic Sans MS", Font.BOLD, 50)); g.fillArc(56, 92, 100, 100, 35, 270); // First pacman g.drawString("PACMAN", 350, 180); g.fillArc(780, 92, 100, 100, 35, 270); // Draw menu options g.setFont(new Font("Comic Sans MS", Font.BOLD, 24)); g.drawString("Play Game", 380, 300); //g.drawString("Map Editor", 525, 340); g.drawString("Scoreboard", 380, 340); g.drawString("Exit", 380, 380); if (mapList.length > 0) { g.drawString("Current Map: " + mapList[currentMapOption], 380, 600); } else { g.drawString( "No maps detected. Have you placed the maps file in the same directory as the program?", 100, 600); } // Draw underline cursor g.setColor(Color.RED); g.fillRect(cursorX, cursorY, 150, 5); } @Override public void keyPressed(KeyEvent e) { switch (e.getKeyCode()) { case KeyEvent.VK_RIGHT: if (currentMapOption >= 0 && currentMapOption < (mapList.length - 1)) { currentMapOption++; } break; case KeyEvent.VK_LEFT: if (currentMapOption > 0 && currentMapOption <= (mapList.length - 1)) { currentMapOption--; } break; case KeyEvent.VK_DOWN: if (currentOption >= 0 && currentOption < 2) { currentOption++; cursorY += 38; } break; case KeyEvent.VK_UP: if (currentOption > 0 && currentOption <= 2) { currentOption--; cursorY -= 38; } break; case KeyEvent.VK_ENTER: // Execute the appropriate state change switch (currentOption) { case 0: // Play game if (mapList.length > 0) { game.setStartMap(mapList[currentMapOption]); game.requestChangeState(STATE_GAME); } break; case 1: // Scoreboard game.requestChangeState(STATE_SCOREBOARD); break; case 2: // Exit game.requestChangeState(STATE_EXITING); break; default: break; } break; default: break; |
Clone # 3
Distance between two fragments = 0
Clone size = 76
Source file "detect/contractionLoop/original/map/Map.java" The first line is 99 | Source file "detect/contractionLoop/contractionLoop/map/Map.java" The first line is 99 | |
public int getWidth() { return mapWidth; |
public int getWidth() { return mapWidth; |
|
public int getHeight() { return mapHeight; |
public int getHeight() { return mapHeight; |
|
public int getNumActors() { return actorList.size(); |
public int getNumActors() { return actorList.size(); |
|
public byte[][] getCollidableMap() { return collideMap; |
public byte[][] getCollidableMap() { return collideMap; |
|
public Item[][] getItemMap() { return itemMap; |
public Item[][] getItemMap() { return itemMap; |
|
public int getDotsRemaining() { return dotsRemaining; |
public int getDotsRemaining() { return dotsRemaining; |
|
public boolean addCollidable(int x, int y, byte t) { // Check bounds if (x < 0 || y < 0 || x >= mapWidth || y >= mapHeight) { return false; } // Check if theres already something there if (collideMap[x][y] > 0) { return false; } // Add to the collideMap collideMap[x][y] = t; return true; |
public boolean addCollidable(int x, int y, byte t) { // Check bounds if (x < 0 || y < 0 || x >= mapWidth || y >= mapHeight) { return false; } // Check if theres already something there if (collideMap[x][y] > 0) { return false; } // Add to the collideMap collideMap[x][y] = t; return true; |
|
public boolean addItem(Item item) { if (item == null) { return false; } // Check bounds final int x = item.getX(); final int y = item.getY(); if (x < 0 || y < 0 || x >= mapWidth || y >= mapHeight) { return false; } // Add to the itemMap if (item.getType() == GameObject.OBJECT_DOT) { dotsRemaining++; } itemMap[x][y] = item; return true; |
public boolean addItem(Item item) { if (item == null) { return false; } // Check bounds final int x = item.getX(); final int y = item.getY(); if (x < 0 || y < 0 || x >= mapWidth || y >= mapHeight) { return false; } // Add to the itemMap if (item.getType() == GameObject.OBJECT_DOT) { dotsRemaining++; } itemMap[x][y] = item; return true; |
|
public boolean addActor(Actor act) { if (act == null) { return false; } // Check bounds final int x = act.getX(); final int y = act.getY(); if (x < 0 || y < 0 || x >= mapWidth || y >= mapHeight) { return false; } // Add to the array list actorList.add(act); return true; |
public boolean addActor(Actor act) { if (act == null) { return false; } // Check bounds final int x = act.getX(); final int y = act.getY(); if (x < 0 || y < 0 || x >= mapWidth || y >= mapHeight) { return false; } // Add to the array list actorList.add(act); return true; |
|
public byte getCollidable(int x, int y) { // Check bounds if (x < 0 || y < 0 || x >= mapWidth || y >= mapHeight) { return -1; } return collideMap[x][y]; |
public byte getCollidable(int x, int y) { // Check bounds if (x < 0 || y < 0 || x >= mapWidth || y >= mapHeight) { return -1; } return collideMap[x][y]; |
|
public Item getItem(int x, int y) { // Check bounds if (x < 0 || y < 0 || x >= mapWidth || y >= mapHeight) { return null; } return itemMap[x][y]; |
public Item getItem(int x, int y) { // Check bounds if (x < 0 || y < 0 || x >= mapWidth || y >= mapHeight) { return null; } return itemMap[x][y]; |
|
public Actor getActor(int idx) { Actor act = null; try { act = actorList.get(idx); } catch (final IndexOutOfBoundsException e) { e.printStackTrace(); } return act; |
public Actor getActor(int idx) { Actor act = null; try { act = actorList.get(idx); } catch (final IndexOutOfBoundsException e) { e.printStackTrace(); } return act; |
|
public Player getPlayer() { // Get from the object map for (final Actor g : actorList) { if (g.getType() == GameObject.OBJECT_PLAYER) { return (Player) g; } } return null; |
public Player getPlayer() { // Get from the object map for (final Actor g : actorList) { if (g.getType() == GameObject.OBJECT_PLAYER) { return (Player) g; } } return null; |
|
public Actor getActor(int x, int y, boolean notPlayer) { // Check bounds if (x < 0 || y < 0 || x >= mapWidth || y >= mapHeight) { return null; } // Get from the object map for (final Actor g : actorList) { if (notPlayer && g.getType() == GameObject.OBJECT_PLAYER) { continue; } if (g.getX() == x && g.getY() == y) { return g; } } return null; |
public Actor getActor(int x, int y, boolean notPlayer) { // Check bounds if (x < 0 || y < 0 || x >= mapWidth || y >= mapHeight) { return null; } // Get from the object map for (final Actor g : actorList) { if (notPlayer && g.getType() == GameObject.OBJECT_PLAYER) { continue; } if (g.getX() == x && g.getY() == y) { return g; } } return null; |
|
public void removeActor(int idx) { actorList.remove(idx); |
public void removeActor(int idx) { actorList.remove(idx); |
|
public void removeItem(int x, int y) { // Check bounds if (x < 0 || y < 0 || x >= mapWidth || y >= mapHeight) { return; } if (itemMap[x][y].getType() == GameObject.OBJECT_DOT) { dotsRemaining--; } itemMap[x][y] = null; |
public void removeItem(int x, int y) { // Check bounds if (x < 0 || y < 0 || x >= mapWidth || y >= mapHeight) { return; } if (itemMap[x][y].getType() == GameObject.OBJECT_DOT) { dotsRemaining--; } itemMap[x][y] = null; |
Clone # 4
Distance between two fragments = 0
Clone size = 62
Source file "detect/contractionLoop/contractionLoop/map/PathFinder.java" The first line is 203 | Source file "detect/contractionLoop/original/map/PathFinder.java" The first line is 240 | |
protected Node getFirstInOpen() { return (Node) open.first(); |
protected Node getFirstInOpen() { return (Node) open.first(); |
|
protected void addToOpen(Node node) { open.add(node); |
protected void addToOpen(Node node) { open.add(node); |
|
protected boolean inOpenList(Node node) { return open.contains(node); |
protected boolean inOpenList(Node node) { return open.contains(node); |
|
protected void removeFromOpen(Node node) { open.remove(node); |
protected void removeFromOpen(Node node) { open.remove(node); |
|
protected void addToClosed(Node node) { closed.add(node); |
protected void addToClosed(Node node) { closed.add(node); |
|
protected boolean inClosedList(Node node) { return closed.contains(node); |
protected boolean inClosedList(Node node) { return closed.contains(node); |
|
protected void removeFromClosed(Node node) { closed.remove(node); |
protected void removeFromClosed(Node node) { closed.remove(node); |
|
protected boolean isValidLocation(Actor mover, int sx, int sy, int x, int y) { boolean invalid = (x < 0) || (y < 0) || (x >= map.getWidth()) || (y >= map.getHeight()); if ((!invalid) && ((sx != x) || (sy != y))) { invalid = map.canMove(mover, x, y) == false; } return !invalid; |
protected boolean isValidLocation(Actor mover, int sx, int sy, int x, int y) { boolean invalid = (x < 0) || (y < 0) || (x >= map.getWidth()) || (y >= map.getHeight()); if ((!invalid) && ((sx != x) || (sy != y))) { invalid = map.canMove(mover, x, y) == false; } return !invalid; |
|
public float getMovementCost(Actor mover, int sx, int sy, int tx, int ty) { return map.getCost(mover, sx, sy, tx, ty); |
public float getMovementCost(Actor mover, int sx, int sy, int tx, int ty) { return map.getCost(mover, sx, sy, tx, ty); |
|
public float getHeuristicCost(Actor mover, int x, int y, int tx, int ty) { return heuristic.getCost(map, mover, x, y, tx, ty); |
public float getHeuristicCost(Actor mover, int x, int y, int tx, int ty) { return heuristic.getCost(map, mover, x, y, tx, ty); |
|
private class SortedNodeList { /** The list of elements */ private final ArrayList<Node> list = new ArrayList<Node>(); /** * Retrieve the first element from the list * * @return The first element from the list */ public Object first() { return list.get(0); } /** * Empty the list */ public void clear() { list.clear(); } /** * Add an element to the list - causes sorting * * @param o * The element to add */ public void add(Node o) { list.add(o); Collections.sort(list); } /** * Remove an element from the list * * @param o * The element to remove */ public void remove(Object o) { list.remove(o); } /** * Get the number of elements in the list * * @return The number of element in the list */ public int size() { return list.size(); } /** * Check if an element is in the list * * @param o * The element to search for * @return True if the element is in the list */ public boolean contains(Object o) { return list.contains(o); |
private class SortedNodeList { /** The list of elements */ private final ArrayList<Node> list = new ArrayList<Node>(); /** * Retrieve the first element from the list * * @return The first element from the list */ public Object first() { return list.get(0); } /** * Empty the list */ public void clear() { list.clear(); } /** * Add an element to the list - causes sorting * * @param o * The element to add */ public void add(Node o) { list.add(o); Collections.sort(list); } /** * Remove an element from the list * * @param o * The element to remove */ public void remove(Object o) { list.remove(o); } /** * Get the number of elements in the list * * @return The number of element in the list */ public int size() { return list.size(); } /** * Check if an element is in the list * * @param o * The element to search for * @return True if the element is in the list */ public boolean contains(Object o) { return list.contains(o); |
|
private class Node implements Comparable<Object> { /** The x coordinate of the node */ private final int x; /** The y coordinate of the node */ private final int y; /** The path cost for this node */ private float cost; /** The parent of this node, how we reached it in the search */ private Node parent; /** The heuristic cost of this node */ private float nodeHeuristic; /** The search depth of this node */ private int depth; /** * Create a new node * * @param x * The x coordinate of the node * @param y * The y coordinate of the node */ public Node(int x, int y) { this.x = x; this.y = y; } /** * Set the parent of this node * * @param parent * The parent node which lead us to this node * @return The depth we have no reached in searching */ public int setParent(Node parent) { depth = parent.depth + 1; this.parent = parent; return depth; } /** * @see Comparable#compareTo(Object) */ @Override public int compareTo(Object other) { final Node o = (Node) other; final float f = nodeHeuristic + cost; final float of = o.nodeHeuristic + o.cost; if (f < of) { return -1; } else if (f > of) { return 1; } else { return 0; |
private class Node implements Comparable<Object> { /** The x coordinate of the node */ private final int x; /** The y coordinate of the node */ private final int y; /** The path cost for this node */ private float cost; /** The parent of this node, how we reached it in the search */ private Node parent; /** The heuristic cost of this node */ private float nodeHeuristic; /** The search depth of this node */ private int depth; /** * Create a new node * * @param x * The x coordinate of the node * @param y * The y coordinate of the node */ public Node(int x, int y) { this.x = x; this.y = y; } /** * Set the parent of this node * * @param parent * The parent node which lead us to this node * @return The depth we have no reached in searching */ public int setParent(Node parent) { depth = parent.depth + 1; this.parent = parent; return depth; } /** * @see Comparable#compareTo(Object) */ @Override public int compareTo(Object other) { final Node o = (Node) other; final float f = nodeHeuristic + cost; final float of = o.nodeHeuristic + o.cost; if (f < of) { return -1; } else if (f > of) { return 1; } else { return 0; |
Clone # 5
Distance between two fragments = 0
Clone size = 59
Source file "detect/contractionLoop/original/state/StateGame.java" The first line is 189 | Source file "detect/contractionLoop/contractionLoop/state/StateGame.java" The first line is 192 | |
final byte sType = map.getCollidable(x, y); | final byte sType = map.getCollidable(x, y); | |
g.setColor(Color.BLUE); | g.setColor(Color.BLUE); | |
switch (sType) { case 0: // Nothing break; case GameObject.WALL_VERTICAL: // Vertical wall, no edges g.fillRoundRect(x * map.CELL_SIZE + map.WALL_OVERLAP, y * map.CELL_SIZE, map.WALL_THICKNESS, map.CELL_SIZE, 0, 0); // 2x+12 = map.CELL_SIZE. // x = 10 break; case GameObject.WALL_HORIZONTAL: // Horizontal wall, no edges g.fillRoundRect(x * map.CELL_SIZE, y * map.CELL_SIZE + map.WALL_OVERLAP, map.CELL_SIZE, map.WALL_THICKNESS, 0, 0); break; case GameObject.WALL_TOPLEFT: g.fillRoundRect(x * map.CELL_SIZE + (map.CELL_SIZE / 2), y * map.CELL_SIZE + map.WALL_OVERLAP, map.CELL_SIZE / 2, map.WALL_THICKNESS, 0, 0); g.fillRoundRect(x * map.CELL_SIZE + map.WALL_OVERLAP, y * map.CELL_SIZE + (map.CELL_SIZE / 2), map.WALL_THICKNESS, map.CELL_SIZE / 2, 0, 0); break; case GameObject.WALL_TOPRIGHT: g.fillRoundRect(x * map.CELL_SIZE, y * map.CELL_SIZE + map.WALL_OVERLAP, map.CELL_SIZE / 2, map.WALL_THICKNESS, 0, 0); g.fillRoundRect(x * map.CELL_SIZE + map.WALL_OVERLAP, y * map.CELL_SIZE + (map.CELL_SIZE / 2), map.WALL_THICKNESS, map.CELL_SIZE / 2, 0, 0); break; case GameObject.WALL_BOTTOMLEFT: g.fillRoundRect(x * map.CELL_SIZE + (map.CELL_SIZE / 2), y * map.CELL_SIZE + map.WALL_OVERLAP, map.CELL_SIZE / 2, map.WALL_THICKNESS, 0, 0); // hori g.fillRoundRect(x * map.CELL_SIZE + map.WALL_OVERLAP, y * map.CELL_SIZE, 12, map.CELL_SIZE / 2, 0, 0); // vert break; case GameObject.WALL_BOTTOMRIGHT: g.fillRoundRect(x * map.CELL_SIZE, y * map.CELL_SIZE + map.WALL_OVERLAP, map.CELL_SIZE / 2, map.WALL_THICKNESS, 0, 0); // hori g.fillRoundRect(x * map.CELL_SIZE + map.WALL_OVERLAP, y * map.CELL_SIZE, map.WALL_THICKNESS, map.CELL_SIZE / 2, 0, 0); // vert break; case GameObject.WALL_GHOSTBARRIER: g.setColor(Color.PINK); g.fillRoundRect(x * map.CELL_SIZE, y * map.CELL_SIZE + map.WALL_OVERLAP, map.CELL_SIZE, map.WALL_THICKNESS / 2, 0, 0); break; default: break; |
switch (sType) { case 0: break; case GameObject.WALL_VERTICAL: g.fillRoundRect(x * map.CELL_SIZE + map.WALL_OVERLAP, y * map.CELL_SIZE, map.WALL_THICKNESS, map.CELL_SIZE, 0, 0); break; case GameObject.WALL_HORIZONTAL: g.fillRoundRect(x * map.CELL_SIZE, y * map.CELL_SIZE + map.WALL_OVERLAP, map.CELL_SIZE, map.WALL_THICKNESS, 0, 0); break; case GameObject.WALL_TOPLEFT: g.fillRoundRect(x * map.CELL_SIZE + (map.CELL_SIZE / 2), y * map.CELL_SIZE + map.WALL_OVERLAP, map.CELL_SIZE / 2, map.WALL_THICKNESS, 0, 0); g.fillRoundRect(x * map.CELL_SIZE + map.WALL_OVERLAP, y * map.CELL_SIZE + (map.CELL_SIZE / 2), map.WALL_THICKNESS, map.CELL_SIZE / 2, 0, 0); break; case GameObject.WALL_TOPRIGHT: g.fillRoundRect(x * map.CELL_SIZE, y * map.CELL_SIZE + map.WALL_OVERLAP, map.CELL_SIZE / 2, map.WALL_THICKNESS, 0, 0); g.fillRoundRect(x * map.CELL_SIZE + map.WALL_OVERLAP, y * map.CELL_SIZE + (map.CELL_SIZE / 2), map.WALL_THICKNESS, map.CELL_SIZE / 2, 0, 0); break; case GameObject.WALL_BOTTOMLEFT: g.fillRoundRect(x * map.CELL_SIZE + (map.CELL_SIZE / 2), y * map.CELL_SIZE + map.WALL_OVERLAP, map.CELL_SIZE / 2, map.WALL_THICKNESS, 0, 0); g.fillRoundRect(x * map.CELL_SIZE + map.WALL_OVERLAP, y * map.CELL_SIZE, 12, map.CELL_SIZE / 2, 0, 0); break; case GameObject.WALL_BOTTOMRIGHT: g.fillRoundRect(x * map.CELL_SIZE, y * map.CELL_SIZE + map.WALL_OVERLAP, map.CELL_SIZE / 2, map.WALL_THICKNESS, 0, 0); g.fillRoundRect(x * map.CELL_SIZE + map.WALL_OVERLAP, y * map.CELL_SIZE, map.WALL_THICKNESS, map.CELL_SIZE / 2, 0, 0); break; case GameObject.WALL_GHOSTBARRIER: g.setColor(Color.PINK); g.fillRoundRect(x * map.CELL_SIZE, y * map.CELL_SIZE + map.WALL_OVERLAP, map.CELL_SIZE, map.WALL_THICKNESS / 2, 0, 0); break; default: break; |
|
item = map.getItem(x, y); | item = map.getItem(x, y); | |
if (item != null) { item.paint(g); |
if (item != null) { item.paint(g); |
Clone # 6
Distance between two fragments = 0
Clone size = 51
Source file "detect/contractionLoop/contractionLoop/game/Item.java" The first line is 15 | Source file "detect/contractionLoop/original/game/Item.java" The first line is 15 | |
public class Item extends GameObject { // Teleportation vars private int teleportDestX; private int teleportDestY; /** * Class constructor for Item * * @param type * Object type * @param color * Base color of the item * @param m * Reference to the map object * @param x * X coordinate the item will occupy on the map * @param y * Y coordinate the item with occupy on the map * @see GameObject */ public Item(int type, Color color, Map m, int x, int y) { super(type, color, m, x, y); teleportDestX = 13; teleportDestY = 17; } /** * Set the destination coordinates for teleportation. This isn't useful to * any item other than a teleport * * @param x * X destination coordinate * @param y * Y destination coordinate */ public void setTeleport(int x, int y) { teleportDestX = x; teleportDestY = y; } /** * Retrieve the teleport destination X coordinate * * @return X destination coordinate * @see Item#setTeleport(int, int) */ public int getTeleportX() { return teleportDestX; } /** * Retrieve the teleport destination Y coordinate * * @return Y destination coordinate * @see Item#setTeleport(int, int) */ public int getTeleportY() { return teleportDestY; } /** * Called when the item is picked up / used by the player (in the player's * act() function) Add point values or trigger powerup modifiers here (using * the pl object) * * @param pl * Player that uses the item * @return True->Destroy the item. False->Keep the item on the map * @see Player#act() */ public boolean use(Player pl) { boolean destroy = false; // Perform action based on type switch (objType) { case OBJECT_DOT: pl.incrementScore(10); destroy = true; break; case OBJECT_POWERUP: pl.incrementScore(50); pl.setPowerUp(true); destroy = true; break; case OBJECT_TELEPORT: pl.move(teleportDestX, teleportDestY); break; default: break; } return destroy; } /** * Item's have no "think" process. Blank method * * @see GameObject#act() */ @Override public void act() { // do nothing } /** * Draw the item based on it's type * * @see GameObject#paint(java.awt.Graphics2D) */ @Override public void paint(Graphics2D g) { g.setColor(objColor); // Item's are placed in the center of a cell final int center_x = (positionX * map.CELL_SIZE) + map.CELL_SIZE / 2; final int center_y = (positionY * map.CELL_SIZE) + map.CELL_SIZE / 2; // Render item based on type switch (objType) { case OBJECT_DOT: g.fillArc(center_x - 4, center_y - 4, 8, 8, 0, 360); break; case OBJECT_POWERUP: g.fillArc(center_x - 8, center_y - 8, 16, 16, 0, 360); break; case OBJECT_TELEPORT: g.fillOval(center_x - 6, center_y - 8, 12, 16); break; default: break; |
public class Item extends GameObject { // Teleportation vars private int teleportDestX; private int teleportDestY; /** * Class constructor for Item * * @param type * Object type * @param color * Base color of the item * @param m * Reference to the map object * @param x * X coordinate the item will occupy on the map * @param y * Y coordinate the item with occupy on the map * @see GameObject */ public Item(int type, Color color, Map m, int x, int y) { super(type, color, m, x, y); teleportDestX = 13; teleportDestY = 17; } /** * Set the destination coordinates for teleportation. This isn't useful to * any item other than a teleport * * @param x * X destination coordinate * @param y * Y destination coordinate */ public void setTeleport(int x, int y) { teleportDestX = x; teleportDestY = y; } /** * Retrieve the teleport destination X coordinate * * @return X destination coordinate * @see Item#setTeleport(int, int) */ public int getTeleportX() { return teleportDestX; } /** * Retrieve the teleport destination Y coordinate * * @return Y destination coordinate * @see Item#setTeleport(int, int) */ public int getTeleportY() { return teleportDestY; } /** * Called when the item is picked up / used by the player (in the player's * act() function) Add point values or trigger powerup modifiers here (using * the pl object) * * @param pl * Player that uses the item * @return True->Destroy the item. False->Keep the item on the map * @see Player#act() */ public boolean use(Player pl) { boolean destroy = false; // Perform action based on type switch (objType) { case OBJECT_DOT: pl.incrementScore(10); destroy = true; break; case OBJECT_POWERUP: pl.incrementScore(50); pl.setPowerUp(true); destroy = true; break; case OBJECT_TELEPORT: pl.move(teleportDestX, teleportDestY); break; default: break; } return destroy; } /** * Item's have no "think" process. Blank method * * @see GameObject#act() */ @Override public void act() { // do nothing } /** * Draw the item based on it's type * * @see GameObject#paint(java.awt.Graphics2D) */ @Override public void paint(Graphics2D g) { g.setColor(objColor); // Item's are placed in the center of a cell final int center_x = (positionX * map.CELL_SIZE) + map.CELL_SIZE / 2; final int center_y = (positionY * map.CELL_SIZE) + map.CELL_SIZE / 2; // Render item based on type switch (objType) { case OBJECT_DOT: g.fillArc(center_x - 4, center_y - 4, 8, 8, 0, 360); break; case OBJECT_POWERUP: g.fillArc(center_x - 8, center_y - 8, 16, 16, 0, 360); break; case OBJECT_TELEPORT: g.fillOval(center_x - 6, center_y - 8, 12, 16); break; default: break; |
Clone # 7
Distance between two fragments = 0
Clone size = 47
Source file "detect/contractionLoop/original/state/StateEditor.java" The first line is 214 | Source file "detect/contractionLoop/contractionLoop/state/StateEditor.java" The first line is 215 | |
final byte sType = map.getCollidable(x, y); | final byte sType = map.getCollidable(x, y); | |
g.setColor(Color.BLUE); | g.setColor(Color.BLUE); | |
switch (sType) { case 0: // Nothing break; case GameObject.WALL_VERTICAL: // Vertical wall, no edges g.fillRoundRect(x * map.CELL_SIZE + 10, y * map.CELL_SIZE, 12, map.CELL_SIZE, 0, 0); // 2x+12 = map.CELL_SIZE. // x = 10 break; case GameObject.WALL_HORIZONTAL: // Horizontal wall, no edges g.fillRoundRect(x * map.CELL_SIZE, y * map.CELL_SIZE + 10, map.CELL_SIZE, 12, 0, 0); break; case GameObject.WALL_TOPLEFT: // g.fillArc(x*map.CELL_SIZE+10, y*map.CELL_SIZE, // map.CELL_SIZE, map.CELL_SIZE, 90, 90); g.fillRoundRect(x * map.CELL_SIZE + (map.CELL_SIZE / 2), y * map.CELL_SIZE + 10, map.CELL_SIZE / 2, 12, 0, 0); g.fillRoundRect(x * map.CELL_SIZE + 10, y * map.CELL_SIZE + (map.CELL_SIZE / 2), 12, map.CELL_SIZE / 2, 0, 0); break; case GameObject.WALL_TOPRIGHT: g.fillRoundRect(x * map.CELL_SIZE, y * map.CELL_SIZE + 10, map.CELL_SIZE / 2, 12, 0, 0); g.fillRoundRect(x * map.CELL_SIZE + 10, y * map.CELL_SIZE + (map.CELL_SIZE / 2), 12, map.CELL_SIZE / 2, 0, 0); break; case GameObject.WALL_BOTTOMLEFT: g.fillRoundRect(x * map.CELL_SIZE + (map.CELL_SIZE / 2), y * map.CELL_SIZE + 10, map.CELL_SIZE / 2, 12, 0, 0); // hori g.fillRoundRect(x * map.CELL_SIZE + 10, y * map.CELL_SIZE, 12, map.CELL_SIZE / 2, 0, 0); // vert break; case GameObject.WALL_BOTTOMRIGHT: g.fillRoundRect(x * map.CELL_SIZE, y * map.CELL_SIZE + 10, map.CELL_SIZE / 2, 12, 0, 0); // hori g.fillRoundRect(x * map.CELL_SIZE + 10, y * map.CELL_SIZE, 12, map.CELL_SIZE / 2, 0, 0); // vert break; case GameObject.WALL_GHOSTBARRIER: g.setColor(Color.PINK); g.fillRoundRect(x * map.CELL_SIZE, y * map.CELL_SIZE + 10, map.CELL_SIZE, 6, 0, 0); break; default: break; |
switch (sType) { case 0: break; case GameObject.WALL_VERTICAL: g.fillRoundRect(x * map.CELL_SIZE + 10, y * map.CELL_SIZE, 12, map.CELL_SIZE, 0, 0); break; case GameObject.WALL_HORIZONTAL: g.fillRoundRect(x * map.CELL_SIZE, y * map.CELL_SIZE + 10, map.CELL_SIZE, 12, 0, 0); break; case GameObject.WALL_TOPLEFT: g.fillRoundRect(x * map.CELL_SIZE + (map.CELL_SIZE / 2), y * map.CELL_SIZE + 10, map.CELL_SIZE / 2, 12, 0, 0); g.fillRoundRect(x * map.CELL_SIZE + 10, y * map.CELL_SIZE + (map.CELL_SIZE / 2), 12, map.CELL_SIZE / 2, 0, 0); break; case GameObject.WALL_TOPRIGHT: g.fillRoundRect(x * map.CELL_SIZE, y * map.CELL_SIZE + 10, map.CELL_SIZE / 2, 12, 0, 0); g.fillRoundRect(x * map.CELL_SIZE + 10, y * map.CELL_SIZE + (map.CELL_SIZE / 2), 12, map.CELL_SIZE / 2, 0, 0); break; case GameObject.WALL_BOTTOMLEFT: g.fillRoundRect(x * map.CELL_SIZE + (map.CELL_SIZE / 2), y * map.CELL_SIZE + 10, map.CELL_SIZE / 2, 12, 0, 0); g.fillRoundRect(x * map.CELL_SIZE + 10, y * map.CELL_SIZE, 12, map.CELL_SIZE / 2, 0, 0); break; case GameObject.WALL_BOTTOMRIGHT: g.fillRoundRect(x * map.CELL_SIZE, y * map.CELL_SIZE + 10, map.CELL_SIZE / 2, 12, 0, 0); g.fillRoundRect(x * map.CELL_SIZE + 10, y * map.CELL_SIZE, 12, map.CELL_SIZE / 2, 0, 0); break; case GameObject.WALL_GHOSTBARRIER: g.setColor(Color.PINK); g.fillRoundRect(x * map.CELL_SIZE, y * map.CELL_SIZE + 10, map.CELL_SIZE, 6, 0, 0); break; default: break; |
|
item = map.getItem(x, y); | item = map.getItem(x, y); | |
if (item != null) { item.paint(g); |
if (item != null) { item.paint(g); |
Clone # 8
Distance between two fragments = 0
Clone size = 46
Source file "detect/contractionLoop/contractionLoop/actors/Actor.java" The first line is 20 | Source file "detect/contractionLoop/original/actors/Actor.java" The first line is 20 | |
public abstract class Actor extends GameObject { /** Whether the actor is alive or not. */ protected boolean isDead; /** The x-position on the map where the actor gets spawned */ protected int spawnX; /** The y-position on the map where the actor gets spawned */ protected int spawnY; /** The direction in which the actor is currently oriented. */ protected Direction currentMoveDir; /** The actor's direction requested by user input. Uses a buffer to * remember requests over some steps to simplify timing for the user. * Computer-controlled actors (ghosts) ignore this. */ protected RequestedDirectionBuffer requestedMoveDirBuffer; /** The size of the direction request buffer. */ private final static int DIRECTION_QUEUE_SIZE = 6; /** The current orientation angle of the actor. Ignored by actors that do * not have to orient (aka ghosts). */ protected int dirOrient; /** The x-position delta to the current map cell, caused by movement * in pixels. */ protected float deltaX; /** The y-position delta to the current map cell, caused by movement * in pixels. */ protected float deltaY; /** The movement speed of the actor */ protected float speed; /** * Actor Class Constructor * * @param type * Object type that is an actor * @param color * Base color of the actor * @param m * Reference to the global map object * @param x * X coordinate to spawn the actor at * @param y * Y coordinate to spawn the actor at * @see GameObject */ public Actor(int type, Color color, Map m, int x, int y) { super(type, color, m, x, y); isDead = false; // Movement spawnX = x; spawnY = y; currentMoveDir = Direction.none; requestedMoveDirBuffer = new RequestedDirectionBuffer(DIRECTION_QUEUE_SIZE); dirOrient = 0; deltaX = 0; deltaY = 0; speed = (float) (5d * map.SCALE); } // Getters and Setters /** * Returns the original X coordinate the Actor was given in the constructor * * @return the X coordinate of the spawn point */ public int getSpawnX() { return spawnX; } /** * Returns the original Y coordinate the Actor was given in the constructor * * @return the Y coordinate of the spawn point */ public int getSpawnY() { return spawnY; } /** * Set the death status of the actor. Used by StateGame and AIManager to * determine if the player / ghost has died */ public void setDead(boolean s) { isDead = s; } /** * Get dead status * * @return True if dead, false if alive * @see Actor#setDead(boolean) */ public boolean isDead() { return isDead; } /** * Speed is the number of pixels an actor moves across the screen in a given * cycle. A full position change is the number of pixels defined in * Map.CELL_SIZE * * @param s * New Speed */ public void setSpeed(float s) { speed = s; } /** * Get the current speed of the actor * * @return Current speed * @see Actor#setSpeed(float) */ public float getSpeed() { return speed; } /** * Set the direction actor should travel in. Player uses this to determine * the direction to "auto-move" to Ghosts ignore what is set by this * function because their direction is determined within act() based on the * path */ public void setMoveDirection(Direction dir) { requestedMoveDirBuffer.setRequestedDirection(dir); } // Public Methods /** * Attempt to move the actor to the given x,y location. This method will * check if a coordinate is valid with the Map class method canMove(). It is * not necessary to call canMove() before this function * * @param x * A x coordinate to move to * @param y * A y coordinate to move to * @return True if the move succeeded. False if otherwise * @see Map#canMove(Actor, int, int) */ public boolean move(int x, int y) { final boolean res = map.canMove(this, x, y); if (res) { positionX = x; positionY = y; } return res; } /** * The primary logic function for actors. StateGame calls this for players * directly in logic() and the AIManager calls this for ghosts in process() * * @see GameObject#act() * @see StateGame#logic() * @see AIManager#process() */ @Override public abstract void act(); /** * * @see GameObject#paint(java.awt.Graphics2D) */ @Override public abstract void paint(Graphics2D g); |
public abstract class Actor extends GameObject { /** Whether the actor is alive or not. */ protected boolean isDead; /** The x-position on the map where the actor gets spawned */ protected int spawnX; /** The y-position on the map where the actor gets spawned */ protected int spawnY; /** The direction in which the actor is currently oriented. */ protected Direction currentMoveDir; /** The actor's direction requested by user input. Uses a buffer to * remember requests over some steps to simplify timing for the user. * Computer-controlled actors (ghosts) ignore this. */ protected RequestedDirectionBuffer requestedMoveDirBuffer; /** The size of the direction request buffer. */ private final static int DIRECTION_QUEUE_SIZE = 6; /** The current orientation angle of the actor. Ignored by actors that do * not have to orient (aka ghosts). */ protected int dirOrient; /** The x-position delta to the current map cell, caused by movement * in pixels. */ protected float deltaX; /** The y-position delta to the current map cell, caused by movement * in pixels. */ protected float deltaY; /** The movement speed of the actor */ protected float speed; /** * Actor Class Constructor * * @param type * Object type that is an actor * @param color * Base color of the actor * @param m * Reference to the global map object * @param x * X coordinate to spawn the actor at * @param y * Y coordinate to spawn the actor at * @see GameObject */ public Actor(int type, Color color, Map m, int x, int y) { super(type, color, m, x, y); isDead = false; // Movement spawnX = x; spawnY = y; currentMoveDir = Direction.none; requestedMoveDirBuffer = new RequestedDirectionBuffer(DIRECTION_QUEUE_SIZE); dirOrient = 0; deltaX = 0; deltaY = 0; speed = (float) (5d * map.SCALE); } // Getters and Setters /** * Returns the original X coordinate the Actor was given in the constructor * * @return the X coordinate of the spawn point */ public int getSpawnX() { return spawnX; } /** * Returns the original Y coordinate the Actor was given in the constructor * * @return the Y coordinate of the spawn point */ public int getSpawnY() { return spawnY; } /** * Set the death status of the actor. Used by StateGame and AIManager to * determine if the player / ghost has died */ public void setDead(boolean s) { isDead = s; } /** * Get dead status * * @return True if dead, false if alive * @see Actor#setDead(boolean) */ public boolean isDead() { return isDead; } /** * Speed is the number of pixels an actor moves across the screen in a given * cycle. A full position change is the number of pixels defined in * Map.CELL_SIZE * * @param s * New Speed */ public void setSpeed(float s) { speed = s; } /** * Get the current speed of the actor * * @return Current speed * @see Actor#setSpeed(float) */ public float getSpeed() { return speed; } /** * Set the direction actor should travel in. Player uses this to determine * the direction to "auto-move" to Ghosts ignore what is set by this * function because their direction is determined within act() based on the * path */ public void setMoveDirection(Direction dir) { requestedMoveDirBuffer.setRequestedDirection(dir); } // Public Methods /** * Attempt to move the actor to the given x,y location. This method will * check if a coordinate is valid with the Map class method canMove(). It is * not necessary to call canMove() before this function * * @param x * A x coordinate to move to * @param y * A y coordinate to move to * @return True if the move succeeded. False if otherwise * @see Map#canMove(Actor, int, int) */ public boolean move(int x, int y) { final boolean res = map.canMove(this, x, y); if (res) { positionX = x; positionY = y; } return res; } /** * The primary logic function for actors. StateGame calls this for players * directly in logic() and the AIManager calls this for ghosts in process() * * @see GameObject#act() * @see StateGame#logic() * @see AIManager#process() */ @Override public abstract void act(); /** * * @see GameObject#paint(java.awt.Graphics2D) */ @Override public abstract void paint(Graphics2D g); |
Clone # 9
Distance between two fragments = 0
Clone size = 46
Source file "detect/contractionLoop/contractionLoop/state/StateGame.java" The first line is 308 | Source file "detect/contractionLoop/original/state/StateGame.java" The first line is 311 | |
@Override public void end() { // Cleanup player = null; map = null; |
@Override public void end() { // Cleanup player = null; map = null; |
|
public void win() { sessionScore += player.getScore(); respawn(true); |
public void win() { sessionScore += player.getScore(); respawn(true); |
|
public void lose() { livesRemaining--; if (livesRemaining > 0) { respawn(false); } else { if (currentLevel == 1) { sessionScore = player.getScore(); // win() never called, so // score is the 1st level // score } game.requestChangeState(State.STATE_SCOREBOARD); |
public void lose() { livesRemaining--; if (livesRemaining > 0) { respawn(false); } else { if (currentLevel == 1) { sessionScore = player.getScore(); // win() never called, so // score is the 1st level // score } game.requestChangeState(State.STATE_SCOREBOARD); |
|
@Override public void keyPressed(KeyEvent e) { if (player == null) { return; } switch (e.getKeyCode()) { case KeyEvent.VK_UP: player.setMoveDirection(Direction.up); break; case KeyEvent.VK_RIGHT: player.setMoveDirection(Direction.right); break; case KeyEvent.VK_DOWN: player.setMoveDirection(Direction.down); break; case KeyEvent.VK_LEFT: player.setMoveDirection(Direction.left); break; case KeyEvent.VK_SPACE: player.setMoveDirection(Direction.stop); break; case KeyEvent.VK_P: // Don't interupt system pauses if (pauseTime < System.currentTimeMillis()) { gamePaused = !gamePaused; } break; case KeyEvent.VK_V: game.toggleDebug(); // AI debug ai.setDebugEnabled(game.isDebugEnabled()); break; case KeyEvent.VK_0: // game.changeState(STATE_MENU); break; default: break; |
@Override public void keyPressed(KeyEvent e) { if (player == null) { return; } switch (e.getKeyCode()) { case KeyEvent.VK_UP: player.setMoveDirection(Direction.up); break; case KeyEvent.VK_RIGHT: player.setMoveDirection(Direction.right); break; case KeyEvent.VK_DOWN: player.setMoveDirection(Direction.down); break; case KeyEvent.VK_LEFT: player.setMoveDirection(Direction.left); break; case KeyEvent.VK_SPACE: player.setMoveDirection(Direction.stop); break; case KeyEvent.VK_P: // Don't interupt system pauses if (pauseTime < System.currentTimeMillis()) { gamePaused = !gamePaused; } break; case KeyEvent.VK_V: game.toggleDebug(); // AI debug ai.setDebugEnabled(game.isDebugEnabled()); break; case KeyEvent.VK_0: // game.changeState(STATE_MENU); break; default: break; |
Clone # 10
Distance between two fragments = 0
Clone size = 44
Source file "detect/contractionLoop/contractionLoop/map/Map.java" The first line is 415 | Source file "detect/contractionLoop/original/map/Map.java" The first line is 414 | |
public int findDistance(GameObject start, GameObject end) { return (int) Math.sqrt(Math.pow(Math.abs(start.getX() - end.getX()), 2) + Math.pow(Math.abs(start.getY() - end.getY()), 2)); |
public int findDistance(GameObject start, GameObject end) { return (int) Math.sqrt(Math.pow(Math.abs(start.getX() - end.getX()), 2) + Math.pow(Math.abs(start.getY() - end.getY()), 2)); |
|
public boolean isEmpty(int x, int y) { // Check bounds if (x < 0 || y < 0 || x >= mapWidth || y >= mapHeight) { return false; } // Check if the Object is hitting something on the collideMap if (getCollidable(x, y) != 0) { return false; } // Check if object is hitting something on the itemMap if (getItem(x, y) != null) { return false; } // Actor collission if (getActor(x, y, false) != null) { return false; } return true; |
public boolean isEmpty(int x, int y) { // Check bounds if (x < 0 || y < 0 || x >= mapWidth || y >= mapHeight) { return false; } // Check if the Object is hitting something on the collideMap if (getCollidable(x, y) != 0) { return false; } // Check if object is hitting something on the itemMap if (getItem(x, y) != null) { return false; } // Actor collission if (getActor(x, y, false) != null) { return false; } return true; |
|
public boolean canMove(Actor act, int x, int y) { if (act == null) { return false; } // Check bounds if (!isInBounds(x, y)) { return false; } // Check if the Object is hitting something on the collideMap if (getCollidable(x, y) != 0) { return false; } // Allow the Actor to move return true; |
public boolean canMove(Actor act, int x, int y) { if (act == null) { return false; } // Check bounds if (!isInBounds(x, y)) { return false; } // Check if the Object is hitting something on the collideMap if (getCollidable(x, y) != 0) { return false; } // Allow the Actor to move return true; |
|
public boolean canMove(Actor act, Direction dir) { int x = act.getX(); int y = act.getY(); switch (dir) { case up: y--; break; case right: x++; break; case down: y++; break; case left: x--; break; case none: return true; } return canMove(act, x, y); |
public boolean canMove(Actor act, Direction dir) { int x = act.getX(); int y = act.getY(); switch (dir) { case up: y--; break; case right: x++; break; case down: y++; break; case left: x--; break; case none: return true; } return canMove(act, x, y); |
|
private boolean isInBounds(int x, int y) { return x > 0 && y > 0 && x <= mapWidth && y <= mapHeight; |
private boolean isInBounds(int x, int y) { return x > 0 && y > 0 && x <= mapWidth && y <= mapHeight; |
|
public float getCost(Actor mover, int sx, int sy, int tx, int ty) { return 1; |
public float getCost(Actor mover, int sx, int sy, int tx, int ty) { return 1; |
Clone # 11
Distance between two fragments = 0
Clone size = 39
Source file "detect/contractionLoop/contractionLoop/game/GameObject.java" The first line is 16 | Source file "detect/contractionLoop/original/game/GameObject.java" The first line is 16 | |
public abstract class GameObject { // Static type vars public static final int OBJECT_DOT = 1; public static final int OBJECT_POWERUP = 2; public static final int OBJECT_CHERRY = 4; public static final int OBJECT_PLAYER = 8; public static final int OBJECT_GHOST = 16; public static final int OBJECT_MARKER = 32; // Virtual public static final int OBJECT_WALL = 64; // Virtual public static final int OBJECT_TELEPORT = 128; // Wall types (Walls aren't instanced GameObject's) public static final byte WALL_VERTICAL = 1; public static final byte WALL_HORIZONTAL = 2; public static final byte WALL_TOPLEFT = 3; public static final byte WALL_TOPRIGHT = 4; public static final byte WALL_BOTTOMLEFT = 5; public static final byte WALL_BOTTOMRIGHT = 6; public static final byte WALL_GHOSTBARRIER = 7; // Generic object attributes protected int objType; protected Color objColor; protected int positionX; protected int positionY; // Outside refereneces protected final Map map; // Can only be set once. Object only exists within // the map. If the map changes, new objects are // created // Getters and Setters /** * Return the type of the object set in the constructor. See static types * defined in GameObject * * @return type of object */ public int getType() { return objType; } /** * Grab the current java.awt.Color (base color) the object is being rendered * in * * @return Base Color of the object */ public Color getColor() { return objColor; } /** * Set the current base color used when rendering the object * * @param c * java.awt.Color Color of object */ public void setColor(Color c) { objColor = c; } /** * Grab the current X coordinate of the object on the map. This property is * frequently modified by the Map class and move() method * * @see Actor#move(int, int) */ public int getX() { return positionX; } /** * Grab the current Y coordinate of the object on the map. This property is * frequently modified by the Map class and move() method * * @see Actor#move(int, int) */ public int getY() { return positionY; } // Public & Protected Abstract methods /** * Class Constructor for a game object * * @param type * Type of game object (see static types above) * @param color * Standard java Color * @param m * Reference to the global Map * @param x * Initial x coordinate * @param y * Initial y coordinate */ public GameObject(int type, Color color, Map m, int x, int y) { objType = type; objColor = color; map = m; positionX = x; positionY = y; } /** * Perform a "Think" cycle for the Object This includes things like self * maintenance and movement */ public abstract void act(); /** * Draw the object. Subclasses should define how they are to be drawn. This * is called in StateGame's logic() * * @param g * The graphics context * @see StateGame#logic() */ public abstract void paint(Graphics2D g); |
public abstract class GameObject { // Static type vars public static final int OBJECT_DOT = 1; public static final int OBJECT_POWERUP = 2; public static final int OBJECT_CHERRY = 4; public static final int OBJECT_PLAYER = 8; public static final int OBJECT_GHOST = 16; public static final int OBJECT_MARKER = 32; // Virtual public static final int OBJECT_WALL = 64; // Virtual public static final int OBJECT_TELEPORT = 128; // Wall types (Walls aren't instanced GameObject's) public static final byte WALL_VERTICAL = 1; public static final byte WALL_HORIZONTAL = 2; public static final byte WALL_TOPLEFT = 3; public static final byte WALL_TOPRIGHT = 4; public static final byte WALL_BOTTOMLEFT = 5; public static final byte WALL_BOTTOMRIGHT = 6; public static final byte WALL_GHOSTBARRIER = 7; // Generic object attributes protected int objType; protected Color objColor; protected int positionX; protected int positionY; // Outside refereneces protected final Map map; // Can only be set once. Object only exists within // the map. If the map changes, new objects are // created // Getters and Setters /** * Return the type of the object set in the constructor. See static types * defined in GameObject * * @return type of object */ public int getType() { return objType; } /** * Grab the current java.awt.Color (base color) the object is being rendered * in * * @return Base Color of the object */ public Color getColor() { return objColor; } /** * Set the current base color used when rendering the object * * @param c * java.awt.Color Color of object */ public void setColor(Color c) { objColor = c; } /** * Grab the current X coordinate of the object on the map. This property is * frequently modified by the Map class and move() method * * @see Actor#move(int, int) */ public int getX() { return positionX; } /** * Grab the current Y coordinate of the object on the map. This property is * frequently modified by the Map class and move() method * * @see Actor#move(int, int) */ public int getY() { return positionY; } // Public & Protected Abstract methods /** * Class Constructor for a game object * * @param type * Type of game object (see static types above) * @param color * Standard java Color * @param m * Reference to the global Map * @param x * Initial x coordinate * @param y * Initial y coordinate */ public GameObject(int type, Color color, Map m, int x, int y) { objType = type; objColor = color; map = m; positionX = x; positionY = y; } /** * Perform a "Think" cycle for the Object This includes things like self * maintenance and movement */ public abstract void act(); /** * Draw the object. Subclasses should define how they are to be drawn. This * is called in StateGame's logic() * * @param g * The graphics context * @see StateGame#logic() */ public abstract void paint(Graphics2D g); |
Clone # 12
Distance between two fragments = 0
Clone size = 37
Source file "detect/contractionLoop/contractionLoop/map/Path.java" The first line is 11 | Source file "detect/contractionLoop/original/map/Path.java" The first line is 11 | |
public class Path { /** The list of steps building up this path */ private final ArrayList<Step> steps; /** * Create an empty path */ public Path() { steps = new ArrayList<Step>(); } /** * Get the length of the path, i.e. the number of steps * * @return The number of steps in this path */ public int getLength() { return steps.size(); } /** * Get the step at a given index in the path * * @param index * The index of the step to retrieve. Note this should be >= 0 * and < getLength(); * @return The step information, the position on the map. */ public Step getStep(int index) { return steps.get(index); } /** * Get the x coordinate for the step at the given index * * @param index * The index of the step whose x coordinate should be retrieved * @return The x coordinate at the step */ public int getX(int index) { return getStep(index).x; } /** * Get the y coordinate for the step at the given index * * @param index * The index of the step whose y coordinate should be retrieved * @return The y coordinate at the step */ public int getY(int index) { return getStep(index).y; } /** * Append a step to the path. * * @param x * The x coordinate of the new step * @param y * The y coordinate of the new step */ public void appendStep(int x, int y) { steps.add(new Step(x, y)); } /** * Prepend a step to the path. * * @param x * The x coordinate of the new step * @param y * The y coordinate of the new step */ public void prependStep(int x, int y) { steps.add(0, new Step(x, y)); } /** * Check if this path contains the given step * * @param x * The x coordinate of the step to check for * @param y * The y coordinate of the step to check for * @return True if the path contains the given step */ public boolean contains(int x, int y) { return steps.contains(new Step(x, y)); } /** * A single step within the path * * @author Kevin Glass */ public class Step { /** The x coordinate at the given step */ private final int x; /** The y coordinate at the given step */ private final int y; /** * Create a new step * * @param x * The x coordinate of the new step * @param y * The y coordinate of the new step */ public Step(int x, int y) { this.x = x; this.y = y; } /** * Get the x coordinate of the new step * * @return The x coodindate of the new step */ public int getX() { return x; } /** * Get the y coordinate of the new step * * @return The y coodindate of the new step */ public int getY() { return y; } /** * @see Object#hashCode() */ @Override public int hashCode() { return x * y; } /** * @see Object#equals(Object) */ @Override public boolean equals(Object other) { if (other instanceof Step) { final Step o = (Step) other; return (o.x == x) && (o.y == y); } return false; |
public class Path { /** The list of steps building up this path */ private final ArrayList<Step> steps; /** * Create an empty path */ public Path() { steps = new ArrayList<Step>(); } /** * Get the length of the path, i.e. the number of steps * * @return The number of steps in this path */ public int getLength() { return steps.size(); } /** * Get the step at a given index in the path * * @param index * The index of the step to retrieve. Note this should be >= 0 * and < getLength(); * @return The step information, the position on the map. */ public Step getStep(int index) { return steps.get(index); } /** * Get the x coordinate for the step at the given index * * @param index * The index of the step whose x coordinate should be retrieved * @return The x coordinate at the step */ public int getX(int index) { return getStep(index).x; } /** * Get the y coordinate for the step at the given index * * @param index * The index of the step whose y coordinate should be retrieved * @return The y coordinate at the step */ public int getY(int index) { return getStep(index).y; } /** * Append a step to the path. * * @param x * The x coordinate of the new step * @param y * The y coordinate of the new step */ public void appendStep(int x, int y) { steps.add(new Step(x, y)); } /** * Prepend a step to the path. * * @param x * The x coordinate of the new step * @param y * The y coordinate of the new step */ public void prependStep(int x, int y) { steps.add(0, new Step(x, y)); } /** * Check if this path contains the given step * * @param x * The x coordinate of the step to check for * @param y * The y coordinate of the step to check for * @return True if the path contains the given step */ public boolean contains(int x, int y) { return steps.contains(new Step(x, y)); } /** * A single step within the path * * @author Kevin Glass */ public class Step { /** The x coordinate at the given step */ private final int x; /** The y coordinate at the given step */ private final int y; /** * Create a new step * * @param x * The x coordinate of the new step * @param y * The y coordinate of the new step */ public Step(int x, int y) { this.x = x; this.y = y; } /** * Get the x coordinate of the new step * * @return The x coodindate of the new step */ public int getX() { return x; } /** * Get the y coordinate of the new step * * @return The y coodindate of the new step */ public int getY() { return y; } /** * @see Object#hashCode() */ @Override public int hashCode() { return x * y; } /** * @see Object#equals(Object) */ @Override public boolean equals(Object other) { if (other instanceof Step) { final Step o = (Step) other; return (o.x == x) && (o.y == y); } return false; |
Clone # 13
Distance between two fragments = 0
Clone size = 34
Source file "detect/contractionLoop/original/game/Game.java" The first line is 67 | Source file "detect/contractionLoop/contractionLoop/game/Game.java" The first line is 67 | |
private void init() { // Debug vars debugEnabled = false; startMap = "test.map"; changeStateRequested = false; // Setup the game frame frame = new Frame("Pacman"); frame.setLayout(null); setBounds(0, 0, RES_X, RES_Y); frame.add(this); frame.setSize(RES_X, RES_Y); frame.setResizable(false); frame.setVisible(true); // Set the exit handler with an anonymous class frame.addWindowListener(new WindowAdapter() { @Override public void windowClosing(WindowEvent e) { // Exit main thread runMainThread = false; } }); // Setup double buffering setIgnoreRepaint(true); // We'll handle repainting createBufferStrategy(2); m_gBuffer = getBufferStrategy(); runMainThread = true; |
private void init() { // Debug vars debugEnabled = false; startMap = "test.map"; changeStateRequested = false; // Setup the game frame frame = new Frame("Pacman"); frame.setLayout(null); setBounds(0, 0, RES_X, RES_Y); frame.add(this); frame.setSize(RES_X, RES_Y); frame.setResizable(false); frame.setVisible(true); // Set the exit handler with an anonymous class frame.addWindowListener(new WindowAdapter() { @Override public void windowClosing(WindowEvent e) { // Exit main thread runMainThread = false; } }); // Setup double buffering setIgnoreRepaint(true); // We'll handle repainting createBufferStrategy(2); m_gBuffer = getBufferStrategy(); runMainThread = true; |
|
public Frame getFrame() { return frame; |
public Frame getFrame() { return frame; |
|
public Graphics2D getGraphicsContext() { return (Graphics2D) m_gBuffer.getDrawGraphics(); |
public Graphics2D getGraphicsContext() { return (Graphics2D) m_gBuffer.getDrawGraphics(); |
|
public String getStartMap() { return startMap; |
public String getStartMap() { return startMap; |
|
public void setStartMap(String m) { startMap = m; |
public void setStartMap(String m) { startMap = m; |
|
public boolean isDebugEnabled() { return debugEnabled; |
public boolean isDebugEnabled() { return debugEnabled; |
|
public void toggleDebug() { debugEnabled = !debugEnabled; |
public void toggleDebug() { debugEnabled = !debugEnabled; |
|
public void requestChangeState(int state) { requestedState = state; changeStateRequested = true; |
public void requestChangeState(int state) { requestedState = state; changeStateRequested = true; |
Clone # 14
Distance between two fragments = 0
Clone size = 32
Source file "detect/contractionLoop/contractionLoop/state/StateEditor.java" The first line is 74 | Source file "detect/contractionLoop/original/state/StateEditor.java" The first line is 74 | |
public void setMarkerObjectType(int t) { markerObjectType = t; |
public void setMarkerObjectType(int t) { markerObjectType = t; |
|
public void setMarkerWallType(byte t) { markerWallType = t; |
public void setMarkerWallType(byte t) { markerWallType = t; |
|
public void setMarkerGhostType(String t) { markerGhostType = t; |
public void setMarkerGhostType(String t) { markerGhostType = t; |
|
public void setMarkerGhostTrapped(boolean t) { markerGhostTrapped = t; |
public void setMarkerGhostTrapped(boolean t) { markerGhostTrapped = t; |
|
public boolean getMarkerGhostTrapped() { return markerGhostTrapped; |
public boolean getMarkerGhostTrapped() { return markerGhostTrapped; |
|
public void setMarkerTeleport(int x, int y) { markerTeleportX = x; markerTeleportY = y; |
public void setMarkerTeleport(int x, int y) { markerTeleportX = x; markerTeleportY = y; |
|
@Override public void reset() { // Force previous references out of scope marker = null; map = null; markerObjectType = GameObject.OBJECT_DOT; |
@Override public void reset() { // Force previous references out of scope marker = null; map = null; markerObjectType = GameObject.OBJECT_DOT; |
|
public void newMap(int width, int height) { // Setup the game map game.getGraphicsContext().setBackground(Color.BLACK); mapWidth = width; mapHeight = height; map = new Map(28, 31, 32); // Create the marker (but don't put it "in" the map) marker = new EditorMarker(Color.GREEN, map, 0, 0); |
public void newMap(int width, int height) { // Setup the game map game.getGraphicsContext().setBackground(Color.BLACK); mapWidth = width; mapHeight = height; map = new Map(28, 31, 32); // Create the marker (but don't put it "in" the map) marker = new EditorMarker(Color.GREEN, map, 0, 0); |
|
public void saveMap(String filename) { map.write(System.getProperty("user.dir") + "\\" + filename); |
public void saveMap(String filename) { map.write(System.getProperty("user.dir") + "\\" + filename); |
|
public void loadMap(String filename) { // Setup the game map game.getGraphicsContext().setBackground(Color.BLACK); map = new Map(System.getProperty("user.dir") + "\\" + filename, 32); mapWidth = map.getWidth(); mapHeight = map.getHeight(); // Create the marker (but don't put it "in" the map) marker = new EditorMarker(Color.GREEN, map, 0, 0); |
public void loadMap(String filename) { // Setup the game map game.getGraphicsContext().setBackground(Color.BLACK); map = new Map(System.getProperty("user.dir") + "\\" + filename, 32); mapWidth = map.getWidth(); mapHeight = map.getHeight(); // Create the marker (but don't put it "in" the map) marker = new EditorMarker(Color.GREEN, map, 0, 0); |
Clone # 15
Distance between two fragments = 0
Clone size = 28
Source file "detect/contractionLoop/contractionLoop/game/Game.java" The first line is 211 | Source file "detect/contractionLoop/original/game/Game.java" The first line is 225 | |
private void changeState(int state) { // Cleanup for the outgoing state if (currentState != null) { frame.removeKeyListener(currentState); removeKeyListener(currentState); currentState.end(); } // Set the new state type stateId = state; // Instance the new state (reset() is called in the construtor) switch (stateId) { case State.STATE_GAME: currentState = new StateGame(this); break; case State.STATE_SCOREBOARD: currentState = new StateScoreboard(this); /* * StateGame sb = new StateScoreboard(); int newScore = 0; * * // If the previous state was STATE_GAME, pull the session * score and pass it to the scoreboard if(currentState * instanceof StateGame) * sb.addScore((int)((StateGame)currentState * ).getSessionScore())); * * currentState = sb; */ break; case State.STATE_EDITOR: currentState = new StateEditor(this); break; case State.STATE_MENU: currentState = new StateMenu(this); break; case State.STATE_EXITING: currentState = null; runMainThread = false; break; default: break; } // Setup input handler and reset() if (currentState != null) { frame.addKeyListener(currentState); addKeyListener(currentState); |
private void changeState(int state) { // Cleanup for the outgoing state if (currentState != null) { frame.removeKeyListener(currentState); removeKeyListener(currentState); currentState.end(); } // Set the new state type stateId = state; // Instance the new state (reset() is called in the construtor) switch (stateId) { case State.STATE_GAME: currentState = new StateGame(this); break; case State.STATE_SCOREBOARD: currentState = new StateScoreboard(this); /* * StateGame sb = new StateScoreboard(); int newScore = 0; * * // If the previous state was STATE_GAME, pull the session * score and pass it to the scoreboard if(currentState * instanceof StateGame) * sb.addScore((int)((StateGame)currentState * ).getSessionScore())); * * currentState = sb; */ break; case State.STATE_EDITOR: currentState = new StateEditor(this); break; case State.STATE_MENU: currentState = new StateMenu(this); break; case State.STATE_EXITING: currentState = null; runMainThread = false; break; default: break; } // Setup input handler and reset() if (currentState != null) { frame.addKeyListener(currentState); addKeyListener(currentState); |
Clone # 16
Distance between two fragments = 0
Clone size = 26
Source file "detect/contractionLoop/contractionLoop/state/State.java" The first line is 15 | Source file "detect/contractionLoop/original/state/State.java" The first line is 15 | |
public abstract class State implements KeyListener { // Game States public static final int STATE_MENU = 1; public static final int STATE_SCOREBOARD = 2; public static final int STATE_GAME = 4; public static final int STATE_DEAD = 8; // public static final int STATE_GAMEOVER = 16; public static final int STATE_EDITOR = 32; public static final int STATE_EXITING = 64; protected Game game; /** * Class Constructor * * @param g * Reference to the game */ public State(Game g) { game = g; reset(); } /** * Return the reference to the game object * * @return Reference to the game object */ public Game getGame() { return game; } /** * Start or reset the state * * Can be called either by the Supervisor or the state itself */ public abstract void reset(); /** * Primary logic function called in the mainThreadLoop * * Called only by the Supervisor */ public abstract void logic(); /** * Signals the state to terminate. Any final updates should be performed * here THIS IS ONLY CALLED INSIDE CHANGESTATE() - DO NOT CALL THIS ANYWHERE * ELSE */ public abstract void end(); /* * Human Input default */ @Override public void keyReleased(KeyEvent e) { // do nothing } @Override public void keyTyped(KeyEvent e) { // Esc switch (e.getKeyChar()) { case 27: game.requestChangeState(STATE_EXITING); break; default: break; |
public abstract class State implements KeyListener { // Game States public static final int STATE_MENU = 1; public static final int STATE_SCOREBOARD = 2; public static final int STATE_GAME = 4; public static final int STATE_DEAD = 8; // public static final int STATE_GAMEOVER = 16; public static final int STATE_EDITOR = 32; public static final int STATE_EXITING = 64; protected Game game; /** * Class Constructor * * @param g * Reference to the game */ public State(Game g) { game = g; reset(); } /** * Return the reference to the game object * * @return Reference to the game object */ public Game getGame() { return game; } /** * Start or reset the state * * Can be called either by the Supervisor or the state itself */ public abstract void reset(); /** * Primary logic function called in the mainThreadLoop * * Called only by the Supervisor */ public abstract void logic(); /** * Signals the state to terminate. Any final updates should be performed * here THIS IS ONLY CALLED INSIDE CHANGESTATE() - DO NOT CALL THIS ANYWHERE * ELSE */ public abstract void end(); /* * Human Input default */ @Override public void keyReleased(KeyEvent e) { // do nothing } @Override public void keyTyped(KeyEvent e) { // Esc switch (e.getKeyChar()) { case 27: game.requestChangeState(STATE_EXITING); break; default: break; |
Clone # 17
Distance between two fragments = 0
Clone size = 25
Source file "detect/contractionLoop/original/map/PathFinder.java" The first line is 138 | Source file "detect/contractionLoop/contractionLoop/map/PathFinder.java" The first line is 132 | |
if ((x == 0) && (y == 0)) { continue; |
if ((x == 0) && (y == 0)) { continue; |
|
if (!allowDiagMovement) { if ((x != 0) && (y != 0)) { continue; |
if (!allowDiagMovement) { if ((x != 0) && (y != 0)) { continue; |
|
final int xp = x + current.x; | final int xp = x + current.x; | |
final int yp = y + current.y; | final int yp = y + current.y; | |
if (isValidLocation(mover, sx, sy, xp, yp)) { // the cost to get to this node is cost the current plus // the movement // cost to reach this node. Note that the heursitic // value is only used // in the sorted open list final float nextStepCost = current.cost + getMovementCost(mover, current.x, current.y, xp, yp); final Node neighbour = nodes[xp][yp]; // map.pathFinderVisited(xp, yp); // if the new cost we've determined for this node is // lower than // it has been previously makes sure the node hasn'e've // determined that there might have been a better path // to get to // this node so it needs to be re-evaluated if (nextStepCost < neighbour.cost) { if (inOpenList(neighbour)) { removeFromOpen(neighbour); } if (inClosedList(neighbour)) { removeFromClosed(neighbour); } } // if the node hasn't already been processed and // discarded then // reset it's cost to our current cost and add it as a // next possible // step (i.e. to the open list) if (!inOpenList(neighbour) && !(inClosedList(neighbour))) { neighbour.cost = nextStepCost; neighbour.nodeHeuristic = getHeuristicCost(mover, xp, yp, tx, ty); maxDepth = Math.max(maxDepth, neighbour.setParent(current)); addToOpen(neighbour); |
if (isValidLocation(mover, sx, sy, xp, yp)) { final float nextStepCost = current.cost + getMovementCost(mover, current.x, current.y, xp, yp); final Node neighbour = nodes[xp][yp]; if (nextStepCost < neighbour.cost) { if (inOpenList(neighbour)) { removeFromOpen(neighbour); } if (inClosedList(neighbour)) { removeFromClosed(neighbour); } } if (!inOpenList(neighbour) && !(inClosedList(neighbour))) { neighbour.cost = nextStepCost; neighbour.nodeHeuristic = getHeuristicCost(mover, xp, yp, tx, ty); maxDepth = Math.max(maxDepth, neighbour.setParent(current)); addToOpen(neighbour); |
Clone # 18
Distance between two fragments = 0
Clone size = 21
Source file "detect/contractionLoop/original/state/StateGame.java" The first line is 147 | Source file "detect/contractionLoop/contractionLoop/state/StateGame.java" The first line is 149 | |
if (map == null) { return; |
if (map == null) { return; |
|
final Graphics2D g = game.getGraphicsContext(); | final Graphics2D g = game.getGraphicsContext(); | |
g.translate(10, 30); | g.translate(10, 30); | |
g.setColor(Color.WHITE); | g.setColor(Color.WHITE); | |
g.setFont(new Font("Comic Sans MS", Font.BOLD, 24)); | g.setFont(new Font("Comic Sans MS", Font.BOLD, 24)); | |
g.drawString("PACMAN by Ramsey Kant", 680, 50); | g.drawString("PACMAN by Ramsey Kant", 680, 50); | |
g.drawString("Score: " + player.getScore(), 750, 100); | g.drawString("Score: " + player.getScore(), 750, 100); | |
g.drawString("Total: " + sessionScore, 750, 150); | g.drawString("Total: " + sessionScore, 750, 150); | |
g.drawString("Lives: " + livesRemaining, 750, 200); | g.drawString("Lives: " + livesRemaining, 750, 200); | |
g.drawString("Level: " + currentLevel, 750, 250); | g.drawString("Level: " + currentLevel, 750, 250); | |
if (!gamePaused) { ai.process(); player.act(); |
if (!gamePaused) { ai.process(); player.act(); |
|
if (player.isDead()) { lose(); return; |
if (player.isDead()) { lose(); return; |
|
if (map.getDotsRemaining() <= 0) { win(); return; |
if (map.getDotsRemaining() <= 0) { win(); return; |
|
Item item = null; | Item item = null; |
Clone # 19
Distance between two fragments = 0
Clone size = 20
Source file "detect/contractionLoop/contractionLoop/actors/Ghost.java" The first line is 203 | Source file "detect/contractionLoop/original/actors/Ghost.java" The first line is 203 | |
final int screenX = (int) ((map.CELL_SIZE * positionX) + deltaX); | final int screenX = (int) ((map.CELL_SIZE * positionX) + deltaX); | |
final int screenY = (int) ((map.CELL_SIZE * positionY) + deltaY); | final int screenY = (int) ((map.CELL_SIZE * positionY) + deltaY); | |
g.setColor(objColor); | g.setColor(objColor); | |
if (inFear) { g.setColor(Color.WHITE); |
if (inFear) { g.setColor(Color.WHITE); |
|
g.fillArc(screenX, screenY, map.CELL_SIZE, map.CELL_SIZE, 0, 360); | g.fillArc(screenX, screenY, map.CELL_SIZE, map.CELL_SIZE, 0, 360); | |
g.fillRect((int) ((map.CELL_SIZE * positionX) + deltaX), (int) ((map.CELL_SIZE * positionY) + (map.CELL_SIZE / 2) + deltaY), map.CELL_SIZE, map.CELL_SIZE / 2); |
g.fillRect((int) ((map.CELL_SIZE * positionX) + deltaX), (int) ((map.CELL_SIZE * positionY) + (map.CELL_SIZE / 2) + deltaY), map.CELL_SIZE, map.CELL_SIZE / 2); |
|
if (inFear) { g.setColor(Color.BLACK); } else { g.setColor(Color.WHITE); |
if (inFear) { g.setColor(Color.BLACK); } else { g.setColor(Color.WHITE); |
|
g.fillOval((int) ((map.CELL_SIZE * positionX) + 4 + deltaX), (int) ((map.CELL_SIZE * positionY) + 3 + deltaY), 8, 10); |
g.fillOval((int) ((map.CELL_SIZE * positionX) + 4 + deltaX), (int) ((map.CELL_SIZE * positionY) + 3 + deltaY), 8, 10); |
|
g.fillOval((int) ((map.CELL_SIZE * positionX) + 12 + deltaX), (int) ((map.CELL_SIZE * positionY) + 3 + deltaY), 8, 10); |
g.fillOval((int) ((map.CELL_SIZE * positionX) + 12 + deltaX), (int) ((map.CELL_SIZE * positionY) + 3 + deltaY), 8, 10); |
|
g.setColor(Color.BLUE); | g.setColor(Color.BLUE); | |
g.fillOval((int) ((map.CELL_SIZE * positionX) + 7 + deltaX), (int) ((map.CELL_SIZE * positionY) + 6 + deltaY), 4, 4); |
g.fillOval((int) ((map.CELL_SIZE * positionX) + 7 + deltaX), (int) ((map.CELL_SIZE * positionY) + 6 + deltaY), 4, 4); |
|
g.fillOval((int) ((map.CELL_SIZE * positionX) + 13 + deltaX), (int) ((map.CELL_SIZE * positionY) + 6 + deltaY), 4, 4); |
g.fillOval((int) ((map.CELL_SIZE * positionX) + 13 + deltaX), (int) ((map.CELL_SIZE * positionY) + 6 + deltaY), 4, 4); |
Clone # 20
Distance between two fragments = 0
Clone size = 18
Source file "detect/contractionLoop/original/actors/Player.java" The first line is 102 | Source file "detect/contractionLoop/contractionLoop/actors/Player.java" The first line is 102 | |
final Actor a = map.getActor(positionX, positionY, true); | final Actor a = map.getActor(positionX, positionY, true); | |
if (a != null && a.getType() == GameObject.OBJECT_GHOST) { // Notify the State of the loss if pacman isn't powered up if (!isPowered) { setDead(true); return; } else { a.setDead(true); |
if (a != null && a.getType() == GameObject.OBJECT_GHOST) { // Notify the State of the loss if pacman isn't powered up if (!isPowered) { setDead(true); return; } else { a.setDead(true); |
|
if (System.currentTimeMillis() > poweredExpireTime) { setPowerUp(false); |
if (System.currentTimeMillis() > poweredExpireTime) { setPowerUp(false); |
|
boolean itemDestroy = false; | boolean itemDestroy = false; | |
final Item item = map.getItem(positionX, positionY); | final Item item = map.getItem(positionX, positionY); | |
if (item != null) { itemDestroy = item.use(this); |
if (item != null) { itemDestroy = item.use(this); |
|
if (itemDestroy) { map.removeItem(positionX, positionY); |
if (itemDestroy) { map.removeItem(positionX, positionY); |
|
final Direction requestedDir = requestedMoveDirBuffer.getRequestedDirection(); | final Direction requestedDir = requestedMoveDirBuffer.getRequestedDirection(); | |
if (requestedDir != Direction.none) { if (map.canMove(this, requestedDir)) { currentMoveDir = requestedDir; |
if (requestedDir != Direction.none) { if (map.canMove(this, requestedDir)) { currentMoveDir = requestedDir; |
Clone # 21
Distance between two fragments = 0
Clone size = 17
Source file "detect/contractionLoop/contractionLoop/game/Game.java" The first line is 178 | Source file "detect/contractionLoop/original/game/Game.java" The first line is 179 | |
if ((lastLoopStart + loopTime) > System.currentTimeMillis()) { continue; } lastLoopStart = System.currentTimeMillis(); if (changeStateRequested) { changeStateRequested = false; changeState(requestedState); continue; } final Graphics2D g = getGraphicsContext(); g.setColor(Color.black); g.fillRect(0, 0, RES_X, RES_Y); currentState.logic(); g.dispose(); m_gBuffer.show(); try { Thread.sleep(10); } catch (InterruptedException e) { e.printStackTrace(); |
if ((lastLoopStart + loopTime) > System.currentTimeMillis()){ continue; } lastLoopStart = System.currentTimeMillis(); // If a state change was requested, execute it now if (changeStateRequested) { changeStateRequested = false; changeState(requestedState); continue; } final Graphics2D g = getGraphicsContext(); // Wipe the screen g.setColor(Color.black); g.fillRect(0, 0, RES_X, RES_Y); // Run the logic of the current game state here currentState.logic(); // Show the new buffer g.dispose(); m_gBuffer.show(); try { Thread.sleep(10); } catch (InterruptedException e) { // TODO Auto-generated catch block e.printStackTrace(); |
Clone # 22
Distance between two fragments = 0
Clone size = 17
Source file "detect/contractionLoop/contractionLoop/state/StateGame.java" The first line is 268 | Source file "detect/contractionLoop/original/state/StateGame.java" The first line is 271 | |
if (game.isDebugEnabled()) { g.setColor(Color.RED); g.drawString("DEBUG ON", 750, 650); /* * // Paint gridline overlay for(int i = 0; i < mapWidth; i++) * g.drawLine(i*map.CELL_SIZE, 0, i*map.CELL_SIZE, * mapHeight*map.CELL_SIZE); for(int i = 0; i < mapHeight; i++) * g.drawLine(0, i*map.CELL_SIZE, mapWidth*map.CELL_SIZE, * i*map.CELL_SIZE); */ // Player X,Y coordinates bottom right g.drawString("positionX: " + player.getX(), 750, 675); g.drawString("positionY: " + player.getY(), 750, 700); |
if (game.isDebugEnabled()) { g.setColor(Color.RED); g.drawString("DEBUG ON", 750, 650); /* * // Paint gridline overlay for(int i = 0; i < mapWidth; i++) * g.drawLine(i*map.CELL_SIZE, 0, i*map.CELL_SIZE, * mapHeight*map.CELL_SIZE); for(int i = 0; i < mapHeight; i++) * g.drawLine(0, i*map.CELL_SIZE, mapWidth*map.CELL_SIZE, * i*map.CELL_SIZE); */ // Player X,Y coordinates bottom right g.drawString("positionX: " + player.getX(), 750, 675); g.drawString("positionY: " + player.getY(), 750, 700); |
|
if (gamePaused) { g.setColor(Color.RED); g.setFont(new Font("Comic Sans MS", Font.BOLD, 24)); g.drawString("PAUSED", 750, 500); if (pauseTime > System.currentTimeMillis()) { g.drawString( "Pause ends in..." + ((pauseTime - System.currentTimeMillis()) / 1000), 750, 550); } if (pauseTime != 0 && System.currentTimeMillis() > pauseTime) { pauseTime = 0; gamePaused = false; } return; |
if (gamePaused) { g.setColor(Color.RED); g.setFont(new Font("Comic Sans MS", Font.BOLD, 24)); g.drawString("PAUSED", 750, 500); if (pauseTime > System.currentTimeMillis()) { g.drawString( "Pause ends in..." + ((pauseTime - System.currentTimeMillis()) / 1000), 750, 550); } if (pauseTime != 0 && System.currentTimeMillis() > pauseTime) { pauseTime = 0; gamePaused = false; } return; |
Clone # 23
Distance between two fragments = 0
Clone size = 17
Source file "detect/contractionLoop/contractionLoop/editor/EditorMarker.java" The first line is 18 | Source file "detect/contractionLoop/original/editor/EditorMarker.java" The first line is 18 | |
public class EditorMarker extends GameObject { /** * Class constructor for EditorMarker * * @param color * Color of the marker * @param m * Reference to the map object * @param x * X coordinate to initially place the marker * @param y * Y coordinate to initially place the marker */ public EditorMarker(Color color, Map m, int x, int y) { super(GameObject.OBJECT_MARKER, color, m, x, y); } // Public Methods /** * Change tile is the EditorMarker's version of Actor's move() method. * Called by keyPressed in StateEditor Moves the Marker on the screen * * @param dx * Amount to change the current X coordinate by * @param dy * Amount to change the current Y coordinate by * @see StateEditor#keyPressed(KeyEvent) */ public void changeTile(int dx, int dy) { // Check bounds if (positionX + dx < 0 || positionY + dy < 0 || positionX + dx >= map.getWidth() || positionY + dy >= map.getHeight()) { return; } positionX += dx; positionY += dy; } /** * EditorMarker has a blank act() method * * @see GameObject#act() */ @Override public void act() { // do nothing } /** * EditorMarker appears as a circle around the tile being edited. The color * is set in the constructor * * @see GameObject#paint(Graphics2D) */ @Override public void paint(Graphics2D g) { final int screenX = (map.CELL_SIZE * positionX); final int screenY = (map.CELL_SIZE * positionY); g.setColor(objColor); g.drawOval(screenX, screenY, map.CELL_SIZE, map.CELL_SIZE); |
public class EditorMarker extends GameObject { /** * Class constructor for EditorMarker * * @param color * Color of the marker * @param m * Reference to the map object * @param x * X coordinate to initially place the marker * @param y * Y coordinate to initially place the marker */ public EditorMarker(Color color, Map m, int x, int y) { super(GameObject.OBJECT_MARKER, color, m, x, y); } // Public Methods /** * Change tile is the EditorMarker's version of Actor's move() method. * Called by keyPressed in StateEditor Moves the Marker on the screen * * @param dx * Amount to change the current X coordinate by * @param dy * Amount to change the current Y coordinate by * @see StateEditor#keyPressed(KeyEvent) */ public void changeTile(int dx, int dy) { // Check bounds if (positionX + dx < 0 || positionY + dy < 0 || positionX + dx >= map.getWidth() || positionY + dy >= map.getHeight()) { return; } positionX += dx; positionY += dy; } /** * EditorMarker has a blank act() method * * @see GameObject#act() */ @Override public void act() { // do nothing } /** * EditorMarker appears as a circle around the tile being edited. The color * is set in the constructor * * @see GameObject#paint(Graphics2D) */ @Override public void paint(Graphics2D g) { final int screenX = (map.CELL_SIZE * positionX); final int screenY = (map.CELL_SIZE * positionY); g.setColor(objColor); g.drawOval(screenX, screenY, map.CELL_SIZE, map.CELL_SIZE); |
Clone # 24
Distance between two fragments = 18
Clone size = 16
Source file "detect/contractionLoop/contractionLoop/editor/EditorFrame.java" The first line is 207 | Source file "detect/contractionLoop/contractionLoop/editor/EditorFrame.java" The first line is 134 | |
btnSave = new JButton(); getContentPane().add(btnSave); btnSave.setText("Save"); btnSave.setBounds(12, 317, 70, 23); btnSave.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent evt) { editor.saveMap(txtFilename.getText()); |
btnDot = new JButton(); getContentPane().add(btnDot); btnDot.setText("Dot"); btnDot.setBounds(12, 36, 59, 23); btnDot.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent evt) { editor.setMarkerObjectType(GameObject.OBJECT_DOT); |
|
btnLoad = new JButton(); getContentPane().add(btnLoad); btnLoad.setText("Load"); btnLoad.setBounds(87, 317, 68, 23); btnLoad.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent evt) { editor.loadMap(txtFilename.getText()); |
btnPacman = new JButton(); getContentPane().add(btnPacman); btnPacman.setText("Pacman"); btnPacman.setBounds(136, 36, 110, 23); btnPacman.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent evt) { editor.setMarkerObjectType(GameObject.OBJECT_PLAYER); |
Clone # 25
Distance between two fragments = 18
Clone size = 16
Source file "detect/contractionLoop/original/editor/EditorFrame.java" The first line is 207 | Source file "detect/contractionLoop/original/editor/EditorFrame.java" The first line is 134 | |
btnSave = new JButton(); getContentPane().add(btnSave); btnSave.setText("Save"); btnSave.setBounds(12, 317, 70, 23); btnSave.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent evt) { editor.saveMap(txtFilename.getText()); |
btnDot = new JButton(); getContentPane().add(btnDot); btnDot.setText("Dot"); btnDot.setBounds(12, 36, 59, 23); btnDot.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent evt) { editor.setMarkerObjectType(GameObject.OBJECT_DOT); |
|
btnLoad = new JButton(); getContentPane().add(btnLoad); btnLoad.setText("Load"); btnLoad.setBounds(87, 317, 68, 23); btnLoad.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent evt) { editor.loadMap(txtFilename.getText()); |
btnPacman = new JButton(); getContentPane().add(btnPacman); btnPacman.setText("Pacman"); btnPacman.setBounds(136, 36, 110, 23); btnPacman.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent evt) { editor.setMarkerObjectType(GameObject.OBJECT_PLAYER); |
Clone # 26
Distance between two fragments = 19
Clone size = 16
Source file "detect/contractionLoop/contractionLoop/editor/EditorFrame.java" The first line is 207 | Source file "detect/contractionLoop/contractionLoop/editor/EditorFrame.java" The first line is 122 | |
btnSave = new JButton(); getContentPane().add(btnSave); btnSave.setText("Save"); btnSave.setBounds(12, 317, 70, 23); btnSave.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent evt) { editor.saveMap(txtFilename.getText()); |
btnWall = new JButton(); getContentPane().add(btnWall); btnWall.setText("Wall"); btnWall.setBounds(12, 218, 59, 23); btnWall.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent evt) { editor.setMarkerObjectType(GameObject.OBJECT_WALL); |
|
btnLoad = new JButton(); getContentPane().add(btnLoad); btnLoad.setText("Load"); btnLoad.setBounds(87, 317, 68, 23); btnLoad.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent evt) { editor.loadMap(txtFilename.getText()); |
btnDot = new JButton(); getContentPane().add(btnDot); btnDot.setText("Dot"); btnDot.setBounds(12, 36, 59, 23); btnDot.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent evt) { editor.setMarkerObjectType(GameObject.OBJECT_DOT); |
Clone # 27
Distance between two fragments = 19
Clone size = 16
Source file "detect/contractionLoop/original/editor/EditorFrame.java" The first line is 207 | Source file "detect/contractionLoop/original/editor/EditorFrame.java" The first line is 122 | |
btnSave = new JButton(); getContentPane().add(btnSave); btnSave.setText("Save"); btnSave.setBounds(12, 317, 70, 23); btnSave.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent evt) { editor.saveMap(txtFilename.getText()); |
btnWall = new JButton(); getContentPane().add(btnWall); btnWall.setText("Wall"); btnWall.setBounds(12, 218, 59, 23); btnWall.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent evt) { editor.setMarkerObjectType(GameObject.OBJECT_WALL); |
|
btnLoad = new JButton(); getContentPane().add(btnLoad); btnLoad.setText("Load"); btnLoad.setBounds(87, 317, 68, 23); btnLoad.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent evt) { editor.loadMap(txtFilename.getText()); |
btnDot = new JButton(); getContentPane().add(btnDot); btnDot.setText("Dot"); btnDot.setBounds(12, 36, 59, 23); btnDot.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent evt) { editor.setMarkerObjectType(GameObject.OBJECT_DOT); |
Clone # 28
Distance between two fragments = 9
Clone size = 16
Source file "detect/contractionLoop/contractionLoop/editor/EditorFrame.java" The first line is 134 | Source file "detect/contractionLoop/contractionLoop/editor/EditorFrame.java" The first line is 122 | |
btnDot = new JButton(); getContentPane().add(btnDot); btnDot.setText("Dot"); btnDot.setBounds(12, 36, 59, 23); btnDot.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent evt) { editor.setMarkerObjectType(GameObject.OBJECT_DOT); |
btnWall = new JButton(); getContentPane().add(btnWall); btnWall.setText("Wall"); btnWall.setBounds(12, 218, 59, 23); btnWall.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent evt) { editor.setMarkerObjectType(GameObject.OBJECT_WALL); |
|
btnPacman = new JButton(); getContentPane().add(btnPacman); btnPacman.setText("Pacman"); btnPacman.setBounds(136, 36, 110, 23); btnPacman.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent evt) { editor.setMarkerObjectType(GameObject.OBJECT_PLAYER); |
btnDot = new JButton(); getContentPane().add(btnDot); btnDot.setText("Dot"); btnDot.setBounds(12, 36, 59, 23); btnDot.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent evt) { editor.setMarkerObjectType(GameObject.OBJECT_DOT); |
Clone # 29
Distance between two fragments = 9
Clone size = 16
Source file "detect/contractionLoop/original/editor/EditorFrame.java" The first line is 134 | Source file "detect/contractionLoop/original/editor/EditorFrame.java" The first line is 122 | |
btnDot = new JButton(); getContentPane().add(btnDot); btnDot.setText("Dot"); btnDot.setBounds(12, 36, 59, 23); btnDot.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent evt) { editor.setMarkerObjectType(GameObject.OBJECT_DOT); |
btnWall = new JButton(); getContentPane().add(btnWall); btnWall.setText("Wall"); btnWall.setBounds(12, 218, 59, 23); btnWall.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent evt) { editor.setMarkerObjectType(GameObject.OBJECT_WALL); |
|
btnPacman = new JButton(); getContentPane().add(btnPacman); btnPacman.setText("Pacman"); btnPacman.setBounds(136, 36, 110, 23); btnPacman.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent evt) { editor.setMarkerObjectType(GameObject.OBJECT_PLAYER); |
btnDot = new JButton(); getContentPane().add(btnDot); btnDot.setText("Dot"); btnDot.setBounds(12, 36, 59, 23); btnDot.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent evt) { editor.setMarkerObjectType(GameObject.OBJECT_DOT); |
Clone # 30
Distance between two fragments = 22
Clone size = 16
Source file "detect/contractionLoop/contractionLoop/editor/EditorFrame.java" The first line is 263 | Source file "detect/contractionLoop/contractionLoop/editor/EditorFrame.java" The first line is 269 | |
lblTeleportSettings = new JLabel(); getContentPane().add(lblTeleportSettings); lblTeleportSettings.setText("Teleport Settings"); lblTeleportSettings.setBounds(237, 196, 123, 16); |
lblTeleportX = new JLabel(); getContentPane().add(lblTeleportX); lblTeleportX.setText("Dest X:"); lblTeleportX.setBounds(237, 249, 60, 16); |
|
lblTeleportX = new JLabel(); getContentPane().add(lblTeleportX); lblTeleportX.setText("Dest X:"); lblTeleportX.setBounds(237, 249, 60, 16); |
lblTeleportY = new JLabel(); getContentPane().add(lblTeleportY); lblTeleportY.setText("Dest Y: "); lblTeleportY.setBounds(235, 279, 52, 16); |
|
lblTeleportY = new JLabel(); getContentPane().add(lblTeleportY); lblTeleportY.setText("Dest Y: "); lblTeleportY.setBounds(235, 279, 52, 16); |
txtTeleportX = new JTextField(); getContentPane().add(txtTeleportX); txtTeleportX.setText("13"); txtTeleportX.setBounds(280, 246, 85, 23); |
|
txtTeleportX = new JTextField(); getContentPane().add(txtTeleportX); txtTeleportX.setText("13"); txtTeleportX.setBounds(280, 246, 85, 23); |
txtTeleportY = new JTextArea(); getContentPane().add(txtTeleportY); txtTeleportY.setText("17"); txtTeleportY.setBounds(280, 275, 82, 20); |
Clone # 31
Distance between two fragments = 22
Clone size = 16
Source file "detect/contractionLoop/original/editor/EditorFrame.java" The first line is 263 | Source file "detect/contractionLoop/original/editor/EditorFrame.java" The first line is 269 | |
lblTeleportSettings = new JLabel(); getContentPane().add(lblTeleportSettings); lblTeleportSettings.setText("Teleport Settings"); lblTeleportSettings.setBounds(237, 196, 123, 16); |
lblTeleportX = new JLabel(); getContentPane().add(lblTeleportX); lblTeleportX.setText("Dest X:"); lblTeleportX.setBounds(237, 249, 60, 16); |
|
lblTeleportX = new JLabel(); getContentPane().add(lblTeleportX); lblTeleportX.setText("Dest X:"); lblTeleportX.setBounds(237, 249, 60, 16); |
lblTeleportY = new JLabel(); getContentPane().add(lblTeleportY); lblTeleportY.setText("Dest Y: "); lblTeleportY.setBounds(235, 279, 52, 16); |
|
lblTeleportY = new JLabel(); getContentPane().add(lblTeleportY); lblTeleportY.setText("Dest Y: "); lblTeleportY.setBounds(235, 279, 52, 16); |
txtTeleportX = new JTextField(); getContentPane().add(txtTeleportX); txtTeleportX.setText("13"); txtTeleportX.setBounds(280, 246, 85, 23); |
|
txtTeleportX = new JTextField(); getContentPane().add(txtTeleportX); txtTeleportX.setText("13"); txtTeleportX.setBounds(280, 246, 85, 23); |
txtTeleportY = new JTextArea(); getContentPane().add(txtTeleportY); txtTeleportY.setText("17"); txtTeleportY.setBounds(280, 275, 82, 20); |
Clone # 32
Distance between two fragments = 0
Clone size = 16
Source file "detect/contractionLoop/contractionLoop/actors/Ghost.java" The first line is 56 | Source file "detect/contractionLoop/original/actors/Ghost.java" The first line is 56 | |
public boolean isInFear() { return inFear; |
public boolean isInFear() { return inFear; |
|
public void setFear(boolean f) { inFear = f; |
public void setFear(boolean f) { inFear = f; |
|
public boolean isTrapped() { return trapped; |
public boolean isTrapped() { return trapped; |
|
public void setTrapped(boolean t) { trapped = t; |
public void setTrapped(boolean t) { trapped = t; |
|
public boolean needsNewPath() { return needNewPath; |
public boolean needsNewPath() { return needNewPath; |
|
public void updatePath(Path p) { nextStepIdx = 1; path = p; needNewPath = false; |
public void updatePath(Path p) { nextStepIdx = 1; path = p; needNewPath = false; |
|
public void setDebugDrawPath(boolean d) { debugDrawPath = d; |
public void setDebugDrawPath(boolean d) { debugDrawPath = d; |
Clone # 33
Distance between two fragments = 0
Clone size = 15
Source file "detect/contractionLoop/contractionLoop/ai/AIManager.java" The first line is 139 | Source file "detect/contractionLoop/original/ai/AIManager.java" The first line is 137 | |
if (!ghost.isTrapped()) { // If fear switches from false to true for this ghost, abandon // their current (and likely) chase path if (!ghost.isInFear() && fear) { ghost.updatePath(null); } ghost.setFear(fear); } else { ghost.setFear(false); |
if (!ghost.isTrapped()) { // If fear switches from false to true for this ghost, abandon // their current (and likely) chase path if (!ghost.isInFear() && fear) { ghost.updatePath(null); } ghost.setFear(fear); } else { ghost.setFear(false); |
|
if (!ghost.isTrapped() && ghost.needsNewPath()) { int randx = player.getX(); int randy = player.getY(); // 45% chance of randomizing a destination, or if they are // fearful if (fear || Math.random() < 0.45) { randx = (int) (Math.random() * map.getWidth()); randy = (int) (Math.random() * map.getHeight()); } final Path p = finder.findPath(ghost, ghost.getX(), ghost.getY(), randx, randy); ghost.updatePath(p); |
if (!ghost.isTrapped() && ghost.needsNewPath()) { int randx = player.getX(); int randy = player.getY(); // 45% chance of randomizing a destination, or if they are // fearful if (fear || Math.random() < 0.45) { randx = (int) (Math.random() * map.getWidth()); randy = (int) (Math.random() * map.getHeight()); } final Path p = finder.findPath(ghost, ghost.getX(), ghost.getY(), randx, randy); ghost.updatePath(p); |
|
ghost.act(); | ghost.act(); | |
ghost.setDebugDrawPath(debugEnabled); | ghost.setDebugDrawPath(debugEnabled); |
Clone # 34
Distance between two fragments = 19
Clone size = 12
Source file "detect/contractionLoop/contractionLoop/editor/EditorFrame.java" The first line is 263 | Source file "detect/contractionLoop/contractionLoop/editor/EditorFrame.java" The first line is 275 | |
lblTeleportSettings = new JLabel(); getContentPane().add(lblTeleportSettings); lblTeleportSettings.setText("Teleport Settings"); lblTeleportSettings.setBounds(237, 196, 123, 16); |
lblTeleportY = new JLabel(); getContentPane().add(lblTeleportY); lblTeleportY.setText("Dest Y: "); lblTeleportY.setBounds(235, 279, 52, 16); |
|
lblTeleportX = new JLabel(); getContentPane().add(lblTeleportX); lblTeleportX.setText("Dest X:"); lblTeleportX.setBounds(237, 249, 60, 16); |
txtTeleportX = new JTextField(); getContentPane().add(txtTeleportX); txtTeleportX.setText("13"); txtTeleportX.setBounds(280, 246, 85, 23); |
|
lblTeleportY = new JLabel(); getContentPane().add(lblTeleportY); lblTeleportY.setText("Dest Y: "); lblTeleportY.setBounds(235, 279, 52, 16); |
txtTeleportY = new JTextArea(); getContentPane().add(txtTeleportY); txtTeleportY.setText("17"); txtTeleportY.setBounds(280, 275, 82, 20); |
Clone # 35
Distance between two fragments = 19
Clone size = 12
Source file "detect/contractionLoop/original/editor/EditorFrame.java" The first line is 263 | Source file "detect/contractionLoop/original/editor/EditorFrame.java" The first line is 275 | |
lblTeleportSettings = new JLabel(); getContentPane().add(lblTeleportSettings); lblTeleportSettings.setText("Teleport Settings"); lblTeleportSettings.setBounds(237, 196, 123, 16); |
lblTeleportY = new JLabel(); getContentPane().add(lblTeleportY); lblTeleportY.setText("Dest Y: "); lblTeleportY.setBounds(235, 279, 52, 16); |
|
lblTeleportX = new JLabel(); getContentPane().add(lblTeleportX); lblTeleportX.setText("Dest X:"); lblTeleportX.setBounds(237, 249, 60, 16); |
txtTeleportX = new JTextField(); getContentPane().add(txtTeleportX); txtTeleportX.setText("13"); txtTeleportX.setBounds(280, 246, 85, 23); |
|
lblTeleportY = new JLabel(); getContentPane().add(lblTeleportY); lblTeleportY.setText("Dest Y: "); lblTeleportY.setBounds(235, 279, 52, 16); |
txtTeleportY = new JTextArea(); getContentPane().add(txtTeleportY); txtTeleportY.setText("17"); txtTeleportY.setBounds(280, 275, 82, 20); |
Clone # 36
Distance between two fragments = 0
Clone size = 12
Source file "detect/contractionLoop/original/ai/AIManager.java" The first line is 92 | Source file "detect/contractionLoop/contractionLoop/ai/AIManager.java" The first line is 94 | |
if (map == null) { return; |
if (map == null) { return; |
|
boolean fear = false; | boolean fear = false; | |
if (map.getPlayer().isPoweredUp()) { fear = true; |
if (map.getPlayer().isPoweredUp()) { fear = true; |
|
if (System.currentTimeMillis() > nextReleaseTime) { for (final Ghost g : ghosts) { if (g.isTrapped()) { g.setTrapped(false); g.move(13, 11); nextReleaseTime = System.currentTimeMillis() + 8000; break; |
if (System.currentTimeMillis() > nextReleaseTime) { for (final Ghost g : ghosts) { if (g.isTrapped()) { g.setTrapped(false); g.move(13, 11); nextReleaseTime = System.currentTimeMillis() + 8000; break; |
Clone # 37
Distance between two fragments = 0
Clone size = 12
Source file "detect/contractionLoop/original/map/Map.java" The first line is 564 | Source file "detect/contractionLoop/contractionLoop/map/Map.java" The first line is 570 | |
item = itemMap[x][y]; | item = itemMap[x][y]; | |
if (item == null) { data.writeBoolean(false); continue; |
if (item == null) { data.writeBoolean(false); continue; |
|
data.writeBoolean(true); | data.writeBoolean(true); | |
data.writeInt(item.getType()); | data.writeInt(item.getType()); | |
data.writeInt(item.getX()); | data.writeInt(item.getX()); | |
data.writeInt(item.getY()); | data.writeInt(item.getY()); | |
data.writeInt(item.getColor().getRGB()); | data.writeInt(item.getColor().getRGB()); | |
if (item.getType() == GameObject.OBJECT_TELEPORT) { data.writeInt(item.getTeleportX()); data.writeInt(item.getTeleportY()); |
if (item.getType() == GameObject.OBJECT_TELEPORT) { data.writeInt(item.getTeleportX()); data.writeInt(item.getTeleportY()); |
Clone # 38
Distance between two fragments = 0
Clone size = 12
Source file "detect/contractionLoop/contractionLoop/state/StateEditor.java" The first line is 360 | Source file "detect/contractionLoop/original/state/StateEditor.java" The first line is 359 | |
if (markerGhostType.equals("Blinky")) { map.addActor(new Ghost(Color.RED, map, marker.getX(), marker.getY(), markerGhostTrapped)); } else if (markerGhostType.equals("Pinky")) { map.addActor(new Ghost(Color.PINK, map, marker.getX(), marker.getY(), markerGhostTrapped)); } else if (markerGhostType.equals("Inky")) { map.addActor(new Ghost(Color.CYAN, map, marker.getX(), marker.getY(), markerGhostTrapped)); } else { map.addActor(new Ghost(Color.ORANGE, map, marker.getX(), marker.getY(), markerGhostTrapped)); |
if (markerGhostType.equals("Blinky")) { map.addActor(new Ghost(Color.RED, map, marker.getX(), marker.getY(), markerGhostTrapped)); } else if (markerGhostType.equals("Pinky")) { map.addActor(new Ghost(Color.PINK, map, marker.getX(), marker.getY(), markerGhostTrapped)); } else if (markerGhostType.equals("Inky")) { map.addActor(new Ghost(Color.CYAN, map, marker.getX(), marker.getY(), markerGhostTrapped)); } else { map.addActor(new Ghost(Color.ORANGE, map, marker.getX(), marker.getY(), markerGhostTrapped)); |
|
break; | break; |
Clone # 39
Distance between two fragments = 0
Clone size = 11
Source file "detect/contractionLoop/original/map/Map.java" The first line is 618 | Source file "detect/contractionLoop/contractionLoop/map/Map.java" The first line is 621 | |
fin = new FileInputStream(filename); | fin = new FileInputStream(filename); | |
data = new DataInputStream(fin); | data = new DataInputStream(fin); | |
if (!data.readUTF().equals("RKPACMAP")) { System.out.println("Not a map file!"); return; |
if (!data.readUTF().equals("RKPACMAP")) { System.out.println("Not a map file!"); return; |
|
mapWidth = data.readInt(); | mapWidth = data.readInt(); | |
mapHeight = data.readInt(); | mapHeight = data.readInt(); | |
dotsRemaining = 0; | dotsRemaining = 0; | |
collideMap = new byte[mapWidth][mapHeight]; | collideMap = new byte[mapWidth][mapHeight]; | |
itemMap = new Item[mapWidth][mapHeight]; | itemMap = new Item[mapWidth][mapHeight]; | |
actorList = new ArrayList<Actor>(); | actorList = new ArrayList<Actor>(); |
Clone # 40
Distance between two fragments = 0
Clone size = 11
Source file "detect/contractionLoop/original/map/Map.java" The first line is 656 | Source file "detect/contractionLoop/contractionLoop/map/Map.java" The first line is 662 | |
if (!data.readBoolean()) { continue; |
if (!data.readBoolean()) { continue; |
|
final int t = data.readInt(); | final int t = data.readInt(); | |
final int ix = data.readInt(); | final int ix = data.readInt(); | |
final int iy = data.readInt(); | final int iy = data.readInt(); | |
final Color c = new Color(data.readInt()); | final Color c = new Color(data.readInt()); | |
addItem(new Item(t, c, this, ix, iy)); | addItem(new Item(t, c, this, ix, iy)); | |
if (t == GameObject.OBJECT_TELEPORT) { final int teleX = data.readInt(); final int teleY = data.readInt(); itemMap[ix][iy].setTeleport(teleX, teleY); |
if (t == GameObject.OBJECT_TELEPORT) { final int teleX = data.readInt(); final int teleY = data.readInt(); itemMap[ix][iy].setTeleport(teleX, teleY); |
Clone # 41
Distance between two fragments = 0
Clone size = 10
Source file "detect/contractionLoop/contractionLoop/state/StateGame.java" The first line is 102 | Source file "detect/contractionLoop/original/state/StateGame.java" The first line is 102 | |
currentLevel++; // Force previous references out of scope player = null; map = null; ai = null; // Setup the game map game.getGraphicsContext().setBackground(Color.BLACK); map = new Map(mapName, 0.75); mapWidth = map.getWidth(); mapHeight = map.getHeight(); // Spawn the player player = map.getPlayer(); // Setup AI ai = new AIManager(map, player, game.isDebugEnabled()); |
currentLevel++; // Force previous references out of scope player = null; map = null; ai = null; // Setup the game map game.getGraphicsContext().setBackground(Color.BLACK); map = new Map(mapName, 0.75); mapWidth = map.getWidth(); mapHeight = map.getHeight(); // Spawn the player player = map.getPlayer(); // Setup AI ai = new AIManager(map, player, game.isDebugEnabled()); |
Clone # 42
Distance between two fragments = 0
Clone size = 10
Source file "detect/contractionLoop/original/actors/Player.java" The first line is 54 | Source file "detect/contractionLoop/contractionLoop/actors/Player.java" The first line is 54 | |
public void incrementScore(int amt) { m_iScore += amt; |
public void incrementScore(int amt) { m_iScore += amt; |
|
public int getScore() { return m_iScore; |
public int getScore() { return m_iScore; |
|
public boolean isPoweredUp() { return isPowered; |
public boolean isPoweredUp() { return isPowered; |
|
public void setPowerUp(boolean x) { isPowered = x; // If powered up, start the timer and increase speed temporarily if (isPowered) { poweredExpireTime = System.currentTimeMillis() + 10000; |
public void setPowerUp(boolean x) { isPowered = x; // If powered up, start the timer and increase speed temporarily if (isPowered) { poweredExpireTime = System.currentTimeMillis() + 10000; |
Clone # 43
Distance between two fragments = 29
Clone size = 10
Source file "detect/contractionLoop/contractionLoop/map/PathFinder.java" The first line is 213 | Source file "detect/contractionLoop/contractionLoop/map/PathFinder.java" The first line is 224 | |
protected void addToOpen(Node node) { open.add(node); |
protected boolean inOpenList(Node node) { return open.contains(node); |
|
protected boolean inOpenList(Node node) { return open.contains(node); |
protected void removeFromOpen(Node node) { open.remove(node); |
|
protected void removeFromOpen(Node node) { open.remove(node); |
protected void addToClosed(Node node) { closed.add(node); |
|
protected void addToClosed(Node node) { closed.add(node); |
protected boolean inClosedList(Node node) { return closed.contains(node); |
|
protected boolean inClosedList(Node node) { return closed.contains(node); |
protected void removeFromClosed(Node node) { closed.remove(node); |
Clone # 44
Distance between two fragments = 29
Clone size = 10
Source file "detect/contractionLoop/contractionLoop/map/PathFinder.java" The first line is 213 | Source file "detect/contractionLoop/original/map/PathFinder.java" The first line is 261 | |
protected void addToOpen(Node node) { open.add(node); |
protected boolean inOpenList(Node node) { return open.contains(node); |
|
protected boolean inOpenList(Node node) { return open.contains(node); |
protected void removeFromOpen(Node node) { open.remove(node); |
|
protected void removeFromOpen(Node node) { open.remove(node); |
protected void addToClosed(Node node) { closed.add(node); |
|
protected void addToClosed(Node node) { closed.add(node); |
protected boolean inClosedList(Node node) { return closed.contains(node); |
|
protected boolean inClosedList(Node node) { return closed.contains(node); |
protected void removeFromClosed(Node node) { closed.remove(node); |
Clone # 45
Distance between two fragments = 29
Clone size = 10
Source file "detect/contractionLoop/original/map/PathFinder.java" The first line is 250 | Source file "detect/contractionLoop/contractionLoop/map/PathFinder.java" The first line is 224 | |
protected void addToOpen(Node node) { open.add(node); |
protected boolean inOpenList(Node node) { return open.contains(node); |
|
protected boolean inOpenList(Node node) { return open.contains(node); |
protected void removeFromOpen(Node node) { open.remove(node); |
|
protected void removeFromOpen(Node node) { open.remove(node); |
protected void addToClosed(Node node) { closed.add(node); |
|
protected void addToClosed(Node node) { closed.add(node); |
protected boolean inClosedList(Node node) { return closed.contains(node); |
|
protected boolean inClosedList(Node node) { return closed.contains(node); |
protected void removeFromClosed(Node node) { closed.remove(node); |
Clone # 46
Distance between two fragments = 29
Clone size = 10
Source file "detect/contractionLoop/original/map/PathFinder.java" The first line is 250 | Source file "detect/contractionLoop/original/map/PathFinder.java" The first line is 261 | |
protected void addToOpen(Node node) { open.add(node); |
protected boolean inOpenList(Node node) { return open.contains(node); |
|
protected boolean inOpenList(Node node) { return open.contains(node); |
protected void removeFromOpen(Node node) { open.remove(node); |
|
protected void removeFromOpen(Node node) { open.remove(node); |
protected void addToClosed(Node node) { closed.add(node); |
|
protected void addToClosed(Node node) { closed.add(node); |
protected boolean inClosedList(Node node) { return closed.contains(node); |
|
protected boolean inClosedList(Node node) { return closed.contains(node); |
protected void removeFromClosed(Node node) { closed.remove(node); |
Clone # 47
Distance between two fragments = 0
Clone size = 10
Source file "detect/contractionLoop/contractionLoop/map/Map.java" The first line is 52 | Source file "detect/contractionLoop/original/map/Map.java" The first line is 52 | |
mapWidth = w; | mapWidth = w; | |
mapHeight = h; | mapHeight = h; | |
SCALE = scale; | SCALE = scale; | |
CELL_SIZE = (int) (32 * scale); | CELL_SIZE = (int) (32 * scale); | |
WALL_THICKNESS = (int) (12 * scale); | WALL_THICKNESS = (int) (12 * scale); | |
WALL_OVERLAP = (int) (10 * scale); | WALL_OVERLAP = (int) (10 * scale); | |
dotsRemaining = 0; | dotsRemaining = 0; | |
collideMap = new byte[mapWidth][mapHeight]; | collideMap = new byte[mapWidth][mapHeight]; | |
itemMap = new Item[mapWidth][mapHeight]; | itemMap = new Item[mapWidth][mapHeight]; | |
actorList = new ArrayList<Actor>(); | actorList = new ArrayList<Actor>(); |
Clone # 48
Distance between two fragments = 0
Clone size = 10
Source file "detect/contractionLoop/contractionLoop/state/StateEditor.java" The first line is 49 | Source file "detect/contractionLoop/original/state/StateEditor.java" The first line is 49 | |
gameView = false; | gameView = false; | |
game.getFrame().setSize(1024, game.RES_Y); | game.getFrame().setSize(1024, game.RES_Y); | |
editorFrame = new EditorFrame(this); | editorFrame = new EditorFrame(this); | |
editorFrame.setVisible(true); | editorFrame.setVisible(true); | |
markerObjectType = GameObject.OBJECT_WALL; | markerObjectType = GameObject.OBJECT_WALL; | |
markerWallType = GameObject.WALL_VERTICAL; | markerWallType = GameObject.WALL_VERTICAL; | |
markerGhostType = "Blinky"; | markerGhostType = "Blinky"; | |
markerGhostTrapped = false; | markerGhostTrapped = false; | |
markerTeleportX = 13; | markerTeleportX = 13; | |
markerTeleportY = 17; | markerTeleportY = 17; |
Clone # 49
Distance between two fragments = 18
Clone size = 10
Source file "detect/contractionLoop/contractionLoop/game/GameObject.java" The first line is 55 | Source file "detect/contractionLoop/contractionLoop/game/Game.java" The first line is 116 | |
public int getType() { return objType; |
public Graphics2D getGraphicsContext() { return (Graphics2D) m_gBuffer.getDrawGraphics(); |
|
public Color getColor() { return objColor; |
public String getStartMap() { return startMap; |
|
public void setColor(Color c) { objColor = c; |
public void setStartMap(String m) { startMap = m; |
|
public int getX() { return positionX; |
public boolean isDebugEnabled() { return debugEnabled; |
|
public int getY() { return positionY; |
public void toggleDebug() { debugEnabled = !debugEnabled; |
Clone # 50
Distance between two fragments = 18
Clone size = 10
Source file "detect/contractionLoop/contractionLoop/game/GameObject.java" The first line is 55 | Source file "detect/contractionLoop/original/game/Game.java" The first line is 116 | |
public int getType() { return objType; |
public Graphics2D getGraphicsContext() { return (Graphics2D) m_gBuffer.getDrawGraphics(); |
|
public Color getColor() { return objColor; |
public String getStartMap() { return startMap; |
|
public void setColor(Color c) { objColor = c; |
public void setStartMap(String m) { startMap = m; |
|
public int getX() { return positionX; |
public boolean isDebugEnabled() { return debugEnabled; |
|
public int getY() { return positionY; |
public void toggleDebug() { debugEnabled = !debugEnabled; |
Clone # 51
Distance between two fragments = 18
Clone size = 10
Source file "detect/contractionLoop/original/game/GameObject.java" The first line is 55 | Source file "detect/contractionLoop/contractionLoop/game/Game.java" The first line is 116 | |
public int getType() { return objType; |
public Graphics2D getGraphicsContext() { return (Graphics2D) m_gBuffer.getDrawGraphics(); |
|
public Color getColor() { return objColor; |
public String getStartMap() { return startMap; |
|
public void setColor(Color c) { objColor = c; |
public void setStartMap(String m) { startMap = m; |
|
public int getX() { return positionX; |
public boolean isDebugEnabled() { return debugEnabled; |
|
public int getY() { return positionY; |
public void toggleDebug() { debugEnabled = !debugEnabled; |
Clone # 52
Distance between two fragments = 18
Clone size = 10
Source file "detect/contractionLoop/original/game/GameObject.java" The first line is 55 | Source file "detect/contractionLoop/original/game/Game.java" The first line is 116 | |
public int getType() { return objType; |
public Graphics2D getGraphicsContext() { return (Graphics2D) m_gBuffer.getDrawGraphics(); |
|
public Color getColor() { return objColor; |
public String getStartMap() { return startMap; |
|
public void setColor(Color c) { objColor = c; |
public void setStartMap(String m) { startMap = m; |
|
public int getX() { return positionX; |
public boolean isDebugEnabled() { return debugEnabled; |
|
public int getY() { return positionY; |
public void toggleDebug() { debugEnabled = !debugEnabled; |
Clone # 53
Distance between two fragments = 14
Clone size = 10
Source file "detect/contractionLoop/contractionLoop/actors/Actor.java" The first line is 104 | Source file "detect/contractionLoop/contractionLoop/actors/Ghost.java" The first line is 56 | |
public int getSpawnY() { return spawnY; |
public boolean isInFear() { return inFear; |
|
public void setDead(boolean s) { isDead = s; |
public void setFear(boolean f) { inFear = f; |
|
public boolean isDead() { return isDead; |
public boolean isTrapped() { return trapped; |
|
public void setSpeed(float s) { speed = s; |
public void setTrapped(boolean t) { trapped = t; |
|
public float getSpeed() { return speed; |
public boolean needsNewPath() { return needNewPath; |
Clone # 54
Distance between two fragments = 14
Clone size = 10
Source file "detect/contractionLoop/contractionLoop/actors/Actor.java" The first line is 104 | Source file "detect/contractionLoop/original/actors/Ghost.java" The first line is 56 | |
public int getSpawnY() { return spawnY; |
public boolean isInFear() { return inFear; |
|
public void setDead(boolean s) { isDead = s; |
public void setFear(boolean f) { inFear = f; |
|
public boolean isDead() { return isDead; |
public boolean isTrapped() { return trapped; |
|
public void setSpeed(float s) { speed = s; |
public void setTrapped(boolean t) { trapped = t; |
|
public float getSpeed() { return speed; |
public boolean needsNewPath() { return needNewPath; |
Clone # 55
Distance between two fragments = 14
Clone size = 10
Source file "detect/contractionLoop/original/actors/Actor.java" The first line is 104 | Source file "detect/contractionLoop/contractionLoop/actors/Ghost.java" The first line is 56 | |
public int getSpawnY() { return spawnY; |
public boolean isInFear() { return inFear; |
|
public void setDead(boolean s) { isDead = s; |
public void setFear(boolean f) { inFear = f; |
|
public boolean isDead() { return isDead; |
public boolean isTrapped() { return trapped; |
|
public void setSpeed(float s) { speed = s; |
public void setTrapped(boolean t) { trapped = t; |
|
public float getSpeed() { return speed; |
public boolean needsNewPath() { return needNewPath; |
Clone # 56
Distance between two fragments = 14
Clone size = 10
Source file "detect/contractionLoop/original/actors/Actor.java" The first line is 104 | Source file "detect/contractionLoop/original/actors/Ghost.java" The first line is 56 | |
public int getSpawnY() { return spawnY; |
public boolean isInFear() { return inFear; |
|
public void setDead(boolean s) { isDead = s; |
public void setFear(boolean f) { inFear = f; |
|
public boolean isDead() { return isDead; |
public boolean isTrapped() { return trapped; |
|
public void setSpeed(float s) { speed = s; |
public void setTrapped(boolean t) { trapped = t; |
|
public float getSpeed() { return speed; |
public boolean needsNewPath() { return needNewPath; |
Clone # 57
Distance between two fragments = 0
Clone size = 10
Source file "detect/contractionLoop/original/state/StateGame.java" The first line is 65 | Source file "detect/contractionLoop/contractionLoop/state/StateGame.java" The first line is 65 | |
public int getSessionScore() { return sessionScore; |
public int getSessionScore() { return sessionScore; |
|
@Override public void reset() { // Set game vars mapName = game.getStartMap(); currentLevel = 0; sessionScore = 0; livesRemaining = 99; pauseTime = 0; // Respawn (start level 1) respawn(true); |
@Override public void reset() { // Set game vars mapName = game.getStartMap(); currentLevel = 0; sessionScore = 0; livesRemaining = 99; pauseTime = 0; // Respawn (start level 1) respawn(true); |
Clone # 58
Distance between two fragments = 0
Clone size = 10
Source file "detect/contractionLoop/contractionLoop/map/Map.java" The first line is 590 | Source file "detect/contractionLoop/original/map/Map.java" The first line is 587 | |
data.writeInt(actorList.size()); | data.writeInt(actorList.size()); | |
for (final Actor a : actorList) { data.writeInt(a.getType()); data.writeInt(a.getX()); data.writeInt(a.getY()); data.writeInt(a.getColor().getRGB()); if (a.getType() == GameObject.OBJECT_GHOST) { data.writeBoolean(((Ghost) a).isTrapped()); |
for (final Actor a : actorList) { data.writeInt(a.getType()); data.writeInt(a.getX()); data.writeInt(a.getY()); data.writeInt(a.getColor().getRGB()); if (a.getType() == GameObject.OBJECT_GHOST) { data.writeBoolean(((Ghost) a).isTrapped()); |
|
data.close(); | data.close(); | |
fout.close(); | fout.close(); |
(*) Warning: the highlighting of differences is based on diff and doesn't reflect the tree-based clone detection algorithm.