├── .gitattributes ├── .github ├── CODEOWNERS ├── ISSUE_TEMPLATE │ ├── bug_report.md │ └── feature_request.md ├── dependabot.yml └── workflows │ ├── deploy-dev.yml │ ├── deploy-pages.yml │ ├── deploy-prod.yml │ └── verify.yml ├── .gitignore ├── LICENSE.md ├── README.md ├── concept └── levels.md ├── config ├── codestyle_cleanup.xml └── codestyle_formatter.xml ├── documentation └── LEVEL.md ├── graphix ├── cannon.psd ├── evilCoin.psd ├── eye.psd ├── mainmenu.psd ├── mrRekt.psd ├── rekit.psd ├── rekitScreenshotArcade.png ├── rekitScreenshotBossRush.png ├── rekitScreenshotInfinite.png ├── rekitScreenshots.psd ├── rektSmasher.psd ├── rektSmasher_0.psd ├── rektSmasher_1.psd ├── rektSmasher_2.psd ├── rektSmasher_3.psd ├── robot.psd └── stackerFaces.psd ├── make.sh └── project ├── JavaDoc.launch ├── MultiJar.launch ├── SingleJar.launch ├── basic ├── .gitignore ├── pom.xml └── src │ └── main │ ├── java │ └── rekit │ │ └── logic │ │ ├── develop │ │ └── TestScene.java │ │ └── gameelements │ │ ├── entities │ │ ├── enemies │ │ │ ├── RektKiller.java │ │ │ ├── Rocket.java │ │ │ ├── Stacker.java │ │ │ ├── Warper.java │ │ │ ├── bosses │ │ │ │ ├── RektSmasher.java │ │ │ │ └── rocketboss │ │ │ │ │ ├── Brain.java │ │ │ │ │ ├── Mouth.java │ │ │ │ │ ├── RocketBoss.java │ │ │ │ │ ├── arm │ │ │ │ │ ├── Arm.java │ │ │ │ │ ├── ArmSegment.java │ │ │ │ │ ├── RocketBossChild.java │ │ │ │ │ ├── armaction │ │ │ │ │ │ ├── ArmAction.java │ │ │ │ │ │ ├── ArmActionCannon.java │ │ │ │ │ │ └── ArmActionRocketLauncher.java │ │ │ │ │ └── armstate │ │ │ │ │ │ ├── ArmActionState.java │ │ │ │ │ │ ├── ArmBuildState.java │ │ │ │ │ │ ├── ArmIdleState.java │ │ │ │ │ │ ├── ArmState.java │ │ │ │ │ │ └── ArmUnbuildState.java │ │ │ │ │ └── damagestate │ │ │ │ │ ├── DamageState.java │ │ │ │ │ ├── State0.java │ │ │ │ │ ├── State1.java │ │ │ │ │ ├── State2.java │ │ │ │ │ └── State3.java │ │ │ ├── cannon │ │ │ │ ├── Cannon.java │ │ │ │ ├── CannonParticle.java │ │ │ │ ├── CannonStateMachine.java │ │ │ │ └── state │ │ │ │ │ ├── AimingState.java │ │ │ │ │ ├── CannonState.java │ │ │ │ │ ├── ChargingState.java │ │ │ │ │ ├── IdleState.java │ │ │ │ │ └── ShootingState.java │ │ │ ├── piston │ │ │ │ ├── IPistonForState.java │ │ │ │ ├── Piston.java │ │ │ │ ├── PistonInner.java │ │ │ │ └── state │ │ │ │ │ ├── ClosedState.java │ │ │ │ │ ├── ClosingState.java │ │ │ │ │ ├── OpenState.java │ │ │ │ │ ├── OpeningState.java │ │ │ │ │ └── PistonState.java │ │ │ └── slurp │ │ │ │ ├── Slurp.java │ │ │ │ ├── SlurpDurp.java │ │ │ │ └── SlurpDurpVisComp.java │ │ └── pickups │ │ │ ├── BluePill.java │ │ │ ├── EvilCoin.java │ │ │ └── SuperCoin.java │ │ └── inanimate │ │ ├── AcceleratorBox.java │ │ ├── BoostBox.java │ │ ├── ClimbUpBox.java │ │ ├── FilterBox.java │ │ ├── MovingBox.java │ │ ├── ReflectionBox.java │ │ └── ToggleBox.java │ └── resources │ ├── conf │ ├── acceleratorbox.properties │ ├── bluepill.properties │ ├── boost.properties │ ├── cannon.properties │ ├── climbup.properties │ ├── piston.properties │ ├── rektkiller.properties │ ├── rektsmasher.properties │ ├── rocket.properties │ ├── rocketBoss.properties │ ├── slurp.properties │ ├── stacker.properties │ └── warper.properties │ ├── images │ ├── evilCoin.png │ ├── rektSmasher_0.png │ ├── rektSmasher_1.png │ ├── rektSmasher_2.png │ ├── rektSmasher_3.png │ ├── rocketBoss │ │ ├── cannon_left.png │ │ ├── cannon_right.png │ │ ├── head_0.png │ │ ├── head_1.png │ │ ├── head_2.png │ │ ├── head_3.png │ │ └── jet.png │ └── stacker │ │ ├── stackerFaces_01.png │ │ ├── stackerFaces_02.png │ │ ├── stackerFaces_03.png │ │ ├── stackerFaces_04.png │ │ └── stackerFaces_05.png │ └── levels │ ├── 1_Land_of_Smashin │ ├── level_1.dat │ ├── level_2.dat │ ├── level_3.dat │ ├── level_4.dat │ ├── level_5.dat │ └── level_6.dat │ ├── 2_Secret_Factory │ ├── level_1.dat │ ├── level_2.dat │ ├── level_3.dat │ ├── level_4.dat │ ├── level_5.dat │ └── level_6.dat │ ├── 3_Debug │ └── level1.dat │ └── test.dat ├── build.sh ├── check-updates.launch ├── game ├── .gitignore ├── pom.xml └── src │ └── main │ └── java │ └── rekit │ └── Main.java ├── global ├── .gitignore ├── pom.xml └── src │ └── main │ ├── java │ ├── org │ │ └── fuchss │ │ │ └── tools │ │ │ ├── lambda │ │ │ ├── BiFunctionWithException.java │ │ │ ├── ConsumerWithException.java │ │ │ ├── FunctionWithException.java │ │ │ ├── LambdaConvert.java │ │ │ ├── SupplierWithException.java │ │ │ ├── VoidFunction.java │ │ │ └── VoidFunctionWithException.java │ │ │ └── tuple │ │ │ ├── Tuple2.java │ │ │ ├── Tuple3.java │ │ │ └── Tuple4.java │ └── rekit │ │ ├── config │ │ └── GameConf.java │ │ ├── core │ │ ├── CameraTarget.java │ │ ├── GameGrid.java │ │ ├── GameTime.java │ │ ├── ShutdownManager.java │ │ └── Team.java │ │ ├── parser │ │ ├── ProgressParser.java │ │ ├── RGBAColorParser.java │ │ └── VecParser.java │ │ ├── primitives │ │ ├── TextOptions.java │ │ ├── geometry │ │ │ ├── Direction.java │ │ │ ├── Frame.java │ │ │ ├── Polygon.java │ │ │ └── Vec.java │ │ ├── image │ │ │ ├── AbstractImage.java │ │ │ └── RGBAColor.java │ │ ├── operable │ │ │ ├── OpProgress.java │ │ │ └── Operable.java │ │ └── time │ │ │ ├── Progress.java │ │ │ └── Timer.java │ │ └── util │ │ ├── CalcUtil.java │ │ ├── LambdaUtil.java │ │ ├── Once.java │ │ ├── ReflectUtils.java │ │ ├── ThreadUtils.java │ │ ├── container │ │ ├── ROContainer.java │ │ └── RWContainer.java │ │ └── state │ │ ├── State.java │ │ └── TimeStateMachine.java │ └── resources │ ├── conf │ └── game.properties │ └── images │ ├── life.png │ ├── logo_0.png │ ├── logo_1.png │ ├── logo_2.png │ ├── mainmenu.png │ ├── mrRekt_glasses_left.png │ └── mrRekt_glasses_right.png ├── gui ├── .gitignore ├── pom.xml └── src │ └── main │ ├── java │ └── rekit │ │ └── gui │ │ ├── GameGridImpl.java │ │ ├── GameView.java │ │ ├── ImageManagement.java │ │ ├── InputHelper.java │ │ ├── View.java │ │ └── controller │ │ ├── Controller.java │ │ ├── ControllerImpl.java │ │ ├── InputHelperImpl.java │ │ ├── Observer.java │ │ └── commands │ │ ├── AttackCommand.java │ │ ├── Command.java │ │ ├── CommandSupervisor.java │ │ ├── EntityCommand.java │ │ ├── FilterCommand.java │ │ ├── InputMethod.java │ │ ├── JumpCommand.java │ │ ├── MenuCommand.java │ │ ├── MenuDirection.java │ │ ├── PlayPauseCommand.java │ │ └── WalkCommand.java │ └── resources │ └── images │ └── icon.png ├── logic ├── .gitignore ├── pom.xml └── src │ └── main │ ├── java │ └── rekit │ │ └── logic │ │ ├── Collidable.java │ │ ├── GameModel.java │ │ ├── ILevelScene.java │ │ ├── IScene.java │ │ ├── Model.java │ │ ├── filters │ │ ├── Filter.java │ │ ├── GrayScaleMode.java │ │ ├── InvertedMode.java │ │ └── RandomMode.java │ │ ├── gameelements │ │ ├── FixedCameraTarget.java │ │ ├── GameElement.java │ │ ├── GameElementFactory.java │ │ ├── RangeCameraTarget.java │ │ ├── entities │ │ │ ├── Entity.java │ │ │ ├── Player.java │ │ │ ├── StateEntity.java │ │ │ ├── pickups │ │ │ │ ├── DefaultCoin.java │ │ │ │ └── Life.java │ │ │ └── state │ │ │ │ ├── DefaultState.java │ │ │ │ ├── EntityState.java │ │ │ │ ├── FallState.java │ │ │ │ ├── JumpState.java │ │ │ │ └── NotInitializedState.java │ │ ├── inanimate │ │ │ ├── EndTrigger.java │ │ │ ├── Inanimate.java │ │ │ ├── InanimateBox.java │ │ │ ├── InanimateDoor.java │ │ │ ├── InanimateFloor.java │ │ │ └── InanimateTrigger.java │ │ ├── particles │ │ │ ├── DamageParticle.java │ │ │ ├── Particle.java │ │ │ ├── ParticleSpawner.java │ │ │ ├── ParticleSpawnerOption.java │ │ │ ├── ParticleSpawnerOptionParser.java │ │ │ ├── TextParticle.java │ │ │ └── TextParticleSpawner.java │ │ └── type │ │ │ ├── Boss.java │ │ │ ├── Coin.java │ │ │ ├── DynamicInanimate.java │ │ │ ├── Enemy.java │ │ │ ├── Group.java │ │ │ └── Pickup.java │ │ ├── gui │ │ ├── BackgroundElement.java │ │ ├── GuiElement.java │ │ ├── LevelGuiElement.java │ │ ├── LifeGui.java │ │ ├── ScoreGui.java │ │ ├── Text.java │ │ ├── TimeDecorator.java │ │ ├── menu │ │ │ ├── ArcadeLevelItem.java │ │ │ ├── BoolSetting.java │ │ │ ├── MainMenuGrid.java │ │ │ ├── MenuActionItem.java │ │ │ ├── MenuGrid.java │ │ │ ├── MenuItem.java │ │ │ ├── MenuList.java │ │ │ ├── SubMenu.java │ │ │ └── TextItem.java │ │ └── parallax │ │ │ ├── BackgroundElement.java │ │ │ ├── HeapElement.java │ │ │ ├── HeapElementCloud.java │ │ │ ├── HeapElementMountain.java │ │ │ ├── HeapLayer.java │ │ │ ├── ParallaxContainer.java │ │ │ ├── ParallaxLayer.java │ │ │ └── TriangulationLayer.java │ │ ├── level │ │ ├── BossRushStructurePart.java │ │ ├── BossStructure.java │ │ ├── Level.java │ │ ├── LevelFactory.java │ │ ├── LevelMtx.java │ │ ├── LogicalPart.java │ │ ├── Structure.java │ │ └── StructurePart.java │ │ └── scene │ │ ├── ArcadeLevelScene.java │ │ ├── BossRushScene.java │ │ ├── InfiniteLevelScene.java │ │ ├── LevelOfTheDayScene.java │ │ ├── LevelScene.java │ │ ├── MainMenuScene.java │ │ ├── Scene.java │ │ └── Scenes.java │ └── resources │ ├── conf │ ├── bossstructure.properties │ ├── endtrigger.properties │ └── player.properties │ └── levels │ └── infinite.dat ├── persistence ├── pom.xml └── src │ └── main │ └── java │ └── rekit │ └── persistence │ ├── DirFileDefinitions.java │ ├── ModManager.java │ └── level │ ├── DataKey.java │ ├── DataKeySetter.java │ ├── LevelData.java │ ├── LevelDefinition.java │ ├── LevelManager.java │ ├── LevelParser.java │ ├── LevelType.java │ ├── SettingKey.java │ └── parser │ ├── Token.java │ ├── TokenType.java │ ├── Tokenizer.java │ └── UnexpectedTokenException.java └── pom.xml /.gitattributes: -------------------------------------------------------------------------------- 1 | # Handle line endings automatically for files detected as text 2 | # and leave all files detected as binary untouched. 3 | * text=auto 4 | 5 | # 6 | # The above will handle all files NOT found below 7 | # 8 | # These files are text and should be normalized (Convert crlf => lf) 9 | *.gitattributes text 10 | .gitignore text 11 | *.md text 12 | *.css text 13 | *.df text 14 | *.htm text 15 | *.html text 16 | *.java text 17 | *.js text 18 | *.json text 19 | *.jsp text 20 | *.jspf text 21 | *.properties text 22 | *.sh text 23 | *.tld text 24 | *.txt text 25 | *.xml text 26 | 27 | # These files are binary and should be left untouched 28 | # (binary is a macro for -text -diff) 29 | *.class binary 30 | *.dll binary 31 | *.ear binary 32 | *.gif binary 33 | *.ico binary 34 | *.jar binary 35 | *.jpg binary 36 | *.jpeg binary 37 | *.png binary 38 | *.so binary 39 | *.war binary 40 | -------------------------------------------------------------------------------- /.github/CODEOWNERS: -------------------------------------------------------------------------------- 1 | * @AnJ95 @dfuchss @matzebond 2 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/bug_report.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Bug report 3 | about: Create a report to help us improve 4 | 5 | --- 6 | 7 | **Describe the bug** 8 | A clear and concise description of what the bug is. 9 | 10 | **To Reproduce** 11 | Steps to reproduce the behavior: 12 | 1. Go to '...' 13 | 2. Click on '....' 14 | 3. Scroll down to '....' 15 | 4. See error 16 | 17 | **Expected behavior** 18 | A clear and concise description of what you expected to happen. 19 | 20 | **Screenshots** 21 | If applicable, add screenshots to help explain your problem. 22 | 23 | **Desktop (please complete the following information):** 24 | - OS: [e.g. Windows 10] 25 | - Java Version [e.g. JRE10, JRE11] 26 | - ReKiT Version [e.g. 1.2.3] 27 | 28 | **Additional context** 29 | Add any other context about the problem here. 30 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/feature_request.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Feature request 3 | about: Suggest an idea for this project 4 | 5 | --- 6 | 7 | **Is your feature request related to a problem? Please describe.** 8 | A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] 9 | 10 | **Describe the solution you'd like** 11 | A clear and concise description of what you want to happen. 12 | 13 | **Describe alternatives you've considered** 14 | A clear and concise description of any alternative solutions or features you've considered. 15 | 16 | **Additional context** 17 | Add any other context or screenshots about the feature request here. 18 | -------------------------------------------------------------------------------- /.github/dependabot.yml: -------------------------------------------------------------------------------- 1 | version: 2 2 | updates: 3 | - package-ecosystem: "github-actions" 4 | directory: "/" 5 | schedule: 6 | interval: "weekly" 7 | day: "wednesday" 8 | time: "11:00" 9 | timezone: "Europe/Berlin" 10 | commit-message: 11 | prefix: "Dependency" 12 | include: "scope" 13 | - package-ecosystem: "maven" 14 | directory: "/project/" 15 | schedule: 16 | interval: "weekly" 17 | day: "wednesday" 18 | time: "11:00" 19 | timezone: "Europe/Berlin" 20 | commit-message: 21 | prefix: "Dependency" 22 | include: "scope" 23 | -------------------------------------------------------------------------------- /.github/workflows/deploy-dev.yml: -------------------------------------------------------------------------------- 1 | name: Maven Deploy (Dev) 2 | 3 | on: 4 | push: 5 | branches: 6 | - 'main' # Build the latest develop-SNAPSHOT 7 | paths: 8 | - 'project/**/src/**' 9 | - 'project/**/pom.xml' 10 | 11 | # Allows you to run this workflow manually from the Actions tab 12 | workflow_dispatch: 13 | 14 | jobs: 15 | publish: 16 | runs-on: ubuntu-latest 17 | steps: 18 | - uses: actions/checkout@v3.0.2 19 | 20 | - uses: actions/setup-java@v3 21 | with: 22 | java-version: 17 23 | distribution: 'temurin' 24 | 25 | - name: maven-settings-xml-action 26 | uses: whelk-io/maven-settings-xml-action@v20 27 | with: 28 | servers: '[{ "id": "github", "username": "x-access-token", "password": "${{ secrets.GITHUB_TOKEN }}" }]' 29 | 30 | - name: Verify with Maven 31 | run: cd project && mvn -B verify -Pbuild 32 | 33 | - name: Publish Package 34 | run: cd project && mvn -B deploy -Pbuild 35 | -------------------------------------------------------------------------------- /.github/workflows/deploy-pages.yml: -------------------------------------------------------------------------------- 1 | name: GH Pages Deploy (Dev) 2 | 3 | on: 4 | push: 5 | branches: 6 | - 'main' # Build the latest develop-SNAPSHOT 7 | paths: 8 | - 'project/**/src/**' 9 | - 'project/**/pom.xml' 10 | 11 | # Allows you to run this workflow manually from the Actions tab 12 | workflow_dispatch: 13 | 14 | jobs: 15 | publish: 16 | runs-on: ubuntu-latest 17 | steps: 18 | - uses: actions/checkout@v3.0.2 19 | 20 | - uses: actions/setup-java@v3 21 | with: 22 | java-version: 17 23 | distribution: 'temurin' 24 | 25 | - name: maven-settings-xml-action 26 | uses: whelk-io/maven-settings-xml-action@v20 27 | with: 28 | servers: '[{ "id": "github", "username": "x-access-token", "password": "${{ secrets.GITHUB_TOKEN }}" }]' 29 | 30 | - name: Build and Install Locally 31 | run: cd project && mvn -B install -Pbuild 32 | 33 | - name: Build Pages 34 | run: cd project && mvn -B clean javadoc:aggregate -Pjavadoc 35 | 36 | - name: Deploy 🚀 37 | uses: JamesIves/github-pages-deploy-action@v4.4.0 38 | with: 39 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 40 | BRANCH: gh-pages 41 | FOLDER: gh-pages 42 | CLEAN: true 43 | -------------------------------------------------------------------------------- /.github/workflows/deploy-prod.yml: -------------------------------------------------------------------------------- 1 | name: Maven Deploy (Prod) 2 | 3 | on: 4 | push: 5 | tags: 6 | - 'v*' # Push events to matching v*, i.e. v1.0, v20.15.10 7 | 8 | # Allows you to run this workflow manually from the Actions tab 9 | workflow_dispatch: 10 | 11 | jobs: 12 | publish: 13 | runs-on: ubuntu-latest 14 | steps: 15 | - uses: actions/checkout@v3.0.2 16 | 17 | - uses: actions/setup-java@v3 18 | with: 19 | java-version: 17 20 | distribution: 'temurin' 21 | 22 | - name: maven-settings-xml-action 23 | uses: whelk-io/maven-settings-xml-action@v20 24 | with: 25 | servers: '[{ "id": "github", "username": "x-access-token", "password": "${{ secrets.GITHUB_TOKEN }}" }]' 26 | 27 | - name: Verify with Maven 28 | run: cd project && mvn -B verify -Pbuild 29 | 30 | - name: Publish Package 31 | run: cd project && mvn -B deploy -Pbuild 32 | -------------------------------------------------------------------------------- /.github/workflows/verify.yml: -------------------------------------------------------------------------------- 1 | name: Maven Verify 2 | 3 | on: 4 | push: # Ignore releases and main dev branch 5 | tags-ignore: 6 | - 'v*' 7 | branches-ignore: 8 | - 'main' 9 | pull_request: 10 | types: [opened, synchronize, reopened] 11 | 12 | # Allows you to run this workflow manually from the Actions tab 13 | workflow_dispatch: 14 | 15 | jobs: 16 | build: 17 | 18 | runs-on: ubuntu-latest 19 | 20 | steps: 21 | - uses: actions/checkout@v3.0.2 22 | 23 | - name: Set up JDK 24 | uses: actions/setup-java@v3 25 | with: 26 | java-version: 17 27 | distribution: 'temurin' 28 | 29 | - name: Verify with Maven 30 | run: cd project && mvn -B verify -Pbuild 31 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | .metadata 3 | **/*.cfs 4 | *.classpath 5 | *.settings 6 | *.project 7 | sh.exe.stackdump 8 | stat.html 9 | *.checkstyle 10 | target* 11 | .recommenders/ 12 | project/global/docs/ 13 | project/logic/docs/ 14 | project/persistence/docs/ 15 | project/gui/docs/ 16 | project/control/docs/ 17 | project/basic/enemypack/docs/ 18 | project/basic/inanimatepack/docs/ 19 | project/game/docs/ 20 | project/basic/pickuppack/docs/ 21 | gh-pages 22 | .ucdetector_reports/ 23 | .idea/ 24 | *.iml 25 | *.jar 26 | -------------------------------------------------------------------------------- /concept/levels.md: -------------------------------------------------------------------------------- 1 | # Arcade Levels 2 | 3 | ## Pack A 4 | 5 | ### Levels 6 | 7 | 1. Easy platform jumping 8 | 2. More demanding platform jumping 9 | 3. *ToggleBoxes*, Stackers 10 | 4. *MovingBoxes*, *Stackers*, some *ToggleBoxes* 11 | 5. **Bonus Level:** Many *Coins*, *Warpers*, *FilterBoxes* 12 | 6. **Boss:** *RektSmasher* 13 | 14 | ### Enemies 15 | * RektKiller 16 | * Stacker 17 | * Warper 18 | * Slurp 19 | 20 | ### Inanimates 21 | * ToggleBox 22 | * Moving Box 23 | * Filter Box 24 | 25 | ### PickUps 26 | * Coin, SuperCoin 27 | * Life 28 | 29 | ## Pack B 30 | 31 | ### Levels 32 | 33 | 1. *Piston* 34 | 2. *AcceleratorBox* , some *Pistons* 35 | 3. *ClimbUpBox*, some *MovingBox* 36 | 4. *Cannon*, *BluePill* 37 | 5. **Bonus Level:** Many *Coins*, *ReflectionBox*, *Rockets* 38 | 6. **Boss:** *RocketBoss* 39 | 40 | ### Enemies 41 | * Rocket 42 | * Cannon 43 | * Piston 44 | 45 | ### Inanimates 46 | * MovingBox 47 | * ClimbUpBox 48 | * AcceleratorBox 49 | 50 | ### PickUps 51 | * EvilCoin 52 | * BluePill 53 | -------------------------------------------------------------------------------- /documentation/LEVEL.md: -------------------------------------------------------------------------------- 1 | # Adding Levels 2 | 3 | ## Create a Level 4 | If you want to create your own levels, follow the steps: 5 | * Create a new text-file (the name has to start with *level* and has to end with *.dat*) 6 | * Define the settings of the level. All possible settings can be found in the SettingKey-Enum. (See this [example](https://github.com/rekit-group/rekit-game/blob/master/project/basic/src/main/resources/levels/test.dat) for reference) 7 | * You can set a `#BOSS_SETTING::ATXXX->Boss` to create a Boss-Room at position `XXX` in your level (you can also specify a concrete Boss by its name) 8 | * In a further step you can create `aliases` to create `structures` easily. You can use specific Items or Groups (e.g. Coin: `#ALIAS::1->Coin`) 9 | * In a last step you can create `structures`. These structures represent pieces of the level that will be put together (either in order or randomly, depending on the shuffle setting). 10 | * Each entry in the structure represents a block or an enemy. You can use an alias or name. Depending on the element you can also provide addition information to the element by adding `:INFO1:INFO2` to the name or alias. These information will be parsed by the create method of the GameElement. 11 | 12 | ## Load Levels 13 | To load a level you have two options: 14 | * You can add the level to a Mod (jar) and add it to the subfolder `levels` (or a subfolder of `levels`). If the `group`-Setting is not set, the level will be placed in the default group. 15 | * You can add the level to the `levels`-Directory (Windows: `%APPDATA%/rekit`, Unix/Mac: `~/.config/rekit`). If you place the level into a subdirectory of the `levels`-Directory and won't set the `group`-Setting, the level will be placed into a group named like the subdirectory (this also applies if you place the level into a Mod). 16 | -------------------------------------------------------------------------------- /graphix/cannon.psd: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rekit-group/rekit-game/64d489145f811f6d2a8cdc8ba062e097f7a66c05/graphix/cannon.psd -------------------------------------------------------------------------------- /graphix/evilCoin.psd: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rekit-group/rekit-game/64d489145f811f6d2a8cdc8ba062e097f7a66c05/graphix/evilCoin.psd -------------------------------------------------------------------------------- /graphix/eye.psd: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rekit-group/rekit-game/64d489145f811f6d2a8cdc8ba062e097f7a66c05/graphix/eye.psd -------------------------------------------------------------------------------- /graphix/mainmenu.psd: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rekit-group/rekit-game/64d489145f811f6d2a8cdc8ba062e097f7a66c05/graphix/mainmenu.psd -------------------------------------------------------------------------------- /graphix/mrRekt.psd: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rekit-group/rekit-game/64d489145f811f6d2a8cdc8ba062e097f7a66c05/graphix/mrRekt.psd -------------------------------------------------------------------------------- /graphix/rekit.psd: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rekit-group/rekit-game/64d489145f811f6d2a8cdc8ba062e097f7a66c05/graphix/rekit.psd -------------------------------------------------------------------------------- /graphix/rekitScreenshotArcade.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rekit-group/rekit-game/64d489145f811f6d2a8cdc8ba062e097f7a66c05/graphix/rekitScreenshotArcade.png -------------------------------------------------------------------------------- /graphix/rekitScreenshotBossRush.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rekit-group/rekit-game/64d489145f811f6d2a8cdc8ba062e097f7a66c05/graphix/rekitScreenshotBossRush.png -------------------------------------------------------------------------------- /graphix/rekitScreenshotInfinite.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rekit-group/rekit-game/64d489145f811f6d2a8cdc8ba062e097f7a66c05/graphix/rekitScreenshotInfinite.png -------------------------------------------------------------------------------- /graphix/rekitScreenshots.psd: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rekit-group/rekit-game/64d489145f811f6d2a8cdc8ba062e097f7a66c05/graphix/rekitScreenshots.psd -------------------------------------------------------------------------------- /graphix/rektSmasher.psd: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rekit-group/rekit-game/64d489145f811f6d2a8cdc8ba062e097f7a66c05/graphix/rektSmasher.psd -------------------------------------------------------------------------------- /graphix/rektSmasher_0.psd: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rekit-group/rekit-game/64d489145f811f6d2a8cdc8ba062e097f7a66c05/graphix/rektSmasher_0.psd -------------------------------------------------------------------------------- /graphix/rektSmasher_1.psd: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rekit-group/rekit-game/64d489145f811f6d2a8cdc8ba062e097f7a66c05/graphix/rektSmasher_1.psd -------------------------------------------------------------------------------- /graphix/rektSmasher_2.psd: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rekit-group/rekit-game/64d489145f811f6d2a8cdc8ba062e097f7a66c05/graphix/rektSmasher_2.psd -------------------------------------------------------------------------------- /graphix/rektSmasher_3.psd: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rekit-group/rekit-game/64d489145f811f6d2a8cdc8ba062e097f7a66c05/graphix/rektSmasher_3.psd -------------------------------------------------------------------------------- /graphix/robot.psd: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rekit-group/rekit-game/64d489145f811f6d2a8cdc8ba062e097f7a66c05/graphix/robot.psd -------------------------------------------------------------------------------- /graphix/stackerFaces.psd: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rekit-group/rekit-game/64d489145f811f6d2a8cdc8ba062e097f7a66c05/graphix/stackerFaces.psd -------------------------------------------------------------------------------- /make.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | PWD=$(pwd) 3 | DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" 4 | if [ "$PWD" != "$DIR" ] 5 | then 6 | echo "This script does not support execution from other directories" 7 | exit 2 8 | fi 9 | 10 | cd project 11 | ./build.sh ./SingleJar.launch 12 | cp game/target/build/linux/ReKiT.jar .. 13 | cd .. 14 | -------------------------------------------------------------------------------- /project/JavaDoc.launch: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /project/MultiJar.launch: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /project/SingleJar.launch: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /project/basic/.gitignore: -------------------------------------------------------------------------------- 1 | /target/ 2 | -------------------------------------------------------------------------------- /project/basic/pom.xml: -------------------------------------------------------------------------------- 1 | 3 | 4.0.0 4 | 5 | rekit 6 | parent 7 | 1.3 8 | 9 | basic 10 | Basic Pack 11 | Contains several Entities as a base set 12 | 13 | 14 | rekit 15 | logic 16 | 17 | 18 | -------------------------------------------------------------------------------- /project/basic/src/main/java/rekit/logic/develop/TestScene.java: -------------------------------------------------------------------------------- 1 | package rekit.logic.develop; 2 | 3 | import java.io.IOException; 4 | 5 | import org.springframework.core.io.Resource; 6 | import org.springframework.core.io.support.PathMatchingResourcePatternResolver; 7 | 8 | import rekit.config.GameConf; 9 | import rekit.logic.GameModel; 10 | import rekit.logic.ILevelScene; 11 | import rekit.logic.gameelements.GameElement; 12 | import rekit.logic.gameelements.GameElementFactory; 13 | import rekit.logic.gameelements.entities.enemies.Warper; 14 | import rekit.logic.level.LevelFactory; 15 | import rekit.logic.scene.LevelScene; 16 | import rekit.persistence.level.LevelDefinition; 17 | import rekit.persistence.level.LevelType; 18 | import rekit.primitives.geometry.Vec; 19 | import rekit.util.LambdaUtil; 20 | 21 | /** 22 | * A test scene which can be used in {@link GameConf#DEBUG} context. 23 | * 24 | * @author Matthias Schmitt 25 | * 26 | */ 27 | public final class TestScene extends LevelScene { 28 | 29 | private TestScene(GameModel model) { 30 | super(model, LevelFactory.createLevel(LambdaUtil.invoke(TestScene::getTestLevel))); 31 | } 32 | 33 | private static LevelDefinition getTestLevel() throws IOException { 34 | PathMatchingResourcePatternResolver resolv = new PathMatchingResourcePatternResolver(); 35 | Resource res = resolv.getResource("/levels/test.dat"); 36 | return new LevelDefinition(res.getInputStream(), LevelType.Test); 37 | } 38 | 39 | /** 40 | * Create the scene by model and options 41 | * 42 | * @param model 43 | * the model 44 | * @param options 45 | * the options 46 | * @return the new scene 47 | */ 48 | public static ILevelScene create(GameModel model, String... options) { 49 | return new TestScene(model); 50 | } 51 | 52 | @Override 53 | public void init() { 54 | super.init(); 55 | } 56 | 57 | @Override 58 | public void start() { 59 | super.start(); 60 | GameElement warperProto = GameElementFactory.getPrototype("Warper"); 61 | Warper warper = (Warper) warperProto.create(new Vec(12, 4)); 62 | // TODO Sth more useful .. 63 | this.addGameElement(warper); 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /project/basic/src/main/java/rekit/logic/gameelements/entities/enemies/bosses/rocketboss/Brain.java: -------------------------------------------------------------------------------- 1 | package rekit.logic.gameelements.entities.enemies.bosses.rocketboss; 2 | 3 | import rekit.core.Team; 4 | import rekit.logic.gameelements.GameElement; 5 | import rekit.logic.gameelements.entities.Player; 6 | import rekit.primitives.geometry.Direction; 7 | import rekit.primitives.geometry.Vec; 8 | 9 | public class Brain extends GameElement { 10 | 11 | private Vec relPos; 12 | private RocketBoss parent; 13 | 14 | protected Brain(RocketBoss parent, Team team) { 15 | super(new Vec(), new Vec(), new Vec(), team); 16 | this.parent = parent; 17 | 18 | this.relPos = RocketBoss.BRAIN_SIZE.add(RocketBoss.HEAD_SIZE).scalar(-1 / 2f).setX(0); 19 | this.setSize(RocketBoss.BRAIN_SIZE); 20 | } 21 | 22 | @Override 23 | public void reactToCollision(GameElement element, Direction dir) { 24 | if (this.parent.getTeam().isHostile(element.getTeam())) { 25 | this.parent.addDamage(1); 26 | // Let Player collide 27 | element.collidedWithSolid(this.getFrame(), dir); 28 | 29 | // Bounce Player off 30 | element.setVel(new Vec(Player.KILL_BOOST, Player.KILL_BOOST)); 31 | 32 | if (this.parent.getLives() == 0) { 33 | element.setVel(new Vec(0, 0)); 34 | } 35 | 36 | } 37 | } 38 | 39 | @Override 40 | public void logicLoop() { 41 | this.setPos(this.parent.getPos().add(this.relPos)); 42 | } 43 | 44 | } 45 | -------------------------------------------------------------------------------- /project/basic/src/main/java/rekit/logic/gameelements/entities/enemies/bosses/rocketboss/Mouth.java: -------------------------------------------------------------------------------- 1 | package rekit.logic.gameelements.entities.enemies.bosses.rocketboss; 2 | 3 | import java.util.Iterator; 4 | import java.util.LinkedList; 5 | import java.util.List; 6 | 7 | import net.jafama.FastMath; 8 | import rekit.core.GameGrid; 9 | import rekit.primitives.geometry.Vec; 10 | import rekit.primitives.image.RGBAColor; 11 | import rekit.primitives.time.Timer; 12 | 13 | public class Mouth { 14 | 15 | private RocketBoss parent; 16 | 17 | private Vec pos; 18 | private Vec size; 19 | 20 | private Timer mouthCurveTimer = new Timer(50); 21 | private Vec mouthCurvePos; 22 | private List mouthCurve = new LinkedList<>(); 23 | 24 | public Mouth(RocketBoss parent, Vec pos, Vec size) { 25 | this.parent = parent; 26 | this.pos = pos; 27 | this.size = size; 28 | } 29 | 30 | public void logicLoop(float calcX, float deltaX) { 31 | this.mouthCurvePos = this.parent.getPos().add(this.pos).addX(0.5f * this.size.x).addX(-calcX); 32 | this.mouthCurveTimer.logicLoop(); 33 | float maxDelta = this.size.y * 0.5f * this.parent.getState().getMouthAmplitude(); 34 | while (this.mouthCurveTimer.timeUp()) { 35 | this.mouthCurveTimer.reset(); 36 | Vec newVec = new Vec(calcX, (float) (FastMath.tan(calcX * 10) * FastMath.sinQuick(calcX * 4) * FastMath.cosQuick(calcX * 0.5f) * maxDelta)); 37 | if (newVec.y > maxDelta) { 38 | newVec = newVec.setY(maxDelta); 39 | } 40 | if (newVec.y < -maxDelta) { 41 | newVec = newVec.setY(-maxDelta); 42 | } 43 | this.mouthCurve.add(newVec); 44 | } 45 | Iterator it = this.mouthCurve.iterator(); 46 | while (it.hasNext()) { 47 | if (it.next().x <= calcX - this.size.x) { 48 | it.remove(); 49 | } else { 50 | break; 51 | } 52 | } 53 | } 54 | 55 | public void internalRender(GameGrid f) { 56 | f.drawPath(this.mouthCurvePos, this.mouthCurve, new RGBAColor(0, 0, 0), true); 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /project/basic/src/main/java/rekit/logic/gameelements/entities/enemies/bosses/rocketboss/arm/RocketBossChild.java: -------------------------------------------------------------------------------- 1 | package rekit.logic.gameelements.entities.enemies.bosses.rocketboss.arm; 2 | 3 | import rekit.core.GameGrid; 4 | import rekit.logic.gameelements.entities.enemies.bosses.rocketboss.RocketBoss; 5 | import rekit.primitives.geometry.Vec; 6 | 7 | /** 8 | * Represents any visual child of the RocketBoss, whose position is relative to 9 | * a parent. 10 | * 11 | * @author Angelo Aracri 12 | */ 13 | public abstract class RocketBossChild { 14 | 15 | protected RocketBoss parent; 16 | protected Vec relPos; 17 | 18 | public RocketBossChild(RocketBoss parent, Vec relPos) { 19 | this.parent = parent; 20 | this.relPos = relPos; 21 | } 22 | 23 | public RocketBossChild() { 24 | // prototype instantiation constructor 25 | } 26 | 27 | public RocketBoss getParent() { 28 | return this.parent; 29 | } 30 | 31 | public Vec getPos() { 32 | return this.parent.getPos().add(this.relPos); 33 | } 34 | 35 | public abstract void logicLoop(float calcX, float deltaX); 36 | 37 | public abstract void internalRender(GameGrid f); 38 | 39 | public abstract RocketBossChild create(RocketBoss parent, Vec relPos); 40 | } 41 | -------------------------------------------------------------------------------- /project/basic/src/main/java/rekit/logic/gameelements/entities/enemies/bosses/rocketboss/arm/armaction/ArmActionCannon.java: -------------------------------------------------------------------------------- 1 | package rekit.logic.gameelements.entities.enemies.bosses.rocketboss.arm.armaction; 2 | 3 | import rekit.logic.gameelements.GameElement; 4 | import rekit.logic.gameelements.entities.enemies.bosses.rocketboss.RocketBoss; 5 | import rekit.logic.gameelements.entities.enemies.cannon.Cannon; 6 | import rekit.primitives.geometry.Vec; 7 | 8 | /** 9 | * This concrete {@link ArmAction} spawns and de-spawns a modified {@link Cannon}. 10 | * @author Angelo Aracri 11 | */ 12 | public class ArmActionCannon extends ArmAction { 13 | 14 | /** 15 | * Reference to the internally used {@link Cannon}. 16 | */ 17 | private GameElement innerCannon; 18 | 19 | public ArmActionCannon(RocketBoss parent, Vec relPos) { 20 | super(parent, relPos); 21 | 22 | innerCannon = new Cannon().create(this.getPos(), new String[]{}); 23 | innerCannon.setSize(innerCannon.getSize().scalar(0.7f)); 24 | this.parent.getScene().addGameElement(innerCannon); 25 | } 26 | 27 | public ArmActionCannon() { 28 | super(); 29 | } 30 | 31 | @Override 32 | public void perform() { 33 | // Do nothing here, as the Cannon acts on its own. 34 | } 35 | 36 | @Override 37 | public void tearDown() { 38 | this.innerCannon.destroy(); 39 | } 40 | 41 | @Override 42 | public ArmAction create(RocketBoss parent, Vec relPos) { 43 | return new ArmActionCannon(parent, relPos); 44 | } 45 | 46 | @Override 47 | public void logicLoop(float calcX, float deltaX) { 48 | this.innerCannon.setPos(this.getPos().addY(0.4f)); 49 | } 50 | 51 | } 52 | -------------------------------------------------------------------------------- /project/basic/src/main/java/rekit/logic/gameelements/entities/enemies/bosses/rocketboss/arm/armstate/ArmActionState.java: -------------------------------------------------------------------------------- 1 | package rekit.logic.gameelements.entities.enemies.bosses.rocketboss.arm.armstate; 2 | 3 | import rekit.logic.gameelements.entities.enemies.bosses.rocketboss.RocketBoss; 4 | import rekit.logic.gameelements.entities.enemies.bosses.rocketboss.arm.Arm; 5 | import rekit.util.state.State; 6 | import rekit.util.state.TimeStateMachine; 7 | 8 | public class ArmActionState extends ArmState { 9 | 10 | private boolean hasPerformedAction = false; 11 | 12 | public ArmActionState(Arm parentArm) { 13 | super(parentArm); 14 | } 15 | 16 | @Override 17 | public void enter(TimeStateMachine parent) { 18 | super.enter(parent); 19 | this.getParentArm().nextArmAction(); 20 | } 21 | 22 | @Override 23 | public void leave() { 24 | this.getParentArm().armAction.tearDown(); 25 | } 26 | 27 | protected void internalLogicLoop() { 28 | if (!hasPerformedAction && timer.getProgress() >= getParentArm().getActionProgressThreshold()) { 29 | this.getParentArm().armAction.perform(); 30 | this.hasPerformedAction = true; 31 | } 32 | } 33 | 34 | protected void internalRender() { 35 | 36 | } 37 | 38 | @Override 39 | public State getNextState() { 40 | return new ArmUnbuildState(getParentArm()); 41 | } 42 | 43 | @Override 44 | public long getTimerTime() { 45 | return RocketBoss.ARM_STATE_TIME_ACTION; 46 | } 47 | 48 | public float getSegmentAmount() { 49 | // Return 1 for all segments 50 | return 1; 51 | } 52 | 53 | } 54 | -------------------------------------------------------------------------------- /project/basic/src/main/java/rekit/logic/gameelements/entities/enemies/bosses/rocketboss/arm/armstate/ArmBuildState.java: -------------------------------------------------------------------------------- 1 | package rekit.logic.gameelements.entities.enemies.bosses.rocketboss.arm.armstate; 2 | 3 | import rekit.logic.gameelements.entities.enemies.bosses.rocketboss.RocketBoss; 4 | import rekit.logic.gameelements.entities.enemies.bosses.rocketboss.arm.Arm; 5 | import rekit.util.state.State; 6 | import rekit.util.state.TimeStateMachine; 7 | 8 | public class ArmBuildState extends ArmState { 9 | 10 | public ArmBuildState(Arm parentArm) { 11 | super(parentArm); 12 | } 13 | 14 | @Override 15 | public void enter(TimeStateMachine parent) { 16 | super.enter(parent); 17 | this.getParentArm().createArmSegments(); 18 | } 19 | 20 | @Override 21 | public State getNextState() { 22 | return new ArmActionState(getParentArm()); 23 | } 24 | 25 | @Override 26 | public long getTimerTime() { 27 | return RocketBoss.ARM_STATE_TIME_BUILD; 28 | } 29 | 30 | public float getSegmentAmount() { 31 | return this.timer.getProgress(); 32 | } 33 | 34 | } 35 | -------------------------------------------------------------------------------- /project/basic/src/main/java/rekit/logic/gameelements/entities/enemies/bosses/rocketboss/arm/armstate/ArmIdleState.java: -------------------------------------------------------------------------------- 1 | package rekit.logic.gameelements.entities.enemies.bosses.rocketboss.arm.armstate; 2 | 3 | import rekit.logic.gameelements.entities.enemies.bosses.rocketboss.RocketBoss; 4 | import rekit.logic.gameelements.entities.enemies.bosses.rocketboss.arm.Arm; 5 | import rekit.util.state.State; 6 | import rekit.util.state.TimeStateMachine; 7 | 8 | public class ArmIdleState extends ArmState { 9 | 10 | public ArmIdleState(Arm parentArm) { 11 | super(parentArm); 12 | } 13 | 14 | @Override 15 | public State getNextState() { 16 | return new ArmBuildState(getParentArm()); 17 | } 18 | 19 | @Override 20 | public void enter(TimeStateMachine parent) { 21 | super.enter(parent); 22 | this.getParentArm().getParent().moveToNextPosition(); 23 | } 24 | 25 | @Override 26 | public long getTimerTime() { 27 | return RocketBoss.ARM_STATE_TIME_IDLE; 28 | } 29 | 30 | public float getSegmentAmount() { 31 | return 0; 32 | } 33 | 34 | } 35 | -------------------------------------------------------------------------------- /project/basic/src/main/java/rekit/logic/gameelements/entities/enemies/bosses/rocketboss/arm/armstate/ArmState.java: -------------------------------------------------------------------------------- 1 | package rekit.logic.gameelements.entities.enemies.bosses.rocketboss.arm.armstate; 2 | 3 | import rekit.logic.gameelements.entities.enemies.bosses.rocketboss.arm.Arm; 4 | import rekit.util.state.State; 5 | 6 | public abstract class ArmState extends State { 7 | private Arm parentArm; 8 | 9 | public ArmState(Arm parentArm) { 10 | super(); 11 | 12 | this.parentArm = parentArm; 13 | } 14 | 15 | public Arm getParentArm() { 16 | return this.parentArm; 17 | } 18 | 19 | public float getSegmentAmount() { 20 | return 1; 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /project/basic/src/main/java/rekit/logic/gameelements/entities/enemies/bosses/rocketboss/arm/armstate/ArmUnbuildState.java: -------------------------------------------------------------------------------- 1 | package rekit.logic.gameelements.entities.enemies.bosses.rocketboss.arm.armstate; 2 | 3 | import rekit.logic.gameelements.entities.enemies.bosses.rocketboss.RocketBoss; 4 | import rekit.logic.gameelements.entities.enemies.bosses.rocketboss.arm.Arm; 5 | import rekit.util.state.State; 6 | 7 | public class ArmUnbuildState extends ArmState { 8 | 9 | public ArmUnbuildState(Arm parentArm) { 10 | super(parentArm); 11 | } 12 | 13 | @Override 14 | public State getNextState() { 15 | return new ArmIdleState(getParentArm()); 16 | } 17 | 18 | @Override 19 | public long getTimerTime() { 20 | return RocketBoss.ARM_STATE_TIME_UNBUILD; 21 | } 22 | 23 | public float getSegmentAmount() { 24 | return 1 - this.timer.getProgress(); 25 | } 26 | 27 | } 28 | -------------------------------------------------------------------------------- /project/basic/src/main/java/rekit/logic/gameelements/entities/enemies/bosses/rocketboss/damagestate/DamageState.java: -------------------------------------------------------------------------------- 1 | package rekit.logic.gameelements.entities.enemies.bosses.rocketboss.damagestate; 2 | 3 | import rekit.logic.gameelements.entities.enemies.bosses.rocketboss.RocketBoss; 4 | import rekit.util.state.State; 5 | 6 | public abstract class DamageState extends State { 7 | 8 | /** 9 | * Reference to the parenting {@link RocketBoss}. 10 | */ 11 | protected RocketBoss parentBoss; 12 | 13 | public void enter(RocketBoss parent) { 14 | super.enter(parent.getMachine()); 15 | this.parentBoss = parent; 16 | } 17 | 18 | public void addDamage(int points) { 19 | this.parent.nextState(); 20 | } 21 | 22 | @Override 23 | public void logicLoop() { 24 | // Do nothing to remove time-dependent functionality 25 | } 26 | 27 | @Override 28 | public abstract DamageState getNextState(); 29 | 30 | @Override 31 | public long getTimerTime() { 32 | // Not required, since time-functionality disabled 33 | return 0; 34 | } 35 | 36 | /** 37 | * Getter for a multiplier that will be used to increase the 38 | * {@link RocketBoss RocketBosses} movement speed, the mouth movement, and 39 | * the delta between arm-actions. 40 | * 41 | * @return the factor for the {@link RocketBoss RocketBosses} time 42 | */ 43 | public abstract float getTimeFactor(); 44 | 45 | public abstract float getMouthAmplitude(); 46 | 47 | /** 48 | * Getter for the source path of the image for the boss. 49 | * 50 | * @return the source path of the {@link RocketBoss RocketBosses} image. 51 | */ 52 | public abstract String getHeadImgSrc(); 53 | 54 | } 55 | -------------------------------------------------------------------------------- /project/basic/src/main/java/rekit/logic/gameelements/entities/enemies/bosses/rocketboss/damagestate/State0.java: -------------------------------------------------------------------------------- 1 | package rekit.logic.gameelements.entities.enemies.bosses.rocketboss.damagestate; 2 | 3 | public class State0 extends DamageState { 4 | 5 | @Override 6 | public DamageState getNextState() { 7 | return new State0(); 8 | } 9 | 10 | @Override 11 | public float getTimeFactor() { 12 | return 0.4f; 13 | } 14 | 15 | @Override 16 | public String getHeadImgSrc() { 17 | return "rocketBoss/head_0.png"; 18 | } 19 | 20 | @Override 21 | public float getMouthAmplitude() { 22 | return 0.1f; 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /project/basic/src/main/java/rekit/logic/gameelements/entities/enemies/bosses/rocketboss/damagestate/State1.java: -------------------------------------------------------------------------------- 1 | package rekit.logic.gameelements.entities.enemies.bosses.rocketboss.damagestate; 2 | 3 | public class State1 extends DamageState { 4 | 5 | @Override 6 | public DamageState getNextState() { 7 | return new State0(); 8 | } 9 | 10 | @Override 11 | public float getTimeFactor() { 12 | return 3; 13 | } 14 | 15 | @Override 16 | public String getHeadImgSrc() { 17 | return "rocketBoss/head_1.png"; 18 | } 19 | 20 | @Override 21 | public float getMouthAmplitude() { 22 | return 1.2f; 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /project/basic/src/main/java/rekit/logic/gameelements/entities/enemies/bosses/rocketboss/damagestate/State2.java: -------------------------------------------------------------------------------- 1 | package rekit.logic.gameelements.entities.enemies.bosses.rocketboss.damagestate; 2 | 3 | public class State2 extends DamageState { 4 | 5 | @Override 6 | public DamageState getNextState() { 7 | return new State1(); 8 | } 9 | 10 | @Override 11 | public float getTimeFactor() { 12 | return 2; 13 | } 14 | 15 | @Override 16 | public String getHeadImgSrc() { 17 | return "rocketBoss/head_2.png"; 18 | } 19 | 20 | @Override 21 | public float getMouthAmplitude() { 22 | return 1.1f; 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /project/basic/src/main/java/rekit/logic/gameelements/entities/enemies/bosses/rocketboss/damagestate/State3.java: -------------------------------------------------------------------------------- 1 | package rekit.logic.gameelements.entities.enemies.bosses.rocketboss.damagestate; 2 | 3 | public class State3 extends DamageState { 4 | 5 | @Override 6 | public DamageState getNextState() { 7 | return new State2(); 8 | } 9 | 10 | @Override 11 | public float getTimeFactor() { 12 | return 1; 13 | } 14 | 15 | @Override 16 | public String getHeadImgSrc() { 17 | return "rocketBoss/head_3.png"; 18 | } 19 | 20 | @Override 21 | public float getMouthAmplitude() { 22 | return 1; 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /project/basic/src/main/java/rekit/logic/gameelements/entities/enemies/cannon/CannonParticle.java: -------------------------------------------------------------------------------- 1 | package rekit.logic.gameelements.entities.enemies.cannon; 2 | 3 | import rekit.logic.gameelements.entities.Player; 4 | import rekit.logic.gameelements.inanimate.Inanimate; 5 | import rekit.logic.gameelements.particles.DamageParticle; 6 | import rekit.logic.gameelements.particles.Particle; 7 | import rekit.primitives.geometry.Direction; 8 | import rekit.primitives.geometry.Frame; 9 | 10 | /** 11 | * {@link Particle} that extends {@link DamageParticle} that is extended by 12 | * calling a {@link Cannon Cannons} method {@link Cannon#hitSomething()} upon 13 | * colliding with an {@link Inanimate} or {@link Player}. 14 | * 15 | * @author Angelo Aracri 16 | */ 17 | public final class CannonParticle extends DamageParticle { 18 | 19 | /** 20 | * The parenting {@link Cannon} whose {@link Cannon#hitSomething()} will be 21 | * called upon a collision with an {@link Inanimate} or {@link Player}. 22 | */ 23 | private Cannon parent; 24 | 25 | /** 26 | * Constructor that saves the reference of the given parenting 27 | * {@link Cannon} whose {@link Cannon#hitSomething()} will be called upon a 28 | * collision with an {@link Inanimate} or {@link Player}. 29 | * 30 | * @param parent 31 | * the parenting {@link Cannon} to message. 32 | */ 33 | public CannonParticle(Cannon parent) { 34 | super(); 35 | this.parent = parent; 36 | } 37 | 38 | @Override 39 | public DamageParticle create() { 40 | return new CannonParticle(this.parent); 41 | } 42 | 43 | @Override 44 | public void collidedWithSolid(Frame collision, Direction dir) { 45 | this.parent.hitSomething(); 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /project/basic/src/main/java/rekit/logic/gameelements/entities/enemies/cannon/CannonStateMachine.java: -------------------------------------------------------------------------------- 1 | package rekit.logic.gameelements.entities.enemies.cannon; 2 | 3 | import rekit.logic.gameelements.entities.enemies.cannon.state.CannonState; 4 | import rekit.util.state.TimeStateMachine; 5 | 6 | /** 7 | *

