Browse Source

Revert "Coin"

Janco Kock 10 years ago
parent
commit
54156e52b3

+ 0 - 13
.idea/libraries/Arcade.xml

@@ -1,13 +0,0 @@
-<component name="libraryTable">
-  <library name="Arcade">
-    <CLASSES>
-      <root url="jar://$PROJECT_DIR$/jl1.0.1.jar!/" />
-      <root url="jar://$PROJECT_DIR$/pi4j-core.jar!/" />
-      <root url="jar://$PROJECT_DIR$/javax.json-1.0.4.jar!/" />
-      <root url="jar://$PROJECT_DIR$/mp3spi1.9.5.jar!/" />
-      <root url="jar://$PROJECT_DIR$/tritonus_share.jar!/" />
-    </CLASSES>
-    <JAVADOC />
-    <SOURCES />
-  </library>
-</component>

+ 0 - 124
.idea/uiDesigner.xml

@@ -1,124 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<project version="4">
-  <component name="Palette2">
-    <group name="Swing">
-      <item class="com.intellij.uiDesigner.HSpacer" tooltip-text="Horizontal Spacer" icon="/com/intellij/uiDesigner/icons/hspacer.png" removable="false" auto-create-binding="false" can-attach-label="false">
-        <default-constraints vsize-policy="1" hsize-policy="6" anchor="0" fill="1" />
-      </item>
-      <item class="com.intellij.uiDesigner.VSpacer" tooltip-text="Vertical Spacer" icon="/com/intellij/uiDesigner/icons/vspacer.png" removable="false" auto-create-binding="false" can-attach-label="false">
-        <default-constraints vsize-policy="6" hsize-policy="1" anchor="0" fill="2" />
-      </item>
-      <item class="javax.swing.JPanel" icon="/com/intellij/uiDesigner/icons/panel.png" removable="false" auto-create-binding="false" can-attach-label="false">
-        <default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3" />
-      </item>
-      <item class="javax.swing.JScrollPane" icon="/com/intellij/uiDesigner/icons/scrollPane.png" removable="false" auto-create-binding="false" can-attach-label="true">
-        <default-constraints vsize-policy="7" hsize-policy="7" anchor="0" fill="3" />
-      </item>
-      <item class="javax.swing.JButton" icon="/com/intellij/uiDesigner/icons/button.png" removable="false" auto-create-binding="true" can-attach-label="false">
-        <default-constraints vsize-policy="0" hsize-policy="3" anchor="0" fill="1" />
-        <initial-values>
-          <property name="text" value="Button" />
-        </initial-values>
-      </item>
-      <item class="javax.swing.JRadioButton" icon="/com/intellij/uiDesigner/icons/radioButton.png" removable="false" auto-create-binding="true" can-attach-label="false">
-        <default-constraints vsize-policy="0" hsize-policy="3" anchor="8" fill="0" />
-        <initial-values>
-          <property name="text" value="RadioButton" />
-        </initial-values>
-      </item>
-      <item class="javax.swing.JCheckBox" icon="/com/intellij/uiDesigner/icons/checkBox.png" removable="false" auto-create-binding="true" can-attach-label="false">
-        <default-constraints vsize-policy="0" hsize-policy="3" anchor="8" fill="0" />
-        <initial-values>
-          <property name="text" value="CheckBox" />
-        </initial-values>
-      </item>
-      <item class="javax.swing.JLabel" icon="/com/intellij/uiDesigner/icons/label.png" removable="false" auto-create-binding="false" can-attach-label="false">
-        <default-constraints vsize-policy="0" hsize-policy="0" anchor="8" fill="0" />
-        <initial-values>
-          <property name="text" value="Label" />
-        </initial-values>
-      </item>
-      <item class="javax.swing.JTextField" icon="/com/intellij/uiDesigner/icons/textField.png" removable="false" auto-create-binding="true" can-attach-label="true">
-        <default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
-          <preferred-size width="150" height="-1" />
-        </default-constraints>
-      </item>
-      <item class="javax.swing.JPasswordField" icon="/com/intellij/uiDesigner/icons/passwordField.png" removable="false" auto-create-binding="true" can-attach-label="true">
-        <default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
-          <preferred-size width="150" height="-1" />
-        </default-constraints>
-      </item>
-      <item class="javax.swing.JFormattedTextField" icon="/com/intellij/uiDesigner/icons/formattedTextField.png" removable="false" auto-create-binding="true" can-attach-label="true">
-        <default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
-          <preferred-size width="150" height="-1" />
-        </default-constraints>
-      </item>
-      <item class="javax.swing.JTextArea" icon="/com/intellij/uiDesigner/icons/textArea.png" removable="false" auto-create-binding="true" can-attach-label="true">
-        <default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
-          <preferred-size width="150" height="50" />
-        </default-constraints>
-      </item>
-      <item class="javax.swing.JTextPane" icon="/com/intellij/uiDesigner/icons/textPane.png" removable="false" auto-create-binding="true" can-attach-label="true">
-        <default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
-          <preferred-size width="150" height="50" />
-        </default-constraints>
-      </item>
-      <item class="javax.swing.JEditorPane" icon="/com/intellij/uiDesigner/icons/editorPane.png" removable="false" auto-create-binding="true" can-attach-label="true">
-        <default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
-          <preferred-size width="150" height="50" />
-        </default-constraints>
-      </item>
-      <item class="javax.swing.JComboBox" icon="/com/intellij/uiDesigner/icons/comboBox.png" removable="false" auto-create-binding="true" can-attach-label="true">
-        <default-constraints vsize-policy="0" hsize-policy="2" anchor="8" fill="1" />
-      </item>
-      <item class="javax.swing.JTable" icon="/com/intellij/uiDesigner/icons/table.png" removable="false" auto-create-binding="true" can-attach-label="false">
-        <default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
-          <preferred-size width="150" height="50" />
-        </default-constraints>
-      </item>
-      <item class="javax.swing.JList" icon="/com/intellij/uiDesigner/icons/list.png" removable="false" auto-create-binding="true" can-attach-label="false">
-        <default-constraints vsize-policy="6" hsize-policy="2" anchor="0" fill="3">
-          <preferred-size width="150" height="50" />
-        </default-constraints>
-      </item>
-      <item class="javax.swing.JTree" icon="/com/intellij/uiDesigner/icons/tree.png" removable="false" auto-create-binding="true" can-attach-label="false">
-        <default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
-          <preferred-size width="150" height="50" />
-        </default-constraints>
-      </item>
-      <item class="javax.swing.JTabbedPane" icon="/com/intellij/uiDesigner/icons/tabbedPane.png" removable="false" auto-create-binding="true" can-attach-label="false">
-        <default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3">
-          <preferred-size width="200" height="200" />
-        </default-constraints>
-      </item>
-      <item class="javax.swing.JSplitPane" icon="/com/intellij/uiDesigner/icons/splitPane.png" removable="false" auto-create-binding="false" can-attach-label="false">
-        <default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3">
-          <preferred-size width="200" height="200" />
-        </default-constraints>
-      </item>
-      <item class="javax.swing.JSpinner" icon="/com/intellij/uiDesigner/icons/spinner.png" removable="false" auto-create-binding="true" can-attach-label="true">
-        <default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1" />
-      </item>
-      <item class="javax.swing.JSlider" icon="/com/intellij/uiDesigner/icons/slider.png" removable="false" auto-create-binding="true" can-attach-label="false">
-        <default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1" />
-      </item>
-      <item class="javax.swing.JSeparator" icon="/com/intellij/uiDesigner/icons/separator.png" removable="false" auto-create-binding="false" can-attach-label="false">
-        <default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3" />
-      </item>
-      <item class="javax.swing.JProgressBar" icon="/com/intellij/uiDesigner/icons/progressbar.png" removable="false" auto-create-binding="true" can-attach-label="false">
-        <default-constraints vsize-policy="0" hsize-policy="6" anchor="0" fill="1" />
-      </item>
-      <item class="javax.swing.JToolBar" icon="/com/intellij/uiDesigner/icons/toolbar.png" removable="false" auto-create-binding="false" can-attach-label="false">
-        <default-constraints vsize-policy="0" hsize-policy="6" anchor="0" fill="1">
-          <preferred-size width="-1" height="20" />
-        </default-constraints>
-      </item>
-      <item class="javax.swing.JToolBar$Separator" icon="/com/intellij/uiDesigner/icons/toolbarSeparator.png" removable="false" auto-create-binding="false" can-attach-label="false">
-        <default-constraints vsize-policy="0" hsize-policy="0" anchor="0" fill="1" />
-      </item>
-      <item class="javax.swing.JScrollBar" icon="/com/intellij/uiDesigner/icons/scrollbar.png" removable="false" auto-create-binding="true" can-attach-label="false">
-        <default-constraints vsize-policy="6" hsize-policy="0" anchor="0" fill="2" />
-      </item>
-    </group>
-  </component>
-</project>

