Skip to content

Commit

Permalink
Add activating the belts
Browse files Browse the repository at this point in the history
  • Loading branch information
MathiasSJacobsen committed Apr 14, 2020
1 parent 0beee68 commit 5416942
Show file tree
Hide file tree
Showing 3 changed files with 64 additions and 142 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
<node x="467.15" y="1184.0">inf112.skeleton.app.cards.ProgramCard</node>
<node x="254.2333333333333" y="1707.0">inf112.skeleton.app.RallyGame</node>
<node x="250.7333333333333" y="1876.0">inf112.skeleton.app.Main</node>
<node x="457.4" y="1420.0">inf112.skeleton.app.cards.Deck</node>
<node x="48.900000000000034" y="147.0">inf112.skeleton.app.Player</node>
<node x="457.4" y="1420.0">inf112.skeleton.app.cards.Deck</node>
<node x="1.3568347953215607" y="0.0">inf112.skeleton.app.enums.Direction</node>
<node x="43.39999999999998" y="405.0">inf112.skeleton.app.BoardLayers</node>
<node x="201.89999999999998" y="1151.0">inf112.skeleton.app.screens.GameScreen</node>
Expand All @@ -16,156 +16,17 @@
<node x="309.4" y="438.5">inf112.skeleton.app.objects.Flag</node>
<node x="471.4" y="438.0">inf112.skeleton.app.enums.TileID</node>
<node x="494.65" y="839.5">inf112.skeleton.app.enums.Rotate</node>
<node x="551.8166666666666" y="1740.0">inf112.skeleton.app.cards.CardHand</node>
</nodes>
<notes />
<edges>
<edge source="inf112.skeleton.app.Board" target="inf112.skeleton.app.enums.TileID">
<point x="81.66666666666669" y="-247.0" />
<point x="380.56666666666666" y="577.0" />
<point x="522.4" y="577.0" />
<point x="0.0" y="38.0" />
</edge>
<edge source="inf112.skeleton.app.Board" target="inf112.skeleton.app.objects.Flag">
<point x="54.44444444444446" y="-247.0" />
<point x="353.34444444444443" y="567.0" />
<point x="415.8999999999999" y="567.0" />
<point x="35.49999999999994" y="37.5" />
</edge>
<edge source="inf112.skeleton.app.cards.CardHand" target="inf112.skeleton.app.cards.Deck">
<point x="-39.75" y="-26.5" />
<point x="591.5666666666666" y="1687.0" />
<point x="610.7333333333333" y="1687.0" />
<point x="61.33333333333337" y="93.0" />
</edge>
<edge source="inf112.skeleton.app.RallyGame" target="inf112.skeleton.app.cards.Deck">
<point x="63.70833333333337" y="-59.5" />
<point x="387.44166666666666" y="1687.0" />
<point x="549.4" y="1687.0" />
<point x="0.0" y="93.0" />
</edge>
<edge source="inf112.skeleton.app.screens.GameScreen" target="inf112.skeleton.app.Board">
<point x="0.0" y="-104.0" />
<point x="293.4" y="1131.0" />
<point x="268.275" y="1131.0" />
<point x="-30.625" y="247.0" />
</edge>
<edge source="inf112.skeleton.app.Main" target="inf112.skeleton.app.RallyGame">
<point x="0.0" y="-26.5" />
<point x="0.0" y="59.5" />
</edge>
<edge source="inf112.skeleton.app.cards.CardHand" target="inf112.skeleton.app.cards.ProgramCard">
<point x="39.75" y="-26.5" />
<point x="671.0666666666666" y="1687.0" />
<point x="651.9" y="1687.0" />
<point x="651.9" y="1384.0" />
<point x="680.65" y="1384.0" />
<point x="91.5" y="71.0" />
</edge>
<edge source="inf112.skeleton.app.RallyGame" target="inf112.skeleton.app.Board">
<point x="-40.54166666666674" y="-59.5" />
<point x="283.19166666666655" y="1667.0" />
<point x="165.89999999999998" y="1667.0" />
<point x="165.89999999999998" y="1131.0" />
<point x="207.02499999999998" y="1131.0" />
<point x="-91.875" y="247.0" />
</edge>
<edge source="inf112.skeleton.app.cards.ProgramCard" target="inf112.skeleton.app.enums.Rotate">
<point x="-61.0" y="-71.0" />
<point x="528.15" y="1131.0" />
<point x="539.65" y="1131.0" />
<point x="0.0" y="14.5" />
</edge>
<edge source="inf112.skeleton.app.RallyGame" target="inf112.skeleton.app.screens.MenuScreen">
<point x="-17.375" y="-59.5" />
<point x="306.3583333333333" y="1647.0" />
<point x="224.58545321637422" y="1647.0" />
<point x="-60.66666666666663" y="104.0" />
</edge>
<edge source="inf112.skeleton.app.screens.MenuScreen" target="inf112.skeleton.app.RallyGame">
<point x="60.66666666666663" y="104.0" />
<point x="345.9187865497075" y="1637.0" />
<point x="329.5249999999999" y="1637.0" />
<point x="5.791666666666629" y="-59.5" />
</edge>
<edge source="inf112.skeleton.app.BoardLayers" target="inf112.skeleton.app.Player">
<point x="0.0" y="-71.0" />
<point x="0.0" y="104.0" />
</edge>
<edge source="inf112.skeleton.app.cards.Deck" target="inf112.skeleton.app.cards.ProgramCard">
<point x="23.0" y="-93.0" />
<point x="572.4" y="1384.0" />
<point x="558.65" y="1384.0" />
<point x="-30.5" y="71.0" />
</edge>
<edge source="inf112.skeleton.app.Board" target="inf112.skeleton.app.Player">
<point x="-27.22222222222223" y="-247.0" />
<point x="271.67777777777775" y="587.0" />
<point x="287.9" y="587.0" />
<point x="287.9" y="385.0" />
<point x="205.0" y="385.0" />
<point x="44.599999999999966" y="104.0" />
</edge>
<edge source="inf112.skeleton.app.screens.GameScreen" target="inf112.skeleton.app.RallyGame">
<point x="-61.0" y="104.0" />
<point x="232.39999999999998" y="1384.0" />
<point x="183.75211988304085" y="1384.0" />
<point x="183.75211988304085" y="1657.0" />
<point x="294.7749999999999" y="1657.0" />
<point x="-28.95833333333337" y="-59.5" />
</edge>
<edge source="inf112.skeleton.app.cards.Deck" target="inf112.skeleton.app.enums.Rotate">
<point x="-69.0" y="-93.0" />
<point x="480.4" y="1384.0" />
<point x="442.9" y="1384.0" />
<point x="442.9" y="1131.0" />
<point x="509.65" y="1131.0" />
<point x="-30.0" y="14.5" />
</edge>
<edge source="inf112.skeleton.app.RallyGame" target="inf112.skeleton.app.Player">
<point x="-52.125000000000114" y="-59.5" />
<point x="271.6083333333332" y="1677.0" />
<point x="21.899999999999977" y="1677.0" />
<point x="21.899999999999977" y="375.0" />
<point x="71.20000000000005" y="375.0" />
<point x="-89.19999999999999" y="104.0" />
</edge>
<edge source="inf112.skeleton.app.RallyGame" target="inf112.skeleton.app.enums.Direction">
<point x="-63.70833333333337" y="-59.5" />
<point x="260.0249999999999" y="1687.0" />
<point x="0.0" y="1687.0" />
<point x="0.0" y="122.0" />
<point x="48.98183479532156" y="122.0" />
<point x="-142.875" y="48.5" />
</edge>
<edge source="inf112.skeleton.app.Board" target="inf112.skeleton.app.enums.Direction">
<point x="108.88888888888891" y="-247.0" />
<point x="407.7888888888889" y="587.0" />
<point x="583.9" y="587.0" />
<point x="583.9" y="122.0" />
<point x="334.73183479532156" y="122.0" />
<point x="142.875" y="48.5" />
</edge>
<edge source="inf112.skeleton.app.Player" target="inf112.skeleton.app.enums.Direction">
<point x="55.75" y="-104.0" />
<point x="216.15000000000003" y="122.0" />
<point x="239.48183479532156" y="122.0" />
<point x="47.625" y="48.5" />
</edge>
<edge source="inf112.skeleton.app.Board" target="inf112.skeleton.app.BoardLayers">
<point x="-81.66666666666669" y="-247.0" />
<point x="217.2333333333333" y="577.0" />
<point x="101.89999999999998" y="577.0" />
<point x="-58.5" y="71.0" />
</edge>
<edge source="inf112.skeleton.app.screens.MenuScreen" target="inf112.skeleton.app.screens.GameScreen">
<point x="0.0" y="-104.0" />
<point x="285.25211988304085" y="1384.0" />
<point x="293.4" y="1384.0" />
<point x="0.0" y="104.0" />
</edge>
</edges>
<settings layout="Hierarchic Group" zoom="0.5072014617971858" x="497.14844769341676" y="569.5093419891617" />
<settings layout="Hierarchic Group" zoom="0.18873873873873873" x="408.5" y="1100.0" />
<SelectedNodes />
<Categories>
<Category>Constructors</Category>
Expand Down
27 changes: 26 additions & 1 deletion src/main/java/inf112/skeleton/app/BoardLayers.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
import inf112.skeleton.app.objects.Belt;

