Skip to content
Permalink
Browse files

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 83f39598ba29e833d7c4caef5149850691f90e8b
Showing with 80 additions and 15 deletions.
  1. +1 −0 .classpath
  2. +21 −0 src/images/Shipinter.java
  3. +55 −3 src/main/Game.java
  4. +2 −11 src/main/Main.java
  5. +1 −1 src/ship/ship.java
@@ -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>
@@ -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;
}

}
@@ -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");
}
}
@@ -5,15 +5,6 @@
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();
}
}
@@ -3,6 +3,6 @@
public class ship {
static int posx;
static int posy;
static int health;


}

0 comments on commit 83f3959

Please sign in to comment.
You can’t perform that action at this time.