Text objects

This commit is contained in:
naomi 2025-03-26 01:33:15 +00:00
parent 5840edc063
commit 55c301dec1
7 changed files with 506 additions and 215 deletions

View file

@ -108,6 +108,7 @@ public class Ball {
if (VectorBreakout.lives <= 0) { if (VectorBreakout.lives <= 0) {
VectorBreakout.gameLose(); VectorBreakout.gameLose();
} }
VectorBreakout.currentTextElements[1].setText(String.valueOf(VectorBreakout.lives));
} }
// Checks to see if the ball is in contact with bricks, paddles, or walls // Checks to see if the ball is in contact with bricks, paddles, or walls
@ -122,6 +123,7 @@ public class Ball {
else if (this.ballY <= 0) { else if (this.ballY <= 0) {
this.bounce((byte) 0); this.bounce((byte) 0);
this.ballY = 0; this.ballY = 0;
this.wallBounceAnimation();
return; return;
} }
@ -129,17 +131,19 @@ public class Ball {
if (this.ballX <= 20) { if (this.ballX <= 20) {
this.bounce((byte) 1); this.bounce((byte) 1);
this.ballX = 22; this.ballX = 22;
this.wallBounceAnimation();
return; return;
} }
else if ((this.ballX + this.ballWidth) >= (VectorBreakout.gameResX - 20 - this.ballWidth)) { else if ((this.ballX + this.ballWidth) >= (VectorBreakout.gameResX - 20 - this.ballWidth)) {
this.bounce((byte) 1); this.bounce((byte) 1);
this.ballX = (short) (VectorBreakout.gameResX - 25 - this.ballWidth); this.ballX = (short) (VectorBreakout.gameResX - 25 - this.ballWidth);
this.wallBounceAnimation();
return; return;
} }
// Check bricks // Check bricks
if (VectorBreakout.currentLevel != null) { if (VectorBreakout.currentLevel != null) {
for (byte i = 0; i < VectorBreakout.currentLevel.levelBricks.length; i++) { for (short i = 0; i < VectorBreakout.currentLevel.levelBricks.length; i++) {
if (VectorBreakout.currentLevel.levelBricks[i] != null) { if (VectorBreakout.currentLevel.levelBricks[i] != null) {
if (VectorBreakout.currentLevel.levelBricks[i].brickY <= this.ballY && if (VectorBreakout.currentLevel.levelBricks[i].brickY <= this.ballY &&
VectorBreakout.currentLevel.levelBricks[i].brickY + VectorBreakout.currentLevel.levelBricks[i].brickHeight >= this.ballY + this.ballHeight) { VectorBreakout.currentLevel.levelBricks[i].brickY + VectorBreakout.currentLevel.levelBricks[i].brickHeight >= this.ballY + this.ballHeight) {
@ -210,4 +214,33 @@ public class Ball {
} }
} }
private void wallBounceAnimation() {
byte ballParticleGen = 0;
for (byte ii = 0; ii < VectorBreakout.currentParticles.length; ii++) {
if (VectorBreakout.currentParticles[ii] == null) {
ballParticleGen++;
switch(ballParticleGen) {
case 1: // Up left
VectorBreakout.currentParticles[ii] = new Particle(0, this.ballX - 3, this.ballY - 10, -2, -2, 15, 2, 6, 3);
VectorBreakout.currentParticles[ii].spawn(5);
break;
case 2: // Up right
VectorBreakout.currentParticles[ii] = new Particle(0, this.ballX + 10, this.ballY - 10, 2, -2, 15, 2, 8, 3);
VectorBreakout.currentParticles[ii].spawn(5);
break;
case 3: // Down right
VectorBreakout.currentParticles[ii] = new Particle(0, this.ballX - 3, this.ballY + 3, 2, 2, 15, 2, 2, 3);
VectorBreakout.currentParticles[ii].spawn(5);
break;
case 4: // Down left
VectorBreakout.currentParticles[ii] = new Particle(0, this.ballX + 10, this.ballY + 3, -2, 2, 15, 2, 4, 3);
VectorBreakout.currentParticles[ii].spawn(5);
break;
}
if (ballParticleGen < 4) {continue;}
else {return;}
}
}
}
} }

View file

@ -11,19 +11,29 @@ public class Brick {
byte scoreOnBreak = 10; byte scoreOnBreak = 10;
byte specialAbility = 0; byte specialAbility = 0;
public Brick(int x, int y, boolean bk, int bc, int sc, int sa) { /**
* Bricks.
* @param x The x coordinate
* @param y The y coordinate
* @param isBroken Is it broken
* @param brickColor The color of the brick
* @param score The score the player receives upon breaking the brick
* @param specialAbility A special event that occurs upon breaking the brick
*/
public Brick(int x, int y, boolean isBroken, int brickColor, int score, int specialAbility) {
this.brickX = (short) x; this.brickX = (short) x;
this.brickY = (short) y; this.brickY = (short) y;
this.isBroken = bk; this.isBroken = isBroken;
this.brickColor = (byte) bc; this.brickColor = (byte) brickColor;
this.scoreOnBreak = (byte) sc; this.scoreOnBreak = (byte) score;
this.specialAbility = (byte) sa; this.specialAbility = (byte) specialAbility;
} }
public void breakBrick() { public void breakBrick() {
if (!isBroken) { if (!isBroken) {
isBroken = true; isBroken = true;
VectorBreakout.score += this.scoreOnBreak + (VectorBreakout.level - 1); VectorBreakout.score += this.scoreOnBreak + (VectorBreakout.level - 1);
VectorBreakout.currentTextElements[0].setText(String.valueOf(VectorBreakout.score));
VectorBreakout.bricksOnScreen--; VectorBreakout.bricksOnScreen--;
switch(this.specialAbility) { switch(this.specialAbility) {
case 1: case 1:
@ -50,23 +60,19 @@ public class Brick {
brickParticleGen++; brickParticleGen++;
switch(brickParticleGen) { switch(brickParticleGen) {
case 1: case 1:
VectorBreakout.currentParticles[ii] = new Particle(0, this.brickX, this.brickY, this.brickWidth - 1, 3, this.brickColor, 3, 3, 2); VectorBreakout.currentParticles[ii] = new Particle(0, this.brickX + 12, this.brickY + 3, 1, 1, this.brickColor, 2, 4, 1);
VectorBreakout.currentParticles[ii].spawn(20); VectorBreakout.currentParticles[ii].spawn(5);
break; break;
case 2: case 2:
VectorBreakout.currentParticles[ii] = new Particle(0, this.brickX, this.brickY, -2, this.brickHeight - 1, this.brickColor, 3, 3, 2); VectorBreakout.currentParticles[ii] = new Particle(0, this.brickX + 20, this.brickY + 13, 1, 1, this.brickColor, 2, 3, 1);
VectorBreakout.currentParticles[ii].spawn(20); VectorBreakout.currentParticles[ii].spawn(5);
break; break;
case 3: case 3:
VectorBreakout.currentParticles[ii] = new Particle(0, this.brickX, this.brickY + this.brickHeight, this.brickWidth - 1, 2, this.brickColor, 3, 3, 2); VectorBreakout.currentParticles[ii] = new Particle(0, this.brickX + 32, this.brickY + 7, 1, 1, this.brickColor, 2, 2, 1);
VectorBreakout.currentParticles[ii].spawn(20); VectorBreakout.currentParticles[ii].spawn(5);
break;
case 4:
VectorBreakout.currentParticles[ii] = new Particle(0, this.brickX + this.brickWidth, this.brickY, -2, this.brickHeight, this.brickColor, 3, 3, 2);
VectorBreakout.currentParticles[ii].spawn(20);
break; break;
} }
if (brickParticleGen < 4) {continue;} if (brickParticleGen < 3) {continue;}
else {return;} else {return;}
} }
} }

View file

@ -28,72 +28,6 @@ public class GameDisplay extends JComponent {
g2.setColor(Color.white); g2.setColor(Color.white);
/**
* Note on rendering numbers:
*
* I am aware that I could be using a switch statement for these.
* However, this did not compile when testing in JDK 1.5, as it would
* refuse to accept anything other than numbers in a switch statement.
* Since I am a silly little nerd who wishes to use this on my older
* systems, I used these goofy if/else statements so I could compile
* on the older JDKs and play on my older systems...
*/
// Score
resetBeam();
moveBeam(20, -13);
g2.setStroke(bt(2));
String numToString = String.valueOf(VectorBreakout.score);
String[] numToRender = numToString.split("");
for (byte i = iStart; i < numToRender.length; i++) {
if ("1".equals(numToRender[i])) {moveBeam(13, 0);g2.draw(drawVec(0, -24));moveBeam(5, 24);}
else if ("2".equals(numToRender[i])) {moveBeam(0, -24);g2.draw(drawVec(14, 0));g2.draw(drawVec(0, 12));g2.draw(drawVec(-14, 0));g2.draw(drawVec(0, 12));g2.draw(drawVec(14, 0));moveBeam(4, 0);}
else if ("3".equals(numToRender[i])) {moveBeam(0, -24);g2.draw(drawVec(14, 0));g2.draw(drawVec(0, 12));g2.draw(drawVec(-14, 0));moveBeam(14, 0);g2.draw(drawVec(0, 12));g2.draw(drawVec(-14, 0));moveBeam(18, 0);}
else if ("4".equals(numToRender[i])) {moveBeam(0, -24);g2.draw(drawVec(0, 12));g2.draw(drawVec(14, 0));moveBeam(0, -12);g2.draw(drawVec(0, 24));moveBeam(4, 0);}
else if ("5".equals(numToRender[i])) {moveBeam(14, -24);g2.draw(drawVec(-14, 0));g2.draw(drawVec(0, 12));g2.draw(drawVec(14, 0));g2.draw(drawVec(0, 12));g2.draw(drawVec(-14, 0));moveBeam(18, 0);}
else if ("6".equals(numToRender[i])) {moveBeam(0, -24);g2.draw(drawVec(0, 24));g2.draw(drawVec(14, 0));g2.draw(drawVec(0, -12));g2.draw(drawVec(-14, 0));moveBeam(18, 12);}
else if ("7".equals(numToRender[i])) {moveBeam(0, -24);g2.draw(drawVec(14, 0));g2.draw(drawVec(0, 24));moveBeam(4, 0);}
else if ("8".equals(numToRender[i])) {g2.draw(drawVec(0, -24));g2.draw(drawVec(14, 0));g2.draw(drawVec(0, 24));g2.draw(drawVec(-14, 0));moveBeam(0, -12);g2.draw(drawVec(14, 0));moveBeam(4, 12);}
else if ("9".equals(numToRender[i])) {moveBeam(14, 0);g2.draw(drawVec(0, -24));g2.draw(drawVec(-14, 0));g2.draw(drawVec(0, 12));g2.draw(drawVec(14, 0));moveBeam(4, 12);}
else {g2.draw(drawVec(14, 0));g2.draw(drawVec(0, -24));g2.draw(drawVec(-14, 0));g2.draw(drawVec(0, 24));moveBeam(18, 0);}
}
// Lives
resetBeam();
moveBeam(200, -13);
numToString = String.valueOf(VectorBreakout.lives);
numToRender = numToString.split("");
for (byte i = iStart; i < numToRender.length; i++) {
if ("1".equals(numToRender[i])) {moveBeam(13, 0);g2.draw(drawVec(0, -24));moveBeam(5, 24);}
else if ("2".equals(numToRender[i])) {moveBeam(0, -24);g2.draw(drawVec(14, 0));g2.draw(drawVec(0, 12));g2.draw(drawVec(-14, 0));g2.draw(drawVec(0, 12));g2.draw(drawVec(14, 0));moveBeam(4, 0);}
else if ("3".equals(numToRender[i])) {moveBeam(0, -24);g2.draw(drawVec(14, 0));g2.draw(drawVec(0, 12));g2.draw(drawVec(-14, 0));moveBeam(14, 0);g2.draw(drawVec(0, 12));g2.draw(drawVec(-14, 0));moveBeam(18, 0);}
else if ("4".equals(numToRender[i])) {moveBeam(0, -24);g2.draw(drawVec(0, 12));g2.draw(drawVec(14, 0));moveBeam(0, -12);g2.draw(drawVec(0, 24));moveBeam(4, 0);}
else if ("5".equals(numToRender[i])) {moveBeam(14, -24);g2.draw(drawVec(-14, 0));g2.draw(drawVec(0, 12));g2.draw(drawVec(14, 0));g2.draw(drawVec(0, 12));g2.draw(drawVec(-14, 0));moveBeam(18, 0);}
else if ("6".equals(numToRender[i])) {moveBeam(0, -24);g2.draw(drawVec(0, 24));g2.draw(drawVec(14, 0));g2.draw(drawVec(0, -12));g2.draw(drawVec(-14, 0));moveBeam(18, 12);}
else if ("7".equals(numToRender[i])) {moveBeam(0, -24);g2.draw(drawVec(14, 0));g2.draw(drawVec(0, 24));moveBeam(4, 0);}
else if ("8".equals(numToRender[i])) {g2.draw(drawVec(0, -24));g2.draw(drawVec(14, 0));g2.draw(drawVec(0, 24));g2.draw(drawVec(-14, 0));moveBeam(0, -12);g2.draw(drawVec(14, 0));moveBeam(4, 12);}
else if ("9".equals(numToRender[i])) {moveBeam(14, 0);g2.draw(drawVec(0, -24));g2.draw(drawVec(-14, 0));g2.draw(drawVec(0, 12));g2.draw(drawVec(14, 0));moveBeam(4, 12);}
else {g2.draw(drawVec(14, 0));g2.draw(drawVec(0, -24));g2.draw(drawVec(-14, 0));g2.draw(drawVec(0, 24));moveBeam(18, 0);}
}
// Level
resetBeam();
moveBeam(380, -13);
numToString = String.valueOf(VectorBreakout.level);
numToRender = numToString.split("");
for (byte i = iStart; i < numToRender.length; i++) {
if ("1".equals(numToRender[i])) {moveBeam(13, 0);g2.draw(drawVec(0, -24));moveBeam(5, 24);}
else if ("2".equals(numToRender[i])) {moveBeam(0, -24);g2.draw(drawVec(14, 0));g2.draw(drawVec(0, 12));g2.draw(drawVec(-14, 0));g2.draw(drawVec(0, 12));g2.draw(drawVec(14, 0));moveBeam(4, 0);}
else if ("3".equals(numToRender[i])) {moveBeam(0, -24);g2.draw(drawVec(14, 0));g2.draw(drawVec(0, 12));g2.draw(drawVec(-14, 0));moveBeam(14, 0);g2.draw(drawVec(0, 12));g2.draw(drawVec(-14, 0));moveBeam(18, 0);}
else if ("4".equals(numToRender[i])) {moveBeam(0, -24);g2.draw(drawVec(0, 12));g2.draw(drawVec(14, 0));moveBeam(0, -12);g2.draw(drawVec(0, 24));moveBeam(4, 0);}
else if ("5".equals(numToRender[i])) {moveBeam(14, -24);g2.draw(drawVec(-14, 0));g2.draw(drawVec(0, 12));g2.draw(drawVec(14, 0));g2.draw(drawVec(0, 12));g2.draw(drawVec(-14, 0));moveBeam(18, 0);}
else if ("6".equals(numToRender[i])) {moveBeam(0, -24);g2.draw(drawVec(0, 24));g2.draw(drawVec(14, 0));g2.draw(drawVec(0, -12));g2.draw(drawVec(-14, 0));moveBeam(18, 12);}
else if ("7".equals(numToRender[i])) {moveBeam(0, -24);g2.draw(drawVec(14, 0));g2.draw(drawVec(0, 24));moveBeam(4, 0);}
else if ("8".equals(numToRender[i])) {g2.draw(drawVec(0, -24));g2.draw(drawVec(14, 0));g2.draw(drawVec(0, 24));g2.draw(drawVec(-14, 0));moveBeam(0, -12);g2.draw(drawVec(14, 0));moveBeam(4, 12);}
else if ("9".equals(numToRender[i])) {moveBeam(14, 0);g2.draw(drawVec(0, -24));g2.draw(drawVec(-14, 0));g2.draw(drawVec(0, 12));g2.draw(drawVec(14, 0));moveBeam(4, 12);}
else {g2.draw(drawVec(14, 0));g2.draw(drawVec(0, -24));g2.draw(drawVec(-14, 0));g2.draw(drawVec(0, 24));moveBeam(18, 0);}
}
// Walls // Walls
g2.setColor(Color.gray); g2.setColor(Color.gray);
g2.setStroke(bt(10)); g2.setStroke(bt(10));
@ -107,7 +41,7 @@ public class GameDisplay extends JComponent {
// Bricks // Bricks
if (VectorBreakout.currentLevel != null) { if (VectorBreakout.currentLevel != null) {
for (byte i = 0; i < VectorBreakout.currentLevel.levelBricks.length; i++) { for (short i = 0; i < VectorBreakout.currentLevel.levelBricks.length; i++) {
if (VectorBreakout.currentLevel.levelBricks[i] != null) { if (VectorBreakout.currentLevel.levelBricks[i] != null) {
if (VectorBreakout.currentLevel.levelBricks[i].isBroken == false) { if (VectorBreakout.currentLevel.levelBricks[i].isBroken == false) {
resetBeam(); resetBeam();
@ -155,8 +89,7 @@ public class GameDisplay extends JComponent {
} }
} }
// Particles (still experimenting with these! rendering disabled for now...) // Particles
/*
for (byte i = 0; i < VectorBreakout.currentParticles.length; i++) { for (byte i = 0; i < VectorBreakout.currentParticles.length; i++) {
if (VectorBreakout.currentParticles[i] != null) { if (VectorBreakout.currentParticles[i] != null) {
if (VectorBreakout.currentParticles[i].isActive) { if (VectorBreakout.currentParticles[i].isActive) {
@ -168,7 +101,273 @@ public class GameDisplay extends JComponent {
} }
} }
} }
/* TextElements
*
* Note on rendering numbers:
*
* I am aware that I could be using a switch statement for these.
* However, this did not compile when testing in JDK 1.5, as it would
* refuse to accept anything other than numbers in a switch statement.
* Since I am a silly little nerd who wishes to use this on my older
* systems, I used these goofy if/else statements so I could compile
* on the older JDKs and play on my older systems...
*/ */
for (byte i = 0; i < VectorBreakout.currentTextElements.length; i++) {
if (VectorBreakout.currentTextElements[i] != null) {
if (VectorBreakout.currentTextElements[i].active) {
resetBeam();
moveBeam(VectorBreakout.currentTextElements[i].x, VectorBreakout.currentTextElements[i].y);
float oldBeamScaleX = beamScaleX;
float oldBeamScaleY = beamScaleY;
beamScaleX = beamScaleX * VectorBreakout.currentTextElements[i].textScale;
beamScaleY = beamScaleY * VectorBreakout.currentTextElements[i].textScale;
g2.setColor(vc(VectorBreakout.currentTextElements[i].textColor));
g2.setStroke(bt(VectorBreakout.currentTextElements[i].vectorScale));
String stringToSplit = String.valueOf(VectorBreakout.currentTextElements[i].text);
String[] stringToRender = stringToSplit.split("");
for (short ii = iStart; ii < stringToRender.length; ii++) {
if ("1".equals(stringToRender[ii])) {moveBeam(7, 0);g2.draw(drawVec(0, -24));moveBeam(11, 24);}
else if ("2".equals(stringToRender[ii])) {moveBeam(0, -24);g2.draw(drawVec(14, 0));g2.draw(drawVec(0, 12));g2.draw(drawVec(-14, 0));g2.draw(drawVec(0, 12));g2.draw(drawVec(14, 0));moveBeam(4, 0);}
else if ("3".equals(stringToRender[ii])) {moveBeam(0, -24);g2.draw(drawVec(14, 0));g2.draw(drawVec(0, 12));g2.draw(drawVec(-14, 0));moveBeam(14, 0);g2.draw(drawVec(0, 12));g2.draw(drawVec(-14, 0));moveBeam(18, 0);}
else if ("4".equals(stringToRender[ii])) {moveBeam(0, -24);g2.draw(drawVec(0, 12));g2.draw(drawVec(14, 0));moveBeam(0, -12);g2.draw(drawVec(0, 24));moveBeam(4, 0);}
else if ("5".equals(stringToRender[ii]) || "S".equals(stringToRender[ii])) {moveBeam(14, -24);g2.draw(drawVec(-14, 0));g2.draw(drawVec(0, 12));g2.draw(drawVec(14, 0));g2.draw(drawVec(0, 12));g2.draw(drawVec(-14, 0));moveBeam(18, 0);}
else if ("6".equals(stringToRender[ii])) {moveBeam(0, -24);g2.draw(drawVec(0, 24));g2.draw(drawVec(14, 0));g2.draw(drawVec(0, -12));g2.draw(drawVec(-14, 0));moveBeam(18, 12);}
else if ("7".equals(stringToRender[ii])) {moveBeam(0, -24);g2.draw(drawVec(14, 0));g2.draw(drawVec(0, 24));moveBeam(4, 0);}
else if ("8".equals(stringToRender[ii])) {g2.draw(drawVec(0, -24));g2.draw(drawVec(14, 0));g2.draw(drawVec(0, 24));g2.draw(drawVec(-14, 0));moveBeam(0, -12);g2.draw(drawVec(14, 0));moveBeam(4, 12);}
else if ("9".equals(stringToRender[ii])) {moveBeam(14, 0);g2.draw(drawVec(0, -24));g2.draw(drawVec(-14, 0));g2.draw(drawVec(0, 12));g2.draw(drawVec(14, 0));moveBeam(4, 12);}
else if ("0".equals(stringToRender[ii]) || "O".equals(stringToRender[ii])) {g2.draw(drawVec(14, 0));g2.draw(drawVec(0, -24));g2.draw(drawVec(-14, 0));g2.draw(drawVec(0, 24));moveBeam(18, 0);}
else if ("\\".equals(stringToRender[ii])) {moveBeam(-(beamX - VectorBreakout.currentTextElements[i].x), 30);} // Newline
else if ("A".equals(stringToRender[ii])) {
g2.draw(drawVec(0, -17));
g2.draw(drawVec(7, -7));
g2.draw(drawVec(7, 7));
g2.draw(drawVec(0, 17));
moveBeam(-14, -10);
g2.draw(drawVec(14, 0));
moveBeam(4, 10);
}
else if ("B".equals(stringToRender[ii])) {
g2.draw(drawVec(0, -24));
g2.draw(drawVec(11, 0));
g2.draw(drawVec(3, 3));
g2.draw(drawVec(0, 6));
g2.draw(drawVec(-3, 3));
g2.draw(drawVec(3, 3));
g2.draw(drawVec(0, 6));
g2.draw(drawVec(-3, 3));
g2.draw(drawVec(-11, 0));
moveBeam(0, -12);
g2.draw(drawVec(11, 0));
moveBeam(7, 12);
}
else if ("C".equals(stringToRender[ii])) {
moveBeam(14, -24);
g2.draw(drawVec(-14, 0));
g2.draw(drawVec(0, 24));
g2.draw(drawVec(14, 0));
moveBeam(4, 0);
}
else if ("D".equals(stringToRender[ii])) {
g2.draw(drawVec(7, 0));
g2.draw(drawVec(7, -7));
g2.draw(drawVec(0, -10));
g2.draw(drawVec(-7, -7));
g2.draw(drawVec(-7, 0));
g2.draw(drawVec(0, 24));
moveBeam(18, 0);
}
else if ("E".equals(stringToRender[ii])) {
g2.draw(drawVec(0, -24));
g2.draw(drawVec(14, 0));
moveBeam(-14, 12);
g2.draw(drawVec(14, 0));
moveBeam(-14, 12);
g2.draw(drawVec(14, 0));
moveBeam(4, 0);
}
else if ("F".equals(stringToRender[ii])) {
g2.draw(drawVec(0, -24));
g2.draw(drawVec(14, 0));
moveBeam(-14, 12);
g2.draw(drawVec(14, 0));
moveBeam(4, 12);
}
else if ("G".equals(stringToRender[ii])) {
moveBeam(14, -17);
g2.draw(drawVec(0, -7));
g2.draw(drawVec(-14, 0));
g2.draw(drawVec(0, 24));
g2.draw(drawVec(14, 0));
g2.draw(drawVec(0, -8));
g2.draw(drawVec(-8, 0));
moveBeam(12, 8);
}
else if ("H".equals(stringToRender[ii])) {
g2.draw(drawVec(0, -24));
moveBeam(14, 0);
g2.draw(drawVec(0, 24));
moveBeam(-14, -12);
g2.draw(drawVec(14, 0));
moveBeam(4, 12);
}
else if ("I".equals(stringToRender[ii])) {
g2.draw(drawVec(14, 0));
moveBeam(-14, -24);
g2.draw(drawVec(14, 0));
moveBeam(-7, 0);
g2.draw(drawVec(0, 24));
moveBeam(11, 0);
}
else if ("J".equals(stringToRender[ii])) {
moveBeam(0, -7);
g2.draw(drawVec(7, 7));
g2.draw(drawVec(7, 0));
g2.draw(drawVec(0, -24));
moveBeam(4, 24);
}
else if ("K".equals(stringToRender[ii])) {
g2.draw(drawVec(0, -24));
moveBeam(14, 0);
g2.draw(drawVec(-14, 12));
g2.draw(drawVec(14, 12));
moveBeam(4, 0);
}
else if ("L".equals(stringToRender[ii])) {
moveBeam(0, -24);
g2.draw(drawVec(0, 24));
g2.draw(drawVec(14, 0));
moveBeam(4, 0);
}
else if ("M".equals(stringToRender[ii])) {
g2.draw(drawVec(0, -24));
g2.draw(drawVec(7, 7));
g2.draw(drawVec(7, -7));
g2.draw(drawVec(0, 24));
moveBeam(4, 0);
}
else if ("N".equals(stringToRender[ii])) {
g2.draw(drawVec(0, -24));
g2.draw(drawVec(14, 24));
g2.draw(drawVec(0, -24));
moveBeam(4, 24);
}
else if ("P".equals(stringToRender[ii])) {
g2.draw(drawVec(0, -24));
g2.draw(drawVec(14, 0));
g2.draw(drawVec(0, 12));
g2.draw(drawVec(-14, 0));
moveBeam(18, 12);
}
else if ("Q".equals(stringToRender[ii])) {
g2.draw(drawVec(0, -24));
g2.draw(drawVec(14, 0));
g2.draw(drawVec(0, 18));
g2.draw(drawVec(-6, 6));
g2.draw(drawVec(-8, 0));
moveBeam(8, -6);
g2.draw(drawVec(6, 6));
moveBeam(4, 0);
}
else if ("R".equals(stringToRender[ii])) {
g2.draw(drawVec(0, -24));
g2.draw(drawVec(14, 0));
g2.draw(drawVec(0, 12));
g2.draw(drawVec(-14, 0));
moveBeam(2, 0);
g2.draw(drawVec(12, 12));
moveBeam(4, 0);
}
else if ("T".equals(stringToRender[ii])) {
moveBeam(0, -24);
g2.draw(drawVec(14, 0));
moveBeam(-7, 0);
g2.draw(drawVec(0, 24));
moveBeam(11, 0);
}
else if ("U".equals(stringToRender[ii])) {
moveBeam(0, -24);
g2.draw(drawVec(0, 24));
g2.draw(drawVec(14, 0));
g2.draw(drawVec(0, -24));
moveBeam(4, 24);
}
else if ("V".equals(stringToRender[ii])) {
moveBeam(0, -24);
g2.draw(drawVec(7, 24));
g2.draw(drawVec(7, -24));
moveBeam(4, 24);
}
else if ("W".equals(stringToRender[ii])) {
moveBeam(0, -24);
g2.draw(drawVec(0, 24));
g2.draw(drawVec(7, -7));
g2.draw(drawVec(7, 7));
g2.draw(drawVec(0, -24));
moveBeam(4, 24);
}
else if ("X".equals(stringToRender[ii])) {
moveBeam(0, -24);
g2.draw(drawVec(14, 24));
moveBeam(-14, 0);
g2.draw(drawVec(14, -24));
moveBeam(4, 24);
}
else if ("Y".equals(stringToRender[ii])) {
moveBeam(0, -24);
g2.draw(drawVec(7, 7));
g2.draw(drawVec(7, -7));
moveBeam(-7, 7);
g2.draw(drawVec(0, 17));
moveBeam(11, 0);
}
else if ("Z".equals(stringToRender[ii])) {
moveBeam(0, -24);
g2.draw(drawVec(14, 0));
g2.draw(drawVec(-14, 24));
g2.draw(drawVec(14, 0));
moveBeam(4, 0);
}
else if (".".equals(stringToRender[ii])) {
moveBeam(7, 0);
g2.draw(drawVec(0, -2));
moveBeam(11, 2);
}
else if (",".equals(stringToRender[ii])) {
moveBeam(7, 0);
g2.draw(drawVec(0, -5));
moveBeam(11, 5);
}
else if (":".equals(stringToRender[ii])) {
moveBeam(7, 0);
g2.draw(drawVec(0, -2));
moveBeam(0, -10);
g2.draw(drawVec(0, -2));
moveBeam(11, 14);
}
else if (";".equals(stringToRender[ii])) {
moveBeam(7, 0);
g2.draw(drawVec(0, -5));
moveBeam(0, -7);
g2.draw(drawVec(0, -2));
moveBeam(11, 14);
}
else if ("!".equals(stringToRender[ii])) {
moveBeam(7, 0);
g2.draw(drawVec(0, -2));
moveBeam(0, -10);
g2.draw(drawVec(0, -12));
moveBeam(11, 24);
}
else { // Blank space
moveBeam(18, 0);
}
}
beamScaleX = oldBeamScaleX;
beamScaleY = oldBeamScaleY;
}
}
}
// Paused // Paused
g2.setStroke(bt(3)); g2.setStroke(bt(3));
@ -232,7 +431,8 @@ public class GameDisplay extends JComponent {
case 4: return Color.magenta; case 4: return Color.magenta;
case 5: return Color.yellow; case 5: return Color.yellow;
case 15: return Color.white; case 15: return Color.white;
default: return Color.gray; case 16: return Color.getHSBColor(313, 34, 100); // pink test
default: return Color.white;
} }
} }
@ -253,93 +453,4 @@ public class GameDisplay extends JComponent {
public GameDisplay() { public GameDisplay() {
} }
/* For later use
// A
g2.draw(drawVec(0, -70));
g2.draw(drawVec(40, -40));
g2.draw(drawVec(40, 40));
g2.draw(drawVec(0, 70));
g2.draw(drawVec(0, -40));
g2.draw(drawVec(-80, 0));
moveBeam(100, 40);
// B
g2.draw(drawVec(0, -110));
g2.draw(drawVec(60, 0));
g2.draw(drawVec(20, (float) 18.333));
g2.draw(drawVec(0, (float) 18.333));
g2.draw(drawVec(-20, (float) 18.333));
g2.draw(drawVec(-60, 0));
g2.draw(drawVec(60, 0));
g2.draw(drawVec(20, (float) 18.333));
g2.draw(drawVec(0, (float) 18.333));
g2.draw(drawVec(-20, (float) 18.333));
g2.draw(drawVec(-60, 0));
moveBeam(100, 0);
// C
moveBeam(80, -110);
g2.draw(drawVec(-80, 0));
g2.draw(drawVec(0, 110));
g2.draw(drawVec(80, 0));
moveBeam(20, 0);
// D
g2.draw(drawVec(40, 0));
g2.draw(drawVec(40, -40));
g2.draw(drawVec(0, -30));
g2.draw(drawVec(-40, -40));
g2.draw(drawVec(-40, 0));
g2.draw(drawVec(0, 110));
moveBeam(100, 110);
// E
moveBeam(80, -110);
g2.draw(drawVec(-80, 0));
g2.draw(drawVec(0, -55));
g2.draw(drawVec(80, 0));
moveBeam(-80, 0);
g2.draw(drawVec(0, -55));
g2.draw(drawVec(80, 0));
moveBeam(20, 0);
// F
g2.draw(drawVec(0, 110));
moveBeam(0, -110);
g2.draw(drawVec(80, 0));
moveBeam(-80, 50);
g2.draw(drawVec(80, 0));
moveBeam(10, 60);
// P
g2.draw(drawVec(0, -110));
g2.draw(drawVec(80, 0));
g2.draw(drawVec(0, 50));
g2.draw(drawVec(-80, 0));
moveBeam(100, 60);
// A
g2.draw(drawVec(0, -70));
g2.draw(drawVec(40, -40));
g2.draw(drawVec(40, 40));
g2.draw(drawVec(0, 70));
g2.draw(drawVec(0, -40));
g2.draw(drawVec(-80, 0));
moveBeam(100, 40);
// U
moveBeam(0, -110);
g2.draw(drawVec(0, 110));
g2.draw(drawVec(80, 0));
g2.draw(drawVec(0, -110));
moveBeam(20, 110);
// S
g2.draw(drawVec(80, 0));
g2.draw(drawVec(0, -55));
g2.draw(drawVec(-80, 0));
g2.draw(drawVec(0, -55));
g2.draw(drawVec(80, 0));
moveBeam(20, -110);
*/
} }

View file

@ -1,9 +1,13 @@
package dev.boyfailure.quajra.vectorbreakout; package dev.boyfailure.quajra.vectorbreakout;
import java.util.Timer;
import java.util.TimerTask;
public class Level { public class Level {
short levelID; short levelID;
String levelName = "Level"; byte rowHeight = 21;
String levelName = "LEVEL";
byte[] levelLayout; // 19 bricks per row byte[] levelLayout; // 19 bricks per row
Brick[] levelBricks; Brick[] levelBricks;
@ -12,31 +16,53 @@ public class Level {
switch(id) { switch(id) {
case 1: case 1:
this.levelName = "Test"; this.levelName = "HELLO WORLD";
levelLayout = new byte[]
{4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,
3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,
2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,
1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1};
break;
case 2:
this.levelName = "DOUBLE TROUBLE";
levelLayout = new byte[] levelLayout = new byte[]
{4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4, {4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,
3,3,3,3,3,5,3,3,3,3,3,3,3,5,3,3,3,3,3, 3,3,3,3,3,5,3,3,3,3,3,3,3,5,3,3,3,3,3,
2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2, 2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,
1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1}; 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1};
break; break;
case 2: case 3:
this.levelName = "waow (based)"; this.levelName = "THINKY THINKY...";
levelLayout = new byte[] levelLayout = new byte[]
{4,1,2,3,4,1,2,3,4,1,2,3,4,1,2,3,4,1,2, {4,1,2,3,4,1,2,3,4,1,2,3,4,1,2,3,4,1,2,
3,4,1,2,3,4,1,2,3,4,1,2,3,4,1,2,3,4,1, 3,4,1,2,3,4,1,2,3,4,1,2,3,4,1,2,3,4,1,
2,3,4,1,2,3,4,1,2,3,4,1,2,3,4,1,2,3,4, 2,3,4,1,2,3,4,1,2,3,4,1,2,3,4,1,2,3,4,
1,2,3,4,1,2,3,4,1,2,3,4,1,2,3,4,1,2,3}; 1,2,3,4,1,2,3,4,1,2,3,4,1,2,3,4,1,2,3};
break; break;
case 3: case 4:
this.levelName = "HOLES"; this.levelName = "HOLES!!";
levelLayout = new byte[] levelLayout = new byte[]
{4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4, {4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,
3,3,0,0,3,3,3,3,0,0,0,3,3,3,3,0,0,3,3, 3,3,0,0,3,3,3,3,0,0,0,3,3,3,3,0,0,3,3,
2,2,0,0,2,2,2,2,0,0,0,2,2,2,2,0,0,2,2, 2,2,0,0,2,2,2,2,0,0,0,2,2,2,2,0,0,2,2,
1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1}; 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1};
break; break;
case 1001:
this.levelName = "TRANS RIGHTS";
levelLayout = new byte[]
{2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,
2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,
6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,
6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,
7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,
6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,
2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,
2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2};
break;
default: default:
this.levelName = "Level " + levelID; this.levelName = "LEVEL " + levelID;
levelLayout = new byte[] levelLayout = new byte[]
{1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, {1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
@ -55,19 +81,25 @@ public class Level {
for (int i = 0; i < this.levelLayout.length; i++) { for (int i = 0; i < this.levelLayout.length; i++) {
switch (this.levelLayout[i]) { switch (this.levelLayout[i]) {
case 1: case 1:
this.levelBricks[i] = new Brick(brickLeftPlacement, (((int) (i / 19)) * 20) + 50, false, 3, 4, 0); this.levelBricks[i] = new Brick(brickLeftPlacement, (((int) (i / 19)) * this.rowHeight) + 50, false, 3, 4, 0);
break; break;
case 2: case 2:
this.levelBricks[i] = new Brick(brickLeftPlacement, (((int) (i / 19)) * 20) + 50, false, 2, 8, 0); this.levelBricks[i] = new Brick(brickLeftPlacement, (((int) (i / 19)) * this.rowHeight) + 50, false, 2, 8, 0);
break; break;
case 3: case 3:
this.levelBricks[i] = new Brick(brickLeftPlacement, (((int) (i / 19)) * 20) + 50, false, 1, 16, 0); this.levelBricks[i] = new Brick(brickLeftPlacement, (((int) (i / 19)) * this.rowHeight) + 50, false, 1, 16, 0);
break; break;
case 4: case 4:
this.levelBricks[i] = new Brick(brickLeftPlacement, (((int) (i / 19)) * 20) + 50, false, 0, 32, 0); this.levelBricks[i] = new Brick(brickLeftPlacement, (((int) (i / 19)) * this.rowHeight) + 50, false, 0, 32, 0);
break; break;
case 5: case 5:
this.levelBricks[i] = new Brick(brickLeftPlacement, (((int) (i / 19)) * 20) + 50, false, 4, 8, 2); this.levelBricks[i] = new Brick(brickLeftPlacement, (((int) (i / 19)) * this.rowHeight) + 50, false, 4, 8, 2);
break;
case 6:
this.levelBricks[i] = new Brick(brickLeftPlacement, (((int) (i / 19)) * this.rowHeight) + 50, false, 4, 8, 0);
break;
case 7:
this.levelBricks[i] = new Brick(brickLeftPlacement, (((int) (i / 19)) * this.rowHeight) + 50, false, 15, 8, 0);
break; break;
default: default:
this.levelBricks[i] = null; this.levelBricks[i] = null;
@ -78,7 +110,16 @@ public class Level {
} }
} }
VectorBreakout.bricksOnScreen = (short) this.levelBricks.length; VectorBreakout.bricksOnScreen = (short) this.levelBricks.length;
VectorBreakout.currentTextElements[2].setText(String.valueOf(this.levelID));
VectorBreakout.currentTextElements[3] = new TextElement("", 1, 24, 480, 15, 2);
VectorBreakout.currentTextElements[3].setText("LEVEL " + String.valueOf(this.levelID) + ": " + this.levelName);
VectorBreakout.currentTextElements[3].activate();
Timer levelTitleGTFO = new Timer();
levelTitleGTFO.schedule(new TimerTask() {
public void run() {
VectorBreakout.currentTextElements[3].cull();
}
}, 3000);
} }
} }

View file

@ -15,35 +15,36 @@ public class Particle {
byte particleDirection; byte particleDirection;
byte particleSpeed = 2; byte particleSpeed = 2;
public Particle(int pid, int x, int y, int x2, int y2, int pc, float sc, int dir, int speed) { public Particle(int particleID, int x, int y, int x2, int y2, int particleColor, float vectorScale, int direction, int speed) {
this.particleID = (byte) pid; this.particleID = (byte) particleID;
this.particleX = (short) x; this.particleX = (short) x;
this.particleY = (short) y; this.particleY = (short) y;
this.particleX2 = (short) x2; this.particleX2 = (short) x2;
this.particleY2 = (short) y2; this.particleY2 = (short) y2;
this.particleColor = (byte) pc; this.particleColor = (byte) particleColor;
this.vectorScale = sc; this.vectorScale = vectorScale;
this.particleDirection = (byte) dir; this.particleDirection = (byte) direction;
this.particleSpeed = (byte) speed; this.particleSpeed = (byte) speed;
} }
public void spawn(int lifetime) { public void spawn(int lifetime) {
this.isActive = true; this.isActive = true;
this.particleLifetime = (short) lifetime; if (VectorBreakout.confettiMode) {this.particleLifetime = 400;}
else {this.particleLifetime = (short) lifetime;}
} }
public void update() { public void update() {
this.particleFrame++; this.particleFrame++;
if (this.particleDirection != 0) { if (this.particleDirection != 0) {
switch(this.particleDirection) { switch(this.particleDirection) {
case 1:this.particleX += this.particleSpeed;break; case 1:this.particleX += this.particleSpeed;break; // Right
case 2:this.particleX += this.particleSpeed;this.particleY+= this.particleSpeed;break; case 2:this.particleX += this.particleSpeed;this.particleY+= this.particleSpeed;break; // Down right
case 3:this.particleY += this.particleSpeed;break; case 3:this.particleY += this.particleSpeed;break; // Down
case 4:this.particleX -= this.particleSpeed;this.particleY+= this.particleSpeed;break; case 4:this.particleX -= this.particleSpeed;this.particleY+= this.particleSpeed;break; // Down left
case 5:this.particleX -= this.particleSpeed;break; case 5:this.particleX -= this.particleSpeed;break; // Left
case 6:this.particleX -= this.particleSpeed;this.particleY-= this.particleSpeed;break; case 6:this.particleX -= this.particleSpeed;this.particleY-= this.particleSpeed;break; // Up left
case 7:this.particleY -= this.particleSpeed;break; case 7:this.particleY -= this.particleSpeed;break; // Up
case 8:this.particleX += this.particleSpeed;this.particleY-= this.particleSpeed;break; case 8:this.particleX += this.particleSpeed;this.particleY-= this.particleSpeed;break; // Up right
} }
} }
if (this.particleFrame >= this.particleLifetime) { if (this.particleFrame >= this.particleLifetime) {

View file

@ -0,0 +1,72 @@
package dev.boyfailure.quajra.vectorbreakout;
public class TextElement {
String text;
boolean active = false;
float textScale = 1;
float vectorScale = 1;
byte textColor;
short x;
short y;
/**
* Text elements.
* @param text The text that will be displayed.
* @param textScale The size of the text on screen.
* @param x The x coordinate of the text's origin point.
* @param y The y coordinate of the text's origin point.
* @param textColor The color of the text.
*/
public TextElement(String text, float textScale, int x, int y, int textColor, float vectorScale) {
this.text = text;
this.textScale = textScale;
this.x = (short) x;
this.y = (short) y;
this.textColor = (byte) textColor;
this.vectorScale = vectorScale;
}
/**
* Prepares the TextElement for rendering.
*/
public void activate() {
this.active = true;
}
/**
* Prepares the TextElement for culling.
*/
public void cull() {
this.active = false;
this.x = 32767;
this.y = 32767;
}
/**
* Changes the text that the TextElement will display.
* @param text The text that the TextElement will display.
*/
public void setText(String text) {
this.text = text;
}
/**
* Changes the text that the TextElement will display.
* @param x The x coordinate of the text's origin point.
* @param y The y coordinate of the text's origin point.
*/
public void moveTo(int x, int y) {
this.x = (short) x;
this.y = (short) y;
}
/**
* Changes the color of the text.
* @param textColor The color of the text.
*/
public void setColor(int textColor) {
this.textColor = (byte) textColor;
}
}

View file

@ -17,24 +17,26 @@ public class VectorBreakout {
public static boolean isPaused = false; public static boolean isPaused = false;
public static boolean debugMenuEnabled = false; public static boolean debugMenuEnabled = false;
public static boolean isLost = false; public static boolean isLost = false;
public static short gameResX = 800; public static boolean movingLeft = false;
public static short gameResY = 600; public static boolean movingRight = false;
public static boolean confettiMode = false;
public static byte lives = 5; public static byte lives = 5;
public static byte chancey = 0; public static byte chancey = 0;
public static short level = 1;
public static byte ballsOnScreen = 0; public static byte ballsOnScreen = 0;
public static short bricksOnScreen = 0;
public static byte targetFrameRate = 60; public static byte targetFrameRate = 60;
public static byte actualFrames = 0; public static byte actualFrames = 0;
public static byte actualFrameRate = 0; public static byte actualFrameRate = 0;
public static byte gameTickRate = 60; public static byte gameTickRate = 60;
public static short gameResX = 800;
public static short gameResY = 600;
public static short level = 1;
public static short bricksOnScreen = 0;
public static int score = 0; public static int score = 0;
public static long frameCounter = 0; public static long frameCounter = 0;
public static boolean movingLeft = false;
public static boolean movingRight = false;
public static Ball[] currentBalls = new Ball[10]; public static Ball[] currentBalls = new Ball[10];
public static Particle[] currentParticles = new Particle[63]; public static Particle[] currentParticles = new Particle[127];
public static Paddle[] currentPaddles = {new Paddle(350, 500, 100, 15, 0, 1)}; public static Paddle[] currentPaddles = new Paddle[2];
public static TextElement[] currentTextElements = new TextElement[63];
public static Level currentLevel; public static Level currentLevel;
public VectorBreakout() { public VectorBreakout() {
@ -128,7 +130,7 @@ public class VectorBreakout {
actualFrameRate = actualFrames; actualFrameRate = actualFrames;
actualFrames = 0; actualFrames = 0;
if (currentLevel != null) { if (currentLevel != null) {
for (byte i = 0; i < currentLevel.levelBricks.length; i++) { for (short i = 0; i < currentLevel.levelBricks.length; i++) {
if (currentLevel.levelBricks[i] != null) { if (currentLevel.levelBricks[i] != null) {
if (currentLevel.levelBricks[i].isBroken) { if (currentLevel.levelBricks[i].isBroken) {
currentLevel.levelBricks[i] = null; currentLevel.levelBricks[i] = null;
@ -136,6 +138,7 @@ public class VectorBreakout {
} }
} }
} }
for (byte i = 0; i < currentBalls.length; i++) { for (byte i = 0; i < currentBalls.length; i++) {
if (currentBalls[i] != null) { if (currentBalls[i] != null) {
if (currentBalls[i].isActive == false) { if (currentBalls[i].isActive == false) {
@ -150,6 +153,14 @@ public class VectorBreakout {
} }
} }
} }
for (byte i = 0; i < currentTextElements.length; i++) {
if (currentTextElements[i] != null) {
if (currentTextElements[i].active == false) {
currentTextElements[i] = null;
}
}
}
if (bricksOnScreen <= 0 && isGameStarted) { if (bricksOnScreen <= 0 && isGameStarted) {
level++; level++;
currentLevel = new Level(level); currentLevel = new Level(level);
@ -158,6 +169,13 @@ public class VectorBreakout {
} }
}); });
gameCuller.start(); gameCuller.start();
currentTextElements[0] = new TextElement("VECTOR BREAKOUT", 2.5f, 67, 280, 15, 2);
currentTextElements[1] = new TextElement("MMXXV BOYFAILURE.DEV", 0.75f, 259, 315, 15, 1);
currentTextElements[2] = new TextElement("PRESS SPACE TO BEGIN", 1, 215, 345, 15, 2);
currentTextElements[0].activate();
currentTextElements[1].activate();
currentTextElements[2].activate();
} }
@ -207,7 +225,7 @@ public class VectorBreakout {
public static void gameLose() { public static void gameLose() {
if (currentLevel != null) { if (currentLevel != null) {
for (byte i = 0; i < currentLevel.levelBricks.length; i++) { for (short i = 0; i < currentLevel.levelBricks.length; i++) {
currentLevel.levelBricks[i] = null; currentLevel.levelBricks[i] = null;
} }
} }
@ -219,6 +237,9 @@ public class VectorBreakout {
} }
public static void newGame() { public static void newGame() {
for (byte i = 0; i < currentTextElements.length; i++) {
currentTextElements[i] = null;
}
lives = 5; lives = 5;
isLost = false; isLost = false;
score = 0; score = 0;
@ -229,6 +250,12 @@ public class VectorBreakout {
movingRight = false; movingRight = false;
currentPaddles[0] = new Paddle(350, 500, 100, 15, 0, 1); currentPaddles[0] = new Paddle(350, 500, 100, 15, 0, 1);
//test currentPaddles[0] = new Paddle(0, 500, 800, 60, 0, 1); //test currentPaddles[0] = new Paddle(0, 500, 800, 60, 0, 1);
currentTextElements[0] = new TextElement(String.valueOf(score), 1, 20, -13, 15, 2);
currentTextElements[1] = new TextElement(String.valueOf(lives), 1, 200, -13, 15, 2);
currentTextElements[2] = new TextElement(String.valueOf(level), 1, 380, -13, 15, 2);
currentTextElements[0].activate();
currentTextElements[1].activate();
currentTextElements[2].activate();
currentLevel = new Level(level); currentLevel = new Level(level);
currentLevel.startLevel(); currentLevel.startLevel();
} }