Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Fixed a heck of a lot of stupid bits. Also a lot of critique.
- Loading branch information
Eyal Minsky-Fenick
committed
Feb 26, 2016
1 parent
83f3959
commit 65e7d1f
Showing
6 changed files
with
130 additions
and
114 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -1,21 +1,25 @@ | |||
package images; | package images; | ||
|
|
||
import java.awt.Image; | import java.awt.Image; | ||
|
// The fuck does shipinter stand for? | ||
public class Shipinter { | // Also, don't forget to PascalCase class names. | ||
Image image; | // I won't fix this one. | ||
public Shipinter(Image shipID){ | public class Shipinter { | ||
this.image = shipID; | Image image; | ||
} | public Shipinter(Image shipID){ | ||
//added a method to retrieve the size of the ship, so it can be drawn onto the actual game. | this.image = shipID; | ||
//the Size is stored in an array where [1] is the width and [2] is the height | } | ||
//it can be used for both player ships and enemy ships | // WHY IS THE IMAGE PARAMETER CALLED SHIPID? | ||
public int[] getsize(){ | //added a method to retrieve the size of the ship, so it can be drawn onto the actual game. | ||
int[] shipsize; | // You'll need to have a method to either get the image or to draw it-Eyal | ||
shipsize = new int[2]; | //the Size is stored in an array where [1] is the width and [2] is the height | ||
shipsize[1] = image.getWidth(null); | //it can be used for both player ships and enemy ships | ||
shipsize[2] = image.getHeight(null); | public int[] getsize(){ | ||
return shipsize; | int[] shipsize; | ||
} | shipsize = new int[2]; | ||
|
shipsize[1] = image.getWidth(null); | ||
} | shipsize[2] = image.getHeight(null); | ||
return shipsize; | |||
} | |||
|
|||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -1,70 +1,70 @@ | |||
package main; | package main; | ||
|
|
||
|
|
||
|
|
||
import java.awt.Dimension; | import java.awt.Dimension; | ||
import java.awt.event.ActionEvent; | import java.awt.event.ActionEvent; | ||
import java.awt.event.ActionListener; | import java.awt.event.ActionListener; | ||
import java.awt.image.BufferStrategy; | import java.awt.image.BufferStrategy; | ||
|
|
||
|
|
||
|
|
||
|
|
||
import javax.swing.JFrame; | import javax.swing.JFrame; | ||
import javax.swing.JMenu; | import javax.swing.JMenu; | ||
import javax.swing.JMenuBar; | import javax.swing.JMenuBar; | ||
import javax.swing.JMenuItem; | import javax.swing.JMenuItem; | ||
import javax.swing.JPanel; | import javax.swing.JPanel; | ||
|
|
||
public class Game implements ActionListener { | public class Game implements ActionListener { | ||
BufferStrategy strategy; | BufferStrategy strategy; | ||
public Game(){ | public Game() { | ||
JFrame container = new JFrame("CSE 2102"); | JFrame container = new JFrame("CSE 2102"); | ||
container.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); | container.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); | ||
|
|
||
JPanel panel = (JPanel) container.getContentPane(); | JPanel panel = (JPanel) container.getContentPane(); | ||
panel.setPreferredSize(new Dimension(800,600)); | panel.setPreferredSize(new Dimension(800,600)); | ||
panel.setLayout(null); | panel.setLayout(null); | ||
|
|
||
panel.setBounds(0,0,800,600); | panel.setBounds(0,0,800,600); | ||
|
|
||
panel.setIgnoreRepaint(true); | panel.setIgnoreRepaint(true); | ||
|
|
||
JMenuBar jmenubar = new JMenuBar(); | JMenuBar jmenubar = new JMenuBar(); | ||
|
|||
JMenu jmGameOptions = new JMenu("Game"); | JMenu jmGameOptions = new JMenu("Game"); | ||
JMenuItem jmiOpen = new JMenuItem("Open"); | JMenuItem jmiOpen = new JMenuItem("Open"); | ||
jmGameOptions.add(jmiOpen); | jmGameOptions.add(jmiOpen); | ||
jmiOpen.addActionListener(this); | jmiOpen.addActionListener(this); | ||
JMenuItem jmiClose = new JMenuItem("Close"); | JMenuItem jmiClose = new JMenuItem("Close"); | ||
jmGameOptions.add(jmiClose); | jmGameOptions.add(jmiClose); | ||
jmiClose.addActionListener(this); | jmiClose.addActionListener(this); | ||
JMenuItem jmiSave = new JMenuItem("Save"); | JMenuItem jmiSave = new JMenuItem("Save"); | ||
jmGameOptions.add(jmiSave); | jmGameOptions.add(jmiSave); | ||
jmiSave.addActionListener(this); | jmiSave.addActionListener(this); | ||
JMenuItem jmiExit = new JMenuItem("Exit"); | JMenuItem jmiExit = new JMenuItem("Exit"); | ||
jmGameOptions.add(jmiExit); | jmGameOptions.add(jmiExit); | ||
jmiExit.addActionListener(this); | jmiExit.addActionListener(this); | ||
jmenubar.add(jmGameOptions); | jmenubar.add(jmGameOptions); | ||
|
|||
|
|||
container.setJMenuBar(jmenubar); | container.setJMenuBar(jmenubar); | ||
container.setVisible(true); | container.setVisible(true); | ||
|
|||
|
|
||
container.pack(); | container.pack(); | ||
container.setResizable(false); | container.setResizable(false); | ||
|
|
||
|
|||
} | } | ||
public void actionPerformed(ActionEvent ae) { | public void actionPerformed(ActionEvent ae) { | ||
String comStr = ae.getActionCommand(); | String comStr = ae.getActionCommand(); | ||
System.out.println(comStr + " Selected"); | System.out.println(comStr + " Selected"); | ||
} | } | ||
} | } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -1,10 +1,11 @@ | |||
package main; | package main; | ||
|
|
||
import java.awt.Dimension; | import java.awt.Dimension; | ||
|
// I think it's ugly to have two separate classes. Just have one class. | ||
import javax.swing.*; | // I won't change this, though. | ||
public class Main extends JFrame{ | import javax.swing.*; | ||
public static void main(String[] args){ | public class Main extends JFrame{ | ||
new Game(); | public static void main(String[] args){ | ||
} | new Game(); | ||
} | } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,7 @@ | |||
package ship; | |||
|
|||
public class PlayerShip extends ship{ | |||
public void move() {} // WHY ISN'T THIS IN SHIP? | |||
// MAYBE SHIP SHOULD BE AN INTERFACE? | |||
// ALSO ABSTRACT METHODS ARE BANNED FROM CONCRETE CLASSES. | |||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -1,8 +1,17 @@ | |||
package ship; | package ship; | ||
|
|
||
public class ship { | /* | ||
static int posx; | NO | ||
static int posy; | NO | ||
|
NO | ||
|
NO | ||
} | NO | ||
NO | |||
EACH SHIP SHOULD HAVE ITS OWN POSITION. | |||
(also, it doesn't hurt to keep positions as doubles and round them) | |||
*/ | |||
|
|||
public class ship { | |||
static int posx; | |||
static int posy; | |||
} |