diff --git a/android/assets/font.ttf b/android/assets/font.ttf new file mode 100644 index 0000000..dcca687 Binary files /dev/null and b/android/assets/font.ttf differ diff --git a/core/src/model/Level.java b/core/src/model/Level.java index 8e5de6f..5013791 100644 --- a/core/src/model/Level.java +++ b/core/src/model/Level.java @@ -63,11 +63,13 @@ public class Level { } public void horizontalCollision(){ - this.projectile.setvY(-this.projectile.getvY()); + this.projectile.setvY(-this.projectile.getvY() * 0.6); + this.projectile.setvX(this.projectile.getvX() * 0.9); } public void verticalCollision(){ - this.projectile.setvX(-this.projectile.getvX()); + this.projectile.setvX(-this.projectile.getvX() * 0.6); + this.projectile.setvY(this.projectile.getvY() * 0.9); } public void step(){ diff --git a/core/src/view/Levelscreen.java b/core/src/view/Levelscreen.java index 939aea7..9bd2de8 100644 --- a/core/src/view/Levelscreen.java +++ b/core/src/view/Levelscreen.java @@ -8,12 +8,15 @@ package view; import com.badlogic.gdx.Game; import com.badlogic.gdx.Gdx; import com.badlogic.gdx.Input; +import com.badlogic.gdx.files.FileHandle; import com.badlogic.gdx.graphics.Color; import com.badlogic.gdx.graphics.GL20; import com.badlogic.gdx.graphics.Texture; import com.badlogic.gdx.graphics.g2d.BitmapFont; +import com.badlogic.gdx.graphics.g2d.GlyphLayout; import com.badlogic.gdx.graphics.g2d.Sprite; import com.badlogic.gdx.graphics.g2d.SpriteBatch; +import com.badlogic.gdx.graphics.g2d.freetype.FreeTypeFontGenerator; import com.badlogic.gdx.utils.Timer; import model.Goal; import model.Level; @@ -49,7 +52,13 @@ public class Levelscreen{ selectedLevel = 0; this.levelAmount = levelAmount; - font = new BitmapFont(); + + FreeTypeFontGenerator generator = new FreeTypeFontGenerator(Gdx.files.internal("font.ttf")); + FreeTypeFontGenerator.FreeTypeFontParameter parameter = new FreeTypeFontGenerator.FreeTypeFontParameter(); + parameter.size = 21; + font = generator.generateFont(parameter); // font size 12 pixels + generator.dispose(); // don't forget to dispose to avoid memory leaks! + font.setColor(Color.BLACK); t = new Timer(); @@ -83,7 +92,11 @@ public class Levelscreen{ if(selectedLevel < levelAmount){ buttonRight.draw(batch); } + + font.getData().setScale(1); font.draw(batch, "" + selectedLevel, GAME_WORLD_WIDTH / 2, GAME_WORLD_HEIGHT / 2); + font.getData().setScale(6); + font.draw(batch,"LEVEL: "+ selectedLevel, GAME_WORLD_WIDTH / 2 - getTextWidth("LEVEL: "+ selectedLevel) / 2, GAME_WORLD_HEIGHT * 0.95f); } @@ -98,5 +111,11 @@ public class Levelscreen{ public int getSelectedLevel(){ return selectedLevel; } + public float getTextWidth(String text){ + GlyphLayout glyphLayout = new GlyphLayout(); + String item = text; + glyphLayout.setText(font,item); + return glyphLayout.width; + } }