Make objects slide across the screen in random positions
Posted
by
user3475907
on Game Development
See other posts from Game Development
or by user3475907
Published on 2014-06-12T00:38:47Z
Indexed on
2014/06/12
3:53 UTC
Read the original article
Hit count: 273
I want to make an object appear randomly at the right hand side of the screen and then slide across the screen and disapear at the left hand side. I am working with libgdx. I have this bit of code but it makes items fall from the top down. Please help.
public EntityManager(int amount, OrthoCamera camera) {
player = new Player(new Vector2(15, 230), new Vector2(0, 0), this, camera);
for (int i = 0; i < amount; i++) {
float x = MathUtils.random(0, MainGame.HEIGHT - TextureManager.ENEMY.getHeight());
float y = MathUtils.random(MainGame.WIDTH, MainGame.WIDTH * 10);
float speed = MathUtils.random(2, 10);
addEntity(new Enemy(new Vector2(x, y), new Vector2(-0, -speed)));
}
© Game Development or respective owner