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
My Laptop is dying so I am going to push this. I have added a menu to
the main screen along with buttons, they dont really do anything though. I have also added a method for retrieving the size of the ship images and storing it in an array
- Loading branch information
Showing
5 changed files
with
80 additions
and
15 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
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 | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package images; | ||
|
||
import java.awt.Image; | ||
|
||
public class Shipinter { | ||
Image image; | ||
public Shipinter(Image shipID){ | ||
this.image = shipID; | ||
} | ||
//added a method to retrieve the size of the ship, so it can be drawn onto the actual game. | ||
//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 | ||
public int[] getsize(){ | ||
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 | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,70 @@ | ||
package main; | ||
|
||
|
||
|
||
import java.awt.Dimension; | ||
import java.awt.event.ActionEvent; | ||
import java.awt.event.ActionListener; | ||
import java.awt.image.BufferStrategy; | ||
|
||
|
||
|
||
|
||
import javax.swing.JFrame; | ||
import javax.swing.JMenu; | ||
import javax.swing.JMenuBar; | ||
import javax.swing.JMenuItem; | ||
import javax.swing.JPanel; | ||
|
||
public class Game { | ||
public class Game implements ActionListener { | ||
BufferStrategy strategy; | ||
public Game(){ | ||
JFrame container = new JFrame("Padraic"); | ||
JFrame container = new JFrame("CSE 2102"); | ||
container.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); | ||
|
||
JPanel panel = (JPanel) container.getContentPane(); | ||
panel.setPreferredSize(new Dimension(800,600)); | ||
panel.setLayout(null); | ||
|
||
panel.setBounds(0,0,800,600); | ||
setIgnoreRepaint(true); | ||
|
||
panel.setIgnoreRepaint(true); | ||
|
||
JMenuBar jmenubar = new JMenuBar(); | ||
|
||
JMenu jmGameOptions = new JMenu("Game"); | ||
|
||
JMenuItem jmiOpen = new JMenuItem("Open"); | ||
jmGameOptions.add(jmiOpen); | ||
jmiOpen.addActionListener(this); | ||
|
||
JMenuItem jmiClose = new JMenuItem("Close"); | ||
jmGameOptions.add(jmiClose); | ||
jmiClose.addActionListener(this); | ||
|
||
JMenuItem jmiSave = new JMenuItem("Save"); | ||
jmGameOptions.add(jmiSave); | ||
jmiSave.addActionListener(this); | ||
|
||
JMenuItem jmiExit = new JMenuItem("Exit"); | ||
jmGameOptions.add(jmiExit); | ||
jmiExit.addActionListener(this); | ||
|
||
jmenubar.add(jmGameOptions); | ||
|
||
|
||
container.setJMenuBar(jmenubar); | ||
container.setVisible(true); | ||
|
||
|
||
|
||
container.pack(); | ||
container.setResizable(false); | ||
|
||
|
||
} | ||
public void actionPerformed(ActionEvent ae) { | ||
String comStr = ae.getActionCommand(); | ||
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
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 | Diff line number | Diff line change |
---|---|---|
|
@@ -3,6 +3,6 @@ package ship; | |
public class ship { | ||
static int posx; | ||
static int posy; | ||
static int health; | ||
|
||
|
||
} |