Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.ancientslime.boombirds.Enemies;
- import com.ancientslime.boombirds.Boombirds;
- import com.ancientslime.boombirds.GameScreen;
- import com.badlogic.gdx.Gdx;
- import com.badlogic.gdx.graphics.g2d.SpriteBatch;
- import com.badlogic.gdx.math.Vector2;
- import com.badlogic.gdx.physics.box2d.World;
- import com.badlogic.gdx.utils.Array;
- public class Bombs {
- private final GameScreen game;
- private final Explosions explosions;
- private final World world;
- private final Array<Bomb> bombList;
- private final Array<Bomb> bombsToRemove;
- public Bombs(final GameScreen game,Explosions explosions, final World world){
- this.game = game;
- this.explosions = explosions;
- this.world = world;
- this.bombList = new Array<Bomb>();
- this.bombsToRemove = new Array<Bomb>();
- }
- public void newBomb(final Vector2 pos, boolean facingRight){
- Bomb bomb = new Bomb(game, this, world, pos, facingRight);
- bombList.add(bomb);
- }
- public void collided(final Bomb bomb) {
- bombsToRemove.add(bomb);
- Gdx.app.postRunnable(new Runnable() {
- public void run() {
- explosions.newExp(new Vector2(bomb.body.getWorldCenter().x, bomb.body.getWorldCenter().y + 3.5f / Boombirds.PPM), false);
- }
- });
- }
- public void update(float delta){
- for (Bomb bomb : bombList) {
- bomb.update(delta);
- if (bombsToRemove.contains(bomb, true)){
- world.destroyBody(bomb.body);
- }
- }
- bombList.removeAll(bombsToRemove, true);
- bombsToRemove.clear();
- }
- public void draw(SpriteBatch batch){
- for (Bomb bomb : bombList){
- if (bomb != null) {
- bomb.draw(batch);
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement