Skip to content
Snippets Groups Projects
Commit 9ae9620d authored by taskat's avatar taskat
Browse files

Item placing corrected

parent fc6fddc3
Branches fikuszkukisz
No related tags found
No related merge requests found
...@@ -47,7 +47,7 @@ public class Board { ...@@ -47,7 +47,7 @@ public class Board {
//place essential objects on stable fields //place essential objects on stable fields
while(essentials.size() != 0){ while(essentials.size() != 0){
int idx = rnd.nextInt(fields.size()); int idx = rnd.nextInt(fields.size());
if(fields.get(idx).getCapacity() == 10 && fields.get(idx).getItem() == null){ if(fields.get(idx).getCapacity() == 10 && fields.get(idx).item == null){
fields.get(idx).addItem(essentials.get(0)); fields.get(idx).addItem(essentials.get(0));
essentials.remove(0); essentials.remove(0);
} }
...@@ -55,7 +55,7 @@ public class Board { ...@@ -55,7 +55,7 @@ public class Board {
//place other items to remaining fields //place other items to remaining fields
while(otheritems.size() != 0){ while(otheritems.size() != 0){
int idx = rnd.nextInt(fields.size()); int idx = rnd.nextInt(fields.size());
if(fields.get(idx).getCapacity() != 0 && fields.get(idx).getItem() == null){ if(fields.get(idx).getCapacity() != 0 && fields.get(idx).item == null){
fields.get(idx).addItem(otheritems.get(0)); fields.get(idx).addItem(otheritems.get(0));
otheritems.remove(0); otheritems.remove(0);
} }
......
...@@ -185,10 +185,8 @@ public class GameWindow extends JFrame{ ...@@ -185,10 +185,8 @@ public class GameWindow extends JFrame{
UI.put("Panel.background", Color.white); UI.put("Panel.background", Color.white);
String[] size = {"4", "5", "6", "7"}; String[] size = {"4", "5", "6", "7"};
String[] players = {"2", "3", "4", "5", "6"}; String[] players = {"2", "3", "4", "5", "6"};
String[] difficulty = {"CakeWalk", "Saturdy afternoon", "Sure?", "You are kidding!", "White hell"};
JComboBox<String> combo = new JComboBox<>(size); JComboBox<String> combo = new JComboBox<>(size);
JComboBox<String> combo1 = new JComboBox<>(players); JComboBox<String> combo1 = new JComboBox<>(players);
JComboBox<String> combo2 = new JComboBox<>(difficulty);
JPanel panel0 = new JPanel(new FlowLayout()); JPanel panel0 = new JPanel(new FlowLayout());
JPanel panel = new JPanel(new GridLayout(0, 1)); JPanel panel = new JPanel(new GridLayout(0, 1));
JLabel bear = new JLabel(new ImageIcon("src/arctic_nightmare/resources/icebear.gif")); JLabel bear = new JLabel(new ImageIcon("src/arctic_nightmare/resources/icebear.gif"));
...@@ -197,12 +195,10 @@ public class GameWindow extends JFrame{ ...@@ -197,12 +195,10 @@ public class GameWindow extends JFrame{
panel.add(combo); panel.add(combo);
panel.add(new JLabel("Players :")); panel.add(new JLabel("Players :"));
panel.add(combo1); panel.add(combo1);
panel.add(new JLabel("Difficulty :"));
panel.add(combo2);
panel0.add(panel); panel0.add(panel);
panel0.add(bear); panel0.add(bear);
int result = JOptionPane.showConfirmDialog(null, panel0, "Game options", JOptionPane.DEFAULT_OPTION, JOptionPane.PLAIN_MESSAGE); int result = JOptionPane.showConfirmDialog(null, panel0, "Game options", JOptionPane.DEFAULT_OPTION, JOptionPane.PLAIN_MESSAGE);
return new Object[]{combo.getSelectedItem(), combo1.getSelectedItem(), combo2.getSelectedItem()}; return new Object[]{combo.getSelectedItem(), combo1.getSelectedItem()};
} }
static public String getPlayerOptions(int count) static public String getPlayerOptions(int count)
......
...@@ -5,32 +5,19 @@ ...@@ -5,32 +5,19 @@
*/ */
package arctic_nightmare; package arctic_nightmare;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import javax.imageio.ImageIO;
import javax.swing.ImageIcon; import javax.swing.ImageIcon;
import javax.swing.JFrame; import javax.swing.JFrame;
import javax.swing.JLabel; import javax.swing.JLabel;
/**
*
* @author csellar
*/
public class ScaledImagePanel extends JLabel{ public class ScaledImagePanel extends JLabel{
private BufferedImage image;
public ScaledImagePanel(JFrame window, String file, int x, int y, int width, int height) { public ScaledImagePanel(JFrame window, String file, int x, int y, int width, int height) {
super(new ImageIcon(GameWindow.getScaledImage((new ImageIcon(file)).getImage(), width, height))); super(new ImageIcon(GameWindow.getScaledImage((new ImageIcon(file)).getImage(), width, height)));
setBounds(x, y, width, height); setBounds(x, y, width, height);
setVisible(true); setVisible(true);
window.add(this); window.add(this);
try {
image = ImageIO.read(new File("/src/arctic_nightmare/resources/divingsuit_visible.png"));
} catch (IOException ex) {
System.out.print("No picture : " + ex.toString());
}
} }
public ScaledImagePanel(JFrame window, ImageIcon picture, int x, int y, int width, int height) { public ScaledImagePanel(JFrame window, ImageIcon picture, int x, int y, int width, int height) {
...@@ -38,11 +25,6 @@ public class ScaledImagePanel extends JLabel{ ...@@ -38,11 +25,6 @@ public class ScaledImagePanel extends JLabel{
setBounds(x, y, width, height); setBounds(x, y, width, height);
setVisible(true); setVisible(true);
window.add(this); window.add(this);
try {
image = ImageIO.read(new File("/src/arctic_nightmare/resources/divingsuit_visible.png"));
} catch (IOException ex) {
System.out.print("No picture : " + ex.toString());
}
} }
void remove() void remove()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment