Skip to content

Commit

Permalink
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
jdm13003 committed Feb 26, 2016
1 parent 6f7cbd2 commit 83f3959
Show file tree
Hide file tree
Showing 5 changed files with 80 additions and 15 deletions.
1 change: 1 addition & 0 deletions .classpath
Expand Up @@ -2,5 +2,6 @@
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
<classpathentry kind="output" path="bin"/>
</classpath>
21 changes: 21 additions & 0 deletions src/images/Shipinter.java
@@ -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;
}

}
58 changes: 55 additions & 3 deletions src/main/Game.java
@@ -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");
}
}
13 changes: 2 additions & 11 deletions src/main/Main.java
Expand Up @@ -5,15 +5,6 @@ import java.awt.Dimension;
import javax.swing.*;
public class Main extends JFrame{
public static void main(String[] args){
new Game();
}
public void Game(){
JFrame container = new JFrame("Padraic");
JPanel panel = (JPanel) container.getContentPane();
Dimension D = new Dimension(800,600);
panel.setPreferredSize(new Dimension(800,600));


}

new Game();
}
}
2 changes: 1 addition & 1 deletion src/ship/ship.java
Expand Up @@ -3,6 +3,6 @@ package ship;
public class ship {
static int posx;
static int posy;
static int health;


}

0 comments on commit 83f3959

Please sign in to comment.