+ 0 - 12
Arcade.iml

@@ -1,12 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<module type="JAVA_MODULE" version="4">
-  <component name="NewModuleRootManager" inherit-compiler-output="true">
-    <exclude-output />
-    <content url="file://$MODULE_DIR$">
-      <sourceFolder url="file://$MODULE_DIR$" isTestSource="false" />
-    </content>
-    <orderEntry type="inheritedJdk" />
-    <orderEntry type="sourceFolder" forTests="false" />
-    <orderEntry type="library" name="Arcade" level="project" />
-  </component>
-</module>

+ 0 - 69
model/drawObjects/CoinAnimation.java

@@ -1,69 +0,0 @@
-package model.drawObjects;
-
-import java.awt.*;
-import java.awt.geom.Ellipse2D;
-import java.awt.geom.Point2D;
-
-/**
- * Created by Bilel on 4-6-2015.
- *
- * CoinAnimation klasse: Weergeeft een balletje (resembleerd een muntje) dat omlaag valt.
- *      Je hoeft alleen achter elkaar de paint(Graphics2D) methode aan te roepen, deze roep automatisch een 'reposition' aan,
- *      waardoor je het balletje alleen snel achter elkaar hoeft te repainten.
- */
-public class CoinAnimation extends DrawObject {
-
-    private Ellipse2D       coinShape;
-    private Point2D.Double  coinSetPoint;
-
-    // Hoevaak de timer gelopen heeft
-    private static int timerLoops = 0;
-
-    public CoinAnimation(int startX, int startY) {
-        coinSetPoint    = new Point2D.Double(startX, startY);
-        coinShape       = new Ellipse2D.Double(startX, startY, 20, 20);
-    }
-
-    // Start
-    public void start() {
-        timerLoops      = 1;
-    }
-
-    public void draw(Graphics2D g2) {
-
-        update(timerLoops);                                             // UPDATE
-        g2.setColor(new Color(255, 255, 0, (255 - timerLoops * 5)));    // GEEL
-        g2.draw(coinShape);                                             // MUNTJE TEKENEN
-        g2.fill(coinShape);
-
-    }
-
-    // Wordt na elke paint aangeroepen
-    public void update(float factor) {
-
-        // Alleen tekenen wanner de animatie ingesteld is om te tekenen (zie: areWeDoneYet()), anders doei.
-        if (areWeDoneYet()) {
-            System.out.println("Call initCoin(int startX, startY) first!");
-            return;
-        }
-
-        // Coin omlaag verschuiven doordat Y * loops omlaag gaat.
-        // Per frame verschuift het balletje delta 10 op Y-as.
-        coinShape.setFrame(coinSetPoint.getX(), coinSetPoint.getY() + 10 * timerLoops,
-                coinShape.getWidth(), coinShape.getHeight());
-        timerLoops++;
-    }
-
-    // Zijn we al begonnen/klaar?
-    public boolean areWeDoneYet() {
-        if (timerLoops > 49 || timerLoops == 0) {
-            timerLoops = 0;
-            return true;
-        }
-        return false;
-    }
-
-    // Zitten we in de laatste loop?
-    public boolean isLastLoop() { return (timerLoops == 49) ? true : false;  }
-
-}

