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