-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
4510c71
commit 6651bf2
Showing
13 changed files
with
416 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package uk.org.ulcompsoc.ld30.components; | ||
|
||
import com.badlogic.ashley.core.Component; | ||
|
||
/** | ||
* @author Ashley Davis (SgtCoDFish) | ||
*/ | ||
public class Ball extends Component { | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package uk.org.ulcompsoc.ld30.components; | ||
|
||
import com.badlogic.ashley.core.Component; | ||
import com.badlogic.ashley.core.ComponentMapper; | ||
import com.badlogic.ashley.core.Entity; | ||
import com.badlogic.gdx.utils.GdxRuntimeException; | ||
|
||
/** | ||
* @author Ashley Davis (SgtCoDFish) | ||
*/ | ||
public class CheatingAI extends Component { | ||
public Entity followMe = null; | ||
|
||
public CheatingAI(Entity followMe) { | ||
if (!ComponentMapper.getFor(Position.class).has(followMe)) { | ||
throw new GdxRuntimeException( | ||
"Created cheating ai with invalid ball: must have Position component already added."); | ||
} | ||
|
||
this.followMe = followMe; | ||
} | ||
} |
18 changes: 18 additions & 0 deletions
18
core/src/uk/org/ulcompsoc/ld30/components/MouseTracker.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package uk.org.ulcompsoc.ld30.components; | ||
|
||
import com.badlogic.ashley.core.Component; | ||
|
||
/** | ||
* @author Ashley Davis (SgtCoDFish) | ||
*/ | ||
public class MouseTracker extends Component { | ||
public float chaseRate = 1.0f; | ||
|
||
public MouseTracker() { | ||
this(1.0f); | ||
} | ||
|
||
public MouseTracker(float chaseRate) { | ||
this.chaseRate = chaseRate; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
47 changes: 47 additions & 0 deletions
47
core/src/uk/org/ulcompsoc/ld30/systems/BallBoundsSystem.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
package uk.org.ulcompsoc.ld30.systems; | ||
|
||
import uk.org.ulcompsoc.ld30.LD30Test; | ||
import uk.org.ulcompsoc.ld30.LD30Test.VictoryType; | ||
import uk.org.ulcompsoc.ld30.components.Ball; | ||
import uk.org.ulcompsoc.ld30.components.Position; | ||
import uk.org.ulcompsoc.ld30.components.Renderable; | ||
|
||
import com.badlogic.ashley.core.ComponentMapper; | ||
import com.badlogic.ashley.core.Entity; | ||
import com.badlogic.ashley.core.Family; | ||
import com.badlogic.ashley.systems.IteratingSystem; | ||
import com.badlogic.gdx.Gdx; | ||
import com.badlogic.gdx.math.Vector2; | ||
|
||
/** | ||
* @author Ashley Davis (SgtCoDFish) | ||
*/ | ||
public class BallBoundsSystem extends IteratingSystem { | ||
private ComponentMapper<Position> posMapper = null; | ||
private ComponentMapper<Renderable> renderMapper = null; | ||
|
||
@SuppressWarnings("unchecked") | ||
public BallBoundsSystem(int priority) { | ||
this(Family.getFor(Position.class, Renderable.class, Ball.class), priority); | ||
} | ||
|
||
protected BallBoundsSystem(Family family, int priority) { | ||
super(family, priority); | ||
|
||
posMapper = ComponentMapper.getFor(Position.class); | ||
renderMapper = ComponentMapper.getFor(Renderable.class); | ||
} | ||
|
||
@Override | ||
public void processEntity(Entity entity, float deltaTime) { | ||
Vector2 pos = posMapper.get(entity).position.cpy(); | ||
float radius = renderMapper.get(entity).dimension.x; | ||
pos.add(radius / 2.0f, radius / 2.0f); | ||
|
||
if (pos.x < 0.0f) { | ||
LD30Test.victoryType = VictoryType.RED; | ||
} else if (pos.x > Gdx.graphics.getWidth()) { | ||
LD30Test.victoryType = VictoryType.BLUE; | ||
} | ||
} | ||
} |
Oops, something went wrong.