+ 2 - 1
model/gameState/GameOverState.java

@@ -23,7 +23,8 @@ public class GameOverState extends GameState {
     BufferedImage gameOver = Images.getImage(ImageType.gameover);
     VolatileImage background;
 	Font textFont = new Font("OCR A Extended", Font.BOLD, 70);
-
+	
+	
 	private String endScore = "";
 	
     int frame;

+ 1 - 1
model/gameState/PlayState.java

@@ -181,11 +181,11 @@ public class PlayState extends GameState {
 					area.hit();
 					enemysInPath.remove();
 					notHit = false;
-					infoPanel.throwACoin();		// Coin Animatie starten bij hit
 					break;
 				}
 			}
 		}
+		
 
 		player.setBeat();
 

+ 43 - 75
model/gameState/TitleState.java

@@ -9,8 +9,6 @@ import java.awt.GradientPaint;
 import java.awt.Graphics2D;
 import java.awt.RenderingHints;
 import java.awt.Transparency;
-import java.awt.event.ActionEvent;
-import java.awt.event.ActionListener;
 import java.awt.image.BufferedImage;
 import java.awt.image.VolatileImage;
 
@@ -20,9 +18,7 @@ import control.GameStateManager.State;
 import control.button.ButtonEvent;
 import control.joystick.JoystickEvent;
 
