Skip to content

Commit

Permalink
Changed project package struckture
Browse files Browse the repository at this point in the history
  • Loading branch information
Tobi-Tob committed Jul 5, 2023
1 parent 7be2b1e commit c593eb2
Show file tree
Hide file tree
Showing 71 changed files with 136 additions and 142 deletions.
Binary file modified SpaceApes/bin/actions/ChangeAngleAction.class
Binary file not shown.
Binary file modified SpaceApes/bin/actions/ChangePowerAction.class
Binary file not shown.
Binary file modified SpaceApes/bin/actions/ChangeWeaponAction.class
Binary file not shown.
Binary file modified SpaceApes/bin/actions/ItemCollisionAction.class
Binary file not shown.
Binary file modified SpaceApes/bin/actions/MoveOnPlanetAction.class
Binary file not shown.
Binary file modified SpaceApes/bin/actions/PolicyNextMoveAction.class
Binary file not shown.
Binary file modified SpaceApes/bin/actions/ProjectileBehaviorAction.class
Binary file not shown.
Binary file modified SpaceApes/bin/actions/ShootAction.class
Binary file not shown.
Binary file modified SpaceApes/bin/entities/Ape.class
Binary file not shown.
Binary file modified SpaceApes/bin/entities/ControlPanel.class
Binary file not shown.
Binary file modified SpaceApes/bin/entities/DamageDisplay.class
Binary file not shown.
Binary file modified SpaceApes/bin/entities/Planet.class
Binary file not shown.
Binary file modified SpaceApes/bin/entities/Projectile.class
Binary file not shown.
Binary file modified SpaceApes/bin/events/LeavingWorldEvent.class
Binary file not shown.
Binary file modified SpaceApes/bin/events/LessThan2ApesLeftEvent.class
Binary file not shown.
Binary file modified SpaceApes/bin/events/PolicyEvent.class
Binary file not shown.
Binary file modified SpaceApes/bin/factories/ApeFactory.class
Binary file not shown.
Binary file modified SpaceApes/bin/factories/ItemFactory.class
Binary file not shown.
Binary file modified SpaceApes/bin/factories/PlanetFactory$PlanetType.class
Binary file not shown.
Binary file modified SpaceApes/bin/factories/PlanetFactory.class
Binary file not shown.
Binary file modified SpaceApes/bin/factories/ProjectileFactory.class
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file removed SpaceApes/bin/map/Map$1.class
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added SpaceApes/bin/policys/Policy.class
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file removed SpaceApes/bin/spaceapes/Constants.class
Binary file not shown.
Binary file not shown.
Binary file added SpaceApes/bin/spaceapes/Map$1.class
Binary file not shown.
Binary file not shown.
Binary file modified SpaceApes/bin/spaceapes/SpaceApes.class
Binary file not shown.
Binary file added SpaceApes/bin/utils/Constants.class
Binary file not shown.
Binary file removed SpaceApes/bin/utils/Policy.class
Binary file not shown.
Binary file modified SpaceApes/bin/utils/Utils.class
Binary file not shown.
2 changes: 1 addition & 1 deletion SpaceApes/src/actions/ChangeAngleAction.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import eea.engine.component.Component;
import eea.engine.entity.Entity;
import entities.Ape;
import map.Map;
import spaceapes.Map;

