attempt to sync cam and body
This commit is contained in:
@@ -2,16 +2,16 @@ Sparks
|
||||
- Delay -
|
||||
active: false
|
||||
- Duration -
|
||||
lowMin: 0.0
|
||||
lowMax: 300.0
|
||||
lowMin: 200.0
|
||||
lowMax: 200.0
|
||||
- Count -
|
||||
min: 200
|
||||
max: 200
|
||||
min: 0
|
||||
max: 15
|
||||
- Emission -
|
||||
lowMin: 0.0
|
||||
lowMax: 0.0
|
||||
highMin: 90.0
|
||||
highMax: 90.0
|
||||
highMin: 200.0
|
||||
highMax: 200.0
|
||||
relative: false
|
||||
scalingCount: 1
|
||||
scaling0: 1.0
|
||||
@@ -21,13 +21,13 @@ timeline0: 0.0
|
||||
lowMin: 0.0
|
||||
lowMax: 0.0
|
||||
highMin: 500.0
|
||||
highMax: 500.0
|
||||
highMax: 1000.0
|
||||
relative: false
|
||||
scalingCount: 1
|
||||
scaling0: 1.0
|
||||
timelineCount: 1
|
||||
timeline0: 0.0
|
||||
independent: false
|
||||
independent: true
|
||||
- Life Offset -
|
||||
active: false
|
||||
independent: false
|
||||
@@ -60,21 +60,25 @@ timeline0: 0.0
|
||||
- X Scale -
|
||||
lowMin: 0.0
|
||||
lowMax: 0.0
|
||||
highMin: 30.0
|
||||
highMax: 30.0
|
||||
highMin: 5.0
|
||||
highMax: 19.0
|
||||
relative: false
|
||||
scalingCount: 1
|
||||
scaling0: 1.0
|
||||
timelineCount: 1
|
||||
scalingCount: 3
|
||||
scaling0: 0.0
|
||||
scaling1: 1.0
|
||||
scaling2: 0.0
|
||||
timelineCount: 3
|
||||
timeline0: 0.0
|
||||
timeline1: 0.30555555
|
||||
timeline2: 1.0
|
||||
- Y Scale -
|
||||
active: false
|
||||
- Velocity -
|
||||
active: true
|
||||
lowMin: 0.0
|
||||
lowMax: 0.0
|
||||
highMin: 30.0
|
||||
highMax: 285.0
|
||||
highMin: 235.0
|
||||
highMax: 600.0
|
||||
relative: false
|
||||
scalingCount: 1
|
||||
scaling0: 1.0
|
||||
@@ -110,8 +114,8 @@ active: false
|
||||
active: true
|
||||
lowMin: 0.0
|
||||
lowMax: 0.0
|
||||
highMin: 0.0
|
||||
highMax: 0.0
|
||||
highMin: -330.0
|
||||
highMax: -330.0
|
||||
relative: true
|
||||
scalingCount: 2
|
||||
scaling0: 0.0
|
||||
@@ -132,16 +136,173 @@ lowMax: 0.0
|
||||
highMin: 1.0
|
||||
highMax: 1.0
|
||||
relative: false
|
||||
scalingCount: 4
|
||||
scalingCount: 2
|
||||
scaling0: 1.0
|
||||
scaling1: 0.0
|
||||
timelineCount: 2
|
||||
timeline0: 0.0
|
||||
timeline1: 1.0
|
||||
- Options -
|
||||
attached: false
|
||||
continuous: false
|
||||
aligned: false
|
||||
additive: false
|
||||
behind: false
|
||||
premultipliedAlpha: false
|
||||
spriteMode: single
|
||||
- Image Paths -
|
||||
particle-star.png
|
||||
|
||||
|
||||
Explosion
|
||||
- Delay -
|
||||
active: false
|
||||
- Duration -
|
||||
lowMin: 300.0
|
||||
lowMax: 300.0
|
||||
- Count -
|
||||
min: 0
|
||||
max: 200
|
||||
- Emission -
|
||||
lowMin: 0.0
|
||||
lowMax: 0.0
|
||||
highMin: 300.0
|
||||
highMax: 300.0
|
||||
relative: false
|
||||
scalingCount: 1
|
||||
scaling0: 1.0
|
||||
timelineCount: 1
|
||||
timeline0: 0.0
|
||||
- Life -
|
||||
lowMin: 0.0
|
||||
lowMax: 0.0
|
||||
highMin: 300.0
|
||||
highMax: 500.0
|
||||
relative: false
|
||||
scalingCount: 1
|
||||
scaling0: 1.0
|
||||
timelineCount: 1
|
||||
timeline0: 0.0
|
||||
independent: true
|
||||
- Life Offset -
|
||||
active: false
|
||||
independent: false
|
||||
- X Offset -
|
||||
active: false
|
||||
- Y Offset -
|
||||
active: false
|
||||
- Spawn Shape -
|
||||
shape: ellipse
|
||||
edges: false
|
||||
side: both
|
||||
- Spawn Width -
|
||||
lowMin: 0.0
|
||||
lowMax: 0.0
|
||||
highMin: 60.0
|
||||
highMax: 90.0
|
||||
relative: false
|
||||
scalingCount: 1
|
||||
scaling0: 1.0
|
||||
timelineCount: 1
|
||||
timeline0: 0.0
|
||||
- Spawn Height -
|
||||
lowMin: 0.0
|
||||
lowMax: 0.0
|
||||
highMin: 60.0
|
||||
highMax: 90.0
|
||||
relative: false
|
||||
scalingCount: 1
|
||||
scaling0: 1.0
|
||||
timelineCount: 1
|
||||
timeline0: 0.0
|
||||
- X Scale -
|
||||
lowMin: 30.0
|
||||
lowMax: 30.0
|
||||
highMin: 60.0
|
||||
highMax: 60.0
|
||||
relative: false
|
||||
scalingCount: 2
|
||||
scaling0: 0.0
|
||||
scaling1: 1.0
|
||||
scaling2: 0.75
|
||||
scaling3: 0.0
|
||||
timelineCount: 4
|
||||
timelineCount: 2
|
||||
timeline0: 0.0
|
||||
timeline1: 0.2
|
||||
timeline2: 0.8
|
||||
timeline3: 1.0
|
||||
timeline1: 1.0
|
||||
- Y Scale -
|
||||
active: false
|
||||
- Velocity -
|
||||
active: true
|
||||
lowMin: 0.0
|
||||
lowMax: 0.0
|
||||
highMin: 0.0
|
||||
highMax: 0.0
|
||||
relative: false
|
||||
scalingCount: 1
|
||||
scaling0: 1.0
|
||||
timelineCount: 1
|
||||
timeline0: 0.0
|
||||
- Angle -
|
||||
active: true
|
||||
lowMin: 0.0
|
||||
lowMax: 0.0
|
||||
highMin: 0.0
|
||||
highMax: 360.0
|
||||
relative: false
|
||||
scalingCount: 1
|
||||
scaling0: 1.0
|
||||
timelineCount: 1
|
||||
timeline0: 0.0
|
||||
- Rotation -
|
||||
active: true
|
||||
lowMin: 0.0
|
||||
lowMax: 0.0
|
||||
highMin: 0.0
|
||||
highMax: 360.0
|
||||
relative: false
|
||||
scalingCount: 1
|
||||
scaling0: 1.0
|
||||
timelineCount: 1
|
||||
timeline0: 0.0
|
||||
- Wind -
|
||||
active: false
|
||||
- Gravity -
|
||||
active: false
|
||||
- Tint -
|
||||
colorsCount: 15
|
||||
colors0: 1.0
|
||||
colors1: 0.9882353
|
||||
colors2: 0.0
|
||||
colors3: 0.9019608
|
||||
colors4: 0.50980395
|
||||
colors5: 0.0
|
||||
colors6: 1.0
|
||||
colors7: 0.0
|
||||
colors8: 0.0
|
||||
colors9: 0.05882353
|
||||
colors10: 0.0
|
||||
colors11: 0.0
|
||||
colors12: 0.0
|
||||
colors13: 0.0
|
||||
colors14: 0.0
|
||||
timelineCount: 5
|
||||
timeline0: 0.0
|
||||
timeline1: 0.24150944
|
||||
timeline2: 0.5094341
|
||||
timeline3: 0.69245297
|
||||
timeline4: 1.0
|
||||
- Transparency -
|
||||
lowMin: 0.0
|
||||
lowMax: 0.0
|
||||
highMin: 1.0
|
||||
highMax: 1.0
|
||||
relative: false
|
||||
scalingCount: 3
|
||||
scaling0: 0.7118639
|
||||
scaling1: 1.0
|
||||
scaling2: 0.0
|
||||
timelineCount: 3
|
||||
timeline0: 0.0
|
||||
timeline1: 0.24305576
|
||||
timeline2: 1.0
|
||||
- Options -
|
||||
attached: false
|
||||
continuous: false
|
||||
@@ -151,5 +312,5 @@ behind: false
|
||||
premultipliedAlpha: false
|
||||
spriteMode: single
|
||||
- Image Paths -
|
||||
particle-star.png
|
||||
particle-fire.png
|
||||
|
||||
|
||||
BIN
assets/particles/particle-fire.png
Normal file
BIN
assets/particles/particle-fire.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 12 KiB |
@@ -6,6 +6,7 @@ import com.badlogic.gdx.graphics.GL20;
|
||||
import com.badlogic.gdx.graphics.OrthographicCamera;
|
||||
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
|
||||
import com.badlogic.gdx.math.Vector2;
|
||||
import com.badlogic.gdx.math.Vector3;
|
||||
import com.badlogic.gdx.physics.box2d.Box2DDebugRenderer;
|
||||
import com.badlogic.gdx.physics.box2d.World;
|
||||
import com.badlogic.gdx.utils.Array;
|
||||
@@ -46,8 +47,7 @@ public class Bugger {
|
||||
this.world.setContactListener(new GameContactListener());
|
||||
this.debugRenderer = new Box2DDebugRenderer();
|
||||
spriteBatch = new SpriteBatch();
|
||||
cam = new OrthographicCamera();
|
||||
cam.setToOrtho(false, Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
|
||||
cam = new OrthographicCamera(160, 90);
|
||||
cam.position.set(Player.getInstance().getPosition().x / 2f, Player.getInstance().getPosition().y / 2f, 0);
|
||||
cam.update();
|
||||
}
|
||||
@@ -60,22 +60,27 @@ public class Bugger {
|
||||
}
|
||||
|
||||
public void cycle(float delta) {
|
||||
updateCamera(delta);
|
||||
cam.update();
|
||||
|
||||
renderClear();
|
||||
renderBackground();
|
||||
|
||||
renderPlayer();
|
||||
|
||||
step();
|
||||
spriteBatch.setProjectionMatrix(cam.combined);
|
||||
cam.position.set(player.getPosition().x, player.getPosition().y, 0);
|
||||
|
||||
handleInput();
|
||||
|
||||
|
||||
cycleProjectiles(delta);
|
||||
cycleEnemies();
|
||||
cycleParticles(delta);
|
||||
|
||||
clearEntities();
|
||||
|
||||
renderPlayer();
|
||||
|
||||
renderEnemies(delta);
|
||||
renderDebug();
|
||||
}
|
||||
@@ -110,12 +115,6 @@ public class Bugger {
|
||||
debugRenderer.render(world, spriteBatch.getProjectionMatrix());
|
||||
}
|
||||
|
||||
public void updateCamera(float delta) {
|
||||
cam.update();
|
||||
spriteBatch.setProjectionMatrix(cam.combined);
|
||||
cam.position.set(Player.getInstance().getPosition().x, Player.getInstance().getPosition().y, 0);
|
||||
}
|
||||
|
||||
public void cycleProjectiles(float delta) {
|
||||
for (Arrow arrow : projectiles) {
|
||||
if (!arrow.isMarkedToDestroy()) {
|
||||
@@ -153,7 +152,7 @@ public class Bugger {
|
||||
}
|
||||
|
||||
public void step() {
|
||||
world.step(1f, 6, 2);
|
||||
world.step(1 / 20f, 6, 2);
|
||||
}
|
||||
|
||||
public void playParticle(float x, float y) {
|
||||
@@ -179,6 +178,7 @@ public class Bugger {
|
||||
spriteBatch.dispose();
|
||||
world.dispose();
|
||||
spaceBackground.dispose();
|
||||
ParticleManager.getInstance().dispose();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,17 +1,12 @@
|
||||
package org.lumijiez.bugger;
|
||||
|
||||
import com.badlogic.gdx.Screen;
|
||||
import org.lumijiez.bugger.entities.Player;
|
||||
import com.badlogic.gdx.graphics.OrthographicCamera;
|
||||
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
|
||||
|
||||
public class GameScreen implements Screen {
|
||||
public final Bugger bugger = Bugger.getInstance();
|
||||
|
||||
|
||||
|
||||
public GameScreen() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void show() {
|
||||
|
||||
@@ -24,8 +19,14 @@ public class GameScreen implements Screen {
|
||||
|
||||
|
||||
@Override
|
||||
public void resize(int i, int i1) {
|
||||
|
||||
public void resize(int w, int h) {
|
||||
// float screenAR = w / (float) h;
|
||||
// Bugger.cam = new OrthographicCamera(20, 20 / screenAR);
|
||||
// Bugger.cam.position.set(Bugger.cam.viewportWidth / 2, Bugger.cam.viewportHeight / 2, 0);
|
||||
// Bugger.cam.update();
|
||||
//
|
||||
// Bugger.spriteBatch = new SpriteBatch();
|
||||
// Bugger.spriteBatch.setProjectionMatrix(Bugger.cam.combined);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -12,7 +12,7 @@ public class Player extends Entity {
|
||||
private static Player instance;
|
||||
|
||||
private Player() {
|
||||
super(null, "images/wasp.png", 50f);
|
||||
super(null, "images/wasp.png", 10f);
|
||||
}
|
||||
|
||||
public static Player getInstance() {
|
||||
@@ -28,7 +28,7 @@ public class Player extends Entity {
|
||||
}
|
||||
|
||||
public void move(float deltaX, float deltaY) {
|
||||
float speed = 5f;
|
||||
float speed = 500f;
|
||||
body.setLinearVelocity(deltaX * speed, deltaY * speed);
|
||||
}
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@ public class Wasp extends EnemyEntity {
|
||||
private static final Random random = new Random();
|
||||
|
||||
public Wasp(World world, Vector2 playerPosition) {
|
||||
super(world, "images/wasp.png", 20f);
|
||||
super(world, "images/wasp.png", 5f);
|
||||
float spawnRadius = 100;
|
||||
float angle = random.nextFloat() * 2 * (float) Math.PI;
|
||||
float spawnX = playerPosition.x + (float) Math.cos(angle) * (spawnRadius + size);
|
||||
|
||||
@@ -8,12 +8,13 @@ public class Arrow extends Entity {
|
||||
private float timeAlive = 0f;
|
||||
|
||||
public Arrow(World world, Vector2 position, Vector2 direction) {
|
||||
super(world, "images/wasp.png", 10f);
|
||||
Vector2 offsetPosition = position.cpy().add(direction.nor().scl(size + 15f));
|
||||
super(world, "images/wasp.png", 1f);
|
||||
Vector2 offsetPosition = position.cpy().add(direction.nor().scl(size + 1f));
|
||||
|
||||
this.body = createBody(offsetPosition.x, offsetPosition.y);
|
||||
float speed = 4000f;
|
||||
float speed = 5000f;
|
||||
this.body.setLinearVelocity(direction.nor().scl(speed));
|
||||
this.body.setAngularVelocity(speed);
|
||||
}
|
||||
|
||||
protected Body createBody(float x, float y) {
|
||||
|
||||
@@ -6,7 +6,6 @@ import com.badlogic.gdx.graphics.g2d.ParticleEffectPool;
|
||||
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
|
||||
import com.badlogic.gdx.utils.Array;
|
||||
import org.lumijiez.bugger.Bugger;
|
||||
import org.lumijiez.bugger.GameScreen;
|
||||
|
||||
public class ParticleManager {
|
||||
private static ParticleManager instance;
|
||||
@@ -16,7 +15,7 @@ public class ParticleManager {
|
||||
private ParticleManager() {
|
||||
ParticleEffect effect = new ParticleEffect();
|
||||
effect.load(Gdx.files.internal("particles/boom.p"), Gdx.files.internal("particles"));
|
||||
effect.scaleEffect(0.2f);
|
||||
effect.scaleEffect(0.6f);
|
||||
particleEffectPool = new ParticleEffectPool(effect, 1, 20);
|
||||
activeEffects = new Array<>();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user