Skip to content

Commit 42773de

Browse files
committed
Remove player body after dying
1 parent d0d9f39 commit 42773de

File tree

1 file changed

+11
-18
lines changed

1 file changed

+11
-18
lines changed

core/src/com/ychstudio/systems/PlayerSystem.java

Lines changed: 11 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -9,25 +9,17 @@
99
import com.badlogic.gdx.graphics.Color;
1010
import com.badlogic.gdx.math.MathUtils;
1111
import com.badlogic.gdx.math.Vector2;
12-
import com.badlogic.gdx.physics.box2d.Body;
13-
import com.badlogic.gdx.physics.box2d.Filter;
14-
import com.badlogic.gdx.physics.box2d.Fixture;
15-
import com.badlogic.gdx.physics.box2d.RayCastCallback;
16-
import com.badlogic.gdx.physics.box2d.World;
12+
import com.badlogic.gdx.physics.box2d.*;
1713
import com.ychstudio.builders.ActorBuilder;
18-
import com.ychstudio.components.Bomb;
19-
import com.ychstudio.components.Player;
20-
import com.ychstudio.components.Renderer;
21-
import com.ychstudio.components.RigidBody;
22-
import com.ychstudio.components.State;
14+
import com.ychstudio.components.*;
2315
import com.ychstudio.components.Transform;
2416
import com.ychstudio.gamesys.GameManager;
17+
2518
import java.util.Queue;
2619

2720
public class PlayerSystem extends IteratingSystem {
2821

2922
protected ComponentMapper<Player> mPlayer;
30-
protected ComponentMapper<Transform> mTransform;
3123
protected ComponentMapper<RigidBody> mRigidBody;
3224
protected ComponentMapper<State> mState;
3325
protected ComponentMapper<Renderer> mRenderer;
@@ -58,7 +50,7 @@ protected void process(int entityId) {
5850
float maxSpeed = player.maxSpeed;
5951

6052
if (player.hp > 0 && player.state != Player.State.TELEPORTING) {
61-
// TODO: cheat code...
53+
// cheat code...
6254
if (Gdx.input.isKeyJustPressed(Input.Keys.NUM_1)) {
6355
player.powerUpAmmo();
6456
}
@@ -172,7 +164,7 @@ protected void process(int entityId) {
172164
if (Gdx.input.isKeyJustPressed(Input.Keys.Z) && player.remoteBomb) {
173165
Queue<Entity> remoteBombQueue = GameManager.getInstance().getRemoteBombDeque();
174166

175-
// clean those bomes which have already exploded
167+
// clean those bombs which have already exploded
176168
while (!remoteBombQueue.isEmpty() && remoteBombQueue.peek().getComponent(Bomb.class) == null) {
177169
remoteBombQueue.remove();
178170
}
@@ -258,11 +250,12 @@ protected void process(int entityId) {
258250
if (state.getStateTime() > 0.65f) {
259251
World b2dWorld = body.getWorld();
260252
b2dWorld.destroyBody(body);
261-
mPlayer.set(entityId, false);
262-
mRigidBody.set(entityId, false);
263-
mState.set(entityId, false);
264-
Transform transform = mTransform.get(entityId);
265-
transform.z = 999;
253+
world.delete(entityId);
254+
// mPlayer.set(entityId, false);
255+
// mRigidBody.set(entityId, false);
256+
// mState.set(entityId, false);
257+
// Transform transform = mTransform.get(entityId);
258+
// transform.z = 999;
266259

267260
GameManager.playerLives--;
268261
if (!GameManager.infiniteLives && GameManager.playerLives <= 0) {

0 commit comments

Comments
 (0)