Skip to content

Commit

Permalink
Interface ObjectGroup hinzugefügt, um Objekte direkt in Verbindung mi…
Browse files Browse the repository at this point in the history
…t anderen Objekten handhaben zu können;

rotate(ang) in NextShape eingefügt, um gedrehte Objekte zu realisieren;

git-svn-id: https://jumpnevolve.googlecode.com/svn/trunk/jumpnevolve@306 42192f38-024e-0d60-f621-68f43529c6e9
  • Loading branch information
erik.wagner1994 committed Nov 3, 2011
1 parent 413631c commit f0ce3d1
Show file tree
Hide file tree
Showing 6 changed files with 59 additions and 8 deletions.
14 changes: 10 additions & 4 deletions src/com/googlecode/jumpnevolve/game/objects/Cannonball.java
Expand Up @@ -10,16 +10,22 @@

/**
* @author Erik Wagner
*
*
*/
class Cannonball extends Shot {

private static final long serialVersionUID = -2667560387023995791L;

/**
* Erzeugt eine neue Kanonenkugel
*
* @param world
* @param shape
* @param livingTime
* Die Welt für das Objekt
* @param position
* Die Position, an der die Kanonenkugel startet
* @param shotDirection
* @param shotSpeed
* Die Richtung, in die sich die Kanonenkugel anfänglich bewegt
* (--> wegen Schwerkraft)
*/
public Cannonball(World world, Vector position, Vector shotDirection) {
super(world, ShapeFactory.createCircle(position, 10), 10.0f,
Expand Down
15 changes: 15 additions & 0 deletions src/com/googlecode/jumpnevolve/graphics/world/ObjectGroup.java
@@ -0,0 +1,15 @@
package com.googlecode.jumpnevolve.graphics.world;

/**
* Ein Interface für Objekte, die aus mehreren Objekten bestehen.
* <p>
* Die zusätzlichen Objekte werden durch {@link getObjects()} zurückgegeben und
* in die World automatisch eingebunden.
*
* @author Erik Wagner
*
*/
public interface ObjectGroup {

public AbstractObject[] getObjects();
}
6 changes: 6 additions & 0 deletions src/com/googlecode/jumpnevolve/graphics/world/World.java
Expand Up @@ -172,6 +172,12 @@ public void add(Object object) {
if (!this.objects.contains(object)) {
this.objects.add((AbstractObject) object);
addToObjectList((AbstractObject) object);
if (object instanceof ObjectGroup) {
for (AbstractObject obj : ((ObjectGroup) object)
.getObjects()) {
this.add(obj);
}
}
}
}
}
Expand Down
11 changes: 8 additions & 3 deletions src/com/googlecode/jumpnevolve/math/NextCircle.java
Expand Up @@ -7,7 +7,7 @@

/**
* @author Erik Wagner
*
*
*/
class NextCircle implements ConvexShape {

Expand Down Expand Up @@ -138,7 +138,12 @@ public String toString() {

@Override
public HelpRectangle getBoundingRect() {
return new HelpRectangle(this.getLeftEnd(), this.getRightEnd(), this
.getUpperEnd(), this.getLowerEnd());
return new HelpRectangle(this.getLeftEnd(), this.getRightEnd(),
this.getUpperEnd(), this.getLowerEnd());
}

@Override
public NextShape rotate(float ang) {
return this;
}
}
13 changes: 12 additions & 1 deletion src/com/googlecode/jumpnevolve/math/NextPolygon.java
Expand Up @@ -7,7 +7,7 @@

/**
* @author Erik Wagner
*
*
*/
class NextPolygon implements ConvexShape {

Expand Down Expand Up @@ -401,4 +401,15 @@ public HelpRectangle getBoundingRect() {
}
return this.boundingRect;
}

@Override
public NextShape rotate(float ang) {
ArrayList<Vector> points = new ArrayList<Vector>();
for (Vector vec : this.relativePoints) {
points.add(vec.rotate(ang));
}
NextPolygon re = new NextPolygon(this.center, points);
re.finish();
return re;
}
}
8 changes: 8 additions & 0 deletions src/com/googlecode/jumpnevolve/math/NextShape.java
Expand Up @@ -15,6 +15,14 @@ public interface NextShape {
public CollisionResult getCollision(NextShape other, Vector deltaVelocity,
boolean thisMoveable, boolean otherMoveable);

/**
* Rotiert das Shape um einen Winkel im Uhrzeigersinn
*
* @param ang
* @return
*/
public NextShape rotate(float ang);

public boolean isPointIn(Vector point);

/**
Expand Down

0 comments on commit f0ce3d1

Please sign in to comment.