List of usage examples for com.badlogic.gdx.math Vector2 Vector2
public Vector2(float x, float y)
From source file:be.ac.ucl.lfsab1509.bouboule.game.gameManager.GraphicManager.java
License:Open Source License
/** * Create the world, the body container and define the game as notPaused * //w ww. j a va 2s. com * GraphicManager() */ public GraphicManager() { world = new World(new Vector2(0, 0), true); world.setContactListener(new EndGameListener()); //world.setVelocityThreshold(10.0f); bodies = new ArrayList<GameBody>(); loadScoreboard(); }
From source file:be.ac.ucl.lfsab1509.bouboule.game.physicEditor.BodyEditorLoader.java
License:Open Source License
private RigidBodyModel readRigidBody(JsonValue bodyElem) { RigidBodyModel rbModel = new RigidBodyModel(); rbModel.name = bodyElem.getString("name"); rbModel.imagePath = bodyElem.getString("imagePath"); JsonValue originElem = bodyElem.get("origin"); rbModel.origin.x = originElem.getFloat("x"); rbModel.origin.y = originElem.getFloat("y"); // polygons/*from ww w. j av a 2 s.c o m*/ JsonValue polygonsElem = bodyElem.getChild("polygons"); for (; polygonsElem != null; polygonsElem = polygonsElem.next()) { PolygonModel polygon = new PolygonModel(); rbModel.polygons.add(polygon); JsonValue vertexElem = polygonsElem.child(); for (; vertexElem != null; vertexElem = vertexElem.next()) { float x = vertexElem.getFloat("x"); float y = vertexElem.getFloat("y"); polygon.vertices.add(new Vector2(x, y)); } polygon.buffer = new Vector2[polygon.vertices.size()]; } // circles JsonValue circleElem = bodyElem.getChild("circles"); for (; circleElem != null; circleElem = circleElem.next()) { CircleModel circle = new CircleModel(); rbModel.circles.add(circle); circle.center.x = circleElem.getFloat("cx"); circle.center.y = circleElem.getFloat("cy"); circle.radius = circleElem.getFloat("r"); } return rbModel; }
From source file:br.cefetmg.games.minigames.CollectItens.java
private void spawnLollipop() { // pega x e y entre 0 e 1 Vector2 position = new Vector2(rand.nextFloat(), rand.nextFloat()); if (quantAtualLollipops < totalLollipops) { // multiplica x e y pela largura e altura da tela position.scl(// w ww. ja va2 s . c o m this.screen.viewport.getScreenWidth() - lollipopTexture.getWidth() * initialCharactersScale, this.screen.viewport.getScreenHeight() - lollipopTexture.getHeight() * initialCharactersScale); Sprite lollipop = new Sprite(lollipopTexture); lollipop.setPosition(position.x, position.y); lollipop.setScale(initialCharactersScale); this.characters.add(lollipop); this.enemiesAppearing.play(); } }
From source file:br.cefetmg.games.minigames.CollectItens.java
private void spawnCandy() { // pega x e y entre 0 e 1 Vector2 position = new Vector2(rand.nextFloat(), rand.nextFloat()); if (quantAtualCandies < totalCandies) { // multiplica x e y pela largura e altura da tela position.scl(this.screen.viewport.getScreenWidth() - candyTexture.getWidth() * initialCharactersScale, this.screen.viewport.getScreenHeight() - candyTexture.getHeight() * initialCharactersScale); Sprite candy = new Sprite(candyTexture); candy.setPosition(position.x, position.y); candy.setScale(initialCharactersScale); this.characters.add(candy); friends++;// w w w . ja va 2 s . co m // toca um efeito sonoro this.enemiesAppearing.play(); } }
From source file:br.cefetmg.games.minigames.CollectItens.java
private void spawnToothpaste() { // pega x e y entre 0 e 1 Vector2 position = new Vector2(rand.nextFloat(), rand.nextFloat()); if (quantAtualToothpaste < totalToothpaste) { // multiplica x e y pela largura e altura da tela position.scl(/* w w w. ja v a 2 s. c om*/ this.screen.viewport.getScreenWidth() - toothpasteTexture.getWidth() * initialCharactersScale, this.screen.viewport.getScreenHeight() - toothpasteTexture.getHeight() * initialCharactersScale); Sprite toothpaste = new Sprite(toothpasteTexture); toothpaste.setPosition(position.x, position.y); toothpaste.setScale(initialCharactersScale); this.characters.add(toothpaste); // toca um efeito sonoro this.friendsAppearing.play(); friends++; } }
From source file:br.cefetmg.games.minigames.CollectItens.java
private void spawnToothbrush() { // pega x e y entre 0 e 1 Vector2 position = new Vector2(rand.nextFloat(), rand.nextFloat()); if (quantAtualToothbrush < totalToothbrush) { // multiplica x e y pela largura e altura da tela position.scl(/*from ww w . ja v a 2 s . c o m*/ this.screen.viewport.getScreenWidth() - toothbrushTexture.getWidth() * initialCharactersScale, this.screen.viewport.getScreenHeight() - toothbrushTexture.getHeight() * initialCharactersScale); Sprite toothbrush = new Sprite(toothbrushTexture); toothbrush.setPosition(position.x, position.y); toothbrush.setScale(initialCharactersScale); this.characters.add(toothbrush); } // toca um efeito sonoro this.friendsAppearing.play(); }
From source file:br.cefetmg.games.minigames.EscoveOsDentes.java
private void spawnEnemy() { // pega x e y entre 0 e 1 Vector2 position = new Vector2(rand.nextFloat(), rand.nextFloat()); // multiplica x e y pela largura e altura da tela position.scl(this.screen.viewport.getWorldWidth() - toothTexture.getWidth() * initialToothScale, this.screen.viewport.getWorldHeight() - toothTexture.getHeight() * initialToothScale); Sprite enemy = new Sprite(toothTexture); Escova novo = new Escova(); enemy.setPosition(position.x, position.y); enemy.setScale(minimumToothScale);//from w w w .j a v a 2s . c o m Tooths.add(enemy); Escovar.add(novo); }
From source file:br.cefetmg.games.minigames.FleeTheTartarus.java
@Override public void onHandlePlayingInput() { // atualiza a posio do alvo de acordo com o mouse Vector2 click = new Vector2(Gdx.input.getX(), Gdx.input.getY()); super.screen.viewport.unproject(click); this.tooth.setCenter(click.x, click.y); for (Tartarus t : this.enemies) { if (t.getBoundingRectangle().overlaps(tooth.getBoundingRectangle())) { tooth.setTexture(deadToothTexture); perdeu.play();/*from ww w . ja va2 s . com*/ super.challengeFailed(); } } if ((this.initialTime + this.maxDuration + 3000) <= System.currentTimeMillis()) { venceu.play(); super.challengeSolved(); } }
From source file:br.cefetmg.games.minigames.Gallows.java
@Override public void onHandlePlayingInput() { //throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. // atualiza a posio do alvo de acordo com o mouse Vector2 click = new Vector2(Gdx.input.getX(), Gdx.input.getY()); super.screen.viewport.unproject(click); this.mousePointer.setPosition(click.x - this.mousePointer.getHeight() * 0.3f, click.y - this.mousePointer.getHeight() * 0.7f); //se apertar P o jogo acaba if (Gdx.input.isKeyPressed(Keys.P)) { super.challengeFailed(); }//from w w w .ja va 2s. co m // verifica se acertou a letr if (Gdx.input.justTouched()) { boolean letraEstaNaPalavra = false; // itera no array de letras for (int i = 0; i < letters.size; i++) { StructSprite sprite = letters.get(i); // se h interseo entre o retngulo do mouse e da letra, // o tiro acertou if (sprite.getSprite().getBoundingRectangle().contains(click)) { // remove a letra do array this.letters.removeValue(sprite, true); for (int j = 0; j < word.length(); j++) { //se a palavra tiver a letra, ela colocada no array de letras acertadas if (word.charAt(j) == sprite.getCaracter()) { Sprite s = new Sprite(sprite.getSprite()); s.setPosition(250 + j * 100, 320.0f); letrasCertas.add(s); letraEstaNaPalavra = true; qtdLetrasAcertadas--; somSucesso.play(); } } if (!letraEstaNaPalavra) { tentativas++; somDenteQuebrando.play(); } break; } } } }
From source file:br.cefetmg.games.minigames.PutTheBraces.java
@Override public void onHandlePlayingInput() { Vector2 click = new Vector2(Gdx.input.getX(), Gdx.input.getY()); super.screen.viewport.unproject(click); brete.setPosition(click.x - this.brete.getWidth() / 2, click.y - this.brete.getHeight() / 2); if (Gdx.input.justTouched()) { // itera no array de dentes for (int i = 0; i < teeth.size; i++) { Tooth tooth = teeth.get(i);/*from w ww. ja v a2s. c o m*/ if (tooth.getBoundingRectangle().contains(click)) { toothWasBraced(tooth); break; } } } }