public class ChangeAngleAction extends ButtonAnimationAction {
private float angleToChange;
Expand Down
2 changes: 1 addition & 1 deletion SpaceApes/src/actions/ChangePowerAction.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import eea.engine.component.Component;
import eea.engine.entity.Entity;
import entities.Ape;
import map.Map;
import spaceapes.Map;

public class ChangePowerAction extends ButtonAnimationAction {
private float powerToChange;
Expand Down
2 changes: 1 addition & 1 deletion SpaceApes/src/actions/ChangeWeaponAction.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import eea.engine.component.Component;
import eea.engine.entity.Entity;
import entities.Ape;
import map.Map;
import spaceapes.Map;

public class ChangeWeaponAction extends ButtonAnimationAction {

Expand Down
2 changes: 1 addition & 1 deletion SpaceApes/src/actions/ItemCollisionAction.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
import entities.Ape;
import entities.Item;
import factories.ItemFactory.ItemType;
import map.Map;
import spaceapes.Map;

public class ItemCollisionAction implements Action {

Expand Down
4 changes: 2 additions & 2 deletions SpaceApes/src/actions/MoveOnPlanetAction.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
import eea.engine.action.Action;
import eea.engine.component.Component;
import entities.Ape;
import map.Map;
import spaceapes.Constants;
import utils.Constants;
import spaceapes.Map;
import spaceapes.SpaceApes;

public class MoveOnPlanetAction implements Action {
Expand Down
2 changes: 1 addition & 1 deletion SpaceApes/src/actions/PolicyNextMoveAction.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import eea.engine.action.Action;
import eea.engine.component.Component;
import entities.Ape;
import utils.Policy;
import policys.Policy;

public class PolicyNextMoveAction implements Action {

Expand Down
4 changes: 2 additions & 2 deletions SpaceApes/src/actions/ProjectileBehaviorAction.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
import entities.DamageDisplay;
import entities.Projectile;
import factories.ProjectileFactory.ProjectileStatus;
import map.Map;
import spaceapes.Constants;
import utils.Constants;
import spaceapes.Map;
import spaceapes.SpaceApes;
import utils.Utils;

Expand Down
4 changes: 2 additions & 2 deletions SpaceApes/src/actions/ShootAction.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
import factories.ProjectileFactory;
import factories.ProjectileFactory.MovementType;
import factories.ProjectileFactory.ProjectileType;
import map.Map;
import spaceapes.Constants;
import spaceapes.Map;
import utils.Constants;
import utils.Utils;

public class ShootAction implements Action {
Expand Down
21 changes: 14 additions & 7 deletions SpaceApes/src/entities/Ape.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

import org.newdawn.slick.geom.Vector2f;
import eea.engine.entity.Entity;
import spaceapes.Constants;
import policys.Policy;
import utils.Constants;
import spaceapes.SpaceApes;
import utils.Policy;
import utils.Utils;

public class Ape extends Entity {
Expand All @@ -17,7 +17,9 @@ public class Ape extends Entity {
private float movementSpeed; // Faktor fuer die Schrittweite des Affen
private float distancePlanetCenter; // Abstand des Planetenmittelpunkts zur Kreisbahn auf der sich der Affe bewegt

private final float scalingFactor = Constants.APE_DESIRED_SIZE / Utils.pixelLengthToWorldLength(Constants.APE_PIXEL_HEIGHT);
public final int apePixelHeight = 300;
public final int apePixelFeetToCenter = 130;
private final float scalingFactor = Constants.APE_SIZE / Utils.pixelLengthToWorldLength(apePixelHeight);

private final int maxHealth = Constants.APE_MAX_HEALTH;
private final int maxEnergy = Constants.APE_MAX_ENERGY;
Expand Down Expand Up @@ -235,7 +237,7 @@ public void setEnergy(float value) {
public void changeEnergy(float value) {
if (energy + value > maxEnergy) {
energy = maxEnergy;
} else if (energy - value < 0) {
} else if (energy + value < 0) {
energy = 0;
} else {
energy += value;
Expand All @@ -246,8 +248,13 @@ public float getDistanceToPlanetCenter() {
return distancePlanetCenter;
}

public void setDistanceToPlanetCenter(float distancePlanetCenter) {
this.distancePlanetCenter = distancePlanetCenter;
public void setDistanceToPlanetCenter() {
float distance = homePlanet.getRadius()
+ Utils.pixelLengthToWorldLength(apePixelFeetToCenter * scalingFactor);
if (distance < 0.1f) {
throw new RuntimeException("Distance to planet center is to close to 0");
}
this.distancePlanetCenter = distance;
}

public void setPlanet(Planet planet) {
Expand Down Expand Up @@ -278,7 +285,7 @@ public void increaseCoins(int value) {
}

public float getRadiusInWorldUnits() { //necessary for collision check
return Constants.APE_DESIRED_SIZE / 2;
return Constants.APE_SIZE / 2;
}

/**
Expand Down
2 changes: 1 addition & 1 deletion SpaceApes/src/entities/ApeInfoSign.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
import eea.engine.component.render.ImageRenderComponent;
import eea.engine.entity.Entity;
import eea.engine.entity.StateBasedEntityManager;
import spaceapes.Constants;
import utils.Constants;
import spaceapes.SpaceApes;
import utils.Utils;

Expand Down
4 changes: 2 additions & 2 deletions SpaceApes/src/entities/ControlPanel.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@
import factories.ProjectileFactory;
import factories.ProjectileFactory.MovementType;
import factories.ProjectileFactory.ProjectileType;
import map.Map;
import spaceapes.Constants;
import spaceapes.Map;
import spaceapes.SpaceApes;
import utils.Constants;
import utils.Utils;

public class ControlPanel extends Entity {
Expand Down
2 changes: 1 addition & 1 deletion SpaceApes/src/entities/DamageDisplay.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
import org.newdawn.slick.state.StateBasedGame;
import eea.engine.entity.Entity;
import eea.engine.entity.StateBasedEntityManager;
import spaceapes.Constants;
import spaceapes.SpaceApes;
import utils.Constants;
import utils.Utils;

/**
Expand Down
3 changes: 1 addition & 2 deletions SpaceApes/src/entities/Planet.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

import eea.engine.entity.Entity;
import factories.PlanetFactory.PlanetType;
import spaceapes.Constants;
import utils.Utils;

public class Planet extends Entity {
Expand All @@ -29,7 +28,7 @@ public Planet(String entityID) {
* @throws RuntimeException wenn Radius zu klein
*/
public float distanceToApePosition() {
float dist = getRadius() + Utils.pixelLengthToWorldLength(Constants.APE_PIXEL_FEET_TO_CENTER * ape.getScalingFactor());
float dist = getRadius() + Utils.pixelLengthToWorldLength(ape.apePixelFeetToCenter * ape.getScalingFactor());
if (dist > 0.1f) {
return dist;
} else
Expand Down
10 changes: 4 additions & 6 deletions SpaceApes/src/entities/Projectile.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
import factories.PlanetFactory.PlanetType;
import factories.ProjectileFactory.ProjectileStatus;
import factories.ProjectileFactory.ProjectileType;
import map.Map;
import spaceapes.Constants;
import spaceapes.Map;
import utils.Constants;
import utils.Utils;

public class Projectile extends Entity {
Expand All @@ -18,8 +18,8 @@ public class Projectile extends Entity {
private double vx; // Geschwindigkeit in x-Richtung
private double vy; // Geschwindigkeit in y-Richtung
private float direction; // Winkel Spitze des Projektils gegenueber x-Achse
private float rotationSpeed; // Rotationsgeschwindigkeit (wird nicht benutzt)
private final float mass; // verschiede Massen der Geschosse moeglich (wird nicht benutzt)
// private float rotationSpeed; // Rotationsgeschwindigkeit (wird nicht benutzt)
// private final float mass; // verschiede Massen der Geschosse moeglich (wird nicht benutzt)
private ProjectileType type;
private int price = 0; // default
private int maxDamage = 10; // default
Expand All @@ -38,8 +38,6 @@ public Projectile(String entityID, Vector2f coordinates, Vector2f velocity) {
this.setCoordinates(coordinates);
this.setVelocity(velocity);
this.direction = getMovementDirection();
this.rotationSpeed = 0f;
this.mass = 1f;

setPosition(Utils.toPixelCoordinates((float) x, (float) y));
}
Expand Down
2 changes: 1 addition & 1 deletion SpaceApes/src/events/LeavingWorldEvent.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

import eea.engine.entity.Entity;
import eea.engine.event.Event;
import spaceapes.Constants;
import utils.Constants;
import utils.Utils;

public class LeavingWorldEvent extends Event {
Expand Down
2 changes: 1 addition & 1 deletion SpaceApes/src/events/LessThan2ApesLeftEvent.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import org.newdawn.slick.GameContainer;
import org.newdawn.slick.state.StateBasedGame;
import eea.engine.event.Event;
import map.Map;
import spaceapes.Map;

public class LessThan2ApesLeftEvent extends Event {

Expand Down
4 changes: 2 additions & 2 deletions SpaceApes/src/events/PolicyEvent.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
import org.newdawn.slick.state.StateBasedGame;

import eea.engine.event.Event;
import utils.Policy;
import utils.Policy.PolicyAction;
import policys.Policy;
import policys.Policy.PolicyAction;

public class PolicyEvent extends Event {
Policy policy;
Expand Down
20 changes: 6 additions & 14 deletions SpaceApes/src/factories/ApeFactory.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,18 @@
import eea.engine.event.ANDEvent;
import eea.engine.event.Event;
import eea.engine.event.basicevents.KeyDownEvent;
import eea.engine.event.basicevents.KeyPressedEvent;
import eea.engine.event.basicevents.LoopEvent;
import eea.engine.event.basicevents.MouseClickedEvent;
import eea.engine.event.basicevents.MouseEnteredEvent;
import entities.Ape;
import entities.Planet;
import events.PolicyEvent;
import factories.ProjectileFactory.MovementType;
import map.Map;
import spaceapes.Constants;
import policys.Policy;
import policys.Policy.PolicyAction;
import utils.Constants;
import spaceapes.Map;
import spaceapes.SpaceApes;
import utils.Policy;
import utils.Policy.PolicyAction;
import utils.Utils;

public abstract class ApeFactory {
Expand All @@ -49,18 +48,11 @@ public abstract class ApeFactory {
public static Ape createApe(String name, Planet homePlanet, float angleOnPlanet, int apeImageIndex, boolean isActive,
boolean isInteractionAllowed, Policy policy) {

final float scalingFactor = Constants.APE_DESIRED_SIZE / Utils.pixelLengthToWorldLength(Constants.APE_PIXEL_HEIGHT);
final float distancePlanetCenter = homePlanet.getRadius()
+ Utils.pixelLengthToWorldLength(Constants.APE_PIXEL_FEET_TO_CENTER * scalingFactor);
if (distancePlanetCenter < 0.1f) {
throw new RuntimeException("Radius ist zu nah an null");
}

Ape ape = new Ape(name);

ape.setPlanet(homePlanet);
homePlanet.setApe(ape);
ape.setDistanceToPlanetCenter(distancePlanetCenter);
ape.setDistanceToPlanetCenter();
ape.setAngleOnPlanet(angleOnPlanet);
ape.setAngleOfView(0);
ape.setHealth(Constants.APE_MAX_HEALTH);
Expand All @@ -71,7 +63,7 @@ public static Ape createApe(String name, Planet homePlanet, float angleOnPlanet,
ape.setInteractionAllowed(isInteractionAllowed);
ape.setPolicy(policy);
ape.setPosition(Utils.toPixelCoordinates(ape.getWorldCoordinates()));
ape.setScale(scalingFactor);
ape.setScale(ape.getScalingFactor());
ape.setRotation(angleOnPlanet + 90f);

if (SpaceApes.renderImages) {
Expand Down
4 changes: 2 additions & 2 deletions SpaceApes/src/factories/ItemFactory.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
import eea.engine.entity.StateBasedEntityManager;
import eea.engine.event.basicevents.LoopEvent;
import entities.Item;
import map.Map;
import spaceapes.Constants;
import utils.Constants;
import spaceapes.Map;
import spaceapes.SpaceApes;
import utils.Utils;

Expand Down
5 changes: 2 additions & 3 deletions SpaceApes/src/factories/PlanetFactory.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import org.newdawn.slick.geom.Vector2f;

import actions.DisplayPlanetInfoAction;
import actions.MoveInOrbitAction;

import java.util.Random;
Expand All @@ -14,8 +13,8 @@
import eea.engine.entity.Entity;
import eea.engine.entity.StateBasedEntityManager;
import entities.Planet;
import map.Map;
import spaceapes.Constants;
import utils.Constants;
import spaceapes.Map;
import spaceapes.SpaceApes;
import utils.Utils;
import eea.engine.event.basicevents.*;
Expand Down
Loading

0 comments on commit c593eb2

Please sign in to comment.