Skip to content

Commit dc8f557

Browse files
committed
Boss fights, progress, more reasonable damage, bosses disappear
1 parent 6ec1b9d commit dc8f557

File tree

15 files changed

+158
-37
lines changed

15 files changed

+158
-37
lines changed

README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,14 @@ Your cube planet has several different worlds to visit to beat bosses, become mo
99

1010
Find out now!
1111

12-
Latest playable version at http://www.ulcompsoc.org.uk/ld30/ - *DOES NOT WORK FOR v0.3, USE JAR FROM RELEASES PAGE*
12+
~~Latest playable version at http://www.ulcompsoc.org.uk/ld30/ - *DOES NOT WORK FOR v0.3, USE JAR FROM RELEASES PAGE*~~
13+
Sorry, HTML version not supported for Ludum Dare release.
1314

1415
### Code Roadmap
1516
1. ~~Basic Battle System~~
1617
2. ~~Map Rendering, World Interactions and Random Battles~~
1718
3. World Changes
18-
4. Better Battle System - AI, Spells etc
19+
4. ~~Better Battle System - AI, Spells etc~~
1920
5. Cube
2021
6. Inventory/Items/Weapons
2122

core/src/uk/org/ulcompsoc/tesseract/TesseractMain.java

Lines changed: 80 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import uk.org.ulcompsoc.tesseract.animations.SlimeFrameResolver;
77
import uk.org.ulcompsoc.tesseract.battle.BattlePerformers;
88
import uk.org.ulcompsoc.tesseract.components.BattleDialog;
9+
import uk.org.ulcompsoc.tesseract.components.Boss;
910
import uk.org.ulcompsoc.tesseract.components.Combatant;
1011
import uk.org.ulcompsoc.tesseract.components.Enemy;
1112
import uk.org.ulcompsoc.tesseract.components.FocusTaker;
@@ -54,6 +55,8 @@
5455
import com.badlogic.gdx.graphics.g2d.BitmapFont;
5556
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
5657
import com.badlogic.gdx.graphics.g2d.TextureRegion;
58+
import com.badlogic.gdx.graphics.g2d.freetype.FreeTypeFontGenerator;
59+
import com.badlogic.gdx.graphics.g2d.freetype.FreeTypeFontGenerator.FreeTypeFontParameter;
5760
import com.badlogic.gdx.graphics.glutils.ShaderProgram;
5861
import com.badlogic.gdx.maps.tiled.TmxMapLoader;
5962
import com.badlogic.gdx.math.GridPoint2;
@@ -74,6 +77,8 @@ public class TesseractMain extends ApplicationAdapter {
7477

7578
private ShaderProgram vortexProgram = null;
7679

80+
private FreeTypeFontGenerator fontGenerator = null;
81+
7782
private BitmapFont font10 = null;
7883
private BitmapFont font12 = null;
7984
private BitmapFont font16 = null;
@@ -90,6 +95,7 @@ public class TesseractMain extends ApplicationAdapter {
9095
BattleVictoryListener battleVictoryListener = null;
9196

9297
private static boolean battleChangeFlag = false;
98+
private static boolean bossIncomingFlag = false;
9399
private static boolean worldChangeFlag = false;
94100
private static boolean diffWorldFlag = false;
95101
private float transitionTime = -1.0f;
@@ -105,6 +111,9 @@ public class TesseractMain extends ApplicationAdapter {
105111

106112
private Texture[] bossTextures = null;
107113
private Animation[] bossAnims = null;
114+
private Stats[] bossStats = { new Stats(250, 15, 10, 3),
115+
new Stats(500, 15, 10, 5), new Stats(500, 40, 10, 5), new Stats(500, 40, 10, 5), new Stats(500, 40, 10, 5),
116+
new Stats(500, 40, 10, 5) };
108117

109118
private DialogueFinishListener healNPCListener = null;
110119
private DialogueFinishListener bossBattleListener = null;
@@ -174,14 +183,32 @@ public void create() {
174183

175184
loadShader();
176185

177-
font10 = new BitmapFont(Gdx.files.internal("fonts/robotobm10.fnt"), Gdx.files.internal("fonts/robotobm10.png"),
178-
false);
179-
font12 = new BitmapFont(Gdx.files.internal("fonts/robotobm12.fnt"), Gdx.files.internal("fonts/robotobm12.png"),
180-
false);
181-
font16 = new BitmapFont(Gdx.files.internal("fonts/robotobm16.fnt"), Gdx.files.internal("fonts/robotobm16.png"),
182-
false);
183-
font24 = new BitmapFont(Gdx.files.internal("fonts/robotobm24.fnt"), Gdx.files.internal("fonts/robotobm24.png"),
184-
false);
186+
fontGenerator = new FreeTypeFontGenerator(Gdx.files.internal("fonts/RobotoRegular.ttf"));
187+
FreeTypeFontParameter para = new FreeTypeFontParameter();
188+
189+
para.size = 10;
190+
font10 = fontGenerator.generateFont(para);
191+
// font10 = new BitmapFont(Gdx.files.internal("fonts/robotobm10.fnt"),
192+
// Gdx.files.internal("fonts/robotobm10.png"),
193+
// false);
194+
195+
para.size = 12;
196+
font12 = fontGenerator.generateFont(para);
197+
// font12 = new BitmapFont(Gdx.files.internal("fonts/robotobm12.fnt"),
198+
// Gdx.files.internal("fonts/robotobm12.png"),
199+
// false);
200+
201+
para.size = 16;
202+
font16 = fontGenerator.generateFont(para);
203+
// font16 = new BitmapFont(Gdx.files.internal("fonts/robotobm16.fnt"),
204+
// Gdx.files.internal("fonts/robotobm16.png"),
205+
// false);
206+
207+
para.size = 24;
208+
font24 = fontGenerator.generateFont(para);
209+
// font24 = new BitmapFont(Gdx.files.internal("fonts/robotobm24.fnt"),
210+
// Gdx.files.internal("fonts/robotobm24.png"),
211+
// false);
185212

186213
playerTexture = new Texture(Gdx.files.internal("player/basicPlayer.png"));
187214
playerRegions = TextureRegion.split(playerTexture, WorldConstants.TILE_WIDTH, WorldConstants.TILE_HEIGHT)[0];
@@ -246,39 +273,49 @@ public void render() {
246273
} else if (battleChangeFlag) {
247274
battleChangeFlag = false;
248275
vortexOff();
249-
changeToBattle();
276+
changeToBattle(bossIncomingFlag);
250277
}
251278
}
252279
}
253280

254281
currentEngine.update(deltaTime);
255282
}
256283

257-
public void flagBattleChange() {
284+
public void flagBattleChange(boolean boss) {
258285
battleChangeFlag = true;
286+
bossIncomingFlag = boss;
259287
transitionTime = BATTLE_START_TRANSITION_TIME;
260288
vortexOn();
261289
}
262290

263291
public void flagWorldChange(boolean boss) {
264292
worldChangeFlag = true;
265293
diffWorldFlag = false;
294+
295+
if (boss) {
296+
getCurrentMap().setBossBeaten();
297+
}
298+
266299
transitionTime = BATTLE_END_TRANSITION_TIME;
267300
}
268301

269302
public static boolean isTransitioning() {
270303
return battleChangeFlag || worldChangeFlag;
271304
}
272305

273-
public void changeToBattle() {
306+
public void changeToBattle(boolean boss) {
274307
Gdx.app.debug("BATTLE_CHANGE", "Changing to battle view.");
275308

276309
this.currentEngine = battleEngine;
277310

278311
((OrthographicCamera) camera).setToOrtho(false, Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
279312
camera.update();
280313

281-
addSlimes(battleEngine, random.nextInt(3) + 1);
314+
if (boss) {
315+
addBoss(battleEngine);
316+
} else {
317+
addSlimes(battleEngine, random.nextInt(3) + 1);
318+
}
282319
battleEngine.getSystem(BattleMessageSystem.class).clearAllMessages();
283320
}
284321

@@ -291,6 +328,10 @@ public void changeToWorld(boolean diffWorld) {
291328

292329
this.currentEngine = worldEngines[currentMapIndex];
293330

331+
if (getCurrentMap().bossBeaten) {
332+
currentEngine.removeEntity(getCurrentMap().bossEntity);
333+
}
334+
294335
if (diffWorld) {
295336
worldPlayerEntity.add(getCurrentMap().findPlayerPosition());
296337
currentEngine.addEntity(worldPlayerEntity);
@@ -442,6 +483,27 @@ public void initBattleEngine(Engine engine) {
442483
engine.addSystem(new TextRenderSystem(batch, font16, 3000));
443484
}
444485

486+
private void addBoss(Engine engine) {
487+
TesseractMap map = getCurrentMap();
488+
489+
if (map.bossBeaten) {
490+
Gdx.app.debug("ADD_BOSS", "Trying to fight a boss for the second time.");
491+
}
492+
493+
Entity boss = new Entity();
494+
final float yMiddle = 12 * WorldConstants.TILE_HEIGHT;
495+
boss.add(new Position(3 * WorldConstants.TILE_WIDTH, yMiddle));
496+
boss.add(new Renderable(bossAnims[currentMapIndex]).setAnimationResolver(new PingPongFrameResolver(0.1f)));
497+
boss.add(bossStats[currentMapIndex]);
498+
boss.add(new Boss());
499+
boss.add(new Combatant());
500+
Enemy enemy = ComponentMapper.getFor(Enemy.class).get(map.bossEntity);
501+
boss.add(enemy);
502+
boss.add(new Named(enemy.speciesName));
503+
504+
engine.addEntity(boss);
505+
}
506+
445507
private void addSlimes(Engine engine, int count) {
446508
if (count < 1 || count > 3) {
447509
throw new GdxRuntimeException("Only between 1-3 slimes supported.");
@@ -554,6 +616,7 @@ public void loadBossFiles() {
554616

555617
public void startBossBattle() {
556618
Gdx.app.debug("BOSS_BATTLE", "Let's get ready to rumble.");
619+
flagBattleChange(true);
557620
}
558621

559622
public void healToFull() {
@@ -565,6 +628,10 @@ public void healToFull() {
565628
public void dispose() {
566629
super.dispose();
567630

631+
if (fontGenerator != null) {
632+
fontGenerator.dispose();
633+
}
634+
568635
for (TesseractMap map : maps) {
569636
if (map != null) {
570637
map.dispose();
@@ -675,7 +742,7 @@ public void receive(Signal<Entity> signal, Entity object) {
675742

676743
if (rand <= prob) {
677744
monsterTilesVisited = 0;
678-
flagBattleChange();
745+
flagBattleChange(false);
679746
}
680747
}
681748
}

core/src/uk/org/ulcompsoc/tesseract/animations/PingPongFrameResolver.java

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,14 @@
11
package uk.org.ulcompsoc.tesseract.animations;
22

3+
import com.badlogic.gdx.graphics.g2d.Animation;
4+
import com.badlogic.gdx.graphics.g2d.Animation.PlayMode;
5+
import com.badlogic.gdx.graphics.g2d.TextureRegion;
6+
37
/**
48
* @author Ashley Davis (SgtCoDFish)
59
*/
610
public class PingPongFrameResolver extends AnimationFrameResolver {
11+
boolean first = true;
712

813
public PingPongFrameResolver() {
914
this(0.0f);
@@ -19,4 +24,14 @@ public float resolveTime(float deltaTime) {
1924
return animTime;
2025
}
2126

27+
@Override
28+
public TextureRegion resolveFrame(Animation anim, float deltaTime) {
29+
if (first) {
30+
anim.setPlayMode(PlayMode.LOOP_PINGPONG);
31+
first = false;
32+
}
33+
34+
return super.resolveFrame(anim, deltaTime);
35+
}
36+
2237
}

core/src/uk/org/ulcompsoc/tesseract/battle/BattleAttack.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
package uk.org.ulcompsoc.tesseract.battle;
22

3-
import java.util.Random;
4-
53
import uk.org.ulcompsoc.tesseract.components.Stats;
64

75
import com.badlogic.ashley.core.Entity;
@@ -22,7 +20,7 @@ public BattleAttack(Entity attacker, Entity target, AttackType attackType) {
2220

2321
public static int resolveDamage(Stats attacker, Stats defender) {
2422
double atk = attacker.getAttack() - defender.getDefence();
25-
atk = atk + atk * (new Random().nextInt(11) - 5) * 0.1;
23+
// atk = atk + atk * (new Random().nextInt(11) - 5) * 0.1;
2624

2725
return Math.max((int) Math.floor(atk), 1);
2826
}

core/src/uk/org/ulcompsoc/tesseract/battle/BattlePerformers.java

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,11 @@
33
import uk.org.ulcompsoc.tesseract.MouseClickPerformer;
44
import uk.org.ulcompsoc.tesseract.TesseractMain;
55
import uk.org.ulcompsoc.tesseract.TesseractStrings;
6-
import uk.org.ulcompsoc.tesseract.WorldConstants;
6+
import uk.org.ulcompsoc.tesseract.components.Combatant;
77
import uk.org.ulcompsoc.tesseract.components.Enemy;
88
import uk.org.ulcompsoc.tesseract.components.MouseClickListener;
99
import uk.org.ulcompsoc.tesseract.components.Position;
10+
import uk.org.ulcompsoc.tesseract.components.Renderable;
1011
import uk.org.ulcompsoc.tesseract.components.TargetMarker;
1112
import uk.org.ulcompsoc.tesseract.systems.BattleAttackSystem;
1213
import uk.org.ulcompsoc.tesseract.systems.BattleMessageSystem;
@@ -40,9 +41,12 @@ public void perform(Entity invoker, Engine engine) {
4041
Entity e = enemies.get(i);
4142
Vector2 pos = posMapper.get(e).position;
4243

44+
final Renderable r = ComponentMapper.getFor(Renderable.class).get(e);
45+
final float imgW = r.width;
46+
final float imgH = r.height;
47+
4348
e.add(new TargetMarker());
44-
e.add(new MouseClickListener(new Rectangle(pos.x, pos.y, WorldConstants.TILE_WIDTH,
45-
WorldConstants.TILE_HEIGHT), enemyTargetPerformer));
49+
e.add(new MouseClickListener(new Rectangle(pos.x, pos.y, imgW, imgH), enemyTargetPerformer));
4650
}
4751
}
4852
}
@@ -53,6 +57,7 @@ public static class DefendPerformer implements MouseClickPerformer {
5357
public void perform(Entity invoker, Engine engine) {
5458
// Gdx.app.debug("PERFORM_JUMP", "Performing defend.");
5559
battleMessageSystem.addMessage(TesseractStrings.getDefendMessage());
60+
ComponentMapper.getFor(Combatant.class).get(TesseractMain.battlePlayerEntity).addBuff(new DefenceBuff());
5661
}
5762
}
5863

@@ -61,6 +66,7 @@ public static class QuaffPerformer implements MouseClickPerformer {
6166
public void perform(Entity invoker, Engine engine) {
6267
// Gdx.app.debug("PERFORM_QUAFF", "Performing a quaff.");
6368
battleMessageSystem.addMessage(TesseractStrings.getQuaffMessage());
69+
ComponentMapper.getFor(Combatant.class).get(TesseractMain.battlePlayerEntity).addBuff(new HealBuff(5));
6470
}
6571
}
6672

core/src/uk/org/ulcompsoc/tesseract/battle/DefenceBuff.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@ public class DefenceBuff implements BuffPerformer {
1717
private Stats stats = null;
1818
private int buffAmt = 0;
1919

20+
public DefenceBuff() {
21+
this(5.0f);
22+
}
23+
2024
public DefenceBuff(float duration) {
2125
this.duration = duration;
2226
}
@@ -26,7 +30,7 @@ public void doBuff(Entity target) {
2630
this.target = target;
2731
stats = statsMapper.get(target);
2832

29-
buffAmt = stats.getLevel();
33+
buffAmt = stats.getDefence();
3034

3135
stats.fortitude += buffAmt;
3236

core/src/uk/org/ulcompsoc/tesseract/battle/HealBuff.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,10 @@ public class HealBuff implements BuffPerformer {
2323

2424
private int healPerTick = 0;
2525

26+
public HealBuff(int ticks) {
27+
this(5.0f, ticks);
28+
}
29+
2630
public HealBuff(float duration, int ticks) {
2731
this.duration = duration;
2832
this.ticks = ticks;
@@ -34,7 +38,7 @@ public void doBuff(Entity target) {
3438
this.target = target;
3539
this.stats = statsMapper.get(target);
3640

37-
this.healPerTick = (int) Math.floor(stats.maxHP * 0.1f);
41+
this.healPerTick = (int) Math.floor(stats.maxHP * 0.05f);
3842
this.timeElapsed = 0.0f;
3943
}
4044

core/src/uk/org/ulcompsoc/tesseract/components/Combatant.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,16 @@ public class Combatant extends Component {
1616
public boolean hasHealAnimation = false;
1717
public boolean hasThinkingAnimation = false;
1818

19-
public List<BuffPerformer> buffs = new ArrayList<BuffPerformer>();
19+
public List<BuffPerformer> addedBuffs = new ArrayList<BuffPerformer>();
20+
public List<BuffPerformer> updatingBuffs = new ArrayList<BuffPerformer>();
2021

2122
// changed in buffsystem
2223
public float thinkingTime = -1.0f;
2324

25+
public void addBuff(BuffPerformer buff) {
26+
addedBuffs.add(buff);
27+
}
28+
2429
public boolean canAct() {
2530
return thinkingTime < -0.5f;
2631
}

0 commit comments

Comments
 (0)