10 Commits
28280ec94e
...
1824042686
Author | SHA1 | Message | Date |
---|---|---|---|
Nico B | 1824042686 |
gitignore modified
|
3 years ago |
Nico B | 01bb10e5dc |
HA04 finished
|
3 years ago |
Nico B | 266c4fa45b |
hello
|
3 years ago |
jkonert | 733f17dbe8 |
and yet another JavaDoc fix
|
3 years ago |
jkonert | 95060106fc |
another JavaDoc fix
|
3 years ago |
jkonert | f0343418f9 |
fixed some JavaDoc mistakes
|
3 years ago |
jkonert | 82cd0392e5 |
removed old JPG of prof Gepperth
|
3 years ago |
jkonert | 5d7ff484ec |
added .DS_Store to .gitignore, changed some patterns slightly
|
3 years ago |
jkonert | 5cce8e7fce |
fixed bug with path to log4j.log file on MacOS
|
3 years ago |
jkonert | 8d709a076d |
removed JUnit dependency of GameProject
|
3 years ago |
13 changed files with 99 additions and 129 deletions
-
29.gitignore
-
7GameProject/.classpath
-
4GameProject/src/base/GameLoop.java
-
15GameProject/src/base/MultiLevelGame.java
-
14GameProject/src/controller/CollisionAwareEgoController.java
-
39GameProject/src/controller/EgoController.java
-
2GameProject/src/log4j2.xml
-
2GameProject/src/playground/Level2.java
-
2GameProject/src/playground/Level4.java
-
30GameProject/src/playground/LevelWithBox.java
-
3GameProject/src/playground/Playground.java
-
81GameProject/src/playground/SpaceInvadersLevelTest.java
-
BINGameProject/video/alexG.jpg
@ -0,0 +1,30 @@ |
|||
package playground; |
|||
import java.awt.Color; |
|||
import gameobjects.*; |
|||
|
|||
/** This class adds a new level to the game. |
|||
* |
|||
* @author team22 |
|||
*/ |
|||
public class LevelWithBox extends SpaceInvadersLevel { |
|||
|
|||
/** This method overrides the initial method and adds a red rectangle on the top which does not do anything. |
|||
* |
|||
* @param id String identifies level |
|||
*/ |
|||
@Override |
|||
public void prepareLevel(String id) { |
|||
super.prepareLevel(id); |
|||
RectObject rectangle = new RectObject("rectangle", this, 350, 100, 0, 0, 700, 250, Color.RED); |
|||
addObject(rectangle); |
|||
} |
|||
|
|||
/** This method overrides the initial method to change the startup message. |
|||
* |
|||
* @return String Startup message |
|||
*/ |
|||
@Override |
|||
protected String getStartupMessage() { |
|||
return "Box-Level!"; |
|||
} |
|||
} |
@ -1,81 +0,0 @@ |
|||
package playground; |
|||
|
|||
import static org.junit.Assert.assertTrue; |
|||
import java.awt.Color; |
|||
import org.junit.jupiter.api.AfterAll; |
|||
import org.junit.jupiter.api.BeforeAll; |
|||
import org.junit.jupiter.api.Test; |
|||
import gameobjects.EgoObject; |
|||
import gameobjects.GameObject; |
|||
import gameobjects.RectObject; |
|||
|
|||
/** |
|||
* Tests {@link SpaceInvadersLevel} for |
|||
* <ol> |
|||
* <li>calcEnemySpeedX() returns the same value as constant SpaceInvadersLevel.ENEMYSPEEDX |
|||
* <li>calcEnemySpeedY() returns the same value as constant SpaceInvadersLevel.ENEMYSPEEDY |
|||
* <li>calcNrEnemies() returns the same value as constant SpaceInvadersLevel.NR_ENEMIES |
|||
* <li>actionIfEnemyIsHit() adds 200 points to score |
|||
* <li>actionIfEgoObjectIsHit() reduces number of lives (egoLives) |
|||
* </ol> |
|||
* @author jkonert |
|||
* |
|||
*/ |
|||
class SpaceInvadersLevelTest { |
|||
|
|||
private static SpaceInvadersLevel myLevel; |
|||
|
|||
@BeforeAll |
|||
static void setUpBeforeClass() throws Exception { |
|||
myLevel = new SpaceInvadersLevel(); |
|||
SpaceInvadersLevel.setGlobalFlag("egoLives", 5); |
|||
SpaceInvadersLevel.setGlobalFlag("points", 500); |
|||
SpaceInvadersLevel.setGlobalFlag("highscore", 5000); |
|||
} |
|||
|
|||
@AfterAll |
|||
static void tearDownAfterClass() throws Exception { |
|||
// nothing |
|||
} |
|||
|
|||
@Test |
|||
void testCalcEnemySpeedX() { |
|||
assertTrue("EnemySpeedX is as in SpaceInvadersLevel defined", myLevel.calcEnemySpeedX() == SpaceInvadersLevel.ENEMYSPEEDX); |
|||
} |
|||
|
|||
@Test |
|||
void testCalcEnemySpeedY() { |
|||
assertTrue("EnemySpeedY is as in SpaceInvadersLevel defined", myLevel.calcEnemySpeedY() == SpaceInvadersLevel.ENEMYSPEEDY); |
|||
} |
|||
|
|||
@Test |
|||
void testCalcNrEnemies() { |
|||
assertTrue("NrOfEnemies is as in SpaceInvadersLevel defined", myLevel.calcNrEnemies() == SpaceInvadersLevel.NR_ENEMIES); |
|||
} |
|||
|
|||
|
|||
@Test |
|||
void testActionIfEnemyIsHitPointsUp() { |
|||
Integer numPointsBefore = (Integer)Playground.getGlobalFlag("points"); |
|||
GameObject dummyShot = new RectObject("shot1", myLevel, 0,0,0,0, 12, 12, Color.WHITE); |
|||
GameObject dummyEnemy = new RectObject("ego1", myLevel, 0,0,0,0, 12, 12, Color.BLACK); |
|||
myLevel.addObject(dummyShot); |
|||
myLevel.addObject(dummyEnemy); |
|||
myLevel.actionIfEnemyIsHit(dummyEnemy, dummyShot);; // this is the call under test |
|||
Integer numPointsAfter = (Integer)Playground.getGlobalFlag("points"); // changed? |
|||
assertTrue("numPoints is up +200 after EnemyIsHit", numPointsAfter == numPointsBefore + 200); // points are set +200 , check. |
|||
} |
|||
|
|||
@Test |
|||
void testActionIfEgoObjectIsHitLivesDown() { |
|||
Integer numLivesBefore = (Integer)Playground.getGlobalFlag("egoLives"); |
|||
GameObject dummyShot = new RectObject("shot1", myLevel, 0,0,0,0, 12, 12, Color.RED); |
|||
GameObject dummyEgo = new EgoObject("ego1", myLevel, 0,0,0,0, 5); |
|||
myLevel.addObject(dummyShot); |
|||
myLevel.actionIfEgoObjectIsHit(dummyShot, dummyEgo); // this is the call under test |
|||
Integer numLivesAfter = (Integer)Playground.getGlobalFlag("egoLives"); // changed? |
|||
assertTrue("numLives is reduced by one ifEgoIsHit", numLivesAfter == numLivesBefore - 1); // lives is reduced by one |
|||
|
|||
} |
|||
|
|||
} |
Before Width: 1664 | Height: 2496 | Size: 181 KiB |
Write
Preview
Loading…
Cancel
Save
Reference in new issue