public World() { super(GAME_TITLE); _fileFilter = new FileNameExtensionFilter("Blockamon SAVE", "save"); this.setLayout(new BorderLayout()); inBattle = false; playingField = new JPanel(null); playingField.setBorder(BorderFactory.createLineBorder(Color.black)); playingField.setPreferredSize(new Dimension(400, 300)); worldSize = playingField.getPreferredSize(); }
public void run() { setDefaultCloseOperation(EXIT_ON_CLOSE); player = createPlayer(); playingField.add(player); createItemShop(); createHealingCenter(); createGrass(); menu = new ControlPanel( getPlayer(), createSaveWriter(_fileFilter), createSaveLoader(_fileFilter), getItemShop(), getHealingCenter(), new WindowDisplay()); add(menu, BorderLayout.NORTH); add(playingField, BorderLayout.CENTER); pack(); player.setVisible(true); this.addKeyListener(new KeyListen(this, menu)); setVisible(true); this.repaint(); }
private void createItemShop() { // creates the shop you can buy from itemShop = new ItemShop(); itemShop.stockItems(Item.HEALVIAL, Item.BLOCKABALL); playingField.add(itemShop); }
// player loses a battle and all blockamon in their party have lost all HealthPoints public void playerWhitedOut() { player.setLocation(healingCenter.getX(), healingCenter.getY()); player.healAllBlockamon(); player.loseMoney(); playingField.repaint(); }
// creates the place that can heal private void createHealingCenter() { healingCenter = new HealingCenter(); playingField.add(healingCenter); playingField.repaint(); }
// creates grass private void createGrass() { // creates the grass where wild Blockamon live wildGrass = new Grass(0, 0, (int) (worldSize.width * .3), worldSize.height, this, menu); playingField.add(wildGrass); }