8 | * Extension of {@link TimeStateMachine} that is specifically used for 9 | * {@link Cannon Cannons}. 10 | *

11 | * Different from the regular {@link TimeStateMachine} as it saves the reference 12 | * to a {@link Cannon} supplied in the constructor and only accepts and returns 13 | * specialized {@link CannonState CannonStates}. 14 | * 15 | * @author Angelo Aracri 16 | */ 17 | public class CannonStateMachine extends TimeStateMachine { 18 | 19 | /** 20 | * Reference to a parenting {@link Cannon}. 21 | */ 22 | protected Cannon parentCannon; 23 | 24 | /** 25 | * Constructor that extends the {@link TimeStateMachine TimeStateMachines} 26 | * {@link TimeStateMachine#TimeStateMachine(rekit.util.state.State) 27 | * constructor} by also saving the reference to a given parenting 28 | * {@link Cannon}. 29 | * 30 | * @param parentCannon 31 | * the parenting {@link Cannon}. 32 | * @param initialState 33 | * the initial {@link CannonState}. 34 | */ 35 | public CannonStateMachine(Cannon parentCannon, CannonState initialState) { 36 | super(initialState); 37 | 38 | // set reference to Cannon 39 | initialState.setCannon(parentCannon); 40 | this.parentCannon = parentCannon; 41 | } 42 | 43 | @Override 44 | public void nextState() { 45 | // get next State defined by current state 46 | CannonState nextState = (CannonState) this.currentState.getNextState(); 47 | 48 | // set reference to Cannon 49 | nextState.setCannon(this.parentCannon); 50 | 51 | // call States protected nextState with the modified CannonState 52 | this.nextState(nextState); 53 | } 54 | 55 | @Override 56 | public CannonState getState() { 57 | return (CannonState) this.currentState; 58 | } 59 | 60 | } 61 | -------------------------------------------------------------------------------- /project/basic/src/main/java/rekit/logic/gameelements/entities/enemies/cannon/state/AimingState.java: -------------------------------------------------------------------------------- 1 | package rekit.logic.gameelements.entities.enemies.cannon.state; 2 | 3 | import rekit.logic.gameelements.GameElement; 4 | import rekit.logic.gameelements.entities.Player; 5 | import rekit.logic.gameelements.entities.enemies.cannon.Cannon; 6 | import rekit.util.state.State; 7 | 8 | /** 9 | * Second {@link CannonState} of the {@link State} that represents the phase 10 | * where the {@link Cannon} aims at the {@link Player} and follows his 11 | * movements. 12 | * 13 | * @author Angelo Aracri 14 | */ 15 | public class AimingState extends CannonState { 16 | 17 | /** 18 | * The {@link Player} to aim at. 19 | */ 20 | private GameElement target; 21 | 22 | /** 23 | * Specialized constructor that stores the reference to the {@link Player} 24 | * to aim at. 25 | * 26 | * @param target 27 | * the {@link Player} to aim at. 28 | */ 29 | public AimingState(GameElement target) { 30 | super(); 31 | this.target = target; 32 | } 33 | 34 | @Override 35 | public float getTargetAngle() { 36 | return this.parentCannon.getPos().getAngleTo(this.target.getPos()); 37 | } 38 | 39 | @Override 40 | public CannonState getNextState() { 41 | return new ChargingState(this.parentCannon.getCurrentAngle()); 42 | } 43 | 44 | @Override 45 | public long getTimerTime() { 46 | return (long) (1000 * Cannon.STATE_AIMING_DURATION); 47 | } 48 | 49 | } 50 | -------------------------------------------------------------------------------- /project/basic/src/main/java/rekit/logic/gameelements/entities/enemies/cannon/state/CannonState.java: -------------------------------------------------------------------------------- 1 | package rekit.logic.gameelements.entities.enemies.cannon.state; 2 | 3 | import rekit.logic.gameelements.entities.Player; 4 | import rekit.logic.gameelements.entities.enemies.cannon.Cannon; 5 | import rekit.logic.gameelements.entities.enemies.cannon.CannonParticle; 6 | import rekit.logic.gameelements.inanimate.Inanimate; 7 | import rekit.util.state.State; 8 | 9 | /** 10 | * Abstract extension of {@link State} that adds functionality specific to the 11 | * {@link Cannon}. Each state is supposed to represent a phase of the 12 | * {@link Cannon Cannons} cycle. 13 | * 14 | * @author Angelo Aracri. 15 | */ 16 | public abstract class CannonState extends State { 17 | 18 | /** 19 | * The parenting {@link Cannon}. 20 | */ 21 | protected Cannon parentCannon; 22 | 23 | /** 24 | * Setter for the stored reference to the parenting {@link Cannon}. 25 | * 26 | * @param parentCannon 27 | * the parenting {@link Cannon} to set. 28 | */ 29 | public void setCannon(Cannon parentCannon) { 30 | this.parentCannon = parentCannon; 31 | } 32 | 33 | /** 34 | * Template method that can be filled by concrete implementations to return 35 | * a custom angle in radians, the {@link Cannon} will aim at. 36 | * 37 | * @return the angle in radians, the {@link Cannon} will aim to. 38 | */ 39 | public float getTargetAngle() { 40 | // default: return DOWN 41 | return 0; 42 | } 43 | 44 | /** 45 | * Template method that can be filled by concrete implementations to return 46 | * a custom delta in x-direction, that will be applied to the {@link Cannon 47 | * Cannons} position to simulate a shaking effect. 48 | * 49 | * @return the x-delta for the {@link Cannon} shaking effect. 50 | */ 51 | public float getCannonShake() { 52 | // default: no shaking 53 | return 0; 54 | } 55 | 56 | /** 57 | *

58 | * Template method that can be filled by concrete implementations to perform 59 | * custom actions when a {@link CannonParticle} collided with an 60 | * {@link Inanimate} or a {@link Player}. 61 | *

62 | *

63 | * Is only used by {@link ShootingState}. 64 | *

65 | */ 66 | public void hitSomething() { 67 | // Do nothing 68 | } 69 | 70 | } 71 | -------------------------------------------------------------------------------- /project/basic/src/main/java/rekit/logic/gameelements/entities/enemies/cannon/state/ChargingState.java: -------------------------------------------------------------------------------- 1 | package rekit.logic.gameelements.entities.enemies.cannon.state; 2 | 3 | import rekit.config.GameConf; 4 | import rekit.logic.gameelements.entities.enemies.cannon.Cannon; 5 | import rekit.util.state.State; 6 | 7 | /** 8 | * Third {@link CannonState} of the {@link State} that represents the phase 9 | * where the {@link Cannon} is about to shoot but does not re-aim. Additionally, 10 | * a shaking effect starts to increase to create a tense feeling ;) 11 | * 12 | * @author Angelo Aracri 13 | */ 14 | public class ChargingState extends CannonState { 15 | 16 | /** 17 | * Current angle, the {@link Cannon} is supposed to be aiming at. 18 | */ 19 | protected float angle; 20 | 21 | /** 22 | * Current x-delta that will be used on the {@link Cannon Cannons} position 23 | * to simulate a shaking effect. 24 | */ 25 | private float currentShake; 26 | 27 | /** 28 | * Constructor that saves the angle in radians to aim at throughout this 29 | * whole {@link State}. 30 | * 31 | * @param angle 32 | * the angle 33 | */ 34 | public ChargingState(float angle) { 35 | super(); 36 | this.angle = angle; 37 | } 38 | 39 | @Override 40 | public CannonState getNextState() { 41 | return new ShootingState(this.getTargetAngle()); 42 | } 43 | 44 | @Override 45 | public float getTargetAngle() { 46 | return this.angle; 47 | } 48 | 49 | @Override 50 | public final float getCannonShake() { 51 | return this.currentShake; 52 | } 53 | 54 | /** 55 | * Method whose return value will be multiplied to the shaking effects 56 | * x-delta to effectively control its strength. The value should be between 57 | * 0 and 1. 58 | * 59 | * @return the value to control the strength of the {@link Cannon Cannons} 60 | *  shaking effect. 61 | */ 62 | public float shakeStrength() { 63 | return this.timer.getProgress(); 64 | } 65 | 66 | @Override 67 | public void logicLoop() { 68 | super.logicLoop(); 69 | this.currentShake = Cannon.MAX_SHAKING * (2 * GameConf.PRNG.nextFloat() - 1) * this.shakeStrength(); 70 | 71 | } 72 | 73 | @Override 74 | public long getTimerTime() { 75 | return (long) (1000 * Cannon.STATE_CHARGING_DURATION); 76 | } 77 | } 78 | -------------------------------------------------------------------------------- /project/basic/src/main/java/rekit/logic/gameelements/entities/enemies/cannon/state/IdleState.java: -------------------------------------------------------------------------------- 1 | package rekit.logic.gameelements.entities.enemies.cannon.state; 2 | 3 | import rekit.logic.gameelements.entities.enemies.cannon.Cannon; 4 | import rekit.util.state.State; 5 | 6 | /** 7 | * First {@link CannonState} of the {@link State} that represents the phase 8 | * where the {@link Cannon} lazily aims downwards and does nothing. 9 | * 10 | * @author Angelo Aracri 11 | */ 12 | public class IdleState extends CannonState { 13 | /** 14 | * Create IdleState. 15 | */ 16 | public IdleState() { 17 | super(); 18 | } 19 | 20 | @Override 21 | public CannonState getNextState() { 22 | return new AimingState(this.parentCannon.getScene().getPlayer()); 23 | } 24 | 25 | @Override 26 | public long getTimerTime() { 27 | return (long) (1000 * Cannon.STATE_IDLE_DURATION); 28 | } 29 | 30 | } 31 | -------------------------------------------------------------------------------- /project/basic/src/main/java/rekit/logic/gameelements/entities/enemies/piston/IPistonForState.java: -------------------------------------------------------------------------------- 1 | package rekit.logic.gameelements.entities.enemies.piston; 2 | 3 | import rekit.logic.gameelements.entities.enemies.piston.state.PistonState; 4 | 5 | /** 6 | * The interface that a {@link PistonState} can see of a {@link Piston} 7 | * 8 | * @author Angelo Aracri 9 | */ 10 | public interface IPistonForState { 11 | 12 | /** 13 | * Get the time in milliseconds how low to keep the piston open. 14 | * 15 | * @return the time in milliseconds 16 | */ 17 | long getCalcTimeOpen(); 18 | 19 | /** 20 | * Get the time in milliseconds how low to keep the piston closed. 21 | * 22 | * @return the time in milliseconds 23 | */ 24 | long getCalcTimeClosed(); 25 | 26 | /** 27 | * Get the time in milliseconds how low to keep the piston opening and 28 | * closing. 29 | * 30 | * @return the time in milliseconds 31 | */ 32 | long getCalcTimeTransistion(); 33 | } 34 | -------------------------------------------------------------------------------- /project/basic/src/main/java/rekit/logic/gameelements/entities/enemies/piston/state/ClosedState.java: -------------------------------------------------------------------------------- 1 | package rekit.logic.gameelements.entities.enemies.piston.state; 2 | 3 | import rekit.logic.gameelements.entities.enemies.piston.IPistonForState; 4 | import rekit.util.state.State; 5 | 6 | /** 7 | * 8 | * The closed state of a piston. 9 | * 10 | */ 11 | public class ClosedState extends PistonState { 12 | /** 13 | * Create closed state by piston 14 | * 15 | * @param piston 16 | * the piston 17 | */ 18 | public ClosedState(IPistonForState piston) { 19 | super(piston); 20 | } 21 | 22 | @Override 23 | public float getCurrentHeight() { 24 | return 1; 25 | } 26 | 27 | @Override 28 | public State getNextState() { 29 | return new OpeningState(this.piston); 30 | } 31 | 32 | @Override 33 | public long getTimerTime() { 34 | // if the reference to piston has not been set yet 35 | if (this.piston == null) { 36 | return 0; 37 | } 38 | return this.piston.getCalcTimeClosed(); 39 | } 40 | 41 | } 42 | -------------------------------------------------------------------------------- /project/basic/src/main/java/rekit/logic/gameelements/entities/enemies/piston/state/ClosingState.java: -------------------------------------------------------------------------------- 1 | package rekit.logic.gameelements.entities.enemies.piston.state; 2 | 3 | import rekit.logic.gameelements.entities.enemies.piston.IPistonForState; 4 | import rekit.util.state.State; 5 | 6 | /** 7 | * 8 | * The closing state of a piston. 9 | * 10 | */ 11 | public class ClosingState extends PistonState { 12 | private float currentHeight; 13 | 14 | /** 15 | * Create closing state by piston 16 | * 17 | * @param piston 18 | * the piston 19 | */ 20 | public ClosingState(IPistonForState piston) { 21 | super(piston); 22 | } 23 | 24 | @Override 25 | public void internalLogicLoop() { 26 | this.currentHeight = this.timer.getProgress(); 27 | } 28 | 29 | @Override 30 | public float getCurrentHeight() { 31 | return this.currentHeight; 32 | } 33 | 34 | @Override 35 | public State getNextState() { 36 | return new ClosedState(this.piston); 37 | } 38 | 39 | @Override 40 | public long getTimerTime() { 41 | // if the reference to piston has not been set yet 42 | if (this.piston == null) { 43 | return 0; 44 | } 45 | return this.piston.getCalcTimeTransistion(); 46 | } 47 | 48 | } 49 | -------------------------------------------------------------------------------- /project/basic/src/main/java/rekit/logic/gameelements/entities/enemies/piston/state/OpenState.java: -------------------------------------------------------------------------------- 1 | package rekit.logic.gameelements.entities.enemies.piston.state; 2 | 3 | import rekit.logic.gameelements.entities.enemies.piston.IPistonForState; 4 | import rekit.util.state.State; 5 | 6 | /** 7 | * 8 | * The open state of a piston. 9 | * 10 | */ 11 | public class OpenState extends PistonState { 12 | /** 13 | * Create open state by piston 14 | * 15 | * @param piston 16 | * the piston 17 | */ 18 | public OpenState(IPistonForState piston) { 19 | super(piston); 20 | } 21 | 22 | @Override 23 | public float getCurrentHeight() { 24 | return 0; 25 | } 26 | 27 | @Override 28 | public State getNextState() { 29 | return new ClosingState(this.piston); 30 | } 31 | 32 | @Override 33 | public long getTimerTime() { 34 | // if the reference to piston has not been set yet 35 | if (this.piston == null) { 36 | return 0; 37 | } 38 | return this.piston.getCalcTimeOpen(); 39 | } 40 | 41 | } 42 | -------------------------------------------------------------------------------- /project/basic/src/main/java/rekit/logic/gameelements/entities/enemies/piston/state/OpeningState.java: -------------------------------------------------------------------------------- 1 | package rekit.logic.gameelements.entities.enemies.piston.state; 2 | 3 | import rekit.logic.gameelements.entities.enemies.piston.IPistonForState; 4 | import rekit.util.state.State; 5 | 6 | /** 7 | * 8 | * The opening state of a piston. 9 | * 10 | */ 11 | public class OpeningState extends PistonState { 12 | 13 | private float currentHeight; 14 | 15 | /** 16 | * Create opening state by piston 17 | * 18 | * @param piston 19 | * the piston 20 | */ 21 | public OpeningState(IPistonForState piston) { 22 | super(piston); 23 | } 24 | 25 | @Override 26 | public void internalLogicLoop() { 27 | this.currentHeight = 1 - this.timer.getProgress(); 28 | } 29 | 30 | @Override 31 | public float getCurrentHeight() { 32 | return this.currentHeight; 33 | } 34 | 35 | @Override 36 | public State getNextState() { 37 | return new OpenState(this.piston); 38 | } 39 | 40 | @Override 41 | public long getTimerTime() { 42 | // if the reference to piston has not been set yet 43 | if (this.piston == null) { 44 | return 0; 45 | } 46 | return this.piston.getCalcTimeTransistion(); 47 | } 48 | 49 | } 50 | -------------------------------------------------------------------------------- /project/basic/src/main/java/rekit/logic/gameelements/entities/enemies/piston/state/PistonState.java: -------------------------------------------------------------------------------- 1 | package rekit.logic.gameelements.entities.enemies.piston.state; 2 | 3 | import rekit.logic.gameelements.entities.enemies.piston.IPistonForState; 4 | import rekit.primitives.time.Timer; 5 | import rekit.util.state.State; 6 | 7 | /** 8 | * Encapsules all timing and phase-depending information in a timeable State. 9 | * See {@link PistonState#getCurrentHeight()} for the actual intrinsic value. 10 | * 11 | * @author Angelo Aracri 12 | */ 13 | public abstract class PistonState extends State { 14 | 15 | protected final IPistonForState piston; 16 | 17 | /** 18 | * Create PistonState by Piston 19 | * 20 | * @param piston 21 | * the piston 22 | */ 23 | public PistonState(IPistonForState piston) { 24 | this.piston = piston; 25 | this.timer = new Timer(this.getTimerTime()); 26 | } 27 | 28 | /** 29 | * The intrinsic state of the State, the current height of the piston 30 | * between 0 and 1. 31 | * 32 | * @return the height of the piston in 0 to 1. 33 | */ 34 | public abstract float getCurrentHeight(); 35 | 36 | } 37 | -------------------------------------------------------------------------------- /project/basic/src/main/java/rekit/logic/gameelements/entities/enemies/slurp/SlurpDurpVisComp.java: -------------------------------------------------------------------------------- 1 | package rekit.logic.gameelements.entities.enemies.slurp; 2 | 3 | import rekit.core.GameGrid; 4 | import rekit.primitives.geometry.Vec; 5 | import rekit.primitives.image.RGBAColor; 6 | 7 | /** 8 | * Simple data-holding class that represents a component of the visualization of 9 | * a SlurpDurp (Thus, the name). 10 | * 11 | * @author Angelo Aracri 12 | */ 13 | public final class SlurpDurpVisComp { 14 | /** 15 | * The relative position. 16 | */ 17 | private Vec relativePos; 18 | /** 19 | * The relative size. 20 | */ 21 | private Vec relativeSize; 22 | /** 23 | * The color. 24 | */ 25 | private RGBAColor col; 26 | 27 | /** 28 | * Create a component. 29 | * 30 | * @param relativePos 31 | * the relative position 32 | * @param relativeSize 33 | * the relative size 34 | * @param col 35 | * the color 36 | */ 37 | public SlurpDurpVisComp(Vec relativePos, Vec relativeSize, RGBAColor col) { 38 | this.relativePos = relativePos; 39 | this.relativeSize = relativeSize; 40 | this.col = col; 41 | } 42 | 43 | /** 44 | * Render component. 45 | * 46 | * @param f 47 | * the field 48 | * @param pos 49 | * the parent position 50 | * @param size 51 | * the parent size 52 | */ 53 | public void render(GameGrid f, Vec pos, Vec size) { 54 | Vec absSize = size.multiply(this.relativeSize); 55 | f.drawCircle(pos.add(this.relativePos.multiply(absSize)), absSize, this.col); 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /project/basic/src/main/java/rekit/logic/gameelements/entities/pickups/EvilCoin.java: -------------------------------------------------------------------------------- 1 | package rekit.logic.gameelements.entities.pickups; 2 | 3 | import rekit.core.GameGrid; 4 | import rekit.logic.gameelements.type.Coin; 5 | import rekit.logic.gameelements.type.Pickup; 6 | import rekit.primitives.geometry.Vec; 7 | import rekit.primitives.image.RGBAColor; 8 | import rekit.util.ReflectUtils.LoadMe; 9 | 10 | /** 11 | * This class defines a simple {@link Pickup}; an EvilCoin which will 12 | * give the player negative points. 13 | * 14 | * @author Dominik Fuchss 15 | * @author Angelo Aracri 16 | * 17 | */ 18 | @LoadMe 19 | public final class EvilCoin extends Coin { 20 | 21 | /** 22 | * Prototype constructor. 23 | */ 24 | public EvilCoin() { 25 | super(); 26 | } 27 | 28 | /** 29 | * Constructor with position. 30 | * 31 | * @param startPos 32 | * the position. 33 | */ 34 | protected EvilCoin(Vec startPos) { 35 | super(startPos); 36 | } 37 | 38 | @Override 39 | protected RGBAColor getColor() { 40 | return null; 41 | } 42 | 43 | @Override 44 | protected RGBAColor getDarkerColor() { 45 | return null; 46 | } 47 | 48 | @Override 49 | public void internalRender(GameGrid f) { 50 | f.drawImage(this.getPos().addY((float) (Coin.SIN * 0.1)), new Vec(1, 1), "evilCoin.png"); 51 | } 52 | 53 | @Override 54 | public EvilCoin create(Vec startPos, String... options) { 55 | return new EvilCoin(startPos); 56 | } 57 | 58 | @Override 59 | protected int getValue() { 60 | return -30; 61 | } 62 | 63 | } 64 | -------------------------------------------------------------------------------- /project/basic/src/main/java/rekit/logic/gameelements/entities/pickups/SuperCoin.java: -------------------------------------------------------------------------------- 1 | package rekit.logic.gameelements.entities.pickups; 2 | 3 | import rekit.logic.gameelements.type.Coin; 4 | import rekit.logic.gameelements.type.Pickup; 5 | import rekit.primitives.geometry.Vec; 6 | import rekit.primitives.image.RGBAColor; 7 | import rekit.util.ReflectUtils.LoadMe; 8 | 9 | /** 10 | * This class defines a simple {@link Pickup}; a SuperCoin which will 11 | * give the player more points than the {@link DefaultCoin} 12 | * 13 | * @author Dominik Fuchss 14 | * @author Angelo Aracri 15 | * 16 | */ 17 | @LoadMe 18 | public final class SuperCoin extends Coin { 19 | /** 20 | * The default color of the coin. 21 | */ 22 | private static RGBAColor color = new RGBAColor(252, 80, 36); 23 | /** 24 | * The shadow color of the coin. 25 | */ 26 | private static RGBAColor darkColor = new RGBAColor(212, 55, 26); 27 | 28 | /** 29 | * Prototype constructor. 30 | */ 31 | public SuperCoin() { 32 | super(); 33 | } 34 | 35 | /** 36 | * Constructor with position. 37 | * 38 | * @param startPos 39 | * the position. 40 | */ 41 | protected SuperCoin(Vec startPos) { 42 | super(startPos); 43 | } 44 | 45 | @Override 46 | protected RGBAColor getColor() { 47 | return SuperCoin.color; 48 | } 49 | 50 | @Override 51 | protected RGBAColor getDarkerColor() { 52 | return SuperCoin.darkColor; 53 | } 54 | 55 | @Override 56 | public SuperCoin create(Vec startPos, String... options) { 57 | return new SuperCoin(startPos); 58 | } 59 | 60 | @Override 61 | protected int getValue() { 62 | return 30; 63 | } 64 | 65 | } 66 | -------------------------------------------------------------------------------- /project/basic/src/main/resources/conf/acceleratorbox.properties: -------------------------------------------------------------------------------- 1 | SIZE=1.0F,1.0F 2 | 3 | COL_1=80,80,80,255 4 | COL_2=150,60,60,255 5 | COL_2_ACTIVE=190,80,80,255 6 | 7 | ANGLE_BOUND_COLOR=150,150,150,180 8 | ANGLE_CURRENT_COLOR=232,148,15,180 9 | ANGLE_LINE_WIDTH=5 10 | ANGLE_LINE_LENGTH=5 11 | 12 | ANGLE_RANGE_FACTOR=1.2F 13 | 14 | BOOST=20.0F 15 | 16 | BORDER_WIDTH=0.1F 17 | INNER_RADIUS=0.3F 18 | 19 | WARM_UP_TIME=200 20 | -------------------------------------------------------------------------------- /project/basic/src/main/resources/conf/bluepill.properties: -------------------------------------------------------------------------------- 1 | SIZE=0.3F,0.5F -------------------------------------------------------------------------------- /project/basic/src/main/resources/conf/boost.properties: -------------------------------------------------------------------------------- 1 | PERIOD=4500 2 | 3 | PARTICLES.angle=0.0F,6.28318531F,6.28318531F,12.5663706F 4 | PARTICLES.colorR=250.0F,0.0F 5 | PARTICLES.colorG=250.0F,-250.0F 6 | PARTICLES.colorB=150.0F 7 | PARTICLES.colorA=220.0F,-220.0F 8 | PARTICLES.timeMin=0.2F 9 | PARTICLES.timeMax=0.4F 10 | PARTICLES.amountMax=1 11 | PARTICLES.speed=2.0F,3.0F,-1.0F,1.0F 12 | -------------------------------------------------------------------------------- /project/basic/src/main/resources/conf/cannon.properties: -------------------------------------------------------------------------------- 1 | #### Logic Configuration 2 | # General 3 | SIZE=1.0F,1.0F 4 | 5 | # Movement 6 | ANGLE_SPEED=1.4F 7 | 8 | # State durations 9 | STATE_IDLE_DURATION=0.8f 10 | STATE_AIMING_DURATION=1.5f 11 | STATE_CHARGING_DURATION=0.2f 12 | STATE_SHOOTING_DURATION=1.5f 13 | 14 | #### Visual Configuration 15 | # Color 16 | COLOR_BASE=100,100,100 17 | COLOR_CANNON=60,60,60 18 | 19 | # Pipe relevant 20 | PIPE_W=0.3F 21 | PIPE_H=0.9F 22 | JOINT_RATIO=0.8f 23 | MAX_SHAKING=0.1f 24 | 25 | # Particle 26 | 27 | PARTICLE_AMOUNT_MIN=1 28 | PARTICLE_AMOUNT_MAX=1 29 | PARTICLE_COLOR_R=50.0F 30 | PARTICLE_COLOR_G=255.0F 31 | PARTICLE_COLOR_B=100.0F 32 | PARTICLE_COLOR_A=200.0F,-100.0F 33 | PARTICLE_SPEED=0.03F 34 | PARTICLE_TIME_MIN=1.2F 35 | PARTICLE_TIME_MAX=1.5F 36 | 37 | PARTICLE_DISTANCE_MU=0.2F 38 | PARTICLE_DISTANCE_SIGMA=0.05F -------------------------------------------------------------------------------- /project/basic/src/main/resources/conf/climbup.properties: -------------------------------------------------------------------------------- 1 | PERIOD=4000 2 | OUTER_COLOR=110,110,110,255 3 | DARK_COLOR=90,90,90,255 4 | ENERGY_COLOR=255,100,0 5 | BOOST=-16 6 | 7 | PARTICLES.angle=0.0F 8 | PARTICLES.colorR=255.0F 9 | PARTICLES.colorG=100.0F 10 | PARTICLES.colorB=0.0F 11 | PARTICLES.colorA=0.0F,220.0F 12 | PARTICLES.timeMin=0.2f 13 | PARTICLES.timeMax=0.4F 14 | PARTICLES.amountMax=1 15 | PARTICLES.size=0.3F,0.5F,0.0F,0.0F 16 | PARTICLES.speed=2.0F,3.0F,-1.0F,1.0F 17 | -------------------------------------------------------------------------------- /project/basic/src/main/resources/conf/piston.properties: -------------------------------------------------------------------------------- 1 | BASE_HEIGHT=0.2F 2 | LOWER_MARGIN=0.3F 3 | 4 | BASE_SEGMENTS=11 5 | BASE_COLOR_1=110,110,110,255 6 | BASE_COLOR_2=200,200,40,255 7 | 8 | PISTON_COLOR_1=160,160,160,255 9 | PISTON_COLOR_2=220,220,220,255 10 | 11 | OPEN_TIME=500.0F,4500.0F 12 | CLOSED_TIME=500.0F,4500.0F 13 | TRANSITION_TIME=500.0F,4500.0F 14 | 15 | NO_DAMAGE_TOLERANCE_HEIGHT=0.3F -------------------------------------------------------------------------------- /project/basic/src/main/resources/conf/rektkiller.properties: -------------------------------------------------------------------------------- 1 | POINTS=40 -------------------------------------------------------------------------------- /project/basic/src/main/resources/conf/rektsmasher.properties: -------------------------------------------------------------------------------- 1 | NAME=RektSmasher 2 | BASE_SPEED=0.5F 3 | SIZE=2.0F,2.0F 4 | LIVES=3 5 | SPIKE_TIME=5000 6 | -------------------------------------------------------------------------------- /project/basic/src/main/resources/conf/rocket.properties: -------------------------------------------------------------------------------- 1 | # Configuration of Rocket 2 | INNER_COLOR=90,90,90 3 | FRONT_COLOR=150,30,30 4 | OUTER_COLOR=50,50,50 5 | PARTICLE_SPAWN_TIME=0.05f 6 | SPEED=3.8F 7 | POINTS=40 8 | 9 | # Sparkling particles 10 | sparkParticles.colorR=200.0F,230.0F,10.0F,25.0F 11 | sparkParticles.colorG=200.0F,250.0F,-140.0F,-120.0F 12 | sparkParticles.colorB=150.0F,200.0F,-140.0F,-120.0F 13 | sparkParticles.colorA=230.0F,250.0F,-150.0F,-230.0F 14 | sparkParticles.angle=0.785398F,2.3561944F,0.0F,0.0F 15 | sparkParticles.speed=3.0F,6.0F,-1.0F,1.0F 16 | sparkParticles.amountMin=1 17 | sparkParticles.amountMax=3 18 | sparkParticles.timeMin=0.1F 19 | 20 | # Explosion particles 21 | explosionParticles.colorR=200.0F,230.0F,10.0F,25.0F 22 | explosionParticles.angle=0.0F,9.869604401F,0.0F,0.0F 23 | explosionParticles.colorG=200.0F,250.0F,-130.0F,-110.0F 24 | explosionParticles.colorB=150.0F,200.0F,-130.0F,-110.0F 25 | explosionParticles.colorA=230.0F,250.0F,-120.0F,-200.0F 26 | explosionParticles.timeMin=0.1f 27 | explosionParticles.timeMax=0.2f 28 | explosionParticles.amountMin=40 29 | explosionParticles.amountMax=50 30 | explosionParticles.speed=4.0F,9.0F,-1.0F,1.0F 31 | -------------------------------------------------------------------------------- /project/basic/src/main/resources/conf/rocketBoss.properties: -------------------------------------------------------------------------------- 1 | 2 | # Jet particles 3 | jetSparkSpawner.colorR=200.0F,230.0F,10.0F,25.0F 4 | jetSparkSpawner.colorG=200.0F,250.0F,-140.0F,-120.0F 5 | jetSparkSpawner.colorB=150.0F,200.0F,-140.0F,-120.0F 6 | jetSparkSpawner.colorA=230.0F,250.0F,-150.0F,-230.0F 7 | jetSparkSpawner.angle=2.3561944F,3.9269908F,0.0F,0.0F 8 | jetSparkSpawner.speed=3.0F,6.0F,-1.0F,1.0F 9 | jetSparkSpawner.amountMin=1 10 | jetSparkSpawner.amountMax=3 11 | jetSparkSpawner.timeMin=0.1F 12 | 13 | JET_SPARK_SPAWN_DELTA=100 14 | PARTICLE_SPAWN_POS=1.5F,0.8F 15 | MOVEMENT_PERIOD=1.6F,0.9F 16 | MOVEMENT_RANGE=0.3F,0.3F 17 | BRAIN_SIZE=1.4F,0.6F 18 | 19 | HEAD_SIZE=2.0F,1.6F 20 | 21 | MOUTH_SIZE=1.6F,0.4F 22 | MOUTH_POS=0.0F,0.4F 23 | 24 | ROCKET_LAUNCHER_SIZE=1.2F,0.6F 25 | ROCKET_LAUNCHER_SOURCE_LEFT=rocketBoss/cannon_left.png 26 | ROCKET_LAUNCHER_SOURCE_RIGHT=rocketBoss/cannon_right.png 27 | 28 | ARM_SEGMENT_SIZE=0.25F,0.25F 29 | ARM_SEGMENT_DIST=0.04F 30 | ARM_SEGMENT_COL=160,160,160 31 | ARM_SEGMENT_BORDER_COL=76,76,76 32 | 33 | ARM_STATE_TIME_IDLE=2000 34 | ARM_STATE_TIME_BUILD=2000 35 | ARM_STATE_TIME_ACTION=4000 36 | ARM_STATE_TIME_UNBUILD=2000 37 | 38 | JET_SOURCE=rocketBoss/jet.png 39 | JET_SIZE=3.8F,1.6F 40 | JET_SHAKE_MU=0.01F 41 | JET_SHAKE_SIGMA=0.005F 42 | 43 | NEXT_POS_DURATION=2000 -------------------------------------------------------------------------------- /project/basic/src/main/resources/conf/slurp.properties: -------------------------------------------------------------------------------- 1 | # Slurp 2 | SLURP_SPEED=1.0F 3 | SLURP_POPOFFS_PER_SEC=0.1F 4 | SLURP_DURP_AMOUNT=15 5 | SLOWING_FACTOR=0.5F -------------------------------------------------------------------------------- /project/basic/src/main/resources/conf/stacker.properties: -------------------------------------------------------------------------------- 1 | # Logic Configuration 2 | ITERATIONS=3 3 | SIZE_REGULAR=0.76F,0.76F 4 | SIZE_DYING=0.76F,0.0F 5 | POINTS=10 6 | 7 | # Visual Configuration 8 | COLOR=249,185,22 9 | FACES=5 10 | DIE_ANIMATION_TIME=0.5F 11 | -------------------------------------------------------------------------------- /project/basic/src/main/resources/conf/warper.properties: -------------------------------------------------------------------------------- 1 | # Warper 2 | WARPER_WARP_DELTA=1.0F 3 | SIZE=0.6F,0.6F 4 | WARPS=15 5 | 6 | WARP_PARTICLES.angle=0.0F,9.869604401F,9.869604401F,12.56637F 7 | WARP_PARTICLES.colorR=250.0F,0.0F 8 | WARP_PARTICLES.colorG=250.0F,-250.0F 9 | WARP_PARTICLES.colorB=150.0F 10 | WARP_PARTICLES.colorA=220.0F,-220.0F 11 | WARP_PARTICLES.timeMin=1.0F 12 | WARP_PARTICLES.speed=2.0F,3.0F,-1.0F,1.0F 13 | -------------------------------------------------------------------------------- /project/basic/src/main/resources/images/evilCoin.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rekit-group/rekit-game/64d489145f811f6d2a8cdc8ba062e097f7a66c05/project/basic/src/main/resources/images/evilCoin.png -------------------------------------------------------------------------------- /project/basic/src/main/resources/images/rektSmasher_0.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rekit-group/rekit-game/64d489145f811f6d2a8cdc8ba062e097f7a66c05/project/basic/src/main/resources/images/rektSmasher_0.png -------------------------------------------------------------------------------- /project/basic/src/main/resources/images/rektSmasher_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rekit-group/rekit-game/64d489145f811f6d2a8cdc8ba062e097f7a66c05/project/basic/src/main/resources/images/rektSmasher_1.png -------------------------------------------------------------------------------- /project/basic/src/main/resources/images/rektSmasher_2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rekit-group/rekit-game/64d489145f811f6d2a8cdc8ba062e097f7a66c05/project/basic/src/main/resources/images/rektSmasher_2.png -------------------------------------------------------------------------------- /project/basic/src/main/resources/images/rektSmasher_3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rekit-group/rekit-game/64d489145f811f6d2a8cdc8ba062e097f7a66c05/project/basic/src/main/resources/images/rektSmasher_3.png -------------------------------------------------------------------------------- /project/basic/src/main/resources/images/rocketBoss/cannon_left.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rekit-group/rekit-game/64d489145f811f6d2a8cdc8ba062e097f7a66c05/project/basic/src/main/resources/images/rocketBoss/cannon_left.png -------------------------------------------------------------------------------- /project/basic/src/main/resources/images/rocketBoss/cannon_right.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rekit-group/rekit-game/64d489145f811f6d2a8cdc8ba062e097f7a66c05/project/basic/src/main/resources/images/rocketBoss/cannon_right.png -------------------------------------------------------------------------------- /project/basic/src/main/resources/images/rocketBoss/head_0.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rekit-group/rekit-game/64d489145f811f6d2a8cdc8ba062e097f7a66c05/project/basic/src/main/resources/images/rocketBoss/head_0.png -------------------------------------------------------------------------------- /project/basic/src/main/resources/images/rocketBoss/head_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rekit-group/rekit-game/64d489145f811f6d2a8cdc8ba062e097f7a66c05/project/basic/src/main/resources/images/rocketBoss/head_1.png -------------------------------------------------------------------------------- /project/basic/src/main/resources/images/rocketBoss/head_2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rekit-group/rekit-game/64d489145f811f6d2a8cdc8ba062e097f7a66c05/project/basic/src/main/resources/images/rocketBoss/head_2.png -------------------------------------------------------------------------------- /project/basic/src/main/resources/images/rocketBoss/head_3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rekit-group/rekit-game/64d489145f811f6d2a8cdc8ba062e097f7a66c05/project/basic/src/main/resources/images/rocketBoss/head_3.png -------------------------------------------------------------------------------- /project/basic/src/main/resources/images/rocketBoss/jet.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rekit-group/rekit-game/64d489145f811f6d2a8cdc8ba062e097f7a66c05/project/basic/src/main/resources/images/rocketBoss/jet.png -------------------------------------------------------------------------------- /project/basic/src/main/resources/images/stacker/stackerFaces_01.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rekit-group/rekit-game/64d489145f811f6d2a8cdc8ba062e097f7a66c05/project/basic/src/main/resources/images/stacker/stackerFaces_01.png -------------------------------------------------------------------------------- /project/basic/src/main/resources/images/stacker/stackerFaces_02.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rekit-group/rekit-game/64d489145f811f6d2a8cdc8ba062e097f7a66c05/project/basic/src/main/resources/images/stacker/stackerFaces_02.png -------------------------------------------------------------------------------- /project/basic/src/main/resources/images/stacker/stackerFaces_03.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rekit-group/rekit-game/64d489145f811f6d2a8cdc8ba062e097f7a66c05/project/basic/src/main/resources/images/stacker/stackerFaces_03.png -------------------------------------------------------------------------------- /project/basic/src/main/resources/images/stacker/stackerFaces_04.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rekit-group/rekit-game/64d489145f811f6d2a8cdc8ba062e097f7a66c05/project/basic/src/main/resources/images/stacker/stackerFaces_04.png -------------------------------------------------------------------------------- /project/basic/src/main/resources/images/stacker/stackerFaces_05.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rekit-group/rekit-game/64d489145f811f6d2a8cdc8ba062e097f7a66c05/project/basic/src/main/resources/images/stacker/stackerFaces_05.png -------------------------------------------------------------------------------- /project/basic/src/main/resources/levels/test.dat: -------------------------------------------------------------------------------- 1 | #SETTING::name->EmptyTestLevel 2 | #SETTING::shuffle->false 3 | #SETTING::doGaps->false 4 | #SETTING::infinite->false 5 | #SETTING::autoCoinSpawn->false 6 | 7 | #ALIAS::1->Inanimate 8 | 9 | #ALIAS::10->DefaultCoin 10 | #ALIAS::11->SuperCoin 11 | #ALIAS::12->EvilCoin 12 | 13 | #ALIAS::2->RektKiller 14 | #ALIAS::3->Warper 15 | #ALIAS::4->Rocket 16 | #ALIAS::5->Slurp 17 | #ALIAS::6->Stacker 18 | #ALIAS::7->Cannon 19 | #ALIAS::8->Piston 20 | 21 | { 22 | {0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0} 23 | {0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0} 24 | {0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 10 10} 25 | {0 0 0 0 0 0 0 0 0 0 0 10 10 0 0 0 0} 26 | {0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1} 27 | {0 0 0 0 0 0 0 0 0 0 0 1 1 0 0 0 0} 28 | {0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0} 29 | {0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0} 30 | {1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1} 31 | } 32 | 33 | { 34 | {0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0} 35 | {0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0} 36 | {0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0} 37 | {0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0} 38 | {0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0} 39 | {0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0} 40 | {0 0 0 0 0 0 0 1 1 0 0 0 0 0 0 0 0} 41 | {0 0 0 0 0 0 1 1 1 0 0 0 6 0 0 0 0} 42 | {1 1 1 1 1 1 1 1 1 0 0 1 1 1 1 1 1} 43 | } 44 | { 45 | {0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0} 46 | {0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0} 47 | {0 0 10 10 0 0 0 0 0 0 0 0 0 0 0 0 0} 48 | {0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0} 49 | {0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0} 50 | {0 0 0 0 1 1 0 0 0 0 0 0 0 0 0 0 0} 51 | {1 1 0 0 1 1 0 0 0 0 0 0 0 0 0 0 0} 52 | {1 1 0 0 1 1 0 0 0 0 0 0 0 0 0 0 0} 53 | {1 1 1 1 1 1 0 0 1 1 1 1 1 1 1 1 1} 54 | } -------------------------------------------------------------------------------- /project/build.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | if [ -z "$1" ] 3 | then 4 | echo "Please specify the launch file" 5 | exit 1 6 | fi 7 | 8 | PWD=$(pwd) 9 | DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" 10 | 11 | if [ "$PWD" != "$DIR" ] 12 | then 13 | echo "This script does not support execution from other directories" 14 | exit 2 15 | fi 16 | 17 | mvn $(cat "$1" | grep "M2_GOALS" | tr "\"" "\n" | tail -2 - | head -1 -) 18 | -------------------------------------------------------------------------------- /project/check-updates.launch: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /project/game/.gitignore: -------------------------------------------------------------------------------- 1 | /target/ 2 | -------------------------------------------------------------------------------- /project/game/pom.xml: -------------------------------------------------------------------------------- 1 | 3 | 4.0.0 4 | 5 | rekit 6 | parent 7 | 1.3 8 | 9 | 10 | 11 | 12 | org.apache.maven.plugins 13 | maven-assembly-plugin 14 | 15 | ${singlejar.name} 16 | false 17 | 18 | 19 | 20 | 21 | 22 | game 23 | 24 | 25 | rekit 26 | gui 27 | 28 | 29 | rekit 30 | logic 31 | 32 | 33 | rekit 34 | basic 35 | 36 | 37 | -------------------------------------------------------------------------------- /project/global/.gitignore: -------------------------------------------------------------------------------- 1 | /target/ 2 | -------------------------------------------------------------------------------- /project/global/pom.xml: -------------------------------------------------------------------------------- 1 | 4 | 4.0.0 5 | 6 | rekit 7 | parent 8 | 1.3 9 | 10 | global 11 | 12 | 13 | org.reflections 14 | reflections 15 | 16 | 17 | org.fuchss 18 | configuration-parser 19 | 20 | 21 | net.jafama 22 | jafama 23 | 24 | 25 | -------------------------------------------------------------------------------- /project/global/src/main/java/org/fuchss/tools/lambda/BiFunctionWithException.java: -------------------------------------------------------------------------------- 1 | package org.fuchss.tools.lambda; 2 | 3 | import java.util.function.BiFunction; 4 | 5 | /** 6 | * Same as {@link BiFunction} but with {@link Exception}. 7 | * 8 | * @author Dominik Fuchss 9 | * 10 | * @param 11 | * input one type 12 | * @param 13 | * input two type 14 | * @param 15 | * output type 16 | */ 17 | @FunctionalInterface 18 | public interface BiFunctionWithException { 19 | O apply(I1 i1, I2 i2) throws Exception; 20 | } 21 | -------------------------------------------------------------------------------- /project/global/src/main/java/org/fuchss/tools/lambda/ConsumerWithException.java: -------------------------------------------------------------------------------- 1 | package org.fuchss.tools.lambda; 2 | 3 | import java.util.function.Consumer; 4 | 5 | /** 6 | * Same as {@link Consumer} but with {@link Exception}. 7 | * 8 | * @param 9 | * the input type 10 | * @author Dominik Fuchss 11 | * 12 | */ 13 | public interface ConsumerWithException { 14 | void accept(I i) throws Exception; 15 | } 16 | -------------------------------------------------------------------------------- /project/global/src/main/java/org/fuchss/tools/lambda/FunctionWithException.java: -------------------------------------------------------------------------------- 1 | package org.fuchss.tools.lambda; 2 | 3 | import java.util.function.Function; 4 | 5 | /** 6 | * Same as {@link Function} but with {@link Exception}. 7 | * 8 | * @author Dominik Fuchss 9 | * 10 | * @param 11 | * the input type 12 | * @param 13 | * the output type 14 | */ 15 | @FunctionalInterface 16 | public interface FunctionWithException { 17 | O apply(I i) throws Exception; 18 | } 19 | -------------------------------------------------------------------------------- /project/global/src/main/java/org/fuchss/tools/lambda/SupplierWithException.java: -------------------------------------------------------------------------------- 1 | package org.fuchss.tools.lambda; 2 | 3 | import java.util.function.Supplier; 4 | 5 | /** 6 | * Same as {@link Supplier} but with {@link Exception}. 7 | * 8 | * @author Dominik Fuchss 9 | * 10 | */ 11 | public interface SupplierWithException { 12 | O get() throws Exception; 13 | } 14 | -------------------------------------------------------------------------------- /project/global/src/main/java/org/fuchss/tools/lambda/VoidFunction.java: -------------------------------------------------------------------------------- 1 | package org.fuchss.tools.lambda; 2 | 3 | @FunctionalInterface 4 | public interface VoidFunction { 5 | void execute(); 6 | } 7 | -------------------------------------------------------------------------------- /project/global/src/main/java/org/fuchss/tools/lambda/VoidFunctionWithException.java: -------------------------------------------------------------------------------- 1 | package org.fuchss.tools.lambda; 2 | 3 | /** 4 | * Same as {@link VoidFunction} but with {@link Exception}. 5 | * 6 | * @author Dominik Fuchss 7 | * 8 | */ 9 | public interface VoidFunctionWithException { 10 | void execute() throws Exception; 11 | } 12 | -------------------------------------------------------------------------------- /project/global/src/main/java/org/fuchss/tools/tuple/Tuple2.java: -------------------------------------------------------------------------------- 1 | package org.fuchss.tools.tuple; 2 | 3 | import java.io.Serializable; 4 | import java.util.Objects; 5 | 6 | /** 7 | * A simple tuple of two values 8 | * 9 | * @author Dominik Fuchss 10 | * 11 | * @param 12 | * the first type 13 | * @param 14 | * the second type 15 | */ 16 | public final class Tuple2 implements Serializable { 17 | private static final long serialVersionUID = 8620745419750320286L; 18 | /** 19 | * The first value. 20 | */ 21 | private final A first; 22 | /** 23 | * The second value. 24 | */ 25 | private final B second; 26 | 27 | private Tuple2(final A first, final B second) { 28 | this.first = first; 29 | this.second = second; 30 | } 31 | 32 | public static Tuple2 of(final A first, final B second) { 33 | return new Tuple2<>(first, second); 34 | } 35 | 36 | /** 37 | * The first value. 38 | * 39 | * @return the first value 40 | */ 41 | public A getFirst() { 42 | return this.first; 43 | } 44 | 45 | /** 46 | * The second value. 47 | * 48 | * @return the second value 49 | */ 50 | public B getSecond() { 51 | return this.second; 52 | } 53 | 54 | @Override 55 | public int hashCode() { 56 | return Objects.hash(this.first, this.second); 57 | } 58 | 59 | @Override 60 | public boolean equals(Object obj) { 61 | if (this == obj) { 62 | return true; 63 | } 64 | if (obj == null || this.getClass() != obj.getClass()) { 65 | return false; 66 | } 67 | Tuple2 other = (Tuple2) obj; 68 | return Objects.equals(this.first, other.first) && Objects.equals(this.second, other.second); 69 | } 70 | 71 | @Override 72 | public String toString() { 73 | return "Tuple2(first=" + this.getFirst() + ", second=" + this.getSecond() + ")"; 74 | } 75 | } 76 | -------------------------------------------------------------------------------- /project/global/src/main/java/rekit/core/CameraTarget.java: -------------------------------------------------------------------------------- 1 | package rekit.core; 2 | 3 | /** 4 | * 5 | * This interface has to be implemented by Objects which can set or calculate 6 | * the current CameraOffset. 7 | * 8 | */ 9 | public interface CameraTarget { 10 | /** 11 | * Get the current camera offset. 12 | * 13 | * @return the current camera offset 14 | */ 15 | float getCameraOffset(); 16 | } 17 | -------------------------------------------------------------------------------- /project/global/src/main/java/rekit/core/GameTime.java: -------------------------------------------------------------------------------- 1 | package rekit.core; 2 | 3 | /** 4 | * This class manages the time of the game and replaces 5 | * {@link System#currentTimeMillis()}. 6 | * 7 | * @author Dominik Fuchss 8 | * 9 | */ 10 | public final class GameTime { 11 | /** 12 | * Prevent instantiation. 13 | */ 14 | private GameTime() { 15 | } 16 | 17 | /** 18 | * Time the game is paused. 19 | */ 20 | private static long paused = 0; 21 | /** 22 | * The time when the last pause started. 23 | */ 24 | private static long started = 0; 25 | /** 26 | * Indicates whether game is paused. 27 | */ 28 | private static boolean pause = false; 29 | 30 | /** 31 | * Get the current time in the game. 32 | * 33 | * @return the current time 34 | */ 35 | public static long getTime() { 36 | if (GameTime.pause) { 37 | return GameTime.started; 38 | } 39 | return System.currentTimeMillis() - GameTime.paused; 40 | } 41 | 42 | /** 43 | * Pause the game. 44 | */ 45 | public static synchronized void pause() { 46 | if (GameTime.pause) { 47 | return; 48 | } 49 | GameTime.pause = true; 50 | GameTime.started = System.currentTimeMillis(); 51 | } 52 | 53 | /** 54 | * Resume from pause. 55 | */ 56 | public static synchronized void resume() { 57 | if (!GameTime.pause) { 58 | return; 59 | } 60 | GameTime.pause = false; 61 | GameTime.paused += System.currentTimeMillis() - GameTime.started; 62 | 63 | } 64 | 65 | /** 66 | * Indicates whether the time has been stopped. 67 | * 68 | * @return {@code true} if stopped, {@code false} otherwise 69 | */ 70 | public static boolean isPaused() { 71 | return GameTime.pause; 72 | } 73 | } 74 | -------------------------------------------------------------------------------- /project/global/src/main/java/rekit/core/ShutdownManager.java: -------------------------------------------------------------------------------- 1 | package rekit.core; 2 | 3 | import java.util.ArrayList; 4 | import java.util.List; 5 | 6 | import org.fuchss.tools.lambda.VoidFunctionWithException; 7 | 8 | /** 9 | * 10 | * The shutdown manager of the system. 11 | * 12 | * @author Dominik Fuchss 13 | * 14 | */ 15 | public final class ShutdownManager { 16 | 17 | private ShutdownManager() { 18 | throw new IllegalAccessError(); 19 | } 20 | 21 | private static boolean RUNNING = true; 22 | 23 | public static boolean isRunning() { 24 | return ShutdownManager.RUNNING; 25 | } 26 | 27 | private static final List HANDLERS = new ArrayList<>(); 28 | 29 | public static synchronized void registerObserver(VoidFunctionWithException shutdownHandler) { 30 | ShutdownManager.HANDLERS.add(shutdownHandler); 31 | } 32 | 33 | public static synchronized void shutdown() { 34 | ShutdownManager.RUNNING = false; 35 | ShutdownManager.HANDLERS.forEach(ShutdownManager::execute); 36 | // If handlers finished. Kill VM. 37 | System.exit(0); 38 | } 39 | 40 | private static void execute(VoidFunctionWithException handler) { 41 | try { 42 | handler.execute(); 43 | } catch (Exception e) { 44 | e.printStackTrace(); 45 | } 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /project/global/src/main/java/rekit/parser/ProgressParser.java: -------------------------------------------------------------------------------- 1 | package rekit.parser; 2 | 3 | import java.util.regex.Matcher; 4 | import java.util.regex.Pattern; 5 | 6 | import org.fuchss.configuration.parser.Parser; 7 | 8 | import rekit.config.GameConf; 9 | import rekit.primitives.time.Progress; 10 | 11 | /** 12 | * This {@link Parser} is used for parsing {@link Progress} objects. 13 | * 14 | * @author Angelo Aracri 15 | */ 16 | public final class ProgressParser implements Parser { 17 | @Override 18 | public Object parseIt(String definition, String[] path) throws Exception { 19 | 20 | Pattern pattern = Pattern.compile("[-|\\+]?([0-9]+\\.[0-9]+[f|F]),[-|\\+]?([0-9]+\\.[0-9]+[f|F])"); 21 | Matcher matcher = pattern.matcher(definition); 22 | if (!matcher.find()) { 23 | GameConf.GAME_LOGGER.error("BundleHelper: " + definition + " is no Progress"); 24 | return null; 25 | } 26 | 27 | float x = Float.parseFloat(matcher.group(1)); 28 | float y = Float.parseFloat(matcher.group(2)); 29 | 30 | return new Progress(x, y); 31 | 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /project/global/src/main/java/rekit/parser/RGBAColorParser.java: -------------------------------------------------------------------------------- 1 | package rekit.parser; 2 | 3 | import java.util.regex.Matcher; 4 | import java.util.regex.Pattern; 5 | 6 | import org.fuchss.configuration.parser.Parser; 7 | 8 | import rekit.primitives.image.RGBAColor; 9 | 10 | /** 11 | * This {@link Parser} is used for parsing {@link RGBAColor RGBAColors}. 12 | * 13 | * @author Dominik Fuchss 14 | * 15 | */ 16 | public final class RGBAColorParser implements Parser { 17 | @Override 18 | public Object parseIt(String definition, String[] path) throws Exception { 19 | Pattern patternRGBA = Pattern.compile("([0-9]+),([0-9]+),([0-9]+),([0-9]+)"); 20 | Matcher matcherRGBA = patternRGBA.matcher(definition); 21 | 22 | Pattern patternRGB = Pattern.compile("([0-9]+),([0-9]+),([0-9]+)"); 23 | Matcher matcherRGB = patternRGB.matcher(definition); 24 | boolean rgba = matcherRGBA.matches(); 25 | boolean rgb = matcherRGB.matches(); 26 | if (!rgba && !rgb) { 27 | Parser.LOGGER.error(definition + " is not a RGB(A) color!"); 28 | return null; 29 | } 30 | Matcher matcher = rgba ? matcherRGBA : matcherRGB; 31 | 32 | int r = Integer.parseInt(matcher.group(1)); 33 | int g = Integer.parseInt(matcher.group(2)); 34 | int b = Integer.parseInt(matcher.group(3)); 35 | int a = rgba ? Integer.parseInt(matcher.group(4)) : 255; 36 | 37 | return new RGBAColor(r, g, b, a); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /project/global/src/main/java/rekit/parser/VecParser.java: -------------------------------------------------------------------------------- 1 | package rekit.parser; 2 | 3 | import java.util.regex.Matcher; 4 | import java.util.regex.Pattern; 5 | 6 | import org.fuchss.configuration.parser.Parser; 7 | 8 | import rekit.config.GameConf; 9 | import rekit.primitives.geometry.Vec; 10 | 11 | /** 12 | * This {@link Parser} is used for parsing {@link Vec Vectors}. 13 | * 14 | * @author Angelo Aracri 15 | * 16 | */ 17 | public final class VecParser implements Parser { 18 | @Override 19 | public Object parseIt(String definition, String[] path) throws Exception { 20 | 21 | Pattern pattern = Pattern.compile("([-|\\+]?[0-9]+\\.[0-9]+[f|F]),([-|\\+]?[0-9]+\\.[0-9]+[f|F])"); 22 | Matcher matcher = pattern.matcher(definition); 23 | if (!matcher.find()) { 24 | GameConf.GAME_LOGGER.error("BundleHelper: " + definition + " is no Vec"); 25 | return null; 26 | } 27 | 28 | float x = Float.parseFloat(matcher.group(1)); 29 | float y = Float.parseFloat(matcher.group(2)); 30 | 31 | return new Vec(x, y); 32 | 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /project/global/src/main/java/rekit/primitives/image/AbstractImage.java: -------------------------------------------------------------------------------- 1 | package rekit.primitives.image; 2 | 3 | /** 4 | * This class represents an abstract version of an Image. 5 | * 6 | * @author Dominik Fuchss 7 | * 8 | */ 9 | public final class AbstractImage { 10 | /** 11 | * The width. 12 | */ 13 | public final int width; 14 | /** 15 | * The height. 16 | */ 17 | public final int height; 18 | /** 19 | * This array contains the RGBA values of the image in this order 20 | * R->G->B->A. 21 | */ 22 | public final byte[] pixels; 23 | 24 | /** 25 | * Create an Abstract Image. 26 | * 27 | * @param height 28 | * the height 29 | * @param width 30 | * the width 31 | * @param pixels 32 | * the pixels 33 | */ 34 | public AbstractImage(int height, int width, byte[] pixels) { 35 | this.height = height; 36 | this.width = width; 37 | this.pixels = pixels; 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /project/global/src/main/java/rekit/primitives/operable/OpProgress.java: -------------------------------------------------------------------------------- 1 | package rekit.primitives.operable; 2 | 3 | /** 4 | * Dynamically scale (linear) an {@link Operable}. 5 | * 6 | * @param 7 | * the class / the {@link Operable} 8 | */ 9 | public final class OpProgress> { 10 | /** 11 | * Indicates whether the element is static. 12 | */ 13 | private boolean isStatic = false; 14 | 15 | /** 16 | * Saved version of the start value. 17 | */ 18 | private Operable start; 19 | 20 | /** 21 | * Saved version of the delta value, calculated by end-initial. 22 | */ 23 | private Operable delta; 24 | 25 | /** 26 | * Constructor that takes the start and end value for calculating values in 27 | * between relative to a progress between 0 and 1. 28 | * 29 | * @param start 30 | * the start value that will be returned for progress = 0 31 | * @param end 32 | * the end value that will be returned for progress = 1 33 | */ 34 | public OpProgress(Operable start, Operable end) { 35 | this.start = start; 36 | this.delta = end.sub(start.get()); 37 | 38 | if (start.equals(end)) { 39 | this.isStatic = true; 40 | } 41 | } 42 | 43 | /** 44 | * Calculates a value between start and end in the same ratio 45 | * as progress has to 0 and 1. Has no defined behavior for other numbers. 46 | * 47 | * @param progress 48 | * a value between 0 and 1 that defines the ratio 49 | * @return the calculated value between start and end 50 | * (inclusive) 51 | */ 52 | public T getNow(float progress) { 53 | // if no change required then there must be no calculation 54 | return this.isStatic ? this.start.get() : this.start.add(this.delta.scalar(progress)); 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /project/global/src/main/java/rekit/primitives/operable/Operable.java: -------------------------------------------------------------------------------- 1 | package rekit.primitives.operable; 2 | 3 | /** 4 | * This interface defines the kind of Objects a {@link OpProgress} will handle. 5 | *
6 | * USAGE: class XYZ implements Operable<XYZ> 7 | * 8 | * @param 9 | * the class itself ! 10 | */ 11 | public interface Operable> { 12 | /** 13 | * Apply scalar. 14 | * 15 | * @param scalar 16 | * the scalar 17 | * @return the object itself 18 | */ 19 | T scalar(float scalar); 20 | 21 | /** 22 | * Apply multiplicand. 23 | * 24 | * @param other 25 | * the other 26 | * @return the object itself 27 | */ 28 | T multiply(T other); 29 | 30 | /** 31 | * Apply summand. 32 | * 33 | * @param other 34 | * the other 35 | * @return the object itself 36 | */ 37 | T add(T other); 38 | 39 | /** 40 | * Apply subtrahend. 41 | * 42 | * @param other 43 | * the other 44 | * @return the object itself 45 | */ 46 | T sub(T other); 47 | 48 | /** 49 | * Always ! Enter the code: {@code return this;} 50 | * 51 | * @return {@code this} 52 | */ 53 | T get(); 54 | 55 | } 56 | -------------------------------------------------------------------------------- /project/global/src/main/java/rekit/primitives/time/Progress.java: -------------------------------------------------------------------------------- 1 | package rekit.primitives.time; 2 | 3 | import org.fuchss.configuration.annotations.ClassParser; 4 | 5 | import rekit.parser.ProgressParser; 6 | 7 | /** 8 | * Data class that holds an start and an end float. It can return 9 | * the corresponding value in between in the same ratio as a given number 10 | * progress to 0 and 1. 11 | * 12 | * @author Angelo Aracri 13 | * 14 | */ 15 | @ClassParser(ProgressParser.class) 16 | public final class Progress { 17 | 18 | /** 19 | * Saved version of the start value. 20 | */ 21 | private float start; 22 | 23 | /** 24 | * Saved version of the delta value, calculated by end-initial. 25 | */ 26 | private float delta; 27 | 28 | /** 29 | * Constructor that takes the start and end value for calculating values in 30 | * between relative to a progress between 0 and 1. 31 | * 32 | * @param start 33 | * the start value that will be returned for progress = 0 34 | * @param end 35 | * the end value that will be returned for progress = 1 36 | */ 37 | public Progress(float start, float end) { 38 | this.start = start; 39 | this.delta = end - start; 40 | } 41 | 42 | /** 43 | * Calculates a value between start and end in the same ratio 44 | * as progress has to 0 and 1. Has no defined behavior for other numbers. 45 | * 46 | * @param progress 47 | * a value between 0 and 1 that defines the ratio 48 | * @return the calculated value between start and end 49 | * (inclusive) 50 | */ 51 | public float getNow(float progress) { 52 | // if no change required then there must be no calculation 53 | return this.isStatic() ? this.start : this.start + this.delta * progress; 54 | } 55 | 56 | /** 57 | * Returns true if start = end, which means there are no calculations 58 | * required in getNow(float progress). 59 | * 60 | * @return true if getNows output never changes, false otherwise 61 | */ 62 | public boolean isStatic() { 63 | return this.delta == 0; 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /project/global/src/main/java/rekit/util/CalcUtil.java: -------------------------------------------------------------------------------- 1 | package rekit.util; 2 | 3 | import rekit.config.GameConf; 4 | import rekit.primitives.geometry.Vec; 5 | 6 | /** 7 | * This class contains several methods to calculate between units. 8 | * 9 | */ 10 | public final class CalcUtil { 11 | /** 12 | * Prevent instantiation. 13 | */ 14 | private CalcUtil() { 15 | } 16 | 17 | /** 18 | * Units to Pixels. 19 | * 20 | * @param units 21 | * the units 22 | * @return the pixels 23 | */ 24 | public static int units2pixel(float units) { 25 | return (int) (units * GameConf.PX_PER_UNIT); 26 | } 27 | 28 | /** 29 | * Units to Pixels. 30 | * 31 | * @param pos 32 | * the position 33 | * @return the position in units 34 | */ 35 | public static Vec units2pixel(Vec pos) { 36 | return new Vec(pos.x * GameConf.PX_PER_UNIT, pos.y * GameConf.PX_PER_UNIT); 37 | } 38 | 39 | /** 40 | * Randomize a value. 41 | * 42 | * @param mu 43 | * the value 44 | * @param sigma 45 | * the sigma 46 | * @return the randomized value 47 | */ 48 | public static double randomize(double mu, double sigma) { 49 | return mu + (GameConf.PRNG.nextDouble() * 2 - 1) * sigma; 50 | } 51 | 52 | /** 53 | * Randomize a value. 54 | * 55 | * @param mu 56 | * the value 57 | * @param sigma 58 | * the sigma 59 | * @return the randomized value 60 | */ 61 | public static float randomize(float mu, float sigma) { 62 | return mu + (GameConf.PRNG.nextFloat() * 2 - 1) * sigma; 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /project/global/src/main/java/rekit/util/LambdaUtil.java: -------------------------------------------------------------------------------- 1 | package rekit.util; 2 | 3 | import org.fuchss.tools.lambda.ConsumerWithException; 4 | import org.fuchss.tools.lambda.FunctionWithException; 5 | import org.fuchss.tools.lambda.LambdaConvert; 6 | import org.fuchss.tools.lambda.SupplierWithException; 7 | import org.fuchss.tools.lambda.VoidFunctionWithException; 8 | 9 | import rekit.config.GameConf; 10 | 11 | /** 12 | * This class contains several methods to work with Lambdas. 13 | * 14 | * @author Dominik Fuchss 15 | * 16 | */ 17 | public final class LambdaUtil { 18 | /** 19 | * Prevent instantiation. 20 | */ 21 | private LambdaUtil() { 22 | } 23 | 24 | /** 25 | * Invoke a {@link FunctionWithException}. 26 | * 27 | * @param in 28 | * the function 29 | * @param i 30 | * the input 31 | * @param 32 | * the in type 33 | * @param 34 | * the out type 35 | * 36 | * @return the output or {@code null} (in error case) 37 | */ 38 | public static O invoke(FunctionWithException in, I i) { 39 | return LambdaConvert.wrap(in, e -> GameConf.GAME_LOGGER.fatal(e.getMessage())).apply(i); 40 | } 41 | 42 | /** 43 | * Invoke a {@link VoidFunctionWithException}. 44 | * 45 | * @param in 46 | * the function 47 | */ 48 | 49 | public static void invoke(VoidFunctionWithException in) { 50 | LambdaConvert.wrap(in, e -> GameConf.GAME_LOGGER.fatal(e.getMessage())).execute(); 51 | } 52 | 53 | /** 54 | * Invoke a {@link ConsumerWithException}. 55 | * 56 | * @param in 57 | * the function 58 | * @param i 59 | * the input 60 | * @param 61 | * the in type 62 | */ 63 | public static void invoke(ConsumerWithException in, I i) { 64 | LambdaConvert.wrap(in, e -> GameConf.GAME_LOGGER.fatal(e.getMessage())).accept(i); 65 | 66 | } 67 | 68 | /** 69 | * Invoke a {@link SupplierWithException}. 70 | * 71 | * @param in 72 | * the function 73 | * @param 74 | * the out type 75 | * @return the return value of the Supplier or {@code null} on failure 76 | */ 77 | public static O invoke(SupplierWithException in) { 78 | return LambdaConvert.wrap(in, e -> GameConf.GAME_LOGGER.fatal(e.getMessage())).get(); 79 | } 80 | 81 | } 82 | -------------------------------------------------------------------------------- /project/global/src/main/java/rekit/util/Once.java: -------------------------------------------------------------------------------- 1 | package rekit.util; 2 | 3 | import org.fuchss.tools.lambda.VoidFunctionWithException; 4 | 5 | /** 6 | * This class realized a {@link VoidFunctionWithException} which can executed 7 | * once. (After that execution the invocation has no effect anymore.) 8 | * 9 | * @author Dominik Fuchss 10 | * 11 | */ 12 | public final class Once implements VoidFunctionWithException { 13 | private boolean invoked = false; 14 | private final VoidFunctionWithException run; 15 | 16 | /** 17 | * Create a Once-Object. 18 | * 19 | * @param run 20 | * the command which shall executed once 21 | */ 22 | public Once(VoidFunctionWithException run) { 23 | this.run = run; 24 | } 25 | 26 | @Override 27 | public void execute() throws Exception { 28 | if (this.invoked || this.run == null) { 29 | return; 30 | } 31 | this.invoked = true; 32 | this.run.execute(); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /project/global/src/main/java/rekit/util/ThreadUtils.java: -------------------------------------------------------------------------------- 1 | package rekit.util; 2 | 3 | /** 4 | * This class contains several methods for a better usability of Threads. 5 | * 6 | * @author Dominik Fuchss 7 | * 8 | */ 9 | public final class ThreadUtils { 10 | /** 11 | * Prevent instantiation. 12 | */ 13 | private ThreadUtils() { 14 | } 15 | 16 | /** 17 | * Same as {@link Thread#sleep(long)}. 18 | * 19 | * @param time 20 | * length of time to sleep in milliseconds 21 | * @return {@code true} if successfully sleeped the time, {@code false} 22 | * otherwise 23 | */ 24 | public static boolean sleep(long time) { 25 | if (time <= 0) { 26 | return true; 27 | } 28 | try { 29 | Thread.sleep(time); 30 | } catch (InterruptedException e) { 31 | return false; 32 | } 33 | return true; 34 | } 35 | 36 | /** 37 | * Run a {@link Runnable} as daemon. 38 | * 39 | * @param name 40 | * the name of the daemon 41 | * @param r 42 | * the runnable 43 | * @return the thread 44 | */ 45 | public static Thread runDaemon(String name, Runnable r) { 46 | return ThreadUtils.runThread(name, r, true); 47 | } 48 | 49 | /** 50 | * Run a {@link Runnable} not a daemon. 51 | * 52 | * @param name 53 | * the name of the thread 54 | * @param r 55 | * the runnable 56 | * @return the thread 57 | */ 58 | public static Thread runThread(String name, Runnable r) { 59 | return ThreadUtils.runThread(name, r, false); 60 | } 61 | 62 | /** 63 | * Run a {@link Runnable}. 64 | * 65 | * @param name 66 | * the name of the thread 67 | * @param r 68 | * the runnable 69 | * @param daemon 70 | * daemon? 71 | * @return the thread 72 | */ 73 | private static Thread runThread(String name, Runnable r, boolean daemon) { 74 | Thread t = new Thread(r); 75 | t.setName(name); 76 | t.setDaemon(daemon); 77 | t.start(); 78 | return t; 79 | } 80 | 81 | } 82 | -------------------------------------------------------------------------------- /project/global/src/main/java/rekit/util/container/ROContainer.java: -------------------------------------------------------------------------------- 1 | package rekit.util.container; 2 | 3 | /** 4 | * This class represents a container or pointer, which can be used to set 5 | * variables in lambdas and can only set one time to a value not equal to 6 | * {@code null}. 7 | * 8 | * @author Dominik Fuchss 9 | * 10 | * @param 11 | * the element type 12 | */ 13 | 14 | public final class ROContainer { 15 | /** 16 | * The element. 17 | */ 18 | private E e; 19 | 20 | /** 21 | * Set the element. 22 | * 23 | * @param e 24 | * the element 25 | */ 26 | public void set(E e) { 27 | if (this.e != null) { 28 | return; 29 | } 30 | this.e = e; 31 | } 32 | 33 | /** 34 | * Get the element 35 | * 36 | * @return the element 37 | */ 38 | public E get() { 39 | return this.e; 40 | } 41 | 42 | @Override 43 | public String toString() { 44 | return "" + this.e; 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /project/global/src/main/java/rekit/util/container/RWContainer.java: -------------------------------------------------------------------------------- 1 | package rekit.util.container; 2 | 3 | /** 4 | * This class represents a container or pointer, which can be used to set 5 | * variables in lambdas. 6 | * 7 | * @author Dominik Fuchss 8 | * 9 | * @param 10 | * the element type 11 | */ 12 | 13 | public final class RWContainer { 14 | /** 15 | * The element. 16 | */ 17 | private E e; 18 | 19 | /** 20 | * Set the element. 21 | * 22 | * @param e 23 | * the element 24 | */ 25 | public void set(E e) { 26 | this.e = e; 27 | } 28 | 29 | /** 30 | * Get the element 31 | * 32 | * @return the element 33 | */ 34 | public E get() { 35 | return this.e; 36 | } 37 | 38 | @Override 39 | public String toString() { 40 | return "" + this.e; 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /project/global/src/main/resources/conf/game.properties: -------------------------------------------------------------------------------- 1 | # Project Parameters 2 | NAME=R\u03B5KiT 3 | VERSION=${rekit.version} 4 | ABOUT=R\u03B5KiT - Version: ${rekit.version}\nCopyright (C) 2017 - 2021 Angelo Aracri | Dominik Fuch\u00DF | Matthias Schmitt\n\nThis program is free software: you can redistribute it and/or modify\nit under the terms of the GNU General Public License as published by\nthe Free Software Foundation, either version 3 of the License, or\n(at your option) any later version.\n\nThis program is distributed in the hope that it will be useful,\nbut WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with this program. If not, see . 5 | 6 | # frame size 7 | 8 | PX_PER_UNIT=50 9 | GRID_W=22 10 | GRID_H=9 11 | GRID_TOLERANCE_BELOW=3 12 | 13 | # time intervals 14 | 15 | RENDER_DELTA=16 16 | LOGIC_DELTA=20 17 | 18 | # graphics 19 | 20 | MENU_BACKGROUND_COLOR=25,25,25 21 | MENU_BOX_COLOR=80,80,80 22 | MENU_BOX_SELECT_COLOR=200,50,0 23 | MENU_BOX_OPTION_COLOR=20,200,20 24 | MENU_TEXT_COLOR=255,255,255 25 | MENU_TEXT_SIZE=37 26 | MENU_TEXT_FONT=Segoe UI Light 27 | 28 | GAME_BACKGROUD_COLOR=110,170,255 29 | GAME_TEXT_COLOR=180,80,30 30 | GAME_TEXT_SIZE=18 31 | GAME_TEXT_FONT=Segoe UI Light 32 | 33 | # entity depending stuff 34 | G=42.0F 35 | -------------------------------------------------------------------------------- /project/global/src/main/resources/images/life.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rekit-group/rekit-game/64d489145f811f6d2a8cdc8ba062e097f7a66c05/project/global/src/main/resources/images/life.png -------------------------------------------------------------------------------- /project/global/src/main/resources/images/logo_0.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rekit-group/rekit-game/64d489145f811f6d2a8cdc8ba062e097f7a66c05/project/global/src/main/resources/images/logo_0.png -------------------------------------------------------------------------------- /project/global/src/main/resources/images/logo_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rekit-group/rekit-game/64d489145f811f6d2a8cdc8ba062e097f7a66c05/project/global/src/main/resources/images/logo_1.png -------------------------------------------------------------------------------- /project/global/src/main/resources/images/logo_2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rekit-group/rekit-game/64d489145f811f6d2a8cdc8ba062e097f7a66c05/project/global/src/main/resources/images/logo_2.png -------------------------------------------------------------------------------- /project/global/src/main/resources/images/mainmenu.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rekit-group/rekit-game/64d489145f811f6d2a8cdc8ba062e097f7a66c05/project/global/src/main/resources/images/mainmenu.png -------------------------------------------------------------------------------- /project/global/src/main/resources/images/mrRekt_glasses_left.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rekit-group/rekit-game/64d489145f811f6d2a8cdc8ba062e097f7a66c05/project/global/src/main/resources/images/mrRekt_glasses_left.png -------------------------------------------------------------------------------- /project/global/src/main/resources/images/mrRekt_glasses_right.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rekit-group/rekit-game/64d489145f811f6d2a8cdc8ba062e097f7a66c05/project/global/src/main/resources/images/mrRekt_glasses_right.png -------------------------------------------------------------------------------- /project/gui/.gitignore: -------------------------------------------------------------------------------- 1 | /target/ 2 | -------------------------------------------------------------------------------- /project/gui/pom.xml: -------------------------------------------------------------------------------- 1 | 3 | 4.0.0 4 | 5 | rekit 6 | parent 7 | 1.3 8 | 9 | gui 10 | 11 | 12 | rekit 13 | logic 14 | 15 | 16 | org.springframework 17 | spring-core 18 | 19 | 20 | commons-io 21 | commons-io 22 | 23 | 24 | -------------------------------------------------------------------------------- /project/gui/src/main/java/rekit/gui/InputHelper.java: -------------------------------------------------------------------------------- 1 | package rekit.gui; 2 | 3 | import java.awt.event.KeyEvent; 4 | 5 | /** 6 | * This interface establishes a Listener to Components of the View.
7 | * 8 | * @author Dominik Fuchss 9 | * 10 | */ 11 | public interface InputHelper { 12 | /** 13 | * Key ID ArrowUp. 14 | */ 15 | int ARROW_UP = KeyEvent.VK_UP; 16 | 17 | /** 18 | * Key ID ArrowUp. 19 | */ 20 | int ARROW_DOWN = KeyEvent.VK_DOWN; 21 | 22 | /** 23 | * Key ID Arrow Left. 24 | */ 25 | int ARROW_LEFT = KeyEvent.VK_LEFT; 26 | 27 | /** 28 | * Key ID Arrow Right. 29 | */ 30 | int ARROW_RIGHT = KeyEvent.VK_RIGHT; 31 | 32 | /** 33 | * Key ID Space. 34 | */ 35 | int SPACE = KeyEvent.VK_SPACE; 36 | 37 | /** 38 | * Key ID Escape. 39 | */ 40 | int ESCAPE = KeyEvent.VK_ESCAPE; 41 | 42 | /** 43 | * Key ID Enter. 44 | */ 45 | int ENTER = KeyEvent.VK_ENTER; 46 | 47 | /** 48 | * Initialize the InputHelper. 49 | * 50 | * @param view 51 | * the view of the MVC 52 | */ 53 | default void initialize(View view) { 54 | view.attachMe(this); 55 | } 56 | 57 | /** 58 | * This method will invoked when a key is pressed. 59 | * 60 | * @param keyCode 61 | * the keycode 62 | */ 63 | void press(int keyCode); 64 | 65 | /** 66 | * This method will invoked when a key is released. 67 | * 68 | * @param keyCode 69 | * the keycode 70 | */ 71 | void release(int keyCode); 72 | 73 | } 74 | -------------------------------------------------------------------------------- /project/gui/src/main/java/rekit/gui/View.java: -------------------------------------------------------------------------------- 1 | package rekit.gui; 2 | 3 | import rekit.logic.Model; 4 | 5 | /** 6 | * This Interface defines the View for the MVC. 7 | * 8 | * @author Dominik Fuchss 9 | * 10 | */ 11 | public interface View { 12 | /** 13 | * Get the view. 14 | * 15 | * @param model 16 | * the model 17 | * @return the view 18 | */ 19 | static View getView(Model model) { 20 | return new GameView(model); 21 | } 22 | 23 | /** 24 | * Start the view. 25 | */ 26 | void start(); 27 | 28 | /** 29 | * Attach a {@link InputHelper}. 30 | * 31 | * @param inputHelper 32 | * the inputHelper 33 | */ 34 | void attachMe(InputHelper inputHelper); 35 | 36 | } 37 | -------------------------------------------------------------------------------- /project/gui/src/main/java/rekit/gui/controller/Controller.java: -------------------------------------------------------------------------------- 1 | package rekit.gui.controller; 2 | 3 | import rekit.gui.View; 4 | import rekit.logic.Model; 5 | 6 | /** 7 | * This Interface defines the Controller for the MVC. 8 | * 9 | * @author Dominik Fuchss 10 | * 11 | */ 12 | public interface Controller { 13 | /** 14 | * Get the controller. 15 | * 16 | * @param model 17 | * the model 18 | * @param view 19 | * the view to attach all controls 20 | * @return the controller 21 | */ 22 | static Controller getController(Model model, View view) { 23 | return new ControllerImpl(model, view); 24 | } 25 | 26 | /** 27 | * Start the Controller. 28 | */ 29 | void start(); 30 | 31 | } 32 | -------------------------------------------------------------------------------- /project/gui/src/main/java/rekit/gui/controller/Observer.java: -------------------------------------------------------------------------------- 1 | package rekit.gui.controller; 2 | 3 | /** 4 | * This interface represents a Observer of the Observer Pattern. 5 | * 6 | * @author Dominik Fuchss 7 | * 8 | */ 9 | public interface Observer { 10 | /** 11 | * Will be invoked when the observer shall get it's update. 12 | */ 13 | void update(); 14 | } 15 | -------------------------------------------------------------------------------- /project/gui/src/main/java/rekit/gui/controller/commands/AttackCommand.java: -------------------------------------------------------------------------------- 1 | package rekit.gui.controller.commands; 2 | 3 | import rekit.config.GameConf; 4 | import rekit.logic.IScene; 5 | 6 | /** 7 | * This {@link Command} will pass the users attack indicator into the current 8 | * {@link IScene}. 9 | * 10 | * @author Dominik Fuchss 11 | * @see GameConf#CONTINUOUS_ATTACK 12 | */ 13 | public final class AttackCommand implements Command { 14 | 15 | private final CommandSupervisor supervisor; 16 | private boolean active = false; 17 | 18 | /** 19 | * Create the command by its supervisor. 20 | * 21 | * @param supervisor 22 | * the supervisor 23 | */ 24 | public AttackCommand(CommandSupervisor supervisor) { 25 | this.supervisor = supervisor; 26 | } 27 | 28 | @Override 29 | public void execute(Object... params) { 30 | if (params.length != 1 || params[0].getClass() != InputMethod.class) { 31 | throw new IllegalArgumentException("Arguments not valid for input command"); 32 | } 33 | InputMethod method = (InputMethod) params[0]; 34 | boolean newActivationState = method == InputMethod.PRESS; 35 | if (newActivationState != this.active) { 36 | this.active = newActivationState; 37 | this.supervisor.getScene().attack(this.active); 38 | } else if (this.active && GameConf.CONTINUOUS_ATTACK) { 39 | this.supervisor.getScene().attack(this.active); 40 | } 41 | } 42 | 43 | } 44 | -------------------------------------------------------------------------------- /project/gui/src/main/java/rekit/gui/controller/commands/Command.java: -------------------------------------------------------------------------------- 1 | package rekit.gui.controller.commands; 2 | 3 | import rekit.gui.controller.Controller; 4 | 5 | /** 6 | * This interface defines a command for a {@link Controller}. 7 | * 8 | * @author Dominik Fuchss 9 | * 10 | */ 11 | public interface Command { 12 | /** 13 | * Execute the command. 14 | * 15 | * @param params 16 | * the parameters 17 | */ 18 | void execute(Object... params); 19 | 20 | } 21 | -------------------------------------------------------------------------------- /project/gui/src/main/java/rekit/gui/controller/commands/CommandSupervisor.java: -------------------------------------------------------------------------------- 1 | package rekit.gui.controller.commands; 2 | 3 | import rekit.logic.IScene; 4 | import rekit.logic.Model; 5 | import rekit.logic.gameelements.entities.StateEntity; 6 | import rekit.logic.gui.menu.MenuItem; 7 | 8 | /** 9 | * This interface defines methods to get info from a {@link Model} and will be 10 | * used by {@link EntityCommand EntityCommands}. 11 | * 12 | * @author Dominik Fuchss 13 | * 14 | */ 15 | public interface CommandSupervisor { 16 | /** 17 | * Get the entity the Command is assigned to. 18 | * 19 | * @param command 20 | * the command 21 | * @return the entity for the command or {@code null} if none assigned 22 | */ 23 | StateEntity getEntity(Command command); 24 | 25 | /** 26 | * Get the menu the Command is assigned to. 27 | * 28 | * @param command 29 | * the command 30 | * @return the menu for the command or {@code null} if none assigned 31 | */ 32 | MenuItem getMenu(Command command); 33 | 34 | /** 35 | * Get the current scene. 36 | * 37 | * @return the current scene 38 | */ 39 | IScene getScene(); 40 | 41 | /** 42 | * Indicates whether commands like moving a player (no menu / basic 43 | * commands) allowed. 44 | * 45 | * @return {@code true} if allowed, {@code false} otherwise 46 | */ 47 | boolean entityCommandAllowed(); 48 | } 49 | -------------------------------------------------------------------------------- /project/gui/src/main/java/rekit/gui/controller/commands/EntityCommand.java: -------------------------------------------------------------------------------- 1 | 2 | package rekit.gui.controller.commands; 3 | 4 | import rekit.gui.controller.Controller; 5 | import rekit.logic.gameelements.entities.Entity; 6 | 7 | /** 8 | * This class defines an Command which will be executed by a {@link Controller} 9 | * and is linked to an {@link Entity}. 10 | * 11 | * @author Dominik Fuchss 12 | * @see JumpCommand 13 | * @see WalkCommand 14 | */ 15 | public abstract class EntityCommand implements Command { 16 | 17 | /** 18 | * The corresponding supervisor. 19 | */ 20 | protected final CommandSupervisor supervisor; 21 | 22 | /** 23 | * Instantiate the Command. 24 | * 25 | * @param supervisor 26 | * the supervisor 27 | */ 28 | public EntityCommand(CommandSupervisor supervisor) { 29 | if (supervisor == null) { 30 | throw new IllegalArgumentException("Supervisor cannot be null"); 31 | } 32 | this.supervisor = supervisor; 33 | } 34 | 35 | @Override 36 | public final void execute(Object... params) { 37 | if (params.length != 1 || params[0].getClass() != InputMethod.class) { 38 | throw new IllegalArgumentException("Arguments not valid for input command"); 39 | } 40 | if (this.supervisor.entityCommandAllowed()) { 41 | this.execute((InputMethod) params[0]); 42 | } 43 | } 44 | 45 | /** 46 | * Execute the command. 47 | * 48 | * @param inputMethod 49 | * the key state 50 | */ 51 | abstract void execute(InputMethod inputMethod); 52 | 53 | } 54 | -------------------------------------------------------------------------------- /project/gui/src/main/java/rekit/gui/controller/commands/FilterCommand.java: -------------------------------------------------------------------------------- 1 | package rekit.gui.controller.commands; 2 | 3 | import rekit.gui.View; 4 | import rekit.logic.Model; 5 | import rekit.logic.filters.Filter; 6 | 7 | /** 8 | * This Command Type is used for attaching and/or detaching {@link Filter 9 | * Filters} to a {@link View}.
10 | * Only for testing purposes 11 | * 12 | * @author Dominik Fuchss 13 | * 14 | */ 15 | public final class FilterCommand implements Command { 16 | /** 17 | * Indicates whether this command will enable a filter. 18 | */ 19 | private final boolean enable; 20 | /** 21 | * The model. 22 | */ 23 | private final Model model; 24 | /** 25 | * The filter. 26 | */ 27 | private final Filter filter; 28 | 29 | /** 30 | * Create a new FilterCommand. 31 | * 32 | * @param enable 33 | * indicates whether this command will enable a filter 34 | * @param model 35 | * the model 36 | * @param filter 37 | * the filter or ignored if {@code enable == false} 38 | */ 39 | public FilterCommand(boolean enable, Model model, Filter filter) { 40 | this.enable = enable; 41 | this.model = model; 42 | this.filter = filter; 43 | } 44 | 45 | @Override 46 | public void execute(Object... params) { 47 | if (this.enable) { 48 | this.model.setFilter(this.filter); 49 | } else { 50 | this.model.removeFilter(); 51 | } 52 | } 53 | 54 | } 55 | -------------------------------------------------------------------------------- /project/gui/src/main/java/rekit/gui/controller/commands/InputMethod.java: -------------------------------------------------------------------------------- 1 | package rekit.gui.controller.commands; 2 | 3 | /** 4 | * This enum is used to indicate a press or release state of a key. 5 | * 6 | * @author Dominik Fuchss 7 | * 8 | */ 9 | public enum InputMethod { 10 | /** 11 | * Key Pressed. 12 | */ 13 | PRESS, 14 | /** 15 | * Key Released. 16 | */ 17 | RELEASE 18 | } -------------------------------------------------------------------------------- /project/gui/src/main/java/rekit/gui/controller/commands/JumpCommand.java: -------------------------------------------------------------------------------- 1 | package rekit.gui.controller.commands; 2 | 3 | import rekit.logic.gameelements.entities.Entity; 4 | import rekit.logic.gameelements.entities.StateEntity; 5 | import rekit.logic.gameelements.entities.state.FallState; 6 | import rekit.logic.gameelements.entities.state.JumpState; 7 | 8 | /** 9 | * This {@link EntityCommand} will cause a Jump of an {@link Entity}. 10 | * 11 | * @author Dominik Fuchss 12 | * @author Angelo Aracri 13 | * 14 | */ 15 | public class JumpCommand extends EntityCommand { 16 | /** 17 | * Create the Command. 18 | * 19 | * @param supervisor 20 | * the supervisor 21 | */ 22 | public JumpCommand(CommandSupervisor supervisor) { 23 | super(supervisor); 24 | } 25 | 26 | @Override 27 | public void execute(InputMethod inputMethod) { 28 | StateEntity entity = this.supervisor.getEntity(this); 29 | if (inputMethod == InputMethod.PRESS) { 30 | if (entity.getEntityState().canJump()) { 31 | entity.setEntityState(new JumpState(entity)); 32 | } 33 | } else { 34 | entity.setEntityState(new FallState(entity)); 35 | } 36 | 37 | } 38 | 39 | } 40 | -------------------------------------------------------------------------------- /project/gui/src/main/java/rekit/gui/controller/commands/MenuCommand.java: -------------------------------------------------------------------------------- 1 | package rekit.gui.controller.commands; 2 | 3 | import rekit.logic.Model.GameState; 4 | import rekit.logic.gui.menu.MenuItem; 5 | 6 | /** 7 | * This class is used for the {@link GameState#MENU MenuGameState}. 8 | * 9 | * @author Matthias Schmitt 10 | * 11 | */ 12 | public class MenuCommand implements Command { 13 | 14 | /** 15 | * The direction for the command. 16 | */ 17 | private MenuDirection dir; 18 | /** 19 | * The supervisor. 20 | */ 21 | protected final CommandSupervisor supervisor; 22 | 23 | /** 24 | * Instantiate the MenuCommand. 25 | * 26 | * @param supervisor 27 | * the supervisor 28 | * @param dir 29 | * the direction 30 | */ 31 | public MenuCommand(CommandSupervisor supervisor, MenuDirection dir) { 32 | this.supervisor = supervisor; 33 | this.dir = dir; 34 | } 35 | 36 | @Override 37 | public final void execute(Object... params) { 38 | if (params.length != 1 || params[0].getClass() != InputMethod.class) { 39 | throw new IllegalArgumentException("Arguments not valid for input command"); 40 | } 41 | this.execute((InputMethod) params[0]); 42 | } 43 | 44 | /** 45 | * Execute the command. 46 | * 47 | * @param inputMethod 48 | * the key state 49 | */ 50 | public void execute(InputMethod inputMethod) { 51 | if (inputMethod != InputMethod.RELEASE) { 52 | return; 53 | } 54 | MenuItem item = this.supervisor.getMenu(this); 55 | this.dir.accept(item); 56 | } 57 | 58 | } 59 | -------------------------------------------------------------------------------- /project/gui/src/main/java/rekit/gui/controller/commands/MenuDirection.java: -------------------------------------------------------------------------------- 1 | package rekit.gui.controller.commands; 2 | 3 | import java.util.function.Consumer; 4 | 5 | import rekit.logic.gui.menu.MenuItem; 6 | 7 | /** 8 | * The enum defines the different directions of KeyPress in a Menu Context. 9 | * 10 | * @author Matthias Schmitt 11 | * @author Dominik Fuchss 12 | * 13 | */ 14 | public enum MenuDirection implements Consumer { 15 | /** 16 | * Up. 17 | */ 18 | UP(item -> item.up()), 19 | /** 20 | * Down. 21 | */ 22 | DOWN(item -> item.down()), 23 | /** 24 | * Left. 25 | */ 26 | LEFT(item -> item.left()), 27 | /** 28 | * Right. 29 | */ 30 | RIGHT(item -> item.right()), 31 | /** 32 | * Back. 33 | */ 34 | BACK(item -> item.unselect()), 35 | /** 36 | * Select. 37 | */ 38 | SELECT(item -> item.select()); 39 | /** 40 | * The action bound to the direction. 41 | */ 42 | private final Consumer action; 43 | 44 | /** 45 | * Bind action to Dir. 46 | * 47 | * @param action 48 | * the action 49 | */ 50 | MenuDirection(Consumer action) { 51 | this.action = action; 52 | } 53 | 54 | @Override 55 | public void accept(MenuItem t) { 56 | this.action.accept(t); 57 | } 58 | 59 | } 60 | -------------------------------------------------------------------------------- /project/gui/src/main/java/rekit/gui/controller/commands/PlayPauseCommand.java: -------------------------------------------------------------------------------- 1 | package rekit.gui.controller.commands; 2 | 3 | import rekit.logic.Model.GameState; 4 | 5 | /** 6 | * This class will be used while {@link GameState#INGAME ingame} to toggle 7 | * pause. 8 | * 9 | * @author Matthias Schmitt 10 | * 11 | */ 12 | public class PlayPauseCommand extends MenuCommand { 13 | /** 14 | * Create the command. 15 | * 16 | * @param supervisor 17 | * the {@link CommandSupervisor} 18 | */ 19 | public PlayPauseCommand(CommandSupervisor supervisor) { 20 | super(supervisor, null); 21 | 22 | } 23 | 24 | @Override 25 | public void execute(InputMethod inputMethod) { 26 | if (inputMethod == InputMethod.RELEASE) { 27 | this.supervisor.getScene().togglePause(); 28 | } 29 | } 30 | 31 | } 32 | -------------------------------------------------------------------------------- /project/gui/src/main/java/rekit/gui/controller/commands/WalkCommand.java: -------------------------------------------------------------------------------- 1 | package rekit.gui.controller.commands; 2 | 3 | import rekit.logic.gameelements.entities.Entity; 4 | import rekit.logic.gameelements.entities.Player; 5 | import rekit.primitives.geometry.Direction; 6 | import rekit.primitives.geometry.Vec; 7 | 8 | /** 9 | * This {@link EntityCommand} will cause a Walk of an {@link Entity}. 10 | * 11 | * @author Dominik Fuchss 12 | * @author Angelo Aracri 13 | * 14 | */ 15 | public class WalkCommand extends EntityCommand { 16 | /** 17 | * The {@link Direction} of the walk. 18 | */ 19 | private Direction dir; 20 | 21 | /** 22 | * Instantiate the WalkCommand. 23 | * 24 | * @param supervisor 25 | * the supervisor 26 | * @param dir 27 | * the direction 28 | */ 29 | public WalkCommand(CommandSupervisor supervisor, Direction dir) { 30 | super(supervisor); 31 | this.dir = dir; 32 | } 33 | 34 | @Override 35 | public void execute(InputMethod inputMethod) { 36 | if (inputMethod == InputMethod.RELEASE) { 37 | return; 38 | } 39 | Entity entity = this.supervisor.getEntity(this); 40 | 41 | // if entity is faster than maximum BEFORE applying speed, then abort 42 | if (Math.abs(entity.getVel().x) > Player.WALK_MAX_SPEED) { 43 | if (Math.signum(this.dir.getVector().x) == Math.signum(entity.getVel().x)) { 44 | return; 45 | } 46 | } 47 | 48 | // Update x velocity with corresponding direction and acceleration 49 | Vec newVel = entity.getVel().addX(this.dir.getVector().x * Player.WALK_ACCEL); 50 | 51 | // check if max speed achieved 52 | if (Math.abs(newVel.x) > Player.WALK_MAX_SPEED) { 53 | newVel = newVel.setX(Math.signum(newVel.x) * Player.WALK_MAX_SPEED); 54 | } 55 | 56 | // Save new velocity 57 | entity.setVel(newVel); 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /project/gui/src/main/resources/images/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rekit-group/rekit-game/64d489145f811f6d2a8cdc8ba062e097f7a66c05/project/gui/src/main/resources/images/icon.png -------------------------------------------------------------------------------- /project/logic/.gitignore: -------------------------------------------------------------------------------- 1 | /target/ 2 | -------------------------------------------------------------------------------- /project/logic/pom.xml: -------------------------------------------------------------------------------- 1 | 3 | 4.0.0 4 | 5 | rekit 6 | parent 7 | 1.3 8 | 9 | logic 10 | 11 | 12 | rekit 13 | global 14 | 15 | 16 | rekit 17 | persistence 18 | 19 | 20 | org.springframework 21 | spring-core 22 | 23 | 24 | -------------------------------------------------------------------------------- /project/logic/src/main/java/rekit/logic/ILevelScene.java: -------------------------------------------------------------------------------- 1 | package rekit.logic; 2 | 3 | import rekit.logic.gameelements.entities.Player; 4 | import rekit.logic.level.Level; 5 | 6 | /** 7 | * This interface extends {@link IScene} and adds necessary methods to 8 | * encapsulate Levels. 9 | * 10 | * @author Matthias Schmitt 11 | * 12 | */ 13 | public interface ILevelScene extends IScene { 14 | /** 15 | * Get the current player of {@code null} if none set. 16 | * 17 | * @return the current player of {@code null} 18 | */ 19 | Player getPlayer(); 20 | 21 | /** 22 | * Get the associated level. 23 | * 24 | * @return the level 25 | */ 26 | Level getLevel(); 27 | 28 | /** 29 | * End a level. 30 | * 31 | * @param won 32 | * indicates whether successful or died 33 | */ 34 | void end(boolean won); 35 | 36 | /** 37 | * Indicates whether the level has ended. 38 | * 39 | * @return {@code true} if ended, {@code false} otherwise 40 | */ 41 | boolean hasEnded(); 42 | 43 | /** 44 | * This method indicates whether the offset is set to wildcard (any position 45 | * is allowed / no elements will be deleted (because of their position)) 46 | * 47 | * @return {@code true} if activated, {@code false} otherwise 48 | */ 49 | boolean isOffsetWildCard(); 50 | 51 | /** 52 | * Set return value of {@link #isOffsetWildCard()}. 53 | * 54 | * @param wildcard 55 | * the value 56 | */ 57 | void setOffsetWildCard(boolean wildcard); 58 | 59 | } 60 | -------------------------------------------------------------------------------- /project/logic/src/main/java/rekit/logic/filters/InvertedMode.java: -------------------------------------------------------------------------------- 1 | package rekit.logic.filters; 2 | 3 | import rekit.primitives.image.RGBAColor; 4 | import rekit.util.ReflectUtils.LoadMe; 5 | 6 | /** 7 | * This filter realizes a filter which will invert all colors. 8 | * 9 | * @author Dominik Fuchss 10 | * 11 | */ 12 | @LoadMe 13 | public class InvertedMode implements Filter { 14 | 15 | @Override 16 | public RGBAColor apply(RGBAColor color) { 17 | return new RGBAColor(255 - color.red, 255 - color.green, 255 - color.blue, color.alpha == 255 ? 255 : 255 - color.alpha); 18 | } 19 | 20 | @Override 21 | public boolean isApplyPixel() { 22 | return true; 23 | } 24 | 25 | @Override 26 | public boolean isApplyImage() { 27 | return false; 28 | } 29 | 30 | } -------------------------------------------------------------------------------- /project/logic/src/main/java/rekit/logic/gameelements/FixedCameraTarget.java: -------------------------------------------------------------------------------- 1 | package rekit.logic.gameelements; 2 | 3 | import rekit.core.CameraTarget; 4 | 5 | /** 6 | * 7 | * This class can be used for set the camera fixed (e.g. for BossRooms etc.) 8 | * 9 | */ 10 | public final class FixedCameraTarget implements CameraTarget { 11 | /** 12 | * The camera offset. 13 | */ 14 | private float cameraOffset; 15 | 16 | /** 17 | * Create by fixed camera offset. 18 | * 19 | * @param cameraOffset 20 | * the camera offset 21 | */ 22 | public FixedCameraTarget(float cameraOffset) { 23 | this.cameraOffset = cameraOffset; 24 | } 25 | 26 | /** 27 | * Get the camera offset. 28 | */ 29 | @Override 30 | public float getCameraOffset() { 31 | return this.cameraOffset; 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /project/logic/src/main/java/rekit/logic/gameelements/RangeCameraTarget.java: -------------------------------------------------------------------------------- 1 | package rekit.logic.gameelements; 2 | 3 | import rekit.core.CameraTarget; 4 | 5 | /** 6 | * 7 | * This class can be used for set the range camera target (e.g. for BossRooms 8 | * etc.). 9 | * 10 | */ 11 | public final class RangeCameraTarget implements CameraTarget { 12 | 13 | private final CameraTarget hint; 14 | private final float min; 15 | private final float max; 16 | 17 | /** 18 | * Create by range and hint target. 19 | * 20 | * @param min 21 | * the minimum value of {@link #getCameraOffset()} 22 | * @param max 23 | * the maximum value of {@link #getCameraOffset()} 24 | * @param hint 25 | * the target which shall focused within the range 26 | */ 27 | public RangeCameraTarget(float min, float max, CameraTarget hint) { 28 | this.min = min; 29 | this.max = max; 30 | this.hint = hint; 31 | } 32 | 33 | @Override 34 | public float getCameraOffset() { 35 | float hint = this.hint.getCameraOffset(); 36 | if (hint < this.min) { 37 | return this.min; 38 | } 39 | if (hint > this.max) { 40 | return this.max; 41 | } 42 | return hint; 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /project/logic/src/main/java/rekit/logic/gameelements/entities/StateEntity.java: -------------------------------------------------------------------------------- 1 | package rekit.logic.gameelements.entities; 2 | 3 | import rekit.core.Team; 4 | import rekit.logic.gameelements.entities.state.DefaultState; 5 | import rekit.logic.gameelements.entities.state.EntityState; 6 | import rekit.primitives.geometry.Direction; 7 | import rekit.primitives.geometry.Frame; 8 | import rekit.primitives.geometry.Vec; 9 | import rekit.util.state.State; 10 | 11 | /** 12 | * This class represents a special kind of {@link Entity}, a {@link Entity} with 13 | * inner state. All will be managed by this {@link State}. 14 | * 15 | * @author Dominik Fuchss 16 | * 17 | */ 18 | public abstract class StateEntity extends Entity { 19 | 20 | /** 21 | * The current State the Entity is in and determines the jump behavior. 22 | */ 23 | private EntityState entityState; 24 | 25 | /** 26 | * Constructor that initializes attributes and takes a start position. 27 | * 28 | * @param startPos 29 | * the position this entity shall be in 30 | * @param vel 31 | * the velocity 32 | * @param size 33 | * the size 34 | * @param team 35 | * the team 36 | */ 37 | protected StateEntity(Vec startPos, Vec vel, Vec size, Team team) { 38 | super(startPos, vel, size, team); 39 | // Set to default state 40 | this.setEntityState(new DefaultState(this)); 41 | } 42 | 43 | /** 44 | * Set the Entities EntitiyState that determines its jump behavior. 45 | * 46 | * @param value 47 | * the new EntityState 48 | */ 49 | public final void setEntityState(EntityState value) { 50 | this.entityState = value; 51 | } 52 | 53 | /** 54 | * Return the Entities current EntitiyState that determines its jump 55 | * behavior. 56 | * 57 | * @return the state 58 | */ 59 | public final EntityState getEntityState() { 60 | return this.entityState; 61 | } 62 | 63 | /** 64 | * This method will calculate the next position of the Entity depending on 65 | * the velocity. 66 | */ 67 | @Override 68 | protected final void innerLogicLoop() { 69 | super.innerLogicLoop(); 70 | this.entityState.logicLoop(); 71 | } 72 | 73 | @Override 74 | public void collidedWithSolid(Frame collision, Direction dir) { 75 | super.collidedWithSolid(collision, dir); 76 | if (dir == Direction.UP) { 77 | this.getEntityState().floorCollision(); 78 | } 79 | } 80 | } 81 | -------------------------------------------------------------------------------- /project/logic/src/main/java/rekit/logic/gameelements/entities/pickups/DefaultCoin.java: -------------------------------------------------------------------------------- 1 | package rekit.logic.gameelements.entities.pickups; 2 | 3 | import rekit.logic.gameelements.type.Coin; 4 | import rekit.primitives.geometry.Vec; 5 | import rekit.primitives.image.RGBAColor; 6 | import rekit.util.ReflectUtils.LoadMe; 7 | 8 | /** 9 | * This class represents default coins. 10 | * 11 | * 12 | */ 13 | @LoadMe 14 | public class DefaultCoin extends Coin { 15 | /** 16 | * Prototype constructor. 17 | */ 18 | public DefaultCoin() { 19 | super(); 20 | } 21 | 22 | /** 23 | * Constructor with position. 24 | * 25 | * @param startPos 26 | * the position. 27 | */ 28 | protected DefaultCoin(Vec startPos) { 29 | super(startPos); 30 | } 31 | 32 | /** 33 | * The default color of the coin. 34 | */ 35 | private static RGBAColor color = new RGBAColor(232, 214, 16); 36 | /** 37 | * The shadow color of the coin. 38 | */ 39 | private static RGBAColor darkColor = new RGBAColor(192, 174, 6); 40 | 41 | @Override 42 | protected RGBAColor getColor() { 43 | return DefaultCoin.color; 44 | } 45 | 46 | @Override 47 | protected RGBAColor getDarkerColor() { 48 | return DefaultCoin.darkColor; 49 | } 50 | 51 | @Override 52 | protected int getValue() { 53 | return 10; 54 | } 55 | 56 | @Override 57 | public DefaultCoin create(Vec startPos, String... options) { 58 | return new DefaultCoin(startPos); 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /project/logic/src/main/java/rekit/logic/gameelements/entities/pickups/Life.java: -------------------------------------------------------------------------------- 1 | package rekit.logic.gameelements.entities.pickups; 2 | 3 | import rekit.core.GameGrid; 4 | import rekit.logic.gameelements.GameElement; 5 | import rekit.logic.gameelements.type.Pickup; 6 | import rekit.primitives.geometry.Vec; 7 | import rekit.util.ReflectUtils.LoadMe; 8 | 9 | /** 10 | * This class defines a simple {@link Pickup}; a Life which will give the 11 | * player lives. 12 | */ 13 | @LoadMe 14 | public final class Life extends Pickup { 15 | /** 16 | * Prototype Constructor. 17 | */ 18 | public Life() { 19 | super(); 20 | } 21 | 22 | /** 23 | * Instantiate a Life by start position. 24 | * 25 | * @param startPos 26 | * the start position 27 | */ 28 | public Life(Vec startPos) { 29 | super(startPos, new Vec(), new Vec(1)); 30 | } 31 | 32 | @Override 33 | public void perform(GameElement collector) { 34 | collector.addDamage(-1); 35 | this.destroy(); 36 | } 37 | 38 | @Override 39 | public void internalRender(GameGrid f) { 40 | f.drawImage(this.getPos(), this.getSize(), "mrRekt_glasses_left.png"); 41 | } 42 | 43 | @Override 44 | public Life create(Vec startPos, String... options) { 45 | return new Life(startPos); 46 | } 47 | 48 | } 49 | -------------------------------------------------------------------------------- /project/logic/src/main/java/rekit/logic/gameelements/entities/state/DefaultState.java: -------------------------------------------------------------------------------- 1 | package rekit.logic.gameelements.entities.state; 2 | 3 | import rekit.logic.gameelements.entities.StateEntity; 4 | 5 | /** 6 | * The default state a entity is in after initialization. Represents the state 7 | * where a player can jump 8 | * 9 | * @author Angelo Aracri 10 | */ 11 | public class DefaultState extends EntityState { 12 | /** 13 | * Create State. 14 | * 15 | * @param entitiy 16 | * the entity 17 | */ 18 | public DefaultState(StateEntity entitiy) { 19 | super(entitiy); 20 | } 21 | 22 | } 23 | -------------------------------------------------------------------------------- /project/logic/src/main/java/rekit/logic/gameelements/entities/state/EntityState.java: -------------------------------------------------------------------------------- 1 | package rekit.logic.gameelements.entities.state; 2 | 3 | import rekit.logic.gameelements.entities.StateEntity; 4 | 5 | /** 6 | * The abstract state an entity can be in. EntityStates determine the 7 | * Entities jumping behavior. 8 | * 9 | * @author Angelo Aracri 10 | */ 11 | public abstract class EntityState { 12 | /** 13 | * The entity. 14 | */ 15 | protected final StateEntity entity; 16 | 17 | /** 18 | * Create State. 19 | * 20 | * @param entity 21 | * the entity 22 | */ 23 | public EntityState(StateEntity entity) { 24 | this.entity = entity; 25 | } 26 | 27 | /** 28 | * Indicates whether the entity can jump. 29 | * 30 | * @return {@code true} if jumping is allowed, {@code false} otherwise 31 | */ 32 | public boolean canJump() { 33 | return true; 34 | } 35 | 36 | /** 37 | * Logic loop of state. 38 | * 39 | */ 40 | public void logicLoop() { 41 | // Do nothing 42 | } 43 | 44 | /** 45 | * This method will be invoked when this entity collides with the floor. 46 | */ 47 | public void floorCollision() { 48 | // Do nothing 49 | } 50 | 51 | } 52 | -------------------------------------------------------------------------------- /project/logic/src/main/java/rekit/logic/gameelements/entities/state/FallState.java: -------------------------------------------------------------------------------- 1 | package rekit.logic.gameelements.entities.state; 2 | 3 | import rekit.logic.gameelements.entities.StateEntity; 4 | 5 | /** 6 | * The default state a entity is in after jumping. Represents the state where a 7 | * player can not jump 8 | * 9 | */ 10 | public class FallState extends EntityState { 11 | /** 12 | * Create State. 13 | * 14 | * @param entity 15 | * the entity 16 | */ 17 | public FallState(StateEntity entity) { 18 | super(entity); 19 | } 20 | 21 | @Override 22 | public boolean canJump() { 23 | return false; 24 | } 25 | 26 | @Override 27 | public void floorCollision() { 28 | this.entity.setEntityState(new DefaultState(this.entity)); 29 | } 30 | 31 | } 32 | -------------------------------------------------------------------------------- /project/logic/src/main/java/rekit/logic/gameelements/entities/state/JumpState.java: -------------------------------------------------------------------------------- 1 | package rekit.logic.gameelements.entities.state; 2 | 3 | import rekit.logic.gameelements.entities.Player; 4 | import rekit.logic.gameelements.entities.StateEntity; 5 | import rekit.primitives.geometry.Vec; 6 | import rekit.primitives.time.Timer; 7 | 8 | /** 9 | * The jumping state a entity is in upon jumping until landing Represents the 10 | * state where a player can not jump anymore. 11 | * 12 | * @author Angelo Aracri 13 | */ 14 | public class JumpState extends EntityState { 15 | private Timer timer; 16 | 17 | /** 18 | * Create State. 19 | * 20 | * @param entity 21 | * the entity 22 | */ 23 | public JumpState(StateEntity entity) { 24 | super(entity); 25 | this.timer = new Timer(Player.JUMP_TIME); 26 | } 27 | 28 | @Override 29 | public boolean canJump() { 30 | return false; 31 | } 32 | 33 | @Override 34 | public void floorCollision() { 35 | this.entity.setEntityState(new DefaultState(this.entity)); 36 | } 37 | 38 | @Override 39 | public void logicLoop() { 40 | this.timer.logicLoop(); 41 | if (!this.timer.timeUp() && this.entity.getVel().y > Player.JUMP_BOOST) { 42 | this.entity.setVel(new Vec(this.entity.getVel().x, Player.JUMP_BOOST)); 43 | } else if (this.timer.timeUp()) { 44 | this.entity.setEntityState(new FallState(this.entity)); 45 | } 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /project/logic/src/main/java/rekit/logic/gameelements/entities/state/NotInitializedState.java: -------------------------------------------------------------------------------- 1 | package rekit.logic.gameelements.entities.state; 2 | 3 | import rekit.config.GameConf; 4 | import rekit.core.Team; 5 | import rekit.logic.gameelements.entities.Entity; 6 | import rekit.logic.gameelements.entities.StateEntity; 7 | 8 | /** 9 | * This state is used for all prototypes of {@link Entity}.
10 | * This state will print to the syserr that the wrong constructor 11 | * {@link Entity#Entity(Team team)} was used to create this element 12 | * 13 | * @author Dominik Fuchss 14 | * 15 | */ 16 | public class NotInitializedState extends EntityState { 17 | /** 18 | * Create the State. 19 | * 20 | * @param entity 21 | * the entity 22 | */ 23 | public NotInitializedState(StateEntity entity) { 24 | super(entity); 25 | } 26 | 27 | /** 28 | * Indicates whether message was written. 29 | */ 30 | private boolean done = false; 31 | 32 | @Override 33 | public void logicLoop() { 34 | if (this.done) { 35 | return; 36 | } 37 | this.done = true; 38 | GameConf.GAME_LOGGER.error("Entity " + this.entity.getClass().getSimpleName() + ": State: NotInitializedState"); 39 | GameConf.GAME_LOGGER.error( 40 | "Entity of type " + this.entity.getClass().getSimpleName() + " is not initialized; maybe you have used the wrong constructor of Entity!"); 41 | } 42 | 43 | @Override 44 | public void floorCollision() { 45 | if (this.done) { 46 | return; 47 | } 48 | this.done = true; 49 | GameConf.GAME_LOGGER.error("Entity " + this.entity.getClass().getSimpleName() + ": State: NotInitializedState"); 50 | GameConf.GAME_LOGGER.error( 51 | "Entity of type " + this.entity.getClass().getSimpleName() + " is not initialized; maybe you have used the wrong constructor of Entity!"); 52 | 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /project/logic/src/main/java/rekit/logic/gameelements/inanimate/InanimateBox.java: -------------------------------------------------------------------------------- 1 | package rekit.logic.gameelements.inanimate; 2 | 3 | import rekit.config.GameConf; 4 | import rekit.core.GameGrid; 5 | import rekit.primitives.geometry.Vec; 6 | import rekit.primitives.image.RGBAColor; 7 | 8 | /** 9 | * 10 | * This is the default implementation of an inanimate in the game (no ground). 11 | * 12 | */ 13 | public class InanimateBox extends Inanimate { 14 | /** 15 | * Create an InanimateBox. 16 | * 17 | * @param pos 18 | * the position 19 | * @param size 20 | * the size 21 | * @param color 22 | * the color 23 | */ 24 | protected InanimateBox(Vec pos, Vec size, RGBAColor color) { 25 | super(pos, size, color); 26 | } 27 | 28 | @Override 29 | public void internalRender(GameGrid f) { 30 | f.drawRectangle(this.getPos(), this.getSize(), this.color); 31 | 32 | RGBAColor darkColor = new RGBAColor(this.color.red - 30, this.color.green - 30, this.color.blue - 30, this.color.alpha); 33 | float sizeDiff = -0.2f; 34 | 35 | f.drawRectangle(this.getPos(), this.getSize(), darkColor); 36 | f.drawRectangle(this.getPos(), this.getSize().add(new Vec(sizeDiff)), this.color); 37 | 38 | f.drawRectangle(this.getPos(), this.getSize().scalar(0.5f), darkColor); 39 | } 40 | 41 | /** 42 | * Create a new InanimateBox. 43 | * 44 | * @param pos 45 | * the position 46 | * @return the new Inanimate 47 | */ 48 | public static Inanimate staticCreate(Vec pos) { 49 | int randCol = (int) (GameConf.PRNG.nextDouble() * 60 + 50); 50 | return new InanimateBox(pos, new Vec(1, 1), new RGBAColor(randCol, randCol, randCol, 255)); 51 | } 52 | 53 | } 54 | -------------------------------------------------------------------------------- /project/logic/src/main/java/rekit/logic/gameelements/inanimate/InanimateDoor.java: -------------------------------------------------------------------------------- 1 | package rekit.logic.gameelements.inanimate; 2 | 3 | import rekit.core.GameGrid; 4 | import rekit.primitives.geometry.Vec; 5 | import rekit.primitives.image.RGBAColor; 6 | 7 | /** 8 | * 9 | * This is the default implementation of an inanimate door in the game. 10 | * 11 | */ 12 | public class InanimateDoor extends InanimateBox { 13 | /** 14 | * Create a new door. 15 | * 16 | * @param pos 17 | * the position 18 | */ 19 | public InanimateDoor(Vec pos) { 20 | super(pos, new Vec(1, 7), new RGBAColor(130, 130, 130, 255)); 21 | } 22 | 23 | @Override 24 | public void internalRender(GameGrid f) { 25 | f.drawRectangle(this.getPos(), this.getSize(), this.color); 26 | 27 | Vec start = this.getPos().add(this.getSize().scalar(-(1 / 2f))).add(new Vec(0.1f, 0.1f)); 28 | Vec end = start.add(this.getSize()).add(new Vec(-0.2f, -0.2f)); 29 | 30 | for (float x = start.x; x <= end.x; x += 0.2) { 31 | f.drawCircle(new Vec(x, start.y), new Vec(0.12f), new RGBAColor(80, 80, 80)); 32 | f.drawCircle(new Vec(x, end.y), new Vec(0.12f), new RGBAColor(80, 80, 80)); 33 | } 34 | 35 | for (float y = start.y; y <= end.y; y += 0.2) { 36 | f.drawCircle(new Vec(start.x, y), new Vec(0.12f), new RGBAColor(80, 80, 80)); 37 | f.drawCircle(new Vec(end.x, y), new Vec(0.12f), new RGBAColor(80, 80, 80)); 38 | } 39 | } 40 | 41 | } 42 | -------------------------------------------------------------------------------- /project/logic/src/main/java/rekit/logic/gameelements/inanimate/InanimateTrigger.java: -------------------------------------------------------------------------------- 1 | package rekit.logic.gameelements.inanimate; 2 | 3 | import rekit.core.GameGrid; 4 | import rekit.core.Team; 5 | import rekit.logic.gameelements.GameElement; 6 | import rekit.logic.gameelements.GameElementFactory; 7 | import rekit.primitives.geometry.Direction; 8 | import rekit.primitives.geometry.Vec; 9 | import rekit.primitives.image.RGBAColor; 10 | 11 | /** 12 | * 13 | * This is the default implementation of an inanimate trigger in the game. 14 | * 15 | */ 16 | public class InanimateTrigger extends Inanimate { 17 | /** 18 | * Utility function for easy use with lambdas. 19 | * 20 | * @param pos 21 | * the position 22 | * @param size 23 | * the size 24 | * @param onPerform 25 | * {@link #perform()} 26 | */ 27 | public static void createTrigger(Vec pos, Vec size, Runnable onPerform) { 28 | GameElementFactory.generate(new InanimateTrigger(pos, size) { 29 | @Override 30 | public void perform() { 31 | onPerform.run(); 32 | } 33 | }); 34 | } 35 | 36 | /** 37 | * Create the trigger. 38 | * 39 | * @param pos 40 | * the position 41 | * @param size 42 | * the size 43 | */ 44 | public InanimateTrigger(Vec pos, Vec size) { 45 | super(pos, size, new RGBAColor(0, 0, 0, 255), Team.TRIGGER); 46 | } 47 | 48 | @Override 49 | public void internalRender(GameGrid f) { 50 | // Do nothing 51 | } 52 | 53 | @Override 54 | public final void reactToCollision(GameElement element, Direction dir) { 55 | if (this.getTeam().isHostile(element.getTeam())) { 56 | this.perform(); 57 | // destroy invisible InanimateTrigger 58 | this.destroy(); 59 | } 60 | } 61 | 62 | /** 63 | * Perform trigger-action. 64 | */ 65 | public void perform() { 66 | 67 | } 68 | 69 | } 70 | -------------------------------------------------------------------------------- /project/logic/src/main/java/rekit/logic/gameelements/particles/DamageParticle.java: -------------------------------------------------------------------------------- 1 | package rekit.logic.gameelements.particles; 2 | 3 | import rekit.core.Team; 4 | import rekit.logic.gameelements.GameElement; 5 | import rekit.logic.gameelements.entities.Player; 6 | import rekit.primitives.geometry.Direction; 7 | import rekit.primitives.geometry.Frame; 8 | import rekit.primitives.geometry.Vec; 9 | 10 | /** 11 | * Regular {@link Particle} with the only difference, that it damages the 12 | * {@link Player} upon collision. 13 | * 14 | * @author Angelo Aracri 15 | */ 16 | public abstract class DamageParticle extends Particle { 17 | /** 18 | * Constructor that sets the {@link DamageParticle DamageParticles} 19 | * {@link Team} to {@link Team#ENEMY}. 20 | */ 21 | public DamageParticle() { 22 | super(); 23 | this.team = Team.ENEMY; 24 | } 25 | 26 | @Override 27 | public void reactToCollision(GameElement element, Direction dir) { 28 | if (this.getTeam().isHostile(element.getTeam())) { 29 | element.addDamage(1); 30 | } 31 | } 32 | 33 | @Override 34 | public abstract DamageParticle create(); 35 | 36 | @Override 37 | public Frame getFrame() { 38 | Vec v1 = this.getPos().add(this.getSize().scalar(-0.2f)); 39 | Vec v2 = this.getPos().add(this.getSize().scalar(0.2f)); 40 | return new Frame(v1, v2); 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /project/logic/src/main/java/rekit/logic/gameelements/particles/ParticleSpawnerOptionParser.java: -------------------------------------------------------------------------------- 1 | package rekit.logic.gameelements.particles; 2 | 3 | import org.fuchss.configuration.parser.Parser; 4 | 5 | /** 6 | * This class realize a parser for a {@link ParticleSpawnerOption}. 7 | * 8 | * @author Dominik Fuchss 9 | * 10 | */ 11 | public final class ParticleSpawnerOptionParser implements Parser { 12 | /** 13 | * The Float-Regex which will be used. 14 | */ 15 | private static final String FLOAT_REGEX = "(-|\\+)?[0-9]+\\.[0-9]+(f|F)"; 16 | 17 | @Override 18 | public synchronized Object parseIt(String definition, String[] path) throws Exception { 19 | ParticleSpawnerOption opt = null; 20 | if (definition.matches("(" + ParticleSpawnerOptionParser.FLOAT_REGEX + ",){3}" + ParticleSpawnerOptionParser.FLOAT_REGEX)) { 21 | // 4 Params 22 | String[] floats = definition.split(","); 23 | opt = new ParticleSpawnerOption(// 24 | Float.parseFloat(floats[0]), Float.parseFloat(floats[1]), // 25 | Float.parseFloat(floats[2]), Float.parseFloat(floats[3])); 26 | } else if (definition.matches(ParticleSpawnerOptionParser.FLOAT_REGEX + "," + ParticleSpawnerOptionParser.FLOAT_REGEX)) { 27 | // 2 Params 28 | String[] floats = definition.split(","); 29 | opt = new ParticleSpawnerOption(Float.parseFloat(floats[0]), Float.parseFloat(floats[1])); 30 | } else if (definition.matches(ParticleSpawnerOptionParser.FLOAT_REGEX)) { 31 | // 1 Param 32 | opt = new ParticleSpawnerOption(Float.parseFloat(definition)); 33 | } 34 | 35 | return opt; 36 | } 37 | 38 | } -------------------------------------------------------------------------------- /project/logic/src/main/java/rekit/logic/gameelements/particles/TextParticle.java: -------------------------------------------------------------------------------- 1 | package rekit.logic.gameelements.particles; 2 | 3 | import java.awt.Font; 4 | 5 | import rekit.config.GameConf; 6 | import rekit.core.GameGrid; 7 | import rekit.primitives.TextOptions; 8 | import rekit.primitives.geometry.Vec; 9 | 10 | /** 11 | * {@link Particle} that shows a text, that can be specified via 12 | * {@link TextParticle#setText(String)} 13 | * 14 | * @author Angelo Aracri 15 | */ 16 | public class TextParticle extends Particle { 17 | 18 | /** 19 | * The internal text of the {@link Particle} that will be rendered 20 | */ 21 | private String text; 22 | 23 | /** 24 | * The options of the {@link TextParticle#text}. 25 | */ 26 | private TextOptions options; 27 | 28 | /** 29 | * Create a TextParticle with standard font. 30 | */ 31 | public TextParticle() { 32 | this(19); 33 | } 34 | 35 | /** 36 | * Create a TextParticle and set font size. 37 | * 38 | * @param fontSize 39 | * the font size 40 | */ 41 | public TextParticle(int fontSize) { 42 | super(); 43 | this.options = new TextOptions(new Vec(-0.6f, 0), fontSize, null, GameConf.GAME_TEXT_FONT, Font.BOLD); 44 | } 45 | 46 | /** 47 | * Setter for the internally used {@link TextParticle#text} that will be 48 | * rendered. 49 | * 50 | * @param text 51 | * the text. 52 | */ 53 | public void setText(String text) { 54 | this.text = text; 55 | } 56 | 57 | /** 58 | * Setter for the internally used font size. 59 | * 60 | * @param size 61 | * the font size. 62 | */ 63 | public void setSize(int size) { 64 | this.options = this.options.setHeight(size); 65 | } 66 | 67 | @Override 68 | public void internalRender(GameGrid f) { 69 | this.options.setColor(this.currentCol); 70 | f.drawText(this.getPos(), this.text, this.options, true); 71 | } 72 | 73 | @Override 74 | public TextParticle create() { 75 | TextParticle newInstance = new TextParticle(this.options.getHeight()); 76 | newInstance.setText(this.text); 77 | return newInstance; 78 | } 79 | } 80 | -------------------------------------------------------------------------------- /project/logic/src/main/java/rekit/logic/gameelements/particles/TextParticleSpawner.java: -------------------------------------------------------------------------------- 1 | package rekit.logic.gameelements.particles; 2 | 3 | /** 4 | * A custom implementation of the {@link ParticleSpawner} that sets the settings 5 | * for an internal {@link TextParticle} that it can 6 | * {@link ParticleSpawner#spawn}. 7 | * 8 | * @author Angelo Aracri 9 | */ 10 | public final class TextParticleSpawner extends ParticleSpawner { 11 | 12 | /** 13 | * The constructor that sets the required settings 14 | */ 15 | public TextParticleSpawner() { 16 | this.amountMin = this.amountMax = 1; 17 | this.angle = new ParticleSpawnerOption(0); 18 | this.colorR = new ParticleSpawnerOption(150); 19 | this.colorG = new ParticleSpawnerOption(30); 20 | this.colorB = new ParticleSpawnerOption(30); 21 | this.colorA = new ParticleSpawnerOption(255, -255); 22 | this.speed = new ParticleSpawnerOption(1, 0.5f); 23 | this.timeMin = this.timeMax = 1; 24 | this.particlePrototype = new TextParticle(); 25 | } 26 | 27 | /** 28 | * Sets the text of the {@link TextParticle}. 29 | * 30 | * @param text 31 | * the text 32 | */ 33 | public void setText(String text) { 34 | ((TextParticle) this.particlePrototype).setText(text); 35 | } 36 | 37 | /** 38 | * Sets the text size of the {@link TextParticle}. 39 | * 40 | * @param size 41 | * the size 42 | */ 43 | public void setSize(int size) { 44 | ((TextParticle) this.particlePrototype).setSize(size); 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /project/logic/src/main/java/rekit/logic/gameelements/type/DynamicInanimate.java: -------------------------------------------------------------------------------- 1 | package rekit.logic.gameelements.type; 2 | 3 | import java.util.Set; 4 | 5 | import rekit.config.GameConf; 6 | import rekit.logic.gameelements.GameElement; 7 | import rekit.logic.gameelements.inanimate.Inanimate; 8 | import rekit.persistence.ModManager; 9 | import rekit.primitives.geometry.Vec; 10 | import rekit.primitives.image.RGBAColor; 11 | import rekit.util.ReflectUtils; 12 | import rekit.util.ReflectUtils.LoadMe; 13 | 14 | /** 15 | * 16 | * This class is the parent class of all dynamically loaded Inanimate. 17 | * 18 | */ 19 | public abstract class DynamicInanimate extends Inanimate { 20 | 21 | /** 22 | * Prototype Constructor. 23 | */ 24 | protected DynamicInanimate() { 25 | super(new Vec(), new Vec(1), new RGBAColor(0, 0, 0, 255)); 26 | } 27 | 28 | /** 29 | * Create an inanimate. 30 | * 31 | * @param pos 32 | * the position 33 | * @param size 34 | * the size 35 | * @param color 36 | * the color 37 | */ 38 | protected DynamicInanimate(Vec pos, Vec size, RGBAColor color) { 39 | super(pos, size, color); 40 | } 41 | 42 | /** 43 | * Load all dynamic inanimate-prototypes. 44 | * 45 | * @return a set of dynamic inanimate-prototypes 46 | * @see LoadMe 47 | */ 48 | public static Set getPrototypes() { 49 | return ReflectUtils.loadInstances(GameConf.SEARCH_PATH, ModManager.SYSLOADER, DynamicInanimate.class); 50 | } 51 | 52 | @Override 53 | public abstract DynamicInanimate create(Vec startPos, String... options); 54 | } 55 | -------------------------------------------------------------------------------- /project/logic/src/main/java/rekit/logic/gameelements/type/Enemy.java: -------------------------------------------------------------------------------- 1 | package rekit.logic.gameelements.type; 2 | 3 | import java.util.Set; 4 | 5 | import rekit.config.GameConf; 6 | import rekit.core.Team; 7 | import rekit.logic.gameelements.GameElement; 8 | import rekit.logic.gameelements.entities.Entity; 9 | import rekit.persistence.ModManager; 10 | import rekit.primitives.geometry.Vec; 11 | import rekit.util.ReflectUtils; 12 | import rekit.util.ReflectUtils.LoadMe; 13 | 14 | /** 15 | * This class is the parent class of all Enemies in the game. 16 | */ 17 | @Group 18 | public abstract class Enemy extends Entity { 19 | /** 20 | * Load all Enemies. 21 | * 22 | * @return a set of enemies 23 | * @see LoadMe 24 | */ 25 | public static final Set getPrototypes() { 26 | return ReflectUtils.loadInstances(GameConf.SEARCH_PATH, ModManager.SYSLOADER, Enemy.class); 27 | } 28 | 29 | /** 30 | * Prototype Constructor. 31 | */ 32 | protected Enemy() { 33 | super(Team.ENEMY); 34 | } 35 | 36 | @Override 37 | public abstract Enemy create(Vec startPos, String... options); 38 | 39 | /** 40 | * Create an Enemy. 41 | * 42 | * @param startPos 43 | * the start pos 44 | * @param vel 45 | * the start velocity 46 | * @param size 47 | * the size 48 | */ 49 | protected Enemy(Vec startPos, Vec vel, Vec size) { 50 | super(startPos, vel, size, Team.ENEMY); 51 | } 52 | 53 | } 54 | -------------------------------------------------------------------------------- /project/logic/src/main/java/rekit/logic/gameelements/type/Group.java: -------------------------------------------------------------------------------- 1 | package rekit.logic.gameelements.type; 2 | 3 | import java.lang.annotation.Documented; 4 | import java.lang.annotation.Retention; 5 | import java.lang.annotation.RetentionPolicy; 6 | 7 | import rekit.logic.gameelements.GameElementFactory; 8 | 9 | /** 10 | * This annotation defines a group. If an abstract class has this annotation, 11 | * this class is expected to have a static method {@code Set getPrototypes()} 13 | * 14 | * @author Dominik Fuchss 15 | * 16 | */ 17 | @Retention(RetentionPolicy.RUNTIME) 18 | @Documented 19 | public @interface Group { 20 | /** 21 | * Get the name of the group. If unset {@link GameElementFactory} will use 22 | * the classes SimpleName. 23 | * 24 | * @return the name of the group 25 | */ 26 | String value() default ""; 27 | } 28 | -------------------------------------------------------------------------------- /project/logic/src/main/java/rekit/logic/gameelements/type/Pickup.java: -------------------------------------------------------------------------------- 1 | package rekit.logic.gameelements.type; 2 | 3 | import java.util.Set; 4 | 5 | import rekit.config.GameConf; 6 | import rekit.core.Team; 7 | import rekit.logic.gameelements.GameElement; 8 | import rekit.logic.gameelements.entities.Entity; 9 | import rekit.persistence.ModManager; 10 | import rekit.primitives.geometry.Direction; 11 | import rekit.primitives.geometry.Vec; 12 | import rekit.util.ReflectUtils; 13 | import rekit.util.ReflectUtils.LoadMe; 14 | 15 | /** 16 | * This class is the parent class of all Pickups in the game. 17 | */ 18 | @Group 19 | public abstract class Pickup extends Entity { 20 | /** 21 | * Load all Pickups. 22 | * 23 | * @return a set of pickups 24 | * @see LoadMe 25 | */ 26 | public static Set getPrototypes() { 27 | return ReflectUtils.loadInstances(GameConf.SEARCH_PATH, ModManager.SYSLOADER, Pickup.class); 28 | } 29 | 30 | /** 31 | * Prototype constructor. 32 | */ 33 | protected Pickup() { 34 | super(Team.PICKUP); 35 | } 36 | 37 | /** 38 | * Create a pickup. 39 | * 40 | * @param startPos 41 | * the start pos 42 | * @param vel 43 | * the start velocity 44 | * @param size 45 | * the size 46 | */ 47 | protected Pickup(Vec startPos, Vec vel, Vec size) { 48 | super(startPos, vel, size, Team.PICKUP); 49 | } 50 | 51 | @Override 52 | public abstract Pickup create(Vec startPos, String... options); 53 | 54 | /** 55 | * Template method that should be overwritten in concrete {@link Pickup 56 | * Pickups} to add the action that is performed upon being collected by the 57 | * Player. 58 | * 59 | * @param collector 60 | * the GameElement which collects this Pickup 61 | */ 62 | public abstract void perform(GameElement collector); 63 | 64 | @Override 65 | public final void reactToCollision(GameElement element, Direction dir) { 66 | if (this.getTeam().isHostile(element.getTeam())) { 67 | this.perform(element); 68 | } 69 | } 70 | 71 | @Override 72 | protected void innerLogicLoop() { 73 | // no logic 74 | } 75 | } 76 | -------------------------------------------------------------------------------- /project/logic/src/main/java/rekit/logic/gui/BackgroundElement.java: -------------------------------------------------------------------------------- 1 | package rekit.logic.gui; 2 | 3 | import rekit.config.GameConf; 4 | import rekit.core.GameGrid; 5 | import rekit.logic.IScene; 6 | import rekit.primitives.geometry.Vec; 7 | 8 | /** 9 | * The standard background of the Game. 10 | * 11 | */ 12 | public final class BackgroundElement extends GuiElement { 13 | /** 14 | * The image name. 15 | */ 16 | private String imageSource; 17 | /** 18 | * The image size. 19 | */ 20 | private Vec imageSize = new Vec(GameConf.GRID_W, GameConf.GRID_H); 21 | 22 | /** 23 | * Create the background by scene and image. 24 | * 25 | * @param scene 26 | * the scene 27 | * @param imageSource 28 | * the path to the image 29 | */ 30 | public BackgroundElement(IScene scene, String imageSource) { 31 | super(scene); 32 | this.imageSource = imageSource; 33 | } 34 | 35 | @Override 36 | public void internalRender(GameGrid f) { 37 | f.drawImage(this.getPos().add(new Vec(11, 5)), this.imageSize, this.imageSource, false, false); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /project/logic/src/main/java/rekit/logic/gui/LevelGuiElement.java: -------------------------------------------------------------------------------- 1 | package rekit.logic.gui; 2 | 3 | import rekit.logic.ILevelScene; 4 | 5 | /** 6 | * This class represents a {@link GuiElement} attached to a {@link ILevelScene}. 7 | * 8 | */ 9 | public abstract class LevelGuiElement extends GuiElement { 10 | /** 11 | * Create LevelGuiElement by ILevelScene. 12 | * 13 | * @param scene 14 | * the scene 15 | */ 16 | public LevelGuiElement(ILevelScene scene) { 17 | super(scene); 18 | } 19 | 20 | @Override 21 | public ILevelScene getScene() { 22 | return (ILevelScene) super.getScene(); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /project/logic/src/main/java/rekit/logic/gui/LifeGui.java: -------------------------------------------------------------------------------- 1 | package rekit.logic.gui; 2 | 3 | import rekit.core.GameGrid; 4 | import rekit.logic.ILevelScene; 5 | import rekit.logic.gameelements.entities.Player; 6 | import rekit.primitives.geometry.Vec; 7 | 8 | /** 9 | * 10 | * This {@link GuiElement} realizes a status view of the {@link Player Player's} 11 | * Lives. 12 | * 13 | */ 14 | public class LifeGui extends LevelGuiElement { 15 | /** 16 | * The image name. 17 | */ 18 | private String image = "life.png"; 19 | /** 20 | * The image size. 21 | */ 22 | private Vec imageSize = new Vec(10); 23 | /** 24 | * The amount of the player's lives. 25 | */ 26 | private int playerLives; 27 | 28 | /** 29 | * Create the status view for lives. 30 | * 31 | * @param scene 32 | * the scene 33 | */ 34 | public LifeGui(ILevelScene scene) { 35 | super(scene); 36 | } 37 | 38 | @Override 39 | public void logicLoop() { 40 | this.playerLives = this.getScene().getPlayer().getLives(); 41 | } 42 | 43 | @Override 44 | public void internalRender(GameGrid f) { 45 | for (int i = 0; i < this.playerLives; i++) { 46 | f.drawImage(this.getPos().addX(50 * i), this.imageSize, this.image, false, true); 47 | } 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /project/logic/src/main/java/rekit/logic/gui/ScoreGui.java: -------------------------------------------------------------------------------- 1 | package rekit.logic.gui; 2 | 3 | import rekit.config.GameConf; 4 | import rekit.core.GameGrid; 5 | import rekit.logic.ILevelScene; 6 | import rekit.logic.gameelements.entities.Player; 7 | import rekit.primitives.TextOptions; 8 | import rekit.primitives.geometry.Vec; 9 | 10 | /** 11 | * 12 | * This {@link GuiElement} realizes a status view of the {@link Player Player's} 13 | * Score. 14 | * 15 | */ 16 | public class ScoreGui extends LevelGuiElement { 17 | /** 18 | * Current score of the {@link Player}. 19 | */ 20 | private int score; 21 | /** 22 | * The highscore of the current Level. 23 | */ 24 | private int highscore; 25 | /** 26 | * Text that prints the score on the GUI. 27 | */ 28 | private Text scoreText; 29 | /** 30 | * Text that prints the highscore on the GUI. 31 | */ 32 | private Text highscoreText; 33 | /** 34 | * The text options for this.highscoreText and this.pointsText. 35 | */ 36 | private TextOptions op; 37 | 38 | /** 39 | * Create the status view. 40 | * 41 | * @param scene 42 | * the scene 43 | */ 44 | public ScoreGui(ILevelScene scene) { 45 | super(scene); 46 | this.op = new TextOptions(new Vec(-1, 0), GameConf.GAME_TEXT_SIZE, GameConf.GAME_TEXT_COLOR, GameConf.GAME_TEXT_FONT, 1); 47 | this.scoreText = new Text(scene, this.op); 48 | this.highscoreText = new Text(scene, this.op); 49 | this.scoreText.setPos(new Vec(GameConf.PIXEL_W - 10, 10)); 50 | this.highscoreText.setPos(new Vec(GameConf.PIXEL_W - 10, 50)); 51 | this.highscore = this.getScene().getLevel().getHighScore(); 52 | } 53 | 54 | @Override 55 | public void logicLoop() { 56 | this.score = this.getScene().getLevel().getScore(); 57 | this.scoreText.setText(String.format("%d Points", this.score)); 58 | this.highscoreText.setText(String.format("%d Highscore", this.highscore)); 59 | } 60 | 61 | @Override 62 | public void internalRender(GameGrid f) { 63 | this.scoreText.internalRender(f); 64 | this.highscoreText.internalRender(f); 65 | } 66 | 67 | } 68 | -------------------------------------------------------------------------------- /project/logic/src/main/java/rekit/logic/gui/Text.java: -------------------------------------------------------------------------------- 1 | package rekit.logic.gui; 2 | 3 | import rekit.core.GameGrid; 4 | import rekit.logic.IScene; 5 | import rekit.primitives.TextOptions; 6 | 7 | /** 8 | * 9 | * This class realizes a simple {@link GuiElement}:
10 | * A Text which can be visualized on the view. 11 | * 12 | */ 13 | public final class Text extends GuiElement { 14 | /** 15 | * The text. 16 | */ 17 | private String text; 18 | /** 19 | * The text options. 20 | */ 21 | private TextOptions options; 22 | 23 | /** 24 | * Create the text element. 25 | * 26 | * @param scene 27 | * the scene 28 | * @param options 29 | * the textoptions 30 | */ 31 | public Text(IScene scene, TextOptions options) { 32 | super(scene); 33 | this.text = ""; 34 | this.options = options; 35 | } 36 | 37 | /** 38 | * Get the text. 39 | * 40 | * @return the text 41 | */ 42 | public String getText() { 43 | return this.text; 44 | } 45 | 46 | /** 47 | * Set the text. 48 | * 49 | * @param text 50 | * the new text 51 | * @return {@code this} 52 | */ 53 | public Text setText(String text) { 54 | this.text = text; 55 | return this; 56 | } 57 | 58 | /** 59 | * Get the text options. 60 | * 61 | * @return the options 62 | */ 63 | public TextOptions getOptions() { 64 | return this.options; 65 | } 66 | 67 | /** 68 | * Set the text options. 69 | * 70 | * @param options 71 | * the new options 72 | */ 73 | public void setOptions(TextOptions options) { 74 | this.options = options; 75 | } 76 | 77 | @Override 78 | public void internalRender(GameGrid f) { 79 | f.drawText(this.getPos(), this.text, this.getOptions(), false); 80 | } 81 | } 82 | -------------------------------------------------------------------------------- /project/logic/src/main/java/rekit/logic/gui/TimeDecorator.java: -------------------------------------------------------------------------------- 1 | package rekit.logic.gui; 2 | 3 | import rekit.core.GameGrid; 4 | import rekit.logic.IScene; 5 | import rekit.primitives.time.Timer; 6 | 7 | /** 8 | * 9 | * This class can decorate all {@link GuiElement GuiElements} so that they will 10 | * be deleted after a specific time. 11 | * 12 | */ 13 | public final class TimeDecorator extends GuiElement { 14 | /** 15 | * The decorated GuiElement. 16 | */ 17 | private GuiElement element; 18 | /** 19 | * The timer. 20 | */ 21 | private Timer timer; 22 | /* 23 | * The last time of invoking {@link #logicLoop()}. 24 | */ 25 | // private long lastTime = GameTime.getTime(); 26 | 27 | /** 28 | * Create a TimeDecorator. 29 | * 30 | * @param scene 31 | * the scene 32 | * @param element 33 | * the decorated element 34 | * @param timer 35 | * the timer 36 | */ 37 | public TimeDecorator(IScene scene, GuiElement element, Timer timer) { 38 | super(scene); 39 | this.element = element; 40 | this.timer = timer; 41 | } 42 | 43 | @Override 44 | public void logicLoop() { 45 | // long deltaTime = GameTime.getTime() - this.lastTime; 46 | // this.lastTime += deltaTime; 47 | this.timer.logicLoop(); 48 | // this.timer.removeTime(deltaTime); 49 | if (this.timer.timeUp()) { 50 | this.visible = false; 51 | this.getScene().removeGuiElement(this); 52 | } 53 | 54 | this.element.logicLoop(); 55 | } 56 | 57 | @Override 58 | public void internalRender(GameGrid f) { 59 | this.element.render(f); 60 | } 61 | 62 | } 63 | -------------------------------------------------------------------------------- /project/logic/src/main/java/rekit/logic/gui/menu/ArcadeLevelItem.java: -------------------------------------------------------------------------------- 1 | package rekit.logic.gui.menu; 2 | 3 | import java.util.List; 4 | 5 | import rekit.config.GameConf; 6 | import rekit.core.GameGrid; 7 | import rekit.logic.GameModel; 8 | import rekit.logic.IScene; 9 | import rekit.logic.scene.Scenes; 10 | import rekit.persistence.level.DataKey; 11 | import rekit.persistence.level.LevelManager; 12 | import rekit.primitives.geometry.Vec; 13 | 14 | /** 15 | * 16 | * This class realizes a {@link MenuItem} with contains an arcade level (switch to). 17 | * 18 | */ 19 | public final class ArcadeLevelItem extends MenuActionItem { 20 | 21 | private final boolean possible; 22 | 23 | /** 24 | * Create MenuActionItem. 25 | * 26 | * @param scene 27 | * the scene 28 | * @param text 29 | * the text 30 | * @param size 31 | * the size 32 | * @param arcadeGroup 33 | * the group of the level 34 | * @param id 35 | * the id of the level 36 | * @param model 37 | * the model 38 | */ 39 | public ArcadeLevelItem(IScene scene, Vec size, String text, List arcadeGroup, String id, GameModel model) { 40 | super(scene, size, text, () -> model.switchScene(Scenes.ARCADE, id)); 41 | this.possible = GameConf.DEBUG || this.checkEnable(arcadeGroup, id); 42 | } 43 | 44 | private boolean checkEnable(List arcadeGroup, String id) { 45 | int idx = arcadeGroup.indexOf(id); 46 | if (idx < 1) { 47 | return true; 48 | } 49 | String prev = arcadeGroup.get(idx - 1); 50 | return (boolean) LevelManager.getLevelById(prev).getData(DataKey.WON); 51 | 52 | } 53 | 54 | @Override 55 | protected void renderItem(GameGrid f) { 56 | if (this.possible) { 57 | super.renderItem(f); 58 | } 59 | } 60 | 61 | @Override 62 | public boolean isSelectable() { 63 | return this.possible; 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /project/logic/src/main/java/rekit/logic/gui/menu/MainMenuGrid.java: -------------------------------------------------------------------------------- 1 | package rekit.logic.gui.menu; 2 | 3 | import rekit.config.GameConf; 4 | import rekit.core.GameGrid; 5 | import rekit.logic.IScene; 6 | import rekit.primitives.geometry.Vec; 7 | import rekit.primitives.time.Timer; 8 | 9 | /** 10 | * 11 | * This class realizes the Main Menu displaying a list of MenuItems. 12 | * 13 | */ 14 | public class MainMenuGrid extends MenuGrid { 15 | /** 16 | * The timer to switch between the different logo images. 17 | */ 18 | private Timer frameTimer; 19 | 20 | /** 21 | * The number of the currently shown logo image. 22 | */ 23 | private int currentFrame; 24 | 25 | /** 26 | * Create a new MainMenuGrid. 27 | * 28 | * @param scene 29 | * the scene 30 | * @param text 31 | * the text (name) 32 | * @param colCount 33 | * the amount of columns 34 | */ 35 | public MainMenuGrid(IScene scene, String text, int colCount) { 36 | super(scene, text, colCount, 425, 100); 37 | this.setItemSize(new Vec(425, 100)); 38 | this.frameTimer = new Timer(120); 39 | } 40 | 41 | @Override 42 | public void logicLoop() { 43 | super.logicLoop(); 44 | this.frameTimer.logicLoop(); 45 | if (this.frameTimer.timeUp()) { 46 | this.frameTimer.reset(); 47 | this.currentFrame = (this.currentFrame + 1) % 3; 48 | } 49 | } 50 | 51 | @Override 52 | protected void internalRender(GameGrid f) { 53 | super.internalRender(f); 54 | if (this.selected) { 55 | f.drawImage(new Vec(GameConf.GRID_W / 2f, 2.2f), new Vec(8, 5), "logo_" + this.currentFrame + ".png"); 56 | } 57 | } 58 | 59 | } 60 | -------------------------------------------------------------------------------- /project/logic/src/main/java/rekit/logic/gui/menu/MenuActionItem.java: -------------------------------------------------------------------------------- 1 | package rekit.logic.gui.menu; 2 | 3 | import org.fuchss.tools.lambda.VoidFunction; 4 | 5 | import rekit.logic.IScene; 6 | import rekit.primitives.geometry.Vec; 7 | 8 | /** 9 | * 10 | * This class realizes a {@link MenuItem} with an attached Action. 11 | * 12 | */ 13 | public class MenuActionItem extends MenuItem { 14 | /** 15 | * The action. 16 | */ 17 | private final VoidFunction selectAction; 18 | 19 | /** 20 | * Create MenuActionItem. 21 | * 22 | * @param scene 23 | * the scene 24 | * @param text 25 | * the text 26 | * @param selectAction 27 | * the action 28 | */ 29 | public MenuActionItem(IScene scene, String text, VoidFunction selectAction) { 30 | super(scene, text); 31 | this.selectAction = selectAction; 32 | } 33 | 34 | /** 35 | * Create MenuActionItem. 36 | * 37 | * @param scene 38 | * the scene 39 | * @param text 40 | * the text 41 | * @param size 42 | * the size 43 | * @param selectAction 44 | * the action 45 | */ 46 | public MenuActionItem(IScene scene, Vec size, String text, VoidFunction selectAction) { 47 | this(scene, text, selectAction); 48 | this.size = size; 49 | } 50 | 51 | @Override 52 | public void select() { 53 | this.selected = true; 54 | this.unselect(); 55 | this.selectAction.execute(); 56 | } 57 | 58 | @Override 59 | public boolean hasChildren() { 60 | return false; 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /project/logic/src/main/java/rekit/logic/gui/menu/MenuList.java: -------------------------------------------------------------------------------- 1 | package rekit.logic.gui.menu; 2 | 3 | import rekit.logic.IScene; 4 | import rekit.primitives.geometry.Vec; 5 | 6 | /** 7 | * 8 | * This class realizes a Menu displaying a list of MenuItems. 9 | * 10 | */ 11 | public class MenuList extends SubMenu { 12 | /** 13 | * Create a MenuList. 14 | * 15 | * @param scene 16 | * the scene 17 | * @param text 18 | * the text 19 | */ 20 | public MenuList(IScene scene, String text) { 21 | super(scene, text); 22 | this.setItemSize(new Vec(400, 100)); 23 | } 24 | 25 | @Override 26 | public void menuUp() { 27 | // hover up 28 | this.menuItems.get(this.index).setHover(false); 29 | this.index -= 1; 30 | if (this.index < 0) { 31 | this.index = this.menuItems.size() - 1; 32 | } 33 | this.menuItems.get(this.index).setHover(true); 34 | } 35 | 36 | @Override 37 | public void menuDown() { 38 | // hover down 39 | this.menuItems.get(this.index).setHover(false); 40 | this.index += 1; 41 | if (this.index >= this.menuItems.size()) { 42 | this.index = 0; 43 | } 44 | this.menuItems.get(this.index).setHover(true); 45 | } 46 | 47 | @Override 48 | protected void calcItemPos() { 49 | // render menu as list 50 | Vec offset = new Vec(0, ((1 - this.menuItems.size()) * this.itemSize.y) / 2.225); 51 | 52 | for (final MenuItem menuItem : this.menuItems) { 53 | menuItem.setPos(this.getPos().add(offset)); 54 | offset = offset.addY(this.itemSize.y * 0.9F); 55 | } 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /project/logic/src/main/java/rekit/logic/gui/menu/TextItem.java: -------------------------------------------------------------------------------- 1 | package rekit.logic.gui.menu; 2 | 3 | import rekit.config.GameConf; 4 | import rekit.core.GameGrid; 5 | import rekit.logic.IScene; 6 | import rekit.primitives.geometry.Vec; 7 | import rekit.primitives.image.RGBAColor; 8 | 9 | /** 10 | * This class realizes a TextField for a Menu. 11 | * 12 | * @author Dominik Fuchss 13 | * 14 | */ 15 | public class TextItem extends MenuItem { 16 | /** 17 | * Vector for spacing. 18 | */ 19 | private final Vec space = new Vec(GameConf.PIXEL_W * 0.95F, GameConf.PIXEL_H * 0.9F).scalar(0.05F, 0.1F); 20 | 21 | /** 22 | * Create the MenuItem. 23 | * 24 | * @param scene 25 | * the scene 26 | * @param text 27 | * the text 28 | */ 29 | public TextItem(IScene scene, String text) { 30 | super(scene, text, new Vec(GameConf.PIXEL_W * 0.95F, GameConf.PIXEL_H * 0.9F)); 31 | } 32 | 33 | /** 34 | * Render the Item itself. 35 | * 36 | * @param f 37 | * the field 38 | */ 39 | @Override 40 | protected void renderItem(GameGrid f) { 41 | f.drawRectangle(this.getPos(), this.getSize(), new RGBAColor(0, 0, 0, 200), false, true); 42 | f.drawText(this.getPos().sub(this.getSize().scalar(0.5F)).add(this.space), this.getText(), GameConf.ABOUT_TEXT, false); 43 | } 44 | 45 | @Override 46 | public boolean isSelectable() { 47 | return false; 48 | } 49 | 50 | @Override 51 | public boolean hasChildren() { 52 | return false; 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /project/logic/src/main/java/rekit/logic/gui/parallax/BackgroundElement.java: -------------------------------------------------------------------------------- 1 | package rekit.logic.gui.parallax; 2 | 3 | import rekit.core.Team; 4 | import rekit.logic.gameelements.GameElement; 5 | import rekit.primitives.geometry.Direction; 6 | import rekit.primitives.geometry.Frame; 7 | import rekit.primitives.geometry.Vec; 8 | 9 | /** 10 | * 11 | * This is the parent class which all background elements shall extend. 12 | * 13 | */ 14 | public abstract class BackgroundElement extends GameElement { 15 | /** 16 | * The parent parallax. 17 | */ 18 | protected ParallaxLayer parent; 19 | /** 20 | * The z-pos of this element. 21 | */ 22 | protected int backgroundZ; 23 | 24 | /** 25 | * Create a BG-Element by parent and pos. 26 | * 27 | * @param parent 28 | * the parent 29 | * @param pos 30 | * the positon 31 | */ 32 | public BackgroundElement(ParallaxLayer parent, Vec pos) { 33 | super(pos.setZ(parent == null ? 1 : parent.perspectiveZ), new Vec(), new Vec(1), Team.BACKGROUND); 34 | this.parent = parent; 35 | this.backgroundZ = Team.BACKGROUND.zRange.min; 36 | } 37 | 38 | @Override 39 | public final Integer getZHint() { 40 | return (int) (this.backgroundZ - this.parent.fieldXtoLayerX(100)); 41 | } 42 | 43 | @Override 44 | public void addDamage(int damage) { 45 | // Do nothing 46 | } 47 | 48 | @Override 49 | public int getLives() { 50 | // Do nothing 51 | return 0; 52 | } 53 | 54 | @Override 55 | public void collidedWithSolid(Frame collision, Direction dir) { 56 | // Do nothing 57 | } 58 | 59 | } 60 | -------------------------------------------------------------------------------- /project/logic/src/main/java/rekit/logic/gui/parallax/HeapElement.java: -------------------------------------------------------------------------------- 1 | package rekit.logic.gui.parallax; 2 | 3 | import rekit.core.GameGrid; 4 | import rekit.primitives.geometry.Vec; 5 | import rekit.primitives.image.RGBAColor; 6 | 7 | /** 8 | * 9 | * This class shall be extended by each heap element. 10 | * 11 | */ 12 | public abstract class HeapElement extends BackgroundElement { 13 | 14 | protected float heapDistanceMu() { 15 | return 9; 16 | } 17 | 18 | protected float heapDistanceSigma() { 19 | return 2; 20 | } 21 | 22 | protected float elemNumMu() { 23 | return 7; 24 | } 25 | 26 | protected float elemNumSigma() { 27 | return 3; 28 | } 29 | 30 | protected int elemColRMu() { 31 | return 240; 32 | } 33 | 34 | protected int elemColRSigma() { 35 | return 15; 36 | } 37 | 38 | protected int elemColGMu() { 39 | return 240; 40 | } 41 | 42 | protected int elemColGSigma() { 43 | return 15; 44 | } 45 | 46 | protected int elemColBMu() { 47 | return 240; 48 | } 49 | 50 | protected int elemColBSigma() { 51 | return 15; 52 | } 53 | 54 | protected int elemColAMu() { 55 | return 220; 56 | } 57 | 58 | protected int elemColASigma() { 59 | return 30; 60 | } 61 | 62 | protected float elemXMu() { 63 | return 0; 64 | } 65 | 66 | protected float elemXSigma() { 67 | return 2; 68 | } 69 | 70 | protected float elemYMu() { 71 | return 2; 72 | } 73 | 74 | protected float elemYSigma() { 75 | return 1; 76 | } 77 | 78 | protected float elemWidthMu() { 79 | return 2.5f; 80 | } 81 | 82 | protected float elemWidthSigma() { 83 | return 1; 84 | } 85 | 86 | protected float elemHeightMu() { 87 | return 1.5f; 88 | } 89 | 90 | protected float elemHeightSigma() { 91 | return 0.8f; 92 | } 93 | 94 | protected RGBAColor col; 95 | 96 | public HeapElement(HeapLayer parent, Vec pos, Vec size, RGBAColor col) { 97 | super(parent, pos); 98 | this.setSize(size); 99 | this.col = col; 100 | } 101 | 102 | @Override 103 | public abstract void internalRender(GameGrid f); 104 | 105 | public abstract HeapElement create(HeapLayer parent, Vec pos, Vec size, RGBAColor col); 106 | } 107 | -------------------------------------------------------------------------------- /project/logic/src/main/java/rekit/logic/gui/parallax/HeapElementCloud.java: -------------------------------------------------------------------------------- 1 | package rekit.logic.gui.parallax; 2 | 3 | import rekit.core.GameGrid; 4 | import rekit.primitives.geometry.Vec; 5 | import rekit.primitives.image.RGBAColor; 6 | 7 | public class HeapElementCloud extends HeapElement { 8 | 9 | public HeapElementCloud(HeapLayer parent, Vec pos, Vec size, RGBAColor col) { 10 | super(parent, pos, size, col); 11 | // R, G and B channel must be same for clouds 12 | if (col != null) { 13 | this.col = new RGBAColor(col.red, col.red, col.red, col.alpha); 14 | } 15 | } 16 | 17 | @Override 18 | public void internalRender(GameGrid f) { 19 | f.drawCircle(this.getPos(), this.getSize(), this.col); 20 | } 21 | 22 | @Override 23 | public HeapElement create(HeapLayer parent, Vec pos, Vec size, RGBAColor col) { 24 | return new HeapElementCloud(parent, pos, size, col); 25 | } 26 | 27 | } 28 | -------------------------------------------------------------------------------- /project/logic/src/main/java/rekit/logic/gui/parallax/ParallaxContainer.java: -------------------------------------------------------------------------------- 1 | package rekit.logic.gui.parallax; 2 | 3 | import java.util.LinkedList; 4 | import java.util.List; 5 | 6 | import rekit.logic.IScene; 7 | 8 | public class ParallaxContainer { 9 | 10 | private List layers; 11 | private IScene scene; 12 | 13 | public ParallaxContainer(IScene scene) { 14 | this.layers = new LinkedList<>(); 15 | this.scene = scene; 16 | } 17 | 18 | public void addLayer(ParallaxLayer layer) { 19 | layer.setScene(this.scene); 20 | this.layers.add(layer); 21 | } 22 | 23 | public void logicLoop(float currentOffset) { 24 | for (ParallaxLayer layer : this.layers) { 25 | layer.logicLoop(currentOffset); 26 | } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /project/logic/src/main/java/rekit/logic/gui/parallax/ParallaxLayer.java: -------------------------------------------------------------------------------- 1 | package rekit.logic.gui.parallax; 2 | 3 | import rekit.config.GameConf; 4 | import rekit.core.GameGrid; 5 | import rekit.logic.IScene; 6 | 7 | public abstract class ParallaxLayer { 8 | 9 | protected float perspectiveZ; 10 | 11 | protected float generateUntil = 0; 12 | 13 | protected IScene scene = null; 14 | 15 | protected float currentlyGeneratedUntil = 0; 16 | 17 | protected float x; 18 | 19 | public ParallaxLayer(float perspectiveZ) { 20 | this.perspectiveZ = perspectiveZ; 21 | } 22 | 23 | public void logicLoop(float currentOffset) { 24 | // x position of where the middle of the image is rendered 25 | this.x = currentOffset; 26 | 27 | this.generateUntil = this.x + GameConf.GRID_W; 28 | } 29 | 30 | public void render(GameGrid f) { 31 | 32 | } 33 | 34 | protected float fieldXtoLayerX(float fieldX) { 35 | return fieldX / this.perspectiveZ; 36 | } 37 | 38 | public void setScene(IScene scene) { 39 | this.scene = scene; 40 | } 41 | 42 | } 43 | -------------------------------------------------------------------------------- /project/logic/src/main/java/rekit/logic/level/BossRushStructurePart.java: -------------------------------------------------------------------------------- 1 | package rekit.logic.level; 2 | 3 | import java.util.ArrayList; 4 | import java.util.List; 5 | 6 | import rekit.logic.gameelements.type.Boss; 7 | import rekit.persistence.level.LevelType; 8 | import rekit.primitives.geometry.Vec; 9 | 10 | /** 11 | * A special type of structure for a BossRush level. 12 | * 13 | * @author Dominik Fuchss 14 | * 15 | * @see LevelType#Boss_Rush 16 | * 17 | */ 18 | final class BossRushStructurePart extends StructurePart { 19 | private final List bosses; 20 | private int next; 21 | 22 | /** 23 | * Create StructurePart by interlink (LevelMtx). 24 | * 25 | * @param mtx 26 | * the interlink 27 | */ 28 | BossRushStructurePart(LevelMtx mtx) { 29 | super(mtx); 30 | this.bosses = new ArrayList<>(); 31 | Boss.getPrototypes().forEach(e -> this.bosses.add((Boss) e)); 32 | this.next = this.bosses.size(); 33 | } 34 | 35 | @Override 36 | public Structure next() { 37 | if (this.next == this.bosses.size() || this.unitsBuilt == 0) { 38 | this.next = 0; 39 | this.shuffle(); 40 | return this.getInitialStructure(); 41 | } 42 | return this.bosses.get(this.next++).create(new Vec(), new String[] {}).getBossStructure(); 43 | } 44 | 45 | private void shuffle() { 46 | List newList = new ArrayList<>(); 47 | while (!this.bosses.isEmpty()) { 48 | int idx = this.random.nextInt(this.bosses.size()); 49 | newList.add(this.bosses.get(idx)); 50 | this.bosses.remove(idx); 51 | } 52 | newList.forEach(this.bosses::add); 53 | } 54 | 55 | } -------------------------------------------------------------------------------- /project/logic/src/main/java/rekit/logic/level/LevelFactory.java: -------------------------------------------------------------------------------- 1 | package rekit.logic.level; 2 | 3 | import java.io.ByteArrayInputStream; 4 | import java.nio.charset.Charset; 5 | import java.util.Objects; 6 | 7 | import rekit.persistence.level.LevelDefinition; 8 | import rekit.persistence.level.LevelManager; 9 | import rekit.persistence.level.LevelType; 10 | import rekit.persistence.level.SettingKey; 11 | 12 | /** 13 | * Factory class which creates all {@link Level Levels}. 14 | * 15 | * @author Dominik Fuchss 16 | * 17 | */ 18 | public final class LevelFactory { 19 | /** 20 | * Prevent instantiation. 21 | */ 22 | private LevelFactory() { 23 | } 24 | 25 | /** 26 | * Create a new {@link Level} by {@link LevelDefinition}. 27 | * 28 | * @param definition 29 | * the definition 30 | * @return the level 31 | */ 32 | public static Level createLevel(LevelDefinition definition) { 33 | Objects.requireNonNull(definition); 34 | LevelMtx mtx = new LevelMtx(definition); 35 | StructurePart struct = new StructurePart(mtx); 36 | LogicalPart logic = new LogicalPart(mtx); 37 | Level lv = new Level(mtx, struct, logic); 38 | return lv; 39 | } 40 | 41 | /** 42 | * Create the BossRush Level (a special level with bosses). 43 | * 44 | * @return the BossRush Level 45 | */ 46 | public static synchronized Level getBossRushLevel() { 47 | 48 | LevelDefinition brLevel = LevelManager.getLevelById(LevelFactory.getBossRushLevelDefinition().getRawData()); 49 | if (brLevel == null) { 50 | brLevel = LevelFactory.getBossRushLevelDefinition(); 51 | LevelManager.addLevel(brLevel, true); 52 | } 53 | 54 | LevelMtx mtx = new LevelMtx(brLevel); 55 | StructurePart sp = new BossRushStructurePart(mtx); 56 | LogicalPart lp = new LogicalPart(mtx); 57 | return new Level(mtx, sp, lp); 58 | 59 | } 60 | 61 | private static LevelDefinition getBossRushLevelDefinition() { 62 | StringBuilder builder = new StringBuilder(); 63 | builder.append("#SETTING::").append(SettingKey.INFINITE).append("->true").append("\n"); 64 | ByteArrayInputStream is = new ByteArrayInputStream(builder.toString().getBytes(Charset.forName("UTF-8"))); 65 | return new LevelDefinition(is, LevelType.Boss_Rush); 66 | } 67 | 68 | } 69 | -------------------------------------------------------------------------------- /project/logic/src/main/java/rekit/logic/level/LevelMtx.java: -------------------------------------------------------------------------------- 1 | package rekit.logic.level; 2 | 3 | import java.util.Random; 4 | 5 | import rekit.persistence.level.LevelDefinition; 6 | 7 | /** 8 | * This is the MTX-Object (a connector/interlink) of the {@link Level}, 9 | * {@link StructurePart} and {@link LogicalPart} which holds necessary 10 | * information. 11 | * 12 | * @author Dominik Fuchss 13 | * 14 | */ 15 | class LevelMtx { 16 | private final LevelDefinition definition; 17 | private final Random random; 18 | 19 | /** 20 | * Create LevelMtx by LevelDefinition. 21 | * 22 | * @param definition 23 | * the definition 24 | */ 25 | LevelMtx(LevelDefinition definition) { 26 | this.definition = definition; 27 | this.random = new Random(this.definition.getSeed()); 28 | } 29 | 30 | /** 31 | * Get {@link LevelDefinition}. 32 | * 33 | * @return the level's definition 34 | */ 35 | LevelDefinition getDefinition() { 36 | return this.definition; 37 | } 38 | 39 | /** 40 | * The source of randomness of the level. 41 | * 42 | * @return the random source 43 | */ 44 | Random getRandom() { 45 | return this.random; 46 | } 47 | 48 | private void resetRandom() { 49 | this.random.setSeed(this.definition.getSeed()); 50 | } 51 | 52 | /** 53 | * Reset the LevelMtx. 54 | */ 55 | public void reset() { 56 | this.resetRandom(); 57 | } 58 | 59 | } 60 | -------------------------------------------------------------------------------- /project/logic/src/main/java/rekit/logic/level/LogicalPart.java: -------------------------------------------------------------------------------- 1 | package rekit.logic.level; 2 | 3 | import java.util.List; 4 | 5 | import rekit.logic.gameelements.entities.Player; 6 | import rekit.persistence.level.LevelDefinition; 7 | import rekit.persistence.level.LevelManager; 8 | import rekit.persistence.level.LevelType; 9 | import rekit.persistence.level.SettingKey; 10 | import rekit.primitives.geometry.Vec; 11 | 12 | /** 13 | * The logical part of a {@link Level}. 14 | * 15 | * @author Dominik Fuchss 16 | * 17 | */ 18 | public final class LogicalPart { 19 | private final LevelDefinition definition; 20 | private final Player player; 21 | 22 | /** 23 | * Create LogicalPart by interlink (LevelMtx). 24 | * 25 | * @param mtx 26 | * the interlink 27 | */ 28 | LogicalPart(LevelMtx mtx) { 29 | this.definition = mtx.getDefinition(); 30 | this.player = new Player(new Vec(6, 5)); 31 | } 32 | 33 | /** 34 | * Get the player of the level. 35 | * 36 | * @return the player 37 | */ 38 | public Player getPlayer() { 39 | return this.player; 40 | } 41 | 42 | /** 43 | * Returns the next level iff existing. 44 | * 45 | * @return the id of next level or {@code null} if none exists 46 | */ 47 | public String getNextLevel() { 48 | if (this.definition.getType() != LevelType.Arcade) { 49 | return null; 50 | } 51 | 52 | String group = this.definition.getSetting(SettingKey.GROUP); 53 | List levels = LevelManager.getArcadeLevelGroups().get(group); 54 | int thatIdx = levels.indexOf(this.definition.getRawData()); 55 | if (thatIdx + 1 >= levels.size()) { 56 | return null; 57 | } 58 | return levels.get(thatIdx + 1); 59 | } 60 | 61 | /** 62 | * Reset the logic of the {@link Level}. 63 | */ 64 | void reset() { 65 | this.player.init(); 66 | } 67 | 68 | } -------------------------------------------------------------------------------- /project/logic/src/main/java/rekit/logic/scene/ArcadeLevelScene.java: -------------------------------------------------------------------------------- 1 | package rekit.logic.scene; 2 | 3 | import rekit.logic.GameModel; 4 | import rekit.logic.level.LevelFactory; 5 | import rekit.persistence.level.LevelManager; 6 | 7 | /** 8 | * This class realizes a LevelScene for arcade levels. 9 | */ 10 | final class ArcadeLevelScene extends LevelScene { 11 | 12 | /** 13 | * Create a new arcade level. 14 | * 15 | * @param model 16 | * the model 17 | * @param arcadeLevelId 18 | * the arcade level's id 19 | */ 20 | private ArcadeLevelScene(GameModel model, String id) { 21 | super(model, LevelFactory.createLevel(LevelManager.getLevelById(id))); 22 | } 23 | 24 | /** 25 | * Create method of the scene. 26 | * 27 | * @param model 28 | * the model 29 | * @param options 30 | * the options - options[0] should be an Integer with the 31 | * arcadeLevelId 32 | * @return a new arcade scene. 33 | */ 34 | public static Scene create(GameModel model, String... options) { 35 | if (options == null || options.length < 1) { 36 | throw new IllegalArgumentException("cant switch to unspecified arcade level"); 37 | } 38 | return new ArcadeLevelScene(model, options[0]); 39 | } 40 | 41 | } 42 | -------------------------------------------------------------------------------- /project/logic/src/main/java/rekit/logic/scene/BossRushScene.java: -------------------------------------------------------------------------------- 1 | package rekit.logic.scene; 2 | 3 | import rekit.logic.GameModel; 4 | import rekit.logic.level.LevelFactory; 5 | 6 | /** 7 | * This class realizes a LevelScene for BossRush levels. 8 | */ 9 | final class BossRushScene extends LevelScene { 10 | /** 11 | * Create a new BossRush Scene. 12 | * 13 | * @param model 14 | * the model 15 | */ 16 | private BossRushScene(GameModel model) { 17 | super(model, LevelFactory.getBossRushLevel()); 18 | } 19 | 20 | /** 21 | * Create method of the scene. 22 | * 23 | * @param model 24 | * the model 25 | * @param options 26 | * the options 27 | * @return a new arcade scene. 28 | */ 29 | public static Scene create(GameModel model, String... options) { 30 | return new BossRushScene(model); 31 | } 32 | 33 | } 34 | -------------------------------------------------------------------------------- /project/logic/src/main/java/rekit/logic/scene/InfiniteLevelScene.java: -------------------------------------------------------------------------------- 1 | package rekit.logic.scene; 2 | 3 | import rekit.logic.GameModel; 4 | import rekit.logic.level.LevelFactory; 5 | import rekit.persistence.level.LevelManager; 6 | 7 | /** 8 | * This class realizes a LevelScene for infinite levels. 9 | */ 10 | final class InfiniteLevelScene extends LevelScene { 11 | /** 12 | * Create a new scene. 13 | * 14 | * @param model 15 | * the model 16 | */ 17 | private InfiniteLevelScene(GameModel model) { 18 | super(model, LevelFactory.createLevel(LevelManager.getInfiniteLevel())); 19 | } 20 | 21 | /** 22 | * Create method of the scene. 23 | * 24 | * @param model 25 | * the model 26 | * @param options 27 | * the options 28 | * @return a new infinite scene. 29 | */ 30 | public static Scene create(GameModel model, String... options) { 31 | return new InfiniteLevelScene(model); 32 | } 33 | 34 | } 35 | -------------------------------------------------------------------------------- /project/logic/src/main/java/rekit/logic/scene/LevelOfTheDayScene.java: -------------------------------------------------------------------------------- 1 | package rekit.logic.scene; 2 | 3 | import rekit.logic.GameModel; 4 | import rekit.logic.level.LevelFactory; 5 | import rekit.persistence.level.LevelManager; 6 | 7 | /** 8 | * This class realizes a LevelScene for lotd levels. 9 | */ 10 | final class LevelOfTheDayScene extends LevelScene { 11 | /** 12 | * Create a new LOTD Scene. 13 | * 14 | * @param model 15 | * the model 16 | */ 17 | private LevelOfTheDayScene(GameModel model) { 18 | super(model, LevelFactory.createLevel(LevelManager.getLOTDLevel())); 19 | } 20 | 21 | /** 22 | * Create method of the scene. 23 | * 24 | * @param model 25 | * the model 26 | * @param options 27 | * the options 28 | * @return a new arcade scene. 29 | */ 30 | public static Scene create(GameModel model, String... options) { 31 | return new LevelOfTheDayScene(model); 32 | } 33 | 34 | } 35 | -------------------------------------------------------------------------------- /project/logic/src/main/resources/conf/bossstructure.properties: -------------------------------------------------------------------------------- 1 | EXPLOSION_PARTICLES.angle=0.0F,9.869604401F,0.0F,0.0F 2 | EXPLOSION_PARTICLES.colorR=200.0F,230.0F,10.0F,25.0F 3 | EXPLOSION_PARTICLES.colorG=200.0F,250.0F,-130.0F,-110.0F 4 | EXPLOSION_PARTICLES.colorB=150.0F,200.0F,-130.0F,-110.0F 5 | EXPLOSION_PARTICLES.colorA=230.0F,250.0F,-120.0F,-200.0F 6 | EXPLOSION_PARTICLES.timeMin=0.1F 7 | EXPLOSION_PARTICLES.timeMax=0.3F 8 | EXPLOSION_PARTICLES.amountMin=40 9 | EXPLOSION_PARTICLES.amountMax=50 10 | EXPLOSION_PARTICLES.speed=4.0F,9.0F,-1.0F,1.0F 11 | 12 | FIREWORKS_PARTICLES.angle=0.0F,9.869604401F,0.0F,9.869604401F 13 | FIREWORKS_PARTICLES.colorR=100.0F,250.0F,-100.0F,5.0F 14 | FIREWORKS_PARTICLES.colorG=100.0F,250.0F,-100.0F,5.0F 15 | FIREWORKS_PARTICLES.colorB=100.0F,250.0F,-100.0F,5.0F 16 | FIREWORKS_PARTICLES.colorA=230.0F,250.0F,-120.0F,-200.0F 17 | FIREWORKS_PARTICLES.timeMin=0.5F 18 | FIREWORKS_PARTICLES.timeMax=1.0F 19 | FIREWORKS_PARTICLES.amountMin=40 20 | FIREWORKS_PARTICLES.amountMax=50 21 | FIREWORKS_PARTICLES.speed=3.0F,5.0F,-1.0F,1.0F 22 | -------------------------------------------------------------------------------- /project/logic/src/main/resources/conf/endtrigger.properties: -------------------------------------------------------------------------------- 1 | PORTAL_NUM=20 2 | PORTAL_PARTICLES.colorA=220.0F,-100.0F 3 | PORTAL_PARTICLES.timeMin=0.3F 4 | PORTAL_PARTICLES.timeMax=0.3F 5 | PORTAL_PARTICLES.speed=2.0F,2.0F,6.0F,6.0F 6 | PORTAL_PARTICLES.amountMin=1 7 | PORTAL_PARTICLES.amountMax=1 8 | PORTAL_PARTICLES.size=1.0F,-0.8F -------------------------------------------------------------------------------- /project/logic/src/main/resources/conf/player.properties: -------------------------------------------------------------------------------- 1 | CAMERA_OFFSET=5.0F 2 | WALK_ACCEL=0.8F 3 | STOP_ACCEL=0.2F 4 | WALK_MAX_SPEED=6.0F 5 | 6 | JUMP_BOOST=-9.8F 7 | KILL_BOOST=-15.5F 8 | JUMP_TIME=250 9 | FLOOR_BOOST=-3.5F 10 | 11 | LIVES=5 -------------------------------------------------------------------------------- /project/persistence/pom.xml: -------------------------------------------------------------------------------- 1 | 4 | 4.0.0 5 | 6 | rekit 7 | parent 8 | 1.3 9 | 10 | persistence 11 | 12 | 13 | rekit 14 | global 15 | 16 | 17 | org.springframework 18 | spring-core 19 | 20 | 21 | org.fuchss 22 | object-casket 23 | 24 | 25 | org.xerial 26 | sqlite-jdbc 27 | 28 | 29 | -------------------------------------------------------------------------------- /project/persistence/src/main/java/rekit/persistence/DirFileDefinitions.java: -------------------------------------------------------------------------------- 1 | package rekit.persistence; 2 | 3 | import java.io.File; 4 | 5 | import rekit.persistence.level.LevelManager; 6 | 7 | /** 8 | * This class contains all Directory and File constants. 9 | * 10 | * @author Dominik Fuchss 11 | * 12 | */ 13 | public final class DirFileDefinitions { 14 | /** 15 | * Prevent instantiation. 16 | */ 17 | private DirFileDefinitions() { 18 | } 19 | 20 | /** 21 | * The base directory for all stored files of the program. 22 | */ 23 | public static final File BASE = DirFileDefinitions.getBaseDir(); 24 | /** 25 | * The directory which contains all custom levels. 26 | */ 27 | public static final File LEVEL_DIR = new File(DirFileDefinitions.BASE.getAbsolutePath() + "/levels"); 28 | /** 29 | * The directory which contains all config files. 30 | */ 31 | public static final File CONFIG_DIR = new File(DirFileDefinitions.BASE.getAbsolutePath() + "/config"); 32 | /** 33 | * The directory which contains all mods / addons. 34 | */ 35 | public static final File MODS_DIR = new File(DirFileDefinitions.BASE.getAbsolutePath() + "/mods"); 36 | 37 | /** 38 | * The global data file for the {@link LevelManager}. 39 | */ 40 | public static final File USER_DATA_DB = new File(DirFileDefinitions.CONFIG_DIR.getAbsolutePath() + "/user-data.db"); 41 | 42 | static { 43 | DirFileDefinitions.LEVEL_DIR.mkdirs(); 44 | DirFileDefinitions.CONFIG_DIR.mkdirs(); 45 | DirFileDefinitions.MODS_DIR.mkdirs(); 46 | } 47 | 48 | private static synchronized File getBaseDir() { 49 | File res = null; 50 | if (System.getProperty("os.name").toLowerCase().indexOf("win") >= 0) { 51 | res = new File(System.getenv("APPDATA") + "/rekit"); 52 | } else { 53 | res = new File(System.getProperty("user.home") + "/.config/rekit"); 54 | } 55 | res.mkdirs(); 56 | return res; 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /project/persistence/src/main/java/rekit/persistence/ModManager.java: -------------------------------------------------------------------------------- 1 | package rekit.persistence; 2 | 3 | import java.io.File; 4 | import java.net.URL; 5 | import java.net.URLClassLoader; 6 | import java.security.AccessController; 7 | import java.security.PrivilegedAction; 8 | import java.util.ArrayList; 9 | import java.util.List; 10 | 11 | import rekit.config.GameConf; 12 | 13 | /** 14 | * This class handles the loading of additional Jars / Mods. 15 | * 16 | * @author Dominik Fuchss 17 | * 18 | */ 19 | public final class ModManager { 20 | /** 21 | * Prevent instantiation. 22 | */ 23 | private ModManager() { 24 | } 25 | 26 | /** 27 | * The system class loader. 28 | */ 29 | 30 | public static final URLClassLoader SYSLOADER = ModManager.loadIt(); 31 | 32 | private static synchronized URLClassLoader loadIt() { 33 | if (ModManager.SYSLOADER != null) { 34 | return ModManager.SYSLOADER; 35 | } 36 | return AccessController 37 | .doPrivileged((PrivilegedAction) () -> new URLClassLoader(ModManager.loadMods(), ClassLoader.getSystemClassLoader())); 38 | } 39 | 40 | /** 41 | * Load all mods from {@link DirFileDefinitions#MODS_DIR}. 42 | */ 43 | private static synchronized URL[] loadMods() { 44 | List urls = new ArrayList<>(); 45 | File[] fs = DirFileDefinitions.MODS_DIR.listFiles(); 46 | if (fs != null) { 47 | for (File f : fs) { 48 | if (f.isFile() && f.getName().endsWith("jar")) { 49 | ModManager.addJar(f, urls); 50 | } 51 | } 52 | } 53 | URL[] url = new URL[urls.size()]; 54 | int i = 0; 55 | for (URL u : urls) { 56 | url[i++] = u; 57 | } 58 | return url; 59 | } 60 | 61 | private static void addJar(File jar, List urls) { 62 | try { 63 | urls.add(jar.toURI().toURL()); 64 | GameConf.GAME_LOGGER.info("Loaded Mod: " + jar.getName()); 65 | } catch (Exception e) { 66 | GameConf.GAME_LOGGER.fatal(e.getMessage()); 67 | } 68 | } 69 | 70 | } 71 | -------------------------------------------------------------------------------- /project/persistence/src/main/java/rekit/persistence/level/DataKeySetter.java: -------------------------------------------------------------------------------- 1 | package rekit.persistence.level; 2 | 3 | /** 4 | * This class defines the necessary methods to update the data of a level. 5 | * 6 | * @author Dominik Fuchss 7 | * @see DataKey 8 | */ 9 | public interface DataKeySetter { 10 | /** 11 | * Get the current score of the level. 12 | * 13 | * @return the score 14 | * @see DataKey#HIGH_SCORE 15 | */ 16 | int getScore(); 17 | 18 | /** 19 | * Get whether the game was successful. 20 | * 21 | * @return {@code true} if success 22 | * @see DataKey#SUCCESS 23 | */ 24 | boolean getSuccess(); 25 | 26 | /** 27 | * Get whether the game was won. 28 | * 29 | * @return {@code true} if won 30 | * @see DataKey#WON 31 | */ 32 | boolean getWon(); 33 | 34 | /** 35 | * Get the current level's definition. 36 | * 37 | * @return the definition 38 | */ 39 | LevelDefinition getDefinition(); 40 | 41 | 42 | } 43 | -------------------------------------------------------------------------------- /project/persistence/src/main/java/rekit/persistence/level/LevelData.java: -------------------------------------------------------------------------------- 1 | package rekit.persistence.level; 2 | 3 | import java.util.HashMap; 4 | import java.util.Map; 5 | 6 | import javax.persistence.Entity; 7 | import javax.persistence.GeneratedValue; 8 | import javax.persistence.Id; 9 | 10 | import org.fuchss.objectcasket.port.ObjectCasketCMP; 11 | 12 | @Entity 13 | public final class LevelData { 14 | @Id 15 | @GeneratedValue 16 | public Integer levelId; 17 | 18 | public final String levelName; 19 | public final Integer levelType; 20 | public final String data; 21 | 22 | public int highscore; 23 | public boolean success; 24 | public boolean won; 25 | 26 | @SuppressWarnings("unused") 27 | private LevelData() { 28 | this(null, null, null); 29 | } 30 | 31 | public LevelData(String levelName, Integer levelType, String levelData) { 32 | this.levelName = levelName; 33 | this.levelType = levelType; 34 | this.data = levelData; 35 | } 36 | 37 | @Override 38 | public String toString() { 39 | return "LevelData [levelId=" + this.levelId + ", levelName=" + this.levelName + ", levelType=" + this.levelType + ", highscore=" + this.highscore + ", success=" + this.success + ", won=" + this.won + "]"; 40 | } 41 | 42 | public static Map getCompare() { 43 | Map res = new HashMap<>(); 44 | res.put("levelName", ObjectCasketCMP.EQUAL); 45 | res.put("levelType", ObjectCasketCMP.EQUAL); 46 | res.put("data", ObjectCasketCMP.EQUAL); 47 | return res; 48 | } 49 | } -------------------------------------------------------------------------------- /project/persistence/src/main/java/rekit/persistence/level/LevelType.java: -------------------------------------------------------------------------------- 1 | package rekit.persistence.level; 2 | 3 | /** 4 | * The type of a level. 5 | * 6 | * @author Dominik Fuchss 7 | * 8 | */ 9 | public enum LevelType { 10 | /** 11 | * Infinite level. 12 | */ 13 | Infinite_Fun, 14 | /** 15 | * Level of the day. 16 | */ 17 | Level_of_the_Day, 18 | /** 19 | * Arcade level. 20 | */ 21 | Arcade, 22 | /** 23 | * Boss Rush Mode. 24 | */ 25 | Boss_Rush, 26 | /** 27 | * Type for tests. 28 | */ 29 | Test 30 | } -------------------------------------------------------------------------------- /project/persistence/src/main/java/rekit/persistence/level/SettingKey.java: -------------------------------------------------------------------------------- 1 | package rekit.persistence.level; 2 | 3 | /** 4 | * This enum defines all valid settings of a {@link LevelDefinition}. 5 | * 6 | * @author Dominik Fuchss 7 | * @see LevelDefinition#setSetting(SettingKey, String) 8 | * @see LevelDefinition#getSetting(SettingKey) 9 | * 10 | */ 11 | public enum SettingKey { 12 | /** 13 | * The name of the level (id=name). 14 | */ 15 | NAME("name"), 16 | /** 17 | * The group of the level for arcade grouping (id=group). 18 | */ 19 | GROUP("group"), 20 | /** 21 | * Indicates whether coins shall automatically spawn (id=autoCoinSpawn). 22 | */ 23 | AUTO_COIN_SPAWN("autoCoinSpawn"), 24 | /** 25 | * Indicates whether the level is infinite (does not end) (id=infinite). 26 | */ 27 | INFINITE("infinite"), 28 | /** 29 | * Indicates whether the structures can be shuffled (id=shuffle). 30 | */ 31 | SHUFFLE("shuffle"), 32 | /** 33 | * Indicates whether it is allowed to create gaps (only floor) sections 34 | * between different structures (id=doGaps). 35 | */ 36 | DO_GAPS("doGaps"); 37 | /** 38 | * The id for the level-files. 39 | */ 40 | private final String id; 41 | 42 | /** 43 | * Create a new SettingKey by id. 44 | * 45 | * @param id 46 | * the id 47 | */ 48 | SettingKey(String id) { 49 | this.id = id; 50 | } 51 | 52 | /** 53 | * Get the id of the SettingKey 54 | * 55 | * @return the id 56 | */ 57 | String getID() { 58 | return this.id; 59 | } 60 | 61 | /** 62 | * Find SettingKey by id. 63 | * 64 | * @param id 65 | * the id 66 | * @return the key or {@code null} if not found 67 | */ 68 | public static final SettingKey getByString(String id) { 69 | for (SettingKey key : SettingKey.values()) { 70 | if (key.id.matches(id)) { 71 | return key; 72 | } 73 | } 74 | return null; 75 | } 76 | 77 | @Override 78 | public String toString() { 79 | return this.id; 80 | } 81 | } 82 | -------------------------------------------------------------------------------- /project/persistence/src/main/java/rekit/persistence/level/parser/Token.java: -------------------------------------------------------------------------------- 1 | package rekit.persistence.level.parser; 2 | 3 | /** 4 | * This class represents a token for the LevelLanguage. 5 | * 6 | * @author Dominik Fuchss 7 | * @see TokenType 8 | */ 9 | public class Token { 10 | 11 | /** The type of the Token. */ 12 | private TokenType type; 13 | 14 | /** The value of the Token. */ 15 | private String value; 16 | 17 | /** 18 | * This creates a new Token by Value. 19 | * 20 | * @param value 21 | * value 22 | */ 23 | public Token(String value) { 24 | this.value = value; 25 | this.type = TokenType.calcType(value); 26 | } 27 | 28 | private Token(String value, TokenType type) { 29 | this.value = value; 30 | this.type = type; 31 | } 32 | 33 | /** 34 | * This creates an EOS token. 35 | * 36 | * @return an EOS token 37 | */ 38 | public static Token getEOSToken() { 39 | return new Token(null, TokenType.EOS); 40 | } 41 | 42 | /** 43 | * Get the TokenType. 44 | * 45 | * @return the Type 46 | */ 47 | public TokenType getType() { 48 | return this.type; 49 | } 50 | 51 | /** 52 | * Get the Token Value. 53 | * 54 | * @return the Value 55 | */ 56 | public String getValue() { 57 | return this.value; 58 | } 59 | 60 | @Override 61 | public String toString() { 62 | return "{Type: " + this.type + " Value: " + this.value + "}"; 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /project/persistence/src/main/java/rekit/persistence/level/parser/TokenType.java: -------------------------------------------------------------------------------- 1 | package rekit.persistence.level.parser; 2 | 3 | import java.util.HashMap; 4 | import java.util.Map; 5 | 6 | /** 7 | * This class defines the different TokenTypes which exist in the LevelLanguage. 8 | * 9 | * @author Dominik Fuchss 10 | * 11 | */ 12 | public enum TokenType { 13 | /** 14 | * A normal setting for the level. 15 | */ 16 | SETTING, 17 | /** 18 | * A setting which belongs to a boss. 19 | */ 20 | BOSS_SETTING, 21 | /** 22 | * An Alias. 23 | */ 24 | ALIAS, 25 | /** 26 | * Mapping. 27 | */ 28 | MAPPING, 29 | /** 30 | * Begin of an Level or an LevelLine (equals "{"). 31 | */ 32 | BEGIN, 33 | /** 34 | * End of an Level or an LevelLine (equals "}"). 35 | */ 36 | END, 37 | /** 38 | * End of String Token. 39 | */ 40 | EOS, 41 | /** 42 | * Token for RAW content. 43 | */ 44 | RAW, 45 | /** 46 | * Token for an delimiter of an Setting or Alias (equals "::"). 47 | */ 48 | DELIMITER; 49 | 50 | /** Map for Special Identifiers to Special TokenType. */ 51 | static final Map SPECIAL_ID_MAP_TO_TYPES = new HashMap() { 52 | private static final long serialVersionUID = -7109095209912302200L; 53 | 54 | { 55 | this.put("{", TokenType.BEGIN); 56 | this.put("}", TokenType.END); 57 | this.put("::", TokenType.DELIMITER); 58 | this.put("#ALIAS", TokenType.ALIAS); 59 | this.put("#BOSS_SETTING", TokenType.BOSS_SETTING); 60 | this.put("#SETTING", TokenType.SETTING); 61 | 62 | } 63 | }; 64 | 65 | /** 66 | * Calculate type. 67 | * 68 | * @param input 69 | * the input 70 | * @return the token type 71 | */ 72 | public static TokenType calcType(String input) { 73 | TokenType type = TokenType.SPECIAL_ID_MAP_TO_TYPES.get(input); 74 | if (type == null) { 75 | return TokenType.determinateByContent(input); 76 | } 77 | return type; 78 | } 79 | 80 | /** 81 | * Find value from content. 82 | * 83 | * @param input 84 | * the input 85 | * @return the type 86 | */ 87 | private static TokenType determinateByContent(String input) { 88 | if (input.matches("(\\w|(\\+|-)?\\d|_|\\.)+->(\\w|\\d|_|-|\\.|:)+")) { 89 | return TokenType.MAPPING; 90 | } 91 | return TokenType.RAW; 92 | } 93 | } 94 | -------------------------------------------------------------------------------- /project/persistence/src/main/java/rekit/persistence/level/parser/Tokenizer.java: -------------------------------------------------------------------------------- 1 | package rekit.persistence.level.parser; 2 | 3 | import java.util.StringTokenizer; 4 | 5 | /** 6 | * This class realizes a tokenizer for the LevelLanguage. 7 | * 8 | * @author Dominik Fuchss 9 | * @see TokenType 10 | * 11 | */ 12 | public class Tokenizer { 13 | /** 14 | * The original input string. 15 | */ 16 | private final String input; 17 | /** 18 | * The inner tokenizer. 19 | */ 20 | private final StringTokenizer scanner; 21 | 22 | /** 23 | * Instantiate a new Tokenizer by input string. 24 | * 25 | * @param input 26 | * the input string 27 | */ 28 | public Tokenizer(String input) { 29 | if (input == null) { 30 | throw new IllegalArgumentException("Null is no input!"); 31 | } 32 | String modIn = "" + input; 33 | for (String k : TokenType.SPECIAL_ID_MAP_TO_TYPES.keySet()) { 34 | modIn = modIn.replace(k, " " + k + " "); 35 | } 36 | this.input = modIn; 37 | this.scanner = new StringTokenizer(this.input, " \t\n\r"); 38 | } 39 | 40 | /** 41 | * Get the next token. 42 | * 43 | * @return the token 44 | */ 45 | public Token nextToken() { 46 | if (!this.scanner.hasMoreTokens()) { 47 | return Token.getEOSToken(); 48 | } 49 | return new Token(this.scanner.nextToken()); 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /project/persistence/src/main/java/rekit/persistence/level/parser/UnexpectedTokenException.java: -------------------------------------------------------------------------------- 1 | package rekit.persistence.level.parser; 2 | 3 | /** 4 | * The Class UnexpectedTokenExecption.
5 | * This exception will thrown when an Unexpected Token reached 6 | * 7 | * @author Dominik Fuchss 8 | */ 9 | public class UnexpectedTokenException extends RuntimeException { 10 | 11 | /** UID. */ 12 | private static final long serialVersionUID = 4789321964295484155L; 13 | 14 | /** 15 | * Instantiates a new unexpected token execption. 16 | * 17 | * @param foundToken 18 | * the unexpected Token 19 | * @param expectedToken 20 | * the expected Type 21 | */ 22 | public UnexpectedTokenException(Token foundToken, TokenType expectedToken) { 23 | 24 | super("Invalid Token: " + foundToken + " expected Type: " + expectedToken); 25 | 26 | } 27 | 28 | /** 29 | * Instantiates a new unexpected token execption. 30 | * 31 | * @param foundToken 32 | * the unexpected Token 33 | * @param comment 34 | * your comment 35 | */ 36 | public UnexpectedTokenException(Token foundToken, String comment) { 37 | super("Invalid Token: " + foundToken + " expected: " + comment); 38 | } 39 | } 40 | --------------------------------------------------------------------------------