Skip to content

Commit

Permalink
Final commit
Browse files Browse the repository at this point in the history
Added menu, corrected upgrades.
  • Loading branch information
arozans committed Apr 6, 2016
1 parent d02794c commit 570f28b
Show file tree
Hide file tree
Showing 62 changed files with 529 additions and 167 deletions.
Binary file added Arkanoid-Logo-New.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified Level_nr_1.ser
Binary file not shown.
Binary file added Level_nr_2.ser
Binary file not shown.
Binary file added Level_nr_3.ser
Binary file not shown.
Binary file added Level_nr_4.ser
Binary file not shown.
Binary file added Level_nr_5.ser
Binary file not shown.
Binary file modified Results.ser
Binary file not shown.
Binary file added arkanoid_logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added arkanoid_logo2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added arkanoid_logo3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added arkanoid_logo_small.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified bin/Controller/Controller.class
Binary file not shown.
Binary file modified bin/Controller/InputController.class
Binary file not shown.
Binary file modified bin/Model/Ball.class
Binary file not shown.
Binary file modified bin/Model/GameFactory.class
Binary file not shown.
Binary file modified bin/Model/Model.class
Binary file not shown.
Binary file modified bin/Model/MovableObject.class
Binary file not shown.
Binary file modified bin/Model/Player.class
Binary file not shown.
Binary file modified bin/Model/Upgrade/TemporaryUpgrade.class
Binary file not shown.
Binary file modified bin/Model/Upgrade/Upgrade.class
Binary file not shown.
Binary file modified bin/Start.class
Binary file not shown.
Binary file modified bin/Utils/AppendingObjectOutputStream.class
Binary file not shown.
Binary file modified bin/Utils/Constants.class
Binary file not shown.
Binary file removed bin/View/EditorView$3.class
Binary file not shown.
Binary file modified bin/View/EditorView.class
Binary file not shown.
Binary file modified bin/View/GlassPanel$3.class
Binary file not shown.
Binary file modified bin/View/GlassPanel$4.class
Binary file not shown.
Binary file modified bin/View/GlassPanel.class
Binary file not shown.
Binary file modified bin/View/LayeredPanel$1.class
Binary file not shown.
Binary file removed bin/View/LayeredPanel$2.class
Binary file not shown.
Binary file modified bin/View/LayeredPanel.class
Binary file not shown.
Binary file added bin/View/MenuView$1$1$1.class
Binary file not shown.
Binary file added bin/View/MenuView$1$1.class
Binary file not shown.
Binary file added bin/View/MenuView$1$2.class
Binary file not shown.
Binary file added bin/View/MenuView$1$3.class
Binary file not shown.
Binary file added bin/View/MenuView$1$4.class
Binary file not shown.
Binary file added bin/View/MenuView$1$5.class
Binary file not shown.
Binary file added bin/View/MenuView$1.class
Binary file not shown.
Binary file added bin/View/MenuView.class
Binary file not shown.
Binary file modified bin/View/PlayerPanel.class
Binary file not shown.
Binary file modified bin/View/View.class
Binary file not shown.
Binary file added blue_square.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
28 changes: 21 additions & 7 deletions src/Controller/Controller.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package Controller;

import javax.swing.SwingUtilities;

import Model.Model;
import Utils.Constants;
import Utils.FileManager;
Expand Down Expand Up @@ -149,10 +151,12 @@ public Controller(View view, Model model)
setOver(false);
setNextLevel(false);

getView().getLayeredPanel().getMainPanel().getPlayerPanel().setPlayer(getModel().getPlayer());
getView().getLayeredPanel().getMainPanel().getPlayerPanel()
.setPlayer(getModel().getPlayer());
getView().getEditorView().getEditorPanel()
.setListOfObjectsToRender(getModel().getEditorModel().getEditorObjects());
getView().getEditorView().getChoicePanel().createChoicePanel(getModel().getEditorModel().getMaxLevel());
getView().getEditorView().getChoicePanel()
.createChoicePanel(getModel().getEditorModel().getMaxLevel());
}