-import javax.swing.*;
-
-public class TitleState extends GameState implements ActionListener {
+public class TitleState extends GameState {
 
     BufferedImage pressStart = Images.getImage(ImageType.pressstart);
     BufferedImage colorStrike = Images.getImage(ImageType.colorstrike);
@@ -32,21 +28,18 @@ public class TitleState extends GameState implements ActionListener {
 	Font textFont2 = new Font("OCR A Extended", Font.BOLD, 130);
 	GradientPaint gp = new GradientPaint(300, 0, new Color(0, 0, 1, 0.6f), 980, 1024, new Color(0, 0, 1, 0.2f));
 
+	
     int index = 0;
     int varx = 0;
     int frame;
 
-	private Timer timer;
-
-	int showInLoops = 1;
     
     int indexKast = 0;
     int xKast=0;
     
 	public TitleState(GameStateManager gsm, SongHandler sh){
 		super(gsm, sh);
-		// Logica zit in ActionListener (dus actionPerformed())
-		(timer = new Timer(1000/3, this)).start();
+		createBackground();
 	}
 
 	@Override
@@ -56,26 +49,23 @@ public class TitleState extends GameState implements ActionListener {
 
 	@Override
 	public void update(float factor) {
+
         frame++;
         indexKast++;
 	}
 
 	@Override
 	public void draw(Graphics2D g2) {
-		// Scherm beelt wat kleurrijke rectangles op het scherm.
-		if (showInLoops > 0) {
-			g2.drawImage(background, 0, 0, 1280, 1024, null);
-			createBackground();
-		}
-		if (showInLoops > 18) {
-			// Code die de arcadekast en 'Press Start' toont.
-			int image_x = ((frame / 6) % 6) * 49;
-			g2.drawImage(pressStart.getSubimage(image_x, 0, 49, 26), 640 - 122, 512, 245, 130, null);
-
-			xKast = indexKast / 10;
-			xKast %= 4;
-			g2.drawImage(kast.getSubimage(xKast * 300, 0, 300, 400), 100, 300, 300, 400, null);
-		}
+		g2.drawImage(background, 0, 0, 1280, 1024, null);
+		int image_x = ((frame / 6) % 6) * 49;
+		g2.drawImage(pressStart.getSubimage(image_x, 0, 49, 26),  640-122, 512, 245, 130, null);
+		
+		
+		
+		xKast = indexKast/10;
+		xKast%=4;
+		//g2.drawImage(kast.getSubimage(xKast*300,0,300,400), 640-122,650,300,400,null);
+		g2.drawImage(kast.getSubimage(xKast*300,0,300,400), 100,300,300,400,null);
 	}
 
 	@Override
@@ -101,58 +91,36 @@ public class TitleState extends GameState implements ActionListener {
 	public void createBackground() {
 		background = Images.initVolatileImage(1280, 1024, Transparency.OPAQUE);
 		Graphics2D g2 = background.createGraphics();
-
-		if (showInLoops > 0) {
-			RenderingHints rh = new RenderingHints(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
-			g2.setRenderingHints(rh);
-		}
-		if (showInLoops > 2) {
-			g2.setColor(new Color(1, 1, 1, 0.3f));
-			g2.fillRect(0, 0, 1280, 1024);
-		}
-		if (showInLoops > 4) {
-			g2.setColor(new Color(0, 1, 0, 0.7f));
-			g2.fillRect(0, 0, 100, 1024);
-			g2.fillRect(1180, 0, 100, 1024);
-		}
-		if (showInLoops > 6) {
-			g2.setColor(new Color(1, 1, 0, 0.7f));
-			g2.fillRect(100, 0, 100, 1024);
-			g2.fillRect(1080, 0, 100, 1024);
-		}
-		if (showInLoops > 8) {
-			g2.setColor(new Color(1, 0, 0, 0.7f));
-			g2.fillRect(200, 0, 100, 1024);
-			g2.fillRect(980, 0, 100, 1024);
-		}
-		if (showInLoops > 12) {
-			g2.setPaint(gp);
-			g2.fillRect(300, 0, 680, 1024);
-		}
-		if (showInLoops > 14) {
-			g2.setFont(textFont);
-			g2.setColor(Color.WHITE);
-			g2.drawString("©2015 Team Hamtaro", 550, 1012);
-		}
-		if (showInLoops > 16) {
-			g2.setColor(Color.RED);
-			g2.setFont(textFont2);
-			g2.drawString("Color", 385, 212);
-			g2.drawString("Strike", 390, 342);
-			g2.dispose();
-		}
-		if (showInLoops > 18) {
-			timer.stop();
-		}
-
+		RenderingHints rh = new RenderingHints(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
+		g2.setRenderingHints(rh);
+		g2.setColor(new Color(1, 1, 1, 0.3f));
+		g2.fillRect(0, 0, 1280, 1024);
+
+		g2.setColor(new Color(0, 1, 0, 0.7f));
+		g2.fillRect(0, 0, 100, 1024);
+		g2.fillRect(1180, 0, 100, 1024);
+
+		g2.setColor(new Color(1, 1, 0, 0.7f));
+		g2.fillRect(100, 0, 100, 1024);
+		g2.fillRect(1080, 0, 100, 1024);
+
+		g2.setColor(new Color(1, 0, 0, 0.7f));
+		g2.fillRect(200, 0, 100, 1024);
+		g2.fillRect(980, 0, 100, 1024);
+
+		g2.setPaint(gp);
+		g2.fillRect(300, 0, 680, 1024);
+
+		g2.setFont(textFont);
+		g2.setColor(Color.WHITE);
+		g2.drawString("©2015 Team Hamtaro", 550, 1012);
+
+		g2.setColor(Color.RED);
+		g2.setFont(textFont2);
+		g2.drawString("Color", 385, 212);
+		g2.drawString("Strike", 390, 342);
+		g2.dispose();
 		background.createGraphics();
 	}
 
-	@Override
-	public void actionPerformed(ActionEvent e) {
-
-		createBackground();
-		showInLoops++;
-	}
-
 }

+ 8 - 25
model/objects/InfoPanel.java

@@ -10,7 +10,6 @@ import java.awt.Transparency;
 import java.awt.image.VolatileImage;
 
 import model.SongHandler;
-import model.drawObjects.CoinAnimation;
 import model.gameState.PlayState;
 
 public class InfoPanel {
@@ -20,16 +19,11 @@ public class InfoPanel {
 	private VolatileImage infoPanel;
 	private SongHandler sh;
 	private String time;
-
-	private int tempComboScore;
-
-	private CoinAnimation coinAnimation = new CoinAnimation(125, 250);
 	
 	public InfoPanel(int x, int y, SongHandler sh){
 		this.x = x;
 		this.y = y;
 		this.sh = sh;
-
 		updateIPanel();
 		generateInfoPanel();
 	}
@@ -70,36 +64,25 @@ public class InfoPanel {
 		g2.drawString("Score: " + totalHighscore, 25, 75);
 		g2.drawRect(25, 100, 200, 30);
 		g2.drawRect(25, 300, 200, 700);
+		
 		g2.drawString(sh.getCurrentSong().getTitle(), 25, 200);
-
-		if(sh.getCurrentSong().getSubtitle() != "") {
+		if(sh.getCurrentSong().getSubtitle() != "")
+		{
 			g2.drawString(sh.getCurrentSong().getSubtitle(), 25, 230);
 			g2.drawString(sh.getCurrentSong().getAuthor(), 25, 260);
 			g2.drawString(time, 25, 290);
 		}
-		else {
+		else
+		{
 			g2.drawString(sh.getCurrentSong().getAuthor(), 25, 230);
 			g2.drawString(time, 25, 260);
 		}
-
-		if (!coinAnimation.areWeDoneYet()) {
-			coinAnimation.draw(g2);
-			// Score pas updaten wanneer coin klaar is met afspelen
-			if (coinAnimation.isLastLoop())
-				tempComboScore = PlayState.comboScore;
-		} else
-			tempComboScore = PlayState.comboScore;
-
-		g2.setColor(Color.YELLOW);
-		g2.fillRect(25, 1000 - 7 * tempComboScore, 200, 7 * tempComboScore);
-
+		
+		g2.setColor(Color.YELLOW);		
+		g2.fillRect(25, 1000 - 7 * PlayState.comboScore, 200, 0 + 7 * PlayState.comboScore);
 		g2.dispose();
 		infoPanel.createGraphics();
 	}
-
-	public void throwACoin() {
-		coinAnimation.start();
-	}
 	
 	public void draw(Graphics2D g2){
 		g2.drawImage(infoPanel, 0, 0, 256,1024,null);