import java.util.ArrayList;
import java.util.Vector;

public abstract class BoardLayers {

Expand All @@ -31,6 +30,7 @@ public abstract class BoardLayers {
public final ArrayList<RotatePad> rotatePads;
public final ArrayList<Vector2> holes;
public final ArrayList<Belt> belts;
public final ArrayList<Belt> expressBelts;

public int boardWidth;
public int boardHeight;
Expand All @@ -53,6 +53,7 @@ public BoardLayers(String mapPath) {
this.flags = new ArrayList<>();
this.lasers = new ArrayList<>();
this.belts = new ArrayList<>();
this.expressBelts = new ArrayList<>();

findFlags();
findRotatePadsAndHolesAndBelts();
Expand Down Expand Up @@ -158,52 +159,76 @@ public void findRotatePadsAndHolesAndBelts() {
// Add express Belts
} else if (ID == TileID.EAST_TO_SOUTH_EXPRESS_BELT.getId()) {
belts.add(new Belt(Direction.SOUTH, 2, new Vector2(x, y)));
expressBelts.add(new Belt(Direction.SOUTH, 2, new Vector2(x, y)));
} else if (ID == TileID.NORTH_TO_EAST_EXPRESS_BELT.getId()) {
belts.add(new Belt(Direction.EAST, 2, new Vector2(x, y)));
expressBelts.add(new Belt(Direction.EAST, 2, new Vector2(x, y)));
} else if (ID == TileID.WEST_TO_NORTH_EXPRESS_BELT.getId()) {
belts.add(new Belt(Direction.NORTH, 2, new Vector2(x, y)));
expressBelts.add(new Belt(Direction.NORTH, 2, new Vector2(x, y)));
} else if (ID == TileID.SOUTH_TO_WEST_EXPRESS_BELT.getId()) {
belts.add(new Belt(Direction.WEST, 2, new Vector2(x, y)));
expressBelts.add(new Belt(Direction.WEST, 2, new Vector2(x, y)));
} else if (ID == TileID.EAST_TO_NORTH_EXPRESS_BELT.getId()) {
belts.add(new Belt(Direction.NORTH, 2, new Vector2(x, y)));
expressBelts.add(new Belt(Direction.NORTH, 2, new Vector2(x, y)));
} else if (ID == TileID.NORTH_TO_WEST_EXPRESS_BELT.getId()) {
belts.add(new Belt(Direction.WEST, 2, new Vector2(x, y)));
expressBelts.add(new Belt(Direction.WEST, 2, new Vector2(x, y)));
} else if (ID == TileID.WEST_TO_SOUTH_EXPRESS_BELT.getId()) {
belts.add(new Belt(Direction.SOUTH, 2, new Vector2(x, y)));
expressBelts.add(new Belt(Direction.SOUTH, 2, new Vector2(x, y)));
} else if (ID == TileID.SOUTH_TO_EAST_EXPRESS_BELT.getId()) {
belts.add(new Belt(Direction.EAST, 2, new Vector2(x, y)));
expressBelts.add(new Belt(Direction.EAST, 2, new Vector2(x, y)));
} else if (ID == TileID.EAST_TO_WEST_EXPRESS_BELT.getId()) {
belts.add(new Belt(Direction.WEST, 2, new Vector2(x, y)));
expressBelts.add(new Belt(Direction.WEST, 2, new Vector2(x, y)));
} else if (ID == TileID.NORTH_TO_SOUTH_EXPRESS_BELT.getId()) {
belts.add(new Belt(Direction.SOUTH, 2, new Vector2(x, y)));
expressBelts.add(new Belt(Direction.SOUTH, 2, new Vector2(x, y)));
} else if (ID == TileID.WEST_TO_EAST_EXPRESS_BELT.getId()) {
belts.add(new Belt(Direction.EAST, 2, new Vector2(x, y)));
expressBelts.add(new Belt(Direction.EAST, 2, new Vector2(x, y)));
} else if (ID == TileID.SOUTH_TO_NORTH_EXPRESS_BELT.getId()) {
belts.add(new Belt(Direction.NORTH, 2, new Vector2(x, y)));
expressBelts.add(new Belt(Direction.NORTH, 2, new Vector2(x, y)));
} else if (ID == TileID.WESTSOUTH_TO_NORTH_EXPRESS_BELT.getId()) {
belts.add(new Belt(Direction.NORTH, 2, new Vector2(x, y)));
expressBelts.add(new Belt(Direction.NORTH, 2, new Vector2(x, y)));
} else if (ID == TileID.EASTSOUTH_TO_NORTH_EXPRESS_BELT.getId()) {
belts.add(new Belt(Direction.NORTH, 2, new Vector2(x, y)));
expressBelts.add(new Belt(Direction.NORTH, 2, new Vector2(x, y)));
} else if (ID == TileID.WESTEAST_TO_NORTH_EXPRESS_BELT.getId()) {
belts.add(new Belt(Direction.NORTH, 2, new Vector2(x, y)));
expressBelts.add(new Belt(Direction.NORTH, 2, new Vector2(x, y)));
} else if (ID == TileID.WESTNORTH_TO_SOUTH_EXPRESS_BELT.getId()) {
belts.add(new Belt(Direction.SOUTH, 2, new Vector2(x, y)));
expressBelts.add(new Belt(Direction.SOUTH, 2, new Vector2(x, y)));
} else if (ID == TileID.EASTNORTH_TO_SOUTH_EXPRESS_BELT.getId()) {
belts.add(new Belt(Direction.SOUTH, 2, new Vector2(x, y)));
expressBelts.add(new Belt(Direction.SOUTH, 2, new Vector2(x, y)));
} else if (ID == TileID.WESTEAST_TO_SOUTH_EXPRESS_BELT.getId()) {
belts.add(new Belt(Direction.SOUTH, 2, new Vector2(x, y)));
expressBelts.add(new Belt(Direction.SOUTH, 2, new Vector2(x, y)));
} else if (ID == TileID.WESTSOUTH_TO_EAST_EXPRESS_BELT.getId()) {
belts.add(new Belt(Direction.EAST, 2, new Vector2(x, y)));
expressBelts.add(new Belt(Direction.EAST, 2, new Vector2(x, y)));
} else if (ID == TileID.WESTNORTH_TO_EAST_EXPRESS_BELT.getId()) {
belts.add(new Belt(Direction.EAST, 2, new Vector2(x, y)));
expressBelts.add(new Belt(Direction.EAST, 2, new Vector2(x, y)));
} else if (ID == TileID.NORTHSOUTH_TO_EAST_EXPRESS_BELT.getId()) {
belts.add(new Belt(Direction.EAST, 2, new Vector2(x, y)));
expressBelts.add(new Belt(Direction.EAST, 2, new Vector2(x, y)));
} else if (ID == TileID.EASTSOUTH_TO_WEST_EXPRESS_BELT.getId()) {
belts.add(new Belt(Direction.WEST, 2, new Vector2(x, y)));
expressBelts.add(new Belt(Direction.WEST, 2, new Vector2(x, y)));
} else if (ID == TileID.EASTNORTH_TO_WEST_EXPRESS_BELT.getId()) {
belts.add(new Belt(Direction.WEST, 2, new Vector2(x, y)));
expressBelts.add(new Belt(Direction.WEST, 2, new Vector2(x, y)));
} else if (ID == TileID.NORTHSOUTH_TO_WEST_EXPRESS_BELT.getId()) {
belts.add(new Belt(Direction.WEST, 2, new Vector2(x, y)));
expressBelts.add(new Belt(Direction.WEST, 2, new Vector2(x, y)));
}
}
}
Expand Down
36 changes: 36 additions & 0 deletions src/main/java/inf112/skeleton/app/RallyGame.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import inf112.skeleton.app.cards.ProgramCard;
import inf112.skeleton.app.enums.Direction;
import inf112.skeleton.app.enums.Rotate;
import inf112.skeleton.app.objects.Belt;
import inf112.skeleton.app.objects.Laser;
import inf112.skeleton.app.objects.RotatePad;
import inf112.skeleton.app.screens.GifScreen;
Expand Down Expand Up @@ -143,6 +144,7 @@ public void doTurn() {
removeDeadPlayers();
dealCards();
selectCards();

}
}

Expand Down Expand Up @@ -267,6 +269,40 @@ public void activateRotatePads() {
}
}
}
public void activateBelts(boolean onlyExpress) {
ArrayList<Belt> belts;

if (onlyExpress){
belts = board.expressBelts;
} else {
belts = board.belts;
}

for (Player player : board.getPlayers()) {
for (Belt belt : belts){
float positionX = player.getPosition().x;
float positionY = player.getPosition().y;
Direction direction = belt.getDirection();

if (player.getPosition().equals(belt.getPosition())){

switch (direction){
case NORTH:
player.setPosition(new Vector2(positionX, positionY + 1));
case EAST:
player.setPosition(new Vector2(positionX + 1, positionY));
case WEST:
player.setPosition(new Vector2(positionX - 1, positionY));
case SOUTH:
player.setPosition(new Vector2(positionX, positionY - 1));
default:
System.out.println("There is something wrong her! ERROR");
return;
}
}
}
}
}

public void render() {
super.render();
Expand Down

0 comments on commit 5416942

Please sign in to comment.