Skip to content

Commit

Permalink
[fix] Reformats spacing on GatoFantasma + renames to PhantomCat
Browse files Browse the repository at this point in the history
  • Loading branch information
fegemo committed Sep 27, 2017
1 parent b6fae2c commit 16f828d
Show file tree
Hide file tree
Showing 7 changed files with 34 additions and 35 deletions.
File renamed without changes.
File renamed without changes
File renamed without changes
File renamed without changes
Original file line number Diff line number Diff line change
@@ -1,16 +1,10 @@
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package br.cefetmg.games.minigames;

import br.cefetmg.games.minigames.util.DifficultyCurve;
import br.cefetmg.games.minigames.util.MiniGameStateObserver;
import br.cefetmg.games.minigames.util.TimeoutBehavior;
import br.cefetmg.games.screens.BaseScreen;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.audio.Sound;
import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.graphics.g2d.Sprite;
import com.badlogic.gdx.graphics.g2d.TextureRegion;
Expand All @@ -19,16 +13,12 @@
import com.badlogic.gdx.utils.Array;
import com.badlogic.gdx.utils.Timer;
import java.util.Comparator;
import java.util.function.Function;
import java.util.function.ToDoubleFunction;
import java.util.function.ToIntFunction;
import java.util.function.ToLongFunction;

/**
*
* @author Luiza-Pedro
*/
public class GatoFantasma extends MiniGame {
public class PhantomCat extends MiniGame {

private Array<Sprite> enemies;
private Sprite target;
Expand All @@ -37,25 +27,25 @@ public class GatoFantasma extends MiniGame {
private Texture fundoTexture;
private int enemiesKilled;
private int spawnedEnemies;
private int cont;
private float initialEnemyScale;
private int totalEnemies;
private float spawnInterval;

public GatoFantasma(BaseScreen screen, MiniGameStateObserver observer, float difficulty) {
super(screen, observer, difficulty, 10f, TimeoutBehavior.WINS_WHEN_MINIGAME_ENDS);
public PhantomCat(BaseScreen screen, MiniGameStateObserver observer,
float difficulty) {
super(screen, observer, difficulty, 10f,
TimeoutBehavior.WINS_WHEN_MINIGAME_ENDS);
}

@Override
protected void onStart() {
cont = 0;
enemies = new Array<Sprite>();
catsTexture = assets.get(
"gato-fantasma/gato-fantasma.png", Texture.class);
"phantom-cat/gato-fantasma.png", Texture.class);
targetTexture = assets.get(
"gato-fantasma/target.png", Texture.class);
"phantom-cat/target.png", Texture.class);
fundoTexture = assets.get(
"gato-fantasma/fundo.jpg", Texture.class);
"phantom-cat/fundo.jpg", Texture.class);
target = new Sprite(targetTexture);
target.setOriginCenter();
enemiesKilled = 0;
Expand All @@ -80,9 +70,13 @@ public void run() {
}

private void spawnEnemy() {
Vector2 position = new Vector2(rand.nextInt()%(720-535)+535f,rand.nextInt()%(370-230)+230f);
Vector2 position = new Vector2(
rand.nextInt() % (720 - 535) + 535f,
rand.nextInt() % (370 - 230) + 230f);
TextureRegion tr = new TextureRegion(catsTexture);
TextureRegion t2 = new TextureRegion(catsTexture, tr.getRegionWidth()/2, tr.getRegionHeight());
TextureRegion t2 = new TextureRegion(catsTexture,
tr.getRegionWidth() / 2,
tr.getRegionHeight());
Sprite enemy = new Sprite(t2);
enemy.setPosition(position.x, position.y);
enemy.setScale(initialEnemyScale);
Expand All @@ -95,7 +89,8 @@ protected void configureDifficultyParameters(float difficulty) {
.getCurveValueBetween(difficulty, 0.05f, 0.25f);
this.spawnInterval = DifficultyCurve.S_NEGATIVE
.getCurveValueBetween(difficulty, 0.5f, 1.5f);
this.totalEnemies = (int) (20 * DifficultyCurve.LINEAR.getCurveValueBetween(difficulty, 0.f, 1.0f)) + 3;
this.totalEnemies = (int) (20 * DifficultyCurve.LINEAR
.getCurveValueBetween(difficulty, 0.f, 1.0f)) + 3;
}

@Override
Expand Down Expand Up @@ -136,7 +131,7 @@ public void onHandlePlayingInput() {
public void onUpdate(float dt) {
for (int i = 0; i < enemies.size; i++) {
Sprite sprite = enemies.get(i);
if (sprite.getScaleY()<2.0f ) {
if (sprite.getScaleY() < 2.0f) {
sprite.setScale(sprite.getScaleX() + 0.3f * dt);
} else {
challengeFailed();
Expand All @@ -146,7 +141,11 @@ public void onUpdate(float dt) {
@Override
public int compare(Sprite b1, Sprite b2) {
//TODO testar nulos
return b1.getScaleX() > b2.getScaleX() ? -1 : b1.getScaleX() == b2.getScaleX() ? 0 : 1;
return b1.getScaleX() > b2.getScaleX()
? -1
: b1.getScaleX() == b2.getScaleX()
? 0
: 1;
}
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,9 @@
*/
package br.cefetmg.games.minigames.factories;

import br.cefetmg.games.minigames.GatoFantasma;
import br.cefetmg.games.minigames.PhantomCat;
import br.cefetmg.games.minigames.MiniGame;
import br.cefetmg.games.minigames.util.MiniGameStateObserver;
import br.cefetmg.games.minigames.util.TimeoutBehavior;
import br.cefetmg.games.screens.BaseScreen;
import com.badlogic.gdx.graphics.Texture;
import java.util.HashMap;
Expand All @@ -18,22 +17,23 @@
*
* @author Luiza-Pedro
*/
public class GatoFantasmaFactory implements MiniGameFactory{
public class PhantomCatFactory implements MiniGameFactory {

@Override
public MiniGame createMiniGame(BaseScreen screen, MiniGameStateObserver observer, float difficulty) {
return new GatoFantasma(screen, observer, difficulty);
public MiniGame createMiniGame(BaseScreen screen,
MiniGameStateObserver observer, float difficulty) {
return new PhantomCat(screen, observer, difficulty);
}

@Override
public Map<String, Class> getAssetsToPreload() {
return new HashMap<String, Class>(){
{
put("gato-fantasma/gato-fantasma.png", Texture.class);
put("gato-fantasma/target.png", Texture.class);
put("gato-fantasma/fundo.jpg", Texture.class);
return new HashMap<String, Class>() {
{
put("phantom-cat/gato-fantasma.png", Texture.class);
put("phantom-cat/target.png", Texture.class);
put("phantom-cat/fundo.jpg", Texture.class);
}
};
}

}
2 changes: 1 addition & 1 deletion core/src/br/cefetmg/games/screens/PlayingGamesScreen.java
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public PlayingGamesScreen(Game game, BaseScreen previous) {
new JumpTheObstaclesFactory(),
// luiza e pedro cordeiro
new SpyFishFactory(),
new GatoFantasmaFactory()
new PhantomCatFactory()
)
), 0, 1, this, this);
hud = new Hud(this, this);
Expand Down

0 comments on commit 16f828d

Please sign in to comment.