/**
Expand All @@ -166,10 +170,19 @@ public Controller(View view, Model model)
*
*
*/
public void startGame()
public void showMenu()
{

view.getMenuView().getMenuFrame().setVisible(true);

}

public void startGame()
{
view.getMainFrame().setVisible(true);
model.loadNextLevel();
long delta = 0l;

while (!isOver())
{
while (isRunning())
Expand All @@ -182,8 +195,8 @@ public void startGame()
break;
long lastTime = System.nanoTime();

if (model.update())
view.render(getModel().getGameObjectList(), getModel().getPlayer());
if (model.update())
view.render(getModel().getGameObjectList(), getModel().getPlayer());

delta = System.nanoTime() - lastTime;
if (delta < Constants.GAME_LOOP_TIME)
Expand All @@ -209,7 +222,8 @@ public void startGame()
*/
private void showNextLevelDialog()
{
getView().getLayeredPanel().getGlassPanel().startNextLevelDialog(getModel().getCurrentLevel());
getView().getLayeredPanel().getGlassPanel()
.startNextLevelDialog(getModel().getCurrentLevel());
FileManager.sleep(3000);
getView().getLayeredPanel().getGlassPanel().stopPause();
setNextLevel(false);
Expand All @@ -224,7 +238,7 @@ private void showNextLevelDialog()
public void endOfGame()
{
getView().getLayeredPanel().getGlassPanel().goodbye();
FileManager.sleep(3000);
FileManager.sleep(2000);
getView().getResultsView().endOfGame(getModel().getResultsModel().getPlayersList());
}
}
74 changes: 56 additions & 18 deletions src/Controller/InputController.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
import java.awt.event.KeyEvent;
import java.awt.event.MouseEvent;

import javax.swing.SwingUtilities;

import Model.Model;
import View.GlassPanel;
import View.View;
Expand All @@ -16,11 +18,11 @@

public class InputController
{
/**
* When true, blocks all functions. Changing when 'P' key is clicked.
*
*/
private boolean blockade;

private boolean blockade;// When true, blocks all functions. Changing when
// 'P' key is clicked.
private int pressedKeys;// counter for pressed arrow keys. When 2 and one of
// the keys are released, racket won't stop moving.
private Model model;
private View view;
private Controller controller;
Expand Down Expand Up @@ -86,6 +88,16 @@ public void setBlockade(boolean blockade)
this.blockade = blockade;
}

public int getPressedKeys()
{
return pressedKeys;
}

public void setPressedKeys(int pressedKeys)
{
this.pressedKeys = pressedKeys;
}

/**
* Constructor of InputController.
*
Expand All @@ -102,6 +114,7 @@ public InputController(Model model, Controller controller, View view)
this.setController(controller);
this.view = view;
this.blockade = false;
this.pressedKeys = 0;
}

/**
Expand Down Expand Up @@ -153,14 +166,20 @@ public void handleInput(KeyEvent ke)
{
if (ke.getKeyCode() == KeyEvent.VK_RIGHT || ke.getKeyCode() == KeyEvent.VK_LEFT)
{

if (ke.getKeyCode() == KeyEvent.VK_RIGHT)
if (ke.getKeyCode() == KeyEvent.VK_RIGHT && !(getModel().getRacketDirection() == 1))
{
getModel().setRacketDirection(1);
else
setPressedKeys(getPressedKeys() + 1);
}
else if (ke.getKeyCode() == KeyEvent.VK_LEFT && !(getModel().getRacketDirection() == -1))
{
getModel().setRacketDirection(-1);
setPressedKeys(getPressedKeys() + 1);

}

}
if (ke.getKeyCode() == KeyEvent.VK_DOWN)
if (ke.getKeyCode() == KeyEvent.VK_UP)
{
getModel().shootBall();
}
Expand All @@ -172,11 +191,11 @@ public void handleInput(KeyEvent ke)
{
showEditor();
}
if (ke.getKeyCode() == KeyEvent.VK_UP)
/* if (ke.getKeyCode() == KeyEvent.VK_UP)
{
getModel().setNewBall(true);
}
if (ke.getKeyCode() == KeyEvent.VK_S)
}*/
/*if (ke.getKeyCode() == KeyEvent.VK_S)
{
getModel().getPcs().firePropertyChange("AdditionalBallsUpgrade", false, true);
}
Expand All @@ -195,7 +214,7 @@ public void handleInput(KeyEvent ke)
if (ke.getKeyCode() == KeyEvent.VK_Q)
{
getModel().getPcs().firePropertyChange("MissilesUpgrade", false, true);
}
}*/
if (ke.getKeyCode() == KeyEvent.VK_SPACE)
{
getModel().fireMissile();
Expand All @@ -204,6 +223,24 @@ public void handleInput(KeyEvent ke)

}

/**
* Function called when user stops pressing left or right arrow and
* therefore racket should stop moving.
*/
public void keyReleased(KeyEvent ke)
{
if (ke.getKeyCode() == KeyEvent.VK_RIGHT || ke.getKeyCode() == KeyEvent.VK_LEFT)
{
setPressedKeys(getPressedKeys() - 1);
if (getPressedKeys() == 1 && ke.getKeyCode() == KeyEvent.VK_RIGHT)
getModel().setRacketDirection(-1);
else if (getPressedKeys() == 1 && ke.getKeyCode() == KeyEvent.VK_LEFT)
getModel().setRacketDirection(1);
else
getModel().setRacketDirection(0);
}
}

/**
* Function called from EditorsView, when player enters his name in
* TextField. It passes name to resultModel, where it is saved, and make
Expand Down Expand Up @@ -327,12 +364,13 @@ public void changeLevel(int selectedIndex)
}

/**
* Function called when user stops pressing left or right arrow and
* therefore racket should stop moving.
* Processing main menu "Play" button
*/
public void keyReleased(KeyEvent ke)
public void menuPlay()
{
if (ke.getKeyCode() == KeyEvent.VK_RIGHT || ke.getKeyCode() == KeyEvent.VK_LEFT)
getModel().setRacketDirection(0);

getView().getMenuView().getMenuFrame().setVisible(false);
getController().startGame();

}
}
15 changes: 12 additions & 3 deletions src/Model/Ball.java
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ public void processCollision(GameObject go)
if (moreAtSide(go)) // if bigger part of ball is on the
// side
{

changeDirectionX(go);

}
Expand All @@ -119,7 +120,10 @@ public void processCollision(GameObject go)

}
else// only on the side
{
changeDirectionX(go);

}
}
else// not on the side
{
Expand Down Expand Up @@ -147,11 +151,13 @@ public boolean moreAtSide(GameObject go)
Point stillObjectPoint;
Point ballCenterPoint = new Point(getX() + getRadius(), getY() + getRadius());
if (leftCollide(go))
stillObjectPoint = new Point((go.getX() + (go.getHeight() / 2)), (go.getY() + (go.getHeight() / 2)));
stillObjectPoint =
new Point((go.getX() + (go.getHeight() / 2)), (go.getY() + (go.getHeight() / 2)));
else
stillObjectPoint = new Point((go.getX() + go.getWidth() - (go.getHeight() / 2)),
(go.getY() + (go.getHeight() / 2)));
if (Math.abs(ballCenterPoint.x - stillObjectPoint.x) < Math.abs(ballCenterPoint.y - stillObjectPoint.y))
if (Math.abs(ballCenterPoint.x - stillObjectPoint.x) < Math
.abs(ballCenterPoint.y - stillObjectPoint.y))
return false;
else
return true;
Expand Down Expand Up @@ -194,7 +200,10 @@ public void propertyChange(PropertyChangeEvent evt)
else
{
setRampage(false);
setColor(Color.black);
int b = (int) (Math.random() * 145);
int r = (int) (Math.random() * 145);
int g = (int) (Math.random() * 145);
setColor(new Color(b, r, g));
}

}
Expand Down
Loading

0 comments on commit 570f28b

Please sign in to comment.